From patchwork Wed Apr 17 21:04:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789337 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp233222wrm; Wed, 17 Apr 2024 14:05:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUiXFvq/J06VESTCAWc2h7cZulJDMEFzM8nxFeyCQuE5XEDNZ2+2FoI3jQQuuPLzJnBkTT6BSKp+30do9fP37iJ X-Google-Smtp-Source: AGHT+IEPPMxDWl7698yt8Yfik02OeL6K6Es3KvzHohg8lL9yyGoJ0csVwaerXGcT1AQnAKXhkhi+ X-Received: by 2002:a05:6102:d87:b0:47b:b94c:ce5c with SMTP id d7-20020a0561020d8700b0047bb94cce5cmr50227vst.0.1713387919288; Wed, 17 Apr 2024 14:05:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713387919; cv=pass; d=google.com; s=arc-20160816; b=s/9XhemLEQY9jNCflQndhm6hyVAehOatH+VgYfjd92xlY/UPID9a4qIM+BIB62v7S4 Sxe2/8SSGlLEKU3AD5WtvGKUzvh2Uc6Owm3DuN0KtskEDD2BB3VnK/A8oafv3mmaVB3Z dMwu9Edg47zxkBYq7jpdYKBOlsqxtOx//NG25jCTpIlROtrHIf3bU+SRxuS9kNVr9UF4 +I7l6vbmSEsb2T85y1NpijOdYq7Vz/R8A8Mzcygl7rpSNRV8I17/t5RZxS65JgVKp/Ss YuAYk1mpGR5Issylv2VMLIGD3fC3dW65ugWbTPcqel0/8C98y1qL7jlZtvJa7lZXDqWT DIfQ== 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=TrprFylpQt77ZPAlLBaqa0o2n33gUO/Kqevloud2MLID5IJSfRDkb/uA+UHNk32FLw BuZewA2qp/0buWXEDOVF7onUaIgpmxFpqId/H8u3dBlmEAGYmx2O9rbnIYj0PnV//X1R yO1UXzVHt2bq+2+5P710b6P58ddZrqWoRto/aEP/NP57+nH8WBLEBBkljsXPA3P8plxJ cVycS0wQiaYGjSVTZcOiYlmCO4GuMIHV/aO4sZFnbFeLWrvOi+OOLxtKxN/X8CUWPews dAy4qRJHOW0BHJdExjCyORgPrOifwmpiqN4GeNmuWyaDdm6BwSKoqMOHXG4Cg7NKiBm/ zKiA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GKMIqRQ8; 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 hy3-20020a67e7c3000000b0047a2a50b72csi26531vsb.357.2024.04.17.14.05.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:05: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=GKMIqRQ8; 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 DF9223858CD1 for ; Wed, 17 Apr 2024 21:05:18 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id 0427E3858D37 for ; Wed, 17 Apr 2024 21:04:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0427E3858D37 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 0427E3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::635 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713387893; cv=none; b=aqkicKjF2t/Wam9+qcW3tVLaPSYn69OW7Qv5dq2dp6xpBbybLpXVuoQfK+gJ4eUJKDtg0NHxy2cgM71FTFLpcyR4ZG3loQCmXje4RPY+2lJ4ZSy43P0cok3jS20P9jMJ4selZFiSOLXFnMneYaS0wcG5cEJSawA/29x68ref5/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713387893; c=relaxed/simple; bh=zn4DbmTot8VHmhi87qT4JPigPp9gYVtGLVN1Tzseteg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=fy5iPYBXNAidLzQlETlRIJj9eBqjYhusJbHNqxZg3KHlgcxks9oKJNKb6tVPdrzzt9kOYd1/DFS/kVRRHcSBuW4FXiXs5rMKEaa7y15q4gp0E0iP1LHzoVo9C5navYIHZzTx7iKXsVfP/rOC8Ybbh/1dg0/o4o9pdtFJf1INQmo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1e5aa82d1f6so8344985ad.0 for ; Wed, 17 Apr 2024 14:04:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713387887; x=1713992687; 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=GKMIqRQ8onIow4RmI7RQpr8vvNay95FxehIN5fo8pmZvdO9mflQiULdws/PxUwTiI4 D+p/FyMbTpeBAhijbdTegtH/trK9ZU3SqIzpgu8wM9snSkFxo4WkS/js/9PAOaeDjrIK fAFSpNwsOPhA4r63l1ceMeHgddvhqj5V0PPYvg9/JpDvmyGF7+9FdiN6MRLIrgRqmYnN sEibrC4BgF/C6qn6JNctJwr1CiOtQfY+l6BecJpk6pUEC8ERNvKQE/JaCp4eWAz80IRo iv9XmY2o8kt6OyFA3TzrL+7DQCaR9Q8g7/rbs/25U6kOLJmTbdP6rLaUVhG4hBmh7Arx hH8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713387887; x=1713992687; 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=aZeKYz5qs1otlhRIsFgyrrlWouLSoOW+ZzXQ/YMBWlWsarjeRv55CgWHzlIdGhFM2p cQ1dBOlYCviSIMPd7Ren1rql/fWqXH2QIHwBWE8Nz+61Is4EtIlWbo72UcwnxvYl5ZXE cwV5+yaxUNwR1layxjG5iIDd48JGStXdvFLCYmZJCYAxX/Kc2hJ4QNJeJLti6ipAwdE8 BZmgQ3aX56sswhgBu4cKDSGBKZjR0yLgaulEcp3IkqRqF1AGzc6qKoC2R89uoQfMp6Z4 TNn2DdpTdQTIJdE2k5migCwVFRimgUYrKwVsM3OrHpfZGP69u6Ehmi49NhYBdwDGAmam ZEuQ== X-Gm-Message-State: AOJu0YzTQAw0STxiAazkinia2HLY0qbvDhTfr3nN2BRSyQCSSgR5fxtO KzKrPc4U+OIWD2aXNGFjJQSHhpftzJCGzUfvOnndGA2VOhiK0spHwqyOduKunL4/lpY5xFvO++9 X X-Received: by 2002:a17:902:c403:b0:1e8:1488:2f9a with SMTP id k3-20020a170902c40300b001e814882f9amr326189plk.30.1713387886721; Wed, 17 Apr 2024 14:04:46 -0700 (PDT) Received: from amd.. ([2804:7f0:b403:ad57:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id l9-20020a170903120900b001e3e0aa9776sm80494plh.27.2024.04.17.14.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:04: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 v5 1/8] gdb: aarch64: Remove MTE address checking from get_memtag Date: Wed, 17 Apr 2024 21:04:17 +0000 Message-Id: <20240417210424.216374-2-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240417210424.216374-1-gustavo.romero@linaro.org> References: <20240417210424.216374-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 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 Wed Apr 17 21:04:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789338 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp233417wrm; Wed, 17 Apr 2024 14:05:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVxdjduHKUeNxKSUCQ4mPv2x1qE2DNNkRZ/Uu5qMVRm2WUB8RejMCnjrhlntpR98Z+Kugqh2ePEXraGrj8tmR4x X-Google-Smtp-Source: AGHT+IH4b6olVt1RKLtb7u7XlN4fGQVnenwQ5LS5uhred2EWSdTaTkh51ZZqvydWtB+48RQaec7e X-Received: by 2002:a05:6102:3f15:b0:47b:5f2b:3785 with SMTP id k21-20020a0561023f1500b0047b5f2b3785mr856786vsv.35.1713387948223; Wed, 17 Apr 2024 14:05:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713387948; cv=pass; d=google.com; s=arc-20160816; b=y4gDigO2vT3dqN4F+92YXYBHE+q5K2m3SIcxxnS+kPgmoTem7GM7W0igxcbuyiE/tq NTTItoFYzoqCpjQr70qGPmFcI609bU981LLagcQ+1lZbQxeXSeceSoYBgg2i66LTG6qy XV8QZ3IWK1FNIfj023j1MYdVZXj2OC6ZwrgCPgClf26cberbKu43dI0xUsS32Ej3gxaj OH6507uilN6/4q2xMRSuEyozxm2thqTjHkDNY17eA9Ot+G0X19vhrIYIFBIigsvxUSy7 kzHCu5AK0PkstwdX4lCFPkHqBjubo38+QVRAIrx8rXhlQN1PzCbnhQzs2OLqI5r1Mjga mgAg== 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=AB1cfcL6bYdgBQzOX0q+LeLFEerR63qRjSyZ1Gu8kI0=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=SL10tP28/xmPEelSxuf+0aRW4Zd+FEoKwbADJJVyrt3N4b6m5CVsLsyHpJezjN5D2Y Ci//TvxQzkQLtDbL/1EgNUeagV+6GKrAMTW/BOPQkjJyXJcR9uE8BrxE7dib1+eW+lZ5 AJfXCPCdkjUcHqL7LIvjRYlBSVM0a0KmSHwl9Ip5WZvgbAzjZ/o3cWSz4fTA7oyXUNLu F62zHuvznR0R4fjz7mWKaIIxo4wdN8SoVsVU3af1ChTl/MPJ0/sEdtylVg/rEdV7OLJL LurhoKnWVHyag8WHDgfSpb2Y57A7qrwXq2tHkQfbt3cNpWV+c0nckbE0gdlCXWc07I6S jnhA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sp0dm7bx; 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 dw20-20020a056102469400b0047a07009ad3si23657vsb.193.2024.04.17.14.05.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:05:48 -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=Sp0dm7bx; 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 A18A1385840B for ; Wed, 17 Apr 2024 21:05:47 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id 78ED73858C62 for ; Wed, 17 Apr 2024 21:04:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 78ED73858C62 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 78ED73858C62 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::629 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713387893; cv=none; b=QclWRM1d53Rg7J+bZNAr+tTexAX3vKs3ZWy6Sn8rWsHm7KsXNacynCOlCoeRqPlpgbxrIb7KKPYpxU/V9QZoFfroITr9wbi/NCx/nRGX8IFginctLn+bxNO3juNqCeDl4Bu4Q2mR3ocHXS2Pvt9x31sdiFuo4aYwb+cYeYRbBC4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713387893; c=relaxed/simple; bh=51FHoGiyjhyoZma8QVYzTWzzaqrp0zk2YyY69ZmRoB0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=mM3PuNph01i3MBr9eI8MMlBI/hhyd6zYFqHlAtPA8+MA4jPoXn4h4ykfMYWNw1xOR8n/Zo5cfKLypGvxID/LRJ4xcBCFP2/efZs5ifU/+2jl2tyNsqLkSLymuhLOVI5Y+Zr2xc4QGQYHgbqoQDD792yNWTA0tRTDKkLbL0UroQ0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1e3f6f03594so1631045ad.0 for ; Wed, 17 Apr 2024 14:04:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713387889; x=1713992689; 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=AB1cfcL6bYdgBQzOX0q+LeLFEerR63qRjSyZ1Gu8kI0=; b=Sp0dm7bx1dH5mUGYuxv6rqp+OwQ7EtFOoTBaubECyL0pJ7SKMwnZIkg5u+I+IMBl/K JF7UwnvgcyJTngOBMvOUKjCM0WEcVi/N/hpt2vevCKw0OKFMsu79x0tZdTZcc4fvPJl5 H8oWcb6uYZ00yfJxEoGXy/v3dIKVrkL0cB0CSSw+JnRqrrm1LKFLe4AeOX1j4gAV6ZLh LRQgxWxrl1aqWQ5ry9hUJ+VklA8lEG03HDo9jXwlM4ABkdfY9GecCRDuVHBuABpqqYdv N242mk81D4037/orYzDr+p8IpK0yg9f7zgn2E3pPg84h/LOOTs8Lb+LOfvZ2GzaT9EF0 0cmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713387889; x=1713992689; 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=AB1cfcL6bYdgBQzOX0q+LeLFEerR63qRjSyZ1Gu8kI0=; b=gavCiop4W3CCU9K2x1u0UquxoZ04/QwX52CV2njeup8nD3va7+hoOMykLLxSlzeUkJ 7QHtDo3yDdtFyVzr4uRHfEOCISK2GJVBOuWeh6JKQKgbo2eS3o0fBoauZK163xeWW0Yg DTP3+gMZLxecwSVJKuCkKx53OL18SvZ2ZAxjnJnq2EGyr/7gpuFXgm7y/BKy8c56fFu/ PNN5KrSWjI2MyTU5LnvOOS496GaTgK2O4rk6fNe8hn1THKyGQnYDKEmbmTvf/VVX1faw ad3PUrAYymoqZKk0aenEWEnyF014HEN1g+ugoBw1k5ReM1LLbZGT/vxwrDew1+M0VOyF QwJw== X-Gm-Message-State: AOJu0YzHrVvAWzojW8ltK2f34MmhEMvQNkI+I0JDB8/WV6+Y/vaz1cHA RD4os9CYInaZyqhdG5EG4gvTXjpo0wk0PGnTpH9DfNXrvt7d373WxcuGS+9KjHY2HiND4hHAFp3 8 X-Received: by 2002:a17:902:ee45:b0:1e2:7d3b:353c with SMTP id 5-20020a170902ee4500b001e27d3b353cmr729137plo.18.1713387888973; Wed, 17 Apr 2024 14:04:48 -0700 (PDT) Received: from amd.. ([2804:7f0:b403:ad57:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id l9-20020a170903120900b001e3e0aa9776sm80494plh.27.2024.04.17.14.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:04:48 -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 v5 2/8] gdb: aarch64: Move MTE address check out of set_memtag Date: Wed, 17 Apr 2024 21:04:18 +0000 Message-Id: <20240417210424.216374-3-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240417210424.216374-1-gustavo.romero@linaro.org> References: <20240417210424.216374-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 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 Approved-By: Luis Machado --- 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 Wed Apr 17 21:04:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789341 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp233591wrm; Wed, 17 Apr 2024 14:06:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUB+axGOvaaFgI2mT/c/IMcWNy1kJMnBiSUkf5rjWx4Yza+EaJSMiuMROa0PtMIIxWxTE2oEeckuQWDaIfz15Og X-Google-Smtp-Source: AGHT+IG1eUTc9AolNKqkegaBhbZNQ1+LLCrSBV5+OsOF/T/rHF+E55zDxYogZoY12TgGuP/HyUBV X-Received: by 2002:a05:6870:1641:b0:22a:a40c:4bf2 with SMTP id c1-20020a056870164100b0022aa40c4bf2mr1007902oae.14.1713387971095; Wed, 17 Apr 2024 14:06:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713387971; cv=pass; d=google.com; s=arc-20160816; b=FnS4jLu0pJBT0qhl/C19HbKfnmiWtyMBIkbzdzunFtdeF2BCtWzezPctBEott4f5oC /Cr1+ytENq2hAKkud1CRLxbTHBNIwfnDwxixCEQnV/2hE7C/jcpuD/Fnj2bBdWf2cLRT 4MuBydNUMIP75EG5YYe4pr4b9GoeA6zAdFFir6djtme9WksZ521TlrtNnqpX/4jMayuu c975rzJcfYrJz+Qwy8ca6stToNeB6/UPDK5WL1K8XCjlN6mZoU1f9sYmMeOL0UYUO8w2 P/DCbCALYPT0rdd9HU21qQrtxm3zWNTPYqkgRNDutG/sjtc+3Ce/jcSlFy1mLt9sPBOU 44Yw== 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=SUG9VaX9a1qdH4uZO3OmbrAbh2E/nzWOWxW4Kd55CXbCZ/802y8mBrBSj2i2cyk1/k dgH3t7Az5//eJRnY6nsAb5p7ZimVEIHG/yiGIckLO9Ls0OarZcbW+m50kjmzAdfy5iRH zlobzQjJEVEH3Ks9BXd4KouCNocK11qTTm0qsuLil79DtlEthPqQWWCfyfzKuM56wiPv cJw4VKRg7/EBCI1N7G+273ZzzgHbqGl6qVdKMrn0p5Nzfrh3w2VfNuDUynS0mfiWzXeZ zYg9PFD6GmfhZ1N674r3NXjHUeHktGjESCAWoWUbWPylXdPGgKeHUthh7N+m9Ol69Qdw IK+g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pTTH0+iD; 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 wh5-20020a05620a56c500b0078a72677be0si36361qkn.194.2024.04.17.14.06.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:06:11 -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=pTTH0+iD; 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 B6230385F014 for ; Wed, 17 Apr 2024 21:06:10 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id A1B1F3858D39 for ; Wed, 17 Apr 2024 21:04:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A1B1F3858D39 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 A1B1F3858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::635 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713387894; cv=none; b=OrZDAaWqRUBnLzKGOI6Lp3P8W9lMDoSrW3D10A/LR9P9aWYwk3v/oU2sxe/6oVlQQzUUC21F6I5TJ9a4BJoqXHhWXhCG9K28/zOY29Y9s9V5GnQGcraGVv6t1+8N6wPOVeBsxk2fTU5MtarYcVtkrX2lbDX+5Nleuxcwd3BEVYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713387894; c=relaxed/simple; bh=WxhGoGvDUNyHMS4tOjdoth41+fxv5hm536NHqm7b6zY=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=prM8IDOyR5KMpeP8PPCHypUGi5YTczlOnnAYzOQsPYXrQstkLQJeXbla5c+y66wkxryzhuDKEEgjyx2+UZV5Y9nAPEuTXOeomr6n55ksgF4mhmpgCxMgO/rlnogtd9VGJAYivmZeHNCxFjWj1y1YrQxOcUwqpg1/iPlP46HCpMY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1e51398cc4eso1845465ad.2 for ; Wed, 17 Apr 2024 14:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713387891; x=1713992691; 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=pTTH0+iDWmfZzjxSZ6R9gn/FRBTn/5XMlcc4QRI5pnNDMiHZrW/p/jtRofYWWkW3Gz IQzmD/QFPub50aaG2p6/ZG/H37yF2yXNCZKv1V/wuSopgyZwP6iNj4MbkwME6WW6qsTC x3Q8e7enFDURo43McQJwmr++jyJEtjrazMA8wJLIKo2G1qP219Ykh3sHuKGpcHenyGlV 7NTVAEPR3fYsYcUDqEYJmofzQQhvyB+uVPpsAkL+vF7V1txoUBERzz34kUqAfOh6s6wU TeB+TzHg22fuKrVIlpC0/gODqzYQ7U/AhSG6tAPqwuATQf1z6Vms7/s51tzbReBAHzMv ZlCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713387891; x=1713992691; 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=PEmy5oXGQ7gVje17iwwseScnFXqUAokDeZjU6uKrUjaaAJ5ng6M+ts1eRJbk1S1+IR qOmeGQvE4v4eByTpBXBq30CPUTbNGkOZw+V7//MysGVnyj+qc5r6n6aCAlrN0cWE219X 2dVIG0TkJchgknpeT+J2P2zBN0xjQaUTZelB6B5kd+i8M3Qu2BXUMLigkUnFKff2bnkM 0pPMB6YDztoUx2FkZ8KHTAkET3q3fdLIkuWu9y0sMpZ71lLNBr31mCaEJQNdMpZhBRg8 Qs6Eo/sM8+4Aa7VHLpFF48fnTcp51lGnBZCNdB3xzMI/gXyKJahrDmKPVivqDtopNCvq /E4A== X-Gm-Message-State: AOJu0YzQbznawWKs83sry4tYWYUlWLQMoRzgRuCDkMvcgGgTlXx9mkyR dQlyBxMUJS8iPPHCb+qbO6/ftTM74pg+O0rdDjdp17QMO2uajKhsQzYj4S/jLanuq9L/62GASTc 1 X-Received: by 2002:a17:902:6f16:b0:1e7:d482:9d96 with SMTP id w22-20020a1709026f1600b001e7d4829d96mr664372plk.10.1713387891203; Wed, 17 Apr 2024 14:04:51 -0700 (PDT) Received: from amd.. ([2804:7f0:b403:ad57:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id l9-20020a170903120900b001e3e0aa9776sm80494plh.27.2024.04.17.14.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:04:50 -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 v5 3/8] gdb: aarch64: Remove MTE address checking from memtag_matches_p Date: Wed, 17 Apr 2024 21:04:19 +0000 Message-Id: <20240417210424.216374-4-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240417210424.216374-1-gustavo.romero@linaro.org> References: <20240417210424.216374-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 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 Wed Apr 17 21:04:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789339 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp233527wrm; Wed, 17 Apr 2024 14:06:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXcd35+hJ3kG203Kn7SHzdbkcgL+iZesDTfkRQqqlpSZJSjdK6DFKrkB/bzia1R+I/EW5wshZlA9bvvWEauPBSR X-Google-Smtp-Source: AGHT+IGGvADu1JApIWPW5lKlAR3x5R2btWNim6silHPMApZuCYRLAcXnm6KRXoXoS/PHXQuuZ0KK X-Received: by 2002:a05:6808:189e:b0:3c7:1605:bae6 with SMTP id bi30-20020a056808189e00b003c71605bae6mr1023760oib.36.1713387960392; Wed, 17 Apr 2024 14:06:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713387960; cv=pass; d=google.com; s=arc-20160816; b=Ou0qglec6hkk7y/RVEnG35O39GNdl7e4qTj3ju5RQi30DLCtAcneYX61N41er+RSZO 8Z60HDW6p0fL7p+W2+wcx07TKpRsNZppXHPz/DAJ++PlofGglx6rvXWbUshNG+Y7eGW7 aVopEK/MEEKskYC0d8HApV6Qx5i1KHZfd+pW6JnDUVz7djeG72RY7H5L9IJ5MjiDM1E9 iQOnxHa2pOjmGkBcZRlkvgmQXNPAPPHKUxeM7aP8DJ3lTaW1qh0s176Jxc4ZskRLjE3O SOCwtKK48JweMelzht4K56FEB/bAtwlfT/O7Oq462hfpA1tHMgydlzK9Fi9c9hJi1y20 KEAA== 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=IoeKzU0ZBpieQJWbFm/DMN3i+Xzyq//TB6McomshGZIbCc/CbbO1smBxyFHFUzhBDb E42UdJWxnzXDwtN5saE3rJbS+wT82SPPNFYQeWalEVyMJ3qx55tOL6b+P6TztAUGl/GV 0NTAnzAYWEm/aY677r16xUP9gouG5qMS6+pKsZC9u/dWJ5nyedKHShgrMZu0FhGn1O6h PFl/WUogEWQtxOJWMoj3oiLaPuU7A4NWsZSsZ/GFkrMEa2F1KkqFjjguYcnVIPt3XZw7 gu8JE7MZ1Wnp7HspwVc+kO1NH1ohHUoa5Zvoeb7Fpa/VJK948EEJDX7RHFUKhWqcNNfO z6vQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eHgT3ib4; 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 c18-20020ac87d92000000b00436648a86a4si14748qtd.450.2024.04.17.14.06.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:06:00 -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=eHgT3ib4; 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 0C0053849AF0 for ; Wed, 17 Apr 2024 21:06:00 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id A5AB23858CDB for ; Wed, 17 Apr 2024 21:04:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A5AB23858CDB 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 A5AB23858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713387900; cv=none; b=RRgIxHYiNeLjYX1wOczzj2xRbQw7Gh9LGb3c9B7++j2eem6GNJnvacC+BF0SDoIYskPci1GY31ocXzrbbDt7hBvifQKXMqqziTzRytJltr5qJIWiXKn3OIEf2iXIlUq6xDyqRQYRyLg7MvlxxU+i5CeMYKO8t6JpA6EWoMses9A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713387900; c=relaxed/simple; bh=5sDr5g7U2ywTRYm1e6GUiteL43TzBcSbyiTAO8R27Z8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Cz3PueFE16f2fIPlCXdvv4n3Dj/yYIzqyz34n8bS4MX/Mr0wfascEcx3pQrplToA2bdIZ/etzeGnkhbJRvq1jY9hv0OjithNKdHAg7JvY4GKw0n8Sqfw6dkS6N2Rl9yEdjRy1IBeQcMnaKomRHd1L1JpdlNxxtbBpiwmPi3iibg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1e0bec01232so1727725ad.3 for ; Wed, 17 Apr 2024 14:04:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713387893; x=1713992693; 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=eHgT3ib4old2pbyv5qADfgiTguIXGbRpHsR0VbqxbycJRgZ0QcxH8e12Oep5HbH8jZ zaqY/Ra0nrj4RooobTlwh/0LAQMs0tW+tzAms/GCQxSY8y1EMdtU2HA8hKbbPbvf5lVf ne53sYy2n2FryzPSu3xGTBqUryJrDNYxVONBi6N5S9x3b1OvEScDCaQfKtzs1YefUZAr zkaZ2ECBAx7PfNmMDu8OltNAmigtu4s6xkyuzKujRFdGRajujhO2MuNSWQUJnie/BMpg VAghLLCc69lCXdWHXAURQG5pANlGy4fYOsZUEWZNDhOzbkfpK/twVigOu+qAlI4PsyUA kY2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713387893; x=1713992693; 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=vTHxKFZVnSIKT0I+jqEGpcBWlCVzFcvHb0DukK4zFWbMqZvRinOhDfPZbdX2pytu9u hKUXQ3v/2qjXotmte/KNZpgu+CLc23IevlfFgn8r9sNCldjCZQQGedhmJbRyXWF7BaKs Rg2FQb+vbvgfKLjPjtMuoxqImWSxwdTiDTRVKS9pKFKGI0DQPi1s3hYrlOjIPKoC2WKW GKo3nWDG70s2ex4IcGtHaN8lMvjBdhYx2YwtwrZI5wRpNXxEuhQOclOit/FKkNwbUHeV Cf5t/AjFCnyYKkKK9NfSgjopK0hIY7JOsp60fWqOMEQjenKaPiMw7JU9mVeyyvqtRAi8 Gu2Q== X-Gm-Message-State: AOJu0YzeqABcUDC9nnRig9mIHneSkGHilxR1VBuyi6bpnV1BykFMylgw eyRTDY6XxSxgI54Gr+5c1DJNCHWGZ9J7BNBY0RID665J9zjeH3r6Ct38RHPcHoep+JColo1lLpG X X-Received: by 2002:a17:902:a70b:b0:1de:e6a5:e51d with SMTP id w11-20020a170902a70b00b001dee6a5e51dmr673737plq.16.1713387893418; Wed, 17 Apr 2024 14:04:53 -0700 (PDT) Received: from amd.. ([2804:7f0:b403:ad57:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id l9-20020a170903120900b001e3e0aa9776sm80494plh.27.2024.04.17.14.04.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:04: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 v5 4/8] gdb: Use passed gdbarch instead of calling current_inferior Date: Wed, 17 Apr 2024 21:04:20 +0000 Message-Id: <20240417210424.216374-5-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240417210424.216374-1-gustavo.romero@linaro.org> References: <20240417210424.216374-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 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 Wed Apr 17 21:04: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: 789342 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp233639wrm; Wed, 17 Apr 2024 14:06:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW+JpFvr9xajYSt+sDh0redKhCtUBiQG4s0c8GrOl06pvejryH3waR5QzFB4CYOZVOvCAHlIKzW6X6CYsxnzm/H X-Google-Smtp-Source: AGHT+IE3S/QLWxXvDSOZW0V+hm8WasNDskJ8LD7Oj3IggY7THzZEbL/ho9aOWg4QwXn4BunAxo9P X-Received: by 2002:a05:6102:3a09:b0:47a:3a7c:70bb with SMTP id b9-20020a0561023a0900b0047a3a7c70bbmr986179vsu.29.1713387978596; Wed, 17 Apr 2024 14:06:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713387977; cv=pass; d=google.com; s=arc-20160816; b=nFg9iMh5XoD96ylgeC/P11ETteP81X/Jn7d+2GBX+HqbsNStMyG2uXdNfMq6QTLqNN p6iVOf6t9so3iyV+m85DiY9TYbWFlPX3/EEWDDsPyJwsNNy5lcQuSTo9n4t7Ra1WOCSW baNyhQzUarSUwpLh/vGJQaM5ewjzshjDvZ6IOLts1fGoanEBTc9W4g/TI0tKpptgcwLl bWaiQHhvMQ0lWtcmGyo/3fUU/hi8wKL/zbdUV56lgmn9usPVbm73NoGPY72RmqwyAoQz YC0G3Zh1HXF7w3ohyI1KN6a2z8LzJoQii3Kfc8DZhtK1Hc4A0pGl4knNSj9hnSXN/uJP Daag== 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=Cz8dlBDDpLi4uxT1uiysfvY180H1c9+AMsXf3hobdK0=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=h6TQgoZEdyv7tplr/RT666jFKCA2CCvDhRA7KmuDRVZQwgvsBIIrBWnyofjDb81NGs j0ww27uVjfvSRiZ9mrJeveI0h1Q5dOhjFmZz6sIfMGS64w/rS7OnIA+dHFW4Ccm49rtb YKLuNWEvsZe486MK4Er5j9wPmCDlrJJJBvgAIZsmPO26Eoc0b36goucdUW9luUlWygNW 5vwzZPLhZra83LqcrtSXaqtw/1sSosPYL55qU2wV88GO/GpFxphXZJJpu7h8cCa1W55u epQ4oKKI8JOAUS3391md7XHbqX5xkcpafMi01Ec39bIukTDNe1Mo+yHyqfJ+GAQeODXD hkew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eniW9ETQ; 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 x27-20020a056102323b00b0047a29e123d2si24985vsf.181.2024.04.17.14.06.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:06:17 -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=eniW9ETQ; 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 620833858427 for ; Wed, 17 Apr 2024 21:06:17 +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 53CDD3858C52 for ; Wed, 17 Apr 2024 21:04:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 53CDD3858C52 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 53CDD3858C52 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=1713387903; cv=none; b=AYdB+A1gpB6AoBunSI6w1YXhB8wwaJh6F5ulBNQ/hillShGZOBCh2MlyR9Sk9svNk6cOLGOvf+qktqpU8N650uAJofwafN9JxsvNaMTh+lV1GSWQylwyBxlXkJtB+eIwVukTLwezzQNSgedTH4YfjEXo0JaqO4KxNlmgkO8kG54= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713387903; c=relaxed/simple; bh=TaXmOSnqR8UoTV+90iJqQIZvxqA10JA9xhjjqRdC+YU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=rIzkWCqkCrc/AET4e6d0gAi8M5Iu/mcNdaollaSBDL2T/LSsfrmApGhctNy3HPSMF7tr0GXAJ9UhVjewW3UR9G+vV2IEqDrJYJrimGBnC6wRJnUAZukV6tbrDlBkP4MSg3CLh9OGDBrqmTSBQJjfsFQjTQEeKcYvH5lSLai1sFc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6ecf1bb7f38so247045b3a.0 for ; Wed, 17 Apr 2024 14:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713387896; x=1713992696; 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=Cz8dlBDDpLi4uxT1uiysfvY180H1c9+AMsXf3hobdK0=; b=eniW9ETQ5wuBbtNVvo+yi/r/FA+8YB8UmIOzGW8vY4PlghMV+XmGcrRnXP2rLZ72Mn NqaKpUZ4pUIgNjm0644wKIHv7xJ/fgS+P/PwI/o3qhfPWYL7nQaKvKrjltAyZHePis/t q1TtV0svckgBxtXy1qFhkkVPTjuDrx2nwTsRKe3pbvlbGPppEPg3DtMVfDQk4+RTGyIf fz/euyK1BUc/ng1yzQphho0CXYezJ+H7iijppkwzqMuE6LMv9nl/AY/FRsAdUNxnZicH pG7cESafe5jrdy726bcHA/9EGDCBU5LbkV/5I+lTdObCzwY9BFGMQk8f4NKtifEMYe2o k1bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713387896; x=1713992696; 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=Cz8dlBDDpLi4uxT1uiysfvY180H1c9+AMsXf3hobdK0=; b=GXi49DtyZ/y0mSfBO3Y4PFAmNLOSYpXRGWNsemb4k7xoJog/2OumnjbgbmrZK7GU4V fKfnEkVFOjKnNzJUpCOgZNv9THVYxB3TLb/+mfbLyjQibcNFNelOwD20X9YIQ1nMX0Ta 93tF3WZzhX5viGTSG/cw2UjuYM/1rE4K2uz23a34o/uWCY2IYLzl0LXRX8Pf1UiDWyXX xEpkxnA903OrSME3vqs47Q9eMWO+2C9P+QAGyeH8P3YD2Uj7bwUxYpjCfy2l/QI2Y6it kQLKtowMjH/iHT9JmuKvKB44b5h12+owFloZuEL/JROv7jSVS3ibshEAmRXx5BwGxklb f/QA== X-Gm-Message-State: AOJu0YxKelNr9pLXL9asy87C9nYztGAd1HicJmUxZNbLiK+Bs93mdZ3R fvpVOvS07cF5JMP/orKflvNH7iTadCdo6NOXxRpl7P6np2yAoUXr+qy03Bhg8RBP3/TICBjmHZM X X-Received: by 2002:a05:6a20:5657:b0:1a7:8b88:963c with SMTP id is23-20020a056a20565700b001a78b88963cmr920157pzc.20.1713387895689; Wed, 17 Apr 2024 14:04:55 -0700 (PDT) Received: from amd.. ([2804:7f0:b403:ad57:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id l9-20020a170903120900b001e3e0aa9776sm80494plh.27.2024.04.17.14.04.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:04:55 -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 v5 5/8] gdb: Introduce is_address_tagged target hook Date: Wed, 17 Apr 2024 21:04:21 +0000 Message-Id: <20240417210424.216374-6-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240417210424.216374-1-gustavo.romero@linaro.org> References: <20240417210424.216374-1-gustavo.romero@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patch=linaro.org@sourceware.org This commit 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 Approved-By: Luis Machado 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..ae56b9d2fa9 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 (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 5c9fdebcdbe..cd271c4b493 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, @@ -15574,6 +15576,14 @@ remote_target::store_memtags (CORE_ADDR address, size_t len, return packet_check_result (rs->buf, true).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 Wed Apr 17 21:04: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: 789343 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp233775wrm; Wed, 17 Apr 2024 14:06:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUQ9UE7sRUag0wCE++bf87HwEz2tJh/+ApkPlQj+GBcFImOAgfQyGgr0CTduliOXImZhY8qLgb8cAKvq/Q1/6sw X-Google-Smtp-Source: AGHT+IFO7GTar1deST1ofTYp6ctCBNu63Ef8lf5vXaHnvI9LeHxOQoTsxnmqG96aWDMup8IvfCqY X-Received: by 2002:ac8:7f16:0:b0:437:79db:d662 with SMTP id f22-20020ac87f16000000b0043779dbd662mr615024qtk.15.1713387998828; Wed, 17 Apr 2024 14:06:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713387998; cv=pass; d=google.com; s=arc-20160816; b=r7HnH3rcS8sXNrbkEcIubZsvm9S0bi7o4BxpkS+rGie2iVvppLkltE10vNNKv/I5Ia +cOiPSgHNRYSe6ndAp0EGKCEJDypNV+tn0Ss7YHhFeJmKQN8lMtILrD+SqlS9BIAJAXB MWIQmufAUdIL/lUWpxB5vMh72JUUd3DZXHKT12jl9HEg2NTKrAFtGWOlGgTS32f+BoMs Yrbn63Bkh68yd2EYz//4IFYD2we2mHXANxiKV28SlMiTUXL1zH/uB+f2jsyMMzl9I5ZM DQqy/xPDopITdj6IPC5wYxQQm2Au57CR4obQR7YcpV5XGU8t5CSpVE4F3NTy63IY6Ynx XqJA== 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=jJMnCAS7JhNlNLrR5zkoIjLZBdkOSQn5g55tAEWRYyc=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=vcPenFqDVLT4eUGTjpUt2oc8Cs9ff5uVtK9TzydyCEFbuOqbbtVzdXA5WnJ+UikTNF SffcrHt6GXWrQkm1pT3Nuxtfl3zSCY5r2UcuHNwmx35aTL74/uwrbl2dvH9WOcJhGgsF sTwVU5jZlJ4Dc4VsHI3PbxadHmAUGwp9ac180A4oWMN/Yve13N1UH1732fhaGV3rCPLB q2upvGkyV7rgUBOzMx3F/TunVsPTdoJcPPdpHaf8+GXzMJC4jHmS4Irt6CTpeP+a588V B2A0hZtg9Y/5byo398SInaucpJuS6nzZfcJ60N9ujE8Db2LD2448GVzDIfjcFQMwPeCC g+NQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="sWpjcs/2"; 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 l15-20020a05622a050f00b004365858c699si34147qtx.138.2024.04.17.14.06.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:06:38 -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="sWpjcs/2"; 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 784D23861870 for ; Wed, 17 Apr 2024 21:06:38 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id 7054B3858427 for ; Wed, 17 Apr 2024 21:04:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7054B3858427 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 7054B3858427 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::634 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713387902; cv=none; b=u2ywucCmPt30ILiY17LssOQLyPAsqkrIu6g1ZhuTo5NfMtktML2UWONwb+CQykSkaTAFTgRu/9nRVzQYb9TtvEzSlINoHEk3gqB8Cx9tuKszTiUsqdoPVAd8ouBRyDPQiCYmRJ7PxU1SN6tmOwpzBlkEfSN/EQSKn/ZH8a04UUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713387902; c=relaxed/simple; bh=vop3zeMlI32VNl+L7d6SvD68a1TBDsSzmZxY05GPZLg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=TwHJp6loHr+8dBPEurpWGkyDRSCK2KR99fTsvw/K8K+bLab6VJ+kdNgSpdz1mEUWF8lQdDsPEKdi2pY3pe2KYSZhEB+CQ5+tNPEX0jyF+vpMnzMBfAg9ohg35poh4y129NU8GoMflIPnUAwX7U/DDUvlSpv78QkhKqgJJdcTTsc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1e3ff14f249so1536405ad.1 for ; Wed, 17 Apr 2024 14:04:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713387898; x=1713992698; 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=jJMnCAS7JhNlNLrR5zkoIjLZBdkOSQn5g55tAEWRYyc=; b=sWpjcs/2rqXFuZXSHyOQzXhctzK+bi7/T1VHFz/KP37nLLGTXrFilq+nFBAG/PCB8k X1zO97hSdLrVCYaM+EDVVPiGN2MTtnfaWfE/xEIZIE7RvOsnA3px1de6Lo7w0zCCes3x wVzeUhexust6/vm0I1A6M4l5q7QQCwuiiatJ/BX4XnkpWMTT7oQklbqYSF5Yma5+i6Fx XnSivBl0zk9KNVFY0ITt0TcZZtDqW5yaK5jbbdQwg61k8f64PgGHlfaoBW0F4RDt9HSp HMX/mcEAnm+Uik3nuWKM4ISzhrxBTbYckyBDP2dh83uYWUn67pC6oz1lVzZ16xjpVoKZ XHkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713387898; x=1713992698; 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=jJMnCAS7JhNlNLrR5zkoIjLZBdkOSQn5g55tAEWRYyc=; b=lZvGjnjeduskTI9XmE7oj0oBxklQbnGmNy0/qqsJBQUBEKoP61k0Ut4aqdnuEB9kLd nklxzkPUvThdZm2guBGf9mPY4PAkPyCVFotnuwnD65zQyD+4vVkuG4YFdADQ4pgN9QZY 0kuO+gVnc3C5xVxwGvBJImUzxXG7XWIBwhodBxJC7OeUzpUQMVGpIVFNZx0nL239vfJj KBjysILKZf+w2q6FrAyW3pPTKfuTj7FEr14ZtdruCdYSYcyCDoVTWqobXDNuQ1UTeoHg w4Lx8v/s2XRT3b1X0oZeuSXXXeraWEsaewG3j53BSONo4SB4bW17XCRi1OefluYI6Esc 91Ww== X-Gm-Message-State: AOJu0Yy90r+mq9x6dVqcIRkOAos9BciqMQWMxfUMDGrtKTnpve3H1dSR eusyGLyEEEipMfBcskHHbmLUJfzMHfvoKrbBGTToi7cM2SKhuXTfJ2hvGqGi4UM6nOc+qL/adNx B X-Received: by 2002:a17:902:e54c:b0:1e4:53b6:6be with SMTP id n12-20020a170902e54c00b001e453b606bemr409471plf.1.1713387897935; Wed, 17 Apr 2024 14:04:57 -0700 (PDT) Received: from amd.. ([2804:7f0:b403:ad57:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id l9-20020a170903120900b001e3e0aa9776sm80494plh.27.2024.04.17.14.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:04:57 -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 v5 6/8] gdb: Add qIsAddressTagged packet Date: Wed, 17 Apr 2024 21:04:22 +0000 Message-Id: <20240417210424.216374-7-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240417210424.216374-1-gustavo.romero@linaro.org> References: <20240417210424.216374-1-gustavo.romero@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patch=linaro.org@sourceware.org This commit 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 | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/gdb/remote.c b/gdb/remote.c index cd271c4b493..2bb962955b5 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -337,6 +337,9 @@ enum { packets and the tag violation stop replies. */ PACKET_memory_tagging_feature, + /* Support for the qIsAddressTagged packet. */ + PACKET_qIsAddressTagged, + PACKET_MAX }; @@ -15535,6 +15538,49 @@ 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 (remote_target *remote, gdb::char_vector &packet, + bool &tagged) +{ + gdb_assert (remote != nullptr); + /* Check reply and disable qIsAddressTagged usage if it's not supported. */ + packet_result result = remote->m_features.packet_ok (packet, + PACKET_qIsAddressTagged); + + /* Return false on error (Exx) or empty reply (packet not supported). */ + if (result.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; + } + + /* Invalid reply. */ + return false; +} + /* Implement the "fetch_memtags" target_ops method. */ bool @@ -15581,6 +15627,31 @@ remote_target::store_memtags (CORE_ADDR address, size_t len, bool remote_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) { + /* Firstly, attempt to check the address using the qIsAddressTagged + packet. */ + if (m_features.packet_support (PACKET_qIsAddressTagged) != PACKET_DISABLE) + { + remote_target *remote = get_current_remote_target (); + struct remote_state *rs = get_remote_state (); + bool is_addr_tagged; + + create_is_address_tagged_request (gdbarch, rs->buf, address); + + putpkt (rs->buf); + getpkt (&rs->buf); + + /* If qIsAddressTagged is not supported PACKET_qIsAddressTagged will be + set to PACKET_DISABLE so no further attempt is made to check addresses + using this packet and the fallback mechanism below will be used + instead. Also, if the check fails due to an error (Exx reply) the + fallback is used too. Otherwise, the qIsAddressTagged query succeeded + and is_addr_tagged is valid. */ + if (check_is_address_tagged_reply (remote, rs->buf, is_addr_tagged)) + return is_addr_tagged; + } + + /* Fallback to arch-specific method of checking whether an address is tagged + in case check via qIsAddressTagged fails. */ return gdbarch_tagged_address_p (gdbarch, address); } @@ -16070,6 +16141,9 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL, add_packet_config_cmd (PACKET_memory_tagging_feature, "memory-tagging-feature", "memory-tagging-feature", 0); + add_packet_config_cmd (PACKET_qIsAddressTagged, + "qIsAddressTagged", "memory-tagging-address-check", 0); + /* Assert that we've registered "set remote foo-packet" commands for all packet configs. */ { From patchwork Wed Apr 17 21:04: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: 789340 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp233542wrm; Wed, 17 Apr 2024 14:06:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUYV6tedUcnTYbhoCHmLB3WSH1JEHnkHBw859P7XQc02TBbidqF7EDXCYhml1//DpNhlNbcmZkcPA2r3tfeDGMv X-Google-Smtp-Source: AGHT+IEIRc7iVpTSZfVPS5DTiix3CQJcA8HR1apmITLQeON7EXw/aGp96IFHKI8ErpVKNKY+v3xp X-Received: by 2002:ac8:5790:0:b0:436:936a:d674 with SMTP id v16-20020ac85790000000b00436936ad674mr757255qta.67.1713387961873; Wed, 17 Apr 2024 14:06:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713387961; cv=pass; d=google.com; s=arc-20160816; b=iDeLWLzt4hW1sz6AHcIXZLHQ5ULuoCGz4hkgpMfWwKrm9Z49sBUyXXpapwJ0qfw5oD AUWWRkq/eofrgPhKinMJEFFiVCQe1f2D/ujEtWnHmK9UFG8Sb6FYRL1mi8qC0k6CfiEG /3GRNs70ERCXsoo3O1ATP4TJeaEZEmOffE9gPhIlFmwwAtU12b1ZCse8fbX1yp4FrdQ9 lt9cDGrxXa0zvdoxx/bzCRBw3/81xSgou4hKenawaAUUgp1wxbK/3J9mH+MzBEr5A3dw +CoS8O44XHSBoQdqXmWu3MbBZ2FzD/oUCvcd/OvzdhTIm3g9NhM88VAtfclXYS32dNHC 6AWA== 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=+i07Poky40jkXDYvyJqhBtQc5rB4/eUfwGp75gk+SQI=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=j/zwoLnZu/r+RuuSDVkyYTp+GHQRMh9MvoQSmKBrpRXqLLBJ+SavB8tMiAhGDYcuQq /RfQG9O+F8tEyOnJ0QjGMxCJLBAqdDMg6nM3mMt0xpcbK6q1BJ1GE25jW16Oex6O0sC5 nDrF0FBjyxdVbvtKujqbDEF+easUiXskXB6wRyyLuLJlLoxpbeanv1HrLXMliRJLlEnK uLWAYZiB98ucu4aiqm7/LsTj9Re0yH7ekmWgLED4UknwAWbmkLD++/Px6k3At4aLK5tZ 10NC53sULVwCrqlB6+phI2Z0D44YIQtbMm78ve5isDlXMp1loFWJlPxw/sxHpfHk3Prz 6QGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pcUpt4Nk; 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 13-20020ac8574d000000b004344a5e5d69si5392qtx.747.2024.04.17.14.06.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:06:01 -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=pcUpt4Nk; 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 82A75384AB41 for ; Wed, 17 Apr 2024 21:06:01 +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 9F3A0385842D for ; Wed, 17 Apr 2024 21:05:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9F3A0385842D 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 9F3A0385842D 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=1713387904; cv=none; b=mrBVDni2+2Hl7TV08CUhhNj4qduuZOBl+MwDwCX2m7jHa4l2EoKH0GEStoDalnW5wc5xNABFznuzFeNVwIOksXBH6s9p5qyazHLXcEK/2tCGbVqEeuyd7W0dAayL9SGJWmwZClr4fCmmkOf0uPB2tNCQqfWIsDAJTZs+fY62h+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713387904; c=relaxed/simple; bh=+QfJjJUE3LzPMo1UQ2j9fXd4ixSljIBqN3foFT3CnrM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Rd2kQcprKyMChBZFcq+gsYLMFmONCL7Oyxi21VdCAkjlx8ehJSK4JpbDG2B28dSC3CB1iiqTXHzp/gNVFg6C0CdTQzh2PfYJ9MW0RF/d3Boc9zdVNF1P9TRjWnvkvQQlLLxGr2X3tKcRC+dN7+3adFkmBPy1SdWpxu50ewe/s9M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6ed0e9ccca1so241726b3a.0 for ; Wed, 17 Apr 2024 14:05:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713387900; x=1713992700; 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=+i07Poky40jkXDYvyJqhBtQc5rB4/eUfwGp75gk+SQI=; b=pcUpt4Nkk0IcqbOtkkT4MMrlA2zOIPxSNzYQbSNKv/fzHHtiNWMxy8Ueq4lwj7uQM9 rnDctOqkQg6ePmN2WVPozKdeh+hmjT0EDmJGfCuTUsy/tV/qTwSB6BpbSoN/BKUBS0Hs 4sGB1UHKlksPQMGQxEuwx7hkGO2ntqapH8P6mUBgsBShhIQSx3kqxGZyjSyV2QZ8MB5B socZrrxnOMdUGX+YuLmFj6JF+J5rBOCf/JGQJ9jz0yGXFUt0eihlAY9e0XCzIbwg77KB kSzjHDFhnFolU6ssXZUVa5CpPiUDt5udAltgdzbB6Dk035mL7mQSIFCBMyKVmAgp+zcf gf9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713387900; x=1713992700; 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=+i07Poky40jkXDYvyJqhBtQc5rB4/eUfwGp75gk+SQI=; b=GLhFdoFLn2sVQol26nI3pjZktVQWsdVoAGOaME+BcD+DRPPSgB1qRCHM5HqV4L2B6q Sicf9w5HkfXPz0I7yLVLXXX8emLseXXuftYKDBCv8Lc5Y95GWaNNtrbkeKerByDarCkI ZNGSm8KIz24Ud1+G7RbS2nrbZFeTjBUgI8kp7j54a3htHh2DFSM3fKGtG3Y6xaDenJJb 10EzFTRJS30x6Dq/6vGP8zg3OinZWC3ePSAJurouwHzGEnP+QkG3QGAIOfX/2LQyZGWO P8X08ZQDrV0vxbueLgC/pLG5VvfV0h5J+4qh4dGMDFzra51z0iu9owExYGxxRh7iX6k4 ctoA== X-Gm-Message-State: AOJu0YzHaEFV5WftvB6YT/T+T+jBxX9gQeA1Zx3BX01jzlPfNsgYaxQy yFKnrmgGKOLJUM6vBeQlg4LnZGCAWPjv6i+9DwFsPzGbxobCDeneIArJKo2bQS4TFL6N4IDLEPZ I X-Received: by 2002:a05:6a21:2d8e:b0:1a7:23c0:24e7 with SMTP id ty14-20020a056a212d8e00b001a723c024e7mr1296222pzb.42.1713387900307; Wed, 17 Apr 2024 14:05:00 -0700 (PDT) Received: from amd.. ([2804:7f0:b403:ad57:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id l9-20020a170903120900b001e3e0aa9776sm80494plh.27.2024.04.17.14.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:04:59 -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 v5 7/8] gdb/testsuite: Add unit tests for qIsAddressTagged packet Date: Wed, 17 Apr 2024 21:04:23 +0000 Message-Id: <20240417210424.216374-8-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240417210424.216374-1-gustavo.romero@linaro.org> References: <20240417210424.216374-1-gustavo.romero@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patch=linaro.org@sourceware.org Add unit tests for testing qIsAddressTagged packet request creation and reply checks. Signed-off-by: Gustavo Romero --- gdb/remote.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/gdb/remote.c b/gdb/remote.c index 2bb962955b5..bc2cfed2595 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -15681,6 +15681,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); @@ -15747,6 +15749,71 @@ 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 error reply on qIsAddressTagged request. */ + reply = "E00"; + strcpy (packet.data (), reply.c_str ()); + /* is_tagged must not change, hence it's tested too. */ + bool is_tagged = false; + SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) == + false); + SELF_CHECK (is_tagged == false); + + /* Test 'tagged' as reply. */ + reply = "01"; + strcpy (packet.data (), reply.c_str ()); + /* Because the byte is 01, is_tagged should be set to true. */ + is_tagged = false; + SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) == + true); + SELF_CHECK (is_tagged == true); + + /* Test 'not tagged' as reply. */ + reply = "00"; + strcpy (packet.data (), reply.c_str ()); + /* Because the byte is 00, is_tagged should be set to false. */ + is_tagged = true; + SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) == + true); + SELF_CHECK (is_tagged == false); + + /* Test an invalid reply (neither 00 nor 01). */ + reply = "04"; + strcpy (packet.data (), reply.c_str ()); + /* Because the byte is invalid is_tagged must not change. */ + is_tagged = false; + SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) == + false); + SELF_CHECK (is_tagged == false); + + /* Test proper first byte truncation. */ + reply = "0104A590001234006"; + strcpy (packet.data (), reply.c_str ()); + /* Because the first byte is 01, is_tagged should be set to true. */ + is_tagged = false; + SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) == + true); + SELF_CHECK (is_tagged == true); + + /* Test empty reply. */ + reply = ""; + strcpy (packet.data (), reply.c_str ()); + /* is_tagged must not change, hence it's tested too. */ + is_tagged = true; + /* On the previous tests, qIsAddressTagged packet was auto detected and set + as supported. But an empty reply means the packet is unsupported, so for + testing the empty reply the support is reset to unknown state, otherwise + packet_ok will complain. */ + remote.m_features.m_protocol_packets[PACKET_qIsAddressTagged].support = + PACKET_SUPPORT_UNKNOWN; + SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) == + false); + SELF_CHECK (is_tagged == true); } static void From patchwork Wed Apr 17 21:04: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: 789344 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp234169wrm; Wed, 17 Apr 2024 14:07:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXbQ7J95Dkul3EFLUepUW9WdzTcqBMQcewk8LT32ml/Qwob3/khjQCacCYFtvdvTaEWpXlld4h9I6GjmBMTqw9z X-Google-Smtp-Source: AGHT+IF5/0w/Dj7ThCLKKFc/rvEdBH3EQOB2sFzMcHzZ0gaJpnlLePYI2wiKBtWK8/1ZMfeWysAE X-Received: by 2002:ac8:70d:0:b0:437:99d9:662f with SMTP id g13-20020ac8070d000000b0043799d9662fmr20949qth.62.1713388052718; Wed, 17 Apr 2024 14:07:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713388052; cv=pass; d=google.com; s=arc-20160816; b=c73sQ5DioEGkFFNRdE3ZgkWa0goTWFsmfatsD0i61AWDXo3PHp6v71kQoDzObbGaPO 7Y7rXcuFR2Vsfq1YeqEXe7lTXLGgx0YBl22RUp+/kmS5achyyf7bJZGydXiI4RI/WCmr OsduJDfG+teqOzDbDXxuLCaiKsv3SfJXO1y4D2kbzmbXt2qit70zgxVxeW4kyJ+x1/d9 LzGXTdri0Pxo+uvHt8aAdMk8ZeYy4UaIkKG2BEDfX6DGp+LZvwYO0rdjURGWL6uIo6GE DRlPdq2Qjp0uE3ZRyNMAXoNw2/lSsfpoNV87qKZyC/6A/D+ZLDf8cfBb4XIW5UJb1YT4 ZvSg== 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=tczhSMFbAb94s7h358uCBvjkww/Sz3Pq7Jj3xfcGsKQ=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=k/gkLXy9ZOO2xX9ojJE2xywc5XUmgul68dzRYFkEO2jzWg+Rrox5q35bRSFkPMVeeu fy2V4LM2KSU5sLHbKN5pVs4DHTbKRDKKuIQ4qzG4yjGYRHaGDNSUyPY/juAafp6Zl0pU sc05gZOZwE7zJc5y7f1GhvdbCFz+jY2xgRd/MpU8Sh/N3sq+ypmRC+ciCnIlxfcKMFH9 qh1bPUfcl0LcbwVQUctofEhHXbKT49UE2mxoNw5l3ylndBIPUHRxGxETaUuTep5VWOUU smnvwKXwyE0in8Ar4QpGmxPVsAvLJ9doY8/gUFJ/8yOxchzISN7uDBJ0396iRM/Z3Z78 9atA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SJHM23IA; 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 u20-20020ac858d4000000b004347cf7c206si32992qta.216.2024.04.17.14.07.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:07:32 -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=SJHM23IA; 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 7401B3858CD1 for ; Wed, 17 Apr 2024 21:07:32 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id 0A4F83858408 for ; Wed, 17 Apr 2024 21:05:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0A4F83858408 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 0A4F83858408 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::632 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713387908; cv=none; b=vdNW6ZbOKRHOXvhESMjeDHO7rNzlnx8nwEWXX74zpgwqMEnAwxywvMmLkrufGPYlKX8c/RGjz39/hXRSEltHSVwyoINKuMbyZxnqHpIzYX7hNaTkgmPaz9hTHH071PHt0i/np50V9vWkjIPBrBsB3LUhg2kxMphayFjvNCRtuKE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713387908; c=relaxed/simple; bh=cVLWOxkA1VHFRsgEUHjDQ4iZA5qrg0m1xE0cjIpH+RI=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ROa7dN7ildxQAbglseCHGu3UjQc/zcjAEGPt5yYo2U8Ap3DvjrITkSgp6Gf8kZiFNzVxeI4lffVtadMrIEJlAzdMYeNhrKNvOu0lS36c4+ZmNHU1CKpH2XKbL7D39TeEwPZ4pye8SK2CX8NNK7u4IGL7jhBkJsIcj6V9nAR4JHw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1e4f341330fso1790755ad.0 for ; Wed, 17 Apr 2024 14:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713387903; x=1713992703; 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=tczhSMFbAb94s7h358uCBvjkww/Sz3Pq7Jj3xfcGsKQ=; b=SJHM23IAHxSUjyThRGQLx6ooWJKAL/bk6S/aFQ6K7i95Ou3n19umUaETP3RXjFYUNr j/bGza/KRT8ONZ279j+eDvg5t9/4wL+hO4w5sXpxdl9Gw0kGy7jX4Dg9JHB4A1wYn/6t 9+lukBpgf7/tIxmuPpimWH//+3BCGBMkMcGyTTr6mjUg8lh7l9Y3eXYff2MNTYO3+GRi e3/DWV63F2eNdaJzgFkHvzHEFe1yqCR6vDZ0+6jEcblsFmvlFl+4fUleBvBlvvCfGZZt 1iPjJkg1flCqHpkGqGX5aQ3vlE7JKdr8Ms1eXa7vsy2Xk8gm+OGHQN/NFsxjAY7qviyR aajw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713387903; x=1713992703; 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=tczhSMFbAb94s7h358uCBvjkww/Sz3Pq7Jj3xfcGsKQ=; b=BH8h0wFlnaz2ozIaO1GL/I2kWtGe9qeY0reiTQ5OqCh/wwr6VmeLVYz/LihEIiKEhU nNGc6WWREOS74qmauWLKE0NvK8Cnfp8k3YQQPaw9O5hYZnQ0qk8tWeoAdHFwnvbCnPRj U2CBt1fsP325Lc3ZRi0+AGIMADzBDv/ml4nKGX+4mR+lvVK5j/lA6XRdZzigSm9vgZkF Ev3e7FCZCgIEg+VHPBCFjHxBC76WlaUgflJXArDPMAuzHxMGsGP3qjLuIsZs8J2qGYld wRbj2XCs9DkuTHTdesLz50aLl1fkimaqj00oOJh2HcqxM6MUVJ7zljZh3MWbGEvpve1z D+ew== X-Gm-Message-State: AOJu0YyKoY0ycixLGPV2EiVAY5OlCFfwDCHTp8+9jQW+wJJpKtLbBuq3 EUgLQ+VmRR8PEItJ2gdC4pf+31PwHWeX5ydTO3oeUaEoUy9YEgnR/8MhAQelXGPPRoNFAf5tD8B B X-Received: by 2002:a17:902:8692:b0:1e2:7dc7:477 with SMTP id g18-20020a170902869200b001e27dc70477mr628915plo.57.1713387902662; Wed, 17 Apr 2024 14:05:02 -0700 (PDT) Received: from amd.. ([2804:7f0:b403:ad57:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id l9-20020a170903120900b001e3e0aa9776sm80494plh.27.2024.04.17.14.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:05:02 -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 v5 8/8] gdb: Document qIsAddressTagged packet Date: Wed, 17 Apr 2024 21:04:24 +0000 Message-Id: <20240417210424.216374-9-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240417210424.216374-1-gustavo.romero@linaro.org> References: <20240417210424.216374-1-gustavo.romero@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patch=linaro.org@sourceware.org This commit documents the qIsAddressTagged packet. Signed-off-by: Gustavo Romero 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..90b0b68a279 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 @dfn{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 @samp{01} +Address @var{address} is tagged. + +@item @samp{00} +Address @var{address} is not tagged. + +@item E @var{nn} +An error occurred whose code is @var{nn}. 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