From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id lPv4MeQZ6l80SQAAWB0awg (envelope-from ) for ; Mon, 28 Dec 2020 12:46:12 -0500 Received: by simark.ca (Postfix, from userid 112) id BF2941F0AA; Mon, 28 Dec 2020 12:46:12 -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 CDB811E590 for ; Mon, 28 Dec 2020 12:46:11 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0EB993851C1F; Mon, 28 Dec 2020 17:46:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0EB993851C1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1609177571; bh=cBDrvpfL1sP+iHQi4Vn9MWhIFNFszBbTswSwXm/fPxo=; 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=cBUR9M9VR/9BqyJx1PV5Ret1BsKVu4PKI3g7WkfRijKl74GfibdK9TyLUzP2oDAWL 0+NhOl0Fy38mwsOaCyckYaDHqVRaKTij7iZTyKKMMAyG6YhTI4T9uSQhyBgvmwU2Zr Cl2KNvwLyvfIBqRKS3GF3eJZ9+3FxhSaAv5dI3d4= Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by sourceware.org (Postfix) with ESMTPS id 6D1073858010 for ; Mon, 28 Dec 2020 17:46:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6D1073858010 Received: by mail-qk1-x734.google.com with SMTP id 143so9388767qke.10 for ; Mon, 28 Dec 2020 09:46:08 -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=cBDrvpfL1sP+iHQi4Vn9MWhIFNFszBbTswSwXm/fPxo=; b=Y4eNJgCOy/73EWxt2sUvHEJcf0lASP7PE2pVws40BWVqzzLzT8WGEdFwt2l0BRjdL4 Em/SKhZVTV5w7kkCFjNDJ+/fZQpL3190FIhFMfC2ulyLmaopRUnycdkye133VzKX+b8j YeLIGfs43x3PoELLKCyAOroXk9m0+vZmHbHEL9eqig+jl3oUIklcRjlkpkKzimNo8hDx NV7XpHdRj9RUMSrReB+K+O2gQ8c+Gj25fS35fhiFe/X/DeguVRKKbpSnPOgTc9j/KdTc bZ0DNOLZymdWPEifHj2mkilRrWyA8Im7nJV2p3wHEJCjB2ENH4YnpvqgWO92H6s7LDwQ vK/g== X-Gm-Message-State: AOAM5317U0upwjSU1cksz5CBCAAeLdR+JacFLBpTMHeDs3eHFxGmPdlu Qwxn8/cWgOOGVPef+Gf/HmKBhg== X-Google-Smtp-Source: ABdhPJwjtLG57ZMiMBcA4fb9P4fxrvUawaycV+ZKDgQnHfoe51iwgiyv9FZDE7c6/dqGIgpdQ4phxQ== X-Received: by 2002:a37:a80a:: with SMTP id r10mr45077575qke.467.1609177567997; Mon, 28 Dec 2020 09:46:07 -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 q73sm24145838qke.16.2020.12.28.09.46.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Dec 2020 09:46:07 -0800 (PST) Subject: Re: [PATCH v3 05/24] GDBserver remote packet support for memory tagging To: Simon Marchi , gdb-patches@sourceware.org References: <20201109170435.15766-1-luis.machado@linaro.org> <20201109170435.15766-6-luis.machado@linaro.org> Message-ID: Date: Mon, 28 Dec 2020 14:46:04 -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: 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 2:50 AM, Simon Marchi wrote: >> 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. > That makes sense. Fixed with an assertion. >> + >> + 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. > I've converted both occurrences of this to an assertion, just to be safe. >> 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. > Right. The way the series was put together, each part builds on top of the previous one. So this will be used in later patches. >> @@ -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 > Yes. Updated to match what was done for the GDB changes. I also updated the documentation for functions and the naming to spell it completely.