From patchwork Thu Apr 18 20:10:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789867 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp750571wrm; Thu, 18 Apr 2024 13:11:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW0S8l3IklaUVyD5DckkJU5mulA4mjkI8l1TMyJ/t4uV8CszCn646dy+RnF5BJ+dOWNBd4tkpUs3I4QKcFtZAHB X-Google-Smtp-Source: AGHT+IEVMvSCA9MIpnsO/Vx/Cq9y4OtukMzzzL11z51BRkw/SYb2L5kIcbCSc4lkWwUdGDRPTaYy X-Received: by 2002:a9d:6288:0:b0:6eb:7ff8:5270 with SMTP id x8-20020a9d6288000000b006eb7ff85270mr60915otk.18.1713471095812; Thu, 18 Apr 2024 13:11:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713471095; cv=pass; d=google.com; s=arc-20160816; b=rrhxalPs1Vv/oEFqagYbGFyNi5cz3nnrgiR/ZbF2VQqSRy90/AIMP6c3ZXlvj43qzp sfXyQ3Ol1wf3G8l96supxdA1BDiB0v2auFnlYgDerDoRMsI9zBgXwf5knEuPFRp4vqof CPYyb6tLsrJVoEHpyNZ4OJTQlk/Ed6sCC+Rq30SYgQFLIPee9VZIv45tNmWOTIbEb+wq 4+ek2b3Lwjs7LxMtc34uaB4EFB/mOpO+elbhudH+5yBV2YOe0lJccw6VZAp/27ASSDnZ 3iwEHiN9zS6JW33NY4FkwuoyLEBD+jtnv24/z5j7Cyvko2KaZQlLqs8AE1bz7qgKwn6w 7frQ== 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=tYCk/P1xjalYBJuMqLUvPVXaT9Bbd2Fw6xG3npnM6gg=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=iwOEOCZnC2okBqdlu5mxEFrPhJLmto0OOWd3OLViNlee+14/KU83u+e49fIbE7tO5E JNNhmAvWwC0ISx9QeIpJoIaEKTCPDIMDysqU9+u8idzDQBBXFvyzVhTiM5t56qCh4ABK G81118u/4Eq39Znq6AWfCYyDA0sNi0ZpXbAzaQl7vCBON0rrsLO+X9GcgEN7085/lje7 oW8muR/Du8ZbobLSCOBVt/nwHXFKxaBBDZIUJvlAFlIJz9BrWlyfHvCouj1+KSeFPDJK 2Ls+FD8AhvYvZbgQBcUZ0I/n9zJ+3HnA9B9NLd0HvkpWvSsHLEppXOrqIOcBYKrqlzwD wtQw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SBez6f7J; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id pi4-20020a05620a378400b0078bcbec867esi2115141qkn.597.2024.04.18.13.11.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:11:35 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SBez6f7J; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 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 655CF3858C35 for ; Thu, 18 Apr 2024 20:11:35 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id 115153858D3C for ; Thu, 18 Apr 2024 20:10:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 115153858D3C 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 115153858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471061; cv=none; b=jkw90a7h4eltISzwABjFdHMkUNLtAfqwcLLBTOUpj9iocxkmN/fCa2Fofzf5ZhF7DnqovQWgMwQRftIMA/gqnUaVAhV3baffvvAZRUDaP1uBu7VQ75cmVpVVhMRQwuV8K3SajaA3mG31TY93kPzIaOAIYVi9t1vYcxo9Oh89NvI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471061; c=relaxed/simple; bh=zn4DbmTot8VHmhi87qT4JPigPp9gYVtGLVN1Tzseteg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=x68cJ9mXBMeaR33HHLYNAF3PLJmZOtPvRY8lflrnNBfpRdVvycoAGtGV2aWZx4h9xAABoMYPHIt3dvrYcw+M/hP37zNB8o+P9ctruD+/SLO40E4JUumlIpmSFi398SkazSIo9yKN+6tGY3YMVAbAO5/c/v1P0HJSpF9N7VtnNdk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1e3f6f03594so11065825ad.0 for ; Thu, 18 Apr 2024 13:10:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713471055; x=1714075855; 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=SBez6f7Jhqj0Jz5dyGKXaZUoWAX7O8SeM0MAEjgvyASnGtdMZrUL1y02toyHOVWudB t5TbZVPFuQ62b2dn2cnxW6D8dYrbTFF3qQksD2cNu5MDmcUVNId1GHa+T6rROdjL8lvH Ly/5jVOp0cMkzN3uATkOponSODIMqMml9MFy5GKQyLuif3bFcg4ihxWwkj8lZ0VWNdVT 1kQhvZneSed3gpYswt2SepCfWn3LHfovSJwMg1sZe8WtiPxLA8v5QBcO9JPl28MdWq+R i1NLPM2Fb2gk7v1Ny7m4lcHxnpQ+7lb9awK5vBO4GkU5poijNa+ZOb4+ZZ62f4gRwshV aB5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713471055; x=1714075855; 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=AITMxVEeZZf6vRC5s4TT33Z/XyRUfZ+6qWHDefGb8Tj4vZTvsXySXZTz+TPWTuIC+4 mLVewQNFxauB7byWfSpaJc7pCtH3tMIOy0vLIwU+0MMrjEBEnghs2nlEHaTmr4lsn8q1 WYkJey02pDSUoFAv36MdK5cZyRfrg947B0rAPKh3zVc/9C9jNNfzOt91a7Ojzf2yKYgK zf+wVjySL6VfGKzdYBlbLLTsMhZyOu9nC7F5PL8lIw1ejmI5BPGJtitnuf1MB7az1frT fULCAfEOFzUmLsnLMriDhsVZY+LNzdqh1DdP0RCNa1tD9s5sAvYLlwejAEk/ZWD6kFCh vpuw== X-Gm-Message-State: AOJu0Yy6kM7TBgfeBXN8Muz4TjjH/ZUPGLQt8LzmMJzqyFjPCUrpc6Qn U/OP1JC3PRDn6AFE6l5LbUcebranvUb7FjDpvVMnU8JVJiihNqEFnvx/msEtxXlBF/dlkjaE4ax P X-Received: by 2002:a17:902:da87:b0:1e4:6243:8543 with SMTP id j7-20020a170902da8700b001e462438543mr213798plx.5.1713471055453; Thu, 18 Apr 2024 13:10:55 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:10:54 -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 1/8] gdb: aarch64: Remove MTE address checking from get_memtag Date: Thu, 18 Apr 2024 20:10:32 +0000 Message-Id: <20240418201039.236867-2-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 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); 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")); From patchwork Thu Apr 18 20:10:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789871 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp750821wrm; Thu, 18 Apr 2024 13:12:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXhbEjN5eq6GtxDA2QxI9KGI2wKycEeJ4ibIPs5217Y6LlsamzhNExQxA36oqBkLp7EwYCTW/LUMNYH7YoaKEUe X-Google-Smtp-Source: AGHT+IHCttSJwlHU2+ZbhcCa4/t+0EgBi2Y8vWvTwBMxHllIKxCNBmbAWk9J2+cdy2xWcgcDYGkm X-Received: by 2002:ac8:5708:0:b0:434:5e80:6e46 with SMTP id 8-20020ac85708000000b004345e806e46mr112976qtw.55.1713471129282; Thu, 18 Apr 2024 13:12:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713471129; cv=pass; d=google.com; s=arc-20160816; b=DcwrDjV3ktJmzUw8P2muZ6HkihWlLBPHpm6ToAN+Zguy+mKYpmXG9tFVG+ryBDitXx 4HXtJ8WuuLdKaFj+7A5OIBrdbH+SYaDTkk12jScbgOsyuMT8x3oQOsOBu15aguA2EI2n 3cfRIAfgeKPGPpwFwAZQdwyJrbnQwIwPjbFdcVHUZ5DT2jONV/E00UfPtzsIw4p2uIZ4 ctDixOA8U1B59Y6ttJWaukCPiUJ7x/6lzJfPh8vf3lmd7QDM9c8RWffmjeJKBJ3OcPAF +vbFrJEifFV4OaPLA0u7l1M0DcQ74zhRCLeBM7IuD55j7r/OD83LQsoW1n4F0iHiYpJh tboQ== 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=k4t/OkSdqXOFOVdbmZG+QDE0aaiWd592cOChHpmR15U=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=mWoj5wEihuIPbDeTNQYClpm2j0gq9GScAmsmu0UA8g/c00mQYxNwCnQJBYEX+2syrk NMRLtjLFUHFzozlhO5oXgdmRJeTLAieo72Tb5bqQ6Qx8Hr5K40IenUjdHFLNP72DPLC8 YAe9b0AAyUQ8ZjyLkmUXKhieNAxJfMgZGRGd0IeoOwCpXz+0xeFVXe1+t+/m7RXCH8oT atOme9N1bqtgoahcobmf+2zaCjoLai9kyhSVd+2TAQY+z33HcxGvXM+yE6jPFLFrZhYi qWtz8NDDlpYgSH6dY3rsBnhyMvCcWLLX6a7/j/7mIfFP8skI8L5k5F1a6BV6/RARkDba VHWQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mEdzXJOu; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id y8-20020ac85f48000000b0043153299a15si2215752qta.695.2024.04.18.13.12.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:12:09 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mEdzXJOu; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 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 E9DB4384AB7D for ; Thu, 18 Apr 2024 20:12:08 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id B7FCF384AB4D for ; Thu, 18 Apr 2024 20:11:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B7FCF384AB4D 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 B7FCF384AB4D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::632 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471066; cv=none; b=m6PRqMkN82JaTV3j8M4B9X8FIo9/TuhSSw9WPV5ukc/Tmv0UGD3/g+nw/BdiTqf98dzJe1S8CQlAYRiPgVIMZ6E9/O8RUVyqjzK1mnARorSt+CuDhN2ZudYhDvT/5fEA3aWJDmB0/G5WMktbzJ14/N9dTsjnmowb7dHmYx+MALM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471066; c=relaxed/simple; bh=WxhGoGvDUNyHMS4tOjdoth41+fxv5hm536NHqm7b6zY=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=HobDDOpRomJ9wTyErMLoz9lRgA9n+8cou2Wr16vyeyaBjF1kFP6GBJuwZ1k43daYLw5N/pukfV63pTj1edTJjpzQTs85cHrIJ6P3sprHlDDqKVSNBA0OO8/8J2Jq3UM6Mt7uEy2LbZFrWC30ugL2pLCDQUxaVmGshAdqwWU9zs0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1e651a9f3ffso8745425ad.1 for ; Thu, 18 Apr 2024 13:11:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713471061; x=1714075861; 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=k4t/OkSdqXOFOVdbmZG+QDE0aaiWd592cOChHpmR15U=; b=mEdzXJOunFWbDcEMuYPeyp5lkm/bjmeTUalLBGJP8Yq1xngt7ToWKo/rgEfRS9grdv UC2l7oELGf3bMW7u8KM0125hFDL50DvO4R6kIBDfjsuvW5tT0XDfbbnvSlW34ERu6wSV RMEekvQR3qmfM4kGVq6ryMBBFsjsvGpnh4ALi/rsu56V+EwiUfnlHrWTfOjPhtJGAv25 +kPevrwn2cuRZiJt8pb82BT0BpU7BZjPDkshNwZG7ctKFGzOqnQ1SDr6CtcM5REayJbQ kJYZYlAtRk0hcgZQUggKSJPW1vlumjpE2WHXcAtKtbm4usdITErQiRSlJaDks1rgFzek 3OAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713471061; x=1714075861; 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=k4t/OkSdqXOFOVdbmZG+QDE0aaiWd592cOChHpmR15U=; b=b24GlQQp/Mddi5qaTasP9MUacbgZIGyCGzYEwuSymxwO3aaAyvz/tzHip829f229YJ WsNnsZPJuUYOjDkKSfCQ5il/rtr2vfaZQ5BKldjZ0jAN/WZKiMhm1knlsIqWO4gxfpLl A5brUTpveJIEeQZkxT2/cgNjSBON+INciUg8whDoYm5j85LvlY1dzj8dg9SF0jfWihan 9IvJyCSzOT5FKY0BtNgNZGQYz0P6uiBWo3hPBFQJuABrhjDe0XRBh7szHr/FFfLtRl1S mkKsbf47cnd2R5lJQfnfynSWUTOv7ETmmU0ohOGKlmjKmOw+wTMItxc7e9ggXPaktGmL 6Nqg== X-Gm-Message-State: AOJu0YzgxfqJNm4WaPMKchxrlq7iNsG2CBzjSRExSZ2lLc15+hoio7Pe xsvhvg2awwwaQpOduCcwsdkHqx9807BwErsh1tHZbO5ld4F2vIuqs4bk5J0txQrEvYnniqgpZbY I X-Received: by 2002:a17:902:d386:b0:1e3:f012:568d with SMTP id e6-20020a170902d38600b001e3f012568dmr146824pld.15.1713471061205; Thu, 18 Apr 2024 13:11:01 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:11:00 -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 3/8] gdb: aarch64: Remove MTE address checking from memtag_matches_p Date: Thu, 18 Apr 2024 20:10:34 +0000 Message-Id: <20240418201039.236867-4-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.1 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 This commit removes aarch64_linux_tagged_address_p from aarch64_linux_memtag_matches_p. aarch64_linux_tagged_address_p checks if an address is tagged (MTE) or not. The check is redundant because aarch64_linux_memtag_matches_p is always called from the upper layers (i.e. from printcmd.c via gdbarch hook gdbarch_memtag_matches_p) 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, gdbarch_memtag_matches_p is called only after should_validate_memtags is called, which checks the address at its end; b) in memory_tag_check_command, gdbarch_memtag_matches_p is called only after gdbarch_tagged_address_p is called directly. 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 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 8e6e63d4dcb..fc60e602748 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -2476,10 +2476,6 @@ aarch64_linux_memtag_matches_p (struct gdbarch *gdbarch, { gdb_assert (address != nullptr); - /* Make sure we are dealing with a tagged address to begin with. */ - if (!aarch64_linux_tagged_address_p (gdbarch, address)) - return true; - CORE_ADDR addr = value_as_address (address); /* Fetch the allocation tag for ADDRESS. */ From patchwork Thu Apr 18 20:10:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789872 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp750836wrm; Thu, 18 Apr 2024 13:12:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW7Mt3ZxWyTL+9N5aIl9G6E3nwD2lHPOFJZkuZASaOQlOSMBPlcuD1pYRy3vBhcuhTvIsVkiG3gPvEMNq0WoSj7 X-Google-Smtp-Source: AGHT+IGRBugy9hhZZgN8I9vtukc2Gw6FtWdckKV1uviJiK+loRZlfBmuWEgblzufUa8M/QIKlpPb X-Received: by 2002:ac8:5915:0:b0:434:8f61:4bb9 with SMTP id 21-20020ac85915000000b004348f614bb9mr133139qty.58.1713471132383; Thu, 18 Apr 2024 13:12:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713471132; cv=pass; d=google.com; s=arc-20160816; b=zTgm1cm4+JCPT0DEAIhTEGNvjfM4s7NDS9kai/xiwyW6dfPsrbTohuTiPykM/W7eq1 VXp879a8Zsox8PLhp8TJPfljLBfV2g1uJt0MNlUEYakly3VY70IxpOcmONNTpcoYvicv IYVg8CBcHUa5qjhqk6SsUKAuJfL6asy0+M3Kmy+ibm8enlDfWSMGZQ+HcISV1ry9Vanz 4hqvD6eMwTelnFabigAQGu6SAkamdtEG+o5bgp1VzCtdG6vN53rUmYg2Xuod66p+dJ66 BAP4z0nobI5XNloJDyLr+ce4hO5laXkToRnFTQ3M+aC7lksfYmEieQ3WzlIu/58Srpt6 ubvw== 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=+Udz0sOQRKXAm5kiKFSTNh5JUUjk+Jni+c5SH40tgmE=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=dGWvgMjosR34/vTdIVDD3JDstuSRrn+j9+BP5909VkT72/lFLh4oi2Kuiuw7nt5MQJ 9991Xzu8jkXUWeKvPXOfAp//cAIM8IJyBs0rHqtsp7thRMENfLushngoCS54LAsAamHC ZRzhCPkX8Bk7Ukp9F9BfjgwTyKy2eymqcYQHZwWPW9kuckAsXTyhdNf0R3pg3939CMHU th3ggiLEahFjhMyJ32PDBTNgjsY9Nwy2iM4eWgYTmJvOREhI4k/MnGdzsurI16js6jBR Co7q69YjdIQMH+B/jzzWpL45UlQ2kLqZ3NaplgV+4u43So80Fs4DYCwE0bVSjRiTC31e 2xLQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PeQPZam+; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id d14-20020ac85ace000000b00436f83741fbsi2293790qtd.282.2024.04.18.13.12.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:12:12 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PeQPZam+; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 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 0498D385841D for ; Thu, 18 Apr 2024 20:12:12 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id 40EA3384AB44 for ; Thu, 18 Apr 2024 20:11:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 40EA3384AB44 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 40EA3384AB44 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::635 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471067; cv=none; b=sfqAOFuYgsjc6Mb5QlprIqfpyx1/X7wU7RKs7alRtRtY5EIvo4weNYNU67hx9zSfb2dc2u03NN1Wtg4yAQhjDq7sBm9s6WTt7kkZ2LfYuQgBhyuTYQ3p9Xf2pR86QstuFO6PLx12ZxrKLBSeAjpb6oAFjq+31q4WKo7IuZWT9es= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471067; c=relaxed/simple; bh=5sDr5g7U2ywTRYm1e6GUiteL43TzBcSbyiTAO8R27Z8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=eUEISA2katfM8fEuxqoKcvOcySwlDEYNc/VxuI4BOB6dWeLXB36xdjuH5K12h2WJGcpn631ZjOrQevfM+YkmKkSqnsfVlY2z/wbuRB5OKAxZ6fjLtZUXilRPQiBft9k00AVRZr1w67UfRX916bEubnniElXJqDEvXYerVmgNGeU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1e857e571f3so11064035ad.0 for ; Thu, 18 Apr 2024 13:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713471064; x=1714075864; 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=+Udz0sOQRKXAm5kiKFSTNh5JUUjk+Jni+c5SH40tgmE=; b=PeQPZam+i12guqTnyTe8rkxXsWKNJRHeYj4nyDH8ddNRXmcUdM/cl3G+ExbxKFMdNS CBFA1RiqY+aJypNmIgfVe+hDr9W6SvZ5vKwIi+12/YB+sNTlo4/GkSlSccgD3phg+qAM 5abBEAczz23nKovRrWA/IKtIU4LoHjqd6W7KIJ4cA/tQ+2keKaCeJUYq+89cgW6v/PR1 +QdPSeewbNhgEz6QZ47PZYM+pWDTsQMJzl/WOpWVBfTL8XR/nZ9H1Kr2JZb5CPh3njVc ftv4rg8J/3VXdKiP87V1h3jZoKdHDYrUedN7x2v+AHlSoK8k5w3UvGV9SlHfzxCSZ41h gEPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713471064; x=1714075864; 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=+Udz0sOQRKXAm5kiKFSTNh5JUUjk+Jni+c5SH40tgmE=; b=eKPghbwnxkLOYEVEpNJY3YjKOyc+0nbIMJVcFOFTp8zs9EuQ0Dr22EF1PNc44Pk0kb 97YtDociz34vZETluKQ24mao5xhSgkUhGXeGvIcaBzMqYBNUqQfnwtp3E/MXL+qw8ktC jXeDDM1o4ARpbcemTOwjQUVJA5ZceMRQh5ziMUoU3Ccx/udAsy4MkFgCEu75op6vyBpX oM1N+ksi4ATUbpe9t5twi4awftiDVIidxsQ8u3vHVtddk2OmQbbx886tj31pQy1ZxlS2 8UO24mGof5/AllAu2l5wbuz/ude7qIx4jc4XhYanxB9KNaQO4eZNtitSRQEDq2qzI/Ax QtmA== X-Gm-Message-State: AOJu0YzXd3n+L05ys1qgRsU+1WrKLLoT9oQfhvj4aJ2ayfTcp51hmRcI FXyV58TR13irfX1fesXkt3VCKli6iqKMZR1hKZCTp8jvLipyJCUdFoNYyCi9XhPGHi3kmc0K8Lk T X-Received: by 2002:a17:903:50e:b0:1e5:3d8a:75fd with SMTP id jn14-20020a170903050e00b001e53d8a75fdmr106506plb.69.1713471064029; Thu, 18 Apr 2024 13:11:04 -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.11.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:11:03 -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 4/8] gdb: Use passed gdbarch instead of calling current_inferior Date: Thu, 18 Apr 2024 20:10:35 +0000 Message-Id: <20240418201039.236867-5-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.1 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 In do_examine function, use passed gdbarch when checking if an address is tagged instead of calling current_inferior()->arch() to make the code more localized and help modularity by not calling a current_* function, which disguises the use of a global state/variable. There is no change in the code behavior. Signed-off-by: Gustavo Romero Suggested-by: Thiago Jung Bauermann Approved-By: Luis Machado Tested-By: Luis Machado --- gdb/printcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 5635f605314..4edbd458e4d 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1132,7 +1132,7 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr) = value_from_ulongest (builtin_type (gdbarch)->builtin_data_ptr, tag_laddr); - if (gdbarch_tagged_address_p (current_inferior ()->arch (), v_addr)) + if (gdbarch_tagged_address_p (gdbarch, v_addr)) { /* Fetch the allocation tag. */ struct value *tag From patchwork Thu Apr 18 20:10:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789873 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp751027wrm; Thu, 18 Apr 2024 13:12:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUkfatlRxxhbY91rWV07gvT3WTcE3k67MJtqIEi5F6e43s4C4PVLf9C3dBy+tX3PaJfIloK6IAo8of2lwX/RIjs X-Google-Smtp-Source: AGHT+IEu8WM42ylvCXGkiVM9Vkh/eO1AxePGYLjzNaowDUuCsF9tTkDIsdxASwuoth4OdeKC6445 X-Received: by 2002:a05:6214:b93:b0:6a0:585f:8313 with SMTP id fe19-20020a0562140b9300b006a0585f8313mr76939qvb.49.1713471168002; Thu, 18 Apr 2024 13:12:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713471167; cv=pass; d=google.com; s=arc-20160816; b=cdgoQNrAdyfCZsludTeOFiS0J1KfsFFqsT/nlSaKjuhaTvdfWwpH64EdPavE9pRKHK 8xzOkccTzOwq4ZvNIhAh3jlWJUjPv2eqCYV5yWIgrXrmgt6sQEVHKbEnbY4kqs5lKpaE ixXpr4dWBn8+9mU4KbKbGuTD6PqK3s0CGC6rthQLrZaPHMUl9oGsY4k4GN/LgFupEd/J Rzd52G9yfEU66WrsmzsLzqOWAyPVNVpAdcnBRMhTcHGJjGbRS27gawTcEyzzCRMfz2Qu Q5dALJAPKM4bPZRhTFJcx3YvCTR657BKY6y8G6RD3n8vx5rrp4++A8YHKdfJFvZ65W4H E2Nw== 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=Cz8dlBDDpLi4uxT1uiysfvY180H1c9+AMsXf3hobdK0=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=LLl1KWSJPFmWdgEdwjchLyuWCE7FEAsbjEMlStOFKFTcvX45XtBGn9NPpgEJM63wOH C6L5R6aDJLrEiC04E+6ZZeqHnsZyi9r58KT5P2rnGWv93pcrSYo/JibAauqy6CH70qe8 l6nOgdbVGUwQg2hyka0sSNSt+lCQ1DQ9Gck98whlUJZfBIOJotPOHQHhiA0f+UgWaAEC lEvD88TTtNYUin2So7i7UVhr0VrsJTPLuX19qIzznDVXnzkzcTYhDEjLIB6d//M1HpHr 1ZLCSRY6LRYkJbCbmKOmT/t3i6T6/A1dF/K3ryjFrC/2eUuo2oNK7MDypllCjK6Lzzr8 KY7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oNN6ED4S; 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 ke24-20020a056214301800b0069b52e49824si2280000qvb.66.2024.04.18.13.12.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:12:47 -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=oNN6ED4S; 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 A1715384AB4A for ; Thu, 18 Apr 2024 20:12:47 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 785843858C35 for ; Thu, 18 Apr 2024 20:11:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 785843858C35 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 785843858C35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::636 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471072; cv=none; b=epFk3PbDZCYr9etRQQEz4QanN6HmfXUYY6/AzFDg2WEKvurFl0xPdttHJdOjTt6Q/BVoo49rQk+8ovgdA9pThB1XrRPdD6hL3LdNlSZDznOp+ZYPnbUREs7WLvV9XAQy+MR+Wn4SL/l9EodvKBnTVmBFmB1gv8f1wOD4PZJEeJQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471072; c=relaxed/simple; bh=TaXmOSnqR8UoTV+90iJqQIZvxqA10JA9xhjjqRdC+YU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ddRD45E0DTnPY4uHLqa1HawmGml8bib2CfLeK5gu+J7pgJtq8f0Ie715eQoadOLu93lDbDFo9/yANujiJ+A/LVdhkgjNlUSF0GvssrZLZS7RJx+a91y699ZHEz1NkV9dJa7jb+v6zAMBzMr9mqDuwvfmryXnBksFvL5H7+CoWzg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1e2b137d666so11050675ad.2 for ; Thu, 18 Apr 2024 13:11:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713471067; x=1714075867; 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=Cz8dlBDDpLi4uxT1uiysfvY180H1c9+AMsXf3hobdK0=; b=oNN6ED4S5PuCYgPQ34I6Bb7olzSIPJ4djW3JfCliTEiV3aiNba3Ev5fwd89WP8Bmf5 kzSKWIc0epvRfwPCRDUKIrUC9m8ddwH5qqPsMHnC0jum0i4XB7Mrjb7ZnehRXj8mQ9zc qiXXfxvehInqqUkzZGSEJuoiRt+kBK87OuOj6YsCLi7W+4djUvsJdncFD1BeuT7g8Bg3 8MO5EXm2888tehZIjZRRuRLL3+ns0xd0hSODhUBbrRa85DpIKvpfRNjQUs3yOJvwENIp /x6gEEWzOZv4hbnyw7gxXdfUeSz1b0PXR/dzhtIZJfvokFmaTkgb+MiTXOP6/3oxjPBd 8GAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713471067; x=1714075867; 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=Cz8dlBDDpLi4uxT1uiysfvY180H1c9+AMsXf3hobdK0=; b=OHbqD+TgSqszKQfVk5Co18STGwpHJES0gYAaFVkeMjOpg5SF+WpO+UNzxTRK5Vw2LO E+yMVItVfsyageVBbVgY/3mpKBzHvU5GqtOWCiWwXAomq6TvAkNEyvU5WYV1F8aQ+pjG JHRMEec7eIhCYBlgzQFlNKks3Oz2qaM7qkrK4z3IEnCcFFxTnY0K1NsErApoac1RI+EP jwxL1JsP7qpHXuK7oVVIuDl1yLSz2RE1xz2o/6d04dR3QrcZkptKa2xKevtdXV/h2tE5 nSZW5VNb1T7Jl9txU6cLXAQSi1qkxAH7a6X9cA8Ac7Yo/xwfhzFJ1lr1mA8ZGXf/pHzW nQog== X-Gm-Message-State: AOJu0YyVp7xUYyE6eQznRrW5mCQaVUOht0qkt/YRcW2m4YkpQC4Bv1kD ZGaJM20czusrWlDD+AlRmETyNhsfiuZoQbBjimtO/n+JdnWshzPV6dICAKyyszECq16Pwbw5Jk9 c X-Received: by 2002:a17:903:11d1:b0:1e4:9bce:adcf with SMTP id q17-20020a17090311d100b001e49bceadcfmr171051plh.63.1713471066833; Thu, 18 Apr 2024 13:11:06 -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.11.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:11:06 -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 5/8] gdb: Introduce is_address_tagged target hook Date: Thu, 18 Apr 2024 20:10:36 +0000 Message-Id: <20240418201039.236867-6-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.1 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 This commit introduces a new target hook, target_is_address_tagged, which is used instead of the gdbarch_tagged_address_p gdbarch hook in the upper layer (printcmd.c). This change enables easy specialization of memory tagging address check per target in the future. As target_is_address_tagged continues to utilize the gdbarch_tagged_address_p hook, there is no change in behavior for all the targets that use the new target hook (i.e., the remote.c, aarch64-linux-nat.c, and corelow.c targets). Just the gdbarch_tagged_address_p signature is changed for convenience, since target_is_address_tagged takes the address to be checked as a CORE_ADDR type. Signed-off-by: Gustavo Romero Approved-By: Luis Machado Tested-By: Luis Machado --- gdb/aarch64-linux-nat.c | 15 +++++++++++++++ gdb/aarch64-linux-tdep.c | 10 +++------- gdb/arch-utils.c | 2 +- gdb/arch-utils.h | 2 +- gdb/corelow.c | 10 ++++++++++ gdb/gdbarch-gen.h | 4 ++-- gdb/gdbarch.c | 2 +- gdb/gdbarch_components.py | 2 +- gdb/printcmd.c | 26 ++++++++++++++------------ gdb/remote.c | 10 ++++++++++ gdb/target-delegates.c | 30 ++++++++++++++++++++++++++++++ gdb/target.c | 6 ++++++ gdb/target.h | 6 ++++++ 13 files changed, 100 insertions(+), 25 deletions(-) diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 3face34ce79..297f56cdbf1 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -110,6 +110,8 @@ class aarch64_linux_nat_target final /* Write allocation tags to memory via PTRACE. */ bool store_memtags (CORE_ADDR address, size_t len, const gdb::byte_vector &tags, int type) override; + /* Check if an address is tagged. */ + bool is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) override; }; static aarch64_linux_nat_target the_aarch64_linux_nat_target; @@ -1071,6 +1073,19 @@ aarch64_linux_nat_target::store_memtags (CORE_ADDR address, size_t len, return false; } +bool +aarch64_linux_nat_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) +{ + /* Here we take a detour going to linux-tdep layer to read the smaps file, + because currently there isn't a better way to get that information to + check if a given address is tagged or not. + + In the future, if this check is made, for instance, available via PTRACE, + it will be possible to drop the smaps path in favor of a PTRACE one for + this check. */ + return gdbarch_tagged_address_p (gdbarch, address); +} + void _initialize_aarch64_linux_nat (); void _initialize_aarch64_linux_nat () diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index fc60e602748..35979875907 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -2451,17 +2451,13 @@ aarch64_mte_get_atag (CORE_ADDR address) /* Implement the tagged_address_p gdbarch method. */ static bool -aarch64_linux_tagged_address_p (struct gdbarch *gdbarch, struct value *address) +aarch64_linux_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address) { - gdb_assert (address != nullptr); - - CORE_ADDR addr = value_as_address (address); - /* Remove the top byte for the memory range check. */ - addr = gdbarch_remove_non_address_bits (gdbarch, addr); + address = gdbarch_remove_non_address_bits (gdbarch, address); /* Check if the page that contains ADDRESS is mapped with PROT_MTE. */ - if (!linux_address_in_memtag_page (addr)) + if (!linux_address_in_memtag_page (address)) return false; /* We have a valid tag in the top byte of the 64-bit address. */ diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 456bfe971ff..cb149c36bc9 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -102,7 +102,7 @@ default_memtag_to_string (struct gdbarch *gdbarch, struct value *tag) /* See arch-utils.h */ bool -default_tagged_address_p (struct gdbarch *gdbarch, struct value *address) +default_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address) { /* By default, assume the address is untagged. */ return false; diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h index 2dcd8f6dc53..467be40c688 100644 --- a/gdb/arch-utils.h +++ b/gdb/arch-utils.h @@ -141,7 +141,7 @@ extern std::string default_memtag_to_string (struct gdbarch *gdbarch, struct value *tag); /* Default implementation of gdbarch_tagged_address_p. */ -bool default_tagged_address_p (struct gdbarch *gdbarch, struct value *address); +bool default_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address); /* Default implementation of gdbarch_memtag_matches_p. */ extern bool default_memtag_matches_p (struct gdbarch *gdbarch, diff --git a/gdb/corelow.c b/gdb/corelow.c index f4e8273d962..bdda742ef59 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -109,6 +109,10 @@ class core_target final : public process_stratum_target bool fetch_memtags (CORE_ADDR address, size_t len, gdb::byte_vector &tags, int type) override; + /* If the architecture supports it, check if ADDRESS is within a memory range + mapped with tags. For example, MTE tags for AArch64. */ + bool is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) override; + x86_xsave_layout fetch_x86_xsave_layout () override; /* A few helpers. */ @@ -1410,6 +1414,12 @@ core_target::fetch_memtags (CORE_ADDR address, size_t len, return false; } +bool +core_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) +{ + return gdbarch_tagged_address_p (gdbarch, address); +} + /* Implementation of the "fetch_x86_xsave_layout" target_ops method. */ x86_xsave_layout diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h index ebcff80bb9e..63fab26987f 100644 --- a/gdb/gdbarch-gen.h +++ b/gdb/gdbarch-gen.h @@ -707,8 +707,8 @@ extern void set_gdbarch_memtag_to_string (struct gdbarch *gdbarch, gdbarch_memta /* Return true if ADDRESS contains a tag and false otherwise. ADDRESS must be either a pointer or a reference type. */ -typedef bool (gdbarch_tagged_address_p_ftype) (struct gdbarch *gdbarch, struct value *address); -extern bool gdbarch_tagged_address_p (struct gdbarch *gdbarch, struct value *address); +typedef bool (gdbarch_tagged_address_p_ftype) (struct gdbarch *gdbarch, CORE_ADDR address); +extern bool gdbarch_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address); extern void set_gdbarch_tagged_address_p (struct gdbarch *gdbarch, gdbarch_tagged_address_p_ftype *tagged_address_p); /* Return true if the tag from ADDRESS matches the memory tag for that diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 9319571deba..2d92f604c49 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -3232,7 +3232,7 @@ set_gdbarch_memtag_to_string (struct gdbarch *gdbarch, } bool -gdbarch_tagged_address_p (struct gdbarch *gdbarch, struct value *address) +gdbarch_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address) { gdb_assert (gdbarch != NULL); gdb_assert (gdbarch->tagged_address_p != NULL); diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py index 7d913ade621..24e979431b6 100644 --- a/gdb/gdbarch_components.py +++ b/gdb/gdbarch_components.py @@ -1267,7 +1267,7 @@ must be either a pointer or a reference type. """, type="bool", name="tagged_address_p", - params=[("struct value *", "address")], + params=[("CORE_ADDR", "address")], predefault="default_tagged_address_p", invalid=False, ) diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 4edbd458e4d..ae56b9d2fa9 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1132,7 +1132,7 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr) = value_from_ulongest (builtin_type (gdbarch)->builtin_data_ptr, tag_laddr); - if (gdbarch_tagged_address_p (gdbarch, v_addr)) + if (target_is_address_tagged (gdbarch, value_as_address (v_addr))) { /* Fetch the allocation tag. */ struct value *tag @@ -1268,7 +1268,7 @@ print_value (value *val, const value_print_options &opts) /* Returns true if memory tags should be validated. False otherwise. */ static bool -should_validate_memtags (struct value *value) +should_validate_memtags (gdbarch *gdbarch, struct value *value) { gdb_assert (value != nullptr && value->type () != nullptr); @@ -1289,7 +1289,7 @@ should_validate_memtags (struct value *value) return false; /* We do. Check whether it includes any tags. */ - return gdbarch_tagged_address_p (current_inferior ()->arch (), value); + return target_is_address_tagged (gdbarch, value_as_address (value)); } /* Helper for parsing arguments for print_command_1. */ @@ -1346,7 +1346,7 @@ print_command_1 (const char *args, int voidprint) { gdbarch *arch = current_inferior ()->arch (); - if (should_validate_memtags (val) + if (should_validate_memtags (arch, val) && !gdbarch_memtag_matches_p (arch, val)) { /* Fetch the logical tag. */ @@ -2946,9 +2946,10 @@ memory_tag_print_tag_command (const char *args, enum memtag_type tag_type) flag, it is no use trying to access/manipulate its allocation tag. It is OK to manipulate the logical tag though. */ + CORE_ADDR addr = value_as_address (val); if (tag_type == memtag_type::allocation - && !gdbarch_tagged_address_p (arch, val)) - show_addr_not_tagged (value_as_address (val)); + && !target_is_address_tagged (arch, addr)) + show_addr_not_tagged (addr); value *tag_value = gdbarch_get_memtag (arch, val, tag_type); std::string tag = gdbarch_memtag_to_string (arch, tag_value); @@ -3124,8 +3125,9 @@ memory_tag_set_allocation_tag_command (const char *args, int from_tty) /* 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)); + CORE_ADDR addr = value_as_address (val); + if (!target_is_address_tagged (current_inferior ()-> arch(), addr)) + show_addr_not_tagged (addr); if (!gdbarch_set_memtags (current_inferior ()->arch (), val, length, tags, memtag_type::allocation)) @@ -3152,12 +3154,12 @@ memory_tag_check_command (const char *args, int from_tty) struct value *val = process_print_command_args (args, &print_opts, true); gdbarch *arch = current_inferior ()->arch (); + CORE_ADDR addr = value_as_address (val); + /* 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 (arch, val)) - show_addr_not_tagged (value_as_address (val)); - - CORE_ADDR addr = value_as_address (val); + if (!target_is_address_tagged (arch, addr)) + show_addr_not_tagged (addr); /* Check if the tag is valid. */ if (!gdbarch_memtag_matches_p (arch, val)) diff --git a/gdb/remote.c b/gdb/remote.c index 5c9fdebcdbe..cd271c4b493 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1084,6 +1084,8 @@ class remote_target : public process_stratum_target bool store_memtags (CORE_ADDR address, size_t len, const gdb::byte_vector &tags, int type) override; + bool is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) override; + public: /* Remote specific methods. */ void remote_download_command_source (int num, ULONGEST addr, @@ -15574,6 +15576,14 @@ remote_target::store_memtags (CORE_ADDR address, size_t len, return packet_check_result (rs->buf, true).status () == PACKET_OK; } +/* Implement the "is_address_tagged" target_ops method. */ + +bool +remote_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) +{ + return gdbarch_tagged_address_p (gdbarch, address); +} + /* Return true if remote target T is non-stop. */ bool diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index 59ea70458ad..e322bbbe481 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -197,6 +197,7 @@ struct dummy_target : public target_ops bool supports_memory_tagging () override; bool fetch_memtags (CORE_ADDR arg0, size_t arg1, gdb::byte_vector &arg2, int arg3) override; bool store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector &arg2, int arg3) override; + bool is_address_tagged (gdbarch *arg0, CORE_ADDR arg1) override; x86_xsave_layout fetch_x86_xsave_layout () override; }; @@ -373,6 +374,7 @@ struct debug_target : public target_ops bool supports_memory_tagging () override; bool fetch_memtags (CORE_ADDR arg0, size_t arg1, gdb::byte_vector &arg2, int arg3) override; bool store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector &arg2, int arg3) override; + bool is_address_tagged (gdbarch *arg0, CORE_ADDR arg1) override; x86_xsave_layout fetch_x86_xsave_layout () override; }; @@ -4562,6 +4564,34 @@ debug_target::store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector return result; } +bool +target_ops::is_address_tagged (gdbarch *arg0, CORE_ADDR arg1) +{ + return this->beneath ()->is_address_tagged (arg0, arg1); +} + +bool +dummy_target::is_address_tagged (gdbarch *arg0, CORE_ADDR arg1) +{ + tcomplain (); +} + +bool +debug_target::is_address_tagged (gdbarch *arg0, CORE_ADDR arg1) +{ + gdb_printf (gdb_stdlog, "-> %s->is_address_tagged (...)\n", this->beneath ()->shortname ()); + bool result + = this->beneath ()->is_address_tagged (arg0, arg1); + gdb_printf (gdb_stdlog, "<- %s->is_address_tagged (", this->beneath ()->shortname ()); + target_debug_print_gdbarch_p (arg0); + gdb_puts (", ", gdb_stdlog); + target_debug_print_CORE_ADDR (arg1); + gdb_puts (") = ", gdb_stdlog); + target_debug_print_bool (result); + gdb_puts ("\n", gdb_stdlog); + return result; +} + x86_xsave_layout target_ops::fetch_x86_xsave_layout () { diff --git a/gdb/target.c b/gdb/target.c index 107a84b3ca1..5c3c1a57dbd 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -796,6 +796,12 @@ target_store_memtags (CORE_ADDR address, size_t len, return current_inferior ()->top_target ()->store_memtags (address, len, tags, type); } +bool +target_is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) +{ + return current_inferior ()->top_target ()->is_address_tagged (gdbarch, address); +} + x86_xsave_layout target_fetch_x86_xsave_layout () { diff --git a/gdb/target.h b/gdb/target.h index c9eaff16346..486a0a687b0 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1334,6 +1334,10 @@ struct target_ops const gdb::byte_vector &tags, int type) TARGET_DEFAULT_NORETURN (tcomplain ()); + /* Returns true if ADDRESS is tagged, otherwise returns false. */ + virtual bool is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) + TARGET_DEFAULT_NORETURN (tcomplain ()); + /* Return the x86 XSAVE extended state area layout. */ virtual x86_xsave_layout fetch_x86_xsave_layout () TARGET_DEFAULT_RETURN (x86_xsave_layout ()); @@ -2317,6 +2321,8 @@ extern bool target_fetch_memtags (CORE_ADDR address, size_t len, extern bool target_store_memtags (CORE_ADDR address, size_t len, const gdb::byte_vector &tags, int type); +extern bool target_is_address_tagged (gdbarch *gdbarch, CORE_ADDR address); + extern x86_xsave_layout target_fetch_x86_xsave_layout (); /* Command logging facility. */ From patchwork Thu Apr 18 20:10:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789874 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp751137wrm; Thu, 18 Apr 2024 13:13:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVdoaP9ZklWzkvY257e2zo1fSzYWI0bmDks2bRusScAg+DOJDekjx1Zzs78DxYzvNFHQeTGHTbxEaQs7hXpjRQj X-Google-Smtp-Source: AGHT+IEk7CewVFm69r8sdoFWN225VQNgtf0E22a6IK2QhSUvn7xp6tZmhZSxDTcROCTxesNKPYuT X-Received: by 2002:a05:690c:c8e:b0:618:8b6c:6c1b with SMTP id cm14-20020a05690c0c8e00b006188b6c6c1bmr83469ywb.4.1713471186358; Thu, 18 Apr 2024 13:13:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713471186; cv=pass; d=google.com; s=arc-20160816; b=RyGtlTEAXSp5VsxHqWIE8yN+F1j8BYX2KjU0Q9n4J9TkOQHF9Vi/AJ27LDBk6ev6L1 vSVofcxVfc8i+5h7rH4seJeCZV3HirC+kC4WoeKC05GKc1cpSng+yIxCvgt+flgLLNy4 DSMomOnPsRD0GpLYaMX+d2P1fjUhXBSjmyF72EnwEbE2yJMeZKsfY8RoCeBQxKl9tFSD iMJaOmFO+ahoHBBIHUO9elhJy+FqAloqVofx1jVdKR4ymgq6YScSFRxCtPvB89NmG4wu LCUaFPs4CmWqsHf+6/TSsB4+MBIwZRbeFgcU9Ufwk+MFN4a7FBTD4KgJud0yLHYkl5f4 W8UA== 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=Jd4vwtUzOixjUh9lVMq2yIZw/U5QwziDmqPZK7rVgWI=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=Sg1uhp1Cit50N5AXb8j0mrkIWUJJBxN/3f/RBKyWnWu3DNdV+86i41NV3h4advUpp6 lOzu/Bqhrqmhd0OgMtWbgPBs3cxG+aZPlEKn5whJsdpsNSdERT0g4T67AJzCsRTx8Drc NzOYTU9rqt4q5arr33464flB5A0ePSIlTksHiCmsmCXb6vqd/hWgZWFxwMKK/vymuGsl VxzjobToF9ihRffj8w/AbRuCsulsb//JBHikrE298DuKG6LmZIilshumLACMJBQEivss E2sjZkW47to9Tm1XuLLbUa3peOjnnPtH0CaMpH8HGQToqT1xim8kfQ+y2nKNZklTDNiJ 2n7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yk2yAlnb; 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 y14-20020a05622a164e00b0043721c53999si2200782qtj.641.2024.04.18.13.13.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:13:06 -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=yk2yAlnb; 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 06CA83858C35 for ; Thu, 18 Apr 2024 20:13:06 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id 402A33858401 for ; Thu, 18 Apr 2024 20:11:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 402A33858401 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 402A33858401 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::632 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471073; cv=none; b=NXBDeL1ge1t9AnkRunvVX74Wp8JDZwZDTyN9WubsbV+Tzt6ovwqOKeKy3/kcTqp9IANep+QSZ79ACR4CzU8xDy9RnANET6IHuUMzTW50AWnvKrn9hB7UbeZXJ6xNZtPkiLhmLAdXttWX6/IyI1LVGAGYp34gZr/WipoT/yoEf9A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471073; c=relaxed/simple; bh=rsgmiX0OaaQbQDKYL8666bsdQDx/qa/EJRl98FTp9nY=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Ab+y/+d1PshTVAi8EbH0IPoeYNeswaIbdW4atARiAOD/DZTWYx21J6BBNo0VvohoBZty911g1nADDrRss0RBnjSXVlt3aef2VIMftC8q840dIOPL0kc81qeVsnE3/5Dr2W0a9za+c/UwjApXb41XMI8OgFXqPA6+MZvMoLHwsgI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1e86d56b3bcso12196295ad.1 for ; Thu, 18 Apr 2024 13:11:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713471070; x=1714075870; 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=Jd4vwtUzOixjUh9lVMq2yIZw/U5QwziDmqPZK7rVgWI=; b=yk2yAlnb1XdboKr0jv88bA2TwJoB3FvXP0r2U8kcgEHVfkJN2i1x8Amq27IRLHTHhH cw/yLZSNOfzIN2POeaNiXeYBgZqG5O52JBeJjo9teQC3xf7UwqMmza3aJVSpWxGeOFDA kP8eYQLhmAYJRttMVX1JHtOzqnF0mai7IJD5Ia1XIMdQ4cxzyZetz7cmCcQTboHUUSb5 ksx1Ds6Hf390ZE+k6CwboiUh6MNJxMkMsUIaHM79+W9bltvE73SYciRUUhi5RRfzZHJj 4/WfIM4L2HaoA6dLPZr7B53WvcKkJqzaV/ZxaxfbA+F856gq/0x2XQr/fiyU3Ru+XnLt P9JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713471070; x=1714075870; 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=Jd4vwtUzOixjUh9lVMq2yIZw/U5QwziDmqPZK7rVgWI=; b=j36rYRVHk7O86qXYSRMLeA6gluGUMMRLp6Dgu/TzDd7BvN1AfStdXBQbQX7GWSv6dJ G2FUGg1EJVgfhifCdmjFXUWz+jVRJv5zUM9cyY/ZRcw80bbibYpu1g4b86QbiwZd1307 iqXi2B4l90P0kQGXwmxbYKM1QskzBrRPACG7Z4yZeyeeLfshIqCZknlPP27hxsNMpec4 EIXtCfsR1hnq9HhcwVuayLD4UNHxwE8gmqoECwiqTnMpqK5o6t0CIeQilPapvUnnG/9B 1KZwhB3MKhe5x57HtZdRra/ty8bTFJ1aZhk7ZMFaU+VOf8oa1A2pc3Wdo6djrNmTmqKv XWxQ== X-Gm-Message-State: AOJu0YwT3+DbYKlT4M0xNdvyxHZP5D0062yUVQrSNxbfm/dpJSaPzTAj ItgcV1r7DLxLCPmxlvRV126RCKrFH8uzFsBZJOIj8+om/tHeWVxL74d7JmRf0U8eddD4uBtRWVM a X-Received: by 2002:a17:902:f690:b0:1e2:7ea0:c1f2 with SMTP id l16-20020a170902f69000b001e27ea0c1f2mr155800plg.58.1713471069641; Thu, 18 Apr 2024 13:11:09 -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.11.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:11:09 -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 6/8] gdb: Add qIsAddressTagged packet Date: Thu, 18 Apr 2024 20:10:37 +0000 Message-Id: <20240418201039.236867-7-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.1 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 This commit adds a new packet, qIsAddressTagged, allowing GDB remote targets to use it to query the stub if a given address is tagged. Currently, the memory tagging address check is done via a read query, where the contents of /proc//smaps is read and the flags are inspected for memory tagging-related flags that indicate the address is in a memory tagged region. This is not ideal, for example, for QEMU stub and other cases, such as on bare-metal, where there is no notion of an OS file like 'smaps.' Hence, the introduction of qIsAddressTagged packet allows checking if an address is tagged in an agnostic way. The is_address_tagged target hook in remote.c attempts to use the qIsAddressTagged packet first for checking if an address is tagged and if the stub does not support such a packet (reply is empty) it falls back to using the current mechanism that reads the contents of /proc//smaps via vFile requests. Signed-off-by: Gustavo Romero Tested-By: Luis Machado --- gdb/remote.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/gdb/remote.c b/gdb/remote.c index cd271c4b493..3d034bb1ef8 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -337,6 +337,9 @@ enum { packets and the tag violation stop replies. */ PACKET_memory_tagging_feature, + /* Support for the qIsAddressTagged packet. */ + PACKET_qIsAddressTagged, + PACKET_MAX }; @@ -15535,6 +15538,50 @@ create_store_memtags_request (gdb::char_vector &packet, CORE_ADDR address, strcpy (packet.data (), request.c_str ()); } +static void +create_is_address_tagged_request (gdbarch *gdbarch, gdb::char_vector &packet, + CORE_ADDR address) +{ + int addr_size; + std::string request; + + addr_size = gdbarch_addr_bit (gdbarch) / 8; + request = string_printf ("qIsAddressTagged:%s", phex_nz (address, addr_size)); + + if (packet.size () < request.length () + 1) + error (_("Contents too big for packet qIsAddressTagged.")); + + strcpy (packet.data (), request.c_str ()); +} + +static bool +check_is_address_tagged_reply (remote_target *remote, gdb::char_vector &packet, + bool &tagged) +{ + gdb_assert (remote != nullptr); + /* Check reply and disable qIsAddressTagged usage if it's not supported. */ + packet_result result = remote->m_features.packet_ok (packet, + PACKET_qIsAddressTagged); + + /* Return false on error (Exx), empty reply (packet not supported), or reply + size doesn't match 2 hex digits. */ + if ((result.status () != PACKET_OK) || (strlen (packet.data ()) != 2)) + return false; + + gdb_byte reply; + /* Convert only 2 hex digits, i.e. 1 byte in hex format. */ + hex2bin (packet.data (), &reply, 1); + + if (reply == 0x00 || reply == 0x01) + { + tagged = !!reply; + return true; + } + + /* Invalid reply. */ + return false; +} + /* Implement the "fetch_memtags" target_ops method. */ bool @@ -15581,6 +15628,31 @@ remote_target::store_memtags (CORE_ADDR address, size_t len, bool remote_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) { + /* Firstly, attempt to check the address using the qIsAddressTagged + packet. */ + if (m_features.packet_support (PACKET_qIsAddressTagged) != PACKET_DISABLE) + { + remote_target *remote = get_current_remote_target (); + struct remote_state *rs = get_remote_state (); + bool is_addr_tagged; + + create_is_address_tagged_request (gdbarch, rs->buf, address); + + putpkt (rs->buf); + getpkt (&rs->buf); + + /* If qIsAddressTagged is not supported PACKET_qIsAddressTagged will be + set to PACKET_DISABLE so no further attempt is made to check addresses + using this packet and the fallback mechanism below will be used + instead. Also, if the check fails due to an error (Exx reply) the + fallback is used too. Otherwise, the qIsAddressTagged query succeeded + and is_addr_tagged is valid. */ + if (check_is_address_tagged_reply (remote, rs->buf, is_addr_tagged)) + return is_addr_tagged; + } + + /* Fallback to arch-specific method of checking whether an address is tagged + in case check via qIsAddressTagged fails. */ return gdbarch_tagged_address_p (gdbarch, address); } @@ -16070,6 +16142,9 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL, add_packet_config_cmd (PACKET_memory_tagging_feature, "memory-tagging-feature", "memory-tagging-feature", 0); + add_packet_config_cmd (PACKET_qIsAddressTagged, + "qIsAddressTagged", "memory-tagging-address-check", 0); + /* Assert that we've registered "set remote foo-packet" commands for all packet configs. */ { From patchwork Thu Apr 18 20:10:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789875 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp751393wrm; Thu, 18 Apr 2024 13:13:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVGWxjfRVXvtrzBFcmTzoRWWrbbDzoLwMX+df/cT1yJgdUMUSbtHn4xScDOd/lGxsJBFWA9/5omXXC8933b2bh8 X-Google-Smtp-Source: AGHT+IHXvcclt2gJJe5an8AUpEPWyy3AGt1YfcxcH9qHqle+hrt6rOXlQr3RmaulElCjau8Ye5JM X-Received: by 2002:ac8:5983:0:b0:437:b7bd:368a with SMTP id e3-20020ac85983000000b00437b7bd368amr1811242qte.19.1713471223872; Thu, 18 Apr 2024 13:13:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713471223; cv=pass; d=google.com; s=arc-20160816; b=nld+Wz0qS11Oxd/iq3bgiN32qI4xDps/h/ciTnePN2PuMCgt1JBhF28q/5L3GZG0QO ql3dW74Wv+IBen66HLrWtEBqHF81qgRy7opfqg2LeQxOONXRcQU43+azDY0B2d3Py09/ DuZd2JcMrfs5jJOYUZXB9qV6lOcUd+JYE0fQfJJeSFxuGWanEuXQlCSkuwfUCoesHpyk fxrVnFUR3si5xDKrRx5LaXn5V9PJyvPsXAsGQRCKrWc+q+Rz+MTCwNyfqagjNZYJSzc2 +00sZifoUUrZbw+MHny9hRBpsVr1/mdfIcpgmvZGO0jeFFGVY+awXd385I84DFKgMaHy BKww== 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=LvPqpPxdXMvMfni6zeyD9qO97KVpmC2OoORvKi1PFXo=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=VlYAJ5aDSdta0vcyU8i4+2ydOqtZ0KNv26Ie3Xf84x3ARyKeipX2FqEEhn9/YnOP9n EX2mWEYdHlHO1Ma1m8ZaenINAAFsOMVwNg9VSVwW/dHWKmSUBqDN37xUx8ZdwZrxg5kH xj7PkSNKEkCfZyOYV6w5vSiW//IiWzmCfYwuG5hUDq6VutmqZY/Iyy8KrAkNyN0eC2Zw p13+yoGmnqgLW0lwm8rfv6s2Sxei8GCo56lRrzKYcn7JDvzqRlaghyC3M/I48i926lo4 h+/EqxDg/xTTUD7Sv36lUnnGkuLvqCH+M0CRTEbilwSfJz5u7zTYC+O1fOVCd7iaFiJC GHuQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QiQwlPwL; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id bp17-20020a05622a1b9100b0042ef110519bsi2173527qtb.783.2024.04.18.13.13.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:13:43 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QiQwlPwL; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 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 81D543861870 for ; Thu, 18 Apr 2024 20:13:43 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id D5572385DC3F for ; Thu, 18 Apr 2024 20:11:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D5572385DC3F 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 D5572385DC3F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::636 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471076; cv=none; b=ByNbqP/Nr+u/wgzdCW4+xVqdcRohw/b6z2ukmqRKDGDSApkVa7QI2/Wga1MnfJvj3SnrxUh39OmbA8i7QS+fH1R7PSnCuWnXpEKztmT8uHQ2QuAmpb1Txa7zS/Yb8qilSwItSlbokhbdU/0+whgAjd0LvW/pnL/JrGwJEJ/bH7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471076; c=relaxed/simple; bh=+aYIy06p33cWuznN4M9G/ExjmM7xSbVaZPDrHjtMX/8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=PQWytq0VWhUSRacaRg/khRcIrC34UG8QuzvG2WBxplvoezGir+Z/jLQx5rYABYi84xJrNE8XvvwhV1tD5dFe+Yas2JI22v28YHNy+Lu6ywF1jFkjtJNf8HEVunIfLGAdp21HWdniaZ2d3PyzLQ0f471367bkD01vEU355omEEDQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1e4c4fb6af3so9686655ad.0 for ; Thu, 18 Apr 2024 13:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713471072; x=1714075872; 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=LvPqpPxdXMvMfni6zeyD9qO97KVpmC2OoORvKi1PFXo=; b=QiQwlPwLKmJw7XMomx8t1/r8UKQRZUsZcNF++ZnX8KsiKDz/ziDuFdiK7lYUG8yHCv tNeSov3a/JF3LkgnaieNrYbuBOzRo4BB92lYyWE1B/HAq75I0ThQBiTIZBQyr7AfpOib kM5RV8s7uY6yyMXTy/qve9IFzrJhv70xo0xWvfQtjfLfjDFErlUEJTTQus5xzuW6jrFT IamFqlU01R6BO9Xka3t0R0Z65HRy6vvNV81CbohFb4g3a6D1bbSkPInILO8+s9mMRMff 4uBZi3ltQgV3JIiI0+4MRo20aI6eG8C/qOBmKlyDo+9+3dleCQzEeNG3GxswumqdE7bD A1Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713471072; x=1714075872; 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=LvPqpPxdXMvMfni6zeyD9qO97KVpmC2OoORvKi1PFXo=; b=ZjeD6jggOhADz6b1jAQEFD9cMGqLgx2NcsMf5v/F/ZKSn5j0NIABgzXBSq6+KX4LMX BeTRWbm9cJUzKdGVcc467lSYuhIiv6sQm4QTtugPHtRHzk5JliiHv+f9HJnaBvGlIqsY hl4Ns6jMiABnCHBttca6uVnJsYRxEWr/GCN+hj3m1ZpQ2iphXTN5s0F/x3vzleBAcskH 28Hp0gmxinszPyaPWs9Bz7vH1sL75EPQclcrRheFxe1r7wj+DB8tPw7+AfEEujg/7YLx kYPnsblEljJQGXWpv4fHb1BuCsfMGv94q948lzvZzr/ivdssM7Q4+0eJ9lhf6crkZQ1/ dPWA== X-Gm-Message-State: AOJu0YxApRZCusnTCZvcp2oAKnlRa5wFGrDxkxyYnYlsPTCWf1BKKmMZ kD2f/c7Eo9cGrRNwwBCfLDYX0a4QudpFnXFoxuLTPfgpMRUYrfnZxJmm2yJyocWhn+kuDPRSA/l m X-Received: by 2002:a17:902:ea12:b0:1e3:e6cb:a07f with SMTP id s18-20020a170902ea1200b001e3e6cba07fmr317668plg.26.1713471072388; Thu, 18 Apr 2024 13:11:12 -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.11.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:11:11 -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 7/8] gdb/testsuite: Add unit tests for qIsAddressTagged packet Date: Thu, 18 Apr 2024 20:10:38 +0000 Message-Id: <20240418201039.236867-8-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.1 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 Add unit tests for testing qIsAddressTagged packet request creation and reply checks. Signed-off-by: Gustavo Romero Tested-By: Luis Machado --- gdb/remote.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/gdb/remote.c b/gdb/remote.c index 3d034bb1ef8..cfb54de157d 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -15682,6 +15682,8 @@ test_memory_tagging_functions () scoped_restore restore_memtag_support_ = make_scoped_restore (&config->support); + struct gdbarch *gdbarch = current_inferior ()->arch (); + /* Test memory tagging packet support. */ config->support = PACKET_SUPPORT_UNKNOWN; SELF_CHECK (remote.supports_memory_tagging () == false); @@ -15748,6 +15750,71 @@ test_memory_tagging_functions () create_store_memtags_request (packet, 0xdeadbeef, 255, 1, tags); SELF_CHECK (memcmp (packet.data (), expected.c_str (), expected.length ()) == 0); + + /* Test creating a qIsAddressTagged request. */ + expected = "qIsAddressTagged:deadbeef"; + create_is_address_tagged_request (gdbarch, packet, 0xdeadbeef); + SELF_CHECK (strcmp (packet.data (), expected.c_str ()) == 0); + + /* Test error reply on qIsAddressTagged request. */ + reply = "E00"; + strcpy (packet.data (), reply.c_str ()); + /* is_tagged must not change, hence it's tested too. */ + bool is_tagged = false; + SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) == + false); + SELF_CHECK (is_tagged == false); + + /* Test 'tagged' as reply. */ + reply = "01"; + strcpy (packet.data (), reply.c_str ()); + /* Because the byte is 01, is_tagged should be set to true. */ + is_tagged = false; + SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) == + true); + SELF_CHECK (is_tagged == true); + + /* Test 'not tagged' as reply. */ + reply = "00"; + strcpy (packet.data (), reply.c_str ()); + /* Because the byte is 00, is_tagged should be set to false. */ + is_tagged = true; + SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) == + true); + SELF_CHECK (is_tagged == false); + + /* Test an invalid reply (neither 00 nor 01). */ + reply = "04"; + strcpy (packet.data (), reply.c_str ()); + /* Because the byte is invalid is_tagged must not change. */ + is_tagged = false; + SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) == + false); + SELF_CHECK (is_tagged == false); + + /* Test malformed reply of incorrect length. */ + reply = "0104A590001234006"; + strcpy (packet.data (), reply.c_str ()); + /* Because this is a malformed reply is_tagged must not change. */ + is_tagged = false; + SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) == + false); + SELF_CHECK (is_tagged == false); + + /* Test empty reply. */ + reply = ""; + strcpy (packet.data (), reply.c_str ()); + /* is_tagged must not change, hence it's tested too. */ + is_tagged = true; + /* On the previous tests, qIsAddressTagged packet was auto detected and set + as supported. But an empty reply means the packet is unsupported, so for + testing the empty reply the support is reset to unknown state, otherwise + packet_ok will complain. */ + remote.m_features.m_protocol_packets[PACKET_qIsAddressTagged].support = + PACKET_SUPPORT_UNKNOWN; + SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) == + false); + SELF_CHECK (is_tagged == true); } static void From patchwork Thu Apr 18 20:10:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789870 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp750778wrm; Thu, 18 Apr 2024 13:12:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWLYfRMj4+r9EnIya5Kdp/sfv/XRaeL2dP/rLjCk0L6ldpDAjIUphq8UhVIIBSTHD3WAJK5+po0ZjUpOI8ObWOg X-Google-Smtp-Source: AGHT+IHQvage9BFpNFTgQ17iAjNT+hw7+f1SYdfvFRIizcG/hGLkBmHUIqBXwV5Q2uCWIXv+b/x4 X-Received: by 2002:a37:de0e:0:b0:78e:eb64:d91 with SMTP id h14-20020a37de0e000000b0078eeb640d91mr546670qkj.1.1713471124298; Thu, 18 Apr 2024 13:12:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713471124; cv=pass; d=google.com; s=arc-20160816; b=RCQtClYHD2tuWQaHXpzWTFaEnpmstTQ538PudCTz20wRe0KDMQCzo+7aZgodtmXRAe 7z1ivISpVj7cngJLkWhlb5OZYi4Z9+DD1zWNeoTOBcUWRfE4ehf10JDguQhJHPVjWyzC F2S9dDzKZGb3AZ3G2vq1ZbN0p744kGiohSEttTFcuwezSn8F+Yr2th/a3637p3/G9L2A YZFPp4RsiKngY+wPWUUBLB0k7HbfBGie1RsgVQnn6hBN5BUtEXy/c6ix7HvZgS+Ngi2C 2qVSPgBega8OQY3cEprBZaUf4LR/0tn7o3Uqz/K6PRcBNAoxidNX7x4J4lHprFC6cU6o tSdg== 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=TF2Nl3FJrU/baf5Up/FEuXBwOW/ZL2rAiN9OJnXXfF4=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=a2niyq+1/qez0Z3L88ukKWYxmqeH7oWGxIdvMlIubfRrUz1Z8EncARcwa9pHrqaCIq qLIFV8BS1T3yEiqbE6bmgXQlwUC94vQTwRhBti3W9hCL2HC01qM7oDczRSkgEsFiM+e2 GCTqdM+3k+7P8vykARwc6s2dg770ZxLz0RTGJnnhSABVydwJlbYIAcq9LxD9TaNhlM+2 gHB87YCzcAfVSJS/+sDaVwRJu+2sYvqrb80NZDlhWsAP2d3C5fqeabEFBPDxs5viuscp e1FWaniCSAQsR7t/Qbs2iw39SaJp3P0N8E1C84mwkXbKEHwWYZADZjrybmbwjZDKUsT6 e4IA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gbBtFLB9; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id pa5-20020a05620a830500b0078eeb70f535si2138078qkn.383.2024.04.18.13.12.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:12:04 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gbBtFLB9; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 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 E029F384AB40 for ; Thu, 18 Apr 2024 20:12:03 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id 82B29384AB7D for ; Thu, 18 Apr 2024 20:11:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 82B29384AB7D 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 82B29384AB7D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::635 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471081; cv=none; b=cfg4+9I55O6fv8lwZa6pCAr4+aNBmofml1b5EHexorLSP1gnw+IdkSs6g+CsBMQA34Ejyu1ssWdgDojHysAkcowGG1Sf6F6IIEp5t5mVIU9dmTMs7duAxiSolmKG5KW1IaScIRIpkhk4QfPtAugTtbBgFsBsD287IqtC72PMSxI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471081; c=relaxed/simple; bh=mPTe+q7MJUDvKWdOmh4uT07j7CKJAiaL8Lmczphlc9o=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ix9abt/8lTIn6A+Z77KGZsz4ImcgCjC7vaQwqPm2XD1RqGJUIJB8it1mWxHF98rgQGTcVEGHi3XPx6nyRjwswR5V5o9lISe63KiNPMNXgtAee7K9Xy+9DVhtSn4KsZJT+xogvtE/8A9iMmk/lSPtw86incS/wHaWgAhkfU1IFuU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1e3ff14f249so9894595ad.1 for ; Thu, 18 Apr 2024 13:11:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713471075; x=1714075875; 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=TF2Nl3FJrU/baf5Up/FEuXBwOW/ZL2rAiN9OJnXXfF4=; b=gbBtFLB9VFTC16IWYdzn3lCuCCzHmsxrFO3a1Pq9QgwFwQTtDUF6Ee3vQcZbMI9BZb 2G/YGajKBNi+i+R4Oko3Qf9H4+mD7iNmJsXjxCDNw+EYnILyew+Lzj3B3KyofdkQ3Ai5 3nzp7A9d4+hrhd7OWyOQ5zK1Xc+WCEHWDZT0L9khNIgVOeOBFiE4J14jNIAOsWIg69JP pDh5oqIfaCek2bAZXgzUuKTqq3/A3M+ybYtb6gWFiZIyOymzTVe+dP65i2zUDXO56HJC nR4UAR7/5b+2LyturGRkyE4DiFVbovPVDl2bvNi7t2e6/QtFmOYh0EF/6j3i+GM+ou5C tfFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713471075; x=1714075875; 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=TF2Nl3FJrU/baf5Up/FEuXBwOW/ZL2rAiN9OJnXXfF4=; b=QwgIa9n5y+K/gBFUH1Ns4qJ/mZYtpnPRNGc62ij75m5Rd7uLIFIiGY5wkghYDB7a0t 7hobXAMkZYLuDqNsvJyvDCa2sglt8encM0413SnUfPX7km374TyBD4u/N435yZTbPUey aqzpBMTG7v3n2iTqeito2usyJDrJnF/yV76HQhnBBNO+Mnm0PT1xE9V0hMEn79Y1GhoH iK6Tgh0RPqvLnCRplKYhXlePApyIvePFHdnF9pOxoAW808pfuKQZ2XaBLbu7HEfpVPx+ ucB64iFnltoNAG18f3pdE0S79u+QWXUYoVzg3jMaYDSzJJBHJTfPI4dUfzQAeEhmy0C1 1Xjw== X-Gm-Message-State: AOJu0YwYY2mRCam/Z9/tQCrJXOEub3tKu12Oz7bGMMOnsH+kA1LoqFjE wPwkcXNkPl87Xpnw0kXXSQHIN+mgxy3cyYifAO34NFi232FrD9VtduNheq1Wn+r+WRGq3jpAzTd S X-Received: by 2002:a17:903:234e:b0:1e5:e664:9c12 with SMTP id c14-20020a170903234e00b001e5e6649c12mr5817226plh.0.1713471075160; Thu, 18 Apr 2024 13:11:15 -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.11.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:11:14 -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 8/8] gdb: Document qIsAddressTagged packet Date: Thu, 18 Apr 2024 20:10:39 +0000 Message-Id: <20240418201039.236867-9-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.1 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 This commit documents the qIsAddressTagged packet. Signed-off-by: Gustavo Romero Reviewed-by: Eli Zaretskii --- gdb/NEWS | 10 ++++++++++ gdb/doc/gdb.texinfo | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 942453c7064..050f6f96e62 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -196,6 +196,16 @@ QThreadOptions in qSupported QThreadOptions packet, and the qSupported response can contain the set of thread options the remote stub supports. +qIsAddressTagged + This new packet allows GDB to query the stub about a given address to check + if it is tagged or not. Many memory tagging-related GDB commands need to + perform this check before they read/write the allocation tag related to an + address. Currently, however, this is done through a 'vFile' request to read + the file /proc//smaps and check if the address is in a region reported + as memory tagged. Since not all targets have a notion of what the smaps + file is about, this new packet provides a more generic way to perform such + a check. + *** Changes in GDB 14 * GDB now supports the AArch64 Scalable Matrix Extension 2 (SME2), which diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 82a617e9ad3..31a531ee992 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -44093,6 +44093,35 @@ although this should not happen given @value{GDBN} will only send this packet if the stub has advertised support for memory tagging via @samp{qSupported}. @end table +@cindex check if a given address is in a memory tagged region +@cindex @samp{qIsAddressTagged} packet +@item qIsAddressTagged:@var{address} +@anchor {qIsAddressTagged} +Check if address @var{address} is in a memory tagged region; if it is, it's +said to be @dfn{tagged}. The target is responsible for checking it, as this +is architecture-specific. + +@var{address} is the address to be checked. + +Reply: +@table @samp +Replies to this packet should all be in two hex digit format, as follows: + +@item @samp{01} +Address @var{address} is tagged. + +@item @samp{00} +Address @var{address} is not tagged. + +@item E @var{nn} +An error occurred whose code is @var{nn}. This means that address could not +be checked for some reason. + +@item @w{} +An empty reply indicates that @samp{qIsAddressTagged} is not supported by the +stub. +@end table + @item QMemTags:@var{start address},@var{length}:@var{type}:@var{tag bytes} @anchor{QMemTags} @cindex store memory tags @@ -45141,9 +45170,11 @@ The remote stub supports and implements the required memory tagging functionality and understands the @samp{qMemTags} (@pxref{qMemTags}) and @samp{QMemTags} (@pxref{QMemTags}) packets. -For AArch64 GNU/Linux systems, this feature also requires access to the -@file{/proc/@var{pid}/smaps} file so memory mapping page flags can be inspected. -This is done via the @samp{vFile} requests. +For AArch64 GNU/Linux systems, this feature can require access to the +@file{/proc/@var{pid}/smaps} file so memory mapping page flags can be +inspected, if @samp{qIsAddressTagged} (@pxref{qIsAddressTagged}) packet +is not supported by the stub. Access to the @file{/proc/@var{pid}/smaps} +file is done via @samp{vFile} requests. @end table