fault_32.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /*
  2. * Copyright (C) 1995 Linus Torvalds
  3. */
  4. #include <linux/signal.h>
  5. #include <linux/sched.h>
  6. #include <linux/kernel.h>
  7. #include <linux/errno.h>
  8. #include <linux/string.h>
  9. #include <linux/types.h>
  10. #include <linux/ptrace.h>
  11. #include <linux/mman.h>
  12. #include <linux/mm.h>
  13. #include <linux/smp.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/init.h>
  16. #include <linux/tty.h>
  17. #include <linux/vt_kern.h> /* For unblank_screen() */
  18. #include <linux/highmem.h>
  19. #include <linux/bootmem.h> /* for max_low_pfn */
  20. #include <linux/vmalloc.h>
  21. #include <linux/module.h>
  22. #include <linux/kprobes.h>
  23. #include <linux/uaccess.h>
  24. #include <linux/kdebug.h>
  25. #include <asm/system.h>
  26. #include <asm/desc.h>
  27. #include <asm/segment.h>
  28. /*
  29. * Page fault error code bits
  30. * bit 0 == 0 means no page found, 1 means protection fault
  31. * bit 1 == 0 means read, 1 means write
  32. * bit 2 == 0 means kernel, 1 means user-mode
  33. * bit 3 == 1 means use of reserved bit detected
  34. * bit 4 == 1 means fault was an instruction fetch
  35. */
  36. #define PF_PROT (1<<0)
  37. #define PF_WRITE (1<<1)
  38. #define PF_USER (1<<2)
  39. #define PF_RSVD (1<<3)
  40. #define PF_INSTR (1<<4)
  41. static inline int notify_page_fault(struct pt_regs *regs)
  42. {
  43. #ifdef CONFIG_KPROBES
  44. int ret = 0;
  45. /* kprobe_running() needs smp_processor_id() */
  46. if (!user_mode_vm(regs)) {
  47. preempt_disable();
  48. if (kprobe_running() && kprobe_fault_handler(regs, 14))
  49. ret = 1;
  50. preempt_enable();
  51. }
  52. return ret;
  53. #else
  54. return 0;
  55. #endif
  56. }
  57. /*
  58. * Return EIP plus the CS segment base. The segment limit is also
  59. * adjusted, clamped to the kernel/user address space (whichever is
  60. * appropriate), and returned in *eip_limit.
  61. *
  62. * The segment is checked, because it might have been changed by another
  63. * task between the original faulting instruction and here.
  64. *
  65. * If CS is no longer a valid code segment, or if EIP is beyond the
  66. * limit, or if it is a kernel address when CS is not a kernel segment,
  67. * then the returned value will be greater than *eip_limit.
  68. *
  69. * This is slow, but is very rarely executed.
  70. */
  71. static inline unsigned long get_segment_eip(struct pt_regs *regs,
  72. unsigned long *eip_limit)
  73. {
  74. unsigned long ip = regs->ip;
  75. unsigned seg = regs->cs & 0xffff;
  76. u32 seg_ar, seg_limit, base, *desc;
  77. /* Unlikely, but must come before segment checks. */
  78. if (unlikely(regs->flags & VM_MASK)) {
  79. base = seg << 4;
  80. *eip_limit = base + 0xffff;
  81. return base + (ip & 0xffff);
  82. }
  83. /* The standard kernel/user address space limit. */
  84. *eip_limit = user_mode(regs) ? USER_DS.seg : KERNEL_DS.seg;
  85. /* By far the most common cases. */
  86. if (likely(SEGMENT_IS_FLAT_CODE(seg)))
  87. return ip;
  88. /* Check the segment exists, is within the current LDT/GDT size,
  89. that kernel/user (ring 0..3) has the appropriate privilege,
  90. that it's a code segment, and get the limit. */
  91. __asm__ ("larl %3,%0; lsll %3,%1"
  92. : "=&r" (seg_ar), "=r" (seg_limit) : "0" (0), "rm" (seg));
  93. if ((~seg_ar & 0x9800) || ip > seg_limit) {
  94. *eip_limit = 0;
  95. return 1; /* So that returned ip > *eip_limit. */
  96. }
  97. /* Get the GDT/LDT descriptor base.
  98. When you look for races in this code remember that
  99. LDT and other horrors are only used in user space. */
  100. if (seg & (1<<2)) {
  101. /* Must lock the LDT while reading it. */
  102. mutex_lock(&current->mm->context.lock);
  103. desc = current->mm->context.ldt;
  104. desc = (void *)desc + (seg & ~7);
  105. } else {
  106. /* Must disable preemption while reading the GDT. */
  107. desc = (u32 *)get_cpu_gdt_table(get_cpu());
  108. desc = (void *)desc + (seg & ~7);
  109. }
  110. /* Decode the code segment base from the descriptor */
  111. base = get_desc_base((struct desc_struct *)desc);
  112. if (seg & (1<<2))
  113. mutex_unlock(&current->mm->context.lock);
  114. else
  115. put_cpu();
  116. /* Adjust EIP and segment limit, and clamp at the kernel limit.
  117. It's legitimate for segments to wrap at 0xffffffff. */
  118. seg_limit += base;
  119. if (seg_limit < *eip_limit && seg_limit >= base)
  120. *eip_limit = seg_limit;
  121. return ip + base;
  122. }
  123. /*
  124. * Sometimes AMD Athlon/Opteron CPUs report invalid exceptions on prefetch.
  125. * Check that here and ignore it.
  126. */
  127. static int __is_prefetch(struct pt_regs *regs, unsigned long addr)
  128. {
  129. unsigned long limit;
  130. unsigned char *instr = (unsigned char *)get_segment_eip(regs, &limit);
  131. int scan_more = 1;
  132. int prefetch = 0;
  133. int i;
  134. for (i = 0; scan_more && i < 15; i++) {
  135. unsigned char opcode;
  136. unsigned char instr_hi;
  137. unsigned char instr_lo;
  138. if (instr > (unsigned char *)limit)
  139. break;
  140. if (probe_kernel_address(instr, opcode))
  141. break;
  142. instr_hi = opcode & 0xf0;
  143. instr_lo = opcode & 0x0f;
  144. instr++;
  145. switch (instr_hi) {
  146. case 0x20:
  147. case 0x30:
  148. /*
  149. * Values 0x26,0x2E,0x36,0x3E are valid x86 prefixes.
  150. * In X86_64 long mode, the CPU will signal invalid
  151. * opcode if some of these prefixes are present so
  152. * X86_64 will never get here anyway
  153. */
  154. scan_more = ((instr_lo & 7) == 0x6);
  155. break;
  156. #ifdef CONFIG_X86_64
  157. case 0x40:
  158. /*
  159. * In AMD64 long mode 0x40..0x4F are valid REX prefixes
  160. * Need to figure out under what instruction mode the
  161. * instruction was issued. Could check the LDT for lm,
  162. * but for now it's good enough to assume that long
  163. * mode only uses well known segments or kernel.
  164. */
  165. scan_more = (!user_mode(regs)) || (regs->cs == __USER_CS);
  166. break;
  167. #endif
  168. case 0x60:
  169. /* 0x64 thru 0x67 are valid prefixes in all modes. */
  170. scan_more = (instr_lo & 0xC) == 0x4;
  171. break;
  172. case 0xF0:
  173. /* 0xF0, 0xF2, 0xF3 are valid prefixes in all modes. */
  174. scan_more = !instr_lo || (instr_lo>>1) == 1;
  175. break;
  176. case 0x00:
  177. /* Prefetch instruction is 0x0F0D or 0x0F18 */
  178. scan_more = 0;
  179. if (instr > (unsigned char *)limit)
  180. break;
  181. if (probe_kernel_address(instr, opcode))
  182. break;
  183. prefetch = (instr_lo == 0xF) &&
  184. (opcode == 0x0D || opcode == 0x18);
  185. break;
  186. default:
  187. scan_more = 0;
  188. break;
  189. }
  190. }
  191. return prefetch;
  192. }
  193. static inline int is_prefetch(struct pt_regs *regs, unsigned long addr,
  194. unsigned long error_code)
  195. {
  196. if (unlikely(boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
  197. boot_cpu_data.x86 >= 6)) {
  198. /* Catch an obscure case of prefetch inside an NX page. */
  199. if (nx_enabled && (error_code & 16))
  200. return 0;
  201. return __is_prefetch(regs, addr);
  202. }
  203. return 0;
  204. }
  205. static noinline void force_sig_info_fault(int si_signo, int si_code,
  206. unsigned long address, struct task_struct *tsk)
  207. {
  208. siginfo_t info;
  209. info.si_signo = si_signo;
  210. info.si_errno = 0;
  211. info.si_code = si_code;
  212. info.si_addr = (void __user *)address;
  213. force_sig_info(si_signo, &info, tsk);
  214. }
  215. void do_invalid_op(struct pt_regs *, unsigned long);
  216. static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address)
  217. {
  218. unsigned index = pgd_index(address);
  219. pgd_t *pgd_k;
  220. pud_t *pud, *pud_k;
  221. pmd_t *pmd, *pmd_k;
  222. pgd += index;
  223. pgd_k = init_mm.pgd + index;
  224. if (!pgd_present(*pgd_k))
  225. return NULL;
  226. /*
  227. * set_pgd(pgd, *pgd_k); here would be useless on PAE
  228. * and redundant with the set_pmd() on non-PAE. As would
  229. * set_pud.
  230. */
  231. pud = pud_offset(pgd, address);
  232. pud_k = pud_offset(pgd_k, address);
  233. if (!pud_present(*pud_k))
  234. return NULL;
  235. pmd = pmd_offset(pud, address);
  236. pmd_k = pmd_offset(pud_k, address);
  237. if (!pmd_present(*pmd_k))
  238. return NULL;
  239. if (!pmd_present(*pmd)) {
  240. set_pmd(pmd, *pmd_k);
  241. arch_flush_lazy_mmu_mode();
  242. } else
  243. BUG_ON(pmd_page(*pmd) != pmd_page(*pmd_k));
  244. return pmd_k;
  245. }
  246. /*
  247. * Handle a fault on the vmalloc or module mapping area
  248. *
  249. * This assumes no large pages in there.
  250. */
  251. static inline int vmalloc_fault(unsigned long address)
  252. {
  253. unsigned long pgd_paddr;
  254. pmd_t *pmd_k;
  255. pte_t *pte_k;
  256. /*
  257. * Synchronize this task's top level page-table
  258. * with the 'reference' page table.
  259. *
  260. * Do _not_ use "current" here. We might be inside
  261. * an interrupt in the middle of a task switch..
  262. */
  263. pgd_paddr = read_cr3();
  264. pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
  265. if (!pmd_k)
  266. return -1;
  267. pte_k = pte_offset_kernel(pmd_k, address);
  268. if (!pte_present(*pte_k))
  269. return -1;
  270. return 0;
  271. }
  272. int show_unhandled_signals = 1;
  273. /*
  274. * This routine handles page faults. It determines the address,
  275. * and the problem, and then passes it off to one of the appropriate
  276. * routines.
  277. */
  278. void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
  279. {
  280. struct task_struct *tsk;
  281. struct mm_struct *mm;
  282. struct vm_area_struct *vma;
  283. unsigned long address;
  284. int write, si_code;
  285. int fault;
  286. /*
  287. * We can fault from pretty much anywhere, with unknown IRQ state.
  288. */
  289. trace_hardirqs_fixup();
  290. /* get the address */
  291. address = read_cr2();
  292. tsk = current;
  293. si_code = SEGV_MAPERR;
  294. /*
  295. * We fault-in kernel-space virtual memory on-demand. The
  296. * 'reference' page table is init_mm.pgd.
  297. *
  298. * NOTE! We MUST NOT take any locks for this case. We may
  299. * be in an interrupt or a critical region, and should
  300. * only copy the information from the master page table,
  301. * nothing more.
  302. *
  303. * This verifies that the fault happens in kernel space
  304. * (error_code & 4) == 0, and that the fault was not a
  305. * protection error (error_code & 9) == 0.
  306. */
  307. if (unlikely(address >= TASK_SIZE)) {
  308. if (!(error_code & 0x0000000d) && vmalloc_fault(address) >= 0)
  309. return;
  310. if (notify_page_fault(regs))
  311. return;
  312. /*
  313. * Don't take the mm semaphore here. If we fixup a prefetch
  314. * fault we could otherwise deadlock.
  315. */
  316. goto bad_area_nosemaphore;
  317. }
  318. if (notify_page_fault(regs))
  319. return;
  320. /* It's safe to allow irq's after cr2 has been saved and the vmalloc
  321. fault has been handled. */
  322. if (regs->flags & (X86_EFLAGS_IF|VM_MASK))
  323. local_irq_enable();
  324. mm = tsk->mm;
  325. /*
  326. * If we're in an interrupt, have no user context or are running in an
  327. * atomic region then we must not take the fault.
  328. */
  329. if (in_atomic() || !mm)
  330. goto bad_area_nosemaphore;
  331. /* When running in the kernel we expect faults to occur only to
  332. * addresses in user space. All other faults represent errors in the
  333. * kernel and should generate an OOPS. Unfortunately, in the case of an
  334. * erroneous fault occurring in a code path which already holds mmap_sem
  335. * we will deadlock attempting to validate the fault against the
  336. * address space. Luckily the kernel only validly references user
  337. * space from well defined areas of code, which are listed in the
  338. * exceptions table.
  339. *
  340. * As the vast majority of faults will be valid we will only perform
  341. * the source reference check when there is a possibility of a deadlock.
  342. * Attempt to lock the address space, if we cannot we then validate the
  343. * source. If this is invalid we can skip the address space check,
  344. * thus avoiding the deadlock.
  345. */
  346. if (!down_read_trylock(&mm->mmap_sem)) {
  347. if ((error_code & PF_USER) == 0 &&
  348. !search_exception_tables(regs->ip))
  349. goto bad_area_nosemaphore;
  350. down_read(&mm->mmap_sem);
  351. }
  352. vma = find_vma(mm, address);
  353. if (!vma)
  354. goto bad_area;
  355. if (vma->vm_start <= address)
  356. goto good_area;
  357. if (!(vma->vm_flags & VM_GROWSDOWN))
  358. goto bad_area;
  359. if (error_code & PF_USER) {
  360. /*
  361. * Accessing the stack below %sp is always a bug.
  362. * The large cushion allows instructions like enter
  363. * and pusha to work. ("enter $65535,$31" pushes
  364. * 32 pointers and then decrements %sp by 65535.)
  365. */
  366. if (address + 65536 + 32 * sizeof(unsigned long) < regs->sp)
  367. goto bad_area;
  368. }
  369. if (expand_stack(vma, address))
  370. goto bad_area;
  371. /*
  372. * Ok, we have a good vm_area for this memory access, so
  373. * we can handle it..
  374. */
  375. good_area:
  376. si_code = SEGV_ACCERR;
  377. write = 0;
  378. switch (error_code & (PF_PROT|PF_WRITE)) {
  379. default: /* 3: write, present */
  380. /* fall through */
  381. case PF_WRITE: /* write, not present */
  382. if (!(vma->vm_flags & VM_WRITE))
  383. goto bad_area;
  384. write++;
  385. break;
  386. case PF_PROT: /* read, present */
  387. goto bad_area;
  388. case 0: /* read, not present */
  389. if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
  390. goto bad_area;
  391. }
  392. survive:
  393. /*
  394. * If for any reason at all we couldn't handle the fault,
  395. * make sure we exit gracefully rather than endlessly redo
  396. * the fault.
  397. */
  398. fault = handle_mm_fault(mm, vma, address, write);
  399. if (unlikely(fault & VM_FAULT_ERROR)) {
  400. if (fault & VM_FAULT_OOM)
  401. goto out_of_memory;
  402. else if (fault & VM_FAULT_SIGBUS)
  403. goto do_sigbus;
  404. BUG();
  405. }
  406. if (fault & VM_FAULT_MAJOR)
  407. tsk->maj_flt++;
  408. else
  409. tsk->min_flt++;
  410. /*
  411. * Did it hit the DOS screen memory VA from vm86 mode?
  412. */
  413. if (regs->flags & VM_MASK) {
  414. unsigned long bit = (address - 0xA0000) >> PAGE_SHIFT;
  415. if (bit < 32)
  416. tsk->thread.screen_bitmap |= 1 << bit;
  417. }
  418. up_read(&mm->mmap_sem);
  419. return;
  420. /*
  421. * Something tried to access memory that isn't in our memory map..
  422. * Fix it, but check if it's kernel or user first..
  423. */
  424. bad_area:
  425. up_read(&mm->mmap_sem);
  426. bad_area_nosemaphore:
  427. /* User mode accesses just cause a SIGSEGV */
  428. if (error_code & PF_USER) {
  429. /*
  430. * It's possible to have interrupts off here.
  431. */
  432. local_irq_enable();
  433. /*
  434. * Valid to do another page fault here because this one came
  435. * from user space.
  436. */
  437. if (is_prefetch(regs, address, error_code))
  438. return;
  439. if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
  440. printk_ratelimit()) {
  441. printk("%s%s[%d]: segfault at %08lx ip %08lx "
  442. "sp %08lx error %lx\n",
  443. task_pid_nr(tsk) > 1 ? KERN_INFO : KERN_EMERG,
  444. tsk->comm, task_pid_nr(tsk), address, regs->ip,
  445. regs->sp, error_code);
  446. }
  447. tsk->thread.cr2 = address;
  448. /* Kernel addresses are always protection faults */
  449. tsk->thread.error_code = error_code | (address >= TASK_SIZE);
  450. tsk->thread.trap_no = 14;
  451. force_sig_info_fault(SIGSEGV, si_code, address, tsk);
  452. return;
  453. }
  454. #ifdef CONFIG_X86_F00F_BUG
  455. /*
  456. * Pentium F0 0F C7 C8 bug workaround.
  457. */
  458. if (boot_cpu_data.f00f_bug) {
  459. unsigned long nr;
  460. nr = (address - idt_descr.address) >> 3;
  461. if (nr == 6) {
  462. do_invalid_op(regs, 0);
  463. return;
  464. }
  465. }
  466. #endif
  467. no_context:
  468. /* Are we prepared to handle this kernel fault? */
  469. if (fixup_exception(regs))
  470. return;
  471. /*
  472. * Valid to do another page fault here, because if this fault
  473. * had been triggered by is_prefetch fixup_exception would have
  474. * handled it.
  475. */
  476. if (is_prefetch(regs, address, error_code))
  477. return;
  478. /*
  479. * Oops. The kernel tried to access some bad page. We'll have to
  480. * terminate things with extreme prejudice.
  481. */
  482. bust_spinlocks(1);
  483. if (oops_may_print()) {
  484. __typeof__(pte_val(__pte(0))) page;
  485. #ifdef CONFIG_X86_PAE
  486. if (error_code & 16) {
  487. pte_t *pte = lookup_address(address);
  488. if (pte && pte_present(*pte) && !pte_exec_kernel(*pte))
  489. printk(KERN_CRIT "kernel tried to execute "
  490. "NX-protected page - exploit attempt? "
  491. "(uid: %d)\n", current->uid);
  492. }
  493. #endif
  494. if (address < PAGE_SIZE)
  495. printk(KERN_ALERT "BUG: unable to handle kernel NULL "
  496. "pointer dereference");
  497. else
  498. printk(KERN_ALERT "BUG: unable to handle kernel paging"
  499. " request");
  500. printk(" at virtual address %08lx\n", address);
  501. printk(KERN_ALERT "printing ip: %08lx ", regs->ip);
  502. page = read_cr3();
  503. page = ((__typeof__(page) *) __va(page))[address >> PGDIR_SHIFT];
  504. #ifdef CONFIG_X86_PAE
  505. printk("*pdpt = %016Lx ", page);
  506. if ((page >> PAGE_SHIFT) < max_low_pfn
  507. && page & _PAGE_PRESENT) {
  508. page &= PAGE_MASK;
  509. page = ((__typeof__(page) *) __va(page))[(address >> PMD_SHIFT)
  510. & (PTRS_PER_PMD - 1)];
  511. printk(KERN_CONT "*pde = %016Lx ", page);
  512. page &= ~_PAGE_NX;
  513. }
  514. #else
  515. printk("*pde = %08lx ", page);
  516. #endif
  517. /*
  518. * We must not directly access the pte in the highpte
  519. * case if the page table is located in highmem.
  520. * And let's rather not kmap-atomic the pte, just in case
  521. * it's allocated already.
  522. */
  523. if ((page >> PAGE_SHIFT) < max_low_pfn
  524. && (page & _PAGE_PRESENT)
  525. && !(page & _PAGE_PSE)) {
  526. page &= PAGE_MASK;
  527. page = ((__typeof__(page) *) __va(page))[(address >> PAGE_SHIFT)
  528. & (PTRS_PER_PTE - 1)];
  529. printk("*pte = %0*Lx ", sizeof(page)*2, (u64)page);
  530. }
  531. printk("\n");
  532. }
  533. tsk->thread.cr2 = address;
  534. tsk->thread.trap_no = 14;
  535. tsk->thread.error_code = error_code;
  536. die("Oops", regs, error_code);
  537. bust_spinlocks(0);
  538. do_exit(SIGKILL);
  539. /*
  540. * We ran out of memory, or some other thing happened to us that made
  541. * us unable to handle the page fault gracefully.
  542. */
  543. out_of_memory:
  544. up_read(&mm->mmap_sem);
  545. if (is_global_init(tsk)) {
  546. yield();
  547. down_read(&mm->mmap_sem);
  548. goto survive;
  549. }
  550. printk("VM: killing process %s\n", tsk->comm);
  551. if (error_code & 4)
  552. do_group_exit(SIGKILL);
  553. goto no_context;
  554. do_sigbus:
  555. up_read(&mm->mmap_sem);
  556. /* Kernel mode? Handle exceptions or die */
  557. if (!(error_code & PF_USER))
  558. goto no_context;
  559. /* User space => ok to do another page fault */
  560. if (is_prefetch(regs, address, error_code))
  561. return;
  562. tsk->thread.cr2 = address;
  563. tsk->thread.error_code = error_code;
  564. tsk->thread.trap_no = 14;
  565. force_sig_info_fault(SIGBUS, BUS_ADRERR, address, tsk);
  566. }
  567. void vmalloc_sync_all(void)
  568. {
  569. /*
  570. * Note that races in the updates of insync and start aren't
  571. * problematic: insync can only get set bits added, and updates to
  572. * start are only improving performance (without affecting correctness
  573. * if undone).
  574. */
  575. static DECLARE_BITMAP(insync, PTRS_PER_PGD);
  576. static unsigned long start = TASK_SIZE;
  577. unsigned long address;
  578. if (SHARED_KERNEL_PMD)
  579. return;
  580. BUILD_BUG_ON(TASK_SIZE & ~PGDIR_MASK);
  581. for (address = start; address >= TASK_SIZE; address += PGDIR_SIZE) {
  582. if (!test_bit(pgd_index(address), insync)) {
  583. unsigned long flags;
  584. struct page *page;
  585. spin_lock_irqsave(&pgd_lock, flags);
  586. for (page = pgd_list; page; page =
  587. (struct page *)page->index)
  588. if (!vmalloc_sync_one(page_address(page),
  589. address)) {
  590. BUG_ON(page != pgd_list);
  591. break;
  592. }
  593. spin_unlock_irqrestore(&pgd_lock, flags);
  594. if (!page)
  595. set_bit(pgd_index(address), insync);
  596. }
  597. if (address == start && test_bit(pgd_index(address), insync))
  598. start = address + PGDIR_SIZE;
  599. }
  600. }