From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: JBeulich@suse.com, ian.campbell@citrix.com,
ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com,
eddie.dong@intel.com, jun.nakajima@intel.com, keir@xen.org
Cc: yang.z.zhang@intel.com, andrew.cooper3@citrix.com,
boris.ostrovsky@oracle.com, xen-devel@lists.xen.org
Subject: [PATCH v7 1/3] xen/libxc: Allow changing max number of hypervisor cpuid leaves
Date: Mon, 24 Mar 2014 19:18:37 -0400 [thread overview]
Message-ID: <1395703119-11502-2-git-send-email-boris.ostrovsky@oracle.com> (raw)
In-Reply-To: <1395703119-11502-1-git-send-email-boris.ostrovsky@oracle.com>
Add support for changing max number of hypervisor leaves from configuration
file.
This number can be specified using xl's standard 'cpuid' option. Only lowest
8 bits of leaf's 0x4000xx00 eax register are processed, all others are ignored.
The changes allow us to revert commit 80ecb40362365ba77e68fc609de8bd3b7208ae19
which is most likely no longer needed now anyway (Solaris bug that it addressed
has been fixed and backported to earlier releases) but leave possibility of
running unpatched version of Solaris by forcing number of leaves to 2 in the
configuration file.
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
tools/libxc/xc_cpuid_x86.c | 11 +++++++++++
xen/arch/x86/traps.c | 16 +++++++++-------
xen/include/public/arch-x86/cpuid.h | 2 ++
3 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
index bbbf9b8..45adcf0 100644
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -555,6 +555,17 @@ static int xc_cpuid_policy(
{
xc_dominfo_t info;
+ /*
+ * For hypervisor leaves (0x4000XXXX) only 0x4000xx00.EAX[7:0] bits (max
+ * number of leaves) can be set by user. Hypervisor will enforce this so
+ * all other bits are don't-care and we can set them to zero.
+ */
+ if ( (input[0] & 0xffff0000) == 0x40000000 )
+ {
+ regs[0] = regs[1] = regs[2] = regs[3] = 0;
+ return 0;
+ }
+
if ( xc_domain_getinfo(xch, domid, 1, &info) == 0 )
return -EINVAL;
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index c462317..e4dec4b 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -677,15 +677,17 @@ int cpuid_hypervisor_leaves( uint32_t idx, uint32_t sub_idx,
struct domain *d = current->domain;
/* Optionally shift out of the way of Viridian architectural leaves. */
uint32_t base = is_viridian_domain(d) ? 0x40000100 : 0x40000000;
- uint32_t limit;
+ uint32_t limit, dummy;
idx -= base;
-
- /*
- * Some Solaris PV drivers fail if max > base + 2. Help them out by
- * hiding the PVRDTSCP leaf if PVRDTSCP is disabled.
- */
- limit = (d->arch.tsc_mode < TSC_MODE_PVRDTSCP) ? 2 : 3;
+ if ( idx > XEN_CPUID_MAX_NUM_LEAVES )
+ return 0; /* Avoid unnecessary pass through domain_cpuid() */
+
+ /* Number of leaves may be user-specified */
+ domain_cpuid(d, base, 0, &limit, &dummy, &dummy, &dummy);
+ limit &= 0xff;
+ if ( (limit < 1) || (limit > XEN_CPUID_MAX_NUM_LEAVES) )
+ limit = XEN_CPUID_MAX_NUM_LEAVES;
if ( idx > limit )
return 0;
diff --git a/xen/include/public/arch-x86/cpuid.h b/xen/include/public/arch-x86/cpuid.h
index d9bd627..19fc9dd 100644
--- a/xen/include/public/arch-x86/cpuid.h
+++ b/xen/include/public/arch-x86/cpuid.h
@@ -65,4 +65,6 @@
#define _XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD 0
#define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD (1u<<0)
+#define XEN_CPUID_MAX_NUM_LEAVES 3
+
#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
--
1.7.10.4
next prev parent reply other threads:[~2014-03-24 23:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-24 23:18 [PATCH v7 0/3] Expose HW APIC virtualization support to HVM guests Boris Ostrovsky
2014-03-24 23:18 ` Boris Ostrovsky [this message]
2014-03-25 9:42 ` [PATCH v7 1/3] xen/libxc: Allow changing max number of hypervisor cpuid leaves Jan Beulich
2014-03-27 13:13 ` Ian Campbell
2014-03-27 14:04 ` Boris Ostrovsky
2014-03-27 14:46 ` Ian Campbell
2014-03-24 23:18 ` [PATCH v7 2/3] x86/hvm: Add HVM-specific hypervisor CPUID leaf Boris Ostrovsky
2014-03-25 9:43 ` Jan Beulich
2014-03-24 23:18 ` [PATCH v7 3/3] x86/hvm: Indicate avaliability of HW support of APIC virtualization to HVM guests Boris Ostrovsky
2014-03-25 9:45 ` Jan Beulich
2014-03-25 13:34 ` Boris Ostrovsky
2014-03-26 1:03 ` Zhang, Yang Z
2014-04-01 15:39 ` Boris Ostrovsky
2014-04-02 1:24 ` Zhang, Yang Z
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=1395703119-11502-2-git-send-email-boris.ostrovsky@oracle.com \
--to=boris.ostrovsky@oracle.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=eddie.dong@intel.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jun.nakajima@intel.com \
--cc=keir@xen.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
--cc=yang.z.zhang@intel.com \
/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).