From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 09000D64077 for ; Fri, 8 Nov 2024 18:43:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CRM+nCx+NkgrBspLoJyW0b5hEl+tJtJBZ5eRpry7Ysk=; b=JF28yP/Lw4APMRyBIxTVLFr/hl wmPi8c2Ox/EYShr46P3cNxOIvgInAoXhA7bBKQ+voD4LjFaAzdSBm1VhX39sgdBJPTkZde08/ZDfB N+SlWnGhUSwIrkIh9cadCfakejtsX2A0JRf2nXYd9f1mJuwpmBtxDh33DtSXKJQ6l7YToukz9lPAG qnVFdRZFNY/JZlCPFheBDP/q9nG3olRXMaLyb2dYyFXnESegvw8FmQwX+dkNe78G5aO63RP53VyrA uJtBkv6tVkodxeT79gqvAHdxTGmMaTBwqbAY5ATS6GjXVLh1hOVv2EiwvM5669hPWEAJ9mEKEWlQK Z/cBNdVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t9Twi-0000000Bcvu-2y6f; Fri, 08 Nov 2024 18:43:00 +0000 Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t9TsL-0000000BcIE-1Cw0; Fri, 08 Nov 2024 18:38:30 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id DC6CBA4408D; Fri, 8 Nov 2024 18:36:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B85CDC4CECD; Fri, 8 Nov 2024 18:38:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731091107; bh=ysbnWIA04niPh4/FnRelxvy/7qgNN9jt3TdDs+ECXHY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=n5x9U7KDBB10MgdIZ5cjW590p6De536vrCk6OUvDIUUWG2j2zr4RwiRpbjUPAeBfJ KA+Mj+0+vl1KNhF2gZGB3soVZT6L4Mq/fgt6ZAkMTvHEaZcF6cD/gm+P3ks6j2M8Ce 0aFHCp+CEvssjEwhAJ/3qT904uMtGPDYzowmckVMpkBsiMOPjm/cf5hsu0BkrngexS +ePBbaF3hoEU86XGCPhGZY/Qr3JR9xpJ+Uz3p2yAEsewaPXhnSpWjXv13FrdBVsClu lZ4glEdEamcE+LykLNeeXHS25zbgkF9/5tjYvV8cmic/HB/9XlfQfKa6/YwQ2/kqh8 u0Ykcp1J7+p7Q== Date: Fri, 8 Nov 2024 10:38:24 -0800 From: Namhyung Kim To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Guo Ren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Nick Terrell , "Masami Hiramatsu (Google)" , Changbin Du , Guilherme Amadio , Yang Jihong , Aditya Gupta , Athira Rajeev , Masahiro Yamada , Bibo Mao , Huacai Chen , Kajol Jain , Atish Patra , Shenlin Liang , Anup Patel , Oliver Upton , "Steinar H. Gunderson" , "Dr. David Alan Gilbert" , Chen Pei , Dima Kogan , Przemek Kitszel , "David S. Miller" , Alexander Lobakin , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH v3 04/20] perf disasm: Add e_machine/e_flags to struct arch Message-ID: References: <20241017002520.59124-1-irogers@google.com> <20241017002520.59124-5-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241108_103829_458590_10010D6B X-CRM114-Status: GOOD ( 37.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Nov 08, 2024 at 10:19:52AM -0800, Ian Rogers wrote: > On Fri, Nov 8, 2024 at 9:33 AM Namhyung Kim wrote: > > > > On Wed, Oct 16, 2024 at 05:25:04PM -0700, Ian Rogers wrote: > > > Currently functions like get_dwarf_regnum only work with the host > > > architecture. Carry the elf machine and flags in struct arch so that > > > in disassembly these can be used to allow cross platform disassembly. > > > > > > Signed-off-by: Ian Rogers > > > --- > > > tools/perf/arch/arc/annotate/instructions.c | 2 ++ > > > tools/perf/arch/arm/annotate/instructions.c | 2 ++ > > > tools/perf/arch/arm64/annotate/instructions.c | 2 ++ > > > tools/perf/arch/csky/annotate/instructions.c | 7 ++++++- > > > tools/perf/arch/loongarch/annotate/instructions.c | 2 ++ > > > tools/perf/arch/mips/annotate/instructions.c | 2 ++ > > > tools/perf/arch/powerpc/annotate/instructions.c | 2 ++ > > > tools/perf/arch/riscv64/annotate/instructions.c | 2 ++ > > > tools/perf/arch/s390/annotate/instructions.c | 2 ++ > > > tools/perf/arch/sparc/annotate/instructions.c | 2 ++ > > > tools/perf/arch/x86/annotate/instructions.c | 3 ++- > > > tools/perf/util/disasm.h | 4 ++++ > > > 12 files changed, 30 insertions(+), 2 deletions(-) > > > > > > diff --git a/tools/perf/arch/arc/annotate/instructions.c b/tools/perf/arch/arc/annotate/instructions.c > > > index 2f00e995c7e3..e5619770a1af 100644 > > > --- a/tools/perf/arch/arc/annotate/instructions.c > > > +++ b/tools/perf/arch/arc/annotate/instructions.c > > > @@ -5,5 +5,7 @@ static int arc__annotate_init(struct arch *arch, char *cpuid __maybe_unused) > > > { > > > arch->initialized = true; > > > arch->objdump.comment_char = ';'; > > > + arch->e_machine = EM_ARC; > > > + arch->e_flags = 0; > > > return 0; > > > } > > > diff --git a/tools/perf/arch/arm/annotate/instructions.c b/tools/perf/arch/arm/annotate/instructions.c > > > index 2ff6cedeb9c5..cf91a43362b0 100644 > > > --- a/tools/perf/arch/arm/annotate/instructions.c > > > +++ b/tools/perf/arch/arm/annotate/instructions.c > > > @@ -53,6 +53,8 @@ static int arm__annotate_init(struct arch *arch, char *cpuid __maybe_unused) > > > arch->associate_instruction_ops = arm__associate_instruction_ops; > > > arch->objdump.comment_char = ';'; > > > arch->objdump.skip_functions_char = '+'; > > > + arch->e_machine = EM_ARM; > > > + arch->e_flags = 0; > > > return 0; > > > > > > out_free_call: > > > diff --git a/tools/perf/arch/arm64/annotate/instructions.c b/tools/perf/arch/arm64/annotate/instructions.c > > > index f86d9f4798bd..d465d093e7eb 100644 > > > --- a/tools/perf/arch/arm64/annotate/instructions.c > > > +++ b/tools/perf/arch/arm64/annotate/instructions.c > > > @@ -113,6 +113,8 @@ static int arm64__annotate_init(struct arch *arch, char *cpuid __maybe_unused) > > > arch->associate_instruction_ops = arm64__associate_instruction_ops; > > > arch->objdump.comment_char = '/'; > > > arch->objdump.skip_functions_char = '+'; > > > + arch->e_machine = EM_AARCH64; > > > + arch->e_flags = 0; > > > return 0; > > > > > > out_free_call: > > > diff --git a/tools/perf/arch/csky/annotate/instructions.c b/tools/perf/arch/csky/annotate/instructions.c > > > index 5337bfb7d5fc..14270311d215 100644 > > > --- a/tools/perf/arch/csky/annotate/instructions.c > > > +++ b/tools/perf/arch/csky/annotate/instructions.c > > > @@ -43,6 +43,11 @@ static int csky__annotate_init(struct arch *arch, char *cpuid __maybe_unused) > > > arch->initialized = true; > > > arch->objdump.comment_char = '/'; > > > arch->associate_instruction_ops = csky__associate_ins_ops; > > > - > > > + arch->e_machine = EM_CSKY; > > > +#if defined(__CSKYABIV2__) > > > + arch->e_flags = EF_CSKY_ABIV2; > > > +#else > > > + arch->e_flags = EF_CSKY_ABIV1; > > > +#endif > > > > By moving this into the general code, it should take care of old systems > > that doesn't have the macro. > > > > In file included from util/disasm.c:109: > > /linux/tools/perf/arch/csky/annotate/instructions.c: In function 'csky__annotate_init': > > /linux/tools/perf/arch/csky/annotate/instructions.c:50:25: error: 'EF_CSKY_ABIV1' undeclared (first use in this function) > > 50 | arch->e_flags = EF_CSKY_ABIV1; > > | ^~~~~~~~~~~~~ > > /linux/tools/perf/arch/csky/annotate/instructions.c:50:25: note: each undeclared identifier is reported only once for each function it appears in > > EF_CSKY_ABIV1 is defined in elf.h and has been there at least 5 years in libelf: > https://sourceware.org/git/?p=elfutils.git;a=commit;f=libelf/elf.h;h=9c82942ae7355a3226c53a92c2c73b33193c5e33 > I suspected the issue here is missing elf.h include, but the .c file > is included in tools/perf/util/disasm.c and that must have a > transitive dependency given other things are building. Do you want me > to send a patch making this conditional with extra #ifdefs or re-send > the series? Yeah, it's unfortunate but I think we can have a small incremental diff here to define them if it's not there. Then I'll squash it to the patch. > > > Also, I think __CSKYABIV2__ is defined only when the host is csky. So > > it'll use ABI v1 on cross env. I'm not sure if it's a problem. We may > > need to save the ABI somewhere in the metadata later. > > Agreed. In general we should read e_machine and e_flags from the ELF > file, so I'm not sure new metadata is needed. This patch is trying to > lay groundwork for that. I understand that. Yeah it should come from the binary. Thanks, Namhyung