vmalloc\_fault缺页异常只会发生在内核态且缺页的虚拟地址空间大于TASK\_SIZE\_MAX。因此vmalloc\_fault检查相应的内核页表init\_mm.pgd。
// linux-3.10.1/arch/x86/include/asm/processor.h
/*
* User space process size. 47bits minus one guard page.
*/
#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
// linux-3.10.1/arch/x86/mm/fault.c
static int fault_in_kernel_space(unsigned long address)
{
return address >= TASK_SIZE_MAX;
}
## 二、vmalloc\_fault
vmalloc\_fault主要是发生vmalloc缺页异常时用于关联内核页表项,将内核页表同步到用户进程的页表中。
// linux-3.10.1/arch/x86/include/asm/pgtable_64_types.h
#define VMALLOC_START _AC(0xffffc90000000000, UL)
#define VMALLOC_END _AC(0xffffe8ffffffffff, UL)
// linux-3.10.1/arch/x86/mm/fault.c
/*
* 64-bit:
*
* Handle a fault on the vmalloc area
*
* This assumes no large pages in there.
*/