Skip to content

Commit bfd431c

Browse files
James-A-Clarkacmel
authored andcommitted
perf cs-etm: Fix contextid validation
Pre 5.11 kernels don't support 'contextid1' and 'contextid2' so validation would be skipped. By adding an additional check for 'contextid', old kernels will still have validation done even though contextid would either be contextid1 or contextid2. Additionally now that it's possible to override options, an existing bug in the validation is revealed. 'val' is overwritten by the contextid1 validation, and re-used for contextid2 validation causing it to always fail. '!val || val != 0x4' is the same as 'val != 0x4' because 0 is also != 4, so that expression can be simplified and the temp variable not overwritten. Fixes: 35c51f8 ("perf cs-etm: Validate options after applying them") Reviewed-by: Leo Yan <[email protected]> Signed-off-by: James Clark <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Poirier <[email protected]> Cc: Mike Leach <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Suzuki Poulouse <[email protected]> Cc: Will Deacon <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/all/[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent a3cee97 commit bfd431c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

tools/perf/arch/arm/util/cs-etm.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ static int cs_etm_validate_context_id(struct auxtrace_record *itr,
7878
char path[PATH_MAX];
7979
int err;
8080
u32 val;
81-
u64 contextid =
82-
evsel->core.attr.config &
83-
(perf_pmu__format_bits(&cs_etm_pmu->format, "contextid1") |
81+
u64 contextid = evsel->core.attr.config &
82+
(perf_pmu__format_bits(&cs_etm_pmu->format, "contextid") |
83+
perf_pmu__format_bits(&cs_etm_pmu->format, "contextid1") |
8484
perf_pmu__format_bits(&cs_etm_pmu->format, "contextid2"));
8585

8686
if (!contextid)
@@ -114,8 +114,7 @@ static int cs_etm_validate_context_id(struct auxtrace_record *itr,
114114
* 0b00100 Maximum of 32-bit Context ID size.
115115
* All other values are reserved.
116116
*/
117-
val = BMVAL(val, 5, 9);
118-
if (!val || val != 0x4) {
117+
if (BMVAL(val, 5, 9) != 0x4) {
119118
pr_err("%s: CONTEXTIDR_EL1 isn't supported, disable with %s/contextid1=0/\n",
120119
CORESIGHT_ETM_PMU_NAME, CORESIGHT_ETM_PMU_NAME);
121120
return -EINVAL;

0 commit comments

Comments
 (0)