All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maran Wilson <maran.wilson@oracle.com>
To: x86@kernel.org, xen-devel@lists.xenproject.org,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	pbonzini@redhat.com, jgross@suse.com
Cc: rkrcmar@redhat.com, maran.wilson@oracle.com, mingo@redhat.com,
	hpa@zytor.com, boris.ostrovsky@oracle.com, tglx@linutronix.de,
	roger.pau@citrix.com
Subject: [PATCH v5 5/7] xen/pvh: Move Xen code for getting mem map via hcall out of common file
Date: Tue, 20 Mar 2018 12:19:46 -0700	[thread overview]
Message-ID: <1521573586-17463-3-git-send-email-maran.wilson__46241.718871943$1521573556$gmane$org@oracle.com> (raw)
In-Reply-To: <1521573369-17216-1-git-send-email-maran.wilson@oracle.com>

We need to refactor PVH entry code so that support for other hypervisors
like Qemu/KVM can be added more easily.

The original design for PVH entry in Xen guests relies on being able to
obtain the memory map from the hypervisor using a hypercall. When we
extend the PVH entry ABI to support other hypervisors like Qemu/KVM,
a new mechanism will be added that allows the guest to get the memory
map without needing to use hypercalls.

For Xen guests, the hypercall approach will still be supported. In
preparation for adding support for other hypervisors, we can move the
code that uses hypercalls into the Xen specific file. This will 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: Juergen Gross <jgross@suse.com>
---
 arch/x86/platform/pvh/enlighten.c | 28 ++++++++++++++--------------
 arch/x86/xen/enlighten_pvh.c      | 20 ++++++++++++++++++++
 2 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/arch/x86/platform/pvh/enlighten.c b/arch/x86/platform/pvh/enlighten.c
index b463ee30517a..347ecb1860d5 100644
--- a/arch/x86/platform/pvh/enlighten.c
+++ b/arch/x86/platform/pvh/enlighten.c
@@ -7,9 +7,6 @@
 #include <asm/hypervisor.h>
 #include <asm/e820/api.h>
 
-#include <asm/xen/interface.h>
-#include <asm/xen/hypercall.h>
-
 #include <xen/interface/memory.h>
 #include <xen/interface/hvm/start_info.h>
 
@@ -24,21 +21,24 @@ 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);
 
+/*
+ * Xen guests are able to obtain the memory map from the hypervisor via the
+ * HYPERVISOR_memory_op hypercall.
+ * If we are trying to boot a Xen PVH guest, it is expected that the kernel
+ * will have been configured to provide an override for this routine to do
+ * just that.
+ */
+void __init __weak mem_map_via_hcall(struct boot_params *ptr __maybe_unused)
+{
+	xen_raw_printk("Error: Could not find memory map\n");
+	BUG();
+}
+
 static void __init init_pvh_bootparams(void)
 {
-	struct xen_memory_map memmap;
-	int rc;
-
 	memset(&pvh_bootparams, 0, sizeof(pvh_bootparams));
 
-	memmap.nr_entries = ARRAY_SIZE(pvh_bootparams.e820_table);
-	set_xen_guest_handle(memmap.buffer, pvh_bootparams.e820_table);
-	rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap);
-	if (rc) {
-		xen_raw_printk("XENMEM_memory_map failed (%d)\n", rc);
-		BUG();
-	}
-	pvh_bootparams.e820_entries = memmap.nr_entries;
+	mem_map_via_hcall(&pvh_bootparams);
 
 	if (pvh_bootparams.e820_entries < E820_MAX_ENTRIES_ZEROPAGE - 1) {
 		pvh_bootparams.e820_table[pvh_bootparams.e820_entries].addr =
diff --git a/arch/x86/xen/enlighten_pvh.c b/arch/x86/xen/enlighten_pvh.c
index 08fc63d14ae5..00658d4bc4f4 100644
--- a/arch/x86/xen/enlighten_pvh.c
+++ b/arch/x86/xen/enlighten_pvh.c
@@ -1,10 +1,15 @@
 #include <linux/acpi.h>
 
+#include <xen/hvc-console.h>
+
 #include <asm/io_apic.h>
+#include <asm/e820/api.h>
 
 #include <asm/xen/interface.h>
 #include <asm/xen/hypercall.h>
 
+#include <xen/interface/memory.h>
+
 /*
  * PVH variables.
  *
@@ -24,3 +29,18 @@ void __init xen_pvh_init(void)
 	pfn = __pa(hypercall_page);
 	wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32));
 }
+
+void __init mem_map_via_hcall(struct boot_params *boot_params_p)
+{
+	struct xen_memory_map memmap;
+	int rc;
+
+	memmap.nr_entries = ARRAY_SIZE(boot_params_p->e820_table);
+	set_xen_guest_handle(memmap.buffer, boot_params_p->e820_table);
+	rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap);
+	if (rc) {
+		xen_raw_printk("XENMEM_memory_map failed (%d)\n", rc);
+		BUG();
+	}
+	boot_params_p->e820_entries = memmap.nr_entries;
+}
-- 
2.16.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-03-20 19:20 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-28 18:27 [RFC PATCH v4 0/7] KVM: x86: Allow Qemu/KVM to use PVH entry point Maran Wilson
2018-02-28 18:27 ` Maran Wilson
2018-02-28 18:27 ` [RFC PATCH v4 1/7] xen/pvh: Split CONFIG_XEN_PVH into CONFIG_PVH and CONFIG_XEN_PVH Maran Wilson
2018-02-28 18:27 ` Maran Wilson
2018-02-28 21:07   ` Konrad Rzeszutek Wilk
2018-02-28 21:07   ` [Xen-devel] " Konrad Rzeszutek Wilk
2018-03-01  5:43     ` Juergen Gross
2018-03-01  5:43     ` [Xen-devel] " Juergen Gross
2018-03-01  7:19   ` Juergen Gross
2018-03-01  7:19   ` Juergen Gross
2018-03-01 15:02   ` Boris Ostrovsky
2018-03-01 15:02   ` Boris Ostrovsky
2018-03-01 15:17     ` Paolo Bonzini
2018-03-01 15:17     ` Paolo Bonzini
2018-03-01 17:24       ` Maran Wilson
2018-03-01 17:24       ` Maran Wilson
2018-02-28 18:27 ` [RFC PATCH v4 2/7] xen/pvh: Move PVH entry code out of Xen specific tree Maran Wilson
2018-02-28 21:08   ` [Xen-devel] " Konrad Rzeszutek Wilk
2018-02-28 21:35     ` Paolo Bonzini
2018-02-28 21:35     ` [Xen-devel] " Paolo Bonzini
2018-03-01  6:11       ` Juergen Gross
2018-03-01  6:11       ` [Xen-devel] " Juergen Gross
2018-03-01  8:46         ` Paolo Bonzini
2018-03-01 16:15           ` Boris Ostrovsky
2018-03-01 16:15           ` [Xen-devel] " Boris Ostrovsky
2018-03-01  8:46         ` Paolo Bonzini
2018-03-01 17:22       ` [Xen-devel] " Maran Wilson
2018-03-01 17:22       ` Maran Wilson
2018-02-28 21:08   ` Konrad Rzeszutek Wilk
2018-02-28 18:27 ` Maran Wilson
2018-02-28 18:27 ` [RFC PATCH v4 3/7] xen/pvh: Create a new file for Xen specific PVH code Maran Wilson
2018-02-28 18:27 ` Maran Wilson
2018-02-28 21:09   ` Konrad Rzeszutek Wilk
2018-02-28 21:09   ` [Xen-devel] " Konrad Rzeszutek Wilk
2018-02-28 18:28 ` [RFC PATCH v4 4/7] xen/pvh: Move Xen specific PVH VM initialization out of common code Maran Wilson
2018-02-28 21:10   ` [Xen-devel] " Konrad Rzeszutek Wilk
2018-02-28 21:10     ` Konrad Rzeszutek Wilk
2018-03-01  7:20   ` Juergen Gross
2018-03-01  7:20   ` Juergen Gross
2018-03-01 16:05   ` Boris Ostrovsky
2018-03-01 17:43     ` Maran Wilson
2018-03-01 17:43     ` Maran Wilson
2018-03-01 16:05   ` Boris Ostrovsky
2018-02-28 18:28 ` Maran Wilson
2018-02-28 18:28 ` [RFC PATCH v4 5/7] xen/pvh: Move Xen code for getting mem map via hcall out of common file Maran Wilson
2018-03-01  7:21   ` Juergen Gross
2018-03-01  7:21   ` Juergen Gross
2018-02-28 18:28 ` Maran Wilson
2018-02-28 18:28 ` [RFC PATCH v4 6/7] xen/pvh: Add memory map pointer to hvm_start_info struct Maran Wilson
2018-02-28 18:28 ` Maran Wilson
2018-03-01  7:29   ` Juergen Gross
2018-03-01  7:29   ` Juergen Gross
2018-03-01  7:41     ` Jan Beulich
2018-03-01  7:41       ` Jan Beulich
2018-03-01 17:19       ` Maran Wilson
2018-03-01 17:19       ` Maran Wilson
2018-03-01  7:41     ` Jan Beulich
2018-03-01 15:23   ` [Xen-devel] " Konrad Rzeszutek Wilk
2018-03-01 15:23     ` Konrad Rzeszutek Wilk
2018-02-28 18:28 ` [RFC PATCH v4 7/7] KVM: x86: Allow Qemu/KVM to use PVH entry point Maran Wilson
2018-02-28 18:28 ` Maran Wilson
2018-03-01  7:31   ` Juergen Gross
2018-03-01  7:31   ` Juergen Gross
2018-02-28 21:39 ` [RFC PATCH v4 0/7] " Paolo Bonzini
2018-02-28 21:39 ` Paolo Bonzini
2018-03-20 19:16 ` [PATCH v5 " Maran Wilson
2018-03-20 19:18   ` [PATCH v5 1/7] xen/pvh: Split CONFIG_XEN_PVH into CONFIG_PVH and CONFIG_XEN_PVH Maran Wilson
2018-03-20 19:18   ` Maran Wilson
2018-03-20 19:23     ` Randy Dunlap
2018-03-20 20:55       ` Maran Wilson
2018-03-20 20:55       ` Maran Wilson
2018-03-20 19:23     ` Randy Dunlap
2018-03-20 19:18   ` [PATCH v5 2/7] xen/pvh: Move PVH entry code out of Xen specific tree Maran Wilson
2018-03-20 19:18   ` Maran Wilson
2018-03-20 19:19   ` [PATCH v5 3/7] xen/pvh: Create a new file for Xen specific PVH code Maran Wilson
2018-03-20 19:19   ` Maran Wilson
2018-03-20 19:19   ` [PATCH v5 4/7] xen/pvh: Move Xen specific PVH VM initialization out of common file Maran Wilson
2018-03-20 19:19   ` Maran Wilson
2018-03-20 19:19   ` Maran Wilson [this message]
2018-03-20 19:19   ` [PATCH v5 5/7] xen/pvh: Move Xen code for getting mem map via hcall " Maran Wilson
2018-03-20 19:20   ` [PATCH v5 6/7] xen/pvh: Add memory map pointer to hvm_start_info struct Maran Wilson
2018-03-20 19:20   ` Maran Wilson
2018-03-20 19:21   ` [PATCH v5 7/7] KVM: x86: Allow Qemu/KVM to use PVH entry point Maran Wilson
2018-03-20 19:21   ` Maran Wilson
2018-03-20 19:16 ` [PATCH v5 0/7] " Maran Wilson

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='1521573586-17463-3-git-send-email-maran.wilson__46241.718871943$1521573556$gmane$org@oracle.com' \
    --to=maran.wilson@oracle.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=roger.pau@citrix.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: link
Be 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.