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"));