linux/arch/x86/xen
Zhenzhong Duan 0d805ee70a xen/mmu: Call xen_cleanhighmap() with 4MB aligned for page tables mapping
When bootup a PVM guest with large memory(Ex.240GB), XEN provided initial
mapping overlaps with kernel module virtual space. When mapping in this space
is cleared by xen_cleanhighmap(), in certain case there could be an 2MB mapping
left. This is due to XEN initialize 4MB aligned mapping but xen_cleanhighmap()
finish at 2MB boundary.

When module loading is just on top of the 2MB space, got below warning:

WARNING: at mm/vmalloc.c:106 vmap_pte_range+0x14e/0x190()
Call Trace:
 [<ffffffff81117083>] warn_alloc_failed+0xf3/0x160
 [<ffffffff81146022>] __vmalloc_area_node+0x182/0x1c0
 [<ffffffff810ac91e>] ? module_alloc_update_bounds+0x1e/0x80
 [<ffffffff81145df7>] __vmalloc_node_range+0xa7/0x110
 [<ffffffff810ac91e>] ? module_alloc_update_bounds+0x1e/0x80
 [<ffffffff8103ca54>] module_alloc+0x64/0x70
 [<ffffffff810ac91e>] ? module_alloc_update_bounds+0x1e/0x80
 [<ffffffff810ac91e>] module_alloc_update_bounds+0x1e/0x80
 [<ffffffff810ac9a7>] move_module+0x27/0x150
 [<ffffffff810aefa0>] layout_and_allocate+0x120/0x1b0
 [<ffffffff810af0a8>] load_module+0x78/0x640
 [<ffffffff811ff90b>] ? security_file_permission+0x8b/0x90
 [<ffffffff810af6d2>] sys_init_module+0x62/0x1e0
 [<ffffffff815154c2>] system_call_fastpath+0x16/0x1b

Then the mapping of 2MB is cleared, finally oops when the page in that space is
accessed.

BUG: unable to handle kernel paging request at ffff880022600000
IP: [<ffffffff81260877>] clear_page_c_e+0x7/0x10
PGD 1788067 PUD 178c067 PMD 22434067 PTE 0
Oops: 0002 [#1] SMP
Call Trace:
 [<ffffffff81116ef7>] ? prep_new_page+0x127/0x1c0
 [<ffffffff81117d42>] get_page_from_freelist+0x1e2/0x550
 [<ffffffff81133010>] ? ii_iovec_copy_to_user+0x90/0x140
 [<ffffffff81119c9d>] __alloc_pages_nodemask+0x12d/0x230
 [<ffffffff81155516>] alloc_pages_vma+0xc6/0x1a0
 [<ffffffff81006ffd>] ? pte_mfn_to_pfn+0x7d/0x100
 [<ffffffff81134cfb>] do_anonymous_page+0x16b/0x350
 [<ffffffff81139c34>] handle_pte_fault+0x1e4/0x200
 [<ffffffff8100712e>] ? xen_pmd_val+0xe/0x10
 [<ffffffff810052c9>] ? __raw_callee_save_xen_pmd_val+0x11/0x1e
 [<ffffffff81139dab>] handle_mm_fault+0x15b/0x270
 [<ffffffff81510c10>] do_page_fault+0x140/0x470
 [<ffffffff8150d7d5>] page_fault+0x25/0x30

Call xen_cleanhighmap() with 4MB aligned for page tables mapping to fix it.
The unnecessory call of xen_cleanhighmap() in DEBUG mode is also removed.

-v2: add comment about XEN alignment from Juergen.

References: https://lists.xen.org/archives/html/xen-devel/2012-07/msg01562.html
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
Reviewed-by: Juergen Gross <jgross@suse.com>

[boris: added 'xen/mmu' tag to commit subject]
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
2017-09-28 08:26:30 -04:00
..
apic.c x86/apic: Move cpumask and to core code 2017-06-22 18:21:22 +02:00
debugfs.c x86/xen: Audit and remove any unnecessary uses of module.h 2016-07-14 15:06:59 +02:00
debugfs.h
efi.c x86/xen/efi: Initialize only the EFI struct members used by Xen 2017-06-23 11:11:03 +02:00
enlighten_hvm.c xen: fix hvm guest with kaslr enabled 2017-08-11 15:50:26 +02:00
enlighten_pv.c x86/paravirt: Remove no longer used paravirt functions 2017-09-13 10:55:15 +02:00
enlighten_pvh.c xen/pvh: Do not fill kernel's e820 map in init_pvh_bootparams() 2017-05-02 11:17:39 +02:00
enlighten.c xen/vcpu: Handle xen_vcpu_setup() failure in hotplug 2017-06-13 16:10:55 +02:00
grant-table.c xen/grant-table: Use kmalloc_array() in arch_gnttab_valloc() 2016-08-26 10:44:22 +01:00
irq.c x86/xen: Get rid of paravirt op adjust_exception_frame 2017-08-31 21:35:10 +02:00
Kconfig x86: Enable 5-level paging support via CONFIG_X86_5LEVEL=y 2017-07-21 10:05:19 +02:00
Makefile objtool, x86: Add several functions and files to the objtool whitelist 2017-06-30 10:19:19 +02:00
mmu_hvm.c x86/xen: split off mmu_hvm.c 2017-05-02 11:05:10 +02:00
mmu_pv.c xen/mmu: Call xen_cleanhighmap() with 4MB aligned for page tables mapping 2017-09-28 08:26:30 -04:00
mmu.c xen/mmu: set MMU_NORMAL_PT_UPDATE in remap_area_mfn_pte_fn 2017-08-31 09:45:55 -04:00
mmu.h x86/xen: Change __xen_pgd_walk() and xen_cleanmfnmap() to support p4d 2017-03-27 08:56:49 +02:00
multicalls.c x86: Replace __get_cpu_var uses 2014-08-26 13:45:49 -04:00
multicalls.h
p2m.c xen: remove tests for pvh mode in pure pv paths 2017-08-31 09:45:55 -04:00
pci-swiotlb-xen.c xen-swiotlb: consolidate xen_swiotlb_dma_ops 2017-06-20 11:12:59 +02:00
platform-pci-unplug.c xen/pvh: PVH guests always have PV devices 2017-02-07 08:07:01 -05:00
pmu.c xen: Make VPMU init message look less scary 2016-08-24 18:45:38 +01:00
pmu.h x86/xen: put setup.c, pmu.c and apic.c under CONFIG_XEN_PV 2017-05-02 11:09:28 +02:00
setup.c xen: remove tests for pvh mode in pure pv paths 2017-08-31 09:45:55 -04:00
smp_hvm.c xen/vcpu: Handle xen_vcpu_setup() failure at boot 2017-06-13 16:10:58 +02:00
smp_pv.c xen/x86: fix cpu hotplug 2017-07-23 08:13:11 +02:00
smp.c xen/vcpu: Handle xen_vcpu_setup() failure at boot 2017-06-13 16:10:58 +02:00
smp.h xen/vcpu: Handle xen_vcpu_setup() failure at boot 2017-06-13 16:10:58 +02:00
spinlock.c locking/spinlocks/x86, paravirt: Remove paravirt_ticketlocks_enabled 2017-01-14 09:33:46 +01:00
suspend_hvm.c xen/pvh*: Support > 32 VCPUs at domain restore 2017-06-13 16:05:17 +02:00
suspend_pv.c x86/xen: split suspend.c for PV and PVHVM guests 2017-05-02 11:09:17 +02:00
suspend.c x86/xen: split suspend.c for PV and PVHVM guests 2017-05-02 11:09:17 +02:00
time.c xen/x86: Don't BUG on CPU0 offlining 2017-07-23 08:09:24 +02:00
trace.c xen: use generated hypervisor symbols in arch/x86/xen/trace.c 2015-03-16 14:49:13 +00:00
vdso.h
vga.c
xen-asm_32.S x86/paravirt/xen: Remove xen_patch() 2017-08-24 09:57:24 +02:00
xen-asm_64.S x86/xen: Get rid of paravirt op adjust_exception_frame 2017-08-31 21:35:10 +02:00
xen-asm.S x86/paravirt/xen: Remove xen_patch() 2017-08-24 09:57:24 +02:00
xen-head.S x86/xen: Redefine XEN_ELFNOTE_INIT_P2M using PUD_SIZE * PTRS_PER_PUD 2017-07-21 10:05:18 +02:00
xen-ops.h x86/xen: Get rid of paravirt op adjust_exception_frame 2017-08-31 21:35:10 +02:00
xen-pvh.S x86/boot/64: Rename init_level4_pgt and early_level4_pgt 2017-06-13 08:56:55 +02:00