0020-x86-perf-Disable-intel_bts-when-PTI.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Peter Zijlstra <[email protected]>
  3. Date: Sun, 14 Jan 2018 11:27:13 +0100
  4. Subject: [PATCH] x86,perf: Disable intel_bts when PTI
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. commit 99a9dc98ba52267ce5e062b52de88ea1f1b2a7d8 upstream.
  9. The intel_bts driver does not use the 'normal' BTS buffer which is exposed
  10. through the cpu_entry_area but instead uses the memory allocated for the
  11. perf AUX buffer.
  12. This obviously comes apart when using PTI because then the kernel mapping;
  13. which includes that AUX buffer memory; disappears. Fixing this requires to
  14. expose a mapping which is visible in all context and that's not trivial.
  15. As a quick fix disable this driver when PTI is enabled to prevent
  16. malfunction.
  17. Fixes: 385ce0ea4c07 ("x86/mm/pti: Add Kconfig")
  18. Reported-by: Vince Weaver <[email protected]>
  19. Reported-by: Robert Święcki <[email protected]>
  20. Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
  21. Signed-off-by: Thomas Gleixner <[email protected]>
  22. Cc: Alexander Shishkin <[email protected]>
  23. Cc: [email protected]
  24. Cc: [email protected]
  25. Cc: [email protected]
  26. Cc: Vince Weaver <[email protected]>
  27. Cc: [email protected]
  28. Cc: [email protected]
  29. Link: https://lkml.kernel.org/r/[email protected]
  30. Signed-off-by: Greg Kroah-Hartman <[email protected]>
  31. Signed-off-by: Fabian Grünbichler <[email protected]>
  32. ---
  33. arch/x86/events/intel/bts.c | 18 ++++++++++++++++++
  34. 1 file changed, 18 insertions(+)
  35. diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
  36. index ddd8d3516bfc..9a62e6fce0e0 100644
  37. --- a/arch/x86/events/intel/bts.c
  38. +++ b/arch/x86/events/intel/bts.c
  39. @@ -582,6 +582,24 @@ static __init int bts_init(void)
  40. if (!boot_cpu_has(X86_FEATURE_DTES64) || !x86_pmu.bts)
  41. return -ENODEV;
  42. + if (boot_cpu_has(X86_FEATURE_PTI)) {
  43. + /*
  44. + * BTS hardware writes through a virtual memory map we must
  45. + * either use the kernel physical map, or the user mapping of
  46. + * the AUX buffer.
  47. + *
  48. + * However, since this driver supports per-CPU and per-task inherit
  49. + * we cannot use the user mapping since it will not be availble
  50. + * if we're not running the owning process.
  51. + *
  52. + * With PTI we can't use the kernal map either, because its not
  53. + * there when we run userspace.
  54. + *
  55. + * For now, disable this driver when using PTI.
  56. + */
  57. + return -ENODEV;
  58. + }
  59. +
  60. bts_pmu.capabilities = PERF_PMU_CAP_AUX_NO_SG | PERF_PMU_CAP_ITRACE |
  61. PERF_PMU_CAP_EXCLUSIVE;
  62. bts_pmu.task_ctx_nr = perf_sw_context;
  63. --
  64. 2.14.2