From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6l+TK8B95V/QTQAAWB0awg (envelope-from ) for ; Fri, 25 Dec 2020 00:50:56 -0500 Received: by simark.ca (Postfix, from userid 112) id A5B2C1F0AA; Fri, 25 Dec 2020 00:50:56 -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 E86461E590 for ; Fri, 25 Dec 2020 00:50:55 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7D0E73858026; Fri, 25 Dec 2020 05:50:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D0E73858026 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1608875455; bh=7sXqTXIEezv9YGXtlQcQoCTk6VxzkMtlSIHAZXpd8Kk=; 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=qF/YHVT6prsVZarVO7ldOeabauFVY51RG9WxRuIopsaKm4OmV5ZhNrCv4/hYXeO3W YBlkzIfZjh9e2w2JpHpKPacoTgi/Vn+xfeB3Y2MlPCYEP+JjZVIC5t/w20rkQBxX3W q7oxVC14d84IepjfKvkReXQuGlwR4CvvyEicA7h0= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id D0FAB3858026 for ; Fri, 25 Dec 2020 05:50:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D0FAB3858026 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 0BP5ol26032243 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Dec 2020 00:50:52 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 0BP5ol26032243 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 5FC841E590; Fri, 25 Dec 2020 00:50:47 -0500 (EST) Subject: Re: [PATCH v3 05/24] GDBserver remote packet support for memory tagging To: Luis Machado , gdb-patches@sourceware.org References: <20201109170435.15766-1-luis.machado@linaro.org> <20201109170435.15766-6-luis.machado@linaro.org> Message-ID: Date: Fri, 25 Dec 2020 00:50:47 -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-6-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 Fri, 25 Dec 2020 05:50:47 +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" > diff --git a/gdbserver/server.cc b/gdbserver/server.cc > index 95db9807a9..7eddd0e01f 100644 > --- a/gdbserver/server.cc > +++ b/gdbserver/server.cc > @@ -547,12 +547,71 @@ handle_btrace_conf_general_set (char *own_buf) > return 1; > } > > +/* Create the qMemTags packet reply given TAGS. */ > + > +static int > +create_fmemtags_reply (char *reply, const gdb::byte_vector &tags) > +{ > + /* It is an error to pass a zero-sized tag vector. */ > + if (tags.size () == 0) > + return 1; If this catches a logic error in GDBserver, this should be an assert. > + > + std::string packet ("m"); > + > + /* Write the tag data. */ > + packet += bin2hex (tags.data (), tags.size ()); > + > + /* Check if the reply is too big for the packet to handle. */ > + if (PBUFSIZ < packet.size ()) > + return 1; > + > + strcpy (reply, packet.c_str ()); > + return 0; > +} > + > +/* Parse the QMemTags request into ADDR, LEN and TAGS. > + > + Return 0 if successful, non-zero otherwise. */ > + > +static int > +parse_smemtags_request (char *request, CORE_ADDR *addr, size_t *len, > + gdb::byte_vector &tags, int *type) > +{ > + if (!startswith (request, "QMemTags:")) > + return 1; That check seems unnecessary, or maybe I'd convert it to an assert. > diff --git a/gdbserver/server.h b/gdbserver/server.h > index 22228050a8..3d4a086e18 100644 > --- a/gdbserver/server.h > +++ b/gdbserver/server.h > @@ -190,6 +190,9 @@ struct client_state > > int current_traceframe = -1; > > + /* If true, memory tagging features are supported. */ > + bool memory_tagging_feature = false; Just a note that as of this patch, this field is unnecessary. If it gets used later, that's fine. > @@ -499,6 +500,19 @@ class process_stratum_target > > /* Return tdesc index for IPA. */ > virtual int get_ipa_tdesc_idx (); > + > + /* Returns true if the target supports memory tagging facilities. */ > + virtual bool supports_memory_tagging (); > + > + /* Return the allocated memory tags of type TYPE associated with > + [ADDRESS, ADDRESS + LEN) in TAGS. */ > + virtual int fetch_memtags (CORE_ADDR address, size_t len, > + gdb::byte_vector &tags, int type); > + > + /* Write the allocation tags of type TYPE contained in TAGS to the > + memory range [ADDRESS, ADDRESS + LEN). */ > + virtual int store_memtags (CORE_ADDR address, size_t len, > + const gdb::byte_vector &tags, int type); I suppose that these should return bool. Simon