From patchwork Thu Apr 18 20:10:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789869 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp750701wrm; Thu, 18 Apr 2024 13:11:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVCGPmGzH7fmsTopFUclIVHQxidY48tthreCuDFrbQOMsy+GYfQat8lU5vq72YY1mmMOHuCDpkFLhizwBft0rmB X-Google-Smtp-Source: AGHT+IE/ECUtgX0Ju6peWzlBbYuMXlQd77B9Uj45ENiR38S1t79Q+XrvuAtptLxBtQsqkUqnLeqD X-Received: by 2002:ad4:4f8e:0:b0:69b:35c9:fdfb with SMTP id em14-20020ad44f8e000000b0069b35c9fdfbmr93380qvb.44.1713471114271; Thu, 18 Apr 2024 13:11:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713471114; cv=pass; d=google.com; s=arc-20160816; b=FVcBCMcCuAjpDV/4jgh326N51z/9DbUtRia6Z7RUYQlsJDiYqynbr6Tw7/O0DBmm+X 7lQrqH09oOwBHzhXnQR22ZrrwB2KpBGQuXcBaZXvCjwr8mmoOwJxwXTjrn+cO9Tqb0Vb vWmEpRq99xOXGjl3eFRmxobqPY0ZH0uU2tp0u4oRxtBx2httvN9vMCSKdCOLciXUKnc8 XAZtVLsrGYr7NAfFXiMokbyxySqxsiIQdSAIUBMU3rOGW8KaUOrMH2Owa2g62FxHhBdF HKS8Oi7Vav/IB927aA27eUWnXaoGAJFcuV4yvCbYotg0lM6EaLHO8VFxIQ1P8m0FCt7i iikg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=AB1cfcL6bYdgBQzOX0q+LeLFEerR63qRjSyZ1Gu8kI0=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=GRJ1Eb+8ZaY3+l9fialmm/dnZ8Z6eoZcW8jXJ4UXo8PWRJbMuNoUs3yKztSuGSdOEh Nd0GbuM1jdVHFN7XjAxEd27eOoe+FbSkV5rMXreWlhVkeh7po8N3p7UVGlz8M4DPcuSE 7VYiFbRnJ/VwFWiYc28PLyLoUozsPX/LeHIp47qDiu5YQDtl5cUrn42ox16vq98iKyZ5 QGSYepNsiRKZtxT/sWkcnX8hVvormBUubnBABAn/lfwHM1iDET8qt58sFqNOqDhYLKg2 SvpPVHvIEcDtjwdZUoG5ypwzrf3pUNuDVmxhOxHWfCv2e93wzF/A3GU+Up128RD4kpMV +Ikg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="klui/rrN"; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gdb-patches-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id jz9-20020a0562140e6900b0069fb60cd5d4si2293503qvb.443.2024.04.18.13.11.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:11:54 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="klui/rrN"; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gdb-patches-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E50BE3858C39 for ; Thu, 18 Apr 2024 20:11:53 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id EB1A23858408 for ; Thu, 18 Apr 2024 20:10:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EB1A23858408 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 EB1A23858408 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::630 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471062; cv=none; b=emQvf4V3duE+5AMZyLZBWtS8gHnH6faufscxVakIFopoo5uWo8wCHmj/HqeShOpea73CoCqRbbfkj/pTwIY7AhX7Ms73H7T2m4Z6bEUPSC78J/EAaOIdItS8d0BJOYRksu6gvvU2YqGcyi0j6PuI5dgfC778C19qS3YET4tvsDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471062; c=relaxed/simple; bh=51FHoGiyjhyoZma8QVYzTWzzaqrp0zk2YyY69ZmRoB0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=IsE7OqWjtvF0SlDecAabLt1XT5CMHcusEQXG6BcOvvBvTz0frNGaWBSl2Jo6rppn6DgZlRnJNdaJv1V8iptFH6aE0ngBCJDDVOtPX2qM5OQYc3O5gMZfsk6TA1na6T2vsHsa5UKMrYG3V5FwCKHDiiMNzW4+rzMmNiLUhmZkGjw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1e2bbc2048eso11416535ad.3 for ; Thu, 18 Apr 2024 13:10:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713471058; x=1714075858; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AB1cfcL6bYdgBQzOX0q+LeLFEerR63qRjSyZ1Gu8kI0=; b=klui/rrNvPwpZOn0HC9XFokSZtq1BgO+yzPKJUj/Co6qfce3LY+oPx1yHuK8NbsG5g ey5Bu6u//bKoCt9L4Fo4X0ymhLj+hxfvgkDygP7ZNtwUnRPDyQJ53aivqZBrRmoaH8BI sjx3kdrkamI7k2XTNErgR/5hqEW4o/1HzYSuFo1ub4g6iF7cPYvXn9N7+nWUACBn0G6u Ao8ACqig7/L1uijWe3n3QNDzih0n6kPKKz9Hd5rNfMSHvoaPI3BrQ2GimEE266faZC8w v8SKaH6UGFCa0d6mdgJM6qGtBOXvvNFmlhgD/V2WuGtF8ky7kUen+TevpJbdA9YgcnSc DW9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713471058; x=1714075858; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AB1cfcL6bYdgBQzOX0q+LeLFEerR63qRjSyZ1Gu8kI0=; b=Cm0xEBVpmlIZnkSSwSomm410qall0wqh9nJC2zBFjSsn9H0ILNYrKkYSF5fCLc78b9 7LZCnQ+VtNioe1xV3xQP7Bf7NBk3lHxmnhhTO46I4MRtJI3y99qu82mCBdMmxrry9orb lKTVDngpoCwlzgc3NfliyER6x7yMpLCleL6p/sQJ/MgJWU2FX0AVTnR4ZAYZ+w7JpFv3 /6slXznW8fmRoLAUysYHknzimSjCtc7O/vnah4IgBfnCAMrGzYzVTBTE3rvXGzgInS3Q 6nwNVGKKLC2wa2LEgM6/Uoc6SW5AveJxqAWf6IfA0nKZmGug3I1ebIVCtLlewMqqNCst J5sA== X-Gm-Message-State: AOJu0Yy3oxIbO54YzsgoVSYtg/xjmviR3W/9qdFXtsRhuknaFEu8rsNv wIw4Kg3ebuFZbebu8TV48yWepsHZj7sNdDB6/YOCMnfiOM0WDPrs7Lu8KC4FTblDwWgfO/mTdI4 F X-Received: by 2002:a17:902:e752:b0:1e2:6d57:c1bb with SMTP id p18-20020a170902e75200b001e26d57c1bbmr217433plf.21.1713471058243; Thu, 18 Apr 2024 13:10:58 -0700 (PDT) Received: from amd.. ([2804:7f0:b403:ad57:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id n18-20020a170903111200b001e0b5eee802sm1925524plh.123.2024.04.18.13.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:10:57 -0700 (PDT) From: Gustavo Romero To: gdb-patches@sourceware.org Cc: luis.machado@arm.com, thiago.bauermann@linaro.org, eliz@gnu.org, tom@tromey.com, gustavo.romero@linaro.org Subject: [PATCH v6 2/8] gdb: aarch64: Move MTE address check out of set_memtag Date: Thu, 18 Apr 2024 20:10:33 +0000 Message-Id: <20240418201039.236867-3-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240418201039.236867-1-gustavo.romero@linaro.org> References: <20240418201039.236867-1-gustavo.romero@linaro.org> MIME-Version: 1.0 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, 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+patch=linaro.org@sourceware.org Remove check in parse_set_allocation_tag_input as it is redundant: currently the check happens at the end of parse_set_allocation_tag_input and also in set_memtag (called after parse_set_allocation_tag_input). After it, 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 on MTE address checks. Signed-off-by: Gustavo Romero Approved-By: Luis Machado --- gdb/aarch64-linux-tdep.c | 4 ---- gdb/printcmd.c | 10 +++++----- 2 files changed, 5 insertions(+), 9 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..5635f605314 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -3101,11 +3101,6 @@ parse_set_allocation_tag_input (const char *args, struct value **val, error (_("Error parsing tags argument. Tags should be 2 digits per byte.")); tags = hex2bin (tags_string.c_str ()); - - /* 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. */ - if (!gdbarch_tagged_address_p (current_inferior ()->arch (), *val)) - show_addr_not_tagged (value_as_address (*val)); } /* Implement the "memory-tag set-allocation-tag" command. @@ -3127,6 +3122,11 @@ 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)); + if (!gdbarch_set_memtags (current_inferior ()->arch (), val, length, tags, memtag_type::allocation)) gdb_printf (_("Could not update the allocation tag(s).\n"));