aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2012-09-13 16:59:14 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-10-16 11:43:58 -0400
commit20b279ddb38ca42f8863cec07b4d45ec24589f13 (patch)
tree993ddf58189bc665e0f392042321770e488e123d
parent1342798cc13e3b48d9b5738f0c8fa812ccea8101 (diff)
perf: Require exclude_guest to use PEBS - kernel side enforcement
Intel PEBS in VT-x context uses the DS address as a guest linear address, even though its programmed by the host as a host linear address. This either results in guest memory corruption and or the hardware faulting and 'crashing' the virtual machine. Therefore we have to disable PEBS on VT-x enter and re-enable on VT-x exit, enforcing a strict exclude_guest. This patch enforces exclude_guest kernel side. Signed-off-by: Peter Zijlstra <peterz@infradead.org> Cc: Avi Kivity <avi@redhat.com> Cc: David Ahern <dsahern@gmail.com> Cc: Gleb Natapov <gleb@redhat.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Robert Richter <robert.richter@amd.com> Link: http://lkml.kernel.org/r/1347569955-54626-3-git-send-email-dsahern@gmail.com Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--arch/x86/kernel/cpu/perf_event.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 915b876edd1e..3373f84d1397 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -338,6 +338,9 @@ int x86_setup_perfctr(struct perf_event *event)
338 /* BTS is currently only allowed for user-mode. */ 338 /* BTS is currently only allowed for user-mode. */
339 if (!attr->exclude_kernel) 339 if (!attr->exclude_kernel)
340 return -EOPNOTSUPP; 340 return -EOPNOTSUPP;
341
342 if (!attr->exclude_guest)
343 return -EOPNOTSUPP;
341 } 344 }
342 345
343 hwc->config |= config; 346 hwc->config |= config;
@@ -380,6 +383,9 @@ int x86_pmu_hw_config(struct perf_event *event)
380 if (event->attr.precise_ip) { 383 if (event->attr.precise_ip) {
381 int precise = 0; 384 int precise = 0;
382 385
386 if (!event->attr.exclude_guest)
387 return -EOPNOTSUPP;
388
383 /* Support for constant skid */ 389 /* Support for constant skid */
384 if (x86_pmu.pebs_active && !x86_pmu.pebs_broken) { 390 if (x86_pmu.pebs_active && !x86_pmu.pebs_broken) {
385 precise++; 391 precise++;