summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Gross <jgross@suse.com>2017-07-28 06:23:14 -0400
committerJuergen Gross <jgross@suse.com>2017-08-11 09:50:26 -0400
commit4ca83dcf4e3bc0c98836dbb97553792ca7ea5429 (patch)
tree58e2838e4e443252dbc6ef5a2837559b4c65f667
parent10231f69eb039550864ff3eb395da0c63c03ed5f (diff)
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>
-rw-r--r--arch/x86/xen/enlighten_hvm.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
index d23531f5f17e..de503c225ae1 100644
--- a/arch/x86/xen/enlighten_hvm.c
+++ b/arch/x86/xen/enlighten_hvm.c
@@ -12,6 +12,7 @@
12#include <asm/setup.h> 12#include <asm/setup.h>
13#include <asm/hypervisor.h> 13#include <asm/hypervisor.h>
14#include <asm/e820/api.h> 14#include <asm/e820/api.h>
15#include <asm/early_ioremap.h>
15 16
16#include <asm/xen/cpuid.h> 17#include <asm/xen/cpuid.h>
17#include <asm/xen/hypervisor.h> 18#include <asm/xen/hypervisor.h>
@@ -21,6 +22,8 @@
21#include "mmu.h" 22#include "mmu.h"
22#include "smp.h" 23#include "smp.h"
23 24
25static unsigned long shared_info_pfn;
26
24void xen_hvm_init_shared_info(void) 27void xen_hvm_init_shared_info(void)
25{ 28{
26 struct xen_add_to_physmap xatp; 29 struct xen_add_to_physmap xatp;
@@ -28,7 +31,7 @@ void xen_hvm_init_shared_info(void)
28 xatp.domid = DOMID_SELF; 31 xatp.domid = DOMID_SELF;
29 xatp.idx = 0; 32 xatp.idx = 0;
30 xatp.space = XENMAPSPACE_shared_info; 33 xatp.space = XENMAPSPACE_shared_info;
31 xatp.gpfn = virt_to_pfn(HYPERVISOR_shared_info); 34 xatp.gpfn = shared_info_pfn;
32 if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp)) 35 if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
33 BUG(); 36 BUG();
34} 37}
@@ -51,8 +54,16 @@ static void __init reserve_shared_info(void)
51 pa += PAGE_SIZE) 54 pa += PAGE_SIZE)
52 ; 55 ;
53 56
57 shared_info_pfn = PHYS_PFN(pa);
58
54 memblock_reserve(pa, PAGE_SIZE); 59 memblock_reserve(pa, PAGE_SIZE);
55 HYPERVISOR_shared_info = __va(pa); 60 HYPERVISOR_shared_info = early_memremap(pa, PAGE_SIZE);
61}
62
63static void __init xen_hvm_init_mem_mapping(void)
64{
65 early_memunmap(HYPERVISOR_shared_info, PAGE_SIZE);
66 HYPERVISOR_shared_info = __va(PFN_PHYS(shared_info_pfn));
56} 67}
57 68
58static void __init init_hvm_pv_info(void) 69static void __init init_hvm_pv_info(void)
@@ -221,5 +232,6 @@ const struct hypervisor_x86 x86_hyper_xen_hvm = {
221 .init_platform = xen_hvm_guest_init, 232 .init_platform = xen_hvm_guest_init,
222 .pin_vcpu = xen_pin_vcpu, 233 .pin_vcpu = xen_pin_vcpu,
223 .x2apic_available = xen_x2apic_para_available, 234 .x2apic_available = xen_x2apic_para_available,
235 .init_mem_mapping = xen_hvm_init_mem_mapping,
224}; 236};
225EXPORT_SYMBOL(x86_hyper_xen_hvm); 237EXPORT_SYMBOL(x86_hyper_xen_hvm);