From nobody Sat Nov 23 23:53:01 2024 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E58720DD42 for ; Fri, 8 Nov 2024 23:46:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731109582; cv=none; b=FV80JERl0/mHS3P4WWrlFql/qJxlXuBQEarivaBQALN7PlXLxhaEf0FwTj+m4aP1au6Elcfkha6poQs1DUOxtEYym4qBRfP4EPvNhT+gDEiI+AchjQCE2uX1alsEJnpdI89vfG8DFxNGTXhsw3gedF0WiPVftYaMInEPGxKYGxA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731109582; c=relaxed/simple; bh=69ZCkIknxwz1LbqUVzw2Tr9y6pSCOiCgn8w870jj4Y4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=YXlUM+lZrvsxz/rd9w55xwIEz97/UOLwVQbzilnpQBrPlK8xo1l3tII1hrLR3pq23wWP6XjKplLR6y29sgGzNe1S0aTfbtVjIwiG79cRrUd/J2AZXlK4NsTJqkUOmDNzJLONX/i4yFueuoFXN5FCnZ9NluJAN/q0KqA6IUYmC28= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=NZq3zu/+; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NZq3zu/+" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6ea7cfb6e0fso54808627b3.0 for ; Fri, 08 Nov 2024 15:46:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731109579; x=1731714379; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=WqfEj71qwDvDkOaRaAnJba0Q5cD+cxzhGu3trqLHupE=; b=NZq3zu/+FD1PKJ1PO9EDEnUELTKOofvlT/hTU3+4OSZ7QsbT1UJBVqZtGMU1iIhlur UQDfExt1JmzoN/MfBa9eOi/FK3vCYrPonpO81+s+PkCFQXS6JZlwbQDrKpetmbIdN712 hMURVxhi30+PVRMmUh3G8uQAsyDcJN9IEd7DKDjAVlNPnq9pA8W0PI7S5sHzPAtQwn6Q OlEeW/R1OkNzaPzVqVRG6aGJ3iihhW9fSpSE7vg65jSXL0EiNnbVF+iorOMsV62qRoAI UHLFwwUOxslYkJVDuNNS4fRmvCdRVosh4Isi9hnmOd+reQ7JQPIB6qMYUmjs3WAySClz bnJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731109579; x=1731714379; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WqfEj71qwDvDkOaRaAnJba0Q5cD+cxzhGu3trqLHupE=; b=mXCiZwUTj2tdM5qpSl3WeqxjpoxOamdBxEyHWWwzw4Tm1AWsk2dLruIrP7iCochOAA F0ok1REQjvtIRsWjb6Q7kzTevMXK+ApoUsu+YdVUTophn7tag8olbtFB8S7JH4TwQ7hm yUcXKJuCDcX0QTMc78+E7qBtp6OXN/bKGpYTlOAr7Dkn0GoqgZTB2bN1Ld7ZF1C27hdG mo8CJzELpS6EXJurbF0bYSH1JUbmMqRXIRJUgklJRieNElJ8Hfl1SGo8q9yuGlM3cy1E aAlxIF9ujvdnCCCBCPeQQC7sNyKmJdkUEVBbR94ze5ZPoMdB9+n3BgxvqH+BbUkecZD2 aizQ== X-Forwarded-Encrypted: i=1; AJvYcCX0PGEx1AQtFuOCB9Qc1lDJ+k+Ki7YWHMyXvSrDv1B/NFyH2SDdilc2kLt+/5fqs55nQBLSpYX5hSpmv2o=@vger.kernel.org X-Gm-Message-State: AOJu0YxZeks39I+5XE18O/454HAyDF9s8AH4j4zKcVA0FHch17EyHV6g UMPo6t+1me7/6n5diofFhCCzFllgGIw5T6aIZSAoWW101FPYIYdlxIHK5Vq0t+805ae877OWV2f TvUHd8Q== X-Google-Smtp-Source: AGHT+IFG/coLtc60xe7I+tUPVMErNFQ95tPpAKZEYNJPxy2g446wDwL8CjW44zY00BE7dZq8D8riH1qdukJU X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:6fd2:1e36:6d8c:7c49]) (user=irogers job=sendgmr) by 2002:a25:949:0:b0:e1d:912e:9350 with SMTP id 3f1490d57ef6-e337f8beb2amr10471276.6.1731109579378; Fri, 08 Nov 2024 15:46:19 -0800 (PST) Date: Fri, 8 Nov 2024 15:45:49 -0800 In-Reply-To: <20241108234606.429459-1-irogers@google.com> Message-Id: <20241108234606.429459-5-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241108234606.429459-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.277.g8800431eea-goog Subject: [PATCH v4 04/20] perf disasm: Add e_machine/e_flags to struct arch From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Reviewed-by: Masami Hiramatsu (Google) 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 *cpui= d __maybe_unused) { arch->initialized =3D true; arch->objdump.comment_char =3D ';'; + arch->e_machine =3D EM_ARC; + arch->e_flags =3D 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 *cp= uid __maybe_unused) arch->associate_instruction_ops =3D arm__associate_instruction_ops; arch->objdump.comment_char =3D ';'; arch->objdump.skip_functions_char =3D '+'; + arch->e_machine =3D EM_ARM; + arch->e_flags =3D 0; return 0; =20 out_free_call: diff --git a/tools/perf/arch/arm64/annotate/instructions.c b/tools/perf/arc= h/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 =3D arm64__associate_instruction_ops; arch->objdump.comment_char =3D '/'; arch->objdump.skip_functions_char =3D '+'; + arch->e_machine =3D EM_AARCH64; + arch->e_flags =3D 0; return 0; =20 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 =3D true; arch->objdump.comment_char =3D '/'; arch->associate_instruction_ops =3D csky__associate_ins_ops; - + arch->e_machine =3D EM_CSKY; +#if defined(__CSKYABIV2__) + arch->e_flags =3D EF_CSKY_ABIV2; +#else + arch->e_flags =3D EF_CSKY_ABIV1; +#endif return 0; } diff --git a/tools/perf/arch/loongarch/annotate/instructions.c b/tools/perf= /arch/loongarch/annotate/instructions.c index ab43b1ab51e3..70262d5f1444 100644 --- a/tools/perf/arch/loongarch/annotate/instructions.c +++ b/tools/perf/arch/loongarch/annotate/instructions.c @@ -131,6 +131,8 @@ int loongarch__annotate_init(struct arch *arch, char *c= puid __maybe_unused) arch->associate_instruction_ops =3D loongarch__associate_ins_ops; arch->initialized =3D true; arch->objdump.comment_char =3D '#'; + arch->e_machine =3D EM_LOONGARCH; + arch->e_flags =3D 0; } =20 return 0; diff --git a/tools/perf/arch/mips/annotate/instructions.c b/tools/perf/arch= /mips/annotate/instructions.c index 340993f2a897..b50b46c613d6 100644 --- a/tools/perf/arch/mips/annotate/instructions.c +++ b/tools/perf/arch/mips/annotate/instructions.c @@ -40,6 +40,8 @@ int mips__annotate_init(struct arch *arch, char *cpuid __= maybe_unused) arch->associate_instruction_ops =3D mips__associate_ins_ops; arch->initialized =3D true; arch->objdump.comment_char =3D '#'; + arch->e_machine =3D EM_MIPS; + arch->e_flags =3D 0; } =20 return 0; diff --git a/tools/perf/arch/powerpc/annotate/instructions.c b/tools/perf/a= rch/powerpc/annotate/instructions.c index 54478cf5cccc..ca567cfdcbdb 100644 --- a/tools/perf/arch/powerpc/annotate/instructions.c +++ b/tools/perf/arch/powerpc/annotate/instructions.c @@ -309,6 +309,8 @@ static int powerpc__annotate_init(struct arch *arch, ch= ar *cpuid __maybe_unused) arch->associate_instruction_ops =3D powerpc__associate_instruction_ops; arch->objdump.comment_char =3D '#'; annotate_opts.show_asm_raw =3D true; + arch->e_machine =3D EM_PPC; + arch->e_flags =3D 0; } =20 return 0; diff --git a/tools/perf/arch/riscv64/annotate/instructions.c b/tools/perf/a= rch/riscv64/annotate/instructions.c index 869a0eb28953..55cf911633f8 100644 --- a/tools/perf/arch/riscv64/annotate/instructions.c +++ b/tools/perf/arch/riscv64/annotate/instructions.c @@ -28,6 +28,8 @@ int riscv64__annotate_init(struct arch *arch, char *cpuid= __maybe_unused) arch->associate_instruction_ops =3D riscv64__associate_ins_ops; arch->initialized =3D true; arch->objdump.comment_char =3D '#'; + arch->e_machine =3D EM_RISCV; + arch->e_flags =3D 0; } =20 return 0; diff --git a/tools/perf/arch/s390/annotate/instructions.c b/tools/perf/arch= /s390/annotate/instructions.c index eeac25cca699..c61193f1e096 100644 --- a/tools/perf/arch/s390/annotate/instructions.c +++ b/tools/perf/arch/s390/annotate/instructions.c @@ -166,6 +166,8 @@ static int s390__annotate_init(struct arch *arch, char = *cpuid __maybe_unused) if (s390__cpuid_parse(arch, cpuid)) err =3D SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_CPUID_PARSING; } + arch->e_machine =3D EM_S390; + arch->e_flags =3D 0; } =20 return err; diff --git a/tools/perf/arch/sparc/annotate/instructions.c b/tools/perf/arc= h/sparc/annotate/instructions.c index 2614c010c235..68c31580ccfc 100644 --- a/tools/perf/arch/sparc/annotate/instructions.c +++ b/tools/perf/arch/sparc/annotate/instructions.c @@ -163,6 +163,8 @@ static int sparc__annotate_init(struct arch *arch, char= *cpuid __maybe_unused) arch->initialized =3D true; arch->associate_instruction_ops =3D sparc__associate_instruction_ops; arch->objdump.comment_char =3D '#'; + arch->e_machine =3D EM_SPARC; + arch->e_flags =3D 0; } =20 return 0; diff --git a/tools/perf/arch/x86/annotate/instructions.c b/tools/perf/arch/= x86/annotate/instructions.c index c869abe3c31d..ae94b1f0b9cc 100644 --- a/tools/perf/arch/x86/annotate/instructions.c +++ b/tools/perf/arch/x86/annotate/instructions.c @@ -202,7 +202,8 @@ static int x86__annotate_init(struct arch *arch, char *= cpuid) if (x86__cpuid_parse(arch, cpuid)) err =3D SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_CPUID_PARSING; } - + arch->e_machine =3D EM_X86_64; + arch->e_flags =3D 0; arch->initialized =3D true; return err; } diff --git a/tools/perf/util/disasm.h b/tools/perf/util/disasm.h index 486c269b29ba..c135db2416b5 100644 --- a/tools/perf/util/disasm.h +++ b/tools/perf/util/disasm.h @@ -44,6 +44,10 @@ struct arch { struct data_loc_info *dloc, Dwarf_Die *cu_die, struct disasm_line *dl); #endif + /** @e_machine: ELF machine associated with arch. */ + unsigned int e_machine; + /** @e_flags: Optional ELF flags associated with arch. */ + unsigned int e_flags; }; =20 struct ins { --=20 2.47.0.277.g8800431eea-goog