Commit bef6e0ae authored by Zhenzhong Duan's avatar Zhenzhong Duan Committed by Juergen Gross

x86/xen: Add "nopv" support for HVM guest

PVH guest needs PV extentions to work, so "nopv" parameter should be
ignored for PVH but not for HVM guest.

If PVH guest boots up via the Xen-PVH boot entry, xen_pvh is set early,
we know it's PVH guest and ignore "nopv" parameter directly.

If PVH guest boots up via the normal boot entry same as HVM guest, it's
hard to distinguish PVH and HVM guest at that time. In this case, we
have to panic early if PVH is detected and nopv is enabled to avoid a
worse situation later.

Remove static from bool_x86_init_noop/x86_op_int_noop so they could be
used globally. Move xen_platform_hvm() after xen_hvm_guest_late_init()
to avoid compile error.
Signed-off-by: default avatarZhenzhong Duan <zhenzhong.duan@oracle.com>
Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
parent cc8f3b4d
...@@ -301,6 +301,8 @@ extern struct x86_apic_ops x86_apic_ops; ...@@ -301,6 +301,8 @@ extern struct x86_apic_ops x86_apic_ops;
extern void x86_early_init_platform_quirks(void); extern void x86_early_init_platform_quirks(void);
extern void x86_init_noop(void); extern void x86_init_noop(void);
extern void x86_init_uint_noop(unsigned int unused); extern void x86_init_uint_noop(unsigned int unused);
extern bool bool_x86_init_noop(void);
extern void x86_op_int_noop(int cpu);
extern bool x86_pnpbios_disabled(void); extern bool x86_pnpbios_disabled(void);
#endif #endif
...@@ -29,8 +29,8 @@ void x86_init_noop(void) { } ...@@ -29,8 +29,8 @@ void x86_init_noop(void) { }
void __init x86_init_uint_noop(unsigned int unused) { } void __init x86_init_uint_noop(unsigned int unused) { }
static int __init iommu_init_noop(void) { return 0; } static int __init iommu_init_noop(void) { return 0; }
static void iommu_shutdown_noop(void) { } static void iommu_shutdown_noop(void) { }
static bool __init bool_x86_init_noop(void) { return false; } bool __init bool_x86_init_noop(void) { return false; }
static void x86_op_int_noop(int cpu) { } void x86_op_int_noop(int cpu) { }
/* /*
* The platform setup functions are preset with the default functions * The platform setup functions are preset with the default functions
......
...@@ -231,14 +231,6 @@ bool __init xen_hvm_need_lapic(void) ...@@ -231,14 +231,6 @@ bool __init xen_hvm_need_lapic(void)
return true; return true;
} }
static uint32_t __init xen_platform_hvm(void)
{
if (xen_pv_domain())
return 0;
return xen_cpuid_base();
}
static __init void xen_hvm_guest_late_init(void) static __init void xen_hvm_guest_late_init(void)
{ {
#ifdef CONFIG_XEN_PVH #ifdef CONFIG_XEN_PVH
...@@ -250,6 +242,9 @@ static __init void xen_hvm_guest_late_init(void) ...@@ -250,6 +242,9 @@ static __init void xen_hvm_guest_late_init(void)
/* PVH detected. */ /* PVH detected. */
xen_pvh = true; xen_pvh = true;
if (nopv)
panic("\"nopv\" and \"xen_nopv\" parameters are unsupported in PVH guest.");
/* Make sure we don't fall back to (default) ACPI_IRQ_MODEL_PIC. */ /* Make sure we don't fall back to (default) ACPI_IRQ_MODEL_PIC. */
if (!nr_ioapics && acpi_irq_model == ACPI_IRQ_MODEL_PIC) if (!nr_ioapics && acpi_irq_model == ACPI_IRQ_MODEL_PIC)
acpi_irq_model = ACPI_IRQ_MODEL_PLATFORM; acpi_irq_model = ACPI_IRQ_MODEL_PLATFORM;
...@@ -259,6 +254,37 @@ static __init void xen_hvm_guest_late_init(void) ...@@ -259,6 +254,37 @@ static __init void xen_hvm_guest_late_init(void)
#endif #endif
} }
static uint32_t __init xen_platform_hvm(void)
{
uint32_t xen_domain = xen_cpuid_base();
struct x86_hyper_init *h = &x86_hyper_xen_hvm.init;
if (xen_pv_domain())
return 0;
if (xen_pvh_domain() && nopv) {
/* Guest booting via the Xen-PVH boot entry goes here */
pr_info("\"nopv\" parameter is ignored in PVH guest\n");
nopv = false;
} else if (nopv && xen_domain) {
/*
* Guest booting via normal boot entry (like via grub2) goes
* here.
*
* Use interface functions for bare hardware if nopv,
* xen_hvm_guest_late_init is an exception as we need to
* detect PVH and panic there.
*/
h->init_platform = x86_init_noop;
h->x2apic_available = bool_x86_init_noop;
h->init_mem_mapping = x86_init_noop;
h->init_after_bootmem = x86_init_noop;
h->guest_late_init = xen_hvm_guest_late_init;
x86_hyper_xen_hvm.runtime.pin_vcpu = x86_op_int_noop;
}
return xen_domain;
}
struct hypervisor_x86 x86_hyper_xen_hvm __initdata = { struct hypervisor_x86 x86_hyper_xen_hvm __initdata = {
.name = "Xen HVM", .name = "Xen HVM",
.detect = xen_platform_hvm, .detect = xen_platform_hvm,
...@@ -268,4 +294,5 @@ struct hypervisor_x86 x86_hyper_xen_hvm __initdata = { ...@@ -268,4 +294,5 @@ struct hypervisor_x86 x86_hyper_xen_hvm __initdata = {
.init.init_mem_mapping = xen_hvm_init_mem_mapping, .init.init_mem_mapping = xen_hvm_init_mem_mapping,
.init.guest_late_init = xen_hvm_guest_late_init, .init.guest_late_init = xen_hvm_guest_late_init,
.runtime.pin_vcpu = xen_pin_vcpu, .runtime.pin_vcpu = xen_pin_vcpu,
.ignore_nopv = true,
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment