commit 3141bba98af302e2a7c5e2a19203bb8a40b6aa63 Author: Dave Anderson Date: Wed Oct 10 09:15:42 2018 -0400 Fix the calculation of the vmalloc memory region size to account for Linux 4.17 commit a7412546d8cb5ad578805060b4006f2a021b5868, titled "x86/mm: Adjust vmalloc base and size at boot-time", which increases the region's size from 32TB to 1280TB when 5-level pagetables are enabled. Also presume that virtual addresses above the end of the vmalloc space up to the beginning of vmemmap space are translatable via 5-level page tables. Without the patch, mapped virtual addresses may fail translation in whatever command accesses them, with errors indicating "seek error: kernel virtual address: type: " (anderson@redhat.com) diff --git a/x86_64.c b/x86_64.c index 6f547e8..345122c 100644 --- a/x86_64.c +++ b/x86_64.c @@ -393,8 +393,12 @@ x86_64_init(int when) readmem(symbol_value("vmalloc_base"), KVADDR, &machdep->machspec->vmalloc_start_addr, sizeof(ulong), "vmalloc_base", FAULT_ON_ERROR); - machdep->machspec->vmalloc_end = - machdep->machspec->vmalloc_start_addr + TERABYTES(32) - 1; + if (machdep->flags & VM_5LEVEL) + machdep->machspec->vmalloc_end = + machdep->machspec->vmalloc_start_addr + TERABYTES(1280) - 1; + else + machdep->machspec->vmalloc_end = + machdep->machspec->vmalloc_start_addr + TERABYTES(32) - 1; if (kernel_symbol_exists("vmemmap_base")) { readmem(symbol_value("vmemmap_base"), KVADDR, &machdep->machspec->vmemmap_vaddr, sizeof(ulong), @@ -1626,7 +1630,8 @@ x86_64_IS_VMALLOC_ADDR(ulong vaddr) (vaddr >= VSYSCALL_START && vaddr < VSYSCALL_END) || (machdep->machspec->cpu_entry_area_start && vaddr >= machdep->machspec->cpu_entry_area_start && - vaddr <= machdep->machspec->cpu_entry_area_end)); + vaddr <= machdep->machspec->cpu_entry_area_end) || + ((machdep->flags & VM_5LEVEL) && vaddr > VMALLOC_END && vaddr < VMEMMAP_VADDR)); } static int