From: Mohit Gambhir <mohit.gambhir@oracle.com>
To: jun.nakajima@intel.com, kevin.tian@intel.com, xen-devel@lists.xen.org
Cc: boris.ostrovsky@oracle.com,
Mohit Gambhir <mohit.gambhir@oracle.com>,
JBeulich@suse.com
Subject: [PATCH v2] x86/vpmu_intel: Fix hypervisor crash by masking PC bit in MSR_P6_EVNTSEL
Date: Wed, 26 Apr 2017 14:11:04 -0400 [thread overview]
Message-ID: <20170426181104.10112-1-mohit.gambhir@oracle.com> (raw)
Setting Pin Control (PC) bit (19) in MSR_P6_EVNTSEL results in a General
Protection Fault and thus results in a hypervisor crash. This patch fixes the
crash by masking PC bit and returning an error in case any guest tries to write
to it.
Signed-off-by: Mohit Gambhir <mohit.gambhir@oracle.com>
---
v2 of this patch takes a different approach to fixing the hypervisor crash.
As stated in the commit message v2 masks PC flag control bit unlike v1 that
used wrmsr_safe while writing to the MSR. v1 posed a complication in returning
the error to the HVM guests.
With this approach the writes to PC bits are protected for both native MSR
writes and VMX data structure writes (for HVM guests)
---
xen/arch/x86/cpu/vpmu_intel.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/xen/arch/x86/cpu/vpmu_intel.c b/xen/arch/x86/cpu/vpmu_intel.c
index 3f0322c..6d768cb 100644
--- a/xen/arch/x86/cpu/vpmu_intel.c
+++ b/xen/arch/x86/cpu/vpmu_intel.c
@@ -76,12 +76,13 @@ static bool_t __read_mostly full_width_write;
#define FIXED_CTR_CTRL_ANYTHREAD_MASK 0x4
#define ARCH_CNTR_ENABLED (1ULL << 22)
+#define ARCH_CNTR_PIN_CONTROL (1ULL << 19)
/* Number of general-purpose and fixed performance counters */
static unsigned int __read_mostly arch_pmc_cnt, fixed_pmc_cnt;
/* Masks used for testing whether and MSR is valid */
-#define ARCH_CTRL_MASK (~((1ull << 32) - 1) | (1ull << 21))
+#define ARCH_CTRL_MASK (~((1ull << 32) - 1) | (1ull << 21) | ARCH_CNTR_PIN_CONTROL)
static uint64_t __read_mostly fixed_ctrl_mask, fixed_counters_mask;
static uint64_t __read_mostly global_ovf_ctrl_mask, global_ctrl_mask;
--
2.9.3
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next reply other threads:[~2017-04-26 18:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-26 18:11 Mohit Gambhir [this message]
2017-04-26 18:19 ` [PATCH v2] x86/vpmu_intel: Fix hypervisor crash by masking PC bit in MSR_P6_EVNTSEL Andrew Cooper
2017-04-26 18:50 ` Mohit Gambhir
2017-04-27 7:32 ` Jan Beulich
2017-04-27 14:57 ` Boris Ostrovsky
2017-04-27 15:05 ` Jan Beulich
2017-04-27 15:18 ` Boris Ostrovsky
2017-04-28 6:43 ` Tian, Kevin
[not found] ` <AADFC41AFE54684AB9EE6CBC0274A5D190CBBD78@SHSMSX101.ccr.corp.intel.com>
2017-04-28 6:52 ` Tian, Kevin
2017-04-28 7:37 ` Jan Beulich
2017-05-03 17:11 ` Mohit Gambhir
2017-05-04 7:22 ` 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=20170426181104.10112-1-mohit.gambhir@oracle.com \
--to=mohit.gambhir@oracle.com \
--cc=JBeulich@suse.com \
--cc=boris.ostrovsky@oracle.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).