From nobody Tue Nov 26 17:30:28 2024 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.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 789177DA7F for ; Thu, 17 Oct 2024 00:25:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729124755; cv=none; b=gOU3wY8wtBE1RZtZ0auwOUWeokAj2h1HWpFqihrelJNRhZ5YaePbBy6ulAgNzIlufOjEMM7EFgBbj95XOgr3IIzAlQGPf6T/qGXR1btrencFFBRfbMGkX1mviZ2rARyfudQ/lLkMpyoRMBH6r69xGFt5ysBNe7jm+jZtOfqi7pI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729124755; c=relaxed/simple; bh=o0PTiK+y2h1Uws8X+L8gDKhz8hsLaB6wtA4lBZEY35A=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=GDrzNB94Bo2EZ4qesUbyDAuI22pNzsOpyz5U0laJxgiVJs/ZCoWuI3j1d995Klbdj+4eyeYJ5tR+mHcyxiC1zJK580LiWMrkzcdFcfiOQSh8vxxDRakyFF1TNiaXcA8QZnBevhT25ckTPuXFBIMnYeE1dLMlySBKrIStbCWzcLc= 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=WEjkKY1p; arc=none smtp.client-ip=209.85.219.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="WEjkKY1p" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e2946a143efso584655276.1 for ; Wed, 16 Oct 2024 17:25:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729124752; x=1729729552; 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=WG2Q2FB5LUQz01Yds7IeFcawWLtm3SGWZPYeFSNMQiM=; b=WEjkKY1p1uQlJfkOR6IE2d27rPTmTgeAV3zp7NP8VjjIeZV2ZfrUPMTYrtxWwQFqns IUn8A7Ah/WLGh1iJfQKrw1e+u4PRlCKNTD2eFXj3nG7u3VZ6J+PpmTLcUW9Q+zc8zfai CVT069pyHHVD2rotVyJnIXNCEfz/myxiHPkLLJ141y9eKsPdE7mMbkvZ7dzI1/YodNf3 Z5XeNm5HPRvZvXQMuIDKFT7NjCzYgJ9pSzPL75ySV5EB7qDe1uU2JNQVSBLoifsNT1EE fWxZjEPect2atJoptYOxSzHvRYk/h0gYrA+OVljb1eSSP0vCU+wiceVxRPBnNIDmf2c/ 5UJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729124752; x=1729729552; 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=WG2Q2FB5LUQz01Yds7IeFcawWLtm3SGWZPYeFSNMQiM=; b=IJaeEUSY+ZKsbWLjKfM/2ea28gEh5W1Wuoc3HGsEz37g62t2amG7Nd3UQVh014EVPz 8z2mvhDkC9lXLRjKc5tXN4KpzsbT2hluei1bp08koOOVc98Ghe3TeNN7Oq7SI7L1niUJ 2LgUweIrvfyy96uiaT0T25W3eLOVWG09DL93GTMuNRSqON8l8nuVxl9tzFSZK3fN8ubG oKVyp5mBm+OW6ZZpy1kFawLCALeTjbryPlxnOqQxthFHe54MoR7SbhEkjkJ5djCAsi3s QR99yq9dlh9d67Y6tbGndamC3zgY5idusEEfpLCBCJTAr7s/irD9f+GDVE1VkioarvqQ 0gzw== X-Forwarded-Encrypted: i=1; AJvYcCV5uf8fklngJX2aRRALXo1WCjX1+y40sWn70XtyDPaH/LgseTwwTvC22HgHLMdKf8p5q4upZR4ssCf1ejk=@vger.kernel.org X-Gm-Message-State: AOJu0YzoT73Wb/wI1NQ24g+AvCzyZe1rz2QIDQcqQBJXmP8bTOf1FPXP XFST+n1FG0LmiFJ1eKt2dZq0n3n3SrdfybEGuNml8ihYOVK/cjS77BJr1dUQLhEtXU5MVSUNQLu XTgZa3g== X-Google-Smtp-Source: AGHT+IG59YkLvXbjXDygQC7BU6le1sFVoo2SJFZVP20/F7DRXE23oZyCK22C1Wgez9VaPqSPFNUmUo+ETWGD X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:a00a:f237:9bc0:79c]) (user=irogers job=sendgmr) by 2002:a25:bd91:0:b0:e0b:f6aa:8088 with SMTP id 3f1490d57ef6-e2b9cdec686mr2964276.1.1729124752310; Wed, 16 Oct 2024 17:25:52 -0700 (PDT) Date: Wed, 16 Oct 2024 17:25:10 -0700 In-Reply-To: <20241017002520.59124-1-irogers@google.com> Message-Id: <20241017002520.59124-11-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 10/20] perf dwarf-regs: Move csky dwarf-regs out of 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" Move arch/csky/util/dwarf-regs.c to util/dwarf-regs-csky.c and compile in unconditionally. To avoid get_arch_regstr being duplicated, rename to get_csky_regstr and add to get_dwarf_regstr switch. Update #ifdefs to allow ABI V1 and V2 tables at the same time. Determine the table from the ELF flags. Signed-off-by: Ian Rogers --- tools/perf/arch/csky/util/Build | 1 - tools/perf/util/Build | 1 + .../dwarf-regs.c =3D> util/dwarf-regs-csky.c} | 19 ++++++++++--------- tools/perf/util/dwarf-regs.c | 11 +++++++---- tools/perf/util/include/dwarf-regs.h | 2 ++ 5 files changed, 20 insertions(+), 14 deletions(-) rename tools/perf/{arch/csky/util/dwarf-regs.c =3D> util/dwarf-regs-csky.c= } (74%) diff --git a/tools/perf/arch/csky/util/Build b/tools/perf/arch/csky/util/Bu= ild index 1325310cab6a..5e6ea82c4202 100644 --- a/tools/perf/arch/csky/util/Build +++ b/tools/perf/arch/csky/util/Build @@ -1,4 +1,3 @@ perf-util-y +=3D perf_regs.o =20 -perf-util-$(CONFIG_LIBDW) +=3D dwarf-regs.o perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) +=3D unwind-libdw.o diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 4c615611b9d7..99ae4e2802b8 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -203,6 +203,7 @@ endif perf-util-$(CONFIG_LIBDW) +=3D probe-finder.o perf-util-$(CONFIG_LIBDW) +=3D dwarf-aux.o perf-util-$(CONFIG_LIBDW) +=3D dwarf-regs.o +perf-util-$(CONFIG_LIBDW) +=3D dwarf-regs-csky.o perf-util-$(CONFIG_LIBDW) +=3D dwarf-regs-x86.o perf-util-$(CONFIG_LIBDW) +=3D debuginfo.o perf-util-$(CONFIG_LIBDW) +=3D annotate-data.o diff --git a/tools/perf/arch/csky/util/dwarf-regs.c b/tools/perf/util/dwarf= -regs-csky.c similarity index 74% rename from tools/perf/arch/csky/util/dwarf-regs.c rename to tools/perf/util/dwarf-regs-csky.c index ca86ecaeacbb..d38ef1f07f3e 100644 --- a/tools/perf/arch/csky/util/dwarf-regs.c +++ b/tools/perf/util/dwarf-regs-csky.c @@ -5,9 +5,8 @@ #include #include =20 -#if defined(__CSKYABIV2__) -#define CSKY_MAX_REGS 73 -const char *csky_dwarf_regs_table[CSKY_MAX_REGS] =3D { +#define CSKY_ABIV2_MAX_REGS 73 +const char *csky_dwarf_regs_table_abiv2[CSKY_ABIV2_MAX_REGS] =3D { /* r0 ~ r8 */ "%a0", "%a1", "%a2", "%a3", "%regs0", "%regs1", "%regs2", "%regs3", /* r9 ~ r15 */ @@ -26,9 +25,9 @@ const char *csky_dwarf_regs_table[CSKY_MAX_REGS] =3D { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "%epc", }; -#else -#define CSKY_MAX_REGS 57 -const char *csky_dwarf_regs_table[CSKY_MAX_REGS] =3D { + +#define CSKY_ABIV1_MAX_REGS 57 +const char *csky_dwarf_regs_table_abiv1[CSKY_ABIV1_MAX_REGS] =3D { /* r0 ~ r8 */ "%sp", "%regs9", "%a0", "%a1", "%a2", "%a3", "%regs0", "%regs1", /* r9 ~ r15 */ @@ -41,9 +40,11 @@ const char *csky_dwarf_regs_table[CSKY_MAX_REGS] =3D { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "%epc", }; -#endif =20 -const char *get_arch_regstr(unsigned int n) +const char *get_csky_regstr(unsigned int n, unsigned int flags) { - return (n < CSKY_MAX_REGS) ? csky_dwarf_regs_table[n] : NULL; + if (flags & EF_CSKY_ABIV2) + return (n < CSKY_ABIV2_MAX_REGS) ? csky_dwarf_regs_table_abiv2[n] : NULL; + + return (n < CSKY_ABIV1_MAX_REGS) ? csky_dwarf_regs_table_abiv1[n] : NULL; } diff --git a/tools/perf/util/dwarf-regs.c b/tools/perf/util/dwarf-regs.c index fd21f9e90e40..9a76f83af62c 100644 --- a/tools/perf/util/dwarf-regs.c +++ b/tools/perf/util/dwarf-regs.c @@ -29,17 +29,18 @@ #define __get_dwarf_regstr(tbl, n) (((n) < ARRAY_SIZE(tbl)) ? (tbl)[(n)] := NULL) =20 /* Return architecture dependent register string (for kprobe-tracer) */ -const char *get_dwarf_regstr(unsigned int n, unsigned int machine, - unsigned int flags __maybe_unused) +const char *get_dwarf_regstr(unsigned int n, unsigned int machine, unsigne= d int flags) { -#if EM_HOST =3D=3D EM_X86_64 || EM_HOST =3D=3D EM_386 || EM_HOST =3D=3D EM= _AARCH64 || EM_HOST =3D=3D EM_ARM +#if EM_HOST =3D=3D EM_X86_64 || EM_HOST =3D=3D EM_386 || EM_HOST =3D=3D EM= _AARCH64 || EM_HOST =3D=3D EM_ARM \ + || EM_HOST =3D=3D EM_CSKY if (machine =3D=3D EM_NONE) { /* Generic arch - use host arch */ machine =3D EM_HOST; } #endif switch (machine) { -#if EM_HOST !=3D EM_X86_64 && EM_HOST !=3D EM_386 && EM_HOST !=3D EM_AARCH= 64 && EM_HOST !=3D EM_ARM +#if EM_HOST !=3D EM_X86_64 && EM_HOST !=3D EM_386 && EM_HOST !=3D EM_AARCH= 64 && EM_HOST !=3D EM_ARM \ + && EM_HOST !=3D EM_CSKY case EM_NONE: /* Generic arch - use host arch */ return get_arch_regstr(n); #endif @@ -51,6 +52,8 @@ const char *get_dwarf_regstr(unsigned int n, unsigned int= machine, return __get_dwarf_regstr(arm_regstr_tbl, n); case EM_AARCH64: return __get_dwarf_regstr(aarch64_regstr_tbl, n); + case EM_CSKY: + return get_csky_regstr(n, flags); case EM_SH: return __get_dwarf_regstr(sh_regstr_tbl, n); case EM_S390: diff --git a/tools/perf/util/include/dwarf-regs.h b/tools/perf/util/include= /dwarf-regs.h index 0b533409d82a..b72d9d308ce4 100644 --- a/tools/perf/util/include/dwarf-regs.h +++ b/tools/perf/util/include/dwarf-regs.h @@ -83,6 +83,8 @@ const char *get_arch_regstr(unsigned int n); #endif =20 +const char *get_csky_regstr(unsigned int n, unsigned int flags); + /** * get_dwarf_regstr() - Returns ftrace register string from DWARF regnum. * @n: DWARF register number. --=20 2.47.0.105.g07ac214952-goog