From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id uqlsNdUm6l8TSwAAWB0awg (envelope-from ) for ; Mon, 28 Dec 2020 13:41:25 -0500 Received: by simark.ca (Postfix, from userid 112) id CB9951F0AA; Mon, 28 Dec 2020 13:41:25 -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 D5C2B1E590 for ; Mon, 28 Dec 2020 13:41:24 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 53119385141D; Mon, 28 Dec 2020 18:41:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53119385141D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1609180884; bh=k3EE3TxsNOFGGXtNJ13hQfWHLW5dzNnaP7pEIWI9Wmc=; 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=nK0Vf7nJjC7qoQJzdejY1CuJW9DZSsakuMS6j2zSGltjKHiZukfKpqO97sg32l5pQ /Ww0OmVgMYUYoht1wh/QK8xyMrTR5AkXtce//BIaVvA46/Q2l6Z89l5fYcez8eZasg toGRdDmxxdHw1IPoLBZCWMjZ1BtthOlOywbjVirM= Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by sourceware.org (Postfix) with ESMTPS id 6517B385141D for ; Mon, 28 Dec 2020 18:41:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6517B385141D Received: by mail-qt1-x82f.google.com with SMTP id a6so7486919qtw.6 for ; Mon, 28 Dec 2020 10:41:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=k3EE3TxsNOFGGXtNJ13hQfWHLW5dzNnaP7pEIWI9Wmc=; b=ZjoDynbt0vyWCzth32v8rHqldyWUQiewakiwZ96+tuHXB7K5k/WubXire4ONWNWTJ9 pYiSF+EeS5ROwUuUd/+qb0iL+H2AlmTeog7k0VwA2gidE1MzBRk0rxc36/g+Q3fTyJzz V3UjysFJF3K+6YtB5q3TJt1icpRIlOm3Ncs4d52PWtDlz92qva9NGPA6JayWEiIvz+Qn YkDafpLZY8d7TyEVITdr8ns8bXUaIcE1H+VUO+wOLdUnF9ujiNMXt9q4woNUQVkTkY30 mfTXV0jgxSJaxuINSyywKdlTs4+fCs+GEJrH/RTiT/SP7VH/rERZTgYcDiZJ6BW/pioi RrRA== X-Gm-Message-State: AOAM533JQLCjozu2CU3jYnQmyj7v4xiST8bXdZKpJT+86kCRUXvNbpB2 znenFrTlaVzvji3oR3VNRd1lESXx9v65og== X-Google-Smtp-Source: ABdhPJwIYsrox0jy1vo4SskDAjENpGhxOdvobhLjKtM2zAKrRBJ8WivKxwQjZI2YsEo+/kKfsq6+9Q== X-Received: by 2002:aed:2cc5:: with SMTP id g63mr44755645qtd.327.1609180880987; Mon, 28 Dec 2020 10:41:20 -0800 (PST) Received: from ?IPv6:2804:7f0:8284:370e:19e7:527f:e109:2734? ([2804:7f0:8284:370e:19e7:527f:e109:2734]) by smtp.gmail.com with ESMTPSA id p23sm24743969qtu.53.2020.12.28.10.41.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Dec 2020 10:41:20 -0800 (PST) Subject: Re: [PATCH v3 10/24] AArch64: Add MTE register set support for GDB and gdbserver To: Simon Marchi , gdb-patches@sourceware.org References: <20201109170435.15766-1-luis.machado@linaro.org> <20201109170435.15766-11-luis.machado@linaro.org> <343202a2-35e3-39a4-e34a-8eb98adad123@polymtl.ca> Message-ID: <12a78818-49d7-3725-cf92-648dfb6a8831@linaro.org> Date: Mon, 28 Dec 2020 15:41:18 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <343202a2-35e3-39a4-e34a-8eb98adad123@polymtl.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Luis Machado via Gdb-patches Reply-To: Luis Machado Cc: david.spickett@linaro.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 12/25/20 9:17 PM, Simon Marchi wrote: > > > 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. > I wasn't aware of that function. Thanks for the info. >> + 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). > Fixed in both the fetch and store functions to be on the same 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? Not yet. There was some back-and-forth on the name of this register set with the kernel folks. I'll post it to the binutils list after fixing up the current version. > > > Otherwise, this LGTM. > > Simon >