From: Juergen Gross <jgross@suse.com> To: linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, boris.ostrovsky@oracle.com, pbonzini@redhat.com, rkrcmar@redhat.com, rjw@rjwysocki.net, len.brown@intel.com, pavel@ucw.cz, Juergen Gross <jgross@suse.com> Subject: [PATCH 3/3] x86/xen: use guest_late_init to detect Xen PVH guest Date: Wed, 8 Nov 2017 10:07:39 +0100 [thread overview] Message-ID: <20171108090739.26491-4-jgross@suse.com> (raw) In-Reply-To: <20171108090739.26491-1-jgross@suse.com> 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> --- arch/x86/xen/enlighten_hvm.c | 24 ++++++++++++++++++++++-- arch/x86/xen/enlighten_pvh.c | 9 --------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c index de503c225ae1..d7d68a39073a 100644 --- a/arch/x86/xen/enlighten_hvm.c +++ b/arch/x86/xen/enlighten_hvm.c @@ -1,3 +1,4 @@ +#include <linux/acpi.h> #include <linux/cpu.h> #include <linux/kexec.h> #include <linux/memblock.h> @@ -188,8 +189,6 @@ static void __init xen_hvm_guest_init(void) xen_hvm_init_time_ops(); xen_hvm_init_mmu_ops(); - if (xen_pvh_domain()) - machine_ops.emergency_restart = xen_emergency_restart; #ifdef CONFIG_KEXEC_CORE machine_ops.shutdown = xen_hvm_shutdown; machine_ops.crash_shutdown = xen_hvm_crash_shutdown; @@ -226,6 +225,26 @@ static uint32_t __init xen_platform_hvm(void) return xen_cpuid_base(); } +static __init void xen_hvm_guest_late_init(void) +{ +#ifdef CONFIG_XEN_PVH + /* Test for PVH domain (PVH boot path taken overrides ACPI flags). */ + if (!xen_pvh && + (x86_platform.legacy.rtc || !x86_platform.legacy.no_vga)) + return; + + /* PVH detected. */ + xen_pvh = true; + + /* 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; + + machine_ops.emergency_restart = xen_emergency_restart; + pv_info.name = "Xen PVH"; +#endif +} + const struct hypervisor_x86 x86_hyper_xen_hvm = { .name = "Xen HVM", .detect = xen_platform_hvm, @@ -233,5 +252,6 @@ const struct hypervisor_x86 x86_hyper_xen_hvm = { .pin_vcpu = xen_pin_vcpu, .x2apic_available = xen_x2apic_para_available, .init_mem_mapping = xen_hvm_init_mem_mapping, + .guest_late_init = xen_hvm_guest_late_init, }; EXPORT_SYMBOL(x86_hyper_xen_hvm); 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"))); struct hvm_start_info pvh_start_info; unsigned int pvh_start_info_sz = sizeof(pvh_start_info); -static void xen_pvh_arch_setup(void) -{ - /* Make sure we don't fall back to (default) ACPI_IRQ_MODEL_PIC. */ - if (nr_ioapics == 0) - acpi_irq_model = ACPI_IRQ_MODEL_PLATFORM; -} - static void __init init_pvh_bootparams(void) { struct xen_memory_map memmap; @@ -102,6 +95,4 @@ void __init xen_prepare_pvh(void) wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32)); init_pvh_bootparams(); - - x86_init.oem.arch_setup = xen_pvh_arch_setup; } -- 2.12.3
WARNING: multiple messages have this Message-ID (diff)
From: Juergen Gross <jgross@suse.com> To: linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Cc: Juergen Gross <jgross@suse.com>, len.brown@intel.com, rkrcmar@redhat.com, rjw@rjwysocki.net, mingo@redhat.com, pavel@ucw.cz, hpa@zytor.com, pbonzini@redhat.com, tglx@linutronix.de, boris.ostrovsky@oracle.com Subject: [PATCH 3/3] x86/xen: use guest_late_init to detect Xen PVH guest Date: Wed, 8 Nov 2017 10:07:39 +0100 [thread overview] Message-ID: <20171108090739.26491-4-jgross@suse.com> (raw) In-Reply-To: <20171108090739.26491-1-jgross@suse.com> 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> --- arch/x86/xen/enlighten_hvm.c | 24 ++++++++++++++++++++++-- arch/x86/xen/enlighten_pvh.c | 9 --------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c index de503c225ae1..d7d68a39073a 100644 --- a/arch/x86/xen/enlighten_hvm.c +++ b/arch/x86/xen/enlighten_hvm.c @@ -1,3 +1,4 @@ +#include <linux/acpi.h> #include <linux/cpu.h> #include <linux/kexec.h> #include <linux/memblock.h> @@ -188,8 +189,6 @@ static void __init xen_hvm_guest_init(void) xen_hvm_init_time_ops(); xen_hvm_init_mmu_ops(); - if (xen_pvh_domain()) - machine_ops.emergency_restart = xen_emergency_restart; #ifdef CONFIG_KEXEC_CORE machine_ops.shutdown = xen_hvm_shutdown; machine_ops.crash_shutdown = xen_hvm_crash_shutdown; @@ -226,6 +225,26 @@ static uint32_t __init xen_platform_hvm(void) return xen_cpuid_base(); } +static __init void xen_hvm_guest_late_init(void) +{ +#ifdef CONFIG_XEN_PVH + /* Test for PVH domain (PVH boot path taken overrides ACPI flags). */ + if (!xen_pvh && + (x86_platform.legacy.rtc || !x86_platform.legacy.no_vga)) + return; + + /* PVH detected. */ + xen_pvh = true; + + /* 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; + + machine_ops.emergency_restart = xen_emergency_restart; + pv_info.name = "Xen PVH"; +#endif +} + const struct hypervisor_x86 x86_hyper_xen_hvm = { .name = "Xen HVM", .detect = xen_platform_hvm, @@ -233,5 +252,6 @@ const struct hypervisor_x86 x86_hyper_xen_hvm = { .pin_vcpu = xen_pin_vcpu, .x2apic_available = xen_x2apic_para_available, .init_mem_mapping = xen_hvm_init_mem_mapping, + .guest_late_init = xen_hvm_guest_late_init, }; EXPORT_SYMBOL(x86_hyper_xen_hvm); 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"))); struct hvm_start_info pvh_start_info; unsigned int pvh_start_info_sz = sizeof(pvh_start_info); -static void xen_pvh_arch_setup(void) -{ - /* Make sure we don't fall back to (default) ACPI_IRQ_MODEL_PIC. */ - if (nr_ioapics == 0) - acpi_irq_model = ACPI_IRQ_MODEL_PLATFORM; -} - static void __init init_pvh_bootparams(void) { struct xen_memory_map memmap; @@ -102,6 +95,4 @@ void __init xen_prepare_pvh(void) wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32)); init_pvh_bootparams(); - - x86_init.oem.arch_setup = xen_pvh_arch_setup; } -- 2.12.3 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-11-08 9:08 UTC|newest] Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-11-08 9:07 [PATCH 0/3] x86/xen: support booting PVH guest via standard boot path Juergen Gross 2017-11-08 9:07 ` [PATCH 1/3] x86/acpi: add test for ACPI_FADT_NO_VGA Juergen Gross 2017-11-08 9:07 ` Juergen Gross 2017-11-08 9:07 ` [PATCH 2/3] x86: add guest_late_init hook to hypervisor_x86 structure Juergen Gross 2017-11-08 9:07 ` Juergen Gross 2017-11-08 9:13 ` Ingo Molnar 2017-11-08 9:27 ` Juergen Gross 2017-11-08 9:40 ` Ingo Molnar 2017-11-08 9:49 ` Juergen Gross 2017-11-08 9:58 ` Ingo Molnar 2017-11-08 9:58 ` Ingo Molnar 2017-11-08 9:49 ` Juergen Gross 2017-11-08 9:40 ` Ingo Molnar 2017-11-08 9:27 ` Juergen Gross 2017-11-08 9:13 ` Ingo Molnar 2017-11-08 9:53 ` Paolo Bonzini 2017-11-08 9:53 ` Paolo Bonzini 2017-11-08 9:07 ` Juergen Gross [this message] 2017-11-08 9:07 ` [PATCH 3/3] x86/xen: use guest_late_init to detect Xen PVH guest Juergen Gross 2017-11-08 11:18 ` Jan Beulich 2017-11-08 11:18 ` [Xen-devel] " Jan Beulich [not found] ` <5A02F633020000780018D26A@suse.com> 2017-11-08 11:55 ` Juergen Gross 2017-11-08 12:03 ` Paolo Bonzini 2017-11-08 12:24 ` Juergen Gross 2017-11-08 12:24 ` [Xen-devel] " Juergen Gross 2017-11-08 12:26 ` Paolo Bonzini 2017-11-08 12:40 ` Juergen Gross 2017-11-08 12:40 ` [Xen-devel] " Juergen Gross 2017-11-08 12:26 ` Paolo Bonzini 2017-11-08 12:03 ` Paolo Bonzini 2017-11-08 12:31 ` Jan Beulich 2017-11-08 12:31 ` [Xen-devel] " Jan Beulich 2017-11-08 12:45 ` Juergen Gross 2017-11-08 12:58 ` Jan Beulich 2017-11-08 12:58 ` [Xen-devel] " Jan Beulich [not found] ` <5A030D78020000780018D37B@suse.com> 2017-11-08 13:36 ` Juergen Gross 2017-11-08 14:10 ` Boris Ostrovsky 2017-11-08 14:10 ` [Xen-devel] " Boris Ostrovsky 2017-11-08 14:17 ` Juergen Gross 2017-11-08 14:17 ` [Xen-devel] " Juergen Gross 2017-11-08 14:24 ` Boris Ostrovsky 2017-11-08 14:24 ` Boris Ostrovsky 2017-11-08 13:36 ` Juergen Gross 2017-11-08 12:45 ` Juergen Gross 2017-11-08 11:55 ` Juergen Gross 2017-11-08 13:37 ` [PATCH 0/3] x86/xen: support booting PVH guest via standard boot path Boris Ostrovsky 2017-11-08 13:37 ` Boris Ostrovsky 2017-11-08 13:40 ` Juergen Gross 2017-11-08 13:40 ` Juergen Gross 2017-11-08 13:47 ` Boris Ostrovsky 2017-11-08 13:47 ` Boris Ostrovsky
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20171108090739.26491-4-jgross@suse.com \ --to=jgross@suse.com \ --cc=boris.ostrovsky@oracle.com \ --cc=hpa@zytor.com \ --cc=kvm@vger.kernel.org \ --cc=len.brown@intel.com \ --cc=linux-kernel@vger.kernel.org \ --cc=mingo@redhat.com \ --cc=pavel@ucw.cz \ --cc=pbonzini@redhat.com \ --cc=rjw@rjwysocki.net \ --cc=rkrcmar@redhat.com \ --cc=tglx@linutronix.de \ --cc=x86@kernel.org \ --cc=xen-devel@lists.xenproject.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.