]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0301-x86-perf-Disable-intel_bts-when-PTI.patch
update ABI file
[pve-kernel.git] / patches / kernel / 0301-x86-perf-Disable-intel_bts-when-PTI.patch
CommitLineData
035dbe67
FG
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Peter Zijlstra <peterz@infradead.org>
3Date: Sun, 14 Jan 2018 11:27:13 +0100
4Subject: [PATCH] x86,perf: Disable intel_bts when PTI
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9commit 99a9dc98ba52267ce5e062b52de88ea1f1b2a7d8 upstream.
10
11The intel_bts driver does not use the 'normal' BTS buffer which is exposed
12through the cpu_entry_area but instead uses the memory allocated for the
13perf AUX buffer.
14
15This obviously comes apart when using PTI because then the kernel mapping;
16which includes that AUX buffer memory; disappears. Fixing this requires to
17expose a mapping which is visible in all context and that's not trivial.
18
19As a quick fix disable this driver when PTI is enabled to prevent
20malfunction.
21
22Fixes: 385ce0ea4c07 ("x86/mm/pti: Add Kconfig")
23Reported-by: Vince Weaver <vincent.weaver@maine.edu>
24Reported-by: Robert Święcki <robert@swiecki.net>
25Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
26Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
27Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
28Cc: greg@kroah.com
29Cc: hughd@google.com
30Cc: luto@amacapital.net
31Cc: Vince Weaver <vince@deater.net>
32Cc: torvalds@linux-foundation.org
33Cc: stable@vger.kernel.org
34Link: https://lkml.kernel.org/r/20180114102713.GB6166@worktop.programming.kicks-ass.net
35Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
36Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
37---
38 arch/x86/events/intel/bts.c | 18 ++++++++++++++++++
39 1 file changed, 18 insertions(+)
40
41diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
42index 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)
47 return -ENODEV;
48
49+ if (boot_cpu_has(X86_FEATURE_PTI)) {
50+ /*
51+ * BTS hardware writes through a virtual memory map we must
52+ * either use the kernel physical map, or the user mapping of
53+ * the AUX buffer.
54+ *
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.
58+ *
59+ * With PTI we can't use the kernal map either, because its not
60+ * there when we run userspace.
61+ *
62+ * For now, disable this driver when using PTI.
63+ */
64+ return -ENODEV;
65+ }
66+
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;
70--
712.14.2
72