From eef6c034a94f102ad6c2ad295779886b53a25831 Mon Sep 17 00:00:00 2001 From: Junhao He Date: Mon, 29 May 2023 19:08:50 +0800 Subject: [PATCH] perf cs-etm: add error logging to cs_etm_is_etmv4() driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I79882 CVE: NA ---------------------------------------------------------------------- When setting up SMT, not every process has an ETM, so the path ".../cs_etm/cpux/trcidr/trcidr0" does not exist, and the function perf_pmu__scan_file() will return an error. Log a error when read fails. Signed-off-by: Junhao He --- tools/perf/arch/arm/util/cs-etm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index 7af0130b3040..b4a53afe6712 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -558,7 +558,7 @@ cs_etm_info_priv_size(struct auxtrace_record *itr __maybe_unused, static bool cs_etm_is_etmv4(struct auxtrace_record *itr, int cpu) { - bool ret = false; + bool ret = true; char path[PATH_MAX]; int scan; unsigned int val; @@ -570,10 +570,11 @@ static bool cs_etm_is_etmv4(struct auxtrace_record *itr, int cpu) snprintf(path, PATH_MAX, "cpu%d/%s", cpu, metadata_etmv4_ro[CS_ETMV4_TRCIDR0]); scan = perf_pmu__scan_file(cs_etm_pmu, path, "%x", &val); - - /* The file was read successfully, we have a winner */ - if (scan == 1) - ret = true; + if (scan != 1) { + pr_err("%s: can't read file %s\n", + CORESIGHT_ETM_PMU_NAME, path); + ret = false; + } return ret; } -- GitLab