From nobody Tue Nov 26 17:20:13 2024 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 9A41822611 for ; Thu, 17 Oct 2024 00:25:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729124740; cv=none; b=hUOPQ3hw3tNzpAtMEDdVYHkCfXtvKylLuqgqInEAgGvlK/Sp4LZjXulyO//uJoQ3ucA4vUeEv2SnOjntZkuwMqcP4ZvlVoIh4vAVtCsmxikJe9mFu07IxsfY+aW+oRZs/vBHS16Cy3w5BiX0Vi2iRjimzzBLm+FC+ab9JuJ15yY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729124740; c=relaxed/simple; bh=Ub0eI8MquskH2tQc5oWIlYlsm4t9+UhJX2S2GNP7lKs=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=AyfjWW16/d3+mNmuHSX+5C3SZYInz9BVN3jMOkRMcJnKoNoFb1AL+yypWCOEvcpZWOymPUmuNk95LEmdyD+5QGskeo1/ATr0yfpZEjzID8fiCGZcVnQ4krOMeLAT5gT+17/6NCBOH2B5syDGi67FhfRScWF5Wru8qxgmCB5c/FU= 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=FjX4sBvy; arc=none smtp.client-ip=209.85.128.201 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="FjX4sBvy" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6dbbeee08f0so21877607b3.0 for ; Wed, 16 Oct 2024 17:25:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729124738; x=1729729538; 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=KMncvSxke+r4vucw8oUD2KkaxOVK5uFPUegLmuP56t0=; b=FjX4sBvyx9dHUHv3oEODwbZknSLwsqHN9gl6d7wtMk46fXgnPG4I37ran6P50eqHWg Z7DZJGM6WW9oJbynE4Xn/2XEwGBGKa3wOCAzNy1i65NH2Zhz1F2pWgAjJLLzDloKazbC m9NM7iyhKggKxdyu7BN8p+WLqKZjTCZ8LkPjaTr0V7xxfpw/fq05bbnlXAKLw1vuiJ3x e0YoclU85cvSJIf4l052Vt9w4xc49F176mrqs2H3mw+w2rSGCLv9PD5GQDZgQvxSBq0Q PNhhGRIO0Q9gnkjYWXwoQsZ5tfYfqQ3x6zebOlqmDTgmrsgSJKaRMrO7Z1NWcBklqkUA +BuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729124738; x=1729729538; 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=KMncvSxke+r4vucw8oUD2KkaxOVK5uFPUegLmuP56t0=; b=lfNlsFjR6Bn2glyajpfxlfVaqfFeVBG3mmvX9m41s4XXkSd86bpCj+QQkPbR1Bi88v H+Zu78wJWq+zMJY0JOUcKmxtc2k98cZ5DKfRho/VLTAyp3g1W6pDLD9JRp7zaqvPaNbL /4aRaUML1N7Dmoo5KSUFXwABKQK0PMhtIW9O/kvOtvDtqMA3E8zuUKvEL70azSmPrIph HTP7DE0Vd1CCY6IBL7ABf71faGKLNutnOxRiJUhJ9Rk6zGtNVSc17b2YL4aru4vpwVge krhevnBg+R1raYw/TE/0D29zhdoRJCYqNkkDNg35ONq5HKwN5YkxoOB9d7RUU9g5bIMX zKaA== X-Forwarded-Encrypted: i=1; AJvYcCXY7EdxWukHn9y4JRVP8wvgxnM8HN86JwzbGwotSl/GJlGUC6sn2KsH42NbDUBEDDz0hCeL4kTV3JEDt74=@vger.kernel.org X-Gm-Message-State: AOJu0Ywelre0ZpVAW+PHqWIplDbiuRxVZoLLH9xhzjZFQkjhvO8WuwXs 7+zZ8qsi9XsulOcw33ZqM0ax7e+ktIa7j4VZBIwATvonszhRO6bcanesbTeG3L+PdDSyy/QsL8N se3Is3Q== X-Google-Smtp-Source: AGHT+IHnKt+0wOaTE7zUTQI2rphyZXnAK5a4MY8raKX1baBAVylSM1xTDZRcbIFg3cQETXVoUICk0Kp05Tww X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:a00a:f237:9bc0:79c]) (user=irogers job=sendgmr) by 2002:a25:aa0c:0:b0:e1c:ffab:a801 with SMTP id 3f1490d57ef6-e2b9ce000a9mr1691276.2.1729124737505; Wed, 16 Oct 2024 17:25:37 -0700 (PDT) Date: Wed, 16 Oct 2024 17:25:04 -0700 In-Reply-To: <20241017002520.59124-1-irogers@google.com> Message-Id: <20241017002520.59124-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: <20241017002520.59124-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v3 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. 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.105.g07ac214952-goog