lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b7c5b4e5-9497-10e5-fd43-5f3e4a0fe51d@intel.com>
Date:   Wed, 28 Nov 2018 14:38:13 +0200
From:   Adrian Hunter <adrian.hunter@...el.com>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:     Jiri Olsa <jolsa@...hat.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf intel-pt: Fix error with config term pt=0

On 27/11/18 2:39 PM, Arnaldo Carvalho de Melo wrote:
> Em Tue, Nov 27, 2018 at 10:43:36AM +0200, Adrian Hunter escreveu:
>> Users should never use 'pt=0', but if they do it may give a meaningless
>> error:
>>
>> 	$ perf record -e intel_pt/pt=0/u uname
>> 	Error:
>> 	The sys_perf_event_open() syscall returned with 22 (Invalid argument) for
>> 	event (intel_pt/pt=0/u).
>>
>> Fix that by forcing 'pt=1'.
>>
>> Signed-off-by: Adrian Hunter <adrian.hunter@...el.com>
>> ---
>>  tools/perf/arch/x86/util/intel-pt.c | 8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
>> index db0ba8caf5a2..af25a7824ee0 100644
>> --- a/tools/perf/arch/x86/util/intel-pt.c
>> +++ b/tools/perf/arch/x86/util/intel-pt.c
>> @@ -524,10 +524,18 @@ static int intel_pt_validate_config(struct perf_pmu *intel_pt_pmu,
>>  				    struct perf_evsel *evsel)
>>  {
>>  	int err;
>> +	char c;
>>  
>>  	if (!evsel)
>>  		return 0;
>>  
>> +	/*
>> +	 * If supported, force pass-through config term (pt=1) even if user
>> +	 * sets pt=0, which avoids senseless kernel errors.
>> +	 */
>> +	if (perf_pmu__scan_file(intel_pt_pmu, "format/pt", "%c", &c) == 1)
>> +		evsel->attr.config |= 1;
> 
> shouldn't we have a warning like:
> 
>    pr_warning("pt=0 doesn't make sense, forcing pt=1")
> 
> 
> Instead of silently doing something the user, mistakenly, did
> explicitely?

Sure, here it is:

From: Adrian Hunter <adrian.hunter@...el.com>
Date: Mon, 26 Nov 2018 14:12:52 +0200
Subject: [PATCH] perf intel-pt: Fix error with config term pt=0

Users should never use 'pt=0', but if they do it may give a meaningless
error:

	$ perf record -e intel_pt/pt=0/u uname
	Error:
	The sys_perf_event_open() syscall returned with 22 (Invalid argument) for
	event (intel_pt/pt=0/u).

Fix that by forcing 'pt=1'.

Signed-off-by: Adrian Hunter <adrian.hunter@...el.com>
---
 tools/perf/arch/x86/util/intel-pt.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
index db0ba8caf5a2..ba8ecaf52200 100644
--- a/tools/perf/arch/x86/util/intel-pt.c
+++ b/tools/perf/arch/x86/util/intel-pt.c
@@ -524,10 +524,21 @@ static int intel_pt_validate_config(struct perf_pmu *intel_pt_pmu,
 				    struct perf_evsel *evsel)
 {
 	int err;
+	char c;
 
 	if (!evsel)
 		return 0;
 
+	/*
+	 * If supported, force pass-through config term (pt=1) even if user
+	 * sets pt=0, which avoids senseless kernel errors.
+	 */
+	if (perf_pmu__scan_file(intel_pt_pmu, "format/pt", "%c", &c) == 1 &&
+	    !(evsel->attr.config & 1)) {
+		pr_warning("pt=0 doesn't make sense, forcing pt=1\n");
+		evsel->attr.config |= 1;
+	}
+
 	err = intel_pt_val_config_term(intel_pt_pmu, "caps/cycle_thresholds",
 				       "cyc_thresh", "caps/psb_cyc",
 				       evsel->attr.config);
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ