From patchwork Tue Apr 16 14:07:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789231 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:dcf:b0:346:15ad:a2a with SMTP id dw15csp304703wrb; Tue, 16 Apr 2024 07:08:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUNNQHkeFGwaV2+MsLafpABlIjEHtjWN0IqkaJndwoytafGNyjauROXoAxs6BC+kS8ouN/fagC1pdqlNaujZTsz X-Google-Smtp-Source: AGHT+IF6fQSYd9KdHBxqEUHMnMjHviFSJtr18IbvYRsdwx5zQ5rvHSOwfwf8AFXMJ3XsCf8Do2rH X-Received: by 2002:a05:6830:11d5:b0:6eb:785f:bc1c with SMTP id v21-20020a05683011d500b006eb785fbc1cmr9152442otq.16.1713276526264; Tue, 16 Apr 2024 07:08:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713276526; cv=pass; d=google.com; s=arc-20160816; b=eZIZOZpdmuM8L6rIiU9cuueBGNDLqAxdVD8luSL7UgpFvgBvNGVsT1uIgUQaZnIRe+ BDTsyGtDqKkSQL7ME2tOY/pa/G45w+4Q5LjHTcPzmlj6kFbN/ut1b/fYCK0MtYZGMYzr cVFwDTnYK6JUTqQafa9sJ0eEvLXmteBixbuk9u6lZo9Z4COPGVr1apfPMEooV4H7eptl hmY6sRne/+J9zmgCkzUrP8e/nsuVUBBbdudQ1ZW4eo2yS3gX4H73K/tUrI9Ck7MFXRC0 BKcyHIboO/CHMGSZsoA5Fb38Fd+mD0MFjDFSTFH/vOESnDZ+ZwAmFcR5BfM9crHGUaGf nIiw== 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=XYxbCVl1FXv3gDOM6iOdkdM2eKMXrox+2an/RLVCH9s=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=oO4xdq7j1lpf+N4Rf/hetSYLJGui7Vmq0fHU/zRvpqEgvMDo+/NpjZfgxplua3r8iG ERlBqqBQ+DV/cjtYSV5itzKKuBHctpS0K0zBzNjTXh+A9I818KqvBsTFEtYICivqaccI 584QvJKUE4QeNSccWe8BpHjLitu9UpkEmAz0SPg+RWJNtiz2SP7O28QsUt9p3kdO9SX1 ufzP0DcVxhGepv9Y/pUL84P60gjJkbYHAulIS7sx7X2Pk+HkgZM9+NwK2QQdq4Hc3GVt 8mLyv1sNWR7lcci9w7AiEqa/oJDpMrYZ6vI4EaAtsiqKSD3zlvSb25WtyuOhdlbtdoxn Qhfg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FIO7FaZF; 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 g13-20020a0561020ccd00b0047b9861b6bbsi208155vst.795.2024.04.16.07.08.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:08:46 -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=FIO7FaZF; 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 B1F6B3858427 for ; Tue, 16 Apr 2024 14:08:45 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id D7A5D3858D3C for ; Tue, 16 Apr 2024 14:07:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D7A5D3858D3C 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 D7A5D3858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276479; cv=none; b=mhQCNn+g097GsT12BAKpTs8mm/Je4p4jsmW+goza1rZbKIqtKi9wSfVOeAx6Mll+0LGcL3BT0kactNxSYCmNUKaTZ28lJhdnk8h/IBP5n/iWbMNf2a1oZcaqvZ2nE7C7Jj4HI5hMPhZkS1ankA0iMkV5e/P9489hwZ7QC3Wf2aI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276479; c=relaxed/simple; bh=3wFYPzMpcsYUfRIUjgt4vWvnnR5nfM+xAA2QmOtJ+aU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=P3VDItNUXkuZq6cLW5NL3+ugY/s0UrwPw9GXMKMxL8Ma/VsCp4/lBznBUgSFeVmCPP0Wim6b0ZISldDNMfOTM9jsiA49bEE2L0fMi9iScPlzTx7+rK8WoWVvpGiIsLyabQlGMuG+ZY5X3fzkk4TL4qUZZ8ZflG4LB27lI5zeuMA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5d8ddbac4fbso3055133a12.0 for ; Tue, 16 Apr 2024 07:07:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713276467; x=1713881267; 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=XYxbCVl1FXv3gDOM6iOdkdM2eKMXrox+2an/RLVCH9s=; b=FIO7FaZF6UO5C2+cVkpnC+502A525ZFM3bm0j8APSeSLkHY8oevoktLv4QLm/6ksls MW6WCt1d+OmS4B3vbNhhnmsbmka/VTF5dud+DGmpoEqQzh3RYw7WZ7wJCBRfe+oP7O4A eCjmcEFKf1hi3SqP54wowZtSzeBEwSd635AnMQI72avEaisWG/TEAyS0D+slvnumCFrr B9kvuwB2tBNOLm6bSEn6dVVPsojZPEcgLQp/mxsHpJGrHdXxThMh6hEQ5NRbkqWakv48 9bWb5eDG8zSITj5OIOerTMSjSwx4/Yp4MvuKrNKW3WduGzWarQJWXgogcR2u7coXBEn5 3NdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713276467; x=1713881267; 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=XYxbCVl1FXv3gDOM6iOdkdM2eKMXrox+2an/RLVCH9s=; b=Bzy7jxImCZ85Dvrzd3LepIy0oLKav71xDZnNhDyVIKpDtGpgjITcnf/0QnZ8fdKdSZ zUuHutO/9li+50T88scqJ9HMsHffiO9Gbyx1gCEaFiDNk52NUH5s4rhfl75bwYG+EVOf FuIAyTxy76CI77qKOlGCR02ESZll2zBMVZO5rB6xu9f2urKwPKh5fzgHuY2urfCBoho1 +mdg+R/clRcKtOnr27fxSJzxA6xYrco5jzDLMowXXo/cQK66zVu4O+Ze/o891tWUGEef khvgPrHyhYhYHZ6AJhWfS+V/HSTCjiUVXd7twA1qUhV4jWAD7iBWVOopSQAh4SAyCyst ghYA== X-Gm-Message-State: AOJu0YyOP5UHhGO1nOaUNLbKbcCSuh/4JBH6HiqorZncvqbzbk85GZUg sMSsRw3xihbYs8xga8H/QWAxoK45/9joWzEYz/dNbGLcxgrHePBVG26M7WRWtLEUHdYtxJxummp crX4= X-Received: by 2002:a05:6a21:1644:b0:1a9:c3e2:65bb with SMTP id no4-20020a056a21164400b001a9c3e265bbmr15276020pzb.14.1713276467290; Tue, 16 Apr 2024 07:07:47 -0700 (PDT) Received: from amd.. ([2804:7f0:b403:ad57:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id o3-20020a63e343000000b005f3d54c0a57sm8937473pgj.49.2024.04.16.07.07.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:07:46 -0700 (PDT) From: Gustavo Romero To: gdb-patches@sourceware.org Cc: luis.machado@arm.com, thiago.bauermann@linaro.org, eliz@gnu.org, tom@tromey.com, gustavo.romero@linaro.org Subject: [PATCH v4 2/8] gdb: aarch64: Move MTE address check out of set_memtag Date: Tue, 16 Apr 2024 14:07:22 +0000 Message-Id: <20240416140728.198163-3-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240416140728.198163-1-gustavo.romero@linaro.org> References: <20240416140728.198163-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 Remove check in parse_set_allocation_tag_input as it is redundant: currently the check happens at the end of parse_set_allocation_tag_input and also in set_memtag (called after parse_set_allocation_tag_input). After it, 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 on MTE address checks. Signed-off-by: Gustavo Romero --- gdb/aarch64-linux-tdep.c | 4 ---- gdb/printcmd.c | 10 +++++----- 2 files changed, 5 insertions(+), 9 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..5635f605314 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -3101,11 +3101,6 @@ parse_set_allocation_tag_input (const char *args, struct value **val, error (_("Error parsing tags argument. Tags should be 2 digits per byte.")); tags = hex2bin (tags_string.c_str ()); - - /* 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)); } /* Implement the "memory-tag set-allocation-tag" command. @@ -3127,6 +3122,11 @@ memory_tag_set_allocation_tag_command (const char *args, int from_tty) /* Parse the input. */ parse_set_allocation_tag_input (args, &val, &length, tags); + /* If the address is not in a region memory-mapped with a memory tagging + flag, it is no use trying to manipulate its allocation tag. */ + if (!gdbarch_tagged_address_p (current_inferior ()->arch (), val)) + show_addr_not_tagged (value_as_address (val)); + if (!gdbarch_set_memtags (current_inferior ()->arch (), val, length, tags, memtag_type::allocation)) gdb_printf (_("Could not update the allocation tag(s).\n"));