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: <9dedd378-ce85-4329-b770-de47548bf380@intel.com>
Date: Tue, 11 Jun 2024 19:29:49 +0300
From: Adrian Hunter <adrian.hunter@...el.com>
To: Athira Rajeev <atrajeev@...ux.vnet.ibm.com>
Cc: Ian Rogers <irogers@...gle.com>, Namhyung Kim <namhyung@...nel.org>,
 Arnaldo Carvalho de Melo <acme@...nel.org>, Jiri Olsa <jolsa@...nel.org>,
 Segher Boessenkool <segher@...nel.crashing.org>,
 Christophe Leroy <christophe.leroy@...roup.eu>,
 LKML <linux-kernel@...r.kernel.org>,
 linux-perf-users <linux-perf-users@...r.kernel.org>,
 linuxppc-dev <linuxppc-dev@...ts.ozlabs.org>, akanksha@...ux.ibm.com,
 Madhavan Srinivasan <maddy@...ux.ibm.com>, Kajol Jain <kjain@...ux.ibm.com>,
 disgoel@...ux.vnet.ibm.com
Subject: Re: [PATCH V3 11/14] tools/perf: Add support to use libcapstone in
 powerpc

On 10/06/24 15:20, Athira Rajeev wrote:
> 
> 
>> On 3 Jun 2024, at 10:28 PM, Adrian Hunter <adrian.hunter@...el.com> wrote:
>>
>> On 3/06/24 19:30, Ian Rogers wrote:
>>> On Fri, May 31, 2024 at 11:10 PM Athira Rajeev
>>> <atrajeev@...ux.vnet.ibm.com> wrote:
>>>>
>>>> Now perf uses the capstone library to disassemble the instructions in
>>>> x86. capstone is used (if available) for perf annotate to speed up.
>>>> Currently it only supports x86 architecture. Patch includes changes to
>>>> enable this in powerpc. For now, only for data type sort keys, this
>>>> method is used and only binary code (raw instruction) is read. This is
>>>> because powerpc approach to understand instructions and reg fields uses
>>>> raw instruction. The "cs_disasm" is currently not enabled. While
>>>> attempting to do cs_disasm, observation is that some of the instructions
>>>> were not identified (ex: extswsli, maddld) and it had to fallback to use
>>>> objdump. Hence enabling "cs_disasm" is added in comment section as a
>>>> TODO for powerpc.
>>>>
>>>> Signed-off-by: Athira Rajeev <atrajeev@...ux.vnet.ibm.com>
>>>> ---
>>>> tools/perf/util/disasm.c | 148 ++++++++++++++++++++++++++++++++++++++-
>>>> 1 file changed, 146 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
>>>> index d8b357055302..915508d2e197 100644
>>>> --- a/tools/perf/util/disasm.c
>>>> +++ b/tools/perf/util/disasm.c
>>>> @@ -1540,12 +1540,18 @@ static int open_capstone_handle(struct annotate_args *args, bool is_64bit,
>>>> {
>>>>        struct annotation_options *opt = args->options;
>>>>        cs_mode mode = is_64bit ? CS_MODE_64 : CS_MODE_32;
>>>> +       int ret;
>>>>
>>>>        /* TODO: support more architectures */
>>>> -       if (!arch__is(args->arch, "x86"))
>>>> +       if ((!arch__is(args->arch, "x86")) && (!arch__is(args->arch, "powerpc")))
>>>>                return -1;
>>>>
>>>> -       if (cs_open(CS_ARCH_X86, mode, handle) != CS_ERR_OK)
>>>> +       if (arch__is(args->arch, "x86"))
>>>> +               ret = cs_open(CS_ARCH_X86, mode, handle);
>>>> +       else
>>>> +               ret = cs_open(CS_ARCH_PPC, mode, handle);
>>>> +
>>>> +       if (ret != CS_ERR_OK)
>>>>                return -1;
>>>
>>> There looks to be a pretty/more robust capstone_init function in
>>> print_insn.c, should we factor this code out and recycle:
>>> https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/util/print_insn.c?h=perf-tools-next#n40
>>
>> On a slightly related note, there is a compile error
>> been around for a while in util/disasm.c on Ubuntu 22.04
>>
>> In file included from /usr/include/capstone/capstone.h:279,
>>                 from util/disasm.c:1354:
>> /usr/include/capstone/bpf.h:94:14: error: ‘bpf_insn’ defined as wrong
>> kind of tag
>>   94 | typedef enum bpf_insn {
>>      |              ^~~~~~~~
>>
> 
> Hi Adrian
> 
> I tried compilation on Ubuntu 22.04, but didn’t face this issue.
> The libcapstone version I have is libcapstone4 which doesn’t have the include for “bpf.h”
> What is the version of libcapstone in the setup where you are seeing this issue ?

Yes, sorry. I got confused.  Ubuntu was OK.  The original issue
was with Fedora 40, but even then it requires binutils-devel
and BUILD_NONDISTRO=1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ