aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Gross <jgross@suse.com>2017-11-09 08:27:39 -0500
committerIngo Molnar <mingo@kernel.org>2017-11-10 04:03:14 -0500
commit418492ba40b2c2bbdaf1a169aac5b1673bde8189 (patch)
tree2deefed6dc8b2571b7f226effb8e4fa3596f5404
parentf3614646005a1b59f836ff54351c9bd2224b6005 (diff)
x86/virt/xen: Use guest_late_init to detect Xen PVH guest
In case we are booted via the default boot entry by a generic loader like grub or OVMF it is necessary to distinguish between a HVM guest with a device model supporting legacy devices and a PVH guest without device model. PVH guests will always have x86_platform.legacy.no_vga set and x86_platform.legacy.rtc cleared, while both won't be true for HVM guests. Test for both conditions in the guest_late_init hook and set xen_pvh to true if they are met. Move some of the early PVH initializations to the new hook in order to avoid duplicated code. Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: Thomas Gleixner <tglx@linutronix.de> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: boris.ostrovsky@oracle.com Cc: xen-devel@lists.xenproject.org Link: http://lkml.kernel.org/r/20171109132739.23465-6-jgross@suse.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/xen/enlighten_hvm.c24
-rw-r--r--arch/x86/xen/enlighten_pvh.c9
2 files changed, 22 insertions, 11 deletions
diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
index 754d5391d9fa..826898701045 100644
--- a/arch/x86/xen/enlighten_hvm.c
+++ b/arch/x86/xen/enlighten_hvm.c
@@ -1,3 +1,4 @@
1#include <linux/acpi.h>
1#include <linux/cpu.h> 2#include <linux/cpu.h>
2#include <linux/kexec.h> 3#include <linux/kexec.h>
3#include <linux/memblock.h> 4#include <linux/memblock.h>
@@ -188,8 +189,6 @@ static void __init xen_hvm_guest_init(void)
188 xen_hvm_init_time_ops(); 189 xen_hvm_init_time_ops();
189 xen_hvm_init_mmu_ops(); 190 xen_hvm_init_mmu_ops();
190 191
191 if (xen_pvh_domain())
192 machine_ops.emergency_restart = xen_emergency_restart;
193#ifdef CONFIG_KEXEC_CORE 192#ifdef CONFIG_KEXEC_CORE
194 machine_ops.shutdown = xen_hvm_shutdown; 193 machine_ops.shutdown = xen_hvm_shutdown;
195 machine_ops.crash_shutdown = xen_hvm_crash_shutdown; 194 machine_ops.crash_shutdown = xen_hvm_crash_shutdown;
@@ -226,6 +225,26 @@ static uint32_t __init xen_platform_hvm(void)
226 return xen_cpuid_base(); 225 return xen_cpuid_base();
227} 226}
228 227
228static __init void xen_hvm_guest_late_init(void)
229{
230#ifdef CONFIG_XEN_PVH
231 /* Test for PVH domain (PVH boot path taken overrides ACPI flags). */
232 if (!xen_pvh &&
233 (x86_platform.legacy.rtc || !x86_platform.legacy.no_vga))
234 return;
235
236 /* PVH detected. */
237 xen_pvh = true;
238
239 /* Make sure we don't fall back to (default) ACPI_IRQ_MODEL_PIC. */
240 if (!nr_ioapics && acpi_irq_model == ACPI_IRQ_MODEL_PIC)
241 acpi_irq_model = ACPI_IRQ_MODEL_PLATFORM;
242
243 machine_ops.emergency_restart = xen_emergency_restart;
244 pv_info.name = "Xen PVH";
245#endif
246}
247
229const __initconst struct hypervisor_x86 x86_hyper_xen_hvm = { 248const __initconst struct hypervisor_x86 x86_hyper_xen_hvm = {
230 .name = "Xen HVM", 249 .name = "Xen HVM",
231 .detect = xen_platform_hvm, 250 .detect = xen_platform_hvm,
@@ -233,5 +252,6 @@ const __initconst struct hypervisor_x86 x86_hyper_xen_hvm = {
233 .init.init_platform = xen_hvm_guest_init, 252 .init.init_platform = xen_hvm_guest_init,
234 .init.x2apic_available = xen_x2apic_para_available, 253 .init.x2apic_available = xen_x2apic_para_available,
235 .init.init_mem_mapping = xen_hvm_init_mem_mapping, 254 .init.init_mem_mapping = xen_hvm_init_mem_mapping,
255 .init.guest_late_init = xen_hvm_guest_late_init,
236 .runtime.pin_vcpu = xen_pin_vcpu, 256 .runtime.pin_vcpu = xen_pin_vcpu,
237}; 257};
diff --git a/arch/x86/xen/enlighten_pvh.c b/arch/x86/xen/enlighten_pvh.c
index 7bd3ee08393e..436c4f003e17 100644
--- a/arch/x86/xen/enlighten_pvh.c
+++ b/arch/x86/xen/enlighten_pvh.c
@@ -25,13 +25,6 @@ struct boot_params pvh_bootparams __attribute__((section(".data")));
25struct hvm_start_info pvh_start_info; 25struct hvm_start_info pvh_start_info;
26unsigned int pvh_start_info_sz = sizeof(pvh_start_info); 26unsigned int pvh_start_info_sz = sizeof(pvh_start_info);
27 27
28static void xen_pvh_arch_setup(void)
29{
30 /* Make sure we don't fall back to (default) ACPI_IRQ_MODEL_PIC. */
31 if (nr_ioapics == 0)
32 acpi_irq_model = ACPI_IRQ_MODEL_PLATFORM;
33}
34
35static void __init init_pvh_bootparams(void) 28static void __init init_pvh_bootparams(void)
36{ 29{
37 struct xen_memory_map memmap; 30 struct xen_memory_map memmap;
@@ -102,6 +95,4 @@ void __init xen_prepare_pvh(void)
102 wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32)); 95 wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32));
103 96
104 init_pvh_bootparams(); 97 init_pvh_bootparams();
105
106 x86_init.oem.arch_setup = xen_pvh_arch_setup;
107} 98}