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] [day] [month] [year] [list]
Message-ID: <a6da023a-6476-fc20-9488-f129fde930fb@huawei.com>
Date:   Tue, 16 Feb 2021 09:22:51 +0000
From:   John Garry <john.garry@...wei.com>
To:     Jiri Olsa <jolsa@...hat.com>, Jianlin Lv <Jianlin.Lv@....com>
CC:     <will@...nel.org>, <mathieu.poirier@...aro.org>,
        <leo.yan@...aro.org>, <peterz@...radead.org>, <mingo@...hat.com>,
        <acme@...nel.org>, <mark.rutland@....com>,
        <alexander.shishkin@...ux.intel.com>, <namhyung@...nel.org>,
        <irogers@...gle.com>, <agerstmayr@...hat.com>,
        <kan.liang@...ux.intel.com>, <adrian.hunter@...el.com>,
        <iecedge@...il.com>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3] perf tools: Fix arm64 build error with gcc-11

>> ---
>>   tools/perf/builtin-script.c                            | 4 +++-
>>   tools/perf/util/scripting-engines/trace-event-python.c | 3 ++-
>>   tools/perf/util/session.c                              | 3 ++-
>>   3 files changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
>> index 42dad4a0f8cf..0d52dc45b1c7 100644
>> --- a/tools/perf/builtin-script.c
>> +++ b/tools/perf/builtin-script.c
>> @@ -643,7 +643,9 @@ static int perf_sample__fprintf_regs(struct regs_dump *regs, uint64_t mask,
>>   
>>   	for_each_set_bit(r, (unsigned long *) &mask, sizeof(mask) * 8) {
>>   		u64 val = regs->regs[i++];
>> -		printed += fprintf(fp, "%5s:0x%"PRIx64" ", perf_reg_name(r), val);
>> +		const char *reg_name = perf_reg_name(r);
>> +
>> +		printed += fprintf(fp, "%5s:0x%"PRIx64" ", reg_name ?: "unknown", val);
>>   	}
>>   
>>   	return printed;
>> diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
>> index c83c2c6564e0..768bdd4240f4 100644
>> --- a/tools/perf/util/scripting-engines/trace-event-python.c
>> +++ b/tools/perf/util/scripting-engines/trace-event-python.c
>> @@ -699,10 +699,11 @@ static int regs_map(struct regs_dump *regs, uint64_t mask, char *bf, int size)
>>   
>>   	for_each_set_bit(r, (unsigned long *) &mask, sizeof(mask) * 8) {
>>   		u64 val = regs->regs[i++];
>> +		const char *reg_name = perf_reg_name(r);
>>   
>>   		printed += scnprintf(bf + printed, size - printed,
>>   				     "%5s:0x%" PRIx64 " ",
>> -				     perf_reg_name(r), val);
>> +				     reg_name ?: "unknown", val);

what I was trying to suggest previously was to add a small helper 
function for this, like:

------- >8 --------

diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h
index a45499126184..2663daf4122c 100644
--- a/tools/perf/util/perf_regs.h
+++ b/tools/perf/util/perf_regs.h
@@ -28,18 +28,25 @@ uint64_t arch__user_reg_mask(void);
  extern const struct sample_reg sample_reg_masks[];

  #include <perf_regs.h>

  #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))

  int perf_reg_value(u64 *valp, struct regs_dump *regs, int id);

+static inline const char *perf_reg_name_str(int id)
+{
+	const char *str = perf_reg_name(id);
+	if (!str)
+		return "unknown";
+	return str;
+}
+
  #else
  #define PERF_REGS_MASK	0
  #define PERF_REGS_MAX	0

  #define DWARF_MINIMAL_REGS PERF_REGS_MASK

-static inline const char *perf_reg_name(int id __maybe_unused)
+static inline const char *perf_reg_name_str(int id __maybe_unused)
  {
  	return "unknown";
  }

----8<----

So if someone were to make a change to use perf_reg_name() directly 
later and do not compile with gcc-11, then they may break the build. 
Hence the helper.

No big deal, though.

>>   	}
>>   
>>   	return printed;
>> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
>> index 25adbcce0281..2b40f1c431a3 100644
>> --- a/tools/perf/util/session.c
>> +++ b/tools/perf/util/session.c
>> @@ -1138,9 +1138,10 @@ static void regs_dump__printf(u64 mask, u64 *regs)
>>   
>>   	for_each_set_bit(rid, (unsigned long *) &mask, sizeof(mask) * 8) {
>>   		u64 val = regs[i++];
>> +		const char *reg_name = perf_reg_name(rid);
>>   
>>   		printf(".... %-5s 0x%016" PRIx64 "\n",
>> -		       perf_reg_name(rid), val);
>> +		       reg_name ?: "unknown", val);
>>   	}
>>   }
>>   
>> -- 
>> 2.25.1
>>
> 
> .
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ