Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xen: introduce generic helper checking for memory map conflicts

When booting as a Xen PV dom0 the memory layout of the dom0 is
modified to match that of the host, as this requires less changes in
the kernel for supporting Xen.

There are some cases, though, which are problematic, as it is the Xen
hypervisor selecting the kernel's load address plus some other data,
which might conflict with the host's memory map.

These conflicts are detected at boot time and result in a boot error.
In order to support handling at least some of these conflicts in
future, introduce a generic helper function which will later gain the
ability to adapt the memory layout when possible.

Add the missing check for the xen_start_info area.

Note that possible p2m map and initrd memory conflicts are handled
already by copying the data to memory areas not conflicting with the
memory map. The initial stack allocated by Xen doesn't need to be
checked, as early boot code is switching to the statically allocated
initial kernel stack. Initial page tables and the kernel itself will
be handled later.

Signed-off-by: Juergen Gross <jgross@suse.com>
Tested-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>

+31 -11
+1 -4
arch/x86/xen/mmu_pv.c
··· 2018 2018 2019 2019 void __init xen_pt_check_e820(void) 2020 2020 { 2021 - if (xen_is_e820_reserved(xen_pt_base, xen_pt_size)) { 2022 - xen_raw_console_write("Xen hypervisor allocated page table memory conflicts with E820 map\n"); 2023 - BUG(); 2024 - } 2021 + xen_chk_is_e820_usable(xen_pt_base, xen_pt_size, "page table"); 2025 2022 } 2026 2023 2027 2024 static unsigned char dummy_mapping[PAGE_SIZE] __page_aligned_bss;
+28 -6
arch/x86/xen/setup.c
··· 567 567 } 568 568 } 569 569 570 - bool __init xen_is_e820_reserved(phys_addr_t start, phys_addr_t size) 570 + static bool __init xen_is_e820_reserved(phys_addr_t start, phys_addr_t size) 571 571 { 572 572 struct e820_entry *entry; 573 573 unsigned mapcnt; ··· 622 622 } 623 623 624 624 return 0; 625 + } 626 + 627 + /* 628 + * Check for an area in physical memory to be usable for non-movable purposes. 629 + * An area is considered to usable if the used E820 map lists it to be RAM. 630 + * In case the area is not usable, crash the system with an error message. 631 + */ 632 + void __init xen_chk_is_e820_usable(phys_addr_t start, phys_addr_t size, 633 + const char *component) 634 + { 635 + if (!xen_is_e820_reserved(start, size)) 636 + return; 637 + 638 + xen_raw_console_write("Xen hypervisor allocated "); 639 + xen_raw_console_write(component); 640 + xen_raw_console_write(" memory conflicts with E820 map\n"); 641 + BUG(); 625 642 } 626 643 627 644 /* ··· 841 824 * Failing now is better than running into weird problems later due 842 825 * to relocating (and even reusing) pages with kernel text or data. 843 826 */ 844 - if (xen_is_e820_reserved(__pa_symbol(_text), 845 - __pa_symbol(_end) - __pa_symbol(_text))) { 846 - xen_raw_console_write("Xen hypervisor allocated kernel memory conflicts with E820 map\n"); 847 - BUG(); 848 - } 827 + xen_chk_is_e820_usable(__pa_symbol(_text), 828 + __pa_symbol(_end) - __pa_symbol(_text), 829 + "kernel"); 830 + 831 + /* 832 + * Check for a conflict of the xen_start_info memory with the target 833 + * E820 map. 834 + */ 835 + xen_chk_is_e820_usable(__pa(xen_start_info), sizeof(*xen_start_info), 836 + "xen_start_info"); 849 837 850 838 /* 851 839 * Check for a conflict of the hypervisor supplied page tables with
+2 -1
arch/x86/xen/xen-ops.h
··· 48 48 void __init xen_relocate_p2m(void); 49 49 #endif 50 50 51 - bool __init xen_is_e820_reserved(phys_addr_t start, phys_addr_t size); 51 + void __init xen_chk_is_e820_usable(phys_addr_t start, phys_addr_t size, 52 + const char *component); 52 53 unsigned long __ref xen_chk_extra_mem(unsigned long pfn); 53 54 void __init xen_inv_extra_mem(void); 54 55 void __init xen_remap_memory(void);