1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Peter Zijlstra <peterz@infradead.org>
3 Date: Sun, 14 Jan 2018 11:27:13 +0100
4 Subject: [PATCH] x86,perf: Disable intel_bts when PTI
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 commit 99a9dc98ba52267ce5e062b52de88ea1f1b2a7d8 upstream.
11 The intel_bts driver does not use the 'normal' BTS buffer which is exposed
12 through the cpu_entry_area but instead uses the memory allocated for the
15 This obviously comes apart when using PTI because then the kernel mapping;
16 which includes that AUX buffer memory; disappears. Fixing this requires to
17 expose a mapping which is visible in all context and that's not trivial.
19 As a quick fix disable this driver when PTI is enabled to prevent
22 Fixes: 385ce0ea4c07 ("x86/mm/pti: Add Kconfig")
23 Reported-by: Vince Weaver <vincent.weaver@maine.edu>
24 Reported-by: Robert Święcki <robert@swiecki.net>
25 Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
26 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
27 Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
30 Cc: luto@amacapital.net
31 Cc: Vince Weaver <vince@deater.net>
32 Cc: torvalds@linux-foundation.org
33 Cc: stable@vger.kernel.org
34 Link: https://lkml.kernel.org/r/20180114102713.GB6166@worktop.programming.kicks-ass.net
35 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
36 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
38 arch/x86/events/intel/bts.c | 18 ++++++++++++++++++
39 1 file changed, 18 insertions(+)
41 diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
42 index ddd8d3516bfc..9a62e6fce0e0 100644
43 --- a/arch/x86/events/intel/bts.c
44 +++ b/arch/x86/events/intel/bts.c
45 @@ -582,6 +582,24 @@ static __init int bts_init(void)
46 if (!boot_cpu_has(X86_FEATURE_DTES64) || !x86_pmu.bts)
49 + if (boot_cpu_has(X86_FEATURE_PTI)) {
51 + * BTS hardware writes through a virtual memory map we must
52 + * either use the kernel physical map, or the user mapping of
55 + * However, since this driver supports per-CPU and per-task inherit
56 + * we cannot use the user mapping since it will not be availble
57 + * if we're not running the owning process.
59 + * With PTI we can't use the kernal map either, because its not
60 + * there when we run userspace.
62 + * For now, disable this driver when using PTI.
67 bts_pmu.capabilities = PERF_PMU_CAP_AUX_NO_SG | PERF_PMU_CAP_ITRACE |
68 PERF_PMU_CAP_EXCLUSIVE;
69 bts_pmu.task_ctx_nr = perf_sw_context;