From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id EQCLHqxspmlM0hEAWB0awg (envelope-from ) for ; Tue, 03 Mar 2026 00:07:56 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=QryG+fss; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 7921C1E08D; Tue, 03 Mar 2026 00:07:56 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 917611E08D for ; Tue, 03 Mar 2026 00:07:55 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 122B14BA23E0 for ; Tue, 3 Mar 2026 05:07:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 122B14BA23E0 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=QryG+fss Received: from mail-dy1-x1332.google.com (mail-dy1-x1332.google.com [IPv6:2607:f8b0:4864:20::1332]) by sourceware.org (Postfix) with ESMTPS id D2B114BA23CD for ; Tue, 3 Mar 2026 05:06:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D2B114BA23CD Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D2B114BA23CD Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1332 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772514418; cv=none; b=aD625Vmf4sQOFwdb4yDxaj/bKN/x5YhHQY/3Bnn7mo9/oRu892rPpWfsvlskuJARdYd5jfmRzT1yAhilyIrIaXb4XFM4bCxymNvuLozhfwSYTEO6n2+XrHt9wbrHUe6f+j3YiU0ejqunoNSw1Knlz31mW737RRglNxCxI7h4bsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772514418; c=relaxed/simple; bh=a67xzsAV17n0ieAuMe/5fSPidTYxd2j0ckZ/lRp2K7k=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wrHsuz18e4/iakK0dAg1pvtEGWZNeX6gouaUu/Yq/rVHNf871AghO6CjzKqES4WV/PwGUDqXMAV8Zo13ruzN3DPKG+ZP6Tx2LwD5Gp8u7uVvvx3Trnf15lpmC7BVt5JHUKgxleXagORGAhknU+Yl2Ns0Xo3Y0A+fCziyjAKyOYA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D2B114BA23CD Received: by mail-dy1-x1332.google.com with SMTP id 5a478bee46e88-2bdfc4b191fso1759817eec.1 for ; Mon, 02 Mar 2026 21:06:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772514412; x=1773119212; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ulbQi6LuM2MDlswNlWyJLxL8Ln4EF+xQD/+J/Kj9OQs=; b=QryG+fssMNbQU/MYmnBzqSyTB6LBIxLDwi8AZtCH32y+Fr0rvvqR8F7Wc/m76lznT8 efB81VkT3Xc9Jqg6VIuUONuBUYY3l4lPpjS1+UmZh6P4+RiQ8w2D6MFkDg8wesXRsP1X wDPAKP9BtvsMjnuvWSziLUIeISPWAUCCstZanxy5YJq+7ijf+KsdoVWF9/fmYVqJmuNu tzaMtW6J7GP0tOQUbU21coTW1bDtdO/ox27pomhK7lZePdpz8S8ACzs77KfZORHdLcUh eRpMc2o6S+d6MeSp3ppz5UC8O9L2T5y5ilqRQV+r2m//KT1FvfVPKdc38hPBAU3VDcF6 f/pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772514412; x=1773119212; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ulbQi6LuM2MDlswNlWyJLxL8Ln4EF+xQD/+J/Kj9OQs=; b=jUlTIaGe19Ri83LLu4cN+m8zT3hI2EOUzT4ktUrNkKbHOES8h0qdh7Ly4NKYSXQLwA AJ33AZWT4cjeVRBjmnrZIPpRdlASm/9whffWzPPki7+6EN3RYkLS99KlfJ2+KG5mbkAB pqImLjRahY7jjVnsQ/SL4UYsrk7iu/mkqtIpZ8At7XhI4Uja/JO79Fd0EvpvxB9nUK/Z hBL3XKKHjzAOKxOHHxBMaNAdsfvRz/RblyU292MGCFykCFNOh353Tx3RIQACNHTReIz6 AneZ/Opq9uR1GjmZxhjvk/6KwLzroNQFbYjWXdJ4B09EYOf4KDxcnxgKm8yMrMvH39rz 40tg== X-Gm-Message-State: AOJu0Yx3izx/dozSimplyoBDehSviygAT72LKX4tonsK/HRsvKaaWBI6 NWvdtQw+61mqgv14hL8aOBVYj3HhYFriYfCJ1gzu8q2mTRjYhRXdfE/kFOmg5Q5ecEUEqMizU3m cBUernTc= X-Gm-Gg: ATEYQzwyXrauIxkKKqoGKd9ztRPI5mzlRuC0PiDX0sK5XJC0NkqZq1lGhBh2VpXnDrJ 0H20TgKXT/NoEU2WpCOUibN/Zc8sVQeNRQ4SfNyV6nsAwxCv1INtPDEjtktO4UBTr5hTOqmiqAN 5JchVZIC6+68BO8TmfbWw1a7L+iA7YBn7E9PCpOSw3OI600PNbLheKgoUaTIc4C0suoZ+lMWBAM CpB8mRiwBo85fnRpoJ8SrUZe7HhnCHY7rqCFDkBdbzRqXVkOU+JEuMstiXf+xD7+ydZGwARhl+N 062C/6XOKaRGrXacDZMs4RmPprsrPa3mfpRl16UvbwxLlkdGnqWKcS4DcS5uUCsUNGKXsgKaftR VFmTL91MMU91oA9UK/KbruJRkHnVeVubgNz8GzCPYMQj/Bqjq4qA0zOyl7VhLNQRjuYPIft7gs/ QPOG8lrJNxP/dqctocFqLZOWzUAwq4gA9hRA== X-Received: by 2002:a05:7300:1348:b0:2be:22b0:8bf3 with SMTP id 5a478bee46e88-2be22b090e8mr378985eec.30.1772514411584; Mon, 02 Mar 2026 21:06:51 -0800 (PST) Received: from localhost ([2804:14d:7e39:8083:f04c:42e3:5943:38f6]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2be1ce921dasm2014306eec.10.2026.03.02.21.06.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2026 21:06:51 -0800 (PST) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Cc: Chris Packham , Luis , Tom Tromey , Simon Marchi , sunilkumar.dora@windriver.com Subject: [PATCH v4 3/6] GDB: aarch64-linux: Reorganize MTE-related definitions Date: Tue, 3 Mar 2026 02:06:38 -0300 Message-ID: <20260303050641.198127-4-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260303050641.198127-1-thiago.bauermann@linaro.org> References: <20260303050641.198127-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org GDB conditionally defines HWCAP2_MTE in gdb/arch/aarch64-mte-linux.h, but that's not the best place for it since it's a definition that should be used only in native code so move it to gdb/nat/aarch64-mte-linux-ptrace.h. Introduce an AARCH64_HWCAP2_MTE in gdb/arch/aarch64-mte-linux.h to be used by target-dependant code. Similarly, add AARCH64_ prefix to the SEGV_MTEAERR and SEGV_MTESERR definitions in gdb/arch/aarch64-mte-linux.h. I noticed that enum class aarch64_memtag_type is only used in native code, so move its definition to gdb/nat/aarch64-mte-linux-ptrace.h as well. I also noticed that gdb/aarch64-linux-tdep.h defines AARCH64_LINUX_SIZEOF_MTE_REGSET which is redundant with AARCH64_LINUX_SIZEOF_MTE, already defined in gdb/arch/aarch64-mte-linux.h so consolidate both definitions. Finally, the include of arch/aarch64-mte-linux.h isn't used in gdb/aarch64-linux-nat.c nor in gdb/nat/aarch64-mte-linux-ptrace.c so remove it from them. Suggested-by: Luis Suggested-by: Simon Marchi --- gdb/aarch64-linux-nat.c | 4 +--- gdb/aarch64-linux-tdep.c | 6 +++--- gdb/aarch64-linux-tdep.h | 3 --- gdb/arch/aarch64-mte-linux.h | 23 ++++------------------- gdb/nat/aarch64-mte-linux-ptrace.c | 1 - gdb/nat/aarch64-mte-linux-ptrace.h | 14 ++++++++++++++ gdbserver/linux-aarch64-low.cc | 2 +- 7 files changed, 23 insertions(+), 30 deletions(-) diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 81a46ee1f0d0..d12e2ddcfb28 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -35,6 +35,7 @@ #include "nat/aarch64-fpmr-linux.h" #include "nat/aarch64-linux.h" #include "nat/aarch64-linux-hw-point.h" +#include "nat/aarch64-mte-linux-ptrace.h" #include "nat/aarch64-pauth-linux.h" #include "nat/aarch64-scalable-linux-ptrace.h" @@ -54,9 +55,6 @@ #include "arch-utils.h" #include "arch/aarch64-gcs-linux.h" -#include "arch/aarch64-mte-linux.h" - -#include "nat/aarch64-mte-linux-ptrace.h" #include "arch/aarch64-scalable-linux.h" #include diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index 504e4126f1bc..4ca05fba771d 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -1764,7 +1764,7 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch, features.vq = aarch64_linux_core_read_vq_from_sections (gdbarch, abfd); features.pauth = hwcap & AARCH64_HWCAP_PACA; features.gcs = features.gcs_linux = hwcap & HWCAP_GCS; - features.mte = hwcap2 & HWCAP2_MTE; + features.mte = hwcap2 & AARCH64_HWCAP2_MTE; features.fpmr = hwcap2 & AARCH64_HWCAP2_FPMR; /* Handle the TLS section. */ @@ -2698,7 +2698,7 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch, const char *meaning; - if (si_code == SEGV_MTEAERR || si_code == SEGV_MTESERR) + if (si_code == AARCH64_SEGV_MTEAERR || si_code == AARCH64_SEGV_MTESERR) meaning = _("Memory tag violation"); else if (si_code == SEGV_CPERR && si_errno == 0) meaning = _("Guarded Control Stack error"); @@ -2710,7 +2710,7 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch, uiout->field_string ("sigcode-meaning", meaning); /* For synchronous faults, show additional information. */ - if (si_code == SEGV_MTESERR) + if (si_code == AARCH64_SEGV_MTESERR) { uiout->text (_(" while accessing address ")); uiout->field_core_addr ("fault-addr", gdbarch, fault_addr); diff --git a/gdb/aarch64-linux-tdep.h b/gdb/aarch64-linux-tdep.h index b99fe91f36bd..385b03cc1be7 100644 --- a/gdb/aarch64-linux-tdep.h +++ b/gdb/aarch64-linux-tdep.h @@ -33,9 +33,6 @@ alignment. */ #define AARCH64_LINUX_SIZEOF_FPREGSET (33 * V_REGISTER_SIZE) -/* The MTE regset consists of a 64-bit register. */ -#define AARCH64_LINUX_SIZEOF_MTE_REGSET (8) - extern const struct regset aarch64_linux_gregset; extern const struct regset aarch64_linux_fpregset; diff --git a/gdb/arch/aarch64-mte-linux.h b/gdb/arch/aarch64-mte-linux.h index 5c7e78c71eaf..bc31ae52b916 100644 --- a/gdb/arch/aarch64-mte-linux.h +++ b/gdb/arch/aarch64-mte-linux.h @@ -20,29 +20,14 @@ #ifndef GDB_ARCH_AARCH64_MTE_LINUX_H #define GDB_ARCH_AARCH64_MTE_LINUX_H - -/* Feature check for Memory Tagging Extension. */ -#ifndef HWCAP2_MTE -#define HWCAP2_MTE (1 << 18) -#endif +#define AARCH64_HWCAP2_MTE (1 << 18) /* The MTE regset consists of a single 64-bit register. */ -#define AARCH64_LINUX_SIZEOF_MTE 8 +#define AARCH64_LINUX_SIZEOF_MTE_REGSET 8 /* Memory tagging definitions. */ -#ifndef SEGV_MTEAERR -# define SEGV_MTEAERR 8 -# define SEGV_MTESERR 9 -#endif - -/* Memory tag types for AArch64. */ -enum class aarch64_memtag_type -{ - /* MTE logical tag contained in pointers. */ - mte_logical = 0, - /* MTE allocation tag stored in memory tag granules. */ - mte_allocation -}; +#define AARCH64_SEGV_MTEAERR 8 +#define AARCH64_SEGV_MTESERR 9 /* Given a TAGS vector containing 1 MTE tag per byte, pack the data as 2 tags per byte and resize the vector. */ diff --git a/gdb/nat/aarch64-mte-linux-ptrace.c b/gdb/nat/aarch64-mte-linux-ptrace.c index 903e11841201..c88b1d4fcd23 100644 --- a/gdb/nat/aarch64-mte-linux-ptrace.c +++ b/gdb/nat/aarch64-mte-linux-ptrace.c @@ -23,7 +23,6 @@ #include "arch/aarch64.h" #include "arch/aarch64-mte.h" -#include "arch/aarch64-mte-linux.h" #include "nat/aarch64-linux.h" #include "nat/aarch64-mte-linux-ptrace.h" diff --git a/gdb/nat/aarch64-mte-linux-ptrace.h b/gdb/nat/aarch64-mte-linux-ptrace.h index d31fa9f3c071..653de33108c8 100644 --- a/gdb/nat/aarch64-mte-linux-ptrace.h +++ b/gdb/nat/aarch64-mte-linux-ptrace.h @@ -20,6 +20,11 @@ #ifndef GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H #define GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H +/* Feature check for Memory Tagging Extension. */ +#ifndef HWCAP2_MTE +#define HWCAP2_MTE (1 << 18) +#endif + /* MTE allocation tag access */ #ifndef PTRACE_PEEKMTETAGS @@ -33,6 +38,15 @@ /* Maximum number of tags to pass at once to the kernel. */ #define AARCH64_MTE_TAGS_MAX_SIZE 4096 +/* Memory tag types for AArch64. */ +enum class aarch64_memtag_type +{ + /* MTE logical tag contained in pointers. */ + mte_logical = 0, + /* MTE allocation tag stored in memory tag granules. */ + mte_allocation +}; + /* Read the allocation tags from memory range [ADDRESS, ADDRESS + LEN) into TAGS. diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index a6439943e855..a00ee1556c80 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -959,7 +959,7 @@ aarch64_adjust_register_sets (const struct aarch64_features &features) break; case NT_ARM_TAGGED_ADDR_CTRL: if (features.mte) - regset->size = AARCH64_LINUX_SIZEOF_MTE; + regset->size = AARCH64_LINUX_SIZEOF_MTE_REGSET; break; case NT_ARM_TLS: if (features.tls > 0)