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 v3 2/2] x86/vpmu: Disable VPMU if guest's CPUID indicates no PMU support
Date: Wed, 22 Feb 2017 13:24:28 -0500 [thread overview]
Message-ID: <1487787868-6053-3-git-send-email-boris.ostrovsky@oracle.com> (raw)
In-Reply-To: <1487787868-6053-1-git-send-email-boris.ostrovsky@oracle.com>
When toolstack overrides Intel CPUID leaf 0xa's PMU version with an
invalid value VPMU should not be available to the guest.
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v3:
* Added pmu_version field to struct cpuid_policy
* vmx_vpmu_initialise() checks whether pmu version is
supported, not just non-zero.
* Fixed commit message
xen/arch/x86/cpu/vpmu_intel.c | 4 ++++
xen/arch/x86/domctl.c | 14 ++++++++++++++
xen/include/asm-x86/cpuid.h | 12 ++++++++++++
3 files changed, 30 insertions(+)
diff --git a/xen/arch/x86/cpu/vpmu_intel.c b/xen/arch/x86/cpu/vpmu_intel.c
index 16e5afb..c6f891f 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 ( v->domain->arch.cpuid->basic.pmu_version <= 1 ||
+ v->domain->arch.cpuid->basic.pmu_version >= 5 )
+ 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..db6a1c3 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 zero then the guest doesn't have VPMU */
+ if ( p->basic.pmu_version == 0 )
+ {
+ struct vcpu *v;
+
+ for_each_vcpu( d, v )
+ vpmu_destroy(v);
+ }
+ break;
+
case 0xd:
if ( ctl->input[1] != 1 )
break;
diff --git a/xen/include/asm-x86/cpuid.h b/xen/include/asm-x86/cpuid.h
index bc3fc7c..d4377e6 100644
--- a/xen/include/asm-x86/cpuid.h
+++ b/xen/include/asm-x86/cpuid.h
@@ -118,6 +118,18 @@ struct cpuid_policy
/* Leaf 0x2 - TLB/Cache/Prefetch. */
uint8_t l2_nr_queries; /* Documented as fixed to 1. */
+ uint8_t l2_desc[15];
+
+ uint64_t :64, :64; /* Leaf 0x3 - PSN. */
+ uint64_t :64, :64; /* Leaf 0x4 - Structured Cache. */
+ uint64_t :64, :64; /* Leaf 0x5 - MONITOR. */
+ uint64_t :64, :64; /* Leaf 0x6 - Therm/Perf. */
+ uint64_t :64, :64; /* Leaf 0x7 - Structured Features. */
+ uint64_t :64, :64; /* Leaf 0x8 - rsvd */
+ uint64_t :64, :64; /* Leaf 0x9 - DCA */
+
+ /* Leaf 0xa - Intel PMU. */
+ uint8_t pmu_version;
};
} basic;
--
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-22 18:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-22 18:24 [PATCH v3 0/2] VPMU management update Boris Ostrovsky
2017-02-22 18:24 ` [PATCH v3 1/2] x86/vpmu: Add get/put_vpmu() and VPMU_AVAILABLE Boris Ostrovsky
2017-02-24 15:38 ` Jan Beulich
2017-02-27 1:41 ` Tian, Kevin
2017-03-01 9:27 ` Jan Beulich
2017-02-22 18:24 ` Boris Ostrovsky [this message]
2017-02-24 15:40 ` [PATCH v3 2/2] x86/vpmu: Disable VPMU if guest's CPUID indicates no PMU support Jan Beulich
2017-02-24 16:16 ` Boris Ostrovsky
2017-02-27 1:41 ` Tian, Kevin
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=1487787868-6053-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).