From patchwork Tue Apr 16 14:07:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789229 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:dcf:b0:346:15ad:a2a with SMTP id dw15csp304447wrb; Tue, 16 Apr 2024 07:08:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWFkLOU3RZ9ByMK+bs/rsQqmfwlNKlRiZef+6oqdhjHAgCN52dCZNfwUMDK0y/UWNUCjc4zHOzlNSMZBA8/npbB X-Google-Smtp-Source: AGHT+IGqUgYxPeInLkDvlypwoCF8kttAj444YDACGdQiq5h0o/0xxdJ39AYgXo96nCml4CKGcU2r X-Received: by 2002:a05:6358:38d:b0:183:c2e1:9b4a with SMTP id a13-20020a056358038d00b00183c2e19b4amr16130915rwj.18.1713276500020; Tue, 16 Apr 2024 07:08:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713276499; cv=pass; d=google.com; s=arc-20160816; b=euPpwIKrUjEGohfCrD8eu7uozJxZG+fixXWPaG93FsZN7OApea/uKB4gzi0jgGlEEY wAsagKGWmqmQ8KiRtB2iq5FGIEE/3iYTH9HBCOiWOR5OT1+XNp37d3HBMvoEdKh1mZVL x+RfKIVCM0py1jP2U+zgYYjcq+YDT5GBAAVDshVOlhvOGbjIaXEtEo8qUtlP3pzbRqDY tKSkDTTgwZxDCPQXP0FSYH1R5dYuTJmAzKNgjmOzSlPep0BUgqv93xZ/3E1LzTdhEPRo ncpEn1YUbnp/G2oIfHlg8w0rMYu9JxDtdYowwv12USnbAdz82Ze3zCJtEwm/5GxjbHCj iFQQ== 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=tYCk/P1xjalYBJuMqLUvPVXaT9Bbd2Fw6xG3npnM6gg=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=F9KqBj5seGxQJaXHMqx1nhtioJeG77sMHTZsYX8EEt597w1mAIeaVG1htBIitVBy6p 3jZ64GrcedrS1dvU2d8zc63mkrkKVMr+WgzyS1s8pABmLWPWL8+BggLSTB5vdo6f1PNG 0uzOeI3qtFb9GFmZrxAw1vWUzTRGOBK2UW+3nCIXB2PhBfg2aXY7Xdh9oPoEZMO0HQam 45vIwU9NRV3ZaZP2DtDLdN18d72JfKaUunvd0sAPPfCOeE1bXVXgaMxkVwHZ6d+FUPjz W6oRxsO8/MWzg44o4NIiVELB3wwFerrMZ9ieYCrY/GFthAj3eSNdqePQPwx3R+I2I7ER w2Uw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mbGmm4iG; 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 eg10-20020a056122488a00b004ca5ee0dbf3si2051311vkb.314.2024.04.16.07.08.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:08:19 -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=mbGmm4iG; 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 84BEA3858D35 for ; Tue, 16 Apr 2024 14:08:19 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 5A6D43858D39 for ; Tue, 16 Apr 2024 14:07:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5A6D43858D39 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 5A6D43858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::433 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276476; cv=none; b=Gz/B8WRjbs6ZXXTQCdCWvULTG8wKz21caDV3HUMpRIM2kbs8MYOQ9emcr9pJGkeo1GS1RrAYV/+aiImW/IpdLATzh5Yt7elAmDLiGgb7fEGE+6WgJdHtrl4ZEQ2UkRq+H6JHm0SIUN22jwqpzO0LOmnEpTarqlLaIt7YO6ODJn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276476; c=relaxed/simple; bh=zn4DbmTot8VHmhi87qT4JPigPp9gYVtGLVN1Tzseteg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=GWdWRQHSSmLlRYoxol+I5pAb0/jE5Urw9g5IcJyZjkSN2gzqV8pw81gJZj9z/CD4+7gRudfp6XTdPvX84Iz52sNFG5tL3X+YJmBN8e5Tu69okCEwN7tibg9nt6sG+sLi1V0+RbCdyySsgFmQp6cT2LgQs9kbgxldUOMB01xHBZU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6eff2be3b33so2173416b3a.2 for ; Tue, 16 Apr 2024 07:07:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713276465; x=1713881265; 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=tYCk/P1xjalYBJuMqLUvPVXaT9Bbd2Fw6xG3npnM6gg=; b=mbGmm4iGXeQ8j4pVCaXCuRgO93GJA7IMwhe2Ib/PJ3Tzm+hwhvfRq4UC4+1XE+TE/E 9QryPUmQPubEbBBX9aM2hVDHjJl4YITVZTRCs2NCMBFMWUiSO8/9p0nOuZ6HmQKaeecV Df+yGcEvVZLWEhHpu2gUYzJLrlb4fpBNl9CEd9oaJiQyUxlz4+QBQNDOqu/ajdxWQsAe Ikqvk8iog3Oca/BQ7Dpmebsu3vWaZFMmqlSX4ufSQCzoE1Xu206sekCsq/h/KiY7P5V3 g0YOamRUBwLfGQz/GPwsCQG7t4ren8J2BaUcBuwXkXjw71q+1syXDUpU3uOBf3cF0cm2 Sj4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713276465; x=1713881265; 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=tYCk/P1xjalYBJuMqLUvPVXaT9Bbd2Fw6xG3npnM6gg=; b=hUre2dZKwsZ+qiVpiHNxyRkkeIzaGZsOj/6xNNLhWBk0bwEi6op8ALDRLG/komNtN2 1NGbrJtAHLb79tOclMG5qgfISzVGGCjatPF+GushMEgItqOu/4joLjgK8fO4sYEWpfJz 7s33EtlK7hktsRksQHtq0ZRzYn8CefsRDp+Kso3H96gO5VN6IiD/oc4dtCJdWwmfg9FX 9yhDdJQL9Igbgpz9Bv+xMJUJn2hAclMtScEkFGzY+XILHQy5QsggtRcG6E/k4FGWyGAV vT0IawxZ6Y9YU2FZWC+z4uUhNUEXhbtFwQkgMCEM5G6SUh2V4K4RnKOSbnqL2bAsfyeg p5SQ== X-Gm-Message-State: AOJu0YxJDJSuR+ER2S2MSzjMUs54Tcsk0w24bedsFENwixiZEYdBb+kd ZOvf2GWo2S3JH5yLIxlsYr8v1kB0Srdx41j/tLrLfZ56yg07rgB4ElGYw/TIfxnkfa0GbxdPiLl RNLE= X-Received: by 2002:a05:6a20:d487:b0:1a9:c3ac:be77 with SMTP id im7-20020a056a20d48700b001a9c3acbe77mr11997225pzb.1.1713276464760; Tue, 16 Apr 2024 07:07:44 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:07:44 -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 1/8] gdb: aarch64: Remove MTE address checking from get_memtag Date: Tue, 16 Apr 2024 14:07:21 +0000 Message-Id: <20240416140728.198163-2-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.0 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 Approved-By: Luis Machado Tested-By: Luis Machado --- 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 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")); From patchwork Tue Apr 16 14:07:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789232 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:dcf:b0:346:15ad:a2a with SMTP id dw15csp304918wrb; Tue, 16 Apr 2024 07:09:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVbXNhd+Ab0Br8ItFecrs1+4BwryGi8hm4ZJWTW/+t8dGOf4cvBZcyPV7R26XS6CEGd5HvbdNcwV0dnSKAikJws X-Google-Smtp-Source: AGHT+IG/MpNMhF0ptixtdEGbxCJt0cNxjT3EB6dSS2VD98+uKyo2GDq3NPtYPHENZf32NemPKhEt X-Received: by 2002:a05:620a:190c:b0:78d:7802:16fc with SMTP id bj12-20020a05620a190c00b0078d780216fcmr15862541qkb.49.1713276549785; Tue, 16 Apr 2024 07:09:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713276549; cv=pass; d=google.com; s=arc-20160816; b=aaJKDT6xduIrSKPpXxu8FqsI9daGkZbdQdp77qzHi9blLIY6W/JRHb7BhzH7929ZXP a+ANu9oIG819D+zKeNx3zi9FP0sz12VlYUc2i4qzaOe3bUxSlhetv+4QhlHGtH0QQo+z jXRT4jTWG6iSquqUrpvynlLqW+a/o0Ra44RZtVe9BcNPXZIz3r9LGaHg9cRiWuVooPxZ DI9ULMuXbcPXcIVR/+W3JolQ67Xrnwnf8XV3klqfrJA1PO3AVDZuJF9QKEccyORW5Csm xk1WVu8sOcmKWhCOhfa5ur2KgKexDSxROgf9qX/2OEyFlYFkfo5jvRgx1D5w9Qz6uqaX DS/Q== 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=k4t/OkSdqXOFOVdbmZG+QDE0aaiWd592cOChHpmR15U=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=NXXjjFecaO8kpeSZpGtSvjVu7GpUgAVvU4ppuO5+j5iey1KdGZ9ahF5kP2kkhljK1D 01vMFHWWLzXldz5W6YKB5cHAKhpBU7Hv7CKMv21pBWrazTM4qg0beWM1ObF/n5qnyhuq AF3uGBnFcWloOcS1Ihz4R6qx/c1QMpUZjfVpts/RnbMNgQXybcp8EwHIXpHk6VPeFw9C Sj76H3JTKPfXSekYGQgrfA46s7bhv+1WMduYuxP9eOdCngLb5lVvvzR/FRcGMhwC63+S 0Bx8L6yHvLqOy4ro2/8TGcMgLqQ4pd0/UhBdK8iXqJlQytUm+gmrY63KiSVwntJQI0BG yd/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dNFdL19d; 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 v17-20020a05620a0a9100b0078a5fc2adf0si12314702qkg.138.2024.04.16.07.09.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:09:09 -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=dNFdL19d; 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 1B22C38460A3 for ; Tue, 16 Apr 2024 14:09:09 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id BDA933858CDA for ; Tue, 16 Apr 2024 14:07:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BDA933858CDA 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 BDA933858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276477; cv=none; b=yEUva6kbmDF73cw/rY46oz+8ecvMLK3HWzpgtAK5mcY1PeWU5v/loxE9RvN6puEV2bTHFX6DiDabm62MuL/o756dXCqi4dV46WsB8zDxfVkWdwrw1dJlWeJQmrLe1hsX1dXuPLfslh6L5vIW2tZtAyVdxxI8ne9VqJIs8P+/SjI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276477; c=relaxed/simple; bh=WxhGoGvDUNyHMS4tOjdoth41+fxv5hm536NHqm7b6zY=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=TrIhqZ1W4G2wEeqhPrfKXmi0sWedQN1GDJqP2YTN5CGfM3uJlgLy1cTyrY7T4soBZe+Uq4Qmt04yRX7X9Eh3K+sxcS2F8msp4b1/gl3TQS+lgGAWl/+PaOOriD4u2FuPPQgff58ecQb+SJTo+2+ahA0w+17q7lmckbsIwDOFwVM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6ecf3943040so3515803b3a.0 for ; Tue, 16 Apr 2024 07:07:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713276469; x=1713881269; 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=k4t/OkSdqXOFOVdbmZG+QDE0aaiWd592cOChHpmR15U=; b=dNFdL19de/q8RksWV8R0X0vx/ia9BRg7pSYUGSwEDMN2b6cnjaIIbq/DOq+736ibvr 3biDpcmSaM9BeQCe/CSlTJ2QebgM1MbjWVoh0X+3n28oyia/PtQFoonYExw6wp5QRU8p rvXiPc+ckyXvSpdG/9jdIjZJQlkEkyvpo3cuidVCqBUc3utsaTfGP5Y+91pTjPyqTO1/ F4CM3GyrQ9XJwX6IB/CMFoS/4KKCoBeuZY7c1PxF63avkBtBRKMoWk3S8s8LVC4iY1wK n4IsMXUi8FbgxuUUAND3hWvxRt9B86069nVSXmYzs7NzSECb4gk3BdnV/UHKSSGLVZBz TAmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713276469; x=1713881269; 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=k4t/OkSdqXOFOVdbmZG+QDE0aaiWd592cOChHpmR15U=; b=nQ1XcTUO/2xnpIXSTJvEXzrv70EOjJPnED/CRFkCgmZQA8LXW6b29jbVzfK3gLb+tD sWyW7REmqzK/JIPTtRB6JOJAD/DwdRkPK5L8m8bacDDrxCEggR1BbeF9MFvtaPnCohhi G/8JWluzaASEicTJgOR65x/dVgPD5kvkplcpcX9jratVg30tTik6ohhwWj8bVqwmHoXX fj5yAfkBGjuUOY7EXteMMPA0uxkWOM67HKRaqpJmQbIbE3rTSUl2z4A/S5mJhXlNSOeh eJ0Jsdoz0K8S7iGimukZaVtb5n9pmeLJEnNgQEKYfkth5zcnTbs1nmyYyvO7BQ2uiFAM Oqrw== X-Gm-Message-State: AOJu0Yxf3uZYfaoItmYBZKTkAwjQqmR5j9o8ByQdGJg6XlgVw/vuyTI6 pXan2VAhmKwfKBEcmRe+2eS9sfPjK+l1b3gL7iSBL0nzzqCjzgomTESNdpmHnZjAPJKH7ubQ57B B51I= X-Received: by 2002:a05:6300:630e:b0:1a7:a21b:66f9 with SMTP id jn14-20020a056300630e00b001a7a21b66f9mr10310191pzc.43.1713276469439; Tue, 16 Apr 2024 07:07:49 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:07:49 -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 3/8] gdb: aarch64: Remove MTE address checking from memtag_matches_p Date: Tue, 16 Apr 2024 14:07:23 +0000 Message-Id: <20240416140728.198163-4-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.2 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 Approved-By: Luis Machado Tested-By: Luis Machado --- 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 Tue Apr 16 14:07:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789235 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:dcf:b0:346:15ad:a2a with SMTP id dw15csp305131wrb; Tue, 16 Apr 2024 07:09:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUkqJHQfxlLFWXiLoGr76TuVlAUMTXgNHnu4Dpsj/fJIIxtwIZ7vlMq204d5tc+HtFTd1QOQHjWueK/q3jcwWvZ X-Google-Smtp-Source: AGHT+IHX8FNFrriFDdCldB+470VhevPyJilfEefyMDvN7jDOjV2JXEBJLDJ6XpCphSfpqDHnCWNQ X-Received: by 2002:a05:620a:5656:b0:78e:db33:754b with SMTP id vw22-20020a05620a565600b0078edb33754bmr8183929qkn.7.1713276573733; Tue, 16 Apr 2024 07:09:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713276573; cv=pass; d=google.com; s=arc-20160816; b=oF48H1ftV7H2hD8I160x8cew47A55enaGxwqp4jpu5zVWLsFehcQEQEjmGbiVOJueX D6UoGU1oKigY7VcL8E2XAiArtN9bTMbXeEiIR/IR01Ym28d0ocdABaXC7oXW2EfFgKb6 vHw4E2VbLhsupsik+7ORqqmrluEDcGWJo70LeQ/CjTa4sWqJ9HL7YQV23QynS7wsJ1J+ SJJEH19HQKxRrNxMwV5JuPFDO20XK8qgRbe19r4rXlenotwaF5bAGew/iZNkuwrHOmgY Or3pDr0WfqbEptZxDf15AYw4Xq9w5cqV08zeARH09T1/rwCN0Jmg5PdjO3ZWgLZvlMig gWMA== 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=+Udz0sOQRKXAm5kiKFSTNh5JUUjk+Jni+c5SH40tgmE=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=i38SIqiwNsWJyRProKwG4HzinAX8In8hUj8vpd4CJglaHq8vYz2Q1sZ7Xp9M8A7JjC aZe2DH9ecYdo0cUvc+M7ZcbTjgRCyoltMQim8bfjTAIktYNej9b55SLcalmQqc9c7+m/ ue5NhPGRFb30qhEpyFSy7dhqwXp2MZ01h7raftJWF+joAGZ2gcSpLVf+Ppw5GU4g0qKt T623OqXFGddGdqWpSvF1IV+IlkMSbBPBh131yBz8kv0e4Grnher3vi7pwCPJLqOkSKVx dPJ8LpH3rPE5wV+oJGtwGYNCaSpzulEEH1lO206HHTN1oV6qFzvRCNT1SZZ60y963ys9 GxvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VvmZsVm1; 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 xx6-20020a05620a5d8600b0078d696334c2si12374164qkn.60.2024.04.16.07.09.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:09:33 -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=VvmZsVm1; 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 5EFAB384645B for ; Tue, 16 Apr 2024 14:09:33 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 01F103858D37 for ; Tue, 16 Apr 2024 14:07:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 01F103858D37 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 01F103858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276487; cv=none; b=Lijd5vq1ClNb8H1+lj3nWAvrZYBsMNYemx9ziHe/o2Ya8Of4LTd+Xf6KkPpUQmJ3jnS/ccfcnNA055rONPWCXevCn1vzvofDkkf6It0ohQcOzVanQU3LN3A+yH3agVhPTwWJuiV5JR3x+79o34LvKui/2/BKLVI6kzjftvQdSJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276487; c=relaxed/simple; bh=5sDr5g7U2ywTRYm1e6GUiteL43TzBcSbyiTAO8R27Z8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Cs6cA7JSiR/p3+fTc2AjAX7kxvElbvOUf5rzcCyMus07Si2hKPn+OPlhq6N5HZJHeWCjVHVmfVkbZeM+yLSz1K8ufjdn7H2W7qjiW0MXDoMH+NfZDph85S52bRMIKiOoFfGVAEqEfD4aNRTx4X8btyXWOlnRIISWEZQZCUmqnkc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6ecf1bb7f38so4049169b3a.0 for ; Tue, 16 Apr 2024 07:07:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713276471; x=1713881271; 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=+Udz0sOQRKXAm5kiKFSTNh5JUUjk+Jni+c5SH40tgmE=; b=VvmZsVm1kxcTn3RoWQk3gxw7w2kS280W/KuyR4q4+jQH7faleB9NFwmia1VlRGIIQp y6Iup/NtHRyWffHdHheGLe/uegTTDUmFqohLtU/6jQV8e9uVwJCqxUQxd48d2lmALKwU Hv+SvmgYLdJ7ruBQEoedib5X9sMUbFmpDbyw8axSyBabIiBbN1oxSnqUldWul/ubIgw9 FcbhSz6a68WYNw0OQr6xZXmMkl6hQvi9yfjC13gUtDCLVpzOlzezCPYD15cbelfgb+4f KlWXguZg0p187IG4Kgv4/MVzwTN61WzriDbWHIDxQLlI+ND16WwhVO2pJixXTVjGdMwI wYLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713276471; x=1713881271; 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=+Udz0sOQRKXAm5kiKFSTNh5JUUjk+Jni+c5SH40tgmE=; b=vroSjCwSmlikCAP7p8EoEzsXO/n49856EivtlwMAoGhkout2M3ROOf5n0Zsk2JBVg+ xq+unBsaJ5USzpSR/apHOvRtIpsCa+CarIevW6BLnsff8wy0SbQ+d9i3AnbwWWgDmg0I ATqP7bKPkpunwkr4Uzym77HlG/oNUYtJlfm9B6c87S5sB1N7luEMK2ZPujsq7U6FQ9ED lWpVXFcNoL1vlhY+IGaoB/5elMbRtTeY/rWR7SB/74q7uS7HCZpto4j19P0iyTkSTIgC KqzbcH83eDrNaxegjTmsMWmw9pNEj4hHBAI5KIGPj1C+pcMBK3yP2Kwtom1lZdrPz+v7 a7hA== X-Gm-Message-State: AOJu0Yy52lF3T/r8Pw5Tlp5hu+2CAk6urPxwHu/t5wqxT+1DnWWCObb4 WNLFtZER+Avwq4D+wChsa1M7ShxdiLIB8ziuutPzufltEfDVYCir8pGA56/6D0AuLGLMw8SnVXp dozY= X-Received: by 2002:a05:6a20:9f4d:b0:1aa:584f:31b1 with SMTP id ml13-20020a056a209f4d00b001aa584f31b1mr1245938pzb.17.1713276471674; Tue, 16 Apr 2024 07:07:51 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:07:51 -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 4/8] gdb: Use passed gdbarch instead of calling current_inferior Date: Tue, 16 Apr 2024 14:07:24 +0000 Message-Id: <20240416140728.198163-5-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.5 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 In do_examine function, use passed gdbarch when checking if an address is tagged instead of calling current_inferior()->arch() to make the code more localized and help modularity by not calling a current_* function, which disguises the use of a global state/variable. There is no change in the code behavior. Signed-off-by: Gustavo Romero Suggested-by: Thiago Jung Bauermann Approved-By: Luis Machado Tested-By: Luis Machado --- gdb/printcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 5635f605314..4edbd458e4d 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 (gdbarch_tagged_address_p (gdbarch, v_addr)) { /* Fetch the allocation tag. */ struct value *tag From patchwork Tue Apr 16 14:07:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789233 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:dcf:b0:346:15ad:a2a with SMTP id dw15csp305016wrb; Tue, 16 Apr 2024 07:09:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW1y69uct8IsBBVT+H1fbhpiW/+F1cmDsVhixXrMaIX11xewNiqhJ7mYTshBd9BDn6ObsqOUyzO5rd8HgqKEgtT X-Google-Smtp-Source: AGHT+IGi+QoYkZdcUh/mNYHWZEiGorZF0xjLmnwGjOwQM6fc/WxtgOk4UNnhzIj8H7oOPTWvbmkt X-Received: by 2002:a05:620a:3728:b0:78d:69d9:1e0d with SMTP id de40-20020a05620a372800b0078d69d91e0dmr16731462qkb.62.1713276561599; Tue, 16 Apr 2024 07:09:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713276561; cv=pass; d=google.com; s=arc-20160816; b=Rb6hvBTUhGgqk65UIKe5xtb7wfZ6wQ2zu5zDZAPIFI2yzM0ZTO0pl7nTXzl3bO8sEA +/gYCXFD59iAWsTTWAoM3xUhoUbxzzAYP3YD2RFeP73L8ADMoEx8SQSEfz0hEjDlND5T iWJw5Gcgice3NuwJ8Kp6haM0R6Tq5nDbUaT8hL24dKJ8MNRv5sx062kY4AV1OmkTxpSI 5UkYpnnD5Ti/gtKgvK/h4b0ihXM9QAi8wB4LotfW494GXBkQdfxDf3+xbhJs4MTc4F2D fY0cwm+n4PLxerNlN3ZaLt55Jr94O6rXLyr2Jwna8+eX8ktNHI3GpB3rhNugbfCU12DJ rHag== 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=aDxb/zg901wOzEIXVG9yopQliPwokB/YWickkC1tTt0=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=ImdsVerxBS2aHvx+GDojy7FoYJpCHu5/LuOstE1mSrjNnCp/BY8Z967pLvmFOpQhxd ti5JOuLc6B4hGfjMu92hw+WRwsJxaghj8KCPasZKLv/hlQQY3RfnRd5ZBuBmXaMh4gAx cHuGzHp4QQ7GGiN5N1EumtZIDdlpNsv5i7D2ctAdGdLbUbZ3FdlfMhdzZyYtHZwWH3cT rQ4HrS9hk3Rh47sD+fw3QdlvQ7jChpz3k7yMqXWh+594pcrAI9f7GjWTZrn0sOaKLfoJ JgFkpFEXlrNNRkoyt0qJvqjQu2nURLeR2TGvv43eZMbIJfvc/QYBQGC8w06shuhoAOnI ru5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sm54WnVu; 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 h9-20020a05620a244900b0078ed6d9b40fsi8670385qkn.777.2024.04.16.07.09.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:09:21 -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=Sm54WnVu; 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 16335384641C for ; Tue, 16 Apr 2024 14:09:21 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id AF4383858C41 for ; Tue, 16 Apr 2024 14:07:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AF4383858C41 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 AF4383858C41 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::429 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276487; cv=none; b=qFWCSfTSpl+5B8f8dod8mzA4iyN3dsznw/Cs+UDMQH6BYPd5d6lPTrmXBLuuH6V6WcRXWa2RHlT7cBT+GJgPitih5yigBOHvTpAFUymdYif4qIkXUz7R/Fi+BtMLOEep83EWJjhp02PT8pMEEXw8HhW0yczg+yPZcTpAGC9RWDg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276487; c=relaxed/simple; bh=51B5/EI/7jtA3901Pcuu6dGcpb8jwhnMTJA0+QgWymc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=AXJKAatxqik7Jc8fLx/CjV8a0bX6TFHDJpXLsBUsmDjFL6CrgE9AExrLviFrqb63Av48mb1OSz78mIxlG+jpG6nK+JG+uiAyGznO5y6w4eUROis8Qf7eNogMAHVCc11gHuvTrLHjAZ01MJt1+5I3lHEUg3Ux5PJTpPkqYrP3Bhg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6ecf05fd12fso4190811b3a.2 for ; Tue, 16 Apr 2024 07:07:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713276474; x=1713881274; 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=aDxb/zg901wOzEIXVG9yopQliPwokB/YWickkC1tTt0=; b=Sm54WnVuiAaVqERv92dzdAGJbwQhN2DeeqtP3TAln0LmkeJ/YZGWgiqVcb29leAHJ+ hjATLQ6sjnSH7zAtzM6cBC/J9i5WMLA18lhnbaeauLA+2vS9TdvKp9kftFImQ23CFFG8 xMpUvSwsM5dUwXA5nYURwlbi4lNb9EGntxF0om6Q+RcXVN3g2Vcg/6mi0xymABC/xWXY ZZp7/4xrUnalvdyt8wlw9LCo5lqGyPtEfFbP1yeekRivxh/ujVaPscpN2B3qNV1ORPp2 uczOYsAdA8Swlu4jXFaI7B3p7gK+wX936lND9RxG/k0fYyGTuzRyTO7RRZNYY87KDMFK 76jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713276474; x=1713881274; 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=aDxb/zg901wOzEIXVG9yopQliPwokB/YWickkC1tTt0=; b=RJNTzwjcO40hTxCgiCvWBV9J6sLA+ej2FhHI8iitKT3gP+e0glfIMhjpg2/Dvlp+Ky U4d9Z6BykQz2B21oJtdlL+gHi5XcMpmhHWcUofaAOdhPAodZIHVNn3ZlUOtQe44ZOLwY soJuCTqTYqMh479Fw15Mjr2vI0QfRVT93S0h9ZiAOPsrgqvDb3MoeWRJmQMnadwZ06PL 2HlJezO2DD0/qbVxOEdKi8H+asEa7Lh2fb4D4JzaPISk8OKiMZ5n/QM4/ijgX2QFrGy5 ZOE+uu0HQc7NNUski7CA3dfyKaPUnhNVEf7V4nKr++7GxyzlaJHSPpZFTK9EqsAzXyGt fnzg== X-Gm-Message-State: AOJu0Yz0Pq83Z4Y4CRExV06J10FrHvgcSuKFofgzmTVtYackH+jefeC7 XswNP+cvchVF1RxnD70cBrV5kyhafmhGvoAVNsio05iDZDrMs+ZhI/bx0LafgAcSxwun/eGIDzz AsKQ= X-Received: by 2002:a05:6a21:32a7:b0:1a3:b155:1cd2 with SMTP id yt39-20020a056a2132a700b001a3b1551cd2mr18677697pzb.10.1713276474131; Tue, 16 Apr 2024 07:07:54 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:07:53 -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 5/8] gdb: Introduce is_address_tagged target hook Date: Tue, 16 Apr 2024 14:07:25 +0000 Message-Id: <20240416140728.198163-6-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=-13.0 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 introduces a new target hook, target_is_address_tagged, which is used instead of the gdbarch_tagged_address_p gdbarch hook in the upper layer (printcmd.c). This change enables easy specialization of memory tagging address check per target in the future. As target_is_address_tagged continues to utilize the gdbarch_tagged_address_p hook, there is no change in behavior for all the targets that use the new target hook (i.e., the remote.c, aarch64-linux-nat.c, and corelow.c targets). Just the gdbarch_tagged_address_p signature is changed for convenience, since target_is_address_tagged takes the address to be checked as a CORE_ADDR type. Signed-off-by: Gustavo Romero Tested-By: Luis Machado --- gdb/aarch64-linux-nat.c | 15 +++++++++++++++ gdb/aarch64-linux-tdep.c | 10 +++------- gdb/arch-utils.c | 2 +- gdb/arch-utils.h | 2 +- gdb/corelow.c | 10 ++++++++++ gdb/gdbarch-gen.h | 4 ++-- gdb/gdbarch.c | 2 +- gdb/gdbarch_components.py | 2 +- gdb/printcmd.c | 26 ++++++++++++++------------ gdb/remote.c | 10 ++++++++++ gdb/target-delegates.c | 30 ++++++++++++++++++++++++++++++ gdb/target.c | 6 ++++++ gdb/target.h | 6 ++++++ 13 files changed, 100 insertions(+), 25 deletions(-) diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 3face34ce79..297f56cdbf1 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 is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) override; }; static aarch64_linux_nat_target the_aarch64_linux_nat_target; @@ -1071,6 +1073,19 @@ aarch64_linux_nat_target::store_memtags (CORE_ADDR address, size_t len, return false; } +bool +aarch64_linux_nat_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) +{ + /* Here we take a detour going to linux-tdep layer to read the smaps file, + because currently there isn't a better way to get that information to + check if a given address is tagged or not. + + In the future, if this check is made, for instance, available via PTRACE, + it will be possible to drop the smaps path in favor of a PTRACE one for + this check. */ + return gdbarch_tagged_address_p (gdbarch, 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..35979875907 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -2451,17 +2451,13 @@ 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); - /* 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..bdda742ef59 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -109,6 +109,10 @@ class core_target final : public process_stratum_target bool fetch_memtags (CORE_ADDR address, size_t len, gdb::byte_vector &tags, int type) override; + /* If the architecture supports it, check if ADDRESS is within a memory range + mapped with tags. For example, MTE tags for AArch64. */ + bool is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) override; + x86_xsave_layout fetch_x86_xsave_layout () override; /* A few helpers. */ @@ -1410,6 +1414,12 @@ core_target::fetch_memtags (CORE_ADDR address, size_t len, return false; } +bool +core_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) +{ + return gdbarch_tagged_address_p (gdbarch, 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 4edbd458e4d..c9689a29f74 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 (gdbarch, v_addr)) + if (target_is_address_tagged (gdbarch, value_as_address (v_addr))) { /* Fetch the allocation tag. */ struct value *tag @@ -1268,7 +1268,7 @@ print_value (value *val, const value_print_options &opts) /* Returns true if memory tags should be validated. False otherwise. */ static bool -should_validate_memtags (struct value *value) +should_validate_memtags (gdbarch *gdbarch, struct value *value) { gdb_assert (value != nullptr && value->type () != nullptr); @@ -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_is_address_tagged (gdbarch, value_as_address (value)); } /* Helper for parsing arguments for print_command_1. */ @@ -1346,7 +1346,7 @@ print_command_1 (const char *args, int voidprint) { gdbarch *arch = current_inferior ()->arch (); - if (should_validate_memtags (val) + if (should_validate_memtags (arch, val) && !gdbarch_memtag_matches_p (arch, val)) { /* Fetch the logical tag. */ @@ -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_is_address_tagged (arch, 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); @@ -3124,8 +3125,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_is_address_tagged (current_inferior ()-> arch(), addr)) + show_addr_not_tagged (addr); if (!gdbarch_set_memtags (current_inferior ()->arch (), val, length, tags, memtag_type::allocation)) @@ -3152,12 +3154,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_is_address_tagged (current_inferior ()->arch (), 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..9717db55e27 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1084,6 +1084,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 is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) override; + public: /* Remote specific methods. */ void remote_download_command_source (int num, ULONGEST addr, @@ -15573,6 +15575,14 @@ remote_target::store_memtags (CORE_ADDR address, size_t len, return packet_check_result (rs->buf).status () == PACKET_OK; } +/* Implement the "is_address_tagged" target_ops method. */ + +bool +remote_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) +{ + return gdbarch_tagged_address_p (gdbarch, address); +} + /* Return true if remote target T is non-stop. */ bool diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index 59ea70458ad..e322bbbe481 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 is_address_tagged (gdbarch *arg0, CORE_ADDR arg1) 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 is_address_tagged (gdbarch *arg0, CORE_ADDR arg1) override; x86_xsave_layout fetch_x86_xsave_layout () override; }; @@ -4562,6 +4564,34 @@ debug_target::store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector return result; } +bool +target_ops::is_address_tagged (gdbarch *arg0, CORE_ADDR arg1) +{ + return this->beneath ()->is_address_tagged (arg0, arg1); +} + +bool +dummy_target::is_address_tagged (gdbarch *arg0, CORE_ADDR arg1) +{ + tcomplain (); +} + +bool +debug_target::is_address_tagged (gdbarch *arg0, CORE_ADDR arg1) +{ + gdb_printf (gdb_stdlog, "-> %s->is_address_tagged (...)\n", this->beneath ()->shortname ()); + bool result + = this->beneath ()->is_address_tagged (arg0, arg1); + gdb_printf (gdb_stdlog, "<- %s->is_address_tagged (", this->beneath ()->shortname ()); + target_debug_print_gdbarch_p (arg0); + gdb_puts (", ", gdb_stdlog); + target_debug_print_CORE_ADDR (arg1); + 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..5c3c1a57dbd 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_is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) +{ + return current_inferior ()->top_target ()->is_address_tagged (gdbarch, address); +} + x86_xsave_layout target_fetch_x86_xsave_layout () { diff --git a/gdb/target.h b/gdb/target.h index c9eaff16346..486a0a687b0 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 is_address_tagged (gdbarch *gdbarch, 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_is_address_tagged (gdbarch *gdbarch, CORE_ADDR address); + extern x86_xsave_layout target_fetch_x86_xsave_layout (); /* Command logging facility. */ From patchwork Tue Apr 16 14:07:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789234 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:dcf:b0:346:15ad:a2a with SMTP id dw15csp305035wrb; Tue, 16 Apr 2024 07:09:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVCcxTobNGzBFUAUAdNZDL8kDwgGSAJHj5pJPdL42mNGV0gLVSQsnfRmOxNUFWl43hxYhguNM9yZ3I0BjaeBrAl X-Google-Smtp-Source: AGHT+IEwvA9RJn0kO6OUeIexPqjySM9ZsHhL66ATYMkgIro0nsyNX0oGbQRh6qFnOzUOQ0XTCoap X-Received: by 2002:a05:6870:b48e:b0:22e:7390:da7 with SMTP id y14-20020a056870b48e00b0022e73900da7mr16022019oap.21.1713276563406; Tue, 16 Apr 2024 07:09:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713276563; cv=pass; d=google.com; s=arc-20160816; b=QVTsCsIggMZ1rP0gypNIWhnqw8spSOoI+l7SPbxvIPXHMSpnwoJ7o4WOyWBTvMUmfn oxJSbucfzYySESoaSNUyStZ9OP4q/lpclLX3SlyVcBgvTwnVJMeFSO6gklD44WqMbK2W FXCJjR/wab5UZPeraR/U0UyS+LeGOAea++EJcYZY1baIVB56vn68tikbS5EDyTipBqzM 5EygdvZkwjMbtE3ODoK7QWkSLfvFabKEOUXLO2XxW6PIsXy1RUrk74UVhykxF0Gx5+fd 0dKREdlHCwJK3HFRZfyNAtjQ2NcRo07x5tiLZv4Pj4SsIK+5B9hsvoFfSEQqtY20ZIoD qvGA== 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=IgkGCOXuapG92Mycu6x1TKV6pdZxvFEkfcXywD93fz4=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=EZTIRYJOGtOwkgJHobG8i2mMT6VZ+7XSjhPFCkbqQ3cF5XO5JMcPDWbb0q9C5QYT95 yP3CLhQtdpLGOjVkNPjG8cCW/xAv00i1lU+57AeuAt5q2PSdBgIijhgZc4aJRufHLS1a UGnnOEgF4dqKKJqWSwTYEK1jXQ4DEFtwqxTMefcoQrAmGiqzDi8GRkhuow/a3ep8IYaC ke7mE+v5sJ+D/oa4NJ+uLAzlM7jKvvQ9I8+BHGWoV9wYymLGhp8Ygwy5GFGBswYEoC75 EopYW0kaNIOCOBIFHmiK5y+3qi9KH2ScB70Dj4RAKPEqfUzc67xoJb1B49wxkFa3U3Ae wNcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=riITQXr5; 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-20020ac87250000000b004364296082asi11632995qtp.420.2024.04.16.07.09.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:09:23 -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=riITQXr5; 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 A03393858C78 for ; Tue, 16 Apr 2024 14:09:22 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id D5F793849AFA for ; Tue, 16 Apr 2024 14:07:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D5F793849AFA 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 D5F793849AFA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::434 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276487; cv=none; b=kIfjXYcuI2NxAwmArwTnHfc8IyaGD1Wh0Zg080YWUwFeu6uAK51+599+tlmd9jz8l2O4IdJWbNlqNQMmsBz+tc1wtWbbyWR37QjKLV5Io2NH5mF2TDP85GFG1otOw6HxnPpgNuaMyNz3dlThnls8fEtXo0HnEmm3bCtWl1leznE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276487; c=relaxed/simple; bh=9dATnzdtLBuIf7cSORFIle5NqSWdcLdnfiAuPirjwGc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=LiDT7/0iZO88RIIXPlyamV7Vte9CP2U2jVaECyLT5DZr4vnI5iTvfVGY8DwP7hDfrW7zh/r3GcdD2qbPz+3XZE5P3vdBlLVg6TniTsyb2csuUb1pVQIId9IfOfdDVRGv2kKLEnA+t1v74teA4hjIZIUjH2M5cPVliOI46Kaw/l4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6ed9fc77bbfso3439273b3a.1 for ; Tue, 16 Apr 2024 07:07:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713276477; x=1713881277; 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=IgkGCOXuapG92Mycu6x1TKV6pdZxvFEkfcXywD93fz4=; b=riITQXr5Zjk3HqNGE6a4QIJ9p6ioaeuxms4UqPCnsHki4r/y3r9zIxAXputp+W4b8M PSGGmsttyB+cHdhXXgHH2pnsAG5N5FNa6fiOGoNx7aEef4GvmMM+RpxL4LTZ2iQvO+fh CMLI3YoPWCEAVoQxrX0U0Ic7LvyshIWkFJIRQQCmGVJR4gAmzIk2PuDq5TQuFpcCOlUi bfSzsQsytXjwsjjiiys/JivCGHLyDvY1DP9Pc8zEOrBZnJNFg7GuHQPTDdqkHV8HtXJp gGrGAJ8jcxQa188PaN+/0rwELI3bi6hOMMAnwxXI2FQ/1Qyt2066VvIM+iDN6Fqm9Lkc 0lrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713276477; x=1713881277; 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=IgkGCOXuapG92Mycu6x1TKV6pdZxvFEkfcXywD93fz4=; b=CHyJ+CSy/XxGNE/79XQeP6l8QEOIXlSyhIZ3ER1ezs4adAF8x1HyBOsiG3sdJk3FJ4 igUrt6IuwtOuayXL4fbJRN+WyOlmJztGpXp/aEC9QdGSH/lJUj36qRpwjSL6bGdUI/V4 Zu8SeWXcCfDn1v0WIRRvZzaXkL0rAtY4H40Lkpjnxp2dr6Vgwt7QHzoybj5ExNboe7Lp m0xW5sfDK6TqchRoPhPTm0PAlfeYpzhT8D8R28rk6lM5lwT7RfLq5wlQGdGYjlKG/jnA hEn+r0UYM/5nEfZU3zd4KBAeT8ajoLNRfOKPcOr2dzwJMK9tZxW+SUQ3P2Ls9WylYzkN 10IA== X-Gm-Message-State: AOJu0Yz3krF75fAw2NnSs/MA3SYxiXK2+gNMTE+9dhx7ydTLh2mZws6X 6KwZ6OKg25G8U2Z5cbO+i4U4GmcD9A+zD2+rL9EdYMQcAsL32R3iU++txAgCZ0hNjV47uUiTXZI LZVs= X-Received: by 2002:a05:6a00:845:b0:6e7:e6b:2ead with SMTP id q5-20020a056a00084500b006e70e6b2eadmr15250278pfk.28.1713276476327; Tue, 16 Apr 2024 07:07:56 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:07:56 -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 6/8] gdb: Add qIsAddressTagged packet Date: Tue, 16 Apr 2024 14:07:26 +0000 Message-Id: <20240416140728.198163-7-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.5 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, qIsAddressTagged, allowing GDB remote targets to use it to query the stub if a given address is tagged. Currently, the memory tagging address check is done via a read query, where the contents of /proc//smaps is read and the flags are inspected for memory tagging-related flags that indicate the address is in a memory tagged region. This is not ideal, for example, for QEMU stub and other cases, such as on bare-metal, where there is no notion of an OS file like 'smaps.' Hence, the introduction of qIsAddressTagged packet allows checking if an address is tagged in an agnostic way. The is_address_tagged target hook in remote.c attempts to use the qIsAddressTagged packet first for checking if an address is tagged and if the stub does not support such a packet (reply is empty) it falls back to using the current mechanism that reads the contents of /proc//smaps via vFile requests. Signed-off-by: Gustavo Romero --- gdb/remote.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/gdb/remote.c b/gdb/remote.c index 9717db55e27..63799ac5e3f 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -15534,6 +15534,40 @@ create_store_memtags_request (gdb::char_vector &packet, CORE_ADDR address, strcpy (packet.data (), request.c_str ()); } +static void +create_is_address_tagged_request (gdbarch *gdbarch, gdb::char_vector &packet, + CORE_ADDR address) +{ + int addr_size; + std::string request; + + addr_size = gdbarch_addr_bit (gdbarch) / 8; + request = string_printf ("qIsAddressTagged:%s", phex_nz (address, addr_size)); + + if (packet.size () < request.length () + 1) + error (_("Contents too big for packet qIsAddressTagged.")); + + strcpy (packet.data (), request.c_str ()); +} + +static bool +check_is_address_tagged_reply (gdb::char_vector &packet, bool *tagged) +{ + if (packet_check_result (packet).status () != PACKET_OK) + return false; + + gdb_byte reply; + /* Convert only 2 hex digits, i.e. 1 byte in hex format. */ + hex2bin (packet.data (), &reply, 1); + + if (reply == 0x00 || reply == 0x01) { + *tagged = !!reply; + return true; + } + + return false; +} + /* Implement the "fetch_memtags" target_ops method. */ bool @@ -15580,6 +15614,21 @@ remote_target::store_memtags (CORE_ADDR address, size_t len, bool remote_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) { + struct remote_state *rs = get_remote_state (); + bool is_addr_tagged; + + /* Firstly, attempt to check the address using the qIsAddressTagged + packet. */ + create_is_address_tagged_request (gdbarch, rs->buf, address); + + putpkt (rs->buf); + getpkt (&rs->buf); + + if (check_is_address_tagged_reply (rs->buf, &is_addr_tagged)) + return is_addr_tagged; + + /* Fallback to arch-specific method of checking whether an address is tagged + if qIsAddressTagged fails. */ return gdbarch_tagged_address_p (gdbarch, address); } From patchwork Tue Apr 16 14:07:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789236 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:dcf:b0:346:15ad:a2a with SMTP id dw15csp305194wrb; Tue, 16 Apr 2024 07:09:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWXm4xo9cYZE5hl44A8PHZ1p6BZBA8s8l6ebUUX4BuuuRHCrM+e9D4hYPTGDFaWiYoAupNZWnrDcv0TkNTdiYB4 X-Google-Smtp-Source: AGHT+IGFtTr6JSKQTUTdgcDJfU0+IpaLOtZKR6iGSzESyZvluCtPDwIdaf8KVocLLqIGZMDW1h62 X-Received: by 2002:a05:622a:58f:b0:434:584b:33ba with SMTP id c15-20020a05622a058f00b00434584b33bamr13688946qtb.51.1713276579668; Tue, 16 Apr 2024 07:09:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713276579; cv=pass; d=google.com; s=arc-20160816; b=P8XgKVblC5KQY2G8OAJgYwUZ/YRcjsyymKwd81Q9+XfKyKRT5+sg9a2wOaHZyl2DBU eimIFbN3NdJM7GMVLifTRfRQbkfkE81nMvN6hz+zZpn1uSI8AzeE7Qkjbmk1Ugwz4KgY lQVtI13cuxHdaKqXHsp2BguizJM8pN4/TnhdJeQoXE4xQ+V2A+/mBBprDCU/C9FHmKyY G8RdtXq/K2THgNumpvWy7cU3ZNh9CqGq/5oBMle2cjSPY6HA41D5p6y8shkCXapHdzsC pz3i77GWtap2VxzqMgLH1ZVCJHUY0y7mzcH+3BYTuhbotoAZzs+GdbUa/b89kCpbtc6U CKPg== 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=NIecbHfd61PBTmQ06xkZ27ONlrNYswqO8NJqiIAjj3Q=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=lr/CgNhfKLIka1AY8LFYCbBhSk4qUElRQkn6L0uXV1gxOrsVxrXar5d1BYPUE2TkHx dPsk0OIsiffh5plVcvp3C8EkRagJKOEnnCsFb+p5WksVaCXXMdIQWrJuSx5l1fIga3r+ PEBww6VOSMyaofm/q+7+oN5SHD9yHq8ShBRQEvJYJuVxiWASpK2zyL6hVNERVeEKlBvY feYm/4h8a3XqaDJOJCmAsd/PCLkxxQ4F22RFVu/QNP5C+cteW/X34As5vk2bHARvfyw9 Ja+XwgT5RjSpVGQ/aY1Zr/fqrX+eHdiwsQmCGSosSClB2ec3r1NWpNQgoZ8nYpMai8qW E0xw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KzhTpixF; 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 h5-20020ac87d45000000b004369f4c005fsi9877331qtb.700.2024.04.16.07.09.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:09:39 -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=KzhTpixF; 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 4CB7B3858C53 for ; Tue, 16 Apr 2024 14:09:39 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 525FA3858C78 for ; Tue, 16 Apr 2024 14:08:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 525FA3858C78 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 525FA3858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276487; cv=none; b=JCQpvdyZI6vzwBwoqkbYBPC0ux5TqrtSvfptk0L+4hTq32z2/HoOurbNpcfk10m4evYT1bgPOqXeu+ml8SFIQmC926622ae7t7wAhLBdctdIRzkuVZJhBM7NRuLKchqHKBmYTQIu6lWVk+TWdT1vqVsvCys1vBBGGsyTtsMBJPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276487; c=relaxed/simple; bh=5JUNK7JchaPtTy/5e/gDv204PBOvA9bZ2y/G1rG+BjE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=I0wafVUjeAIN6DkwNiS7LwbVQb9jvjIeEHkIUSOP8WPhkxtiGZ2vjguHYLRzEB6LVhqwxSbiifNzcrk3BjrszmfkXHIJsg8H5pOGlwbOnNt1NwEA3yB3oW2Q36icYDaPE/6a0dp4YvkVWOejchNbG3kbvy5QlWWCqWIOjJ2K9rY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6ed0e9ccca1so4046574b3a.0 for ; Tue, 16 Apr 2024 07:08:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713276479; x=1713881279; 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=NIecbHfd61PBTmQ06xkZ27ONlrNYswqO8NJqiIAjj3Q=; b=KzhTpixFzQmo5Hri7y8aqI7gtIdfHNcCbhwDn7p9xeTWbBfd1PE+JO3Bj5vg9ORtjE GPULT4A+sTKhoLaUnUN0AUbZJYpV5cfUHCyCt/cA9PEuIBUyoOd5zDBGuWFJ864fTnRc Pz5JYgSFy/Jk4DbA+qTNV0sUlhNdKdi8Br+SyhKUmKlLRtc1AP+GrojlxCiZF7g3b81V XHVDJBypMSmU6J35LvgIxlsFBIbG/CNUCPf9Ufs02HpMqRf4Q6JdCgWoBQ0q3T3Q2PVb iuhgQtY0RHL04rX4f81MuWrDlM8SJrYU2jGALqDf8LapgBYi6NjGTJ+A/b18UndF3Vgn D+ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713276479; x=1713881279; 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=NIecbHfd61PBTmQ06xkZ27ONlrNYswqO8NJqiIAjj3Q=; b=XfkJWOFDldrJuxuUISnFjbdP9onXIWA6db8It15Frx7VtFRhK6JoWIUPAnIqPQ1rjZ GghIgZjZVzJt0mln7pp6DOd7U8k1wmF2jGqXUjrafi5lVPeGLFWcIyIf1YL4nCQAt/6/ hwDBRBQNc0WdytcLhQIFU9mS9JX8XmxbnOsNkEjUaK/Cjj9ada9pYNIbepAEfKoSUxQl gN6ZA4fh7iKOYRmD3s7gzywFPDAwQ3azZxg8hWoS2pInZu0Gr1fXANnoT53uSMAwvLX0 lvP+YTc9Ro3irubFmcpo9eSHRJP+Ye7aJ1OuijUCzBThfQuAPrIT8eYYDTpwmFpA1Bw3 1LIA== X-Gm-Message-State: AOJu0YzLt8SXq3GEZD6CrneX6F/+fTwtyNOsMaRyH43cmKA2lCh4NH/w qHITXnkBFK72v5GbgzzkiTCSvZFopNs8QX+2bnYBf+B3EvbsYpxQu0k7G+8RraGpXnHpxduG5yo LGp4= X-Received: by 2002:a05:6a21:35c2:b0:1a7:a564:14db with SMTP id ba2-20020a056a2135c200b001a7a56414dbmr11693441pzc.24.1713276478578; Tue, 16 Apr 2024 07:07:58 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:07:58 -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 7/8] gdb/testsuite: Add unittest for qIsAddressTagged packet Date: Tue, 16 Apr 2024 14:07:27 +0000 Message-Id: <20240416140728.198163-8-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.5 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 Add unittests for testing qIsAddressTagged packet request creation and reply checks. Signed-off-by: Gustavo Romero --- gdb/remote.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/gdb/remote.c b/gdb/remote.c index 63799ac5e3f..42f34a03c95 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -15658,6 +15658,8 @@ test_memory_tagging_functions () scoped_restore restore_memtag_support_ = make_scoped_restore (&config->support); + struct gdbarch *gdbarch = current_inferior ()->arch (); + /* Test memory tagging packet support. */ config->support = PACKET_SUPPORT_UNKNOWN; SELF_CHECK (remote.supports_memory_tagging () == false); @@ -15724,6 +15726,46 @@ test_memory_tagging_functions () create_store_memtags_request (packet, 0xdeadbeef, 255, 1, tags); SELF_CHECK (memcmp (packet.data (), expected.c_str (), expected.length ()) == 0); + + /* Test creating a qIsAddressTagged request. */ + expected = "qIsAddressTagged:deadbeef"; + create_is_address_tagged_request (gdbarch, packet, 0xdeadbeef); + SELF_CHECK (strcmp (packet.data (), expected.c_str ()) == 0); + + /* Test empty reply on qIsAddressTagged request. */ + reply = "E00"; + /* is_tagged must not changed, hence it's tested too. */ + bool is_tagged = false; + strcpy (packet.data (), reply.c_str ()); + SELF_CHECK (check_is_address_tagged_reply (packet, &is_tagged) == false); + SELF_CHECK (is_tagged == false); + + /* Test if only the first byte (01) is correctly extracted from a long + numerical reply, with remaining garbage. */ + reply = "0104A590001234006mC0fe"; + /* Because the first byte is 01, is_tagged should be set to true. */ + is_tagged = false; + strcpy (packet.data (), reply.c_str ()); + SELF_CHECK (check_is_address_tagged_reply (packet, &is_tagged) == true); + SELF_CHECK (is_tagged == true); + + /* Test if only the first byte (00) is correctly extracted from a long + numerical reply, with remaining garbage. */ + reply = "0004A590001234006mC0fe"; + /* Because the first byte is 00, is_tagged should be set to false. */ + is_tagged = true; + strcpy (packet.data (), reply.c_str ()); + SELF_CHECK (check_is_address_tagged_reply (packet, &is_tagged) == true); + SELF_CHECK (is_tagged == false); + + /* Test if only the first byte, 04, is correctly extracted and recognized + as invalid (only 00 and 01 are valid replies). */ + reply = "0404A590001234006mC0fe"; + /* Because the first byte is invalid is_tagged must not change. */ + is_tagged = false; + strcpy (packet.data (), reply.c_str ()); + SELF_CHECK (check_is_address_tagged_reply (packet, &is_tagged) == false); + SELF_CHECK (is_tagged == false); } static void From patchwork Tue Apr 16 14:07:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789237 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:dcf:b0:346:15ad:a2a with SMTP id dw15csp305334wrb; Tue, 16 Apr 2024 07:09:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUcfxnW1sPmOzZLw8hgq63y2Z0Ak2XxBHv/a0AddAXroVWglkntJdgKNXPGywtEefahKKmHB+CqXnJdzMbqy3Xy X-Google-Smtp-Source: AGHT+IHXiA9aP6oPGOyPk4nlpKYDUJY3zDHAmNJ2niKfwxW1/K6OHGVMdKjuZNTVQiA2qFV6nfuN X-Received: by 2002:a05:620a:47c2:b0:78e:bd2f:1088 with SMTP id du2-20020a05620a47c200b0078ebd2f1088mr3151825qkb.4.1713276593635; Tue, 16 Apr 2024 07:09:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713276593; cv=pass; d=google.com; s=arc-20160816; b=sDDXtmVqy9bY/nIobSxtJqqylTLSbjtBEbRNDCkva3E9xJuCFTVU/kaesPcvx66sGp yHqTPZXXKrvLPd/10fvCY19twEd8L0flb+JBPIKsAGp00Q+42g6wDi8nqwIXjOI/+uzZ MpupGNE6rVRnePJp57Z89+6TOp9fvnSfJbujGhu87o1/lLYWBfqAwkYXZmGOTsVjdI2A j1Mzn8A8oRoAISw4YAYA5hL9LRi1vSw4EAVOrJJnhwLC+HL74D15Nj523eosY9IJbwSz rmnqF4mPkFCsW6ENf41GO2YQkP9kkpVBLzlEfDoNGPIHKb8cv8TpNhR2R9Vb1K2tf6zA wvog== 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=TySCtsAV9w2OFUsPqDtQ4yT0bercISlHKAJQghi98fU=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=xsefOHvZ/bdKvx7Jkg6SRXvSsrX9LV6DaijLbBaWFqmRyxN2UtkrSKa2YkxTGVgj9s gtz+Nql+wFa2FUYkzRDyVJBhLUIx5WDN6sQWRWlWpjzOLEM86KZYkLiqocwADEtZV2sp 6+w1KmoRxj00awyRAWzdKQtLDTxA2XMxwhvKPT1RLqYBLe3UOymyJ/BABSUwS+4LIvVU Zf9Rg61l/QUGweRBn2DySH+DNA/Ee8QQHPWhdTnyl484C6DKciAhL+Wn6x9YTBK+nu2U RAm5umpyWXEJ2Ko3daWYfoof8P9oIs8dHbEQ7kms9EMZkcWBhN2SpsjZ9bbwuhkYdBiR BA8A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P2iwK47d; 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 d14-20020a05620a136e00b0078d778420c3si11976872qkl.647.2024.04.16.07.09.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:09: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=P2iwK47d; 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 31DE6385840B for ; Tue, 16 Apr 2024 14:09:53 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 4381E3858431 for ; Tue, 16 Apr 2024 14:08:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4381E3858431 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 4381E3858431 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276495; cv=none; b=BjgTNInB51tZMYavJ7jQzk657h9G9J4Jh/AeINXtL6byUlT6xbiNbhVlZdULUvqB/ESZiMgwJT+XYizQd+qIE28UjzMlU6HL+I5ZJIH4e71QVbk9b85AmCyfFxmC85QzH3ega9PjIZqtnNw1U7oq6BJIMIuXoKqintXpbAgm910= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276495; c=relaxed/simple; bh=uX7XlHxVf0V1WMrVHD1NCj+jz5ubqQflYFbXbd+PMaQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=aTw/DuUJ+uUoxaUYws2QigN82oSStYsvweI3KXcJPduvd1fjBsOr9Q2hjLrXSPRCoIZ8DepSj/6FMH15X2tG+C2kGro6a9yz1/+4nmtpNJLI//PdhcZuoHHCHlE2KDpHcWM1b8+xaf7fyLz9bF2bE0/NLTB71+/5CdKYGHdPlCk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6ee12766586so2928792b3a.0 for ; Tue, 16 Apr 2024 07:08:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713276481; x=1713881281; 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=TySCtsAV9w2OFUsPqDtQ4yT0bercISlHKAJQghi98fU=; b=P2iwK47dYWVDxK1VHobPzCcHYA6eKPKn0m+/pDnOJVp86eETHmehVZvP5y+YK0JoCz pOd1fan35zSy+IueN8vM8AgdnIx+FyKlsDsFwPM+pO0JkFYEhVW87NrHdEG0kARPk9a0 f0pkcem/iEQIrrDUUyIulLvo31eDf6sfRQKbXuN0A0cQKagVmLCox9SWKZA6IX1vHgiO M1iCV/LQQNqgPQxvyUAomKoGEyZW0qSumTG+fjVwj6PrAfGESKf/iuW8NZ5ek8pD4W/s zhq9Zo9MFO8ifh5vLDxvMQ1NWILyFHVmyMGFN53SVSWVT3XNkXBJSUZld8UGEQzjQLFU l3Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713276481; x=1713881281; 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=TySCtsAV9w2OFUsPqDtQ4yT0bercISlHKAJQghi98fU=; b=jdTOVmZowjERqhAFos54gq6SwpLIf7+k485TxInWIlY1NBjRbsNlkEZZ8apwnmzrB0 dj0UcBsuGNbSwhK+TgFnTeL6L42Kox5NVNSt07nvuOa/YvkuxbSdvBnunNyTAC4gpL1p WAQgW9Up3xrJ4oQ60ZIxJQnFaSw1Mc3pQOgwCMSnYJvnd1KmmVjdHsXlQC4SJAlel6L8 34Bw4AdP/BlZjg0hKU7an+nUi5CJ9VMAkwdyRRfioYywJ8JX5Zq5X7Fb0pyQ6YrC5bj1 EIywP/JrRGigU6L4WdrK8znnIf0K+67gs/2Vk4k0Fg8k7VURRU11wCTlocOEd2mOnG58 Tqtg== X-Gm-Message-State: AOJu0YxDA9+PKol1SHabW6xpQ4C2rhNEm3TMm9Kcqme2t6s0G/7yk6pz 2TU5Wi1zJDxAVQSzMflBCZP9spVUVocfKIQwHU8aEOGx+lfcoF3sQ261433wGQqODnBL2v5P5wv ET5w= X-Received: by 2002:a05:6a20:3d86:b0:1aa:3ee3:8d5d with SMTP id s6-20020a056a203d8600b001aa3ee38d5dmr3101796pzi.14.1713276480816; Tue, 16 Apr 2024 07:08:00 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:08:00 -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 8/8] gdb: Document qIsAddressTagged packet Date: Tue, 16 Apr 2024 14:07:28 +0000 Message-Id: <20240416140728.198163-9-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=-13.0 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 documents the qIsAddressTagged packet. Signed-off-by: Gustavo Romero Reviewed-by: Eli Zaretskii Reviewed-By: Eli Zaretskii --- gdb/NEWS | 10 ++++++++++ gdb/doc/gdb.texinfo | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index feb3a37393a..1693a7a15f8 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -192,6 +192,16 @@ QThreadOptions in qSupported QThreadOptions packet, and the qSupported response can contain the set of thread options the remote stub supports. +qIsAddressTagged + This new packet allows GDB to query the stub about a given address to check + if it is tagged or not. Many memory tagging-related GDB commands need to + perform this check before they read/write the allocation tag related to an + address. Currently, however, this is done through a 'vFile' request to read + the file /proc//smaps and check if the address is in a region reported + as memory tagged. Since not all targets have a notion of what the smaps + file is about, this new packet provides a more generic way to perform such + a check. + *** Changes in GDB 14 * GDB now supports the AArch64 Scalable Matrix Extension 2 (SME2), which diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 82a617e9ad3..cb6033bbbee 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -44093,6 +44093,35 @@ although this should not happen given @value{GDBN} will only send this packet if the stub has advertised support for memory tagging via @samp{qSupported}. @end table +@item qIsAddressTagged:@var{address} +@cindex check if a given address is in a memory tagged region. +@cindex @samp{qIsAddressTagged} packet +@anchor {qIsAddressTagged} +Check if address @var{address} is in a memory tagged region; if it is, it's +said to be tagged. The target is responsible for checking it, as this is +architecture-specific. + +@var{address} is the address to be checked. + +Reply: +@table @samp +Replies to this packet should all be in two hex digit format, as follows: + +@item @var{01} +Address @var{address} is tagged. + +@item @var{00} +Address @var{address} is not tagged. + +@item E @var{nn} +An error occurred. This means that address could not be checked for some +reason. + +@item @w{} +An empty reply indicates that @samp{qIsAddressTagged} is not supported by the +stub. +@end table + @item QMemTags:@var{start address},@var{length}:@var{type}:@var{tag bytes} @anchor{QMemTags} @cindex store memory tags @@ -45141,9 +45170,11 @@ The remote stub supports and implements the required memory tagging functionality and understands the @samp{qMemTags} (@pxref{qMemTags}) and @samp{QMemTags} (@pxref{QMemTags}) packets. -For AArch64 GNU/Linux systems, this feature also requires access to the -@file{/proc/@var{pid}/smaps} file so memory mapping page flags can be inspected. -This is done via the @samp{vFile} requests. +For AArch64 GNU/Linux systems, this feature can require access to the +@file{/proc/@var{pid}/smaps} file so memory mapping page flags can be +inspected, if @samp{qIsAddressTagged} (@pxref{qIsAddressTagged}) packet +is not supported by the stub. Access to the @file{/proc/@var{pid}/smaps} +file is done via @samp{vFile} requests. @end table