From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id qDozKmSoi2h5AAEAWB0awg (envelope-from ) for ; Thu, 31 Jul 2025 13:31:16 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=T4i8hcuZ; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 92FAA1E102; Thu, 31 Jul 2025 13:31:16 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-10.1 required=5.0 tests=ARC_SIGNED,ARC_VALID, BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 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 509B21E091 for ; Thu, 31 Jul 2025 13:31:14 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C3DEE3858D39 for ; Thu, 31 Jul 2025 17:31:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3DEE3858D39 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=T4i8hcuZ Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by sourceware.org (Postfix) with ESMTPS id 176AB3858D1E for ; Thu, 31 Jul 2025 17:30:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 176AB3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 176AB3858D1E Authentication-Results: server2.sourceware.org; arc=fail smtp.remote-ip=192.198.163.14 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1753983029; cv=fail; b=oub+rZnwDHrukl2hf0StkVw6wwPvLsWv42LWeC0frGnW0X7u6tDZdWYMVNuNilVTH9RPWF2MyC5XrdEEygPirl70FDy1toKMxdTvzC5tJUmIULDgnnXE+6Lxy6+7j+xxjlmZyGxIa4RRbU4JE5UgtYsP6g81oj59u+ekR7otkKA= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1753983029; c=relaxed/simple; bh=FSqbk0lmfO00SiQ9n7nTUBsOTOk0xebbHkvuF2DBzc8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=p9pp8bynncuAJVuY+kx7fUEJtiNYAfj9EkHX4JqL5k8r5ZcvasxvIh0WgSCI9XFufdaLIZdmYtZP9RPncu217/KDx8vrv/7FnO3VwRT/AESUobvuKI90rUGNhnfNx5xPn3k3eJKmN1tpOlLg8B/HV9igQrLQjcqhzGCFy3NARA8= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 176AB3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1753983029; x=1785519029; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=FSqbk0lmfO00SiQ9n7nTUBsOTOk0xebbHkvuF2DBzc8=; b=T4i8hcuZF8B8xFgnUTVmo+HWj1A/4yojyqxduu0lBSOPmqemN/70Dg6N yLKz4LABASKJexWNzJ53Q43BEZ1JwQSq4ao78pABdnQWsLO4Q0q3EDM3n p9E9Ku7ilIBZ35xJEpVQ2qkGjAPSV2nLtRTYsZ+7criGQYb6pTWE3BCPL VxsFygGQc0Yac7zSbkawxFzdZlLH1oxM4COCnq8xotpHVV/88+5FyrMO/ LNH7MLGxHP4JfaezC/zGPach3i5jl+ofCQrSdm74Kmlh2p8B/eBPEe3RH HnsFwW83uteKRVGzK4wQC+WSWMwwYPShb8YyZn/bSWmAdOvVIhg2x5gT/ A==; X-CSE-ConnectionGUID: JepGDoGxQXOcO70jlyNnZA== X-CSE-MsgGUID: yMR35ZorQii5fnn6psC7hg== X-IronPort-AV: E=McAfee;i="6800,10657,11508"; a="56398812" X-IronPort-AV: E=Sophos;i="6.17,254,1747724400"; d="scan'208";a="56398812" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jul 2025 10:30:28 -0700 X-CSE-ConnectionGUID: bI99nuNNRauOxdkyfMtuqA== X-CSE-MsgGUID: /r9vE9W/TVKgNJfVp9ieoA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,254,1747724400"; d="scan'208";a="163332448" Received: from orsmsx903.amr.corp.intel.com ([10.22.229.25]) by orviesa007.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jul 2025 10:30:27 -0700 Received: from ORSMSX903.amr.corp.intel.com (10.22.229.25) by ORSMSX903.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.26; Thu, 31 Jul 2025 10:29:50 -0700 Received: from ORSEDG901.ED.cps.intel.com (10.7.248.11) by ORSMSX903.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.26 via Frontend Transport; Thu, 31 Jul 2025 10:29:50 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (40.107.220.83) by edgegateway.intel.com (134.134.137.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.26; Thu, 31 Jul 2025 10:29:26 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f+cuj2Wm/10z7uuAnkWb/FoWN+jyocxdmATvfK23V7aAbGOohsFRMjHYMIohx3k6W4W5P2+ZIA58tpDWAJ8Qhj027Uq3OFds6bd0BX6GTDJcZ+uB+9u9M36L9BDRIAnzpmSaYHF3K/WwJDTNsuujSLCsH1l8LJTHy7YJjmajVS8yac308jpE9fANztFNDbFXsI7KGcGeqeAitHIhw24Hrue33NLog5air7Ht483wn1LMWoWuGZcVa0y+wpg/ZBlFO329tDpgY+i0Sp6uGv4spK/+3kizbTzWmhMzCQlf3hZZXxwuq+ygghyvBeBGHe1U+H8g40INjo6kBld2XSeFfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RzBMgR76NARGNKBGCzmEL7/RT9xk0fgdQbvhY4GQ7SQ=; b=wIHjBOI9jPnsvL6fieEjizNW//qMIPEjaGLfSMyfy0wiYoFBEgnI0l7ABqVfwxCk6yWj9wYIk+iH8u0vLAhuRKI5Hvp808r2EQ6rEQ9QXhoDLRczK/K7MAI/gBPw4Zj82KhmzT6g1SKHfuWEThAUEl2R2q94QqVmDECYaeJ4ybVstLVz0U8yCip/8U6jSyoP+LyYJwUU0WYcR+mQJuSn37T+gvAZfejCWIpidjVs8ypftyBV5QqjvwGiWv7VCM09BePAPI2PY60VkZfHddNz0Yhe1JN/JkU5Mo0yycaPJTe9/uw8x7a6cCrI6Vu7EX5yfq8JiFTs0G/KmhuohEJVsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SN7PR11MB7638.namprd11.prod.outlook.com (2603:10b6:806:34b::22) by DS7PR11MB7860.namprd11.prod.outlook.com (2603:10b6:8:e9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8989.11; Thu, 31 Jul 2025 17:29:10 +0000 Received: from SN7PR11MB7638.namprd11.prod.outlook.com ([fe80::25b8:16dc:755e:34d1]) by SN7PR11MB7638.namprd11.prod.outlook.com ([fe80::25b8:16dc:755e:34d1%5]) with mapi id 15.20.8964.023; Thu, 31 Jul 2025 17:29:10 +0000 From: "Schimpe, Christina" To: Andrew Burgess , "gdb-patches@sourceware.org" CC: "thiago.bauermann@linaro.org" , "luis.machado@arm.com" Subject: RE: [PATCH v5 12/12] gdb: Enable displaced stepping with shadow stack on amd64 linux. Thread-Topic: [PATCH v5 12/12] gdb: Enable displaced stepping with shadow stack on amd64 linux. Thread-Index: AQHb6AfizSC5ndygakChfuK1GxWB07RK5FuAgAGKQcA= Date: Thu, 31 Jul 2025 17:29:10 +0000 Message-ID: References: <20250628082810.332526-1-christina.schimpe@intel.com> <20250628082810.332526-13-christina.schimpe@intel.com> <874iutdbjg.fsf@redhat.com> In-Reply-To: <874iutdbjg.fsf@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SN7PR11MB7638:EE_|DS7PR11MB7860:EE_ x-ms-office365-filtering-correlation-id: c6a600fb-c544-4834-0aeb-08ddd057c2b2 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|376014|366016|38070700018; x-microsoft-antispam-message-info: =?us-ascii?Q?/Fau30We4UP9K9ZSJ9lbWKUx+s/Wfk/m8Ena1XEktwNHcb+AVTx56PPE9ncC?= =?us-ascii?Q?06fnQFK/O5yf2n9bc21lcdsS27AqEqcLU2HKtNvr8XVO4W0pNz5IpHnBVNCA?= =?us-ascii?Q?L3plYCyB4Bebo+4qeBOXKpbvNrb+0YIPOagUMzUTmWeEzHjqQEtzH5bHKcLG?= =?us-ascii?Q?FvLl1RCGuM6Yd7pRWRnAg/R1BTuaukm/8ukEmVCQHcBQiFvqTtxIg9834X/t?= =?us-ascii?Q?DpmSRnP9rn7oH1U2CUuTPe86mLOLOn1WZ+g90KNyFHyevCBanxV31fI48E/M?= =?us-ascii?Q?BZZxtK/yFgrvxn3zq94NXJraAF63aWLgEN40qc0YtvGdwuetyFaizGXgM3eZ?= =?us-ascii?Q?CdksCtERZrbUbEFNfYj2aoY3NEL31194uJXYIlHwmsxvLS1NDW3dZ4uT8T+d?= =?us-ascii?Q?xckfY/Gcjli44riLVxBVY4WP2aBDxWJZnwZBztIelzcXXIy0X5uibnAMkblS?= =?us-ascii?Q?QWwlsRPo54ax6jVj4O2Sa0JHURps2Zb/CAVT9uMvGRSQUjxkT1yyykAs3jhZ?= =?us-ascii?Q?32hzGGRLD2rBHF00ImW1p0dMPmbaf7RhZU1e0TwlOQ96ZHSfPuqn5kcpD28h?= =?us-ascii?Q?kR7u7xKdknKICq4XgJKTbjZzEYA/kQpsHLPniPooMy6DxJwk85ldp5OJKdfg?= =?us-ascii?Q?CI7lpeXdBwP8BDfDa8wEQxEB6POhkec7/OjC8IfE20DtOKZPDBYOE3+gEhzf?= =?us-ascii?Q?7BqPGiAhdIpUMLk3rZyN0GQaciRMzxg3e3Ni6Lcg0cwokiWbCFpgKKaLo7uF?= =?us-ascii?Q?VZUryz1Qn+gtgHzwm9RU7FZlk/BxbQTQEKb97jTIEHEKeDNUrjiyssgh52Vm?= =?us-ascii?Q?TQzWBGvPOR9AwH6utVy3RGhr40R2bZR+TuTRRJt64G8IRAAsdDdCSgXV1/Ao?= =?us-ascii?Q?MDpLv3t9f8QBkM60b8ovEUHDp5Fupqv9+A6P9NnwJW4WILEI/O0l2fiNJbz4?= =?us-ascii?Q?1A6egT9rMyDKolikAsfwdJjKWGTwexvAgJIHvYhOBe0TL7eDkxMEb9ke3xp8?= =?us-ascii?Q?rI93l1QIbwUyngI5vsSZye1MZk86GO8WU89j5WXJ3NRJ0lAcX5+O3w0gvt6b?= =?us-ascii?Q?+4FxdePmI6pXf5gbOL5bcuWvtn1jMtl0LnNKhx/njRGZC0wB2h2ENOtHpunD?= =?us-ascii?Q?FyvpMObyoNoTd3Bjv2IkK+JB5evPiuz3iPBGrOvrrx1GrfBu6GF0OA9BLvKR?= =?us-ascii?Q?NeJoZ8uinqRZwGjnzEggmZRPJa9m6VNYYHMNz5iAPtF4dt8rUoDsRaOiNCFk?= =?us-ascii?Q?lDgPO8jNd2LKXD3YlGWlPSfJlGy4ZL2jHP3B44VulPOu13EuW1msvre/zaf0?= =?us-ascii?Q?+hdw1obAEILEk8PmwvppaP/Z1NinzQO9h79MQkWJtHTx/cDZAjeEy8XoVJDm?= =?us-ascii?Q?ezQPEBMV+q1rwrM7DxjVtqmAfdTvuYXeoRtkwqzv6vXbnthwDFZrbvD0R5be?= =?us-ascii?Q?jt7lYEPaYWxuKUIQ8zL0FzH7flCLznbtAQoW6OKCqZ2ZAvjLJMjwdHIDinjj?= =?us-ascii?Q?sUwTscl6p7G/2D4=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN7PR11MB7638.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(366016)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?7z4eBZLBPcPHKjC6dSWbT9HLBfxVHL3iZ8zN8SmqHMhusPYN31WIDCiyKjop?= =?us-ascii?Q?Crabd30e2kJWrRYfB3+DhEWj7a2COUTWZtTM9dAzCl8ri97KCugtm9fJOj52?= =?us-ascii?Q?fXQDBe/5+QEwhpaj+JpHfDscNx8vUAeUZE9ZZ9nAnkiL19EERO8osjoGhs9R?= =?us-ascii?Q?vFQoa7R3Y1PQxsIZKw727dn8DjmCEJ9KIMVP6tEj2QUw9RnTrJuWgkHSUnSK?= =?us-ascii?Q?lMKWcfrOLbsDk26Fif5lN0cvRptywv0QxMdHGojniTnRbWSTd2qIr1k8SLOh?= =?us-ascii?Q?N09bvT/jTLuYr3Z9rm3d9ku9AQo4JkjiRHvIf6GgQGC4VGuE3mpeAsFLJ2nI?= =?us-ascii?Q?gV0Jq90O2m71oZCbPQgCeAjlRupNoWc5L1k+FsiUbf1D6/+vrgQX2btTvbf3?= =?us-ascii?Q?+kQ8RCxQ93xaoV2pawBJLj+yXtNPp2SG0TnzIyBXkDN7X1U3uyVlz6NCts4c?= =?us-ascii?Q?Pt8RR9QdQ4fs3i53kgrEn0k/xZ8cKnXQL5Ct0HC1n/ApgIU0tN51NrMeP8+b?= =?us-ascii?Q?9Zmqvp/LpO44ae+WJWhLdsTDL45UlxB1zNCKwB3e8s0Q31WL1b+fhqv0vvjv?= =?us-ascii?Q?gsy1LN7tebeaIdKljNd52yTohL/9iRf2PmgyiGJahKOcLWMyLlbpzn8kByyj?= =?us-ascii?Q?sDPVKrEpLhvrNiv56mRDQklU17yMrhtSDac8Hkee5pBwL4OOje4pqT1JbZAR?= =?us-ascii?Q?1BJQIP2glyvCqgr4XqWjURERBH0Pya+P26onkCwRSerO/fxisNESXxkblDxX?= =?us-ascii?Q?cFxOnKCtpv8WAy+4Q3bj7DU4CD2j5+gBXv6F6hOYe2QBTgLL34lFUiuHZmX6?= =?us-ascii?Q?mccpvupP10Dk2SpYv1ZActGDVUKOT56Tx4KJFcK9X4Y8VVmrDmRHcyP/YpgB?= =?us-ascii?Q?xdiu8eLRLGpJESR+QASPZlTifQQBwmHxWva15/B4R/qJOVZ60zWhZfPdNbEW?= =?us-ascii?Q?UJX6fl55r9o+iTbUujgkTF3rMOiV8pGzwdrUGTPvgAmB2u/cq2MGd/y27t8n?= =?us-ascii?Q?SGvRQ/Ch6ZYiw+bHLfPJ5tLMAj4j2eZnez5OEvwRfoWLK6Aa/jGNzmyeAvzq?= =?us-ascii?Q?RGlgSkx4npcdCos7LSMjO8xeqfTL0LhkOC169+pAN4XEVFzmK4XcKbz+l3kd?= =?us-ascii?Q?uxN1mvnSHxeJKLnfSFz6ZRrt1uHs0D0bp+S+EIvdijN7l21G+KqFgECuyE7t?= =?us-ascii?Q?9FQwaaggVJZiCcc9jaL42Q8rzL2BBMwNANtKR+fz/OlNt111T9q/EQPE9bEw?= =?us-ascii?Q?oRIgD+h6oHBSGxC1eRpne+IEn8g96g1HH8bAfxIYrADhQfOrGV0tcg7gtpMv?= =?us-ascii?Q?EBzKCfeK5Bhcf4m85lk4lEbt63lHdO4tAThKhcQwh8DzU7inSiSkCkFhKY7E?= =?us-ascii?Q?RJyfap8FI0ZMyUwkSa9kx8yBETJ1675k8QSI94pU7ICjh4+TkXFeJN+zOE9c?= =?us-ascii?Q?tz/GAmTQ4jYfzEcVyqcNTvQ/jgQkr1mrsam6xzz5+/uUCgtJHXZU244rmjE8?= =?us-ascii?Q?v18kPXQ6yauPj1mbtiwV71noOgXDtdK5vUFTrURxfX8cU2pmK9FDdziI+vux?= =?us-ascii?Q?limolsQIzrEQIEh4feNAvspBf+o7/NULCAPVk41/Gsag8z8t8i4lM92TloHU?= =?us-ascii?Q?cA=3D=3D?= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN7PR11MB7638.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c6a600fb-c544-4834-0aeb-08ddd057c2b2 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Jul 2025 17:29:10.3440 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: nuRSmJn2N0Zugt9jrJEonvFA+FKc+1AaWVwoMYaptXVTgqIh8Tl8R6K5gQkyuHDrXjgwvUSjO6gJH9EetJMtZUHlD0LyZajfny/KQ1TJ8z8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR11MB7860 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable 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 Hi Andrew, = Thank you for the review. = > -----Original Message----- > From: Andrew Burgess > Sent: Wednesday, July 30, 2025 4:00 PM > To: Schimpe, Christina ; gdb- > patches@sourceware.org > Cc: thiago.bauermann@linaro.org; luis.machado@arm.com > Subject: Re: [PATCH v5 12/12] gdb: Enable displaced stepping with shadow > stack on amd64 linux. > = > Christina Schimpe writes: > = > > Currently, if displaced stepping is active and the single stepped > > instruction is a call instruction, the return address atop the stack > > is the address following the copied instruction. However, to allow > > normal program execution it has to be the address following the > > original instruction. Due to that reason, the return address is > > corrected in amd64_displaced_step_fixup and i386_displaced_step_fixup. > > > > For programs that are shadow-stack enabled we see a control-protection > > exception, as the address on the shadow stack does not match the > > address atop the stack. > > > > Fix this by correcting the shadow stack top address as well. > > > > Reviewed-By: Luis Machado > > Reviewed-By: Eli Zaretskii > > --- > > gdb/NEWS | 3 + > > gdb/amd64-linux-tdep.c | 16 +++- > > gdb/amd64-tdep.c | 15 +++ > > gdb/doc/gdb.texinfo | 11 ++- > > gdb/i386-tdep.c | 15 +++ > > .../gdb.arch/amd64-shadow-stack-disp-step.exp | 92 > > +++++++++++++++++++ > > 6 files changed, 149 insertions(+), 3 deletions(-) create mode > > 100644 gdb/testsuite/gdb.arch/amd64-shadow-stack-disp-step.exp > > > > diff --git a/gdb/NEWS b/gdb/NEWS > > index ba555f0dea1..60510fefea4 100644 > > --- a/gdb/NEWS > > +++ b/gdb/NEWS > > @@ -3,6 +3,9 @@ > > > > *** Changes since GDB 16 > > > > +* Debugging Linux programs that use x86-64 or x86-64 with 32-bit > > +pointer > > + size (X32) Shadow Stacks are now supported. > > + > > * Support for the shadow stack pointer register on x86-64 or x86-64 wi= th > > 32-bit pointer size (X32) GNU/Linux. > > > > diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index > > 899fe2df02c..782b66f1467 100644 > > --- a/gdb/amd64-linux-tdep.c > > +++ b/gdb/amd64-linux-tdep.c > > @@ -1936,8 +1936,10 @@ > amd64_linux_shadow_stack_element_size_aligned (gdbarch *gdbarch) > > possible. */ > > > > static std::optional > > -amd64_linux_get_shadow_stack_pointer (gdbarch *gdbarch, regcache > > *regcache) > > +amd64_linux_get_shadow_stack_pointer (gdbarch *gdbarch, regcache > *regcache, > > + bool &shadow_stack_enabled) > > { > > + shadow_stack_enabled =3D false; > > const i386_gdbarch_tdep *tdep =3D gdbarch_tdep > > (gdbarch); > > > > if (tdep =3D=3D nullptr || tdep->ssp_regnum < 0) @@ -1955,6 +1957,9 = @@ > > amd64_linux_get_shadow_stack_pointer (gdbarch *gdbarch, regcache > *regcache) > > if (ssp =3D=3D 0x0) > > return {}; > > > > + /* In case there is a shadow stack pointer available which is non-nu= ll, > > + the shadow stack feature is enabled. */ shadow_stack_enabled = =3D > > + true; > > return ssp; > > } > > > > @@ -1965,8 +1970,13 @@ static void > > amd64_linux_shadow_stack_push (gdbarch *gdbarch, CORE_ADDR > new_addr, > > regcache *regcache) > > { > > + bool shadow_stack_enabled; > > std::optional ssp > > - =3D amd64_linux_get_shadow_stack_pointer (gdbarch, regcache); > > + =3D amd64_linux_get_shadow_stack_pointer (gdbarch, regcache, > > + shadow_stack_enabled); > > + > > + /* For amd64/Linux, if SSP has a value that means shadow stack is > > + enabled. */ > = > It feels like this statement should be associated with an assert. I'd > suggest: > = > if (!ssp.has_value ()) > return; > else > gdb_assert (shadow_stack_enabled); Agree, will add. > > if (!ssp.has_value ()) > > return; > > > > @@ -2122,6 +2132,8 @@ amd64_linux_init_abi_common(struct > gdbarch_info info, struct gdbarch *gdbarch, > > (gdbarch, amd64_linux_remove_non_address_bits_watchpoint); > > > > set_gdbarch_shadow_stack_push (gdbarch, > > amd64_linux_shadow_stack_push); > > + set_gdbarch_get_shadow_stack_pointer (gdbarch, > > + > amd64_linux_get_shadow_stack_pointer); > > dwarf2_frame_set_init_reg (gdbarch, amd64_init_reg); } > > > > diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index > > 450dbc38047..8afb3a7abba 100644 > > --- a/gdb/amd64-tdep.c > > +++ b/gdb/amd64-tdep.c > > @@ -1917,6 +1917,21 @@ amd64_displaced_step_fixup (struct gdbarch > *gdbarch, > > displaced_debug_printf ("relocated return addr at %s to %s", > > paddress (gdbarch, rsp), > > paddress (gdbarch, retaddr)); > > + > > + /* If shadow stack is enabled, we need to correct the return add= ress > > + on the shadow stack too. */ > > + bool shadow_stack_enabled; > > + std::optional ssp > > + =3D gdbarch_get_shadow_stack_pointer (gdbarch, regs, > > + shadow_stack_enabled); > > + if (ssp.has_value () && shadow_stack_enabled) > = > Given the strengthening of the comment on > gdbarch_get_shadow_stack_pointer that I suggest in the previous patch, I > think this should become: > = > if (shadow_stack_enabled) > { > gdb_assert (ssp.has_value ()); > = > ... etc ... > } Agree, will add. > > + { > > + write_memory_unsigned_integer (*ssp, retaddr_len, byte_order, > > + retaddr); > > + displaced_debug_printf ("relocated shadow stack return addr at %s > " > > + "to %s", paddress (gdbarch, *ssp), > > + paddress (gdbarch, retaddr)); > > + } > > } > > } > > > > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index > > b5120b78426..488816d5ca2 100644 > > --- a/gdb/doc/gdb.texinfo > > +++ b/gdb/doc/gdb.texinfo > > @@ -27059,12 +27059,20 @@ the program stream must be an > @code{ENDBR} > > instruction, otherwise the processor signals a control protection > exception. > > @end itemize > > > > -Impact on Call/Print: > > +Impact on GDB commands: > > +@itemize @bullet > > +@item Call/Print: > > Inferior calls in @value{GDBN} reset the current PC to the beginning > > of the function that is called. No call instruction is executed, but > > the @code{RET} instruction actually is. To avoid a control > > protection exception due to the missing return address on the shadow > > stack, @value{GDBN} pushes the new return address to the shadow stack > and updates the shadow stack pointer. > > +@item Step: > > +With displaced stepping, @value{GDBN} may run an out of line copy of > > +a call instruction. In this case, the wrong return address is pushed > > +to the shadow stack. @value{GDBN} corrects this value to avoid a > > +control protection exception. For more details on displaced stepping,= see > @ref{displaced-stepping}. > > +@end itemize > > > > @node Alpha > > @subsection Alpha > > @@ -41741,6 +41749,7 @@ GLOBAL Disassembler_2 > (Matches current architecture) > > @cindex out-of-line single-stepping > > @item set displaced-stepping > > @itemx show displaced-stepping > > +@anchor{displaced-stepping} > > Control whether or not @value{GDBN} will do @dfn{displaced stepping} > > if the target supports it. Displaced stepping is a way to single-step > > over breakpoints without removing them from the inferior, by executing > > diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index > > 8eb5b4fac86..3b05ace2142 100644 > > --- a/gdb/i386-tdep.c > > +++ b/gdb/i386-tdep.c > > @@ -899,6 +899,21 @@ i386_displaced_step_fixup (struct gdbarch > *gdbarch, > > displaced_debug_printf ("relocated return addr at %s to %s", > > paddress (gdbarch, esp), > > paddress (gdbarch, retaddr)); > > + > > + /* If shadow stack is enabled, we need to correct the return add= ress > > + on the shadow stack too. */ > > + bool shadow_stack_enabled; > > + std::optional ssp > > + =3D gdbarch_get_shadow_stack_pointer (gdbarch, regs, > > + shadow_stack_enabled); > > + if (ssp.has_value () && shadow_stack_enabled) > = > Same comment here as for amd64. Yes, will fix. > > + { > > + write_memory_unsigned_integer (*ssp, retaddr_len, byte_order, > > + retaddr); > > + displaced_debug_printf ("relocated shadow stack return addr at %s > " > > + "to %s", paddress (gdbarch, *ssp), > > + paddress (gdbarch, retaddr)); > > + } > > } > > } > > > > diff --git a/gdb/testsuite/gdb.arch/amd64-shadow-stack-disp-step.exp > > b/gdb/testsuite/gdb.arch/amd64-shadow-stack-disp-step.exp > > new file mode 100644 > > index 00000000000..47bb4df8cfe > > --- /dev/null > > +++ b/gdb/testsuite/gdb.arch/amd64-shadow-stack-disp-step.exp > > @@ -0,0 +1,92 @@ > > +# Copyright 2025 Free Software Foundation, Inc. > > + > > +# This program is free software; you can redistribute it and/or > > +modify # it under the terms of the GNU General Public License as > > +published by # the Free Software Foundation; either version 3 of the > > +License, or # (at your option) any later version. > > +# > > +# This program is distributed in the hope that it will be useful, # > > +but WITHOUT ANY WARRANTY; without even the implied warranty of # > > +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # > GNU > > +General Public License for more details. > > +# > > +# You should have received a copy of the GNU General Public License # > > +along with this program. If not, see . > > + > > +# Test continue from call instructions with shadow stack and > > +displaced # stepping being enabled. > > + > > +require allow_ssp_tests support_displaced_stepping > > + > > +standard_testfile amd64-shadow-stack.c > > + > > +save_vars { ::env(GLIBC_TUNABLES) } { > > + > > + append_environment GLIBC_TUNABLES "glibc.cpu.hwcaps" "SHSTK" > > + > > + if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfil= e} \ > > + additional_flags=3D"-fcf-protection=3Dreturn"] } { > > + return -1 > = > All of the 'return -1' in the global scope should just be 'return'. The > -1 is not checked or used. Yes, will fix. > > + } > > + > > + # Enable displaced stepping. > > + gdb_test_no_output "set displaced-stepping on" > > + gdb_test "show displaced-stepping" ".* displaced stepping .* is on= .*" > > + > > + if { ![runto_main] } { > > + return -1 > > + } > > + > > + # Get the address of the call1 instruction. > = > I think you mean: > = > # Get the address of the call to the call1 function. Yes, thank you. > > + set call1_addr -1 > > + gdb_test_multiple "disassemble main" "" { > > + -re -wrap "($hex) <\\+($decimal)>:\\s*call\\s*0x.*.*" { > > + set call1_addr $expect_out(1,string) > > + pass $gdb_test_name > > + } > > + } > > + > > + if { $call1_addr =3D=3D -1 } { > > + return -1 > > + } > > + > > + # Get the address of the call2 instruction. > = > As above: > = > # Get the address of the call to the call2 function. Will fix. > > + set call2_addr -1 > > + gdb_test_multiple "disassemble call1" "" { > > + -re -wrap "($hex) <\\+($decimal)>:\\s*call\\s*0x.*.*" { > > + set call2_addr $expect_out(1,string) > > + pass $gdb_test_name > > + } > > + } > > + > > + if { $call2_addr =3D=3D -1 } { > > + return -1 > > + } > > + > > + gdb_test "break *$call1_addr" \ > > + "Breakpoint $decimal at $hex.*" \ > > + "break at the address of the call1 instruction" > > + > > + gdb_test "break *$call2_addr" \ > > + "Breakpoint $decimal at $hex.*" \ > > + "break at the address of the call2 instruction" > > + > > + # Depending on instruction generation we might end up in the call > > + # instruction after "runto_main". Only resume until call1 instruc= tion > > + # in case the first instruction we're stopped at is not yet the ca= ll1 > > + # instruction. > = > Could you not just add some filler to the test program to avoid needing to > do this? I don't really object (to this) but using filler might be simpl= er. Indeed, simply adding a nop instruction will fix this: ~~~ /* Depending on instruction generation we might end up in the call instruction of call1 function after "runto_main". Avoid this by adding a nop instruction, to simplify the testing in amd64-shadow-stack-disp-step.exp. */ asm ("nop"); ~~~ Thank you! > > + set stop_addr [get_valueof "/x" "\$pc" "" "value of pc after > runto_main"] > > + if {[eval expr "$stop_addr < $call1_addr"]} { > = > Is the 'eval expr' really needed here? There are plenty of the places in= the > testsuite where we just write something like: > = > if { $stop_addr < $call1_addr } { ... } > = > so I would have expected that to work. I see: ERROR: tcl error sourcing /tmp/gdb.arch/amd64-shadow-stack-disp-step.exp. ERROR: tcl error code TCL LOOKUP COMMAND {0x555555555148 < 0x00005555555551= 4d} ERROR: invalid command name "0x555555555148 < 0x000055555555514d" while executing "::gdb_tcl_unknown {0x555555555148 < 0x000055555555514d}" I think the examples that are available in the testsuite for comparing addr= esses are always inside gdb_assert. The gdb_assert proc then again uses "expr". But I can omit "eval" at least. = Kind Regards, Christina > Thanks, > Andrew > = > > + gdb_test "continue" \ > > + "Breakpoint $decimal, $call1_addr in main ().*" \ > > + "continue until call1 instruction" > > + } > > + gdb_assert {$call1_addr =3D=3D [get_valueof "/x" "\$pc" ""]} > > + > > + # Test continue from breakpoint at call1 and call2 instructions. > > + gdb_test "continue" \ > > + "Breakpoint $decimal, $call2_addr in call1 ().*" \ > > + "continue from call1 instruction" > > + > > + gdb_continue_to_end "continue from call2 instruction" > > +} > > -- > > 2.43.0 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928