[PATCH] perf/x86: Reject non sampling events with precise_ip

From: Jiri Olsa
Date: Tue Jan 03 2017 - 09:25:35 EST


On Tue, Jan 03, 2017 at 10:40:59AM +0100, Peter Zijlstra wrote:
> On Wed, Dec 28, 2016 at 02:31:04PM +0100, Jiri Olsa wrote:
> > When in counting mode we setup the counter with the
> > longest possible period and read the value with read
> > syscall.
> >
> > We also still setup the PMI to be triggered when such
> > counter overflow to reconfigure it.
> >
> > We also get PEBS interrupt if such counter has precise_ip
> > set (which makes no sense, but it's possible).
>
> I think we should reject non sampling pebs events, as you say they make
> no sense what so ever.

ook, attached

jirka


---
As Peter suggested [1] rejecting non sampling PEBS events,
because they dont make any sense and could cause issues
in NMI handler [2].

[1] 20170103094059.GC3093@worktop">http://lkml.kernel.org/r/20170103094059.GC3093@worktop
[2] http://lkml.kernel.org/r/1482931866-6018-3-git-send-email-jolsa@xxxxxxxxxx

Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
arch/x86/events/core.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 64582cfa6976..48b851f0ef89 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -505,6 +505,10 @@ int x86_pmu_hw_config(struct perf_event *event)

if (event->attr.precise_ip > precise)
return -EOPNOTSUPP;
+
+ /* There's no sense in having PEBS for non sampling events. */
+ if (!is_sampling_event(event))
+ return -EINVAL;
}
/*
* check that PEBS LBR correction does not conflict with
--
2.9.3