fault_32.c 17 KB

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