From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=40.107.201.11 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795991506; b=am403FuXE7ZH79np+1hhcTPgqENGWkOho8ugHbx68Gdx5AMcLFFCOqXgzOU20zGlMiBa cFakM7Sj75XJQKrZw/2HA5aNyTmZstkBIIwBocbY4Bj32OcX/GGNwe1LcwkUVGoZHwmI7 y/5pl+R0ok4sx22SpqG0zijtJvpFxJPwUTEMw3Jhj34TICXeKXJdJe98DOwLdgfQi7ugX a2Sni6LMAUGLVvbHJAE8wjZ20ggHS57rY3AIbSGpdVnxmGMf0tDjsYk5m1hyh1RDGXJkB oDpdy4Itmwp0uaEa2Uf2ed8Ddj4poYhBWKcdzUrMx7LgoWft8rKFvQmStVvtR8Vr+iA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795991506; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=1meOhLk7NEk5kZJ6LUcCO0MCSh1pwLP29odPV1/VTdE=; b=nhZuR7DUkHhXV/S+ZRotrK8CaKeY23GNTwTR7/puxMIEQu5OvvHIz2B09IwiVgAKh1hd XxXLkNYHxSK7gn6XsAAvzbaO3KSmLITg4UUL3ufBzvRRp2rGVcmB8hmyfZNVqoy4KW5F4 U7/GatwqkCSaWq3j4xlO0VkCmNCVY6s2nbkFGWkYffmjcqR8FW73cDk6QVatUZZx0hJtn gpDOEhjeHqowsfoEFA5KqQ6JitMf9xvbU41Vtv6BJZpCypp3zgpEjs22cl8KGuvHj3xyN 4XNh4IzRzH3lC29tJqLrodHC9ePxSThBI6aDYtE7WvZtEzQSVaqVjjFrfqGFCn9KGoA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=lAAx5tem; arc=pass header.oldest-pass=0 smtp.remote-ip=40.107.201.11 Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11013011.outbound.protection.outlook.com [40.107.201.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 466C5606A31C for ; Sun, 29 Nov 2026 22:31:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 466C5606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=lAAx5tem ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CBKU9/JsqVoqITjOkcVc8JMHXr1fRqJDJlJhgoLpdzwk5Op12l11998bRkXn8Pp/gJkwX5LxX4Jbp/x4bDxVXVTerRD6migTS+OAOEw1r91GaTuqK1v53KPUUFRQ0d0kadkZ0RtpFuk1ik0XR3XzbIyz3SYkTe+RZfYwIxCvU7OFAOVmMolpbdc3ZpzWpOh/k8iNtGmIamOaLszH6bFN2SouUPdyzyYEu/MlF9b03BGUoWc1Ve4DRUiX9YsF+IJfGDL+zOuWj4zeg09l96ptIoBR9M6fhsBYZEJ9jyfD3NBanqqFb5z+XeVgzsNRDyva7N735E7IGf5w2zzjB7fFhw== 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=1meOhLk7NEk5kZJ6LUcCO0MCSh1pwLP29odPV1/VTdE=; b=ypmXv//bCCAF6tXILiJkYBIWotzVQI1gMaymYDBXOeddPcEz4ZZKXmMGisPQgWnkb0sYF/aWZ4uyfgjrXJeHVz2huLwYLo+kfj6QOyA3ankGekXSORL0SN8TCVg+QgoRgG3G54WHZwz2JcufRr9PjGIC6fzNt5u28K4bCkj2CL36vpA5ClDkxoRP70kSnsRlcFsXjUa7Yb8wrJJJyVl47yA6YOq3B2TPvdC79YDtrBExxnKhzzKwZgQjda1dRKQxkhtKSMPcYeMB+uKqjGui7SE6Iry3Bwph5/is7veRSRL4q60wx7943evHKE+tIL5ImIimamV+awhDYa9AbMOWiw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1meOhLk7NEk5kZJ6LUcCO0MCSh1pwLP29odPV1/VTdE=; b=lAAx5temvWB2C37DNW17xCq7V/Y419Jht0UNoIhHGM9HOLCd+SxNQn0Jib/MrxVR4fF3WjEN4FagsSRgO29lJeQ0OYLk0Ho/pPZfN7J+Wb38kIqco20v0GBKeRt29TtOjLg1B3coSRAeecXeaIADI7TS7+eYhchsHdnOIFKz6wI= Received: from DS1P221CA0019.NAMP221.PROD.OUTLOOK.COM (2603:10b6:8:242::18) by SJ0PR12MB7007.namprd12.prod.outlook.com (2603:10b6:a03:486::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.12; Sun, 29 Nov 2026 22:31:41 +0000 Received: from CH7PEPF0000001C.namprd21.prod.outlook.com (2603:10b6:8:242:cafe::ae) by DS1P221CA0019.outlook.office365.com (2603:10b6:8:242::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.662.12 via Frontend Transport; Sun, 29 Nov 2026 22:31:41 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH7PEPF0000001C.mail.protection.outlook.com (10.167.244.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.0 via Frontend Transport; Sun, 29 Nov 2026 22:31:41 +0000 Received: from BLRKPRNAYAK.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Sun, 29 Nov 2026 16:31:36 -0600 From: K Prateek Nayak To: Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , the arch/x86 maintainers , CC: Andy Lutomirski , Peter Zijlstra , Rick Edgecombe , Andrew Cooper , Kees Cook , Pawan Gupta , K Prateek Nayak Subject: [RFC PATCH 05/27] x86/sync_core: Don't use IRET-to-self with kernel shadow stacks Date: Sun, 29 Nov 2026 22:29:30 +0000 Message-ID: <20261129222953.9124-6-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261129222953.9124-1-kprateek.nayak@amd.com> References: <20261129222953.9124-1-kprateek.nayak@amd.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH7PEPF0000001C:EE_|SJ0PR12MB7007:EE_ X-MS-Office365-Filtering-Correlation-Id: e0e533a9-f45a-4f6c-1c55-08df4e688a30 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|7416014|376014|23010399003|82310400026|10067099003|56012099006|261026121527099003|261026140227099003|261022105027099003|261022075727099003|261028144727099003|261021135927099003|261021121427099003|261102123227099003|261009223027099003|18002099003|22082099003|11063799006|3023799007; X-Microsoft-Antispam-Message-Info: IB0DkfXvllZKK11wtReB0h2jWtk/jPQCSpnkbjErGd5wIeQoGyTOB5dqVKUiOdIoRFXP4p+Nfne9gq0WUx1RZAJRxQ3CAkcqWtVSn4fBuCVpIqb1M7Av5T7Cp9Ly4sG7RAY1Pf38Iv8lQ2eDzFAoB9lF9ZjYOV9R/uE/mamEpHK9b5XmdGiuy5YsFW7xX5itbyxyGU3BQnW1B89n5LYLDuPaifaKewBUHddBjoiBQjQekWHL0UhycO+qN1zAs0Up5XOvh+YtbdbZk78EJOxU2KVWWpC5SWV0UlDLnX5Y3PgQa2E3ruRx2Vo9grCziU+3cO5umlG6z7BfvOcjzTRliwbw8HpTz3QrV7EwKMBd3fWipgDf4gXRT/pj0WfxTwmZFuUKAvP4CTgbgjVnS5crHBUe/Ix65fZsTou2E3rNZBdOkgAqcSbKmJZ9xM5EIEmPz9EbNKgEhDQwl802pq9UuZTTZ5EIHqrcDXoGdBi1DGrHJRzYUFsahY16CahItdX7AV23GOxjz20U5jEuedzKgqJg7wWGgue6GHULOH6gbvMpr0x+41hjMX5u8SONwlMQzqvZohuEJ0Hq42OPfXAdUSR5yCg8x+EgzCXWr5oPP0kkts/HhOnfFnfEc5TEFuv7wTlfagcE3J9GqI9s0yzw+d+vVsdULMd4K/a3Ph+PcIvt3y2F5AdbVeim1E7Cl/Fsc8M0ms4rWOBKCnUCG9wjCg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700016)(7416014)(376014)(23010399003)(82310400026)(10067099003)(56012099006)(261026121527099003)(261026140227099003)(261022105027099003)(261022075727099003)(261028144727099003)(261021135927099003)(261021121427099003)(261102123227099003)(261009223027099003)(18002099003)(22082099003)(11063799006)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GhaKY7EiSi1KXM9Y3X5aRhXIuPlDk4t8onBJqaNavtNTN5ZBCXsmx1NKGuqTqMPhsn18+GsIEC9FA+VA9GgVC75jllF5IbUbKeWkH5mPW3pTo7ncV2O/g7xqKCBJAc1mfVFtO2ySUiwdnHkd09VRk75eRvyesBMQbYFemr55pdGzmlZXiIaZeUH0SUyf5YVrysQVDhW24Sqdf1AipCLpSbafLKJMuJcVyAWBDYNx0hzqKyJSgopVryiYHAA6VL0CUL+DFZr1TffRkldCfec2/kW5TwDVA42Qa/S6hu648bFCI25NOtjVqdM3Wiu/Xf0oYDuHyWuPFpfqKCnJSAz3KqhREvw+Et8RcuEuJmwHpiqoIgvLeWcM1JoqKYFtjD6/aJSdQMAA5ZU5Vu0JexxAQskV5r6HL3Q+Kc23dDB9Ynz9l2H+1My8zh9y239NimlP X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2026 22:31:41.1561 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e0e533a9-f45a-4f6c-1c55-08df4e688a30 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH7PEPF0000001C.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7007 On CPUs without SERIALIZE (Zen6), sync_core() serializes with IRET-to-self. With kernel shadow stacks enabled, IRET at CPL0 also pops a {SSP, LIP, CS} frame from the shadow stack and checks it against the RIP and CS it returns to. IRET-to-self only builds the frame on the regular stack, so the IRET raises: Unexpected kernel mode #CP, error_code: far/iret WARNING: arch/x86/kernel/cet.c:42 at exc_control_protection+0xe2/0x3b0 RIP: 0010:do_sync_core+0x24/0x30 smp_call_function_many_cond+0x3e7/0x5f0 smp_text_poke_batch_finish+0x12f/0x590 arch_jump_label_transform_apply+0x1a/0x30 static_key_disable_cpuslocked+0x90/0xa0 LFENCE is not enough for cross-modifying code and making IRET-to-self shadow stack compatible would need three CALLs plus three WRSSs to fake the frame. Use write-to-cr2 as the serializing operation for systems that have X86_FEATURE_KERN_SHSTK but don't support SERIALIZE instruction. Signed-off-by: K Prateek Nayak --- arch/x86/include/asm/sync_core.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/x86/include/asm/sync_core.h b/arch/x86/include/asm/sync_core.h index df22113db9cd..b056444407b5 100644 --- a/arch/x86/include/asm/sync_core.h +++ b/arch/x86/include/asm/sync_core.h @@ -66,6 +66,17 @@ static __always_inline void sync_core(void) return; } + /* + * IRET-to-self fabricates a frame on the regular stack only. With + * supervisor shadow stacks enabled, IRET (and ERETS) also pop and + * verify a {SSP, LIP, CS} frame from the shadow stack, which isn't + * there -> #CP(FAR-RET/IRET). Use MOV-to-CR2 to serialize. + */ + if (cpu_feature_enabled(X86_FEATURE_KERN_SHSTK)) { + native_write_cr2(native_read_cr2()); + return; + } + /* * For all other processors, there are quite a few ways to do this. * IRET-to-self is nice because it works on every CPU, at any CPL -- 2.43.0