From patchwork Thu Apr 4 06:48:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 785808 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp684564wro; Wed, 3 Apr 2024 23:49:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWkNmS/nr5+nlQ6mNZtepRQy+oeasDuBb6K1NnWJtxD55TzFU1cMIAHjFbdY/TEc4jlqEh3Hi++XtcGZC6IpufH X-Google-Smtp-Source: AGHT+IG7Q0OFcqv+hFYCvM4LnaiCq1vKvmQwVJoiKZE/PsPwH7yk5c0Z7Qw0gwGe3r29G2+2LCyA X-Received: by 2002:ae9:e206:0:b0:78b:cf48:afcd with SMTP id c6-20020ae9e206000000b0078bcf48afcdmr1538030qkc.34.1712213356499; Wed, 03 Apr 2024 23:49:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712213356; cv=pass; d=google.com; s=arc-20160816; b=hxfoIny4tdOXoS22mOFgfrVGHwN7Mv1p1N9LqGp85DvwZA5cFpiHEePX8fOlif1mh3 5hfwjacAhHt6diDTO6hCUijO9rNnJv+jUE6pB02gzJriS2J24s/3CKAzChdj0KRx8pWX bkrMNq+BoakZcuCQ3HniXCnlPT0kP3Ua01VXhTaIJn1bRoeyYtKYw9jnHRsFIHIUOzEN BDAQ+sZNVMX1asG2UP+rfUCv1kfdCrNtyuHT380s15bD8p7lgB4pkDzEegQ2G0sAw/O+ X08divNB778I+Wuiv0DvCS9ioQz76DIM/Zb5rKq2HLFtJdwuTLbAC7VZmdrMGrVG0vfz rukA== 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=nFpODmsS60D0MgO2Sq0vHP1Bf80f04kJ09zfTtn5e6M=; fh=ip7+QkkM488k9wyzFaZPu3h7BUQARzj44zdeG2KNIXU=; b=GcwM0OJNSQDGK5+nGCNCbn6bZLVBhWQHLHRKzOqib+hlIOJPjZdFHzurqUn7Cl/a9S kLBvJhdcJufScndlzX19flxVRAyRK4nOllJ2q9O9b+zC2ijS0iflHZHclu9WUb1kjIv6 4ABeEfg0NDDjQ3VLqJ54+TByD2lVTW0vJsmdBw6T/pF70xNkCyDqCyY0/23xhLwwlTRB cElunLdW9S+AxFTPIqEYUGDWwZ9Hx+3M0Zk3xtr0DbQMKh+ohpB52bOI+UY61dr2jsNb mii95oHJohMkDso2NXL3Yy6z4tZzltELjHAmxsYsGNzGeteRZoTCl6xT1nQeqlFMN6BT FUGQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=di+pJtgG; 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 pe47-20020a05620a852f00b0078bc2576789si14566783qkn.159.2024.04.03.23.49.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 23:49:16 -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=di+pJtgG; 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 D5A123846405 for ; Thu, 4 Apr 2024 06:49:15 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by sourceware.org (Postfix) with ESMTPS id 5023D3858D34 for ; Thu, 4 Apr 2024 06:48:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5023D3858D34 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 5023D3858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::231 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712213330; cv=none; b=rXI828GC1QFsGTZ6ZRJXqSTb9yWabQG/vISPufboAMAn2lW/WUDjE3KkrXsKQY6sM9ehK3dadtGKjHV34Q43gOjSTBTFm1tZ9aOwOetUKk35cmNrPrfYLGERZUFMYn+SnFlEEDiziVtoXaEjzQLS+9FYlHjhEEonjFLo+DQ0IgI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712213330; c=relaxed/simple; bh=cw8HWoi0GK9IULJ9tjjvNvNLD3bq4hT65KiMLi9O98c=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=F2QTjALJX1iKlPQcmc3OuYw06s9RqHz38ccODqd11anNQkQeNFZMpsxU5BMWGHgh5+tZ7sI2IRjMCld1Cejs3nyOJnVtI7fJy4HOm6a8+1xKGvjq4Uv6rm+0N4yD+B3y6gXBIR6J5fqC9309iqsvBEGs8HIHbBz+Na/ycgmJd9k= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3c38eced701so335886b6e.1 for ; Wed, 03 Apr 2024 23:48:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712213326; x=1712818126; 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=nFpODmsS60D0MgO2Sq0vHP1Bf80f04kJ09zfTtn5e6M=; b=di+pJtgGQBNTkBlHWfiLaiDVZilWCZwJXDVacmmY9MR9VRdtCcBR410av3R8Av3xoh CwE3p1Z0N2MYbfZ/LtMEpF8U6k+K50nFcAKIx8Q6bhZjGB4Y30mI19ET6vJBKT5ubs4/ tveuRTjpmGT46muNhsqNGscs0HMtELcTRhQwqwftJvrbzLugdoKa6y+AtZ+C8exz7UFi W9eJRNgHMvkLqYroixhUhFCw7UAn+0uqhGshTpW4YjkFQKSiiEDVCXqp1JefvfcAB1++ 2bIpoWcWkydEW6WyOTUrw5cQtNFRfbWK8im5h7DZayWfOvQdIv3twLFTDpSofPCQkIIb zTMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712213326; x=1712818126; 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=nFpODmsS60D0MgO2Sq0vHP1Bf80f04kJ09zfTtn5e6M=; b=bMwdkhuaC5uZL7xlkPOLU6IQKEEtjVbzmHNYDArRvXgmeer/J22fmaxaFoda9teAzb E5tcwQh2TSle5SNtR9A5TP4jF/bS98x1k1ekNjovN6UrhZhYo/FPHkihL7lfKrTMsvnS 8l+uZruUlmhedlJbXMoRS3AzXKgMmy8y0taObjtOnpF8+Q1DzDtZB+/WLjdoiQqGdXgk CcKN8FOg+HTG5R/RTzVyzOhg2G42ceuGeSGaP2z0mLgvsBoISxkcgXYCTT/P8Ecb9OEQ s1k/5qF9AR2ZKOgQlhX5/Ip1wSd2g/gWGHe8anmx1IQYayacVx3aAHzfEpZnUuP6FZK8 MyYA== X-Gm-Message-State: AOJu0Yw9SluvbyAJzOX7+bxSo2WthaYsWi5AEYpZzQs6Gq/bRoNax4lv u9OuXAMmeP8Ywk2HXaxvrmAunWzGlPMCItaSnKuNja6Ad9XW8yQ7/eY22KzDrLof7BEFQM1eGzK k X-Received: by 2002:a05:6808:228f:b0:3c5:d998:6eb4 with SMTP id bo15-20020a056808228f00b003c5d9986eb4mr163714oib.7.1712213326231; Wed, 03 Apr 2024 23:48:46 -0700 (PDT) Received: from amd.. ([2804:7f0:b402:d0dc:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id n16-20020aa79850000000b006e64ddfa71asm13218899pfq.170.2024.04.03.23.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 23:48:45 -0700 (PDT) From: Gustavo Romero To: gdb-patches@sourceware.org Cc: luis.machado@arm.com, thiago.bauermann@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v3 1/7] gdb: aarch64: Remove MTE address checking from get_memtag Date: Thu, 4 Apr 2024 06:48:13 +0000 Message-Id: <20240404064819.2848899-2-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404064819.2848899-1-gustavo.romero@linaro.org> References: <20240404064819.2848899-1-gustavo.romero@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.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_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 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 4 06:48:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 785811 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp684669wro; Wed, 3 Apr 2024 23:49:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUMbh9NGlAXIur9th69oXH8huquXXAT6ITlN4BZK+V/yZTipLtP+iz2uETECtdGsV7PEbLIWLtjQ9j5mpgmbj8A X-Google-Smtp-Source: AGHT+IEtOJNx+A71XkSmHmu9C9JJHfm50m2tpYriJDTMx8VOaNGmVWlwxmBnMEGkitvSqjLdhCoJ X-Received: by 2002:a05:620a:4006:b0:78d:3c29:1522 with SMTP id h6-20020a05620a400600b0078d3c291522mr1926273qko.49.1712213378547; Wed, 03 Apr 2024 23:49:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712213378; cv=pass; d=google.com; s=arc-20160816; b=bbcMOsEM5VYK48LFrJQ3Pivdad+IsgDPUQqvScWB4I/kACxUU0clSxXRnU5962hra6 B86eVESU32F1gggo7me3+6ufmyJwTzqCQWOIoLxFJB+JQ0FJWNPhC1floFVxhN7yoiHA dO+W0xH9wHQ8CQxP5vz0+QDs3wZV+HnM/Qm0PCHZJT3WksnS4arByWaLscjRCoZv/80V F9xEOtPao+NuTXM3QX5TYBHRI5Zb14J+lLdWLYDoy8vMw3PnplwqURaLoceMdHYGqY8d wordyRIlfJM3la74Qm9xfacZw8dgY7GElp2NMPEJ6I2ScQh5PHpfPD11OsmsxshaOUlN qcyA== 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=DWYOE8EpQChfa8uCdhk5+693ODj8bGW6P79IkUH3wv8=; fh=ip7+QkkM488k9wyzFaZPu3h7BUQARzj44zdeG2KNIXU=; b=oeWBDP10CgzzShg3EMm+GimuzQ1CikPBeI3JA/yTL2v9q1oebLwtP6DoljBgiF0uo4 s76f+g2LdhnMDn5x9tEDuNa7ROzm9hhj06nEUIPa5iWwF3WThXmtTEdXYfkDhS7Ts4La QmlLjSIWuT3J6+CqaxHQlXbuxIaASNRTTZv5sZS2xdSZ4CVxyWNcTk705+KoDLO+JmyJ lzaKcB50LYJrlpqEEXCpum4Rd3wuGwNM3YotWiJicNvMYUiB1cnykwxrkpbv0n3KtFOw wofr/wqXMnC1dQKeXwRji2PwrsdkGSCjCv2Dt6o/WVKPKYDEYXAhhR+JeoG+0qbobmgT DJbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rZ1O04RU; 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 t16-20020a05620a0b1000b00789f94f2f5csi15457645qkg.783.2024.04.03.23.49.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 23:49:38 -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=rZ1O04RU; 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 2CB753846405 for ; Thu, 4 Apr 2024 06:49:38 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id C5C8F3858C50 for ; Thu, 4 Apr 2024 06:48:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C5C8F3858C50 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 C5C8F3858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::429 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712213331; cv=none; b=aVdSjAO7B2lfUs+pEQ6UO7KL8G4l07onsy/Npt+t+0J3KK6S5SzZAShvGPOszyNic7TlCLspI/BKWVYCPp/1YLdJGmlee7CW5ov8YYo+EhqCvA/xqToHGnybH+cPasNib2sqJUbbG6eyva9XTKdHzqfODYa6V+JHuxEady6UCWY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712213331; c=relaxed/simple; bh=lVZNgHHbt9wy4pZkjHuJ9gFQRh1DGKSeSPidKtEJSbA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=auL1QaSfq0KE8fxniXrbmVHKUNiYJZIKwDjjiSvFDarTXz+UWBQL1HdGN95hOAWbYU8HAr651ya7tHOjqHxttgZER3i/dqDIQbbsM9dVdHj+eFycPVZ/ooT+Yni4tfUn6HdOM1j69hFTxjhxYJyjQCE5pqDEp9qCxc/Ci3gES6s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6eced1dab1fso243899b3a.1 for ; Wed, 03 Apr 2024 23:48:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712213328; x=1712818128; 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=DWYOE8EpQChfa8uCdhk5+693ODj8bGW6P79IkUH3wv8=; b=rZ1O04RUtNflKQWdunKkvDOo58I1YiDrZ6L6GaWwd3BiIv3qDC0Q8mNlq3T2plo+5E AQ9fg6JPamUfoWj7DLSL4t8lxCs02a4NZwmh/PTMNoY4qdcwagc1KgYFf0xKVHdQff9D Wzks25MWEPuEFHpADbSOPfL8/a/qtMdoAn7QdEKCelpcZJruCKwleqjxrNBytd2Gkgur eeObViy5y7daEnU+l2UufiOEGuqMIDNBqis5bd9T4kAC1K9QN73xBdpwLwaG7RbuTva1 Jmrlevz2ZmIxhU6ICtmmMvsuYMsSdpwRE9+f0ToHnaHyGT48LKSHY3M4bUv5vLyNkmyq 9XBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712213328; x=1712818128; 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=DWYOE8EpQChfa8uCdhk5+693ODj8bGW6P79IkUH3wv8=; b=hl+nsEz6+TuVOsGfOVO0Ez3ByY7WSfd2O45yVFE0V2qchdIPbktz7BEEFzYzVuwyRz E9UrhAt8FxBmC2LWKN2iOxlpgW0OujjqfTH8Zr6z2zut+AiRdftUzSuv2KkhhcHcaNYY UheZwbQ2CLAlJKk+EBEC2S2W2BILIVfWoEFsL3zn9FFUZ6TLonz1n26ckHQSCJAgi+Cz +WT5p9Fy+ER6wUodZbnbekFvEelEjLgxebKGkaHJ6J967Ki+pqCrffW7sSrMGCHNAQt7 oohmrh4241Ksjb+rcUt6BTVDRUeCEylZK3SBhdZGPhuSlpiHOJdzFrbm0ASHp135Uo0V /Idw== X-Gm-Message-State: AOJu0YzlVRt/g0clDy8vvq0DHXZkaBvQUYIO80vmW4tQiyndLSms+I6D /xh3Si44Ki/26hYxvDEc0zd8rPf55GK3DvbuE/k3kTHuEXSL3S8O0E3D6zPC2ObYgFMBRYXmPwM y X-Received: by 2002:a05:6a00:1886:b0:6ea:be87:fd36 with SMTP id x6-20020a056a00188600b006eabe87fd36mr1708798pfh.1.1712213328218; Wed, 03 Apr 2024 23:48:48 -0700 (PDT) Received: from amd.. ([2804:7f0:b402:d0dc:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id n16-20020aa79850000000b006e64ddfa71asm13218899pfq.170.2024.04.03.23.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 23:48:47 -0700 (PDT) From: Gustavo Romero To: gdb-patches@sourceware.org Cc: luis.machado@arm.com, thiago.bauermann@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v3 2/7] gdb: aarch64: Move MTE address check out of set_memtag Date: Thu, 4 Apr 2024 06:48:14 +0000 Message-Id: <20240404064819.2848899-3-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404064819.2848899-1-gustavo.romero@linaro.org> References: <20240404064819.2848899-1-gustavo.romero@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 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 Move MTE address check out of set_memtag and add this check to the upper layer, before set_memtag is called. This is a preparation for using a target hook instead of a gdbarch hook MTE address checks. Signed-off-by: Gustavo Romero --- gdb/aarch64-linux-tdep.c | 4 ---- gdb/printcmd.c | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index 50055ac3f48..8e6e63d4dcb 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -2525,10 +2525,6 @@ aarch64_linux_set_memtags (struct gdbarch *gdbarch, struct value *address, /* Remove the top byte. */ addr = gdbarch_remove_non_address_bits (gdbarch, addr); - /* Make sure we are dealing with a tagged address to begin with. */ - if (!aarch64_linux_tagged_address_p (gdbarch, address)) - return false; - /* With G being the number of tag granules and N the number of tags passed in, we can have the following cases: diff --git a/gdb/printcmd.c b/gdb/printcmd.c index cb0d32aa4bc..774e3ec74ae 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -3127,6 +3127,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 4 06:48:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 785810 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp684615wro; Wed, 3 Apr 2024 23:49:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUO4bxDjMcU5cjr7gErkpUaVAtoH6FyGNgb99YZhaO8NC+PplScl2joGYYdkTg5NGQFNTtiCYo/uFPjqEULH/36 X-Google-Smtp-Source: AGHT+IG8j0uUSg2Ew9h4xD3MqYZH0oz9Kwc5OHbILQ8/opuQsjuw5rioVRBhEchZdGBIB14h3Ltj X-Received: by 2002:ae9:f442:0:b0:78b:d716:64c0 with SMTP id z2-20020ae9f442000000b0078bd71664c0mr1509778qkl.3.1712213369036; Wed, 03 Apr 2024 23:49:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712213369; cv=pass; d=google.com; s=arc-20160816; b=JOIAob87n8dtuOc0yBYvHmOGJkvBVs9S6m2Z1UdR27VW5Os9rWPxJPQi9IGS2t7Yjx Jab0okp1fsB0I7dDiAWA0jXX1l4a3udTvfSHBSlHNk1+Us3fGj6PUHloQAzvM22vNfgp T7ULAV728uOPZ3inbW18PxHDMdLStMsdCb0iR0Ow06i631nN+1rlCj5RRVQAnv0aRJuW v2uUSphAK1FOPBVvCxlTHU1G+Y6hYtYgHzFD1ghcyBtb22rEhvUSKIQ9KWdBC860pdFC juUz03x19OYzXqCWTQQsNgyvCwh+/BBHWvqvdCts3ry+mizvpGJc0rs1Cenoy/s0oI3N 54aA== 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=CkpJndIS961iAMYqy80lEUh7uV3OrKV2zpeEaXIJ8mU=; fh=ip7+QkkM488k9wyzFaZPu3h7BUQARzj44zdeG2KNIXU=; b=0ZcpEQU5SkwkCN6LngWqKW9faLlqWVkF20754f/Vnr7qnaQQzCd75ugpZ7ZjixgVwu rr1QS1lXSVtzZqzfkIqzGvs8QlfSq5JGOnAvxJ6C8jg469bqaFQa+6eaVkbhOZsCKuZm k6jIOCsmj1FUuL8xFzWZ/JF6QM+5KvAj2Nu6GSD18i6ZftgyOJU43hyToSrpwENB4dj/ 9xzI+69h7MwCJ2dm2fZ4cdBgRTHp/L1ar1yw/oQp5dtAHgB8MGFlZT1yzwhN9GXkIYHg U5VBQ5FF8XUYlm8k41C97tYqePpZQ2hIwbxLRKXabou6tzZpdnF0ge3GUQUjjmIHivud fqvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MIl5LrkE; 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 f26-20020a05620a20da00b0078a025958fdsi15502367qka.275.2024.04.03.23.49.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 23:49:29 -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=MIl5LrkE; 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 A78B93846405 for ; Thu, 4 Apr 2024 06:49:28 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by sourceware.org (Postfix) with ESMTPS id E215F385840A for ; Thu, 4 Apr 2024 06:48:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E215F385840A 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 E215F385840A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::236 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712213333; cv=none; b=q4f3QmK325omzM7ZCA2jtkz6UaD2Bz3/sCYNUl51f86Z/ENH9gDJ+HEmg2YomtE1sH4ewdofnst8tUlF3XG8w+i79wX/50z2LqcaP8xW6amW8PV5GHfOFV5bRHlwiOhxXkg+CCtmv9Gl8HTAobaOXFgS3Cwl3pH+WkEze4EJKjc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712213333; c=relaxed/simple; bh=m0zxqCy8ZHC4pqDMn5zPMAeOHRoB5JgRRsV+IvPQPCM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=cBdAMT2YC+EPnErO3wfTJVnN2P8YD3PSqESzo8ITc+MUa/cJ8StkUOTggKjXf6Z9bQt6STA2IzNUizdQXlyvZpDTUuYIpXIsp8gmZQNbKuu/fb8nazgMDHCmfaV3L1FyHVaMaZjvZI98qtpqh3OftaioeXUF4k59jhMdlI4I+fU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3c3e2e18db7so377936b6e.0 for ; Wed, 03 Apr 2024 23:48:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712213330; x=1712818130; 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=CkpJndIS961iAMYqy80lEUh7uV3OrKV2zpeEaXIJ8mU=; b=MIl5LrkErzFqCMBwR/1Boz/58FrG02lP3qxaJDK0Qmg/d+xFHg8bOGaiHIUwBzR1hp V4o7DpYCgLzIVUTjxO6PNRqj7FhRRdFJw0qOXOfSHiFfkT4DFNNSVzTn8MgPlhxecoch XUhtDuucKOKsXAGPnDYeRdOcqekhQwoh4EQ4d5cz+pEQr625STf+h2ymgNx+Wq9PEq2h J9XcI9uFJ1w7qCT9qp/71wADa4/5jmGosgu4wCTO7G2uQd5DvHw9SBcxZHxj+Di/7O9L lBEta+ogyTaBGbYcJ6dac72w9PmRzfMyr8MFUSAMZQkpy8BGAMawjCMbxycLikFzOMfv spIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712213330; x=1712818130; 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=CkpJndIS961iAMYqy80lEUh7uV3OrKV2zpeEaXIJ8mU=; b=Xezg1hy8sXaCfePta0Z6foYheuFnTNDb50j2aITKS8BBsH7qWGxVo3BLLbtOYkzFkM JgRtgsuFIYd8ftsGyLfL7uxRbOIYWi89brtsTLAyNiDZj3mgKblEvh8v3Ccmm/dyCJJR CJEVkG/3J2YCdm5aghcC92uylq9DQYzBC+lWnNHGPimYFtOsDyWHSItKBDsx0gZb/iyc J2uglPre/YVt2x72njp5rpPDGOJ7w+wzMo9lc1BV1VuYCdLknxt+xo9Lkgzl67JSw0T/ FoC+j5j9o1WwJNXCccNLSSkMhY/HJTRPdtwqswAFlpa1ptUfnlIMIK53UkkvRJkr5Zm8 ye2w== X-Gm-Message-State: AOJu0YzXluY0zO+xlywmqfhBlatc/OM1+f1ToURbvfwBkdTphoiUIvsM Ypo4tk1CMtpZ7bSzCXNUZlJez0yUbKK9OBzYd6LHHkKC55OPhWAXCAVpo35BAxFrl7aclh/EGU9 v X-Received: by 2002:a05:6808:178d:b0:3c5:d4e0:b295 with SMTP id bg13-20020a056808178d00b003c5d4e0b295mr1684394oib.0.1712213330609; Wed, 03 Apr 2024 23:48:50 -0700 (PDT) Received: from amd.. ([2804:7f0:b402:d0dc:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id n16-20020aa79850000000b006e64ddfa71asm13218899pfq.170.2024.04.03.23.48.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 23:48:49 -0700 (PDT) From: Gustavo Romero To: gdb-patches@sourceware.org Cc: luis.machado@arm.com, thiago.bauermann@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v3 3/7] gdb: aarch64: Remove MTE address checking from memtag_matches_p Date: Thu, 4 Apr 2024 06:48:15 +0000 Message-Id: <20240404064819.2848899-4-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404064819.2848899-1-gustavo.romero@linaro.org> References: <20240404064819.2848899-1-gustavo.romero@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 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 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 4 06:48:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 785815 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp684907wro; Wed, 3 Apr 2024 23:50:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXC9XhlUIsttJ34aYqrB92lSYIB9oZlGQKc5MMYhesboRdGE3gLFdZakMA2x/5isWSMlCOWlVdV30lVGaYPcGCZ X-Google-Smtp-Source: AGHT+IFKFo5VMcf+h1hwwpyX0zVlAK56sFH7d7C1TO4b/yvnCg4V3kMeb+hAFDwqyav25BARZWBo X-Received: by 2002:a05:622a:1887:b0:431:4e0f:2f2c with SMTP id v7-20020a05622a188700b004314e0f2f2cmr1658315qtc.38.1712213439834; Wed, 03 Apr 2024 23:50:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712213439; cv=pass; d=google.com; s=arc-20160816; b=Lr0+IE9tMkCHCdDJVq9OoJ+EAvpmUYxcgX2anbj3AKIFmsT1Fwxf4HIGiV/nh3bCJI eHZ7cGtngA3gCNlo4ObOfCoDWdkhJadzrymunvlddcf/qPoCEVRXEGGhvHSBC7YbubdV 8rWu+V7dzNMMidk+eY12jmWb6lMIwCz4AVEitiHJdni1bF5C93hSww0po9YUJxxZWV0F Nmee6gIUCDHknSEnqXr4eZSLAjLIempGcpMhXHl3LZN31GqZWzF8nMR5713vP2OJMswb ZYbK7iCAjYArU+kfc47JGbsqumwDX3dZzrraVVQTaOXgtMeBsd6Yl39WrymLRIulw8oi bNDg== 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=Qsh8ZoUkD9tLuOVPgVN9rMDq0Yb6rVyAgck6A3Y+ReI=; fh=ip7+QkkM488k9wyzFaZPu3h7BUQARzj44zdeG2KNIXU=; b=ejb/P06L2kjtwxGoWIJzggZI967EiGOD0CG1mhxTNi7dm7y3G1QPKuGKrwTzfL5Xe9 ffcRpaGNZV6ii0uaLAMzo33bUWm0mbqrAA6AMiiPgRJ0hagjYgrRrzB0nH5jh6Dqm2rv BykQUQLgJifC8Id3zvrMEhPwxyPOKwy+2We8hkrdO5HApUztN2oKpiQHsl/yB/jwtidu QEF2zKe+FmEeQbcE7QWzOvE90oDcwXp2YzV86Lfxai2HzF5pFctoQHzweiAr7R5zuolV v6430AoiEGhVL6zKRY17MPM1MJFRP0s16ffc1H8FppXDf5Jx73wXKaPMZYbtWts/16Cv uvig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z6EJ4RZA; 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 c4-20020ac85a84000000b004343cff2f05si4510197qtc.658.2024.04.03.23.50.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 23:50:39 -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=z6EJ4RZA; 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 73AB13858CDB for ; Thu, 4 Apr 2024 06:50:39 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by sourceware.org (Postfix) with ESMTPS id CDACE3858C32 for ; Thu, 4 Apr 2024 06:48:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CDACE3858C32 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 CDACE3858C32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::22d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712213336; cv=none; b=ZD84y9HpdFzJTReUJSXGosiub3CQW19A7GCVH8eriscLuxzeXt49BK7k+YrPOmbmUgC4jqQx3znvzLXEGS3vaVx5SCkJxHsWy30Bi0EcxY/AkirFQ5Uy7TfwurZeGT3b2nGB8k+OgbMEWTgxjXBnXS7eGRrZtSB/PExVG0hwbQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712213336; c=relaxed/simple; bh=biB/Jfk29K6e4bngrml/SPgQBP6fEkIBiEIcROOxMhU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=EugjnrosbqB93TlTawX39GPKoYjgREgkt6YEZFiTjkdmeA1GzBjEiDuUs0qnhWmcNgPiCQoHvp7n1rWEGDPyejjIf5AzVIrbEmwN2CIfalgiV0j84/szyKVcs9fiYuLkPqUec2c7a0y+QAUA5ngpFIcMmJvAW/TfVDixT8aoRjs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3c5d50e190bso371273b6e.2 for ; Wed, 03 Apr 2024 23:48:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712213332; x=1712818132; 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=Qsh8ZoUkD9tLuOVPgVN9rMDq0Yb6rVyAgck6A3Y+ReI=; b=z6EJ4RZAXLQeMwT3Ppof8s4KbJKwkXAfHK6UFO2IvjP3sRMwo+G6dV9DqZbrGwmFHa Cwa6ifP/KnUNDg1nJHdP/NQO1B2l7CUwdknBGDzbuydGAL0Y4FmjodoXbxLWFMmH0ljw 7NglU1Pl3fL/2WfE6TIoJeG9F69K4WS9flNotQoQmD9hROT+hgVkhAaYgXiQN57krgGt o3YRMGbRasS49/V0BNaB/xp620FJaE4cogSE/pZ/NNV0ZEqk0gAdePUw7vIz36+sLFVY x9q05lFF+lkeOGEI9LK9Dir+zWt//RyPY8Auy0400cvX1VsfSPKp8N7VNitXTml4Vkdn zwoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712213332; x=1712818132; 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=Qsh8ZoUkD9tLuOVPgVN9rMDq0Yb6rVyAgck6A3Y+ReI=; b=aP+jlVhbRPudywN/XKNocV/DaAOLi6vsUt2RKCnLoBn6U4bhp1cgcZZNgiRW0wRuH4 8GiXn97ZnN243YCSZYjT/8yZzmCh+De72N1Pxuhkaf16OoaG2grO1vq5BZLbNIDyy9Dl 62lemRKZuubWfAq9VVvpfXV3CWlznad3GZ/duOGwxs8as6n0xWYjL3IalLGnMUee0sk6 XWRglBsy3eMpFEX47TtoOahWSC+FthXqrpEwQ7We9M4dGt5BBJ0KqLsBxCdCwScsvBQN THSI87icoSQVh8gOGLzSZdQqKcIXvh4aDmBp1orUKQMmlSL/WZGK1wKobN/V6nZHGgAe JXQg== X-Gm-Message-State: AOJu0Yy4ehPZ7We1Tz8Wn3qQygECvAlUnQOilAkrrAwgM9Gd1CpBoLRv e0kH5AFCWT877Cx3+qe/1M58BBQiXuLSv4t2aRqj0BhGta86+0KvciqyuDoVqekzZZK40IudxS1 c X-Received: by 2002:a05:6808:1587:b0:3c3:c594:d924 with SMTP id t7-20020a056808158700b003c3c594d924mr1544711oiw.8.1712213332533; Wed, 03 Apr 2024 23:48:52 -0700 (PDT) Received: from amd.. ([2804:7f0:b402:d0dc:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id n16-20020aa79850000000b006e64ddfa71asm13218899pfq.170.2024.04.03.23.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 23:48:52 -0700 (PDT) From: Gustavo Romero To: gdb-patches@sourceware.org Cc: luis.machado@arm.com, thiago.bauermann@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v3 4/7] gdb: Use passed gdbarch instead of calling current_inferior Date: Thu, 4 Apr 2024 06:48:16 +0000 Message-Id: <20240404064819.2848899-5-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404064819.2848899-1-gustavo.romero@linaro.org> References: <20240404064819.2848899-1-gustavo.romero@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 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 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 774e3ec74ae..62fbcb98cfb 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 4 06:48:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 785812 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp684736wro; Wed, 3 Apr 2024 23:49:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWbIbTattTpxuFhfajxMWUToeLSWU9MRu2c7fDAsWPalGAyuL7ztgME8DYxB1ugw6IJJGUPHYqeHmWyUnpvhExO X-Google-Smtp-Source: AGHT+IF+fCy7V3gSxJG1hCXJPy+XzErwO6mEFLeU1/vEBmWzAIjUdTaar7GimqGlb15/8YeUNdPv X-Received: by 2002:a05:620a:5dc2:b0:78c:79ff:ded8 with SMTP id xy2-20020a05620a5dc200b0078c79ffded8mr1524113qkn.53.1712213396013; Wed, 03 Apr 2024 23:49:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712213396; cv=pass; d=google.com; s=arc-20160816; b=YxOnIKdVdQOPIhXy9otGY+jNE0jTvLS52fOj69bLCcnivozYDExqZENmQAw3HTIbHq lPBUJ3YDgeAjsCLA91e8i4yZmRTmwKrlaF3bOx6DsgZ1K2MRX+vxXZWrQQqw3of7brjV /3MEWwuiD9+kRZ6nM2hgIaDEYdln4+adk4my9a9DCtX5/Tnsv7Uoqf42g9h8LwZ1MdAM Qr9T5aS18DbyhKNvvdKpR89GbMswtbuNg6T1k6slKCAGqFEayAyEW2XmWNMXrvlTR5XJ IE9AbUtH/XVg8B/MrSwAIhomKecWPkBnJl9W5cpCgTpElf0jrTqVQsk5vs+BsUxs4uxQ 7LSg== 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=y5RxHf8Te57ZG0LVVGGa3lEh2+B6GPPEi9wprQMp6Zg=; fh=ip7+QkkM488k9wyzFaZPu3h7BUQARzj44zdeG2KNIXU=; b=OTHE0ydBsAP74xYf+/GXiocqp8cTtSlrnjhNYJFvKfmWr+gqOl1vvz+cwRHExT9YjK jakpLo70zUmirbXh+1CDqMphBRGmfHtRcYZIWVZ1G/mwsgaI9D4J0QfbrFD6bM+9Rdeq yIvsAsMD6lDTX2L1leHyiCHoMrk2t1Bl2mZcH6kg2gCnUTJVxvGE0ZJQQfemVT2EjF4Z YurNzylrQ1K7pUs1KmQhME+Cn4PKZORoC/TCjDLZFWrc6fslI5lwNKSbIgQDyEmkqlSd DK10CrhvhDVtLny639c51XtxX8EJ9vY1+Oy+gvtz+HgQP67BNQKHX0Hrnd2KSvF8Lu+4 tXNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wOFgm2Qh; 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 e19-20020a05620a209300b00789e55e913bsi16249699qka.252.2024.04.03.23.49.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 23:49:55 -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=wOFgm2Qh; 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 A0D85384646C for ; Thu, 4 Apr 2024 06:49:55 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 314E73858431 for ; Thu, 4 Apr 2024 06:48:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 314E73858431 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 314E73858431 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712213340; cv=none; b=qcO3d4a/0yEO/1AE0wItjROt0cuyUDfha34W9acjDsnTDdK4sEFy1+qZcUPdPFA30r8fDFiaLv6z7rbrkjdR/Mn2v0BNJusfziCvUCg5ak8SbORJ8JzZBIJHlYMXQZ94bqVOeVI/B1M3WtTbR9ZvBdjA9iAQg6FXEPtK4+e8Rh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712213340; c=relaxed/simple; bh=GkPm58lENjYBRJ/Pccx/Ww0JCKlD9pYQWA6CfG5H0I8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=tyURkoJZx5DzDSqDJ2wLRsgxE0flNERGh/CEY64maBAb7KOfVK2HYkEtCkL4F9DByglDFj4A29gAwu2twQl5qsPKuy3VOvhLSqahSn1tO2fL3GMuePnZ5IVriZk5ePfxa6UfBtYftF4K4BelGTRiwwdTPtW0NpuVNBBfoXgt7HQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6e6fb9a494aso581899b3a.0 for ; Wed, 03 Apr 2024 23:48:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712213335; x=1712818135; 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=y5RxHf8Te57ZG0LVVGGa3lEh2+B6GPPEi9wprQMp6Zg=; b=wOFgm2QhIJz8luPDa9QcoluhksY10QbVbYuPtC+9uqJc1A+u+/5PHbym7OsUwo8nC+ AdqtkmUNqSItyq+JIamNZH9ug4DuaGpMhdrFiu8obppjlUW8AWSNR0OpxFiiPn3GhsTh ImpciKU9QzBiF3Fm8Bv3dF9fBi4xjMgRG5EvBonD9ky0n8HmvPh0M2Ac4hQeqHst/yKF OAaFGyajVp7qRp3bITiCfELAXESgjvw39vFkMiCo4+p77nXZ2NJ5RZeLJOOpA97x4U4q Np6iOeDD2kUWwCdh+zXH6c3zjUJaL4bp2Cgpbt7t5YjYWNbGfhEqLE8sM0Reywm6PGEj Ulbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712213335; x=1712818135; 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=y5RxHf8Te57ZG0LVVGGa3lEh2+B6GPPEi9wprQMp6Zg=; b=SG064VbXHYUvLBRhiOENq5RG+f6789gpPi6cSjYFv/HLfGyaCWaTnEd7+GD9VC2FMf DYswQbkQQFuEg+IFWrif+tInnpKKvdBVaXW7Z+GPJ+g4zlL4ioCfPi9dN8CB15QKJZQx wO8oYQXQPK5GFp6k2QVq5eTGmcPJ4q+kUvmNev5eGTU1RlWpbGqymtRTyFaGxGNCjYG4 uMb9zC9cD8UvsjbvmdTpNUhFCnz8kIiB42BqAcA/vrZqHyqaK6GHe7HsAdNs1xGbvTuT eWiBVAakN1V4fJTC/l4kgv8eMnPCIIjCyNVr2QLtSCw/cOj3RH5JdLF1zBmUxYgrfqm0 6DZQ== X-Gm-Message-State: AOJu0Yx4YJtCoBTxR6s0UOrzC0ZsUbArFU522pgNqNYyug0EuCGDPG0J D7FQtbZs2Ay88SFmop8KQkIMw/HmA7u8m83CcfHR/2IsXZUUDuqLfX9xZiBQx+gQMXWfLGCoLeF K X-Received: by 2002:a05:6a00:6902:b0:6ec:f094:753b with SMTP id hs2-20020a056a00690200b006ecf094753bmr370722pfb.24.1712213334579; Wed, 03 Apr 2024 23:48:54 -0700 (PDT) Received: from amd.. ([2804:7f0:b402:d0dc:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id n16-20020aa79850000000b006e64ddfa71asm13218899pfq.170.2024.04.03.23.48.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 23:48:54 -0700 (PDT) From: Gustavo Romero To: gdb-patches@sourceware.org Cc: luis.machado@arm.com, thiago.bauermann@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v3 5/7] gdb: Introduce is_address_tagged target hook Date: Thu, 4 Apr 2024 06:48:17 +0000 Message-Id: <20240404064819.2848899-6-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404064819.2848899-1-gustavo.romero@linaro.org> References: <20240404064819.2848899-1-gustavo.romero@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 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 allows the memory tagging address checking to be specialized easily per target in the future. Since target_is_address_tagged continues to use the gdbarch_tagged_address_p hook there is no change in behavior for the targets using the new target hook (the remote.c, aarch64-linux-nat.c, and corelow.c targets). 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 --- gdb/aarch64-linux-nat.c | 8 ++++++++ gdb/aarch64-linux-tdep.c | 10 ++++------ gdb/arch-utils.c | 2 +- gdb/arch-utils.h | 2 +- gdb/corelow.c | 8 ++++++++ gdb/gdbarch-gen.h | 4 ++-- gdb/gdbarch.c | 2 +- gdb/gdbarch_components.py | 2 +- gdb/printcmd.c | 31 +++++++++++++++++-------------- gdb/remote.c | 10 ++++++++++ gdb/target-delegates.c | 30 ++++++++++++++++++++++++++++++ gdb/target.c | 6 ++++++ gdb/target.h | 6 ++++++ 13 files changed, 95 insertions(+), 26 deletions(-) diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 3face34ce79..19c099832a5 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,12 @@ 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) +{ + 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..2a47c3f0845 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -2451,17 +2451,15 @@ 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); + gdb_assert (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..b13d0124471 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -109,6 +109,8 @@ class core_target final : public process_stratum_target bool fetch_memtags (CORE_ADDR address, size_t len, gdb::byte_vector &tags, int type) override; + bool is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) override; + x86_xsave_layout fetch_x86_xsave_layout () override; /* A few helpers. */ @@ -1410,6 +1412,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 62fbcb98cfb..24eac7c8421 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); @@ -3104,8 +3105,9 @@ parse_set_allocation_tag_input (const char *args, struct value **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 (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); } /* Implement the "memory-tag set-allocation-tag" command. @@ -3129,8 +3131,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)) @@ -3157,12 +3160,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 (current_inferior ()->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 e278711df7b..9717db55e27 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, @@ -15573,6 +15575,14 @@ remote_target::store_memtags (CORE_ADDR address, size_t len, return packet_check_result (rs->buf).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 4 06:48:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 785814 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp684858wro; Wed, 3 Apr 2024 23:50:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUGnsvvhCpM+flcK3FlgS02/xwCwEoIcnEh7T1uiqD3hghALWcLgTohSumoY1I0uqhT2SFJHprwugDLj5MdIlhW X-Google-Smtp-Source: AGHT+IFYX2Lehpq5MduLRgMXXSCaxZkSNUx1kmyucL/ezh2vPCyIpgXcGulpxEa/PwUq/665/T1n X-Received: by 2002:a05:620a:2908:b0:78b:e896:d6dd with SMTP id m8-20020a05620a290800b0078be896d6ddmr2181348qkp.44.1712213421838; Wed, 03 Apr 2024 23:50:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712213421; cv=pass; d=google.com; s=arc-20160816; b=Cwg1FupviJyszvqFaRrm6hYlKlJ1PwzarfsyS+gaJCYxOFUcTyLuAwBGtn9QUkBigT eBrSuls21fRLQowCsmmbdezcPk7ZcwWEMI7TG5dBeKUdef6XzEW1K/bGz48LHljJnKf9 EvHMkKjboPYEHVDBPieaXvGn/DSRKAcxjR/ZecpEBEXv+kPwASY+RIttpL56YWLsYnxd 9NwXTTw1RsyVbxt/l5pT1NcZSrk7N3u/75vy5Aps0TY2WhIXLZTNdtUXUe7GGi6nGOQW hIdbHX9omdUftqLCKReSiPo0YlN+SKlfKNW6XrwVkIFsQJOybIJapeMXZdc3H+zu2Hsn bSIg== 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=9HZMYDqkUwPT4I03LFdl2g+FeiecaWvFzIFhBbXjTuA=; fh=ip7+QkkM488k9wyzFaZPu3h7BUQARzj44zdeG2KNIXU=; b=Fu0yzpFbzOZeu05dVFfJRd1dV1SyHaUDBkhPXqiYcCtV8AQxeuk1gcmUK+YWoVuK17 9XnUjictkq+l8mikzwGz1aKjucz2/UGGnIwNHNmfg8zvQfqaNuaVoAZgQx4ejOeqcgfr 89ZYTXXhXH8fXbykd4lZhClKE6FQQHctc63N7rks7S2yiCdC7IG3Loc2V1PPfDwPFDPE 2D1tyZC4baVn1Q8BuWiOpd+7bwUNe0ZrlZ4RGeC01+zkMgMuB8oXpPT6VBN59Xyla7Qu kNFm/T66yvSOaML/k63idbuI1wwdXsJYLYXowvsOP890tosE3hNKrDF5z3EZgMRiJNba q2bQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MRVtVSzw; 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 f2-20020ae9ea02000000b0078a5ed3ccc7si1805757qkg.518.2024.04.03.23.50.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 23:50:21 -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=MRVtVSzw; 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 702BC3858402 for ; Thu, 4 Apr 2024 06:50:21 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by sourceware.org (Postfix) with ESMTPS id B659F3858C78 for ; Thu, 4 Apr 2024 06:48:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B659F3858C78 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 B659F3858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::22d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712213340; cv=none; b=GjDqD5IvprCBjyyjXo4jge0GydZPhiCgpl4KqCAqDViIUMoRvaSdcL/9//AYnHteuNTMAQL7iPzp1axO/NxVKprtIPqfBy/qHHqqo6svGJZ5ShV7tazEqOTG1S6r7zL8I1Jpa563bFDFfmxyIgu5Bvg4O7bE4EyFIU4WjmPw/f4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712213340; c=relaxed/simple; bh=RvB+lC1m3hkqCZBVtyKqnaR5Y+gsr0I7EO/5NWNjmEY=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=VcvjAMAQFHMuHlRHB1laTOntAWhZN7Yn9+zR4SZe4SBZhxZbJzbL2PyVPu7aiD+pfI7yE/Zc3WTuRoyWqTdVN5/9r8BY+iC7cGcG5sHAv7C18HwLSKQCBHUOaw8ZIcFFG+LqtR9I2KpEoMmH6zoX/5K8/Tx2hwI+20mhHpAHDFo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3c3d7e7402dso469541b6e.1 for ; Wed, 03 Apr 2024 23:48:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712213336; x=1712818136; 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=9HZMYDqkUwPT4I03LFdl2g+FeiecaWvFzIFhBbXjTuA=; b=MRVtVSzwIkHChaTkpPumPmiKzCw+XQf+q1/6d2eIRMxJicTd2LHsBEA3v3xD9W6G9H LfmdaHuWBthwhPFG/9HZK1d61HvVEQlGTenjtCdewA6keTMMuRy+j73ZfeV9uClFLAJW OYZMgMiGumAJ4jvFWkgI5cZ9ScW2ZLgbnkbZlf7x2NScNIM49VrK5cyXOFfqjgd5haOx l2btAhZm3Qf9sId9Fup9dZua3SWK6jqAyFDjZ8v11X63rby5SxBQiHeGgpyPvWuEUudI 1JHbIhVSDx6gqXFMYNY9Y3lzI8kVZoHI2xgmAK9FVz4cCgWBGFY1bggsppwv8zrSLsle k3gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712213336; x=1712818136; 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=9HZMYDqkUwPT4I03LFdl2g+FeiecaWvFzIFhBbXjTuA=; b=Vc0t3ciuSymiIXXrSgogqaKRkIBjKerG0v/O3TNu6RvuRVWyJNOxbwTX5Zb1HRYcuI tmxHbV/AK7LMTu49B9XA8blVQ593dA+EMUKSmhGPizgmtgUWZlz8OSAdJD88cUJt1QQ+ 9pT6y690Jl8WYUj9fMO3ug9NQiSOW8zM3DAkFWkJ/j3xVehsZNQnf+pCK9oTI6facnkg bmD1n4yhs5c0xKU2UhNt0B1j45hv7hGETc+QPlkGf4e3c9OSyyCm+hLwUN9p5P3sOS8C QXT3tM0yMk/TGKrxJ/3E8cZU4Adu1utBR0UtFyf15P5eX2lED51zjl+Fmb6NevmE+tpa K1WA== X-Gm-Message-State: AOJu0Yy4z7NgIiU0Pdb8R1NbRj5ebwJmzXvWv1N0FiZPIGx/LfVyArCR D4FVFFSSfh3sdMyvA9OPpqrDhwy4tv4UNeEMrSbMnD9MKzkQBCJSfNyi3QSZ4izKnCcm7qYF3iZ + X-Received: by 2002:a05:6808:13c9:b0:3c3:72ec:cb60 with SMTP id d9-20020a05680813c900b003c372eccb60mr1792640oiw.49.1712213336590; Wed, 03 Apr 2024 23:48:56 -0700 (PDT) Received: from amd.. ([2804:7f0:b402:d0dc:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id n16-20020aa79850000000b006e64ddfa71asm13218899pfq.170.2024.04.03.23.48.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 23:48:56 -0700 (PDT) From: Gustavo Romero To: gdb-patches@sourceware.org Cc: luis.machado@arm.com, thiago.bauermann@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v3 6/7] gdb: Add qMemTagAddrCheck packet Date: Thu, 4 Apr 2024 06:48:18 +0000 Message-Id: <20240404064819.2848899-7-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404064819.2848899-1-gustavo.romero@linaro.org> References: <20240404064819.2848899-1-gustavo.romero@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 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, qMemTagAddrCheck, allowing GDB remote targets to use it to query the stub if a given address is tagged. It also adds a new GDB remote feature, 'memory-tagging-check-addr', which must be advertised by the GDB stub to inform it can reply to memory tagging address checks via the new qMemTagCheckAddr packet. 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 qMemTagCheckAddr packet allows checking addresses in an OS-agnostic way. The is_address_tagged target hook in remote.c uses the qMemTagCheckAddr packet to check an address if the stub advertises the 'memory-tagging-check-add+' feature, otherwise it falls back to using the current mechanism, which reads the contents of /proc//smaps via vFile requests. Signed-off-by: Gustavo Romero --- gdb/remote.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/gdb/remote.c b/gdb/remote.c index 9717db55e27..94ac8520740 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 checking if an address is tagged via qMemTagCheckAddr packet. */ + PACKET_memory_tagging_check_addr_feature, + PACKET_MAX }; @@ -758,6 +761,10 @@ struct remote_features bool remote_memory_tagging_p () const { return packet_support (PACKET_memory_tagging_feature) == PACKET_ENABLE; } + bool remote_memory_tagging_check_addr_p () const + { return packet_support (PACKET_memory_tagging_check_addr_feature) == + PACKET_ENABLE; } + /* Reset all packets back to "unknown support". Called when opening a new connection to a remote target. */ void reset_all_packet_configs_support (); @@ -5764,6 +5771,8 @@ static const struct protocol_feature remote_protocol_features[] = { { "no-resumed", PACKET_DISABLE, remote_supported_packet, PACKET_no_resumed }, { "memory-tagging", PACKET_DISABLE, remote_supported_packet, PACKET_memory_tagging_feature }, + { "memory-tagging-check-addr", PACKET_DISABLE, remote_supported_packet, + PACKET_memory_tagging_check_addr_feature }, }; static char *remote_support_xml; @@ -5875,6 +5884,10 @@ remote_target::remote_query_supported () != AUTO_BOOLEAN_FALSE) remote_query_supported_append (&q, "memory-tagging+"); + if (m_features.packet_set_cmd_state (PACKET_memory_tagging_check_addr_feature) + != AUTO_BOOLEAN_FALSE) + remote_query_supported_append (&q, "memory-tagging-check-addr+"); + /* Keep this one last to work around a gdbserver <= 7.10 bug in the qSupported:xmlRegisters=i386 handling. */ if (remote_support_xml != NULL @@ -15534,6 +15547,21 @@ create_store_memtags_request (gdb::char_vector &packet, CORE_ADDR address, strcpy (packet.data (), request.c_str ()); } +static void +create_is_address_tagged_request (gdb::char_vector &packet, CORE_ADDR address) +{ + int addr_size; + std::string request; + + addr_size = gdbarch_addr_bit (current_inferior ()->arch()) / 8; + request = string_printf ("qMemTagCheckAddr:%s", phex_nz (address, addr_size)); + + if (packet.size () < request.length () + 1) + error (_("Contents too big for packet qMemTagCheckAddr.")); + + strcpy (packet.data (), request.c_str ()); +} + /* Implement the "fetch_memtags" target_ops method. */ bool @@ -15580,7 +15608,27 @@ remote_target::store_memtags (CORE_ADDR address, size_t len, bool remote_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) { - return gdbarch_tagged_address_p (gdbarch, address); + struct remote_state *rs = get_remote_state (); + + if (!m_features.remote_memory_tagging_check_addr_p ()) + /* Fallback to arch-specific method of checking whether an address is + tagged. */ + return gdbarch_tagged_address_p (gdbarch, address); + + create_is_address_tagged_request (rs->buf, address); + + putpkt (rs->buf); + getpkt (&rs->buf); + + /* Check if reply is OK. */ + if (packet_check_result (rs->buf).status () != PACKET_OK) + return false; + + gdb_byte tagged_addr; + /* Convert only 2 hex digits, i.e. 1 byte in hex format. */ + hex2bin (rs->buf.data (), &tagged_addr , 1); + + return tagged_addr != 0; } /* Return true if remote target T is non-stop. */ @@ -16066,6 +16114,10 @@ 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_memory_tagging_check_addr_feature, + "memory-tagging-check-addr-feature", + "memory-tagging-check-addr-feature", 0); + /* Assert that we've registered "set remote foo-packet" commands for all packet configs. */ { From patchwork Thu Apr 4 06:48:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 785813 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp684744wro; Wed, 3 Apr 2024 23:50:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWssgGDDrAPsj8uSJxGs4VwoSCPpYRCYpOwn5om3kDoIgWyjVZibnDQsC7UXmUS/ZnsIF2VHqXpOMHjiRJtvd5r X-Google-Smtp-Source: AGHT+IGfNmNI/S0Ggquo5QpBtOMTD1XfeHy0AjQGCqT7MjL12GInYjvY5euyRE6GmviO7nh10CZ1 X-Received: by 2002:ac8:5c8a:0:b0:434:338b:6be0 with SMTP id r10-20020ac85c8a000000b00434338b6be0mr1608946qta.8.1712213400840; Wed, 03 Apr 2024 23:50:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712213400; cv=pass; d=google.com; s=arc-20160816; b=BrhYKVyeSRbrcaCxr4S03z6+Z9VoLJYgHU5+CFSlK2OvP++d49IsddKaiF1qiXZkDK wtbqglUF42IED4BI6ENmFlJ6AE4Oja3sInFSwYiSZsNHoWd6Tj7TQAwQxQWsVKj2banC Vrb1AA0CIQ6t9CBqwEfgZFkp6LI7+eRmHPL7yh9QlPXcKaeLCHLFXqO8kRXQgDoOal9M UIHWyrr879nER9PPoPuwvsku5jCy8OAMVjpw4anvQo7RSRd4fMCOKk8q+emPPlpjg3GI /KLNr6RNZyIP1CKJhJB6Q7CDUw3VEX8pwQSixroAnaCcfKu96go7csTTr02N8FKG0o+j Y8xA== 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=XWjkfvtd9SBgDUnFrV+O02//Ju3oUvg/eI1DG3feFo4=; fh=ip7+QkkM488k9wyzFaZPu3h7BUQARzj44zdeG2KNIXU=; b=1GgcxGNcZBaC3V8CNqnFALgnrxAv4kHoEPemsn3zz+Z/ynha0lxbD8CVkJiNuhdIIe SZTW+SJbxtscM41iY67rXqmmUhycK4v5sO5cCWVipeij6YCIOiwNAGz4mmQd/UEghICq LJGgbF0JdvVugRhbF0ww0XO2ioKsNgE2ANmT6+o/SAiW46BuymT0OC6JmGIO1vN9x7Zp Y552sGpdlEL4I3BtO2R6vA2tJo8AU1htwTWZy8WmnSytRPZqw3UHGpJKIiB5A5LbEB1p DCMbVxtvchN07x7mNksodr3wKHIGgwumKQ8/VjS3DuJHDvsKayprqwiHFUAZD+70AJr7 9pLQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fcaI1r5V; 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 s13-20020a05622a1a8d00b00432d2f8478dsi11100731qtc.375.2024.04.03.23.50.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 23:50:00 -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=fcaI1r5V; 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 77B683858294 for ; Thu, 4 Apr 2024 06:50:00 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by sourceware.org (Postfix) with ESMTPS id 4758F3858C24 for ; Thu, 4 Apr 2024 06:49:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4758F3858C24 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 4758F3858C24 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::2d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712213342; cv=none; b=XrSSBhdrlr4QuUn6Il38xMwZm7+IWCxv4VhDuCFTEYCBi6JTurzXSAmPK6L+khI47atH1uLXQ8j273xC8RLbNVvDIMm3vFsewR4vpl35yEU5srG3/nh4SzBTvFXtxmhWG7kUxHYgdYUWO/jrIxeR5/qU3KWINGwfa4qWmDOj894= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712213342; c=relaxed/simple; bh=25R6Lo0ZPs6vmg7inSkR1rYr1lXnedOqF4np2mkyvmc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=fbSxG4q9ioOMU6cVzYnOvqXO932RRhZmaeznSxRbLNNW/umgRqiWai9EjoEgxY0oCFSMSBqWgQTnc6atp8SbjmDQiiQfhk13GdmTxKwQlqujmNGxp+HnqIW+lx8xQYszbIORWUHev5gnAVknWMm8xjANLjk8V9hbFg+FsOHW2zc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-22a96054726so569740fac.0 for ; Wed, 03 Apr 2024 23:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712213338; x=1712818138; 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=XWjkfvtd9SBgDUnFrV+O02//Ju3oUvg/eI1DG3feFo4=; b=fcaI1r5V1uPf/PsQI86iyjuZkj2naT8NiLJj/Lssasio5ls/j2ija0syhWX4LAj74B txxl9nIkDudon+Ahv9TTnOChvxgeDmEbw9p/jGJnXrZtxFc3XimmfVzI65RdTkv6S776 yH/k600mN1yvoTIRpyqvhQNizMNxYWdQSaOrNFaG0PSzxAUb8z3xs/nd+/A9Y0aJK4Ax lLB3o3FoHLho76Km7+KpHW5U59NVEmnHFE5mTdPm6Bc8jQrrqSDd8zZ3lTsYMHyXbzF1 QyPqupMAZdjATogTBNRpwJQvKngCOZ0QJ0rI0SDqa3L1m1hZ+gB6WvsHkztFTnqa0yEA JsUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712213338; x=1712818138; 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=XWjkfvtd9SBgDUnFrV+O02//Ju3oUvg/eI1DG3feFo4=; b=f/9hQdhofzwzcYOJrP7pXtLB/1Rmpteo0dD8aaODBN/R7VsFlddf/AoyMJM88fIwqB g8wQFh4HhsSRrF/7JZdBv74nU4QhINMAPSwkUsYX7EtueCDV0ZZTFNFcIgDAYc/1z4A5 o7Tu3qQJtJvvanyNmGmK3rxOpW3X5JRyi3rdbbuFpi4djXa6ZwmveTrz1xHMHCsREp05 7IyxTFbmhceoGy5NhzLyxs31LUOk8hxfo6iZJhNsbhUKyX7OBZHv+/o18C9U05xoEGhi wNHVsMllMLqukByo8PBtvSvkHmyILSn4eLiVlnGRXl4rvn65ZyWsAwB1efEeVqlw/kaI y/Ig== X-Gm-Message-State: AOJu0YzoQkefJ6La7Fu6vN6s+Gh77P9L8C5LiSJqY1Bxrd+pdOUFF4NG 01A16AlUq0/V/nYQYcI0HZRzgEWYYMKecZEMjMUU14VllLP/BW9L4dbS1HVLB2q5z4ydbwn+/IT 6 X-Received: by 2002:a05:6870:9e91:b0:220:8d82:3838 with SMTP id pu17-20020a0568709e9100b002208d823838mr1702286oab.28.1712213338607; Wed, 03 Apr 2024 23:48:58 -0700 (PDT) Received: from amd.. ([2804:7f0:b402:d0dc:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id n16-20020aa79850000000b006e64ddfa71asm13218899pfq.170.2024.04.03.23.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 23:48:58 -0700 (PDT) From: Gustavo Romero To: gdb-patches@sourceware.org Cc: luis.machado@arm.com, thiago.bauermann@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v3 7/7] gdb: Document qMemTagCheckAddr packet Date: Thu, 4 Apr 2024 06:48:19 +0000 Message-Id: <20240404064819.2848899-8-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404064819.2848899-1-gustavo.romero@linaro.org> References: <20240404064819.2848899-1-gustavo.romero@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 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 'qMemTagCheckAddr' packet and the associated feature 'memory-tagging-check-addr' that informs if this packet is supported by the target. Signed-off-by: Gustavo Romero Reviewed-By: Eli Zaretskii --- gdb/NEWS | 9 ++++++++ gdb/doc/gdb.texinfo | 50 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index feb3a37393a..1158715f41c 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -192,6 +192,15 @@ QThreadOptions in qSupported QThreadOptions packet, and the qSupported response can contain the set of thread options the remote stub supports. +qMemTagCheckAddr + 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..afd57ff874c 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -44093,6 +44093,37 @@ 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 +@item qMemTagCheckAddr:@var{address} +@anchor {qMemTagCheckAddr} +@cindex check if a given address is in a memory tagged region. +@cindex @samp{qMemTagCheckAddr} packet +Check if address @var{address} is in a memory tagged region; if it is, it's said +to be 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 are in a 2 hex digits format. + +@item @var{01} +Address @var{address} is tagged. + +@item @var{00} +Address @var{address} is not tagged. + +@item E @var{nn} +An error occurred. This means that address could not be checked for some +reason. + +@item @w{} +An empty reply indicates that @samp{qMemTagCheckAddr} is not supported by the +stub. This situation should not occur because @value{GDBN} will only send this +packet if the stub has advertised support for memory tagging check via the +@samp{memory-tagging-check-addr} feature in @samp{qSupported}. +@end table + @item QMemTags:@var{start address},@var{length}:@var{type}:@var{tag bytes} @anchor{QMemTags} @cindex store memory tags @@ -44914,6 +44945,11 @@ These are the currently defined stub features and their properties: @tab @samp{-} @tab No +@item @samp{memory-tagging-check-addr} +@tab No +@tab @samp{-} +@tab No + @end multitable These are the currently defined stub features, in more detail: @@ -45141,9 +45177,17 @@ 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{memory-tagging-check-addr} feature (see below) is not supported by the +stub. Access to the @file{/proc/@var{pid}/smaps} file is done via @samp{vFile} +requests. + +@item memory-tagging-check-addr +The remote stub supports and implements the required memory tagging address +check functionality and understands the @samp{qMemTagCheckAddr} +(@pxref{qMemTagCheckAddr}) packet, which is used for address checking instead +of accessing the @file{/proc/@var{pid}/smaps} file. @end table