LKML Archive on
 help / color / Atom feed
From: Jiri Olsa <>
To: Peter Zijlstra <>
Cc: lkml <>,
	Ingo Molnar <>,
	Alexander Shishkin <>,
	Arnaldo Carvalho de Melo <>,
	Andi Kleen <>,
	Vince Weaver <>
Subject: [PATCH 3/3] perf/x86/intel: Disallow precise_ip on BTS event
Date: Wed, 21 Nov 2018 11:16:12 +0100
Message-ID: <> (raw)
In-Reply-To: <>

Vince reported crash in bts flush code when touching the callchain
data, which was supposed to be initialized as an 'early' callchain,
but intel_pmu_drain_bts_buffer does not do that.

  BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
  Call Trace:
   ? intel_get_event_constraints+0x219/0x360
   ? perf_assign_events+0xe2/0x2a0
   ? select_idle_sibling+0x22/0x3a0
   ? __update_load_avg_se+0x1ec/0x270
   ? enqueue_task_fair+0x377/0xdd0
   ? cpumask_next_and+0x19/0x20
   ? load_balance+0x134/0x950
   ? check_preempt_curr+0x7a/0x90
   ? ttwu_do_wakeup+0x19/0x140

It was triggered by fuzzer but can be easily reproduced by:
  # perf record -e cpu/branch-instructions/pu -g -c 1

Peter suggested not to allow branch tracing for precise events:

> Now arguably, this is really stupid behaviour. Who in his right mind
> wants callchain output on BTS entries. And even if they do, BTS +
> precise_ip is nonsensical.
> So in my mind disallowing precise_ip on BTS would be the simplest fix.

Suggested-by: Peter Zijlstra <>
Fixes: 6cbc304f2f36 ("perf/x86/intel: Fix unwind errors from PEBS entries (mk-II)")
Reported-by: Vince Weaver <>
Signed-off-by: Jiri Olsa <>
 arch/x86/events/intel/core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 3fd3842571e8..284893373d69 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3102,6 +3102,10 @@ static int intel_pmu_bts_config(struct perf_event *event)
 		if (!attr->exclude_kernel)
 			return -EOPNOTSUPP;
+		/* BTS is not allowed for precise events. */
+		if (attr->precise_ip)
+			return -EOPNOTSUPP;
 		/* disallow bts if conflicting events are present */
 		if (x86_add_exclusive(x86_lbr_exclusive_lbr))
 			return -EBUSY;

  parent reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-21 10:16 [PATCH 1/3] perf/x86/intel: Move branch tracing setup to intel object Jiri Olsa
2018-11-21 10:16 ` [PATCH 2/3] perf/x86/intel: Add generic branch tracing check to intel_pmu_has_bts Jiri Olsa
2018-11-22 10:13   ` [tip:perf/urgent] perf/x86/intel: Add generic branch tracing check to intel_pmu_has_bts() tip-bot for Jiri Olsa
2018-11-21 10:16 ` Jiri Olsa [this message]
2018-11-22 10:14   ` [tip:perf/urgent] perf/x86/intel: Disallow precise_ip on BTS events tip-bot for Jiri Olsa
2018-11-22 10:13 ` [tip:perf/urgent] perf/x86/intel: Move branch tracing setup to the Intel-specific source file tip-bot for Jiri Olsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

LKML Archive on

Archives are clonable:
	git clone --mirror lkml/git/0.git
	git clone --mirror lkml/git/1.git
	git clone --mirror lkml/git/2.git
	git clone --mirror lkml/git/3.git
	git clone --mirror lkml/git/4.git
	git clone --mirror lkml/git/5.git
	git clone --mirror lkml/git/6.git
	git clone --mirror lkml/git/7.git
	git clone --mirror lkml/git/8.git
	git clone --mirror lkml/git/9.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ \
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone