summaryrefslogtreecommitdiff |
diff options
author | Jiri Kosina <jkosina@suse.cz> | 2017-12-11 12:39:41 +0100 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2017-12-11 12:39:41 +0100 |
commit | a80588b0a6fb9546a470b05dc22dc0f637508c95 (patch) | |
tree | f071e3d2273215ad4a2d2b302de4d19913b3d723 | |
parent | 62cf71e0941c0b6f90ed219c0bea1fed7ad5c6cb (diff) | |
parent | 282057348474897897f4a8907096fd4d96cec740 (diff) |
Merge remote-tracking branch 'origin/users/jgross/SLE15/for-next' into SLE15rpm-4.12.14-6--SLE-15-SP1-Packages-Alpha2rpm-4.12.14-6--SLE-15-SP1-Packages-Alpha1rpm-4.12.14-6--SLE-15-Packages-Beta4rpm-4.12.14-6
-rw-r--r-- | patches.fixes/xen-fix-hvm-guest-with-kaslr-enabled.patch | 81 | ||||
-rw-r--r-- | patches.fixes/xen-split-up-xen_hvm_init_shared_info.patch | 95 | ||||
-rw-r--r-- | patches.fixes/xen-x86-provide-init_mem_mapping-hook.patch | 76 | ||||
-rw-r--r-- | series.conf | 3 |
4 files changed, 255 insertions, 0 deletions
diff --git a/patches.fixes/xen-fix-hvm-guest-with-kaslr-enabled.patch b/patches.fixes/xen-fix-hvm-guest-with-kaslr-enabled.patch new file mode 100644 index 0000000000..89577c8843 --- /dev/null +++ b/patches.fixes/xen-fix-hvm-guest-with-kaslr-enabled.patch @@ -0,0 +1,81 @@ +From: Juergen Gross <jgross@suse.com> +Date: Fri, 28 Jul 2017 12:23:14 +0200 +Git-commit: 4ca83dcf4e3bc0c98836dbb97553792ca7ea5429 +Patch-mainline: v4.13 +References: bnc#1071891 +Subject: xen: fix hvm guest with kaslr enabled + +A Xen HVM guest running with KASLR enabled will die rather soon today +because the shared info page mapping is using va() too early. This was +introduced by commit a5d5f328b0e2baa5ee7c119fd66324eb79eeeb66 ("xen: +allocate page for shared info page from low memory"). + +In order to fix this use early_memremap() to get a temporary virtual +address for shared info until va() can be used safely. + +Signed-off-by: Juergen Gross <jgross@suse.com> +Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> +Acked-by: Ingo Molnar <mingo@kernel.org> +Signed-off-by: Juergen Gross <jgross@suse.com> +--- + arch/x86/xen/enlighten_hvm.c | 16 ++++++++++++++-- + 1 file changed, 14 insertions(+), 2 deletions(-) + +diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c +index d23531f..de503c2 100644 +--- a/arch/x86/xen/enlighten_hvm.c ++++ b/arch/x86/xen/enlighten_hvm.c +@@ -12,6 +12,7 @@ + #include <asm/setup.h> + #include <asm/hypervisor.h> + #include <asm/e820/api.h> ++#include <asm/early_ioremap.h> + + #include <asm/xen/cpuid.h> + #include <asm/xen/hypervisor.h> +@@ -21,6 +22,8 @@ + #include "mmu.h" + #include "smp.h" + ++static unsigned long shared_info_pfn; ++ + void xen_hvm_init_shared_info(void) + { + int cpu; +@@ -28,7 +31,7 @@ void xen_hvm_init_shared_info(void) + xatp.domid = DOMID_SELF; + xatp.idx = 0; + xatp.space = XENMAPSPACE_shared_info; +- xatp.gpfn = virt_to_pfn(HYPERVISOR_shared_info); ++ xatp.gpfn = shared_info_pfn; + if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp)) + BUG(); + +@@ -51,8 +54,16 @@ static void __init reserve_shared_info(void) + pa += PAGE_SIZE) + ; + ++ shared_info_pfn = PHYS_PFN(pa); ++ + memblock_reserve(pa, PAGE_SIZE); +- HYPERVISOR_shared_info = __va(pa); ++ HYPERVISOR_shared_info = early_memremap(pa, PAGE_SIZE); ++} ++ ++static void __init xen_hvm_init_mem_mapping(void) ++{ ++ early_memunmap(HYPERVISOR_shared_info, PAGE_SIZE); ++ HYPERVISOR_shared_info = __va(PFN_PHYS(shared_info_pfn)); + } + + static void __init init_hvm_pv_info(void) +@@ -221,5 +232,6 @@ const struct hypervisor_x86 x86_hyper_xen_hvm = { + .init_platform = xen_hvm_guest_init, + .pin_vcpu = xen_pin_vcpu, + .x2apic_available = xen_x2apic_para_available, ++ .init_mem_mapping = xen_hvm_init_mem_mapping, + }; + EXPORT_SYMBOL(x86_hyper_xen_hvm); +-- +cgit v1.1 + diff --git a/patches.fixes/xen-split-up-xen_hvm_init_shared_info.patch b/patches.fixes/xen-split-up-xen_hvm_init_shared_info.patch new file mode 100644 index 0000000000..c6c17ddbe6 --- /dev/null +++ b/patches.fixes/xen-split-up-xen_hvm_init_shared_info.patch @@ -0,0 +1,95 @@ +From: Juergen Gross <jgross@suse.com> +Date: Fri, 28 Jul 2017 12:23:13 +0200 +Git-commit: 10231f69eb039550864ff3eb395da0c63c03ed5f +Patch-mainline: v4.13 +References: bnc#1071891 +Subject: xen: split up xen_hvm_init_shared_info() + +Instead of calling xen_hvm_init_shared_info() on boot and resume split +it up into a boot time function searching for the pfn to use and a +mapping function doing the hypervisor mapping call. + +Signed-off-by: Juergen Gross <jgross@suse.com> +Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> +Acked-by: Ingo Molnar <mingo@kernel.org> +Signed-off-by: Juergen Gross <jgross@suse.com> +--- + arch/x86/xen/enlighten_hvm.c | 45 +++++++++++++++++++++++--------------------- + 1 file changed, 24 insertions(+), 21 deletions(-) + +diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c +index 87d7913..d23531f 100644 +--- a/arch/x86/xen/enlighten_hvm.c ++++ b/arch/x86/xen/enlighten_hvm.c +@@ -21,30 +21,10 @@ + #include "mmu.h" + #include "smp.h" + +-void __ref xen_hvm_init_shared_info(void) ++void xen_hvm_init_shared_info(void) + { + int cpu; + struct xen_add_to_physmap xatp; +- u64 pa; +- +- if (HYPERVISOR_shared_info == &xen_dummy_shared_info) { +- /* +- * Search for a free page starting at 4kB physical address. +- * Low memory is preferred to avoid an EPT large page split up +- * by the mapping. +- * Starting below X86_RESERVE_LOW (usually 64kB) is fine as +- * the BIOS used for HVM guests is well behaved and won't +- * clobber memory other than the first 4kB. +- */ +- for (pa = PAGE_SIZE; +- !e820__mapped_all(pa, pa + PAGE_SIZE, E820_TYPE_RAM) || +- memblock_is_reserved(pa); +- pa += PAGE_SIZE) +- ; +- +- memblock_reserve(pa, PAGE_SIZE); +- HYPERVISOR_shared_info = __va(pa); +- } + + xatp.domid = DOMID_SELF; + xatp.idx = 0; +@@ -70,6 +50,28 @@ void __ref xen_hvm_init_shared_info(void) + } + } + ++static void __init reserve_shared_info(void) ++{ ++ u64 pa; ++ ++ /* ++ * Search for a free page starting at 4kB physical address. ++ * Low memory is preferred to avoid an EPT large page split up ++ * by the mapping. ++ * Starting below X86_RESERVE_LOW (usually 64kB) is fine as ++ * the BIOS used for HVM guests is well behaved and won't ++ * clobber memory other than the first 4kB. ++ */ ++ for (pa = PAGE_SIZE; ++ !e820__mapped_all(pa, pa + PAGE_SIZE, E820_TYPE_RAM) || ++ memblock_is_reserved(pa); ++ pa += PAGE_SIZE) ++ ; ++ ++ memblock_reserve(pa, PAGE_SIZE); ++ HYPERVISOR_shared_info = __va(pa); ++} ++ + static void __init init_hvm_pv_info(void) + { + int major, minor; +@@ -153,6 +155,7 @@ static void __init xen_hvm_guest_init(void) + + init_hvm_pv_info(); + ++ reserve_shared_info(); + xen_hvm_init_shared_info(); + + xen_panic_handler_init(); +-- +cgit v1.1 + diff --git a/patches.fixes/xen-x86-provide-init_mem_mapping-hook.patch b/patches.fixes/xen-x86-provide-init_mem_mapping-hook.patch new file mode 100644 index 0000000000..1572521dd1 --- /dev/null +++ b/patches.fixes/xen-x86-provide-init_mem_mapping-hook.patch @@ -0,0 +1,76 @@ +From: Juergen Gross <jgross@suse.com> +Date: Fri, 28 Jul 2017 12:23:12 +0200 +Git-commit: c138d81163d82db044dcaf1141395713f03bf0bf +Patch-mainline: v4.13 +References: bnc#1071891 +Subject: x86: provide an init_mem_mapping hypervisor hook + +Provide a hook in hypervisor_x86 called after setting up initial +memory mapping. + +This is needed e.g. by Xen HVM guests to map the hypervisor shared +info page. + +Signed-off-by: Juergen Gross <jgross@suse.com> +Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> +Acked-by: Ingo Molnar <mingo@kernel.org> +Signed-off-by: Juergen Gross <jgross@suse.com> +--- + arch/x86/include/asm/hypervisor.h | 10 ++++++++++ + arch/x86/mm/init.c | 3 +++ + 2 files changed, 13 insertions(+) + +diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h +index 2112615..0ead9db 100644 +--- a/arch/x86/include/asm/hypervisor.h ++++ b/arch/x86/include/asm/hypervisor.h +@@ -43,6 +43,9 @@ struct hypervisor_x86 { + + /* pin current vcpu to specified physical cpu (run rarely) */ + void (*pin_vcpu)(int); ++ ++ /* called during init_mem_mapping() to setup early mappings. */ ++ void (*init_mem_mapping)(void); + }; + + extern const struct hypervisor_x86 *x86_hyper; +@@ -57,8 +60,15 @@ extern const struct hypervisor_x86 x86_hyper_kvm; + extern void init_hypervisor_platform(void); + extern bool hypervisor_x2apic_available(void); + extern void hypervisor_pin_vcpu(int cpu); ++ ++static inline void hypervisor_init_mem_mapping(void) ++{ ++ if (x86_hyper && x86_hyper->init_mem_mapping) ++ x86_hyper->init_mem_mapping(); ++} + #else + static inline void init_hypervisor_platform(void) { } + static inline bool hypervisor_x2apic_available(void) { return false; } ++static inline void hypervisor_init_mem_mapping(void) { } + #endif /* CONFIG_HYPERVISOR_GUEST */ + #endif /* _ASM_X86_HYPERVISOR_H */ +diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c +index 673541e..bf3f106 100644 +--- a/arch/x86/mm/init.c ++++ b/arch/x86/mm/init.c +@@ -18,6 +18,7 @@ + #include <asm/dma.h> /* for MAX_DMA_PFN */ + #include <asm/microcode.h> + #include <asm/kaslr.h> ++#include <asm/hypervisor.h> + + /* + * We need to define the tracepoints somewhere, and tlb.c +@@ -636,6 +637,8 @@ void __init init_mem_mapping(void) + load_cr3(swapper_pg_dir); + __flush_tlb_all(); + ++ hypervisor_init_mem_mapping(); ++ + early_memtest(0, max_pfn_mapped << PAGE_SHIFT); + } + +-- +cgit v1.1 + diff --git a/series.conf b/series.conf index 21b93df0dd..9d6567e70c 100644 --- a/series.conf +++ b/series.conf @@ -6793,6 +6793,9 @@ patches.fixes/xen-fix-booting-ballooned-down-hvm-guest.patch patches.fixes/xen-events-fifo-dont-use-get-put-cpu.patch patches.fixes/xen-x86-mark-xen_find_pt_base-as-init.patch + patches.fixes/xen-x86-provide-init_mem_mapping-hook.patch + patches.fixes/xen-split-up-xen_hvm_init_shared_info.patch + patches.fixes/xen-fix-hvm-guest-with-kaslr-enabled.patch patches.drivers/0001-usb-Add-Xen-pvUSB-protocol-description.patch patches.drivers/0002-usb-Introduce-Xen-pvUSB-frontend-xen-hcd.patch |