From patchwork Tue Apr 16 14:07:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 88541 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 C345F384772F for ; Tue, 16 Apr 2024 14:08:26 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 5A6D43858D39 for ; Tue, 16 Apr 2024 14:07:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5A6D43858D39 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 5A6D43858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::433 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276476; cv=none; b=Gz/B8WRjbs6ZXXTQCdCWvULTG8wKz21caDV3HUMpRIM2kbs8MYOQ9emcr9pJGkeo1GS1RrAYV/+aiImW/IpdLATzh5Yt7elAmDLiGgb7fEGE+6WgJdHtrl4ZEQ2UkRq+H6JHm0SIUN22jwqpzO0LOmnEpTarqlLaIt7YO6ODJn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276476; c=relaxed/simple; bh=zn4DbmTot8VHmhi87qT4JPigPp9gYVtGLVN1Tzseteg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=GWdWRQHSSmLlRYoxol+I5pAb0/jE5Urw9g5IcJyZjkSN2gzqV8pw81gJZj9z/CD4+7gRudfp6XTdPvX84Iz52sNFG5tL3X+YJmBN8e5Tu69okCEwN7tibg9nt6sG+sLi1V0+RbCdyySsgFmQp6cT2LgQs9kbgxldUOMB01xHBZU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6eff2be3b33so2173416b3a.2 for ; Tue, 16 Apr 2024 07:07:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713276465; x=1713881265; 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=tYCk/P1xjalYBJuMqLUvPVXaT9Bbd2Fw6xG3npnM6gg=; b=mbGmm4iGXeQ8j4pVCaXCuRgO93GJA7IMwhe2Ib/PJ3Tzm+hwhvfRq4UC4+1XE+TE/E 9QryPUmQPubEbBBX9aM2hVDHjJl4YITVZTRCs2NCMBFMWUiSO8/9p0nOuZ6HmQKaeecV Df+yGcEvVZLWEhHpu2gUYzJLrlb4fpBNl9CEd9oaJiQyUxlz4+QBQNDOqu/ajdxWQsAe Ikqvk8iog3Oca/BQ7Dpmebsu3vWaZFMmqlSX4ufSQCzoE1Xu206sekCsq/h/KiY7P5V3 g0YOamRUBwLfGQz/GPwsCQG7t4ren8J2BaUcBuwXkXjw71q+1syXDUpU3uOBf3cF0cm2 Sj4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713276465; x=1713881265; 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=tYCk/P1xjalYBJuMqLUvPVXaT9Bbd2Fw6xG3npnM6gg=; b=hUre2dZKwsZ+qiVpiHNxyRkkeIzaGZsOj/6xNNLhWBk0bwEi6op8ALDRLG/komNtN2 1NGbrJtAHLb79tOclMG5qgfISzVGGCjatPF+GushMEgItqOu/4joLjgK8fO4sYEWpfJz 7s33EtlK7hktsRksQHtq0ZRzYn8CefsRDp+Kso3H96gO5VN6IiD/oc4dtCJdWwmfg9FX 9yhDdJQL9Igbgpz9Bv+xMJUJn2hAclMtScEkFGzY+XILHQy5QsggtRcG6E/k4FGWyGAV vT0IawxZ6Y9YU2FZWC+z4uUhNUEXhbtFwQkgMCEM5G6SUh2V4K4RnKOSbnqL2bAsfyeg p5SQ== X-Gm-Message-State: AOJu0YxJDJSuR+ER2S2MSzjMUs54Tcsk0w24bedsFENwixiZEYdBb+kd ZOvf2GWo2S3JH5yLIxlsYr8v1kB0Srdx41j/tLrLfZ56yg07rgB4ElGYw/TIfxnkfa0GbxdPiLl RNLE= X-Google-Smtp-Source: AGHT+IGdCTsare5CbQpKG6YLt8mrf5yYQY8g971S5gSGnIJNQlOlX4Aq/tEOC2i4dh/wyr8r1KWCcg== X-Received: by 2002:a05:6a20:d487:b0:1a9:c3ac:be77 with SMTP id im7-20020a056a20d48700b001a9c3acbe77mr11997225pzb.1.1713276464760; Tue, 16 Apr 2024 07:07:44 -0700 (PDT) Received: from amd.. ([2804:7f0:b403:ad57:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id o3-20020a63e343000000b005f3d54c0a57sm8937473pgj.49.2024.04.16.07.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:07:44 -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 v4 1/8] gdb: aarch64: Remove MTE address checking from get_memtag Date: Tue, 16 Apr 2024 14:07:21 +0000 Message-Id: <20240416140728.198163-2-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240416140728.198163-1-gustavo.romero@linaro.org> References: <20240416140728.198163-1-gustavo.romero@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.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 This commit removes aarch64_linux_tagged_address_p from aarch64_linux_get_memtag. aarch64_linux_tagged_address_p checks if an address is tagged (MTE) or not. The check is redundant because aarch64_linux_get_memtag is always called from the upper layers (i.e. from printcmd.c via gdbarch hook gdbarch_get_memtag) after either gdbarch_tagged_address_p (that already points to aarch64_linux_tagged_address_p) has been called or after should_validate_memtags (that calls gdbarch_tagged_address_p at the end) has been called, so the address is already checked. Hence: a) in print_command_1, aarch64_linux_get_memtag (via gdbarch_get_memtag hook) is called but only after should_validate_memtags, which calls gdbarch_tagged_address_p; b) in do_examine, aarch64_linux_get_memtag is also called only after gdbarch_tagged_address_p is directly called; c) in memory_tag_check_command, gdbarch_get_memtag is called -- tags matching or not -- after the initial check via direct call to gdbarch_tagged_address_p; d) in memory_tag_print_tag_command, address is checked directly via gdbarch_tagged_address_p before gdbarch_get_memtag is called. Also, because after this change the address checking only happens at the upper layer it now allows the address checking to be specialized easily per target, via a target hook. Signed-off-by: Gustavo Romero Reviewed-by: Thiago Jung Bauermann Approved-By: Luis Machado Tested-By: Luis Machado --- gdb/aarch64-linux-tdep.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index 0b9784f38e4..50055ac3f48 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -2575,10 +2575,6 @@ aarch64_linux_get_memtag (struct gdbarch *gdbarch, struct value *address, tag = aarch64_mte_get_ltag (addr); else { - /* Make sure we are dealing with a tagged address to begin with. */ - if (!aarch64_linux_tagged_address_p (gdbarch, address)) - return nullptr; - /* Remove the top byte. */ addr = gdbarch_remove_non_address_bits (gdbarch, addr); std::optional atag = aarch64_mte_get_atag (addr);