From patchwork Thu Mar 28 22:48:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 783638 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp2965886wrt; Thu, 28 Mar 2024 15:49:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVZR9hghkZ2ujW9GE1uLsrTU7Npf8NkfnDB8+ro6ektVVVgMStnTCDO3uW07kMjlod2JYbFiIvX/LT9yvVz+wBs X-Google-Smtp-Source: AGHT+IFF9jvmygMlCBBgGQGLGN2s2WeRnP+62tdCdKl/g9RM3/z59XpSl3k926IKeb/HXnXFQmtu X-Received: by 2002:a05:620a:1920:b0:78a:6b2d:1c79 with SMTP id bj32-20020a05620a192000b0078a6b2d1c79mr1097223qkb.8.1711666189216; Thu, 28 Mar 2024 15:49:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711666189; cv=pass; d=google.com; s=arc-20160816; b=jE4AiYcxtqB0NrSMC+PrKSpI4OqBjem4nitn3oICC6bcVMxfqBra852JKGJz+RStUw 6H/ICNDLJfbeqaCjIsU5BEgClSLdxe3e36piqvMfS3ywH26tv2sPw1sQa21qp37p0Va8 Ik3HKUERRY8grC7WoqjE5V8lvgPB/x1O1K5JWVf/i8ebtFt8pbN3RHqhZB2m+52EIlFd 8YFhmoOdpK/MV+SKbMDkC5Er31bkz9Hy5TdP5UczQSUvrWs0iy48IlypvhRtvg4Xhzqw QW1qW5sJQK97pYyDcX04eGNc5zqswgwqtu+LWAaTg9NAra/0ZXWKPf6Lasjyyr0gvR2U aMKQ== 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=GmrXSAQWGBoEsD1JTGXAnrjztPWXOpPhFjyHBjPIkOb71teGbI+MwIvTZMJ5YWh9TT 10EwWMRsZKjg0cCduqPHFpYeoieyYVxnT9Og062eL7J/GbZuSdwozJjrT+WHVGA6N363 0nqClV8r8LUwXmH9MapaZrX+rnnDOwGxy2ZUMMXGN9KpAWU5qtrp5CwMZ8BatFDwi9+N E7Ps8JGRiWjZvmc5bU30m20Z+0oqFpD7oGZOgnDSc+nJ+c0zxw1n+ST+3gosltsA9T+J iOW2eOmxsvScIiuOV7Syx5dpcdFRicqE44SkeVJdOpYVJqtWxwPlVMtEq8zUCoBu0m7y ECQw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jTHqrtJL; 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 y17-20020a37e311000000b0078a4534419bsi2344669qki.326.2024.03.28.15.49.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 15:49:49 -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=jTHqrtJL; 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 D0CF7385843B for ; Thu, 28 Mar 2024 22:49:48 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id 61D7E3858D33 for ; Thu, 28 Mar 2024 22:49:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 61D7E3858D33 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 61D7E3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::632 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711666186; cv=none; b=mRasjPhmWYrWvFSaxB/GRhZnUNcqA53U6AiwrKQHdFqANldPahbhJLejOGzHuCkZjuFZtxpIjAPQxzxj6IksUIYLsjCM5yBFgXIH4KMWH2LutAWaascWAe2A9e2Jq+S7D+pX+mAcxH/LLQkrZQSDjmWsO2CCvVhcY+6N5Fr6F1g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711666186; c=relaxed/simple; bh=cw8HWoi0GK9IULJ9tjjvNvNLD3bq4hT65KiMLi9O98c=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=L74qLKPo6fT+2LbTMLFv0iKu8yr+T+sL0PGMXNBjac2fH2YEcFtkrGScf6eiotpRH1wCkzTYDSXd7yXlTwfTZZUmi3uCCEdoNhlrxEDXkJMJcikeOa7p3LolYIp38lJ4QAGePyqNWZOXrezYs2NWWHFEIQ/CBRw8Sp65+WiUT0A= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1e220e40998so6942075ad.1 for ; Thu, 28 Mar 2024 15:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711666183; x=1712270983; 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=jTHqrtJLf0iNT0KHECkJJDqjPvdcFJm6lJMHmKxcWWY66QRAYiqIkePPatgF4yBwys rTYMQDx4IvKQm60jWwLF6pHMCI+8G4YFWzq6osNIS0PCRfzBFvJ2j4BfGmTgXPPvSREi Oys+uEu/QVbECjyDLTF16oVD6HhRybTm6qBT02zV4GaOa4GJyv7rmdJmlYiZhEDc05cM 1APwxP/Gd+HEfmUXxcbGllAaYnG1qCzSKPl17VBIPP6LaUtsuxoihUlX0UnqwmUgCTa0 rVinejkZxGrMQxwm3ETKECI4wg2kQl+Zr4C7DBGMxX1Z9aQHziblaqLhSE8aa3P/Ohfx 9O2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711666183; x=1712270983; 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=MzDmre629ocDJuhux3oMw8vpcTar9RKuvEtDWnCKviep3wkAjKrBb6WDYnibAr8lPB 7we1+cT6hfkRFHWzOnqcga24ZPzAhkSVlykzSKqFwhZ1Ojj4qvxJfWh1NIEw9yX1Jpmt KYd0QZJun2KlflBwNTPU9ar1ZhyE+pFHIBbYTfd+1juhwynEVxCHNlYFuh9VsV6T8jA0 TN2THDHuooyG3f2IkeoidAbQK7RbTg78bIcXpX2tNSYFQUXYITEd3SKKswKE/nsbkjnE pkGwvlF1cmkaCecGdxECWHYlEuSyyF9hgGFcCOj/mOi9zbGnTILoYWK3Uona1wjV/uci evYw== X-Gm-Message-State: AOJu0YzNJYKixnUKU/ThzoJ9gIejWhiZwVx69+fzoLx2b/NDhLyz1CbN hTbbTPDaBqSqhxFjCfuq5rcaODyWV4lA4Zl1gTfrOYvVGzZ6OQ4UyDyITKCyepDWhH/q4fPKAho R X-Received: by 2002:a17:902:e849:b0:1e0:b871:53f5 with SMTP id t9-20020a170902e84900b001e0b87153f5mr1168238plg.20.1711666182872; Thu, 28 Mar 2024 15:49:42 -0700 (PDT) Received: from amd.. ([2804:7f0:b402:d0dc:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id t4-20020a170902e84400b001d8be6d1ec4sm2162999plg.39.2024.03.28.15.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 15:49:42 -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 v2 1/4] gdb: aarch64: Remove MTE address checking from get_memtag Date: Thu, 28 Mar 2024 22:48:47 +0000 Message-Id: <20240328224850.2785280-2-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328224850.2785280-1-gustavo.romero@linaro.org> References: <20240328224850.2785280-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 Reviewed-by: Thiago Jung Bauermann --- 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 22:48:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 783640 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp2966033wrt; Thu, 28 Mar 2024 15:50:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVWecCB1+CpfGwSUHH+YdHwGR4oIE2mdjIlL608V1y/XORKuL2FFpp5HBrc+HOizDG4Sia9vqUMbYZsydea9bcG X-Google-Smtp-Source: AGHT+IGJpExxHS06A8VK3/GLx7zZmN6K0l4TKWjiNGJVveZxsFCgQP/TvjiWPc2AKqy3MOyQxkb3 X-Received: by 2002:a05:6214:70d:b0:698:f030:c9bc with SMTP id c13-20020a056214070d00b00698f030c9bcmr112457qvz.64.1711666220180; Thu, 28 Mar 2024 15:50:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711666220; cv=pass; d=google.com; s=arc-20160816; b=yEZpgO4AtQOrCBnvA+WVxWCKljPYZ5d+qymmq5lvAHzQ4SkUJjKxgNcXC3CnyPZ0nu lpo9qQIquGKDKxio7GHXxLKUv0Tpat8h6NgAy3K0R6856NhwvK1TypVAJRKCZSF2tu+R 3dv50OnEKUG+6sZjTDro3Mj3SRj8qzLx2LAtGtwAy4YMnjdfa0K4b96AIxYKBYfHvdCJ aWKL1ngDN1sJW2DSqJtzS99ChTnyc5OJL0LCDUfvQ1O+Bo67bM1HvqpGRCHhmdJNZO81 rRCGAoW6edM5MVo5IgMISYD2g0Q/BJ+/EWVmydZ+6/VfLbzdZf/0lFh00Vt9afZ9gv1V SBWg== 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=Ph3WxJt+ypQ+cDARC2U4iVbM2p0k8o64Aah7lCmWXmQt0ZXToyzSrnYibphYQotVVC aQ0Vi2REWZi826zzai7GdsrF3gJHcTqC6i01A1rbAG9S2EM6Ymw6jr7HHbBDz7yjCuTT gZzaj0aZCtHxZHaumgipelLPygEZKi2MJUnKAFYgAb1W3T0oBZfIWmDFdPLkgyixyfjo GXQ0FlBJtjsiJ9QMwHKu3Y3QQtOHigwMhB+7L/lc8t1u03U0cfn50DGskT6FKiT+IcZd veBuYU7wVScIQQWtDNoCtpzvJkvKVNSY8Iz8pop4DhgTsr3T2nQpuNX0W3kxw90Ur7Ug 8gWQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w3tdlu0O; 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 ea19-20020ad458b3000000b0068cd864e437si2410994qvb.325.2024.03.28.15.50.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 15:50:20 -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=w3tdlu0O; 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 BB6BD385E037 for ; Thu, 28 Mar 2024 22:50:19 +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 4E2523858D3C for ; Thu, 28 Mar 2024 22:49:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4E2523858D3C 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 4E2523858D3C 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=1711666188; cv=none; b=EVRN9BfGEpFGGvCQsoDbdJnDA68yrqbTuxcupdNpMEv35HuCyRlncVuQk6hODBj4GiY+ffEeonL21lYKyo4ZG4uNCKC1tPc8ks5GpCSUix/7Y5TLjzJTQd3SgbVuyG9aXHniLvhI7qGEat2JUZhtJtVOnGimMl97GXJAuESowhI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711666188; c=relaxed/simple; bh=Ot07zx98/HzRqfFiuW6mucw3t+ApYoI7a9eYGtpH+b0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=wHLlX8Rv6kwgdCHrwztGJZ+kBqqX79o3clZYiEBlVMpy28NslzsPMFWOtXaN9YZeOINESVa4o/CFtUhi8RdbA7JNbkwKFoFp4KSxVheUPKeuBTx3UdnFuIiibFT8NBdQRFGQ8Y/JDgXu6WQ1CGTI5hR2L0NMIaYXob9gmx3Q43M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1e0f0398553so14662725ad.3 for ; Thu, 28 Mar 2024 15:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711666185; x=1712270985; 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=w3tdlu0OvciO8p8Ubr2Gtoy2C0Jd+GCWQM8JKplflsMiR4frmS+OpdQMgAH+4GB8AD JujasGYs/cC/MvE2NAw+Z+TLKqVaALUO32G5WIc1yXl+DOeRur7dy5GJkRuY9F8E6Bj7 9EfQEIw3pA8fdfWTXcnLHxwQ70mriWZ75X+LtHALSX/g4JJ9IRf2LDpcbNFk8r0kZESp zNSGEAU8xO43+hlKcRTqe79PPL8qWeORvYfMUj+dNi/CWq5UGpFxJABI1wZfhUSR7Zrf 25NEnvbacboHKf5m0Tywp4xOzY2Z4YHG80jYK8r89iFbMaZAvksFxgeumfO5kbHCMmcq J/eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711666185; x=1712270985; 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=ml8xVvfCl6VwVhqUPkjinyohT8U1XW5xsXXtrbTn9qsDV8wuiTvJKPSkg47Y5221bt Xa1Ip3474kcrXAPMBxOCBX3N7g17x+LFkz7KCS4qe1rb1cDUC5pT+T1w5O5scgHC+/2F ZttgTNsMHN+toJ2KinSxWayJTL/ZNMatnOlxXPwz5bXAsRG89f1riLXaOlpdxTZ0x6SC lLxAMyHE0ND4J6aCEl/7cPw2KxxWYyUUWJIPcltaVIbUznSoxx9MzOOwcNu1LqTUxsjP meM1nk+dl1oUfbnARxjPjDTfJjHRFHqn6OMGa/nnQrs1y/LL6TJmeT1fh11TLGoLN0r1 7IPQ== X-Gm-Message-State: AOJu0YwSO8vOmBKxdRhFzY9i6gAp57+aMSR7tXsClOwfbvJpQ1KI7/df gNaL+qai8DjgMDzlCtw/18uO9ka2xlyJga/O+0d94hqeptKEXHuphA4aLG5a5zwkP34Cq2n1gyF w X-Received: by 2002:a17:903:22cb:b0:1e0:b1e9:afb2 with SMTP id y11-20020a17090322cb00b001e0b1e9afb2mr1119745plg.7.1711666184830; Thu, 28 Mar 2024 15:49:44 -0700 (PDT) Received: from amd.. ([2804:7f0:b402:d0dc:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id t4-20020a170902e84400b001d8be6d1ec4sm2162999plg.39.2024.03.28.15.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 15:49:44 -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 v2 2/4] gdb: aarch64: Move MTE address check out of set_memtag Date: Thu, 28 Mar 2024 22:48:48 +0000 Message-Id: <20240328224850.2785280-3-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328224850.2785280-1-gustavo.romero@linaro.org> References: <20240328224850.2785280-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 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 22:48:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 783641 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp2966052wrt; Thu, 28 Mar 2024 15:50:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUPf6a8hdUTX615V7gSCS5HRceTZyWZvp8X7wCNVyplc5rPvKv7ze2A9R7NBH/XG/L4X9E1FphQvhGPDTyIo4uV X-Google-Smtp-Source: AGHT+IHvleyoAbztMN44Dp8BmfsmJCKOJanBzgHE+Ykba449I5rxgo64cnSAJ/9QSgZOFMGJNzwm X-Received: by 2002:a05:620a:5623:b0:78a:3524:11f with SMTP id vv3-20020a05620a562300b0078a3524011fmr1343639qkn.10.1711666222840; Thu, 28 Mar 2024 15:50:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711666222; cv=pass; d=google.com; s=arc-20160816; b=y3yF/CrX6d609iRPskxP6xp3dq7psD+8bDbdxcD+h+5oz4ntL856AjSgTEuVlnUDEK RSuK3v2eW0rIKRMN6neqXzkAYhFYYb0H5v2GxErEhOtoQ7ftyRTLjHhUtYftGItaRlRP 9DbKgnr27DVoF6uMhG3x8dVkhGQ/ohO/SQR3GwlO6Nnjomu+HdxHqSJK/UZfmgYe1GPa qNn1U7IoeWerNHPu7UgLPl+ojzv2xzD3oGDlRRZA/gZOCxZ0nOheJE1kOX1UlIqZuG3k WwBRaWceWu1AGwUcrwMuzyHL8gjFaPghG68FVVCJniCbQMS71R6rIc+kSam2p0244udl 8dDw== 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=lTMtylkPJ2R2P12VKFLAXf4un0PA9Yd0KF+X0h2gEwa51D/ak7NtIGequf8ULEUWNi O5Rz/SkyK7mf1H9D4AUnsiaq6uyUBxfpoFltt1VsA9k00TyPnMuWLXQRpGP/JDA9fe73 h8hYOr+6sEAtDLv89G5Xdi18M6Gl8xaeTlpCtx6FdX0rs6VVlITlth0ATElANoCKiKOW wKkzMGxKkIQbsYk1bRpP2LVrLWIqPvJxCa1HMkD9TYZ2nQ7/gPfZN0qvCHgFGyjHq5OU d6q0El2YvUXsx1g46kE7E9yOAtFHJnuuleyfiXhn0Tjd4PDfWTqXZODpqqs6uC1jd6J2 k6DA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TWJ0H1qj; 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 ea20-20020a05620a489400b0078a5e629b00si2847628qkb.127.2024.03.28.15.50.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 15:50:22 -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=TWJ0H1qj; 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 211A4385C6E8 for ; Thu, 28 Mar 2024 22:50:22 +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 3D5F03858407 for ; Thu, 28 Mar 2024 22:49:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3D5F03858407 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 3D5F03858407 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=1711666190; cv=none; b=Kxdu3GA14dH7j8g7Zfr0Q+gronFYeMhbPXEpb8WUtUvwr+sVf9rkbpAkbUQmpBPCqCbey7YJomosoF55rFg1eA31pekydqcHL/PoskIDPK1qxPrSaG4cjUXoGsZEOA8x2lNbn19jrwdchTJmtCJguD2ryNh4jyMlf+9a3VyMoQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711666190; c=relaxed/simple; bh=m0zxqCy8ZHC4pqDMn5zPMAeOHRoB5JgRRsV+IvPQPCM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Dcef5/VdYls72LN/TL90eW50I0+YsCDQNwqu6RmaZyOJWK6cIcutR6zYim2aZjt8WHFUb3yhNpg/sK8t2kUsiytz0K2MphBb6cY3kIsCQBa9Abu1eDcktYEBa0fak87Q6Fvs/Y6BHTnP+ARyoRuztigNEyFBgieT1AsO8B+48Y0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1e228c12468so3609005ad.1 for ; Thu, 28 Mar 2024 15:49:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711666187; x=1712270987; 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=TWJ0H1qjnjjqhg582qN3IEviiVMbrkf0El9AR4YLeab8JIRyGBSlON2+JZ38z3dPFx sEX0iYoK/VUWIaPlmV9gf80x41q/JmJEzbl8TyIt9eIz2THwSX0f/1Vp8wt8T4jL274U J0d1AjxVA1gTeGNUxcgsEEU5Qpe4WilDgF42CWnzbwrYC8M2B6UJn1X/qxv2Vw9+P6jW fB0AASQqZy6WjHJTs8EVsG+clPOaoAOcjz9XutEKsCeqf0Kcx4B7kdehihqe+6dDmbm5 UE6eBP8XuEKo63yUMWqEWDNrCHIouU1SUTP96/OscYIwifBGnQckVCzFX8h/5UJ7JISn zYMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711666187; x=1712270987; 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=bF7HuP1PoI41qPgwY0wr2ETzY9R0w9Iqam+ex8MkEI7VDNV/LCwTYliVRCbyd/FZHv DLHbTW2VcZq5MU60yjsW7U4Y7zRLbugTm2Ej2gdeO/zIBGqGGgk+GNvRSlqhQprZHXor OiEF8PdTZtfqpg4s23yoNAh962GITl8CxJFlpZAJ2xmX442RLWluVf876RUZ9ZsOmPUo Wyay89MZWKFcOEXCSFGJvDgfXTQgRKDB5qQiVFSANMz58PNviNYmonlYo3lSvzkgk48W qAtg2AxFuIIop/d8o6bZQQVKM3/vYvaFSw6ph0g03DlFq7XGZEOGXY755HQsberi2kar Bi4g== X-Gm-Message-State: AOJu0YwoLrPJmohORyqgOnfMqnh/VH/3oVicmSLhWEpwaUuZNlyw73oi 10zMzLB2sPMAokfUEe/Wt4Y+RIgZr1t/NW4nib5x5KT6NNoLv/35uJVoRwO0yu8QFWJvyRkFddL O X-Received: by 2002:a17:902:7686:b0:1de:f571:837c with SMTP id m6-20020a170902768600b001def571837cmr4699419pll.28.1711666186793; Thu, 28 Mar 2024 15:49:46 -0700 (PDT) Received: from amd.. ([2804:7f0:b402:d0dc:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id t4-20020a170902e84400b001d8be6d1ec4sm2162999plg.39.2024.03.28.15.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 15:49:46 -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 v2 3/4] gdb: aarch64: Remove MTE address checking from memtag_matches_p Date: Thu, 28 Mar 2024 22:48:49 +0000 Message-Id: <20240328224850.2785280-4-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328224850.2785280-1-gustavo.romero@linaro.org> References: <20240328224850.2785280-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 Reviewed-by: Thiago Jung Bauermann --- 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 22:48:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 783642 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp2966154wrt; Thu, 28 Mar 2024 15:50:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUApuvox36j9nEeGTdtTdX1lmz4vQXE5wLj3TPF9ft1VFCRz085P2icCENhN50IfoFbzYm0L36hC/tIle4ehks3 X-Google-Smtp-Source: AGHT+IFZ5jQZE2Ulgf3ny9lV9yv8zK1KV5Cj/ZiyUWUCxGzmC2+iFFHjaygy0lgP9UOim/Y+prwm X-Received: by 2002:a0c:f00c:0:b0:698:efdf:f3d7 with SMTP id z12-20020a0cf00c000000b00698efdff3d7mr153705qvk.32.1711666253028; Thu, 28 Mar 2024 15:50:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711666253; cv=pass; d=google.com; s=arc-20160816; b=mMzeDqGz62dI+qQuAhuqUw5cI7baYNKjIs8xdQAhVce0iwij5KMs/vr/47N7FFxQhE V/KH8da+bLeNwJjnLmxDFg8GzbPo0VT0yTFnNYGi0my/yyrwjceWnrPsjw7zDG9+VmcC 31V0mAeJ6niJkpDVJ85OuNmPydeEwfCTPQ9Nxr576h1P6/+oCDyM3ppATxryCtEqAv9i Pz+uIihYDRN+EEzSrBoEbU3//4r6hHFCW8z6stlavRJji+D1gbaNCWgDi+pHIGqIyRbi 1eiSql0ID9wOI5QWYC5XZ4wdBHN5K1vZRzMiT1i9ea0Bz/Gl4Cpv2s2fBX15D2QtcsLe 9bTg== 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=HPJ4RZnxjbpN/TedBXWCkizcOMgXcXDslptn0wSdI6E=; fh=ip7+QkkM488k9wyzFaZPu3h7BUQARzj44zdeG2KNIXU=; b=CYFS9jclmwEthxKQYizLyNKqqPNZI1IFh+yiU/z3/uxsndAqutMz/M1i8QH1u/AOOh CoHHjS18hjcG3npn3hXnfOcjM5PYVYdfd86peXNwwJknusum7x7WYZ0AslgnBjVCG2cj 312lByOZd1Fx2EL9Cnnxow1tvqyoT3m49auYt55uDtSNyKQ4x0uEZQSBU14iHQSjJSoU BdiGCISQQhdWsqU/NTG851FX1TSV/V8OvjNMC87dPz0D55uC543e6NRwW60uvIxaXSjA 1XLtBJEjJ7nWlxCjpe9gFSiyasxemefXvaVnN2OontaN6KiLoUOpK9BSB+zxc/g+DUs7 G+VQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UbsRHYyX; 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 l16-20020ad44450000000b00696b0106038si2393010qvt.347.2024.03.28.15.50.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 15:50:53 -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=UbsRHYyX; 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 911243858C78 for ; Thu, 28 Mar 2024 22:50:52 +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 CDB5E3858432 for ; Thu, 28 Mar 2024 22:49:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CDB5E3858432 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 CDB5E3858432 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=1711666195; cv=none; b=urrD+MiRCVIgc4l5kyvF0IzV2eqjpNmWKhxsM8u31/GbP/GaUkkjvawWDVT16uuBvHxBNW5lU9XgzBwAl2Ms/AcMWa75+RIW54ULrJewx2eK5yMt/OeLMKVQrBxhZChNLcykziyzWAEAfTd6Lf67MfGkC/EqV/7AWe2yX5mIpBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711666195; c=relaxed/simple; bh=Clxv7Gk0iU5OwJqJ/lXa6lnXHw6ixYlhikP0RbNbenE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=RPApL0Nbatl+X7xwstKaRRH51eJVlBVY1NBcoLQqoeLym/9pxuAsGFeXkzBv+1jjdfsOQCFUkz4OvGv/08Plz6g0aJ12IAvYkv9LHxL9WPTGoiON7DwBl7k2nGyJW7KjuPUfJy+gTz5ATTjL1zC2jnpelp2SkoWSB3+mFuybtU4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1e0f3052145so14552865ad.2 for ; Thu, 28 Mar 2024 15:49:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711666189; x=1712270989; 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=HPJ4RZnxjbpN/TedBXWCkizcOMgXcXDslptn0wSdI6E=; b=UbsRHYyXjWg1K8q7o5/8cfXlIYtq68ZVsPUT5ezINDYyBbvbkMD1/fUoIlc5UJH645 TgpaCvlKREUkjQVGNR2AHpMNLwKSx7nQ3kdJwgqNLwRf7+1v3YRB0zkuLIA4e2ZBwKT+ a3sjox0FfcE55ictonqTjlR3utc7mQaHIlnB5mTC0rusNFzzVHAOeq2EW8aVh0FBsXGh X+I8/L7X78tGJyeiBxEZypgVx+Yv96sDKRu3Jwj647ogL/RTjyJp/t/cHW1Vwxi4Ju6c wNlh15YMATrpxJlKbFa6FwSIkzh9w8VulRXDTDtzBDUlV8p9Vav4NaNHCoWxjMDHlPdM l2ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711666189; x=1712270989; 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=HPJ4RZnxjbpN/TedBXWCkizcOMgXcXDslptn0wSdI6E=; b=mit5cNJe75lsDt9tUrQY/610TW+HClYyZD79HttGy9YbGmy0qMaCYo1UI7wZqrfI3W zJESu23uanvPYv/AusAtPhfBEkqyr2SXAQKgTnmYuCsX9IKBG1Kc8M6lASDz4iuk+eWv nP+vC2n1yytHja/sWouI/O2xR9hVFq4GIyAnd4qjXZZvv/cy34AhvSPdBkuReS36hXzW 5wmAcHRocp46rRYLZXVaMds9XQu8HI94/xMfOvqOAgRIFdKcFBKXHKqvoURMB5EkiRyh PT/YbO7/gTYP50obqCN5iJ5pis6+FRKHhxp298go95QjVboLibTZJQX1Eyp/J5c5Mb/K tpVg== X-Gm-Message-State: AOJu0YyhrQZZBTrOCoR1DJhcrYYkA3pmkztgGWYOdkYuoO0XtR5pkqxz j6MGICQkyl2UjAR8Zb3Nx1k7i/dvi+iLP5zGGPD3S9Ap6+CMtB1srmcVNOHiKb5eB3hD6kSerxp h X-Received: by 2002:a17:902:c18c:b0:1dd:e115:3368 with SMTP id d12-20020a170902c18c00b001dde1153368mr741200pld.68.1711666188983; Thu, 28 Mar 2024 15:49:48 -0700 (PDT) Received: from amd.. ([2804:7f0:b402:d0dc:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id t4-20020a170902e84400b001d8be6d1ec4sm2162999plg.39.2024.03.28.15.49.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 15:49:48 -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 v2 4/4] gdb: Add new remote packet to check if address is tagged Date: Thu, 28 Mar 2024 22:48:50 +0000 Message-Id: <20240328224850.2785280-5-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328224850.2785280-1-gustavo.romero@linaro.org> References: <20240328224850.2785280-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..c5544d2e53c 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).status () != 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. */