Skip to content

Commit 99a9dc9

Browse files
Peter ZijlstraKAGA-KOKO
authored andcommitted
x86,perf: Disable intel_bts when PTI
The intel_bts driver does not use the 'normal' BTS buffer which is exposed through the cpu_entry_area but instead uses the memory allocated for the perf AUX buffer. This obviously comes apart when using PTI because then the kernel mapping; which includes that AUX buffer memory; disappears. Fixing this requires to expose a mapping which is visible in all context and that's not trivial. As a quick fix disable this driver when PTI is enabled to prevent malfunction. Fixes: 385ce0e ("x86/mm/pti: Add Kconfig") Reported-by: Vince Weaver <[email protected]> Reported-by: Robert Święcki <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: Vince Weaver <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent a237f76 commit 99a9dc9

File tree

1 file changed

+18
-0
lines changed
  • arch/x86/events/intel

1 file changed

+18
-0
lines changed

arch/x86/events/intel/bts.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,24 @@ static __init int bts_init(void)
582582
if (!boot_cpu_has(X86_FEATURE_DTES64) || !x86_pmu.bts)
583583
return -ENODEV;
584584

585+
if (boot_cpu_has(X86_FEATURE_PTI)) {
586+
/*
587+
* BTS hardware writes through a virtual memory map we must
588+
* either use the kernel physical map, or the user mapping of
589+
* the AUX buffer.
590+
*
591+
* However, since this driver supports per-CPU and per-task inherit
592+
* we cannot use the user mapping since it will not be availble
593+
* if we're not running the owning process.
594+
*
595+
* With PTI we can't use the kernal map either, because its not
596+
* there when we run userspace.
597+
*
598+
* For now, disable this driver when using PTI.
599+
*/
600+
return -ENODEV;
601+
}
602+
585603
bts_pmu.capabilities = PERF_PMU_CAP_AUX_NO_SG | PERF_PMU_CAP_ITRACE |
586604
PERF_PMU_CAP_EXCLUSIVE;
587605
bts_pmu.task_ctx_nr = perf_sw_context;

0 commit comments

Comments
 (0)