2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
14 * From i386 code copyright (C) 1995 Linus Torvalds
17 #include <linux/signal.h>
18 #include <linux/sched.h>
19 #include <linux/kernel.h>
20 #include <linux/errno.h>
21 #include <linux/string.h>
22 #include <linux/types.h>
23 #include <linux/ptrace.h>
24 #include <linux/mman.h>
26 #include <linux/smp.h>
27 #include <linux/interrupt.h>
28 #include <linux/init.h>
29 #include <linux/tty.h>
30 #include <linux/vt_kern.h> /* For unblank_screen() */
31 #include <linux/highmem.h>
32 #include <linux/module.h>
33 #include <linux/kprobes.h>
34 #include <linux/hugetlb.h>
35 #include <linux/syscalls.h>
36 #include <linux/uaccess.h>
38 #include <asm/pgalloc.h>
39 #include <asm/sections.h>
40 #include <asm/traps.h>
41 #include <asm/syscalls.h>
43 #include <arch/interrupts.h>
45 static noinline
void force_sig_info_fault(const char *type
, int si_signo
,
46 int si_code
, unsigned long address
,
48 struct task_struct
*tsk
,
53 if (unlikely(tsk
->pid
< 2)) {
54 panic("Signal %d (code %d) at %#lx sent to %s!",
55 si_signo
, si_code
& 0xffff, address
,
56 is_idle_task(tsk
) ? "the idle task" : "init");
59 info
.si_signo
= si_signo
;
61 info
.si_code
= si_code
;
62 info
.si_addr
= (void __user
*)address
;
63 info
.si_trapno
= fault_num
;
64 trace_unhandled_signal(type
, regs
, address
, si_signo
);
65 force_sig_info(si_signo
, &info
, tsk
);
70 * Synthesize the fault a PL0 process would get by doing a word-load of
71 * an unaligned address or a high kernel address.
73 SYSCALL_DEFINE2(cmpxchg_badaddr
, unsigned long, address
,
74 struct pt_regs
*, regs
)
76 if (address
>= PAGE_OFFSET
)
77 force_sig_info_fault("atomic segfault", SIGSEGV
, SEGV_MAPERR
,
78 address
, INT_DTLB_MISS
, current
, regs
);
80 force_sig_info_fault("atomic alignment fault", SIGBUS
,
82 INT_UNALIGN_DATA
, current
, regs
);
85 * Adjust pc to point at the actual instruction, which is unusual
86 * for syscalls normally, but is appropriate when we are claiming
87 * that a syscall swint1 caused a page fault or bus error.
92 * Mark this as a caller-save interrupt, like a normal page fault,
93 * so that when we go through the signal handler path we will
94 * properly restore r0, r1, and r2 for the signal handler arguments.
96 regs
->flags
|= PT_FLAGS_CALLER_SAVES
;
102 static inline pmd_t
*vmalloc_sync_one(pgd_t
*pgd
, unsigned long address
)
104 unsigned index
= pgd_index(address
);
110 pgd_k
= init_mm
.pgd
+ index
;
112 if (!pgd_present(*pgd_k
))
115 pud
= pud_offset(pgd
, address
);
116 pud_k
= pud_offset(pgd_k
, address
);
117 if (!pud_present(*pud_k
))
120 pmd
= pmd_offset(pud
, address
);
121 pmd_k
= pmd_offset(pud_k
, address
);
122 if (!pmd_present(*pmd_k
))
124 if (!pmd_present(*pmd
)) {
125 set_pmd(pmd
, *pmd_k
);
126 arch_flush_lazy_mmu_mode();
128 BUG_ON(pmd_ptfn(*pmd
) != pmd_ptfn(*pmd_k
));
133 * Handle a fault on the vmalloc or module mapping area
135 static inline int vmalloc_fault(pgd_t
*pgd
, unsigned long address
)
140 /* Make sure we are in vmalloc area */
141 if (!(address
>= VMALLOC_START
&& address
< VMALLOC_END
))
145 * Synchronize this task's top level page-table
146 * with the 'reference' page table.
148 pmd_k
= vmalloc_sync_one(pgd
, address
);
151 if (pmd_huge(*pmd_k
))
152 return 0; /* support TILE huge_vmap() API */
153 pte_k
= pte_offset_kernel(pmd_k
, address
);
154 if (!pte_present(*pte_k
))
159 /* Wait until this PTE has completed migration. */
160 static void wait_for_migration(pte_t
*pte
)
162 if (pte_migrating(*pte
)) {
164 * Wait until the migrater fixes up this pte.
165 * We scale the loop count by the clock rate so we'll wait for
166 * a few seconds here.
169 int bound
= get_clock_rate();
170 while (pte_migrating(*pte
)) {
172 if (++retries
> bound
)
173 panic("Hit migrating PTE (%#llx) and"
174 " page PFN %#lx still migrating",
175 pte
->val
, pte_pfn(*pte
));
181 * It's not generally safe to use "current" to get the page table pointer,
182 * since we might be running an oprofile interrupt in the middle of a
185 static pgd_t
*get_current_pgd(void)
187 HV_Context ctx
= hv_inquire_context();
188 unsigned long pgd_pfn
= ctx
.page_table
>> PAGE_SHIFT
;
189 struct page
*pgd_page
= pfn_to_page(pgd_pfn
);
190 BUG_ON(PageHighMem(pgd_page
)); /* oops, HIGHPTE? */
191 return (pgd_t
*) __va(ctx
.page_table
);
195 * We can receive a page fault from a migrating PTE at any time.
196 * Handle it by just waiting until the fault resolves.
198 * It's also possible to get a migrating kernel PTE that resolves
199 * itself during the downcall from hypervisor to Linux. We just check
200 * here to see if the PTE seems valid, and if so we retry it.
202 * NOTE! We MUST NOT take any locks for this case. We may be in an
203 * interrupt or a critical region, and must do as little as possible.
204 * Similarly, we can't use atomic ops here, since we may be handling a
205 * fault caused by an atomic op access.
207 static int handle_migrating_pte(pgd_t
*pgd
, int fault_num
,
208 unsigned long address
,
209 int is_kernel_mode
, int write
)
216 if (pgd_addr_invalid(address
))
219 pgd
+= pgd_index(address
);
220 pud
= pud_offset(pgd
, address
);
221 if (!pud
|| !pud_present(*pud
))
223 pmd
= pmd_offset(pud
, address
);
224 if (!pmd
|| !pmd_present(*pmd
))
226 pte
= pmd_huge_page(*pmd
) ? ((pte_t
*)pmd
) :
227 pte_offset_kernel(pmd
, address
);
229 if (pte_migrating(pteval
)) {
230 wait_for_migration(pte
);
234 if (!is_kernel_mode
|| !pte_present(pteval
))
236 if (fault_num
== INT_ITLB_MISS
) {
237 if (pte_exec(pteval
))
240 if (pte_write(pteval
))
243 if (pte_read(pteval
))
251 * This routine is responsible for faulting in user pages.
252 * It passes the work off to one of the appropriate routines.
253 * It returns true if the fault was successfully handled.
255 static int handle_page_fault(struct pt_regs
*regs
,
258 unsigned long address
,
261 struct task_struct
*tsk
;
262 struct mm_struct
*mm
;
263 struct vm_area_struct
*vma
;
264 unsigned long stack_offset
;
270 /* on TILE, protection faults are always writes */
274 is_kernel_mode
= (EX1_PL(regs
->ex1
) != USER_PL
);
276 tsk
= validate_current();
279 * Check to see if we might be overwriting the stack, and bail
280 * out if so. The page fault code is a relatively likely
281 * place to get trapped in an infinite regress, and once we
282 * overwrite the whole stack, it becomes very hard to recover.
284 stack_offset
= stack_pointer
& (THREAD_SIZE
-1);
285 if (stack_offset
< THREAD_SIZE
/ 8) {
286 pr_alert("Potential stack overrun: sp %#lx\n",
289 pr_alert("Killing current process %d/%s\n",
290 tsk
->pid
, tsk
->comm
);
291 do_group_exit(SIGKILL
);
295 * Early on, we need to check for migrating PTE entries;
296 * see homecache.c. If we find a migrating PTE, we wait until
297 * the backing page claims to be done migrating, then we proceed.
298 * For kernel PTEs, we rewrite the PTE and return and retry.
299 * Otherwise, we treat the fault like a normal "no PTE" fault,
300 * rather than trying to patch up the existing PTE.
302 pgd
= get_current_pgd();
303 if (handle_migrating_pte(pgd
, fault_num
, address
,
304 is_kernel_mode
, write
))
307 si_code
= SEGV_MAPERR
;
310 * We fault-in kernel-space virtual memory on-demand. The
311 * 'reference' page table is init_mm.pgd.
313 * NOTE! We MUST NOT take any locks for this case. We may
314 * be in an interrupt or a critical region, and should
315 * only copy the information from the master page table,
318 * This verifies that the fault happens in kernel space
319 * and that the fault was not a protection fault.
321 if (unlikely(address
>= TASK_SIZE
&&
322 !is_arch_mappable_range(address
, 0))) {
323 if (is_kernel_mode
&& is_page_fault
&&
324 vmalloc_fault(pgd
, address
) >= 0)
327 * Don't take the mm semaphore here. If we fixup a prefetch
328 * fault we could otherwise deadlock.
330 mm
= NULL
; /* happy compiler */
332 goto bad_area_nosemaphore
;
336 * If we're trying to touch user-space addresses, we must
337 * be either at PL0, or else with interrupts enabled in the
338 * kernel, so either way we can re-enable interrupts here.
345 * If we're in an interrupt, have no user context or are running in an
346 * atomic region then we must not take the fault.
348 if (in_atomic() || !mm
) {
349 vma
= NULL
; /* happy compiler */
350 goto bad_area_nosemaphore
;
354 * When running in the kernel we expect faults to occur only to
355 * addresses in user space. All other faults represent errors in the
356 * kernel and should generate an OOPS. Unfortunately, in the case of an
357 * erroneous fault occurring in a code path which already holds mmap_sem
358 * we will deadlock attempting to validate the fault against the
359 * address space. Luckily the kernel only validly references user
360 * space from well defined areas of code, which are listed in the
363 * As the vast majority of faults will be valid we will only perform
364 * the source reference check when there is a possibility of a deadlock.
365 * Attempt to lock the address space, if we cannot we then validate the
366 * source. If this is invalid we can skip the address space check,
367 * thus avoiding the deadlock.
369 if (!down_read_trylock(&mm
->mmap_sem
)) {
370 if (is_kernel_mode
&&
371 !search_exception_tables(regs
->pc
)) {
372 vma
= NULL
; /* happy compiler */
373 goto bad_area_nosemaphore
;
375 down_read(&mm
->mmap_sem
);
378 vma
= find_vma(mm
, address
);
381 if (vma
->vm_start
<= address
)
383 if (!(vma
->vm_flags
& VM_GROWSDOWN
))
385 if (regs
->sp
< PAGE_OFFSET
) {
387 * accessing the stack below sp is always a bug.
389 if (address
< regs
->sp
)
392 if (expand_stack(vma
, address
))
396 * Ok, we have a good vm_area for this memory access, so
400 si_code
= SEGV_ACCERR
;
401 if (fault_num
== INT_ITLB_MISS
) {
402 if (!(vma
->vm_flags
& VM_EXEC
))
405 #ifdef TEST_VERIFY_AREA
406 if (!is_page_fault
&& regs
->cs
== KERNEL_CS
)
407 pr_err("WP fault at "REGFMT
"\n", regs
->eip
);
409 if (!(vma
->vm_flags
& VM_WRITE
))
412 if (!is_page_fault
|| !(vma
->vm_flags
& VM_READ
))
418 * If for any reason at all we couldn't handle the fault,
419 * make sure we exit gracefully rather than endlessly redo
422 fault
= handle_mm_fault(mm
, vma
, address
, write
);
423 if (unlikely(fault
& VM_FAULT_ERROR
)) {
424 if (fault
& VM_FAULT_OOM
)
426 else if (fault
& VM_FAULT_SIGBUS
)
430 if (fault
& VM_FAULT_MAJOR
)
435 #if CHIP_HAS_TILE_DMA() || CHIP_HAS_SN_PROC()
437 * If this was an asynchronous fault,
438 * restart the appropriate engine.
441 #if CHIP_HAS_TILE_DMA()
442 case INT_DMATLB_MISS
:
443 case INT_DMATLB_MISS_DWNCL
:
444 case INT_DMATLB_ACCESS
:
445 case INT_DMATLB_ACCESS_DWNCL
:
446 __insn_mtspr(SPR_DMA_CTR
, SPR_DMA_CTR__REQUEST_MASK
);
449 #if CHIP_HAS_SN_PROC()
450 case INT_SNITLB_MISS
:
451 case INT_SNITLB_MISS_DWNCL
:
452 __insn_mtspr(SPR_SNCTL
,
453 __insn_mfspr(SPR_SNCTL
) &
454 ~SPR_SNCTL__FRZPROC_MASK
);
460 up_read(&mm
->mmap_sem
);
464 * Something tried to access memory that isn't in our memory map..
465 * Fix it, but check if it's kernel or user first..
468 up_read(&mm
->mmap_sem
);
470 bad_area_nosemaphore
:
471 /* User mode accesses just cause a SIGSEGV */
472 if (!is_kernel_mode
) {
474 * It's possible to have interrupts off here.
478 force_sig_info_fault("segfault", SIGSEGV
, si_code
, address
,
479 fault_num
, tsk
, regs
);
484 /* Are we prepared to handle this kernel fault? */
485 if (fixup_exception(regs
))
489 * Oops. The kernel tried to access some bad page. We'll have to
490 * terminate things with extreme prejudice.
495 /* FIXME: no lookup_address() yet */
496 #ifdef SUPPORT_LOOKUP_ADDRESS
497 if (fault_num
== INT_ITLB_MISS
) {
498 pte_t
*pte
= lookup_address(address
);
500 if (pte
&& pte_present(*pte
) && !pte_exec_kernel(*pte
))
501 pr_crit("kernel tried to execute"
502 " non-executable page - exploit attempt?"
503 " (uid: %d)\n", current
->uid
);
506 if (address
< PAGE_SIZE
)
507 pr_alert("Unable to handle kernel NULL pointer dereference\n");
509 pr_alert("Unable to handle kernel paging request\n");
510 pr_alert(" at virtual address "REGFMT
", pc "REGFMT
"\n",
515 if (unlikely(tsk
->pid
< 2)) {
516 panic("Kernel page fault running %s!",
517 is_idle_task(tsk
) ? "the idle task" : "init");
521 * More FIXME: we should probably copy the i386 here and
522 * implement a generic die() routine. Not today.
529 do_group_exit(SIGKILL
);
532 * We ran out of memory, or some other thing happened to us that made
533 * us unable to handle the page fault gracefully.
536 up_read(&mm
->mmap_sem
);
537 if (is_global_init(tsk
)) {
539 down_read(&mm
->mmap_sem
);
542 pr_alert("VM: killing process %s\n", tsk
->comm
);
544 do_group_exit(SIGKILL
);
548 up_read(&mm
->mmap_sem
);
550 /* Kernel mode? Handle exceptions or die */
554 force_sig_info_fault("bus error", SIGBUS
, BUS_ADRERR
, address
,
555 fault_num
, tsk
, regs
);
561 /* We must release ICS before panicking or we won't get anywhere. */
562 #define ics_panic(fmt, ...) do { \
563 __insn_mtspr(SPR_INTERRUPT_CRITICAL_SECTION, 0); \
564 panic(fmt, __VA_ARGS__); \
568 * When we take an ITLB or DTLB fault or access violation in the
569 * supervisor while the critical section bit is set, the hypervisor is
570 * reluctant to write new values into the EX_CONTEXT_K_x registers,
571 * since that might indicate we have not yet squirreled the SPR
572 * contents away and can thus safely take a recursive interrupt.
573 * Accordingly, the hypervisor passes us the PC via SYSTEM_SAVE_K_2.
575 * Note that this routine is called before homecache_tlb_defer_enter(),
576 * which means that we can properly unlock any atomics that might
577 * be used there (good), but also means we must be very sensitive
578 * to not touch any data structures that might be located in memory
579 * that could migrate, as we could be entering the kernel on a dataplane
580 * cpu that has been deferring kernel TLB updates. This means, for
581 * example, that we can't migrate init_mm or its pgd.
583 struct intvec_state
do_page_fault_ics(struct pt_regs
*regs
, int fault_num
,
584 unsigned long address
,
587 unsigned long pc
= info
& ~1;
588 int write
= info
& 1;
589 pgd_t
*pgd
= get_current_pgd();
591 /* Retval is 1 at first since we will handle the fault fully. */
592 struct intvec_state state
= {
593 do_page_fault
, fault_num
, address
, write
, 1
596 /* Validate that we are plausibly in the right routine. */
597 if ((pc
& 0x7) != 0 || pc
< PAGE_OFFSET
||
598 (fault_num
!= INT_DTLB_MISS
&&
599 fault_num
!= INT_DTLB_ACCESS
)) {
600 unsigned long old_pc
= regs
->pc
;
602 ics_panic("Bad ICS page fault args:"
603 " old PC %#lx, fault %d/%d at %#lx\n",
604 old_pc
, fault_num
, write
, address
);
607 /* We might be faulting on a vmalloc page, so check that first. */
608 if (fault_num
!= INT_DTLB_ACCESS
&& vmalloc_fault(pgd
, address
) >= 0)
612 * If we faulted with ICS set in sys_cmpxchg, we are providing
613 * a user syscall service that should generate a signal on
614 * fault. We didn't set up a kernel stack on initial entry to
615 * sys_cmpxchg, but instead had one set up by the fault, which
616 * (because sys_cmpxchg never releases ICS) came to us via the
617 * SYSTEM_SAVE_K_2 mechanism, and thus EX_CONTEXT_K_[01] are
618 * still referencing the original user code. We release the
619 * atomic lock and rewrite pt_regs so that it appears that we
620 * came from user-space directly, and after we finish the
621 * fault we'll go back to user space and re-issue the swint.
622 * This way the backtrace information is correct if we need to
623 * emit a stack dump at any point while handling this.
625 * Must match register use in sys_cmpxchg().
627 if (pc
>= (unsigned long) sys_cmpxchg
&&
628 pc
< (unsigned long) __sys_cmpxchg_end
) {
630 /* Don't unlock before we could have locked. */
631 if (pc
>= (unsigned long)__sys_cmpxchg_grab_lock
) {
632 int *lock_ptr
= (int *)(regs
->regs
[ATOMIC_LOCK_REG
]);
633 __atomic_fault_unlock(lock_ptr
);
636 regs
->sp
= regs
->regs
[27];
640 * We can also fault in the atomic assembly, in which
641 * case we use the exception table to do the first-level fixup.
642 * We may re-fixup again in the real fault handler if it
643 * turns out the faulting address is just bad, and not,
644 * for example, migrating.
646 else if (pc
>= (unsigned long) __start_atomic_asm_code
&&
647 pc
< (unsigned long) __end_atomic_asm_code
) {
648 const struct exception_table_entry
*fixup
;
650 /* Unlock the atomic lock. */
651 int *lock_ptr
= (int *)(regs
->regs
[ATOMIC_LOCK_REG
]);
652 __atomic_fault_unlock(lock_ptr
);
654 fixup
= search_exception_tables(pc
);
656 ics_panic("ICS atomic fault not in table:"
657 " PC %#lx, fault %d", pc
, fault_num
);
658 regs
->pc
= fixup
->fixup
;
659 regs
->ex1
= PL_ICS_EX1(KERNEL_PL
, 0);
663 * Now that we have released the atomic lock (if necessary),
664 * it's safe to spin if the PTE that caused the fault was migrating.
666 if (fault_num
== INT_DTLB_ACCESS
)
668 if (handle_migrating_pte(pgd
, fault_num
, address
, 1, write
))
671 /* Return zero so that we continue on with normal fault handling. */
676 #endif /* !__tilegx__ */
679 * This routine handles page faults. It determines the address, and the
680 * problem, and then passes it handle_page_fault() for normal DTLB and
681 * ITLB issues, and for DMA or SN processor faults when we are in user
682 * space. For the latter, if we're in kernel mode, we just save the
683 * interrupt away appropriately and return immediately. We can't do
684 * page faults for user code while in kernel mode.
686 void do_page_fault(struct pt_regs
*regs
, int fault_num
,
687 unsigned long address
, unsigned long write
)
691 /* This case should have been handled by do_page_fault_ics(). */
694 #if CHIP_HAS_TILE_DMA()
696 * If it's a DMA fault, suspend the transfer while we're
697 * handling the miss; we'll restart after it's handled. If we
698 * don't suspend, it's possible that this process could swap
699 * out and back in, and restart the engine since the DMA is
702 if (fault_num
== INT_DMATLB_MISS
||
703 fault_num
== INT_DMATLB_ACCESS
||
704 fault_num
== INT_DMATLB_MISS_DWNCL
||
705 fault_num
== INT_DMATLB_ACCESS_DWNCL
) {
706 __insn_mtspr(SPR_DMA_CTR
, SPR_DMA_CTR__SUSPEND_MASK
);
707 while (__insn_mfspr(SPR_DMA_USER_STATUS
) &
708 SPR_DMA_STATUS__BUSY_MASK
)
713 /* Validate fault num and decide if this is a first-time page fault. */
717 #if CHIP_HAS_TILE_DMA()
718 case INT_DMATLB_MISS
:
719 case INT_DMATLB_MISS_DWNCL
:
721 #if CHIP_HAS_SN_PROC()
722 case INT_SNITLB_MISS
:
723 case INT_SNITLB_MISS_DWNCL
:
728 case INT_DTLB_ACCESS
:
729 #if CHIP_HAS_TILE_DMA()
730 case INT_DMATLB_ACCESS
:
731 case INT_DMATLB_ACCESS_DWNCL
:
737 panic("Bad fault number %d in do_page_fault", fault_num
);
740 #if CHIP_HAS_TILE_DMA() || CHIP_HAS_SN_PROC()
741 if (EX1_PL(regs
->ex1
) != USER_PL
) {
742 struct async_tlb
*async
;
744 #if CHIP_HAS_TILE_DMA()
745 case INT_DMATLB_MISS
:
746 case INT_DMATLB_ACCESS
:
747 case INT_DMATLB_MISS_DWNCL
:
748 case INT_DMATLB_ACCESS_DWNCL
:
749 async
= ¤t
->thread
.dma_async_tlb
;
752 #if CHIP_HAS_SN_PROC()
753 case INT_SNITLB_MISS
:
754 case INT_SNITLB_MISS_DWNCL
:
755 async
= ¤t
->thread
.sn_async_tlb
;
764 * No vmalloc check required, so we can allow
765 * interrupts immediately at this point.
769 set_thread_flag(TIF_ASYNC_TLB
);
770 if (async
->fault_num
!= 0) {
771 panic("Second async fault %d;"
772 " old fault was %d (%#lx/%ld)",
773 fault_num
, async
->fault_num
,
776 BUG_ON(fault_num
== 0);
777 async
->fault_num
= fault_num
;
778 async
->is_fault
= is_page_fault
;
779 async
->is_write
= write
;
780 async
->address
= address
;
786 handle_page_fault(regs
, fault_num
, is_page_fault
, address
, write
);
790 #if CHIP_HAS_TILE_DMA() || CHIP_HAS_SN_PROC()
792 * Check an async_tlb structure to see if a deferred fault is waiting,
793 * and if so pass it to the page-fault code.
795 static void handle_async_page_fault(struct pt_regs
*regs
,
796 struct async_tlb
*async
)
798 if (async
->fault_num
) {
800 * Clear async->fault_num before calling the page-fault
801 * handler so that if we re-interrupt before returning
802 * from the function we have somewhere to put the
803 * information from the new interrupt.
805 int fault_num
= async
->fault_num
;
806 async
->fault_num
= 0;
807 handle_page_fault(regs
, fault_num
, async
->is_fault
,
808 async
->address
, async
->is_write
);
813 * This routine effectively re-issues asynchronous page faults
814 * when we are returning to user space.
816 void do_async_page_fault(struct pt_regs
*regs
)
819 * Clear thread flag early. If we re-interrupt while processing
820 * code here, we will reset it and recall this routine before
821 * returning to user space.
823 clear_thread_flag(TIF_ASYNC_TLB
);
825 #if CHIP_HAS_TILE_DMA()
826 handle_async_page_fault(regs
, ¤t
->thread
.dma_async_tlb
);
828 #if CHIP_HAS_SN_PROC()
829 handle_async_page_fault(regs
, ¤t
->thread
.sn_async_tlb
);
832 #endif /* CHIP_HAS_TILE_DMA() || CHIP_HAS_SN_PROC() */
835 void vmalloc_sync_all(void)
838 /* Currently all L1 kernel pmd's are static and shared. */
839 BUG_ON(pgd_index(VMALLOC_END
) != pgd_index(VMALLOC_START
));
842 * Note that races in the updates of insync and start aren't
843 * problematic: insync can only get set bits added, and updates to
844 * start are only improving performance (without affecting correctness
847 static DECLARE_BITMAP(insync
, PTRS_PER_PGD
);
848 static unsigned long start
= PAGE_OFFSET
;
849 unsigned long address
;
851 BUILD_BUG_ON(PAGE_OFFSET
& ~PGDIR_MASK
);
852 for (address
= start
; address
>= PAGE_OFFSET
; address
+= PGDIR_SIZE
) {
853 if (!test_bit(pgd_index(address
), insync
)) {
855 struct list_head
*pos
;
857 spin_lock_irqsave(&pgd_lock
, flags
);
858 list_for_each(pos
, &pgd_list
)
859 if (!vmalloc_sync_one(list_to_pgd(pos
),
861 /* Must be at first entry in list. */
862 BUG_ON(pos
!= pgd_list
.next
);
865 spin_unlock_irqrestore(&pgd_lock
, flags
);
866 if (pos
!= pgd_list
.next
)
867 set_bit(pgd_index(address
), insync
);
869 if (address
== start
&& test_bit(pgd_index(address
), insync
))
870 start
= address
+ PGDIR_SIZE
;