From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: xen-devel@lists.xen.org
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>,
andrew.cooper3@citrix.com, kevin.tian@intel.com,
jun.nakajima@intel.com, jbeulich@suse.com
Subject: [PATCH v2 2/3] x86/vpmu: Disable VPMU if guest's CPUID indicates no PMU support
Date: Fri, 17 Feb 2017 12:40:11 -0500 [thread overview]
Message-ID: <1487353212-4395-3-git-send-email-boris.ostrovsky@oracle.com> (raw)
In-Reply-To: <1487353212-4395-1-git-send-email-boris.ostrovsky@oracle.com>
When toolstack overrides CPUID leaf 0xa values (on Intel processors)
VPMU should not be available to the guest.
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
* New in v2
xen/arch/x86/cpu/vpmu_intel.c | 4 ++++
xen/arch/x86/domctl.c | 14 ++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/xen/arch/x86/cpu/vpmu_intel.c b/xen/arch/x86/cpu/vpmu_intel.c
index 16e5afb..051bf85 100644
--- a/xen/arch/x86/cpu/vpmu_intel.c
+++ b/xen/arch/x86/cpu/vpmu_intel.c
@@ -884,6 +884,10 @@ int vmx_vpmu_initialise(struct vcpu *v)
if ( vpmu_mode == XENPMU_MODE_OFF )
return 0;
+ if ( MASK_EXTR(v->domain->arch.cpuid->basic.raw[0xa].a,
+ PMU_VERSION_MASK) == 0 )
+ return -EINVAL;
+
if ( (arch_pmc_cnt + fixed_pmc_cnt) == 0 )
return -EINVAL;
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 8e5259f..cbcc207 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -253,6 +253,20 @@ static int update_domain_cpuid_info(struct domain *d,
}
break;
+ case 0xa:
+ if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
+ break;
+
+ /* If PMU version is invalid then the guest doesn't have VPMU */
+ if ( MASK_EXTR(leaf.a, 0xff) == 0 )
+ {
+ struct vcpu *v;
+
+ for_each_vcpu( d, v )
+ vpmu_destroy(v);
+ }
+ break;
+
case 0xd:
if ( ctl->input[1] != 1 )
break;
--
1.8.3.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-02-17 17:40 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-17 17:40 [PATCH v2 0/3] VPMU management update Boris Ostrovsky
2017-02-17 17:40 ` [PATCH v2 1/3] x86/vpmu: Add get/put_vpmu() and VPMU_AVAILABLE Boris Ostrovsky
2017-02-21 8:09 ` Tian, Kevin
2017-02-21 14:09 ` Boris Ostrovsky
2017-02-22 3:05 ` Tian, Kevin
2017-02-22 14:06 ` Boris Ostrovsky
2017-02-21 11:00 ` Andrew Cooper
2017-02-21 14:12 ` Boris Ostrovsky
2017-02-17 17:40 ` Boris Ostrovsky [this message]
2017-02-21 8:13 ` [PATCH v2 2/3] x86/vpmu: Disable VPMU if guest's CPUID indicates no PMU support Tian, Kevin
2017-02-22 9:55 ` Jan Beulich
2017-02-22 14:15 ` Boris Ostrovsky
2017-02-22 14:38 ` Jan Beulich
2017-02-22 15:02 ` Boris Ostrovsky
2017-02-22 15:10 ` Andrew Cooper
2017-02-22 16:34 ` Boris Ostrovsky
2017-02-22 16:42 ` Andrew Cooper
2017-02-22 15:16 ` Jan Beulich
2017-02-17 17:40 ` [PATCH v2 3/3] libxc/x86: PV guests should see leaf 0xa on Intel Boris Ostrovsky
2017-02-20 14:15 ` Wei Liu
2017-02-20 14:16 ` Andrew Cooper
2017-02-20 14:17 ` Wei Liu
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=1487353212-4395-3-git-send-email-boris.ostrovsky@oracle.com \
--to=boris.ostrovsky@oracle.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.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).