~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/arch/um/kernel/trap_kern.c

Version: ~ [ 0.6-2.3.46 ] ~
Architecture: ~ [ um ] ~

** Warning: Cannot open xref database.

1 #include "linux/kernel.h" 2 #include "linux/sched.h" 3 #include "linux/mm.h" 4 #include "linux/spinlock.h" 5 #include "asm/semaphore.h" 6 #include "asm/pgtable.h" 7 #include "asm/pgalloc.h" 8 #include "asm/a.out.h" 9 #include "user_util.h" 10 #include "kern_util.h" 11 12 extern int nsyscalls; 13 14 void segv(unsigned long address, int is_write) 15 { 16 struct mm_struct *mm = current->mm; 17 struct vm_area_struct *vma; 18 pgd_t *pgd; 19 pmd_t *pmd; 20 pte_t *pte; 21 unsigned long page; 22 int n; 23 static unsigned long last_address = 0; 24 static int last_is_write = 0, last_nsyscalls; 25 static struct task_struct *last_task = NULL; 26 27 if((address == last_address) && (last_is_write == is_write) && 28 (last_task == current) && (last_nsyscalls == nsyscalls)){ 29 KERN_UNTESTED(); 30 } 31 #ifdef notdef 32 if(!strcmp(current->comm, "K15httpd") && (current->thread.nsyscalls > 300) && 33 (address == 0x40103cc0)){ 34 printk("K15httpd segfaulting at 0x%p\n", address); 35 KERN_UNTESTED(); 36 } 37 #endif 38 last_address = address; 39 last_is_write = is_write; 40 last_task = current; 41 last_nsyscalls = nsyscalls; 42 down(&mm->mmap_sem); 43 vma = find_vma(mm, address); 44 if(!vma) panic("No vma in segv"); 45 if((vma->vm_start > address) && (vma->vm_flags != VM_STACK_FLAGS)) 46 panic("Bogus address in segv"); 47 page = address & PAGE_MASK; 48 pgd = pgd_offset(mm, page); 49 pmd = pmd_offset(pgd, page); 50 if(current->thread.starting_exec && pmd_present(*pmd) && 51 pte_present(*pte_offset(pmd, page))){ 52 up(&mm->mmap_sem); 53 flush_tlb_range(mm, page, page + PAGE_SIZE); 54 return; 55 } 56 if(((vma->vm_flags & VM_GROWSDOWN) != 0) && (vma->vm_start > page)){ 57 if(expand_stack(vma, address)) panic("expand_stack failed"); 58 } 59 do { 60 if((n = handle_mm_fault(current, vma, address, is_write)) <= 0){ 61 printk("handle_mm_fault returned %d\n", n); 62 force_sigbus(); 63 } 64 pte = pte_offset(pmd, page); 65 } while(is_write && (n > 0) && !pte_write(*pte)); 66 if(is_write && !pte_write(*pte)) panic("page not writeable"); 67 if(!is_write && !pte_present(*pte)){ 68 printk("Page disappeared while handling fault"); 69 force_sigbus(); 70 } 71 flush_tlb_range(mm, page, page + PAGE_SIZE); 72 up(&mm->mmap_sem); 73 } 74 75 void trap_init(void) 76 { 77 } 78 79 void flush_thread(void) 80 { 81 flush_tlb_all(); 82 current->thread.starting_exec = 1; 83 } 84 85 spinlock_t trap_lock = SPIN_LOCK_UNLOCKED; 86 87 void lock_trap(void) 88 { 89 spin_lock(&trap_lock); 90 } 91 92 void unlock_trap(void) 93 { 94 spin_unlock(&trap_lock); 95 } 96 97

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.