From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Jan Beulich <JBeulich@suse.com>
Subject: [PATCH 5/6] x86/cpuid: Don't offer HVM hypervisor leaves to PV guests
Date: Mon, 16 Jan 2017 11:40:29 +0000 [thread overview]
Message-ID: <1484566830-13916-6-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1484566830-13916-1-git-send-email-andrew.cooper3@citrix.com>
Xen leaf 4 is HVM-only. Report a lower max_leaf to PV guests, so they don't
go and investigate a leaf which will return all zeros.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
---
xen/arch/x86/traps.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 4f29c3a..51bcd97 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -911,12 +911,16 @@ void cpuid_hypervisor_leaves(const struct vcpu *v, uint32_t leaf,
uint32_t idx = leaf - base;
unsigned int limit = is_viridian_domain(d) ? p->hv2_limit : p->hv_limit;
+ /* Current, HVM max leaf is 4 and PV max leaf is 3. */
+ unsigned int max_leaf = has_hvm_container_domain(d) ? 4 : 3;
+ BUILD_BUG_ON(XEN_CPUID_MAX_NUM_LEAVES != 4);
+
if ( limit == 0 )
/* Default number of leaves */
- limit = XEN_CPUID_MAX_NUM_LEAVES;
+ limit = max_leaf;
else
- /* Clamp toolstack value between 2 and MAX_NUM_LEAVES. */
- limit = min(max(limit, 2u), XEN_CPUID_MAX_NUM_LEAVES + 0u);
+ /* Clamp toolstack value between 2 and max_leaf. */
+ limit = min(max(limit, 2u), max_leaf);
if ( idx > limit )
return;
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-01-16 11:40 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-16 11:40 [PATCH 0/6] Further CPUID improvements Andrew Cooper
2017-01-16 11:40 ` [PATCH 1/6] x86/xstate: Fix array overrun on hardware with LWP Andrew Cooper
2017-01-16 16:26 ` Jan Beulich
2017-01-16 11:40 ` [PATCH 2/6] x86/cpuid: Introduce recalculate_xstate() Andrew Cooper
2017-01-16 16:45 ` Jan Beulich
2017-01-16 17:02 ` Andrew Cooper
2017-01-16 17:09 ` Jan Beulich
2017-01-17 11:27 ` [PATCH v2 " Andrew Cooper
2017-01-17 12:52 ` Jan Beulich
2017-01-17 15:15 ` Andrew Cooper
2017-01-17 15:28 ` Jan Beulich
2017-01-17 15:30 ` Andrew Cooper
2017-01-16 11:40 ` [PATCH 3/6] x86/cpuid: Move all xstate leaf handling into guest_cpuid() Andrew Cooper
2017-01-16 16:58 ` Jan Beulich
2017-01-16 17:07 ` Andrew Cooper
2017-01-16 11:40 ` [PATCH 4/6] tools/libxc: Remove xsave calculations from libxc Andrew Cooper
2017-01-16 11:44 ` Wei Liu
2017-01-16 11:40 ` Andrew Cooper [this message]
2017-01-16 17:02 ` [PATCH 5/6] x86/cpuid: Don't offer HVM hypervisor leaves to PV guests Jan Beulich
2017-01-17 11:01 ` Andrew Cooper
2017-01-16 11:40 ` [PATCH 6/6] x86/cpuid: Offer ITSC to domains which are automatically non-migrateable Andrew Cooper
2017-01-16 17:07 ` Jan Beulich
2017-01-16 17:26 ` Andrew Cooper
2017-01-17 9:00 ` Jan Beulich
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=1484566830-13916-6-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=xen-devel@lists.xen.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).