From: Ankur Arora <ankur.a.arora@oracle.com>
To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org
Cc: jgross@suse.com, sstabellini@kernel.org, konrad.wilk@oracle.com,
ankur.a.arora@oracle.com, pbonzini@redhat.com,
boris.ostrovsky@oracle.com, joao.m.martins@oracle.com
Subject: [Xen-devel] [RFC PATCH 02/16] x86/xen: cpuid support in xenhost_t
Date: Thu, 9 May 2019 10:25:26 -0700 [thread overview]
Message-ID: <20190509172540.12398-3-ankur.a.arora@oracle.com> (raw)
Message-ID: <20190509172526.2F1VgYWfJWjIq6YNOOj-S4GeyTlR9-m4tl6KR5QkpbE@z> (raw)
In-Reply-To: <20190509172540.12398-1-ankur.a.arora@oracle.com>
xen_cpuid_base() is used to probe and setup features early in a
guest's lifetime.
We want this to behave differently depending on xenhost->type: for
instance, local xenhosts cannot intercept the cpuid instruction at all.
Add op (*cpuid_base)() in xenhost_ops_t.
Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
---
arch/x86/include/asm/xen/hypervisor.h | 2 +-
arch/x86/pci/xen.c | 2 +-
arch/x86/xen/enlighten_hvm.c | 7 +++++--
arch/x86/xen/enlighten_pv.c | 16 +++++++++++++++-
arch/x86/xen/enlighten_pvh.c | 4 ++++
drivers/tty/hvc/hvc_xen.c | 2 +-
drivers/xen/grant-table.c | 3 ++-
drivers/xen/xenbus/xenbus_xs.c | 3 ++-
include/xen/xenhost.h | 21 +++++++++++++++++++++
9 files changed, 52 insertions(+), 8 deletions(-)
diff --git a/arch/x86/include/asm/xen/hypervisor.h b/arch/x86/include/asm/xen/hypervisor.h
index 39171b3646bb..6c4cdcdf997d 100644
--- a/arch/x86/include/asm/xen/hypervisor.h
+++ b/arch/x86/include/asm/xen/hypervisor.h
@@ -53,7 +53,7 @@ static inline bool xen_x2apic_para_available(void)
#else
static inline bool xen_x2apic_para_available(void)
{
- return (xen_cpuid_base() != 0);
+ return (xen_cpuid_base(NULL) != 0);
}
#endif
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index 9112d1cb397b..d1a3b9f08289 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -431,7 +431,7 @@ void __init xen_msi_init(void)
* event channels for MSI handling and instead use regular
* APIC processing
*/
- uint32_t eax = cpuid_eax(xen_cpuid_base() + 4);
+ uint32_t eax = cpuid_eax(xenhost_cpuid_base(xh_default) + 4);
if (((eax & XEN_HVM_CPUID_X2APIC_VIRT) && x2apic_mode) ||
((eax & XEN_HVM_CPUID_APIC_ACCESS_VIRT) && boot_cpu_has(X86_FEATURE_APIC)))
diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
index 100452f4f44c..ffc5791675b2 100644
--- a/arch/x86/xen/enlighten_hvm.c
+++ b/arch/x86/xen/enlighten_hvm.c
@@ -83,7 +83,10 @@ static void __init xen_hvm_init_mem_mapping(void)
xen_vcpu_info_reset(0);
}
+extern uint32_t xen_pv_cpuid_base(xenhost_t *xh);
+
xenhost_ops_t xh_hvm_ops = {
+ .cpuid_base = xen_pv_cpuid_base,
};
xenhost_ops_t xh_hvm_nested_ops = {
@@ -94,7 +97,7 @@ static void __init init_hvm_pv_info(void)
int major, minor;
uint32_t eax, ebx, ecx, edx, base;
- base = xen_cpuid_base();
+ base = xenhost_cpuid_base(xh_default);
eax = cpuid_eax(base + 1);
major = eax >> 16;
@@ -250,7 +253,7 @@ static uint32_t __init xen_platform_hvm(void)
if (xen_pv_domain() || xen_nopv)
return 0;
- return xen_cpuid_base();
+ return xenhost_cpuid_base(xh_default);
}
static __init void xen_hvm_guest_late_init(void)
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index bb6e811c1525..a4e04b0cc596 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -1189,10 +1189,23 @@ static void __init xen_dom0_set_legacy_features(void)
x86_platform.legacy.rtc = 1;
}
+uint32_t xen_pv_cpuid_base(xenhost_t *xh)
+{
+ return hypervisor_cpuid_base("XenVMMXenVMM", 2);
+}
+
+uint32_t xen_pv_nested_cpuid_base(xenhost_t *xh)
+{
+ return hypervisor_cpuid_base("XenVMMXenVMM",
+ 2 /* nested specific leaf? */);
+}
+
xenhost_ops_t xh_pv_ops = {
+ .cpuid_base = xen_pv_cpuid_base,
};
xenhost_ops_t xh_pv_nested_ops = {
+ .cpuid_base = xen_pv_nested_cpuid_base,
};
/* First C function to be called on Xen boot */
@@ -1469,7 +1482,8 @@ static int xen_cpu_dead_pv(unsigned int cpu)
static uint32_t __init xen_platform_pv(void)
{
if (xen_pv_domain())
- return xen_cpuid_base();
+ /* xenhost is setup in xen_start_kernel. */
+ return xenhost_cpuid_base(xh_default);
return 0;
}
diff --git a/arch/x86/xen/enlighten_pvh.c b/arch/x86/xen/enlighten_pvh.c
index 826c296d27a3..c07eba169572 100644
--- a/arch/x86/xen/enlighten_pvh.c
+++ b/arch/x86/xen/enlighten_pvh.c
@@ -29,6 +29,10 @@ void __init xen_pvh_init(void)
u32 msr;
u64 pfn;
+ /*
+ * Note: we have already called xen_cpuid_base() in
+ * hypervisor_specific_init()
+ */
xenhost_register(xenhost_r1, &xh_hvm_ops);
/*
diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c
index dc43fa96c3de..5e5ca35d7187 100644
--- a/drivers/tty/hvc/hvc_xen.c
+++ b/drivers/tty/hvc/hvc_xen.c
@@ -595,7 +595,7 @@ console_initcall(xen_cons_init);
#ifdef CONFIG_X86
static void xen_hvm_early_write(uint32_t vtermno, const char *str, int len)
{
- if (xen_cpuid_base())
+ if (xen_cpuid_base(xh_default))
outsb(0xe9, str, len);
}
#else
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 7ea6fb6a2e5d..98af259d0d4f 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -50,6 +50,7 @@
#endif
#include <xen/xen.h>
+#include <xen/xenhost.h>
#include <xen/interface/xen.h>
#include <xen/page.h>
#include <xen/grant_table.h>
@@ -1318,7 +1319,7 @@ static bool gnttab_need_v2(void)
uint32_t base, width;
if (xen_pv_domain()) {
- base = xen_cpuid_base();
+ base = xenhost_cpuid_base(xh_default);
if (cpuid_eax(base) < 5)
return false; /* Information not available, use V1. */
width = cpuid_ebx(base + 5) &
diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
index 49a3874ae6bb..3236d1b1fa01 100644
--- a/drivers/xen/xenbus/xenbus_xs.c
+++ b/drivers/xen/xenbus/xenbus_xs.c
@@ -49,6 +49,7 @@
#include <asm/xen/hypervisor.h>
#include <xen/xenbus.h>
#include <xen/xen.h>
+#include <xen/xenhost.h>
#include "xenbus.h"
/*
@@ -722,7 +723,7 @@ static bool xen_strict_xenbus_quirk(void)
#ifdef CONFIG_X86
uint32_t eax, ebx, ecx, edx, base;
- base = xen_cpuid_base();
+ base = xenhost_cpuid_base(xh_default);
cpuid(base + 1, &eax, &ebx, &ecx, &edx);
if ((eax >> 16) < 4)
diff --git a/include/xen/xenhost.h b/include/xen/xenhost.h
index a58e883f144e..13a70bdadfd2 100644
--- a/include/xen/xenhost.h
+++ b/include/xen/xenhost.h
@@ -1,6 +1,9 @@
#ifndef __XENHOST_H
#define __XENHOST_H
+#include <xen/interface/features.h>
+#include <xen/interface/xen.h>
+#include <asm/xen/hypervisor.h>
/*
* Xenhost abstracts out the Xen interface. It co-exists with the PV/HVM/PVH
* abstractions (x86_init, hypervisor_x86, pv_ops etc) and is meant to
@@ -70,6 +73,16 @@ typedef struct {
} xenhost_t;
typedef struct xenhost_ops {
+ /*
+ * xen_cpuid is used to probe features early.
+ * xenhost_r0:
+ * Implementation could not use cpuid at all: it's difficult to
+ * intercept cpuid instruction locally.
+ * xenhost_r1:
+ * xenhost_r2:
+ * Separate cpuid-leafs?
+ */
+ uint32_t (*cpuid_base)(xenhost_t *xenhost);
} xenhost_ops_t;
extern xenhost_t *xh_default, *xh_remote;
@@ -92,4 +105,12 @@ void __xenhost_unregister(enum xenhost_type type);
for ((xh) = (xenhost_t **) &xenhosts[0]; \
(((xh) - (xenhost_t **)&xenhosts) < 2) && (*xh)->type != xenhost_invalid; (xh)++)
+static inline uint32_t xenhost_cpuid_base(xenhost_t *xh)
+{
+ if (xh)
+ return (xh->ops->cpuid_base)(xh);
+ else
+ return xen_cpuid_base();
+}
+
#endif /* __XENHOST_H */
--
2.20.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-05-09 17:25 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-09 17:25 [Xen-devel] [RFC PATCH 00/16] xenhost support Ankur Arora
2019-05-09 17:25 ` [Xen-devel] [RFC PATCH 01/16] x86/xen: add xenhost_t interface Ankur Arora
2019-06-07 15:04 ` Juergen Gross
2019-06-11 7:16 ` Ankur Arora
2019-06-14 11:52 ` Juergen Gross
2019-05-09 17:25 ` Ankur Arora
2019-05-09 17:25 ` Ankur Arora [this message]
2019-05-09 17:25 ` [Xen-devel] [RFC PATCH 02/16] x86/xen: cpuid support in xenhost_t Ankur Arora
2019-06-12 21:09 ` Andrew Cooper
2019-05-09 17:25 ` [Xen-devel] [RFC PATCH 03/16] x86/xen: make hypercall_page generic Ankur Arora
2019-05-09 17:25 ` Ankur Arora
2019-05-09 17:25 ` [RFC PATCH 04/16] x86/xen: hypercall support for xenhost_t Ankur Arora
2019-05-09 17:25 ` [Xen-devel] " Ankur Arora
2019-06-12 21:15 ` Andrew Cooper
2019-06-14 7:20 ` Ankur Arora
2019-06-14 7:35 ` Juergen Gross
2019-06-14 8:00 ` Andrew Cooper
2019-05-09 17:25 ` [RFC PATCH 05/16] x86/xen: add feature support in xenhost_t Ankur Arora
2019-05-09 17:25 ` [Xen-devel] " Ankur Arora
2019-05-09 17:25 ` [Xen-devel] [RFC PATCH 06/16] x86/xen: add shared_info support to xenhost_t Ankur Arora
2019-06-07 15:08 ` Juergen Gross
2019-06-08 5:01 ` Ankur Arora
2019-05-09 17:25 ` Ankur Arora
2019-05-09 17:25 ` [RFC PATCH 07/16] x86/xen: make vcpu_info part of xenhost_t Ankur Arora
2019-05-09 17:25 ` [Xen-devel] " Ankur Arora
2019-06-14 11:53 ` Juergen Gross
2019-06-17 6:28 ` Ankur Arora
2019-05-09 17:25 ` [RFC PATCH 08/16] x86/xen: irq/upcall handling with multiple xenhosts Ankur Arora
2019-05-09 17:25 ` [Xen-devel] " Ankur Arora
2019-06-14 12:01 ` Juergen Gross
2019-05-09 17:25 ` [RFC PATCH 09/16] xen/evtchn: support evtchn in xenhost_t Ankur Arora
2019-05-09 17:25 ` [Xen-devel] " Ankur Arora
2019-06-14 12:04 ` Juergen Gross
2019-06-17 6:09 ` Ankur Arora
2019-05-09 17:25 ` [RFC PATCH 10/16] xen/balloon: support ballooning " Ankur Arora
2019-05-09 17:25 ` [Xen-devel] " Ankur Arora
2019-06-17 9:28 ` Juergen Gross
2019-06-19 2:24 ` Ankur Arora
2019-05-09 17:25 ` [RFC PATCH 11/16] xen/grant-table: make grant-table xenhost aware Ankur Arora
2019-05-09 17:25 ` [Xen-devel] " Ankur Arora
2019-06-17 9:36 ` Juergen Gross
2019-06-19 2:25 ` Ankur Arora
2019-05-09 17:25 ` [RFC PATCH 12/16] xen/xenbus: support xenbus frontend/backend with xenhost_t Ankur Arora
2019-05-09 17:25 ` [Xen-devel] " Ankur Arora
2019-06-17 9:50 ` Juergen Gross
2019-06-19 2:38 ` Ankur Arora
2019-05-09 17:25 ` [Xen-devel] [RFC PATCH 13/16] drivers/xen: gnttab, evtchn, xenbus API changes Ankur Arora
2019-06-17 10:07 ` Juergen Gross
2019-06-19 2:55 ` Ankur Arora
2019-05-09 17:25 ` Ankur Arora
2019-05-09 17:25 ` [Xen-devel] [RFC PATCH 14/16] xen/blk: " Ankur Arora
2019-06-17 10:14 ` Juergen Gross
2019-06-19 2:59 ` Ankur Arora
2019-05-09 17:25 ` Ankur Arora
2019-05-09 17:25 ` [RFC PATCH 15/16] xen/net: " Ankur Arora
2019-05-09 17:25 ` [Xen-devel] " Ankur Arora
2019-06-17 10:14 ` Juergen Gross
2019-05-09 17:25 ` [Xen-devel] [RFC PATCH 16/16] xen/grant-table: host_addr fixup in mapping on xenhost_r0 Ankur Arora
2019-06-17 10:55 ` Juergen Gross
2019-06-19 3:02 ` Ankur Arora
2019-05-09 17:25 ` Ankur Arora
2019-06-07 14:51 ` [Xen-devel] [RFC PATCH 00/16] xenhost support Juergen Gross
2019-06-07 15:22 ` Joao Martins
2019-06-07 16:21 ` Juergen Gross
2019-06-08 5:50 ` Ankur Arora
2019-06-08 5:33 ` Ankur Arora
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=20190509172540.12398-3-ankur.a.arora@oracle.com \
--to=ankur.a.arora@oracle.com \
--cc=boris.ostrovsky@oracle.com \
--cc=jgross@suse.com \
--cc=joao.m.martins@oracle.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=sstabellini@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).