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: boris.ostrovsky@oracle.com, tglx@linutronix.de, mingo@redhat.com,
	hpa@zytor.com, roger.pau@citrix.com, rkrcmar@redhat.com,
	maran.wilson@oracle.com
Subject: [PATCH v8 5/7] xen/pvh: Move Xen code for getting mem map via hcall out of common file
Date: Wed,  5 Dec 2018 22:05:30 -0800	[thread overview]
Message-ID: <1544076330-21992-3-git-send-email-maran.wilson@oracle.com> (raw)
In-Reply-To: <1544076152-21637-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 | 29 ++++++++++++++---------------
 arch/x86/xen/enlighten_pvh.c      | 20 ++++++++++++++++++++
 2 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/arch/x86/platform/pvh/enlighten.c b/arch/x86/platform/pvh/enlighten.c
index 637bd74ba32d..8040b3fbf545 100644
--- a/arch/x86/platform/pvh/enlighten.c
+++ b/arch/x86/platform/pvh/enlighten.c
@@ -8,11 +8,7 @@
 #include <asm/e820/api.h>
 #include <asm/x86_init.h>
 
-#include <asm/xen/interface.h>
-#include <asm/xen/hypercall.h>
-
 #include <xen/xen.h>
-#include <xen/interface/memory.h>
 #include <xen/interface/hvm/start_info.h>
 
 /*
@@ -31,21 +27,24 @@ static u64 pvh_get_root_pointer(void)
 	return pvh_start_info.rsdp_paddr;
 }
 
+/*
+ * 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 41a7d6ad74e0..35b7599d2d0b 100644
--- a/arch/x86/xen/enlighten_pvh.c
+++ b/arch/x86/xen/enlighten_pvh.c
@@ -1,13 +1,18 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/acpi.h>
 
+#include <xen/hvc-console.h>
+
 #include <asm/io_apic.h>
 #include <asm/hypervisor.h>
+#include <asm/e820/api.h>
 
 #include <xen/xen.h>
 #include <asm/xen/interface.h>
 #include <asm/xen/hypercall.h>
 
+#include <xen/interface/memory.h>
+
 /*
  * PVH variables.
  *
@@ -28,3 +33,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


  parent reply	other threads:[~2018-12-06  6:06 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-06  6:02 [PATCH v8 0/7] KVM: x86: Allow Qemu/KVM to use PVH entry point Maran Wilson
2018-12-06  6:04 ` [PATCH v8 1/7] xen/pvh: Split CONFIG_XEN_PVH into CONFIG_PVH and CONFIG_XEN_PVH Maran Wilson
2018-12-06  6:04 ` Maran Wilson
2018-12-06 22:11   ` Paolo Bonzini
2018-12-06 22:34     ` Boris Ostrovsky
2018-12-06 22:34     ` Boris Ostrovsky
2018-12-06 22:49       ` Paolo Bonzini
2018-12-06 22:49       ` Paolo Bonzini
2018-12-06 23:11         ` Boris Ostrovsky
2018-12-06 23:30           ` Paolo Bonzini
2018-12-06 23:30           ` Paolo Bonzini
2018-12-06 23:36             ` Andrew Cooper
2018-12-06 23:36             ` [Xen-devel] " Andrew Cooper
2018-12-06 23:11         ` Boris Ostrovsky
2018-12-07  6:02     ` Juergen Gross
2018-12-07  6:02     ` Juergen Gross
2018-12-07 13:41       ` Paolo Bonzini
2018-12-07 13:41       ` Paolo Bonzini
2018-12-07 13:50         ` Juergen Gross
2018-12-07 13:52           ` Paolo Bonzini
2018-12-07 13:58             ` Juergen Gross
2018-12-07 15:14               ` Paolo Bonzini
2018-12-07 18:21                 ` Maran Wilson
2018-12-07 18:21                 ` Maran Wilson
2018-12-07 15:14               ` Paolo Bonzini
2018-12-07 13:58             ` Juergen Gross
2018-12-07 13:52           ` Paolo Bonzini
2018-12-07 13:50         ` Juergen Gross
2018-12-06 22:11   ` Paolo Bonzini
2018-12-06  6:04 ` [PATCH v8 2/7] xen/pvh: Move PVH entry code out of Xen specific tree Maran Wilson
2018-12-06  6:04 ` Maran Wilson
2018-12-06  6:05 ` [PATCH v8 3/7] xen/pvh: Create a new file for Xen specific PVH code Maran Wilson
2018-12-06  6:05 ` Maran Wilson
2018-12-06  6:05 ` [PATCH v8 4/7] xen/pvh: Move Xen specific PVH VM initialization out of common file Maran Wilson
2018-12-06  6:05 ` Maran Wilson
2018-12-06  6:05 ` [PATCH v8 5/7] xen/pvh: Move Xen code for getting mem map via hcall " Maran Wilson
2018-12-06  6:05 ` Maran Wilson [this message]
2018-12-06  6:06 ` [PATCH v8 6/7] xen/pvh: Add memory map pointer to hvm_start_info struct Maran Wilson
2018-12-06  6:06 ` Maran Wilson
2018-12-06  6:06 ` [PATCH v8 7/7] KVM: x86: Allow Qemu/KVM to use PVH entry point Maran Wilson
2018-12-06  6:06 ` Maran Wilson
2018-12-06 22:05   ` Paolo Bonzini
2018-12-06 22:05   ` Paolo Bonzini
2018-12-06 21:21 ` [PATCH v8 0/7] " Paolo Bonzini
2018-12-06 21:21 ` Paolo Bonzini
2018-12-06 21:37   ` Borislav Petkov
2018-12-06 21:37   ` Borislav Petkov
2018-12-06 21:58     ` Boris Ostrovsky
2018-12-06 21:58     ` Boris Ostrovsky
2018-12-06 22:14       ` Paolo Bonzini
2018-12-06 22:14       ` Paolo Bonzini
2018-12-07 10:25         ` Borislav Petkov
2018-12-07 10:25         ` Borislav Petkov
2018-12-07 16:07           ` [Xen-devel] " Boris Ostrovsky
2018-12-07 19:22             ` Borislav Petkov
2018-12-07 19:22             ` Borislav Petkov
2018-12-07 16:07           ` Boris Ostrovsky
2018-12-12 18:09   ` Maran Wilson
2018-12-12 18:17     ` Boris Ostrovsky
2018-12-12 18:17     ` Boris Ostrovsky
2018-12-13 13:13     ` Paolo Bonzini
2018-12-13 13:13     ` Paolo Bonzini
2018-12-12 18:09   ` 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=1544076330-21992-3-git-send-email-maran.wilson@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.