From patchwork Thu Mar 28 07:00:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 783587 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp2572896wrt; Thu, 28 Mar 2024 00:02:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUhd/r0IqT9Do63qZeLSWeZopi0wEnCjQaxEoX/fwOkh1Ionja7eb5AIcqVaVRBuEBANrNSyWq2gExAFC17LvX2 X-Google-Smtp-Source: AGHT+IEIsc6EBBDzw16OO0geZcQAfnPQyD7/CXbL8PT+L05oK2WNMqytsoE2Cg4BEcjTuz/PR5Cc X-Received: by 2002:a05:6122:459a:b0:4ca:80c5:7544 with SMTP id de26-20020a056122459a00b004ca80c57544mr2621958vkb.4.1711609326894; Thu, 28 Mar 2024 00:02:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711609326; cv=pass; d=google.com; s=arc-20160816; b=raKAAji9NNvkSYscECBwcBbZEh0d9SnypPwpB4qksG0rqqSIARG2jWwsxqOxGdr571 JaCU0d5aio6qzW+W5G7JOgXGXdqHVBGBueDdZf/qHe8QGNgW5LVwi1wFGVqWAUrIN4DV zanfPqrvmpIOPvpthGEbljHLCNNaMNVlu8tNTLp4Avg99ChpX7R/f6vMIFGzKExDkwUt RHBo2IY8YKR0WC6zdZ2KA7cfhwnN5yhV4EElXCWw578SLuKQbsRReYKrBUqum5NDrrlN nDIQtwuDvluYSAiSOrEqklw5wh8MrDnCB59XCsy44DaEj2vs3ac3GbCsPRFPr2vzRC8U 6lcA== 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=KMhIK92GkRiBx7sNL8LhIZ8p4iDg7dPzw1XEQvpaqKKEEet1bubAGZggkqazhabnkk jlheV6q+33ti42/+vq4h0R7tbU8nUAY0FA+4nx7zeriC8DlcS4j1+POHMUHSv8hV+Ed7 +qwBQt3QN22e+M4xRnotJCEEgcGeoL2/j7juWNn8TBv8pNxQhCktQqiqKDiXh5C4J9U9 nfHlJdRyyRlcV4vQrZi+frIpIcXZa5B0CMyTjBE4pl3555PhIucs8XVEuIBheNGykQ6s exWi1omg9mdxnG0/5SJJZ5elpRFLFbrhoEe1fzfsbfMtet36j9ysASp5HaWIG3j3IRIw 6fBQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tYcjXBCR; 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 t10-20020a0cea2a000000b00696121a27c1si802967qvp.424.2024.03.28.00.02.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 00:02: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=tYcjXBCR; 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 8549A385E82A for ; Thu, 28 Mar 2024 07:02:06 +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 709803858C36 for ; Thu, 28 Mar 2024 07:01:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 709803858C36 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 709803858C36 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=1711609292; cv=none; b=AOxJm/6ir7rPfr6qZvWVscd6FgiHzrbSZ8jIr8b8tRsyE3dOMaSAm2gBL1TonH7rHWecW6ngJIEPFPap6ihWyHvAQjMF6ZILE0b04585r24yWv6grD5nZd1+hy5DnoNdrL10zRtNLVrhLOO+zCinUrP26U1rWKLMWwOzkW8lyso= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711609292; c=relaxed/simple; bh=cw8HWoi0GK9IULJ9tjjvNvNLD3bq4hT65KiMLi9O98c=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=k/xh85h38bewXf1QYyKESlKqYpPNKGBusEbh5oSpwwHtcztKiJdS/63zcv3C7jAAfuc1jTgKEndihb/p1/J40BtEf1dTEhT07rRhoGYJ/6w08RhGROn7UkKEzYCG/uMkG3aTSvPvdsXfN9oHRTmVa+W0KDqN0BU+eBum/vvcHfw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1df01161b39so5612415ad.3 for ; Thu, 28 Mar 2024 00:01:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711609289; x=1712214089; 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=tYcjXBCRUiqpeFRHXmEyheiNDQ6yNLueTyi8JAlS0O1p3URrwk7TSIyzz1DiayG2lU eXm0bSizk9MRFSOmHKCrPS7OccKzRkMvP2mcGqbvLlwCtXscmYXbJi4VIEG/4s6OhDiZ hQi9uRyv27OVu/5U9HDOlXYOUbo+cZt+oqisZb2qGXzchxCtmKTWnq1xSu11ygWzyohz QscqJuLt3lrHJf6w22k9mpa7gAbXCA0uPYdndAjUvkDoeNI5wet8n8PXaMTxKb62Sxwx qYtfakyObTy1QavIdcsyxgWm7+S4e2sOn/UG+hD3G7VHbLvwWgyN5q3CwKEHAA7IXOly UYJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711609289; x=1712214089; 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=rf8Y5dogFT1dyUUHonIRZEM1D4j7VEmb4iHpn5D4BvY0VjHiJMvWuxS8tZcJa2J2PI xPN8yd5Ul2Z0gsev3gWnBv5nmLUQK9kB8CX29ETEDLlM6pbILy5jUgEXSomS2ftF7Rn0 Fmvmu0XRGeexrLpSXSUVvgpU4X7qVGe9oxv9/jePrhHpIz1Zs8gN6949mzNM4/lIhU+z Il4N3p+0Vp82wYVNYYVSBsEqZ9dEZsJXvEoRy7q3upFcF6hx6v+nsWyRhL4JyK+DICmg gTldkjSlZ/tP/Gvgfl4jXBbdaP8CE0RDHG40zueNp1qtjAd+RCVzsNeP6bQ05ZwS/dJ+ m1kA== X-Gm-Message-State: AOJu0YyuvBtRD+1/dbRmNEZtEzlDtRTHPXzKJ409ZQxcGPZPlsLatPPv fB5vNTszsuSlnXPe+QUZ35SSuHFsedLebu71Zdk1X/CTHJqg/JhlH+oBzGt2EppLrKm0deHnbWb G X-Received: by 2002:a17:902:6808:b0:1e0:e2b1:7395 with SMTP id h8-20020a170902680800b001e0e2b17395mr1864703plk.14.1711609289205; Thu, 28 Mar 2024 00:01:29 -0700 (PDT) Received: from amd.. ([2804:7f0:b402:41b2:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id b15-20020a170902650f00b001e014627baasm754252plk.79.2024.03.28.00.01.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 00:01:28 -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 1/4] gdb: aarch64: Remove MTE address checking from get_memtag Date: Thu, 28 Mar 2024 07:00:52 +0000 Message-Id: <20240328070055.2578783-2-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328070055.2578783-1-gustavo.romero@linaro.org> References: <20240328070055.2578783-1-gustavo.romero@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 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 --- 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 Mar 28 07:00:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 783585 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp2572835wrt; Thu, 28 Mar 2024 00:01:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVRSggvHtcK7ptPTCnm8uKJTrb3Dk0C/WnrdjjSGlUmk/XKBpAtfPVceGaelnJO1JrLHuAzJca9ATKEoK51sLWf X-Google-Smtp-Source: AGHT+IGJGhdVsQ6uR47b76kDN0CoUvXHnwMMIgOxVsmQKQsJJ92twTMM/zo0wvTeoRyPZkRUWdsn X-Received: by 2002:a05:620a:c90:b0:78b:c1e6:31d8 with SMTP id q16-20020a05620a0c9000b0078bc1e631d8mr4708qki.14.1711609319043; Thu, 28 Mar 2024 00:01:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711609319; cv=pass; d=google.com; s=arc-20160816; b=FGjFakgcUfINAJryikEd+aANp0l1/+uQ/slY47zrcJtXzTJmA044oUC9sgkz3S2RvM 3Ai8ILFMmJd3FD5NpUXfsPBO07DSpVQKb9WrxqcH4WO5OPHuAathPAAE7/Xl5dSaRRMl ak2EzDJu4me7mPp/loqoxLPHACi9Xvb0/o9gx/bdzBJFQD85nysSr6Kdg5s71LPPvt5v uhZWkQWJknaQtP32Fqa7CdAWa1eoVxZ1UuMQ97dv46qNnjjYDIHxd80XToBP/Cuih+xD 9/mn11iYQwLQrjWYjxkuhrqBWBcY8MjLg2az1aIZXRQOEyKuUQb68EqnIYcLmzFN4/83 cZfA== 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=ilag/Jr+6TNnOGN02ZgOKlgSmIgtYGupLlm4g6mhHbQ=; fh=ip7+QkkM488k9wyzFaZPu3h7BUQARzj44zdeG2KNIXU=; b=BO5SwbrxhjAjM78iQ8uFqzK4e0klSi6hrMMugPgHl/9++VTnCaca399iOROQMFmQNn iYKfzFhye9GtnC6HUN9WlQiZdDs5rouRlQV/EkueJ6IB4oxjSECzyWyAseBd8SJkQPtR IKEW3vT5YLiQebrd6F2CksHpqasP5DwIdEzc8A5WAH4NkDAC7YFfj6f+MI77HIzAdpVA GV2H8lro1yhiMK2GgXWvlRPrB+ouVZ2HBwhGHb0iiUebJp8u1ND0shVKN8VF/OzCtrr3 ecGa4/pWqQ86WlfYjuptlaoSWS9lzkvN1wioRpwJE/Bd4JBA3R9FfzYBFUIrOmh0hyJ/ t0PA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TYZ6cX86; 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 pe32-20020a05620a852000b00789dc64b235si794697qkn.517.2024.03.28.00.01.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 00:01:59 -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=TYZ6cX86; 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 772AE385DC3F for ; Thu, 28 Mar 2024 07:01:58 +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 87BCB3858D20 for ; Thu, 28 Mar 2024 07:01:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 87BCB3858D20 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 87BCB3858D20 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=1711609294; cv=none; b=iSiJt9mhhIKHJn9B7tu+Rr+h/yJLeDYV1F5PPsGTwN7pVr8wGpABQT+y9OZpmLsFpAQR3qYPRbVsqXebjcU1Sqs8xEnBH8m56JYQ103xOTmsf1Q9tT6xTo8N1nlPVLnM3IWKRjA/wN0I5AejrR+WTbzmGnoQMnbPYnErMZS2sYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711609294; c=relaxed/simple; bh=Ot07zx98/HzRqfFiuW6mucw3t+ApYoI7a9eYGtpH+b0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Qa20I58VdDBt7UsESc18+9DoLvVe5evvhG7FCcrT69BkWB3i509VvAkQlpl1ePu2tBp9G9ostRz8VpgoDAVUy4NrrdM+MFT9ibWIB9Xjagy+sgk4Lih2NuAuZK96PsWjWsDkDpUb1Jjvp23J2T6CQEZYLTldle0kj0oYIxN5BOU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1e0f0398553so6360995ad.3 for ; Thu, 28 Mar 2024 00:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711609291; x=1712214091; 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=ilag/Jr+6TNnOGN02ZgOKlgSmIgtYGupLlm4g6mhHbQ=; b=TYZ6cX860l9z+9uMqWbQNw7EYt1RVH+8n+3Y3qmP3I+Jr4K1WBS/3dCcutdxwIAMY3 +rOL3Axjjl4KiZNeeSLxe9DCcJwt6AkwTR3yWQ9GQx2nG0G1IrXZPvLVX05leg7i9vnE JghJC1FIviyN3ff44raG7Ahh22HCrmhp0cnKXvaBgTdkcWxu+APkG4Vr8Doh+T0Si2Ar iGtQ30BuUvG5t+GJOtIzTql04KNxoS+u1IpS/5DwfO22lO+Z2DdtOvbDdJ8Cblmum5Bl +nCaOGZtVv0GON8Gu2xUn6OBrDfMLdxoBANLfCO6wOz5L/FON6yaPjCVZ65fHfy9UMj7 PmXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711609291; x=1712214091; 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=ilag/Jr+6TNnOGN02ZgOKlgSmIgtYGupLlm4g6mhHbQ=; b=S5bUAcFylGo2jXN0VYiigzNNjQOUKreQgOEEv0jctZHAnIuP3kMd61rPqreklt6INj 7OcsXfBchj6DZb7H5QKtN+NOBIoGeK5UcfD73HWAvsjI+Vkq2Aj4/W1QC5FMhk227fW/ h04nhw9GVX/kKS6bY2DggmxXLs4GF5PDc8LSaA5tO22wN7YvwVm31xTw+B7BkxNJ3KGd iHH3JYCONvDF0z8jWI2zbFHijH1S6O/wLQAw+1fzEliBp1UIVbaMfZiI6SiZVUrz3pnl OCB3Kv16TzK02Qj8MefUWp4Z7ziUmFRw6OyruHVj4hXklXPBBSE0BwebgJCyUh3xcDfa Oh0w== X-Gm-Message-State: AOJu0YxpyITrFigOSHb/4VfvFuZBlTsnBawG890QgUXm8Iro4rMWLLRg pSwnRKitDV1QqG5xoWguJLahDdbl+LpwxRjYq9ufWh9ffYKP+9wSgMGD0rQ8RF0gsieW0UpuXPA d X-Received: by 2002:a17:902:a617:b0:1e2:15a9:32d5 with SMTP id u23-20020a170902a61700b001e215a932d5mr843770plq.29.1711609291149; Thu, 28 Mar 2024 00:01:31 -0700 (PDT) Received: from amd.. ([2804:7f0:b402:41b2:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id b15-20020a170902650f00b001e014627baasm754252plk.79.2024.03.28.00.01.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 00:01:30 -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 2/4] gdb: aarch64: Move MTE address check out of set_memtag Date: Thu, 28 Mar 2024 07:00:53 +0000 Message-Id: <20240328070055.2578783-3-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328070055.2578783-1-gustavo.romero@linaro.org> References: <20240328070055.2578783-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 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 | 6 ++++++ 2 files changed, 6 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..ae4d640ccf2 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -3127,6 +3127,12 @@ 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 Mar 28 07:00:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 783586 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp2572874wrt; Thu, 28 Mar 2024 00:02:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVYFFoH00zDgXS6OpVhj6Yl/QuD7p9yuLDIviw6n41i3C8ep4gPLBCmXeDoSyKEoGbP6JWlzA745O/DdibrzcQx X-Google-Smtp-Source: AGHT+IGvnwf4xtvUgXJ4aRCJEzo3oxdoYoYyC6V77+G4BmmpHzoK6J4ddFwTwlzyGsurFwpUA1Ri X-Received: by 2002:a05:6871:60a:b0:229:f768:f6fa with SMTP id w10-20020a056871060a00b00229f768f6famr2079254oan.8.1711609324289; Thu, 28 Mar 2024 00:02:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711609324; cv=pass; d=google.com; s=arc-20160816; b=yu8eNnCS5k4zeBHyBVBFQYJvUQaXwXtCw3V7YnX3ENsJZM8NbkAjA8bYVW7AB3pzYp iup3W+4clpZLf+vxGjrbEQOjh0rIhcyUauNn5jlRJMgrEVcXohfULGLZgrn+nd9nXjRW obxNlQDdtphzLEbDtPH6xgjdwSYufnnN3t0WrktvkttDZFOmRJ8PIgMTU8hRoOlrLzbZ bGmPJ2p5vzXm0XkPXwjD/m9yXQxEfrvQ00/XAG61VUKE+bLLsTigFbO+VOuLDGoxlZVS LQAKGMkWDtEagXzUDF1GmqoqX34P7rX6VDYzXTMryLajOXynx6jsgVxt4klV47T4+ZRn 03MA== 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=0ckeD6IQS3qWMEMIeiGGTJDo5qe/KQ8pCc+3ombDHghgdjCDnM6/HzQJwk7TOsyrmv Ek8+8WaKcIvgsIDyN+oIBZLPKdfeUZkPnVOLKmWtiKO9NlVP2GB13kbSGxrLpx1eRkcK fqbGgcHNEj+tHZnRYRpfDJv2q04+9vgAhI4opgKHwNN+6jTb/SRMjjOLfgK8nc4c3fxJ geFTQGSd8njRqHY5I2XOhnmvc376vvCcek3MpQAxxicRfBhh27t9Ba0oICsyvAL0SuWf hxBUsvwt8D2TOHfQPGXbtDhcbgxiBAL/uYiBrczqMJUEmOADMxhhNg87hwy/wQKYT3wD h0yQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IfJe9z0N; 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 z3-20020ac87f83000000b00431651420cbsi767837qtj.755.2024.03.28.00.02.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 00:02: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=IfJe9z0N; 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 BEDAE385ED4A for ; Thu, 28 Mar 2024 07:02:03 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id 91D03385DC06 for ; Thu, 28 Mar 2024 07:01:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 91D03385DC06 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 91D03385DC06 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::629 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711609296; cv=none; b=qjqr6hKgGE1jYNFr1gHn8Ep6bGPkNM2GSMNennAtdiBxZXpuvVvoOj3lxx6Nti23CEp+qIAbO0mbscYBt1qVYNWguBSZm7E70kpFevnc+hC9fL6er/mzggES4onxnBU8I7inpRNtLASOtSmTPTsAOAkGiOVVVNoEgMLEL2ohaNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711609296; c=relaxed/simple; bh=m0zxqCy8ZHC4pqDMn5zPMAeOHRoB5JgRRsV+IvPQPCM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=CwrExYixEKPb9gEwLb+ZzpymFjwvpIRm5EObiuuiOfgqXfkD+bRF2oLAFuRg5SVNgApkZMXPTTX3Fj6fReoPRARhFMvVIJEwlYN1AUmIkUJo3KRkzhYiAgh6FlO22vehG68xlLNOLip+CqaGcpZmepSXzp/AqM9Ob0ETRQDjaI4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1e0189323b4so4475295ad.1 for ; Thu, 28 Mar 2024 00:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711609293; x=1712214093; 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=IfJe9z0NdHlQaIVZpADMMdjA2qoioRnuHJaZNKhOVVYhuNSGhFHL8kICoRx1hX9Hvp ZzF9JWuEEqGF8wmxScloFk3FztLU6hzcgE4iVplZVgels5214Sojehad1AvxfHM6UJJJ 5SdMeohGm8U2NtI7CzvWOJJx5dNrUVb0eC6+6RMHa5mo7ACUl7zAytfbPnYK/x5565Mc MnMviUdT859WrMEG9S/y2IypexhfaHQEsOColW2XtzYyQnfavdrvdwYbglfcsBFJkvN4 FN/qjpVq4LTMNThKG84gaUd/5RjvgJWv0nygG/cQsX44eINHSbASHxZYN1WSB8g+wXHh +pcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711609293; x=1712214093; 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=GLA06TG72xa2ZKyN9Wzd8zKe0ddUyjuNbh+f8iw/y9U6qvo5fosPt7heoZuZPlsWvs S9ylMt5i2/z7Hf19Dpqyv+9GHDu2z/5V+Sd1TmvPu6T8Eoo3IGKb7d+FLSK1CyU4HWgR TlvWXUGyJb6Fp4MciW4vwaUK9T2+wNz+RFjmP4EZBngyV614//AuiXpvHILORQ1u57DA JsjjT8JXTQVEFtcpdUBaO+eh5nd2fnb21Rv5e4PQTov/86oL1kS+ASbYGGWEoTY9y2AH L7tK1mztRCKtYbKOijcHPmk94gzetrKtb5MfFznytU9ayGnGPDdVhg3rnFgTzBVOgcrA 7xOw== X-Gm-Message-State: AOJu0YxqdbMSwmdsaXm4iWO2Xvi7YEIx7VEMGszWJFlEP4t/OQvBzrXm sO1dPlS8ZzOYQWwBnOdiIJZxiL4Aa4fguppyvfBIRZaUF3nmysVH3vrKfS5oYJGfCPjZR6ZDYLb 3 X-Received: by 2002:a17:902:7248:b0:1e0:afbb:7a89 with SMTP id c8-20020a170902724800b001e0afbb7a89mr1672701pll.22.1711609293144; Thu, 28 Mar 2024 00:01:33 -0700 (PDT) Received: from amd.. ([2804:7f0:b402:41b2:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id b15-20020a170902650f00b001e014627baasm754252plk.79.2024.03.28.00.01.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 00:01:32 -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 3/4] gdb: aarch64: Remove MTE address checking from memtag_matches_p Date: Thu, 28 Mar 2024 07:00:54 +0000 Message-Id: <20240328070055.2578783-4-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328070055.2578783-1-gustavo.romero@linaro.org> References: <20240328070055.2578783-1-gustavo.romero@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 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 --- 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 Mar 28 07:00:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 783588 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp2573163wrt; Thu, 28 Mar 2024 00:02:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXmVYE0Du3xCtcABeMV1x7Pzugjviz8mxXv7ZRxN6VB4bgVyBmJPR/nJgZWVO7iQw26KC4InygnSRs/FpXzvDtU X-Google-Smtp-Source: AGHT+IFLwnGe/BSNTiaFy2OK9WjScuL1/psB7z0blEsztsg53LY48ro0Poh/sR83i2vBeIEHahms X-Received: by 2002:ae9:c206:0:b0:78a:4214:c570 with SMTP id j6-20020ae9c206000000b0078a4214c570mr1936450qkg.48.1711609365870; Thu, 28 Mar 2024 00:02:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711609365; cv=pass; d=google.com; s=arc-20160816; b=dVsPNyy2tlp+qwPwNrjdcxWfLeEYbGsl8tqOp+jwC2am1MYcBL09V0kDNmfwF19+Q9 Y0JkE3wIBxRjyYv3Tw5F7P9GLzCHjfVlRzJQ7MUMRdhxy/CvYgDN37x2OfGVji0NuWR5 k2YWWAHrHwEc/mXn4tLN/ZHTL7C6w7UVYSjyLOuhSe/6udv5o07XZ9X+e/TXHHOet6fm OAOs6UQxqPt3ib+qijLtAZZlm6QMUPEeZi0jDLSwdK+LKw/dqhNRHJBfMzcdGh373rTa onwf8UpMKy/oNpRJ4bbElkYNA5qTWITAKIMhE+aT40SBaflmAW5I+px/Rl5B8xz8VDTv 8SbA== 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=t9wpyNHtdNH1k7QzmkpmpbKaNXwp0hO7JeNHnXBiFrk=; fh=ip7+QkkM488k9wyzFaZPu3h7BUQARzj44zdeG2KNIXU=; b=eQ85wcaRPkqStoUaI5Crrn+u/kRtX6vgd0qLm1enZT3AlryH5sxMdsz2XdrFgWnJAG zxsowYFZsiEBxV50e3DFTicGnyaBCCsmgEAO/FOMmTXNaZ6tFX4SCHu6RDWmH4yLFsxn BwUpII0D4GUnXsMQ8lik6a+06IHuvKH9OQMYYp/YMi3c1xPWXVLElnkC3WGrbr/wjqYb 1l/ag9B9irU7fgU5Swk5N9VTa9gnlo7cFc3LH/itS4zUNMuR1LTBIkga7NkcqdBKZWbw KPhhkCsipx/7qE4YDmCpcs1cmgJPG5BawgCIZeUxZjd8Thq/k/B1pJb43KsIRRQSKqIf 8eRg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lA7aJ6NU; 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 pc4-20020a05620a840400b00789f61e3e39si827224qkn.74.2024.03.28.00.02.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 00:02:45 -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=lA7aJ6NU; 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 796553858C31 for ; Thu, 28 Mar 2024 07:02:45 +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 CF8CB385E451 for ; Thu, 28 Mar 2024 07:01:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CF8CB385E451 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 CF8CB385E451 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=1711609307; cv=none; b=oI9jQFlcWyYOOI4hGp0+ahSC9CUBKaE700Ro2mypsz6L9vI2gH8gRorTfuqkwuspzpcjLbTt+GeIPjHxIPh5q7M6htCKUy9aTM0xANLTOfEe3uGxQ6xJB24izf97Ep3h6SV3XHz+fgoHU3QWkeuAtX6l4luH4bevh0OQkpqfAJ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711609307; c=relaxed/simple; bh=v7pya4SfuGPtlHQGcSzcCqPuSwKTKACscHghXIMCWFE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=GnywogDP+FO9MGXeUEsuPmb5lxPTL1aKzB3TKMmN2wr4MUA8LrGFpIUKoY61jMPjppElBTiwd4qsVFkKbOTbpWfcSjCWPU8RUYnvOZkM0uYunBhOKXGga0WNDiSM4wSDPP5ci1Ebjtr0VkTyrDAlumLcRd9GpWDBdFOCzAjqMss= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1e0b889901bso6109545ad.1 for ; Thu, 28 Mar 2024 00:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711609295; x=1712214095; 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=t9wpyNHtdNH1k7QzmkpmpbKaNXwp0hO7JeNHnXBiFrk=; b=lA7aJ6NUxTvIMoEwjxam69Kia34+Q/0RGjLzHy8iQg6WRnvbhAkQ4T2pNC5RLm3HHi cvHgLF0FRegyL9lB6YG9up5hZSR++1qYld08fbG1AbIdJX6wCVqHp80SZALmgAEHmKuZ oNlLApnCeT89IhQYKdE5kB9ZoOILv7H35N6ZOTioEK7NVbeWBHXy2X8ddZaOVbD9rT57 Dxvy6ufUyEch027hfZV3Q8j1bft4nLgdoXQAiK5BZ+/NoXcbegTS9da+xy7jjrPrxwUt TVlpA8EpupjKUQZq44CHl/7PFpe9XlVKHtpGr+a/818ZtFexSaOu7TCdaLpCr3w/DRBc 0siw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711609295; x=1712214095; 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=t9wpyNHtdNH1k7QzmkpmpbKaNXwp0hO7JeNHnXBiFrk=; b=EMmDW8CtkAOQ0puIr3feObzjMH+iprJIckDn57ipIWMMbzjILR/FecgK1Oeuy0XnSn J1AXcnrLmrjswXxAHJK2fH8L9CaDuNp1m5ibCoz0aJQ7LynZAkF+krgTxXYsV4luVOIv C/qy7tkA3MC/hCEVrwbvmtg5kbVIQGTnToXGaDusP/SSRlNV6waihiIYLLJ/a7zKGasc 6YNf6PiVns1WBuxOrNvOtDewB8z+WuMvmSrxgmqxnx/nGMuEEgBQdWU7ITOjp4IdlHq+ o3j4Rdhcvmrf/n07Nm22C6HV0CtvOgUJ6evcdunj96SlSNIBkgCbOZWp823XWWF0EbmQ k3iw== X-Gm-Message-State: AOJu0YytS7fjNwwZ9CB84+teqxqwra2JPTyNc4NJrLOHmtKhPaa8gJPA RX4pwovPqwQMp9dd/p89Jq7wpUqaZJ1v4J5CTrwTtBwvEtemQz8+jLSzD3lxK5YJ6Vp5iQhEr9Q X X-Received: by 2002:a17:902:6f02:b0:1e0:d0e8:b083 with SMTP id w2-20020a1709026f0200b001e0d0e8b083mr1600675plk.51.1711609295315; Thu, 28 Mar 2024 00:01:35 -0700 (PDT) Received: from amd.. ([2804:7f0:b402:41b2:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id b15-20020a170902650f00b001e014627baasm754252plk.79.2024.03.28.00.01.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 00:01:34 -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 4/4] gdb: Add new remote packet to check if address is tagged Date: Thu, 28 Mar 2024 07:00:55 +0000 Message-Id: <20240328070055.2578783-5-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328070055.2578783-1-gustavo.romero@linaro.org> References: <20240328070055.2578783-1-gustavo.romero@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 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 gdbservers if a given address is tagged. It also adds a new GDB remote feature, 'memory-tagging-check-add+', which must be advertised by the GDB servers to inform GDB they can reply to address checks via the new qMemTagAddrCheck remote packet. Currently, this address check is done via a read query, where the contents of /proc//smaps is read and the flags in there are inspected for MTE-related flags that indicate the address is in a tagged memory region. This is not ideal, for example, on QEMU gdbstub and in other cases, like in baremetal debugging, where there is no notion of any OS file like smaps. Hence, qMemTagAddrCheck packet allows check addresses in an OS-agnostic way. For supporting the new packet, a new target hook is introduced, check_memtag_addr, which is used instead of the gdbarch_tagged_address_p gdbarch hook in the upper layers (printcmd.c). The new target hook is then specialized per target, for remote.c, aarch64-linux-nat.c, and corelow.c targets (the current targets that are MTE-aware). The target hook in remote.c uses the qMemTagAddrCheck packet to check an address if the server advertised the 'memory-tagging-check-add+' feature, otherwise it falls back to using the current mechanism, i.e. it reads the /proc//smaps contents. In the aarch64-linux-nat.c and corelow.c the target hook uses the gdbarch_tagged_address_p gdbarch hook, so there is no change regarding how an address is checked in these targets. Just the gdbarch_tagged_address_p signature is changed for convenience, since target_check_memtag_addr 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 | 27 +++++++++-------- gdb/remote.c | 62 +++++++++++++++++++++++++++++++++++++++ gdb/target-delegates.c | 28 ++++++++++++++++++ gdb/target.c | 6 ++++ gdb/target.h | 6 ++++ 13 files changed, 143 insertions(+), 24 deletions(-) diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 3face34ce79..1c64df6af41 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 check_memtag_addr (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::check_memtag_addr (CORE_ADDR address) +{ + return gdbarch_tagged_address_p (current_inferior ()->arch (), 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..676738825fb 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 check_memtag_addr (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::check_memtag_addr (CORE_ADDR address) +{ + return gdbarch_tagged_address_p (current_inferior ()->arch (), 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 ae4d640ccf2..c81c75afc5d 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 (target_check_memtag_addr (value_as_address(v_addr))) { /* Fetch the allocation tag. */ struct value *tag @@ -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_check_memtag_addr (value_as_address(value)); } /* Helper for parsing arguments for print_command_1. */ @@ -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_check_memtag_addr(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_check_memtag_addr (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_check_memtag_addr (addr)) { + show_addr_not_tagged (addr); } if (!gdbarch_set_memtags (current_inferior ()->arch (), val, length, tags, @@ -3158,12 +3161,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_check_memtag_addr (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..264adb686f8 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 qMemTagAddrCheck 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 (); @@ -1084,6 +1091,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 check_memtag_addr (CORE_ADDR address) override; + public: /* Remote specific methods. */ void remote_download_command_source (int num, ULONGEST addr, @@ -5762,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; @@ -5873,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 @@ -15532,6 +15547,19 @@ create_store_memtags_request (gdb::char_vector &packet, CORE_ADDR address, strcpy (packet.data (), request.c_str ()); } +static void +create_check_memtag_addr_request (gdb::char_vector &packet, CORE_ADDR address) +{ + int addr_size = gdbarch_addr_bit (current_inferior ()->arch()) / 8; + + std::string request = string_printf ("qMemTagAddrCheck:%s", phex_nz (address, addr_size)); + + if (packet.size () < request.length ()) + error (_("Contents too big for packet qMemTagAddrCheck.")); + + strcpy (packet.data (), request.c_str ()); +} + /* Implement the "fetch_memtags" target_ops method. */ bool @@ -15573,6 +15601,36 @@ remote_target::store_memtags (CORE_ADDR address, size_t len, return packet_check_result (rs->buf).status () == PACKET_OK; } +bool +remote_target::check_memtag_addr (CORE_ADDR address) +{ + struct remote_state *rs = get_remote_state (); + + if (!m_features.remote_memory_tagging_check_addr_p ()) + /* Fallback to reading /proc//smaps for checking if an address is + tagged or not. */ + return gdbarch_tagged_address_p (current_inferior ()->arch (), address); + + create_check_memtag_addr_request (rs->buf, address); + + putpkt (rs->buf); + getpkt (&rs->buf); + + /* Check if reply is OK. */ + if ((packet_check_result (rs->buf.data ()) != PACKET_OK) || rs->buf.empty()) + 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); + if (tagged_addr) + /* 01 means address is tagged. */ + return true; + else + /* 00 means address is not tagged. */ + return false; +} + /* Return true if remote target T is non-stop. */ bool @@ -16056,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. */ { diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index 59ea70458ad..fbd9e3f65b4 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 check_memtag_addr (CORE_ADDR arg0) 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 check_memtag_addr (CORE_ADDR arg0) override; x86_xsave_layout fetch_x86_xsave_layout () override; }; @@ -4562,6 +4564,32 @@ debug_target::store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector return result; } +bool +target_ops::check_memtag_addr (CORE_ADDR arg0) +{ + return this->beneath ()->check_memtag_addr (arg0); +} + +bool +dummy_target::check_memtag_addr (CORE_ADDR arg0) +{ + tcomplain (); +} + +bool +debug_target::check_memtag_addr (CORE_ADDR arg0) +{ + gdb_printf (gdb_stdlog, "-> %s->check_memtag_addr (...)\n", this->beneath ()->shortname ()); + bool result + = this->beneath ()->check_memtag_addr (arg0); + gdb_printf (gdb_stdlog, "<- %s->check_memtag_addr (", this->beneath ()->shortname ()); + target_debug_print_CORE_ADDR (arg0); + 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..938a0f76595 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_check_memtag_addr (CORE_ADDR address) +{ + return current_inferior ()->top_target ()->check_memtag_addr (address); +} + x86_xsave_layout target_fetch_x86_xsave_layout () { diff --git a/gdb/target.h b/gdb/target.h index c9eaff16346..bb64d32994e 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 check_memtag_addr (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_check_memtag_addr (CORE_ADDR address); + extern x86_xsave_layout target_fetch_x86_xsave_layout (); /* Command logging facility. */