From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id zcpRN8bXpmfOuScAWB0awg (envelope-from ) for ; Fri, 07 Feb 2025 23:04:22 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=HrwG5aJN; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id D2FC41E105; Fri, 7 Feb 2025 23:04:22 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D0CDC1E05C for ; Fri, 7 Feb 2025 23:04:21 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6E9433857829 for ; Sat, 8 Feb 2025 04:04:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E9433857829 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=HrwG5aJN 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 C9EFC3857823 for ; Sat, 8 Feb 2025 04:03:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C9EFC3857823 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 C9EFC3857823 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=1738987432; cv=none; b=DB9xb0NGtlvWv54b3shCxriVlivY3IfcOBCPNzM17mgPmKiqTk+CNYJ9ZVkXJWg1FR22Pi5yJbmF8n2OaJQnuOOO09wsXLj6ZbQbIvTc6Y6YHUmPT1vpuVdO74D5vhO7Na3l8KtHnNZpL9WrUWQYSF5I2UEmuMoYJXMoHYH+qPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1738987432; c=relaxed/simple; bh=U4weqJV+1NyeauO4nyxI9wr+EKsdVOWADJ7gPODwCzk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=FvkUoBfzS97tGv03DwKfh55S+oKRVj7CDJg++Z9IvMp0m7z7vD1kaHC2hAYCru17T113OJCvTXWeLj7HHnG4GpA417zqTTLAUmW+H5ouHoKRZ1kUDcPRlly4TRcenl1ThfVgrabjxEsavE2yCN1ISTOv9c69XdnmxjWij8fjb4c= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C9EFC3857823 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-21f2cfd821eso49950365ad.3 for ; Fri, 07 Feb 2025 20:03:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738987431; x=1739592231; darn=sourceware.org; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=nJumF9hNbgWLBjEzdwyxnUcQX4gZ2DlCYiSCXme+NR8=; b=HrwG5aJNUyeUtNT1uBIqBSlhxbbEH37n2sSOAq78hl9T3oecbSlNZquCsTGZRfci87 BphKhzcGjgFlLHL3fURkylkCa+OOFGp316E8aVZZxDPFMb6WC3TcSlmpXxTZhxYVNDdv i7K1GKnqfTAw0l1MWLp6pi3hfgcpzK05VcbUqvgMeJe8E8488SyAfZ6C03RZQI45/mpe 75Ztyik2WpEwNZBRSKG1hynQ0JyvpeiHQ6IcliC1024g14RsrHU8AGd25KwBPShvvXty jJ3EZesycwa8VM1Dx3hIWicRszHmUIaejrjM3qeLhhA9VxxmZ7hlq4tY2snJQOpWukxY WAWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738987431; x=1739592231; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nJumF9hNbgWLBjEzdwyxnUcQX4gZ2DlCYiSCXme+NR8=; b=iVYC0zNBgf8hcF69Q4ZN/8slh4vpCnx2SB8tNwaHpKWnSxPlUGq65kQTaVSjfI20XE gKVQu2OVx1cOKtc3cRU4xMCqNnz0LGG9f5y+ghB+L4k/uGuBwGcsiFGx6HN8O4Qnwm/a xHJhp1EdQj8sX2FbrgsclMHMGXcvqlk3cuUSqEpJIRxqs3tk3KlfMrbPm2YtrGt24bZl CPLcKoX/l1j+1PFvLBx4mHhBTgNerAkW/YYwBeAbytsZ9r7Ebc+/B+IQ3RnLDjFnBdcn 4cuzeKmXRJfIdPbNjGB3CJ/NpxGDjYFzT9Hqax3b5bB/H3US8HxsRUwFatsQ0h1jdPTm zD6A== X-Gm-Message-State: AOJu0YyQbEqHg8NcKS8d5NiuXrQM9SJnWF04HapNdkU3CzvK9WTXMcba lTqUxn7z5fAQm1dMZztdqm2V5yftSkXhvwqYKiR1VvHE4Tx1xlC2tuu7Id4KV04= X-Gm-Gg: ASbGncvQtr+jMjvAseZbbKM3o526MAq5PZgfKKEhr5nh+F1TfU7Ahw5x2u1fVmikwV6 7BeMqoMIyl4FjIDSZpYBJh5MSVzFmBRJc+/2H0n73yR3QVYA/F3aW7eobE2KrzQ9ROhzqSYCWJv O94cUxupjSrEe0vQXBx6kvldqYwnzaJqWTVK+haLYh9kaoCsYbHCBatmeHYDLJDNWC9u3oY9hGC qAJTbak++cYf4F9Wj/kFeYRuad3mDyw7+cChvo/HPIa0mnQxS2D6tolym0OsGI70CkVobC+UTkY ZNp9FXkcZLFrjyGhB5o5rKI= X-Google-Smtp-Source: AGHT+IG88erJ0DcdE4l3ImimsuCbibtyTShdaMWIz1E7uha1q/TtPxbrAThRp1tr9Lfnni6OGtXZ3g== X-Received: by 2002:a05:6a21:2d0b:b0:1e1:b44f:cff1 with SMTP id adf61e73a8af0-1ee03b4227bmr10302462637.33.1738987430833; Fri, 07 Feb 2025 20:03:50 -0800 (PST) Received: from localhost ([2804:14d:7e39:8470:b53a:98d4:8895:d0]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73048a9d1a0sm3919047b3a.12.2025.02.07.20.03.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 20:03:50 -0800 (PST) From: Thiago Jung Bauermann To: "Schimpe, Christina" Cc: "gdb-patches@sourceware.org" Subject: Re: [PATCH 11/12] gdb, gdbarch: Introduce gdbarch method to get the shadow stack pointer. In-Reply-To: (Christina Schimpe's message of "Fri, 7 Feb 2025 12:01:16 +0000") References: <20241220200501.324191-1-christina.schimpe@intel.com> <20241220200501.324191-12-christina.schimpe@intel.com> <87ldujhhjh.fsf@linaro.org> User-Agent: mu4e 1.12.8; emacs 29.4 Date: Sat, 08 Feb 2025 01:03:47 -0300 Message-ID: <87v7tlqdzw.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain 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~public-inbox=simark.ca@sourceware.org "Schimpe, Christina" writes: >> -----Original Message----- >> From: Thiago Jung Bauermann >> Sent: Thursday, February 6, 2025 4:35 AM >> To: Schimpe, Christina >> Cc: gdb-patches@sourceware.org >> Subject: Re: [PATCH 11/12] gdb, gdbarch: Introduce gdbarch method to get the >> shadow stack pointer. >> >> >> "Schimpe, Christina" writes: >> >> > diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py >> > index 52f265e8e0e..df70cb082a4 100644 >> > --- a/gdb/gdbarch_components.py >> > +++ b/gdb/gdbarch_components.py >> > @@ -2822,6 +2822,8 @@ Some targets support special hardware-assisted >> > control-flow protection technologies. For example, Intel's >> > Control-flow Enforcement Technology (CET) provides a shadow stack and >> indirect branch tracking. >> > To enable inferior calls the function shadow_stack_push has to be provided. >> > +The method get_shadow_stack_pointer has to be provided to enable >> > +displaced stepping. >> > >> > Push the address NEW_ADDR on the shadow stack and update the shadow >> > stack pointer. >> > @@ -2831,3 +2833,11 @@ pointer. >> > params=[("CORE_ADDR", "new_addr")], >> > predicate=True, >> > ) >> > + >> > +Method( >> > + type="std::optional", >> > + name="get_shadow_stack_pointer", >> > + params=[], >> > + predefault="default_get_shadow_stack_pointer", >> > + invalid=False, >> > +) >> >> Ideally, there should be a comment on this method entry. >> >> This method is only used in amd64-tdep.c and i386-tdep.c. IMHO it would be >> better to put it in i386_gdbarch_tdep instead. > > Hi Thiago, > > Thank you for the review. > > As also discussed here: > https://sourceware.org/pipermail/gdb-patches/2025-February/215266.html, > I wonder if it's better to keep the code generic. Indeed, that's a good point. In the case of this method, I have an additional concern though: its callers assume that if gdbarch_get_shadow_stack_pointer returns a value, then it means that shadow stacks are enabled in the inferior. But this is an x86 particularity. On AArch64, if the processor supports shadow stacks then the shadow stack register is always available, even if shadow stacks are turned off. So I think that there should be an additional method to indicate whether shadow stacks are enabled in the inferior. > And I plan to use the gdbarch method gdbarch_get_shadow_stack_pointer in a future series > for "bt shadow". > I shared the commits in this comment: > https://sourceware.org/pipermail/gdb-patches/2025-February/215178.html, Indeed. I see the same assumption in that code as well. Which makes a lot of sense since it only needs to support x86. But that will need to be adapted when posted upstream. -- Thiago