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: 87750 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E5526385EC49 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-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-Google-Smtp-Source: AGHT+IFX71jFjkSBudbrvLqbq08EGLwUUocTi1vJmiV0mOSBOVy9oxyxc9n/g4abbg9E8Vwk1UvKKQ== 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+patchwork=sourceware.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"));