summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaran Wilson <maran.wilson@oracle.com>2018-12-10 14:08:45 -0500
committerBoris Ostrovsky <boris.ostrovsky@oracle.com>2018-12-13 13:41:49 -0500
commit8cee3974b35bfb235d4637e10de5c5b364a9057e (patch)
tree13a789aad069c68c3deb6ae8b838bf379476ff23
parent4df7363e52105bf7a8589efb2959c907872644fb (diff)
xen/pvh: Move Xen specific PVH VM initialization out of common file
We need to refactor PVH entry code so that support for other hypervisors like Qemu/KVM can be added more easily. This patch moves the small block of code used for initializing Xen PVH virtual machines into the Xen specific file. This initialization is not going to be needed for Qemu/KVM guests. Moving it out of the common file is going to allow us to compile kernels in the future without CONFIG_XEN that are still capable of being booted as a Qemu/KVM guest via the PVH entry point. Signed-off-by: Maran Wilson <maran.wilson@oracle.com> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Reviewed-by: Juergen Gross <jgross@suse.com> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
-rw-r--r--arch/x86/platform/pvh/enlighten.c29
-rw-r--r--arch/x86/xen/enlighten_pvh.c22
-rw-r--r--include/xen/xen.h3
3 files changed, 44 insertions, 10 deletions
diff --git a/arch/x86/platform/pvh/enlighten.c b/arch/x86/platform/pvh/enlighten.c
index 491932991202..637bd74ba32d 100644
--- a/arch/x86/platform/pvh/enlighten.c
+++ b/arch/x86/platform/pvh/enlighten.c
@@ -82,26 +82,37 @@ static void __init init_pvh_bootparams(void)
82} 82}
83 83
84/* 84/*
85 * If we are trying to boot a Xen PVH guest, it is expected that the kernel
86 * will have been configured to provide the required override for this routine.
87 */
88void __init __weak xen_pvh_init(void)
89{
90 xen_raw_printk("Error: Missing xen PVH initialization\n");
91 BUG();
92}
93
94/*
95 * When we add support for other hypervisors like Qemu/KVM, this routine can
96 * selectively invoke the appropriate initialization based on guest type.
97 */
98static void hypervisor_specific_init(void)
99{
100 xen_pvh_init();
101}
102
103/*
85 * This routine (and those that it might call) should not use 104 * This routine (and those that it might call) should not use
86 * anything that lives in .bss since that segment will be cleared later. 105 * anything that lives in .bss since that segment will be cleared later.
87 */ 106 */
88void __init xen_prepare_pvh(void) 107void __init xen_prepare_pvh(void)
89{ 108{
90 u32 msr;
91 u64 pfn;
92
93 if (pvh_start_info.magic != XEN_HVM_START_MAGIC_VALUE) { 109 if (pvh_start_info.magic != XEN_HVM_START_MAGIC_VALUE) {
94 xen_raw_printk("Error: Unexpected magic value (0x%08x)\n", 110 xen_raw_printk("Error: Unexpected magic value (0x%08x)\n",
95 pvh_start_info.magic); 111 pvh_start_info.magic);
96 BUG(); 112 BUG();
97 } 113 }
98 114
99 xen_pvh = 1; 115 hypervisor_specific_init();
100 xen_start_flags = pvh_start_info.flags;
101
102 msr = cpuid_ebx(xen_cpuid_base() + 2);
103 pfn = __pa(hypercall_page);
104 wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32));
105 116
106 init_pvh_bootparams(); 117 init_pvh_bootparams();
107} 118}
diff --git a/arch/x86/xen/enlighten_pvh.c b/arch/x86/xen/enlighten_pvh.c
index 6be7bc719b38..41a7d6ad74e0 100644
--- a/arch/x86/xen/enlighten_pvh.c
+++ b/arch/x86/xen/enlighten_pvh.c
@@ -1,5 +1,12 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include <linux/types.h> 2#include <linux/acpi.h>
3
4#include <asm/io_apic.h>
5#include <asm/hypervisor.h>
6
7#include <xen/xen.h>
8#include <asm/xen/interface.h>
9#include <asm/xen/hypercall.h>
3 10
4/* 11/*
5 * PVH variables. 12 * PVH variables.
@@ -8,3 +15,16 @@
8 * after startup_{32|64} is invoked, which will clear the .bss segment. 15 * after startup_{32|64} is invoked, which will clear the .bss segment.
9 */ 16 */
10bool xen_pvh __attribute__((section(".data"))) = 0; 17bool xen_pvh __attribute__((section(".data"))) = 0;
18
19void __init xen_pvh_init(void)
20{
21 u32 msr;
22 u64 pfn;
23
24 xen_pvh = 1;
25 xen_start_flags = pvh_start_info.flags;
26
27 msr = cpuid_ebx(xen_cpuid_base() + 2);
28 pfn = __pa(hypercall_page);
29 wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32));
30}
diff --git a/include/xen/xen.h b/include/xen/xen.h
index d7a2678da77f..0e2156786ad2 100644
--- a/include/xen/xen.h
+++ b/include/xen/xen.h
@@ -29,6 +29,9 @@ extern bool xen_pvh;
29 29
30extern uint32_t xen_start_flags; 30extern uint32_t xen_start_flags;
31 31
32#include <xen/interface/hvm/start_info.h>
33extern struct hvm_start_info pvh_start_info;
34
32#ifdef CONFIG_XEN_DOM0 35#ifdef CONFIG_XEN_DOM0
33#include <xen/interface/xen.h> 36#include <xen/interface/xen.h>
34#include <asm/xen/hypervisor.h> 37#include <asm/xen/hypervisor.h>