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]
Date:   Wed, 21 Jun 2023 12:10:24 +0800
From:   WANG Rui <wangrui@...ngson.cn>
To:     Namhyung Kim <namhyung@...nel.org>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Huacai Chen <chenhuacai@...ngson.cn>,
        loongarch@...ts.linux.dev, Tiezhu Yang <yangtiezhu@...ngson.cn>,
        WANG Xuerui <kernel@...0n.name>, linux-kernel@...r.kernel.org,
        linux-perf-users@...r.kernel.org, loongson-kernel@...ts.loongnix.cn
Subject: Re: [PATCH] perf annotate: Fix instruction association and parsing
 for LoongArch

Hello Namhyung,

On Wed, Jun 21, 2023 at 2:42 AM Namhyung Kim <namhyung@...nel.org> wrote:
> > +static int loongarch_call__parse(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms)
> > +{
> > +       char *c, *endptr, *tok, *name;
> > +       struct map *map = ms->map;
> > +       struct addr_map_symbol target = {
> > +               .ms = { .map = map, },
>
> Looking here...
>
> > +       };
> > +
> > +       c = strchr(ops->raw, '#');
> > +       if (c++ == NULL)
> > +               return -1;
> > +
> > +       ops->target.addr = strtoull(c, &endptr, 16);
> > +
> > +       name = strchr(endptr, '<');
> > +       name++;
> > +
> > +       if (arch->objdump.skip_functions_char &&
> > +           strchr(name, arch->objdump.skip_functions_char))
> > +               return -1;
> > +
> > +       tok = strchr(name, '>');
> > +       if (tok == NULL)
> > +               return -1;
> > +
> > +       *tok = '\0';
> > +       ops->target.name = strdup(name);
> > +       *tok = '>';
> > +
> > +       if (ops->target.name == NULL)
> > +               return -1;
> > +
> > +       target.addr = map__objdump_2mem(map, ops->target.addr);
> > +
> > +       if (maps__find_ams(ms->maps, &target) == 0 &&
> > +           map__rip_2objdump(target.ms.map, map__map_ip(target.ms.map, target.addr)) == ops->target.addr)
>
> So the target.ms.map is 'map', right?  Then we can reduce the line.

toos/perf/util/maps.c:

> int maps__find_ams(struct maps *maps, struct addr_map_symbol *ams)
> {
>     if (ams->addr < map__start(ams->ms.map) || ams->addr >= map__end(ams->ms.map)) {
>         if (maps == NULL)
>             return -1;
>         ams->ms.map = maps__find(maps, ams->addr);

Is it possible that `target.ms.map` might be reassigned within the
`maps_find_ams` function in this case?

>         if (ams->ms.map == NULL)
>             return -1;
>     }
>
>     ams->al_addr = map__map_ip(ams->ms.map, ams->addr);
>     ams->ms.sym = map__find_symbol(ams->ms.map, ams->al_addr);
>
>     return ams->ms.sym ? 0 : -1;
> }

Thanks!

-- 
WANG Rui
Loongson Technology Corporation Limited

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ