Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.201.67 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796007048; b=PYZ6NfEA2TEhjUNQLeCmuheyHJZB1b/sAO//vgBerMkRKmx8ea5WPkXGlO32QSd9M3Wg NCoE1cJnQmznZroZw19+Qve2oL/5qm+i+T1yDadLHgnyxN2wi3hC9eZcOBAX90hHbTV+V HKDkZnCSVbmUQbHs7MHkfciZOrX5PIerCxOuI+vpk/u2ZdtDxw/5CMmeDydti/tTTn3Ca NcSfnCeelAEmOHqLaBlK94Kz3otLC+24idSPjELOFrDqxbAr6ZBlEtkWX6yMMpm8yJeQR +2Su72BvtEJ0qgv5Yos4jDPwxOkkEJuWql9hI35B0j85DUQxfq9nQ9Jaqbd1uZlVPEQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796007048; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: Received:Message-ID:Date:MIME-Version:User-Agent:Subject:To:CC: References:Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding: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=hWqkjxMulHZs2Q5dUsT8S+nrg02ifegMZXCEDweUSJc=; b=XI/FycUwF/Ho7xX1KznAQMEDBNXBzx0jwOFXSXdr+DWTj8p9bSgpUHeQ4mu61UTADLnt si5Nejt7hvNaNnCnV13ywe6Siqn+FSf2zvGa0CqdvKZz/79+ovhOSSSGXoMtBTRlbDP67 UPNLbSbwPj2dKbWoDrfDBTib61CUK1RGAOBtl6IX4tAL54oBD8ZvfS2NVDBe0Ue0gjEm8 unRhFQCe/9kjW50VAHdmI0Ai5wG/p1y1UglvJIL96hMOG2dv+inOkkht7ULOkO2dTDvM8 El87XDOAOTyPNMD830ZK9WkJPnX0gcH2XLDD8WywhFlxVs9hy8ZvOhmG6Mfn6ac3yNw== 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=EqD62Y5J; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.201.67 Received: from CY3PR05CU001.outbound.protection.outlook.com (mail-westcentralusazon11013067.outbound.protection.outlook.com [40.93.201.67]) (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 EC6FE606A31D for ; Mon, 30 Nov 2026 02:50:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EC6FE606A31D 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=EqD62Y5J ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z0eKJEP+pYtLI/wpois3lzrU5ocHL7v3casgCEyu6a1uA+A4F4/kelA07T34vKhUoUwEZU5S+gGLhr9EJgNK2bXCSi6fKX4lA3LZ2LxxzUuLtjMXchzemeX53oLZwhrHSeJPMXzORY+IJ5VVyuhIrIodo6Imq/SK31WjiDzd6TzYrFZx+HcxNbo4mG8WhSZOq1JnqpH6yTxH1NlM3B0wFLoqC9rj9p5A2MWSJ8BBaWosY4+5Ph5Rfz/RZcgB4t7jTn6Z05yBjar4VmVcsVt71AZFtZ8nB8fsYUtYmc4BBN0Ug8Yxe9D7qurIqK4WiI7hSEy4Q0b2UP9OqlfDHDW99w== 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=hWqkjxMulHZs2Q5dUsT8S+nrg02ifegMZXCEDweUSJc=; b=M+uz4Nmpn6hh2T9nVmmf6jJJA9aPaWYILJNFU0uCzhkY+8AnueMBrxPTcwo8xQyn5cHoB8+mKyF5AetBEcPRaZQ6yO0z+0MCFiP/VvednHbbMothCz+RhLmRnbGcSfhcZNujbGMw4RBmmRWT7NDFMsjp2j5lD+7OxSMRVOMDPAwLY8UwpBN5On71g3DuZFlHOVMr0OkCs09vhlyh7E6IHaEXEVw5+eZTZHzXyBosL27ytkFeV7jb57ud+5Ukq4fHl+xk8VVQcKGIq6BtoggtpEBWBsxuao67BkgKh0ViHh+veEpNd6nhG6HQyR9EmfABpNJ37Nu3nhuvncneTc8oYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=citrix.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=hWqkjxMulHZs2Q5dUsT8S+nrg02ifegMZXCEDweUSJc=; b=EqD62Y5JHYHr3sb70GHbUSxWKxR7qL9ryJTo8bsR9mWKqOpHV/7ZR0H3zYTl4FqZTJnGWYM4/BsPQUtARMtF/mdaTccf9ZDhlDkERZfmXCPLWUyAfiwPESGmmoGD99F1u7wq5CDDhz0WGOuMhAp1Y/C45IEjbxqWPrPKroC2Dmw= Received: from BY3PR05CA0009.namprd05.prod.outlook.com (2603:10b6:a03:254::14) by EAYPR12MB999157.namprd12.prod.outlook.com (2603:10b6:303:2bf::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.639.14; Mon, 30 Nov 2026 02:50:43 +0000 Received: from EA8PEPF00000008.namprd05.prod.outlook.com (2603:10b6:a03:254:cafe::7b) by BY3PR05CA0009.outlook.office365.com (2603:10b6:a03:254::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.9 via Frontend Transport; Mon, 30 Nov 2026 02:50:43 +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 EA8PEPF00000008.mail.protection.outlook.com (10.167.249.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Mon, 30 Nov 2026 02:50:42 +0000 Received: from satlexmb08.amd.com (10.181.42.217) 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 20:50:42 -0600 Received: from [10.136.42.27] (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.57 via Frontend Transport; Sun, 29 Nov 2026 20:50:39 -0600 Message-ID: <9858d06e-d2e8-461f-a124-244eb991eaaf@amd.com> Date: Mon, 30 Nov 2026 08:20:33 +0530 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 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 00/27] x86/shstk: More shadow stack enablement and path to IDT support To: Andrew Cooper , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , the arch/x86 maintainers , CC: Andy Lutomirski , Peter Zijlstra , Rick Edgecombe , Kees Cook , Pawan Gupta References: <20261129222953.9124-1-kprateek.nayak@amd.com> Content-Language: en-US From: K Prateek Nayak In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: EA8PEPF00000008:EE_|EAYPR12MB999157:EE_ X-MS-Office365-Filtering-Correlation-Id: 9272e148-6f94-4ab0-2b6d-08df4e8cb9d6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|23010399003|82310400026|376014|7416014|1800799024|261028144727099003|261022075727099003|261022105027099003|261102123227099003|261026121527099003|261026140227099003|11063799006|10067099003|4143699003|261021121427099003|56012099006|261021123027099003|22082099003|18002099003|261009223027099003; X-Microsoft-Antispam-Message-Info: ZgYRjvdMCtVOB7TngtC8VM3K0/cTyQ+/roXDgJpKk4MEVLlnwgaE0GCJrFwHqETSD6tj7DkmDnPnsccjTLpJzA4GYjssqa8AMnmI/AXm7as1yIJhIwIpNv9W5z3rODKgnbiU3qb7H9g1OlV1ESDhj/Sp50wHcTLQQ/7SkJyIXI5RdGzPic8JeXl3M0DiEVCtH3AU2Vq7I4QFOYaYMI0kAoyTDGKqlpgt6hRaJ4xNiipMp8s7gCkidOPAl0rdjOAXpHYeQbI6jV3SW246htRb+Q3O6RQQW5R8caDZizTCul4BTCNDgTrUkKsWVX5XAxQSQR034hoJzfuKxsYw6HDzED/4/VccRORvcYeECrdOce0NmAyuFnstJ0CNnXUNUMfS5l1YG+XU0EHTVqtk1IxOrBFUWG2xtj1KTGJBiVUO1dB+TX04empPozUeG/7TkCC6tHGHgFmli0OQLkC1p69O+Q/N/9zUTKSP3yYT8SWUxYSwQGYGqLFoAK7gWmV8tjZm5e3jSfU5lxSyPjLdXe74c02zwKoPFv5IM4+WVM8Tgu9d6dmbybRfklCv38atDMm8uuQ5eUGM9AMtkFNREZHtzbmxuo9VQRJMS/lnVd6wZ7sOYpiQ6NCNi8arKH93x0KWEjZsEn/LbAwFsVFbHA0N8HEAtdMze0sZDXcTiWog7gRO+XPVqGrrPhRNBdGbJHeL7TdKzck6HDJfQ+O99HtDNw== 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)(36860700016)(23010399003)(82310400026)(376014)(7416014)(1800799024)(261028144727099003)(261022075727099003)(261022105027099003)(261102123227099003)(261026121527099003)(261026140227099003)(11063799006)(10067099003)(4143699003)(261021121427099003)(56012099006)(261021123027099003)(22082099003)(18002099003)(261009223027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: k2EBCndD65v0pQgkLyWkzMrX4yxuIASIBSS+fhayuf/Bkn6+iDyyq3o7C6dX/2StrwrSd0mT+Bj4y+2Mynbyx5zfDOTOsusoATYZjZxhVPY61chmAU1YBdjQwLKq7urqjrOODnT8p0G+21tPoC6O7UJi3TlpmGgWNQXnGUFApeWp5OtKreVgeiHGVy82RDJCTK4XRARa6qWSqY2A+V1GrH+WPPldVx/uiYP6TonpozDuYLWf42gA4lQ92kxTOL2sc4k6Y0jpdG6vI/Od+F9Sg3Lv+ABLp2E09qs/8wqQlK3CclLL1qOKGbv1JtGRTHSnSEMPXHy4NoI0wMsrR5rLqp/lw1vx7jVEsEupRS5LRkoIFhp1aroZFbNdox/SfOi45masqiwoKr74ztEjneH9PDZsiiT2GaTjtAWueCMDpTRk0vd1hukcAC4Q+L4wIEyy X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2026 02:50:42.8765 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9272e148-6f94-4ab0-2b6d-08df4e8cb9d6 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: EA8PEPF00000008.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: EAYPR12MB999157 Hello Andrew, On 11/30/2026 4:30 AM, Andrew Cooper wrote: > On 29/11/2026 10:29 pm, K Prateek Nayak wrote: >> Write-to-CR2 for serialization >> ============================== >> >> CPUs that don't have SERIALIZE and have X86_FEATURE_KERN_SHSTK will >> default to using write-to-CR2 as serializing step. write-to-CR2 is >> available widely and although the comment in sync_core() suggests XEN >> may have some issues here, CONFIG_X86_KERE_SHADOW_STACK cannot be >> compiled with XEN yet so we'll consider write-to-CR2 as a temporary >> measure. > > There is no legitimate dependency CONFIG_X86_KERNEL_SHADOW_STACK and > XEN; it's bogus and needs dropping. > > Xen PV guests will never see CET (SS or IBT) and never enter the > CONFIG_X86_KERNEL_SHADOW_STACK paths. Xen HVM guests will, and they > will work as per native, just like KVM guests/etc. Ack! Thank you for clarifying. I only thought they won't see FRED but now that I look at your comment on Deve's thread, I see you mention CET_SS as a whole. Sorry for getting that mixed up. > The change you've made in sync core is fine. IRET is used because for > both XenPV and for UML, it will serialise without trapping; it's a > performance concern only. Ack! And since you say CET_SS will not be visible, the guests will continue to user the IRET-to-self path and there should be no concern. > >> CALL emulation >> ============== >> >> Call emulation requires a RET frame to be inserted below the FRED entry >> frame. FRED frame is a { CS, LIP, SSP } pushed onto the shadow stack. >> >> To make our lives easy, we push a corresponding metadata frame onto the >> regula stack on top of pt_regs to make the following container: >> >> struct { >> u64 metadata; /* Context */ >> u64 ssp; /* SSP at FRED_ENTRY */ >> pt_rega *regs; >> } >> >> For CALL emulation, regs_emulate_call() helper will use the SSP from >> this context to overwrite the CS in the FRED frame with the return IP. >> The original CS and LIP are moved one slot up to make: >> >> ... ... >> +-----+ +-----+ >> | CS | | RET | >> | LIP | -> +-----+ >> | SSP | | CS | >> +-----+ | LIP | <- Jump to CALL site >> +-----+ <- Top of stack >> >> Text patching events always occur at same FRED level and SSP always >> points to address 3 slots down. regs_emulate_call() will then notify >> FRED_EXIT of the patching by setting a flag in the metadata. >> >> FRED_EXIT will see this flag and do a dummy call, fixup stack, and >> overwrite the top of shadow stack with a SSP of three slots down to >> complete the FRED frame which matches for ERETS. After an ERETS, the >> fist RET will mismatch but rest of the RETs are balanced in RSB. >> >> This is also the same method of doing a direct call via ORIG_RAX in >> ftrace_regs_caller and has been adopted here. > > MSR_FRED_CONFIG.SSP (bit 3) exists exclusively for this purpose. > > There was a reasonable amount of spirited debate required to get that > into the FRED spec. It would be a shame not to use it. Ooo! That should do well too and save a few WRSS for CALL handling on the FRED path. -- Thanks and Regards, Prateek