From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id zxbzJss5DmZUqyIAWB0awg (envelope-from ) for ; Thu, 04 Apr 2024 01:25:31 -0400 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=bys9e6h3; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 8C1141E0C0; Thu, 4 Apr 2024 01:25:31 -0400 (EDT) Received: from server2.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 ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 712E31E08C for ; Thu, 4 Apr 2024 01:25:29 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EDC373858C50 for ; Thu, 4 Apr 2024 05:25:28 +0000 (GMT) Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by sourceware.org (Postfix) with ESMTPS id 248283858D34 for ; Thu, 4 Apr 2024 05:25:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 248283858D34 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 248283858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::22c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712208309; cv=none; b=ZWA8Uuy4dCdOmSIo8Qwhv+mq8sIHjI4i4jiziLPYZOjpjgb6jh2uKL8mztNdTG0zv6YXYNf2fRfIUZcIZ6Gb7yBqJmXJ3BSovgCjrUWNM5DiZVbv1HJqzHXfiMCBBNrZJZt4IYQY069awuUwjjF+nz79zgzeLCf1qcJPOVwBmZg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712208309; c=relaxed/simple; bh=hFPZgg776dFmzCWWhzUKrOJcb3udrZoEeKvrwyUISUc=; h=DKIM-Signature:Subject:To:From:Message-ID:Date:MIME-Version; b=YUL78JMStlZ3PPIDhES3TpKWeWF4+zlahogprMkuLbM5FOXSsDZmNzSSrsB4yYDG029S+vmkkVyVIaTvlbGzcKM8J/n1QmIFqMiiqHE98J6xhY/wit8VZ9hFzRRxGbQzgSNapc0ppRTf6N8GfY4U/yGYAew9yZx7bLoLej+h9iw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-3c3d7e7402dso428149b6e.1 for ; Wed, 03 Apr 2024 22:25:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712208306; x=1712813106; darn=sourceware.org; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject:from:to:cc :subject:date:message-id:reply-to; bh=f4kFOqIxba407QJGvKZPpYNUGhDQ3pooqkojQjYBPsk=; b=bys9e6h3aSpQsEdcLgEivS0WME3tZ7c4t11DcRxlbV0OcQH3zn63dA6VqKCNa/Gi5/ QpsdSOuXnaEZwZRk9V+e6wc0f7MkCkEnvAp2FBPtGZUSxar1kJcO3CE9GUdnJ3N/Kv+a RBeeraNMDl6smnx7n+IaJ3GbIooo2pkBDSzMF0exo16ahBOqogPv1/P0ik73JlhL0cCv j9yhBrnIyDvNRbxju8G6+1UOdoD3e5YCfFqcgMUOPQYekqYsXvGl/fV7lO+FrYar/IIr 2Dd5rMU1mMMGOctzlELx/GPJfiQgHm6X3SRDxehbylWG63orIjdihLerUlUv0wSPtOD6 GVzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712208306; x=1712813106; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=f4kFOqIxba407QJGvKZPpYNUGhDQ3pooqkojQjYBPsk=; b=JcTwcIVP9ei8U8MJHR5e5eEOAfiemypfMi+r1scrj/N1NO+cI6v5NfjijSLjNzD7k8 y8qHhnwD/PbneNvHAa53gEJ4arb9vdnvHgDcLNDw8VieMZGe4GLmIpW8m8D54DHcaLA8 CfKXzB0QSB7Ssp2yZdKT0WZPc82+vO3Zt2SfAOgsaO6KeIA9pCpPUCYsq9E1z5Opjy4l ttzHPnCIoO1I1uilMaai2luVO1Ks+to+6Om7R6wO2op0FH91COutBKRhY+8wsPpAPFH+ AEwHGqiSGAavQFxLzJxeyg5wugWQGE4wb4b5jxR6rK1hAC8wgQ1bMLF5ep/MW4IR6iGb WFBg== X-Gm-Message-State: AOJu0Yy3gi0GqCzJ9PYnwgfPsDcKIAXCTSgnCwiYFPq3/x0WyluS5pnE lAwrQmayqtzznq469zvmAbdoruRJ4Qm+O1+WZ4z/MvOIBdujmulEpAVGl+m3bhgaxQtaI/qqqmZ Y X-Google-Smtp-Source: AGHT+IF+FFe43Nzf6mdbg4/zKCRg5YrpxF4aCbXeqRMkFvjhZp9hhYPWHQDaav8Acv2lrURwgQwHmA== X-Received: by 2002:a05:6808:1308:b0:3c3:d75c:c900 with SMTP id y8-20020a056808130800b003c3d75cc900mr1537092oiv.0.1712208306392; Wed, 03 Apr 2024 22:25:06 -0700 (PDT) Received: from ?IPv6:2804:7f0:b402:d0dc:4f31:e30e:9a7a:2717? ([2804:7f0:b402:d0dc:4f31:e30e:9a7a:2717]) by smtp.gmail.com with ESMTPSA id p19-20020aa78613000000b006e6c10fc87fsm12729330pfn.46.2024.04.03.22.25.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Apr 2024 22:25:05 -0700 (PDT) Subject: Re: [PATCH v2 2/4] gdb: aarch64: Move MTE address check out of set_memtag To: Thiago Jung Bauermann Cc: gdb-patches@sourceware.org, luis.machado@arm.com References: <20240328224850.2785280-1-gustavo.romero@linaro.org> <20240328224850.2785280-3-gustavo.romero@linaro.org> <87msqg8s1b.fsf@linaro.org> From: Gustavo Romero Message-ID: <322b8080-d9f4-7741-4358-ca6f0de4b7f5@linaro.org> Date: Thu, 4 Apr 2024 02:25:02 -0300 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: <87msqg8s1b.fsf@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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 On 3/29/24 9:47 PM, Thiago Jung Bauermann wrote: > Gustavo Romero writes: > >> Move MTE address check out of set_memtag and add this check to the >> upper layer, before set_memtag is called. This is a preparation for >> using a target hook instead of a gdbarch hook MTE address checks. > > gdbarch_set_memtags is also called from > memory_tag_with_logical_tag_command. Shouldn't the same check be added > there? In aarch64_linux_set_memtags, the memory check is inside the else {}, which is only executed when tag_type == memtag_type::allocation, but not in the if {}, which is executed when memtag_type::logical. Because memory_tag_with_logical_tag_command always calls set_memtags with the argument for tag_type param == memtag_type::logical there is no need to check the address. In other words, memory_tag_with_logical_tag_command is about logical tags only, so it's a local operation that does not touch any memory in the target, it just changes a local pointer, so it's ok to change the pointer, being it tagged or not, hence not memory checks are needed. These comments try to clarify a bit it: In memory_tag_with_logical_tag_command: /* Setting the logical tag is just a local operation that does not touch any memory from the target. Given an input value, we modify the value to include the appropriate tag. <-- In memory_tag_print_tag_command: /* If the address is not in a region memory mapped with a memory tagging flag, it is no use trying to access/manipulate its allocation tag. It is OK to manipulate the logical tag though. */ <-- >> >> Signed-off-by: Gustavo Romero >> --- >> gdb/aarch64-linux-tdep.c | 4 ---- >> gdb/printcmd.c | 6 ++++++ >> 2 files changed, 6 insertions(+), 4 deletions(-) >> >> diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c >> index 50055ac3f48..8e6e63d4dcb 100644 >> --- a/gdb/aarch64-linux-tdep.c >> +++ b/gdb/aarch64-linux-tdep.c >> @@ -2525,10 +2525,6 @@ aarch64_linux_set_memtags (struct gdbarch *gdbarch, struct value *address, >> /* Remove the top byte. */ >> addr = gdbarch_remove_non_address_bits (gdbarch, addr); >> >> - /* Make sure we are dealing with a tagged address to begin with. */ >> - if (!aarch64_linux_tagged_address_p (gdbarch, address)) >> - return false; >> - >> /* With G being the number of tag granules and N the number of tags >> passed in, we can have the following cases: >> >> diff --git a/gdb/printcmd.c b/gdb/printcmd.c >> index cb0d32aa4bc..ae4d640ccf2 100644 >> --- a/gdb/printcmd.c >> +++ b/gdb/printcmd.c >> @@ -3127,6 +3127,12 @@ memory_tag_set_allocation_tag_command (const char *args, int from_tty) >> /* Parse the input. */ >> parse_set_allocation_tag_input (args, &val, &length, tags); >> >> + /* If the address is not in a region memory mapped with a memory tagging >> + flag, it is no use trying to manipulate its allocation tag. */ >> + if (!gdbarch_tagged_address_p (current_inferior ()->arch (), val)) { >> + show_addr_not_tagged (value_as_address(val)); >> + } > > GNU style doesn't use curly braces in if blocks with only one statement. Fixed in v3. Cheers, Gustavo