From patchwork Wed Apr 17 21:04:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 88626 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F26303847700 for ; Wed, 17 Apr 2024 21:05:36 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id 78ED73858C62 for ; Wed, 17 Apr 2024 21:04:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 78ED73858C62 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 78ED73858C62 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::629 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713387893; cv=none; b=QclWRM1d53Rg7J+bZNAr+tTexAX3vKs3ZWy6Sn8rWsHm7KsXNacynCOlCoeRqPlpgbxrIb7KKPYpxU/V9QZoFfroITr9wbi/NCx/nRGX8IFginctLn+bxNO3juNqCeDl4Bu4Q2mR3ocHXS2Pvt9x31sdiFuo4aYwb+cYeYRbBC4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713387893; c=relaxed/simple; bh=51FHoGiyjhyoZma8QVYzTWzzaqrp0zk2YyY69ZmRoB0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=mM3PuNph01i3MBr9eI8MMlBI/hhyd6zYFqHlAtPA8+MA4jPoXn4h4ykfMYWNw1xOR8n/Zo5cfKLypGvxID/LRJ4xcBCFP2/efZs5ifU/+2jl2tyNsqLkSLymuhLOVI5Y+Zr2xc4QGQYHgbqoQDD792yNWTA0tRTDKkLbL0UroQ0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1e3f6f03594so1631045ad.0 for ; Wed, 17 Apr 2024 14:04:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713387889; x=1713992689; 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=Sp0dm7bx1dH5mUGYuxv6rqp+OwQ7EtFOoTBaubECyL0pJ7SKMwnZIkg5u+I+IMBl/K JF7UwnvgcyJTngOBMvOUKjCM0WEcVi/N/hpt2vevCKw0OKFMsu79x0tZdTZcc4fvPJl5 H8oWcb6uYZ00yfJxEoGXy/v3dIKVrkL0cB0CSSw+JnRqrrm1LKFLe4AeOX1j4gAV6ZLh LRQgxWxrl1aqWQ5ry9hUJ+VklA8lEG03HDo9jXwlM4ABkdfY9GecCRDuVHBuABpqqYdv N242mk81D4037/orYzDr+p8IpK0yg9f7zgn2E3pPg84h/LOOTs8Lb+LOfvZ2GzaT9EF0 0cmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713387889; x=1713992689; 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=gavCiop4W3CCU9K2x1u0UquxoZ04/QwX52CV2njeup8nD3va7+hoOMykLLxSlzeUkJ 7QHtDo3yDdtFyVzr4uRHfEOCISK2GJVBOuWeh6JKQKgbo2eS3o0fBoauZK163xeWW0Yg DTP3+gMZLxecwSVJKuCkKx53OL18SvZ2ZAxjnJnq2EGyr/7gpuFXgm7y/BKy8c56fFu/ PNN5KrSWjI2MyTU5LnvOOS496GaTgK2O4rk6fNe8hn1THKyGQnYDKEmbmTvf/VVX1faw ad3PUrAYymoqZKk0aenEWEnyF014HEN1g+ugoBw1k5ReM1LLbZGT/vxwrDew1+M0VOyF QwJw== X-Gm-Message-State: AOJu0YzHrVvAWzojW8ltK2f34MmhEMvQNkI+I0JDB8/WV6+Y/vaz1cHA RD4os9CYInaZyqhdG5EG4gvTXjpo0wk0PGnTpH9DfNXrvt7d373WxcuGS+9KjHY2HiND4hHAFp3 8 X-Google-Smtp-Source: AGHT+IFPZOkHQTUgZwQE8Citm0DlD3sul+/35et1up4x6tEZ50VHWYc4zzIxXbP4R0TRFR+zrkCbDg== X-Received: by 2002:a17:902:ee45:b0:1e2:7d3b:353c with SMTP id 5-20020a170902ee4500b001e27d3b353cmr729137plo.18.1713387888973; Wed, 17 Apr 2024 14:04:48 -0700 (PDT) Received: from amd.. ([2804:7f0:b403:ad57:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id l9-20020a170903120900b001e3e0aa9776sm80494plh.27.2024.04.17.14.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:04:48 -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 v5 2/8] gdb: aarch64: Move MTE address check out of set_memtag Date: Wed, 17 Apr 2024 21:04:18 +0000 Message-Id: <20240417210424.216374-3-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240417210424.216374-1-gustavo.romero@linaro.org> References: <20240417210424.216374-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+patchwork=sourceware.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"));