lkml.org 
[lkml]   [2019]   [Jul]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v6 4/4] x86/xen: Add "nopv" support for HVM guest
    Date
    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.

    Move xen_platform_hvm() after xen_hvm_guest_late_init() to avoid compile
    error.

    Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
    Cc: Boris 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>
    ---
    arch/x86/xen/enlighten_hvm.c | 32 ++++++++++++++++++++++++--------
    1 file changed, 24 insertions(+), 8 deletions(-)

    diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
    index 1756cf7..7e1c75f 100644
    --- a/arch/x86/xen/enlighten_hvm.c
    +++ b/arch/x86/xen/enlighten_hvm.c
    @@ -231,14 +231,6 @@ bool __init xen_hvm_need_lapic(void)
    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)
    {
    #ifdef CONFIG_XEN_PVH
    @@ -250,6 +242,9 @@ static __init void xen_hvm_guest_late_init(void)
    /* PVH detected. */
    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. */
    if (!nr_ioapics && acpi_irq_model == ACPI_IRQ_MODEL_PIC)
    acpi_irq_model = ACPI_IRQ_MODEL_PLATFORM;
    @@ -259,6 +254,26 @@ static __init void xen_hvm_guest_late_init(void)
    #endif
    }

    +static uint32_t __init xen_platform_hvm(void)
    +{
    + 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) {
    + /*
    + * Guest booting via normal boot entry (like via grub2) goes
    + * here.
    + */
    + x86_init.hyper.guest_late_init = xen_hvm_guest_late_init;
    + return 0;
    + }
    + return xen_cpuid_base();
    +}
    +
    const __initconst struct hypervisor_x86 x86_hyper_xen_hvm = {
    .name = "Xen HVM",
    .detect = xen_platform_hvm,
    @@ -268,4 +283,5 @@ static __init void xen_hvm_guest_late_init(void)
    .init.init_mem_mapping = xen_hvm_init_mem_mapping,
    .init.guest_late_init = xen_hvm_guest_late_init,
    .runtime.pin_vcpu = xen_pin_vcpu,
    + .ignore_nopv = true,
    };
    --
    1.8.3.1
    \
     
     \ /
      Last update: 2019-07-08 11:13    [W:3.587 / U:0.016 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site