From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id oIVVECOB5l9PZAAAWB0awg (envelope-from ) for ; Fri, 25 Dec 2020 19:17:39 -0500 Received: by simark.ca (Postfix, from userid 112) id 35E7A1F0AA; Fri, 25 Dec 2020 19:17:39 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 222901E965 for ; Fri, 25 Dec 2020 19:17:38 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 62D17385800D; Sat, 26 Dec 2020 00:17:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 62D17385800D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1608941857; bh=X1nA6VC8gGTMHCILc7nFCDoHW5s3dbKaFDm3B0VG7mA=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=DoRBi0nlrnUd0wp/xhoBW1q+UOiXyWjmj5U0GGZ0bnx61tAeda3/t7sknJOU2cT04 aM4AEFTxqZjBCbyOteWreybKRAC72B1elXTBwRaxdzOusJIvCwl3fYdtkrQY75LkmN yYHbZZqNw6RZ7s9YOo/HofE1mLRcfhskbnWV9KT8= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 5BB3B385800D for ; Sat, 26 Dec 2020 00:17:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5BB3B385800D Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 0BQ0HSV5017453 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Dec 2020 19:17:32 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 0BQ0HSV5017453 Received: from [10.0.0.213] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 19EE81E965; Fri, 25 Dec 2020 19:17:28 -0500 (EST) Subject: Re: [PATCH v3 10/24] AArch64: Add MTE register set support for GDB and gdbserver To: Luis Machado , gdb-patches@sourceware.org References: <20201109170435.15766-1-luis.machado@linaro.org> <20201109170435.15766-11-luis.machado@linaro.org> Message-ID: <343202a2-35e3-39a4-e34a-8eb98adad123@polymtl.ca> Date: Fri, 25 Dec 2020 19:17:27 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20201109170435.15766-11-luis.machado@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sat, 26 Dec 2020 00:17:28 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Cc: david.spickett@linaro.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2020-11-09 12:04 p.m., Luis Machado via Gdb-patches wrote: > AArch64 MTE support in the Linux kernel exposes a new register > through ptrace. This patch adds the required code to support it. > > include/ChangeLog: > > YYYY-MM-DD Luis Machado > > * elf/common.h (NT_ARM_TAGGED_ADDR_CTRL): Define. > > gdb/ChangeLog: > > YYYY-MM-DD Luis Machado > > * aarch64-linux-nat.c (fetch_mteregs_from_thread): New function. > (store_mteregs_to_thread): New function. > (aarch64_linux_nat_target::fetch_registers): Update to call > fetch_mteregs_from_thread. > (aarch64_linux_nat_target::store_registers): Update to call > store_mteregs_to_thread. > * aarch64-tdep.c (aarch64_mte_register_names): New struct. > (aarch64_cannot_store_register): Handle MTE registers. > (aarch64_gdbarch_init): Initialize and setup MTE registers. > * aarch64-tdep.h (gdbarch_tdep) : New field. > : New method. > * arch/aarch64-linux.h (AARCH64_LINUX_SIZEOF_MTE): Define. > > gdbserver/ChangeLog: > > YYYY-MM-DD Luis Machado > > * linux-aarch64-low.cc (aarch64_fill_mteregset): New function. > (aarch64_store_mteregset): New function. > (aarch64_regsets): Add MTE register set entry. > (aarch64_sve_regsets): Add MTE register set entry. > --- > gdb/aarch64-linux-nat.c | 70 ++++++++++++++++++++++++++++++++++ > gdb/aarch64-tdep.c | 24 ++++++++++++ > gdb/aarch64-tdep.h | 9 +++++ > gdb/arch/aarch64-mte-linux.h | 3 ++ > gdbserver/linux-aarch64-low.cc | 29 ++++++++++++++ > include/elf/common.h | 3 ++ > 6 files changed, 138 insertions(+) > > diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c > index 1392ec440c..dea34da669 100644 > --- a/gdb/aarch64-linux-nat.c > +++ b/gdb/aarch64-linux-nat.c > @@ -461,6 +461,60 @@ fetch_pauth_masks_from_thread (struct regcache *regcache) > &pauth_regset[1]); > } > > +/* Fill GDB's register array with the MTE register values from > + the current thread. */ > + > +static void > +fetch_mteregs_from_thread (struct regcache *regcache) > +{ > + struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ()); > + int regno = tdep->mte_reg_base; > + > + gdb_assert (regno != -1); > + > + uint64_t tag_ctl = 0; > + struct iovec iovec; > + > + iovec.iov_base = &tag_ctl; > + iovec.iov_len = sizeof (tag_ctl); > + > + int tid = regcache->ptid ().lwp (); Should this use get_ptrace_pid? Same in the store version. > + if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_TAGGED_ADDR_CTRL, > + &iovec) != 0) The indentation is wrong on this last line (and it would all fit on one line). > diff --git a/include/elf/common.h b/include/elf/common.h > index fc672de9f2..334e9e301f 100644 > --- a/include/elf/common.h > +++ b/include/elf/common.h > @@ -660,6 +660,9 @@ > /* note name must be "LINUX". */ > #define NT_ARM_PAC_MASK 0x406 /* AArch pointer authentication code masks */ > /* note name must be "LINUX". */ > +#define NT_ARM_TAGGED_ADDR_CTRL 0x409 /* AArch64 tagged address control > + (prctl()) */ > + /* note name must be "LINUX". */ > #define NT_ARC_V2 0x600 /* ARC HS accumulator/extra registers. */ > /* note name must be "LINUX". */ > #define NT_SIGINFO 0x53494749 /* Fields of siginfo_t. */ What this changed approved by binutils? Otherwise, this LGTM. Simon