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=52.101.85.31 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795991420; b=PxFCA4rWHVU4pTdRocxrYY4xloxPUhxWvHKRfiI91AYnBg6bHMI4PrYaT7mwtRkimm3/ kl8RPgmXeOeky8+2T9Ov4kQrM8dTv8aJGIYc0fEsMyNpPagitXfH6dgPRjXVcMTcnyZ2E OlY2GCjRgeL83PN8eCHL25p1nzSPeiOrQ86BrGDlCHY3AfcLQCWHSuVIeT73ycAJwnx3B RvatT16bdgwKriTDzeKkhNXjYD79/Mzn3KEs2nhkdSrBGvQ4GTzrDzfBfDoMne8rFpCup 8C195K8hMjjE7HKcVzHAfp+UKw56ZZK2t1QqUdUmndUp6j8BYdImxtZIV5e2LS83eMw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795991420; 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: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=FgdQvN0cDgw06do/phiNML6eN8FhJwyUWhqsXRTQO+A=; b=XSBNR/6UNi63qG7kbmVhtGmzJpaAC1nze6Vh95LTbnrQDd2420p4KCAlGvzg64DkC9MX 8s+iazh9MwwHVlPQ4ggJciT2ncjClL7kBxu4vBtBK3nAi8xscm/yORvKAI/oP9rHmfLtN h0t94Gt1PuTJoQpTDVRLpARijU8RlctVU3F8OhWflCKSzVfdbCuKjr5c1x6dox2tf6NWI LNBqWcbeSilvAzPQaeDkORoOVUwjv4DztmQSIh/oRLWta8NU4aL7Y7pLLseSD/V4UMCHL IPj7uB1EtqYRKaDA9XGPMMn/GiHwIfAHP8kBelm2mVPksew2KEra+MNCC44XEokbRxA== 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=MnsjsZ7a; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.85.31 Received: from BYAPR05CU005.outbound.protection.outlook.com (mail-westusazon11010031.outbound.protection.outlook.com [52.101.85.31]) (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 79A35606A329 for ; Sun, 29 Nov 2026 22:30:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 79A35606A329 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=MnsjsZ7a ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mm3DSlMXkzy+jhLikmUgTLQsp3h96PtYvdgy7AIMExrle2wIY4J8vIKVehLX/FizRkNUptxarIv/bkoRTfqzct8CUvPLrQghCg4n23SOQXQYotty/CTKEDH7MwD53B93Pn7u2QfB+O8+2RWJ1o/W4dn9A1MxaajTsmVV4n45Lnte2PDuygPqgGKSy/yOW72zAdnqpjBvP9Iem6waVUuFOjWXZDwl6+KLU4HBXfp9FRiK9AELCmGpVGPQzuiTdyiL8HO48027uyOEDMcR5lXwfGCo7j98KNkzM/g0QcA3R1s/vR9yjcZrTMwR9yksjHWUmb0i/QaAOI7DORMIS0eO2A== 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=FgdQvN0cDgw06do/phiNML6eN8FhJwyUWhqsXRTQO+A=; b=Mm8AEP+TE1M8571iAc5L5851WNNZGr02Efq2f54Bn1zWl5wC3GpmfRBxwJLyw/0KN6Owu0wvTweo723EdZsqMAIiAMpCxcvQlQRAdCKwi7B/iFZdkjGXOldV5AhN/B6swCeV7wjfNcFzIu/txfdCeDgEhEHfa1pfQW9QB/BYS/JIxuyrL2Lb5pYqZqivExhzs5ByzgFSza16URyUKPI3mUJt3jtREZXttnZUcN6UvLSjMoEYWtBghioFZ9PY0PI0ml56fqy/AS5o8Pz4oI9uzxxFQGkoKBBlp9XPhiJkGbEUp473Rho3EoE2KKN3FHLrUQuDwr0+LTouIQ6tOklqgQ== 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=FgdQvN0cDgw06do/phiNML6eN8FhJwyUWhqsXRTQO+A=; b=MnsjsZ7a9SGDGxU0sd4QOD6r/hORTdTHB/MI9IjukxeVxwqrRdc9hV0ODD0E1ZHmJty8yJG56c4Qr7um4FvmR/SGcCCd1gucG1m5IlwInFDabdLpNZMe4YgQargRFOyAInyEF9H2KlH+AU43L6Za7leL4L/+CFV9T6MSk1QNnLs= Received: from CH0PR13CA0030.namprd13.prod.outlook.com (2603:10b6:610:b1::35) by IA0PR12MB8350.namprd12.prod.outlook.com (2603:10b6:208:40d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.7; Sun, 29 Nov 2026 22:30:14 +0000 Received: from CH7PEPF0000001C.namprd21.prod.outlook.com (2603:10b6:610:b1:cafe::a1) by CH0PR13CA0030.outlook.office365.com (2603:10b6:610:b1::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.9 via Frontend Transport; Sun, 29 Nov 2026 22:30:14 +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:30:13 +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:30:08 -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 00/27] x86/shstk: More shadow stack enablement and path to IDT support Date: Sun, 29 Nov 2026 22:29:25 +0000 Message-ID: <20261129222953.9124-1-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 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_|IA0PR12MB8350:EE_ X-MS-Office365-Filtering-Correlation-Id: 8ae42538-e02e-4c86-08a6-08df4e6855ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|1800799024|23010399003|7416014|376014|82310400026|10067099003|56012099006|261028144727099003|261022113327099003|261026140227099003|261026121527099003|261022075727099003|261021123027099003|261102123227099003|261022105027099003|261021121427099003|261009223027099003|18002099003|11063799006|6133799003|13003099007|3023799007; X-Microsoft-Antispam-Message-Info: kvDuO41zacqs8AaZAsn5tDDXD/zawEWH+GYG2IXfxUfeh1K/dbjLoxmf4YVYH60ClzSWYEMp1oaSbNn1mloqmY8SWtq83ozHlUkxp+UyrLXDADbPzVRZGNisZmzyhV9WGHZyJ+UsDq6s1nBZPXcSBZzFNU665YjpRDmjJ79ZD0+xFDdCcIIzF0bqZ+CEMkRXuXLQJPesuBUFkJQNmx2BMuVTzPxuZztN2HZj59rheO4t7T5WNf/1SbCzH6NO79LP/k9B3jJ/OZs9857rugUwqL3MNfk2REPN++5DLtYNjQlKB3j2VJXlWCx59bE7FJ22ev0er8G52oSihiTLoCvUOEjeMpsS67xoyFOIRkOKTJDKuIz+OCFmn/hr41onicth5Et9aF753msvaMimSuginGelLu1t72VSQrzSQj8YYry0SGp//Xn/TOxuP2opbuNgg7lLCgIy/2IjOPJTAbPXeTcNgq94QdXkYZDSPTBOOEE0MuPfy71JGMW58zfHWZKfbPRwqK53JqebUimW3uUodhtT3I5UtC7vWxzuIyg0hLfqYQUdWctF9/Js6bhZkNf1LIraccXRcZPCpbhAbiuTU5Bl7WKd4uKz+NxmBlTGW7AbMphCLIGm8QNQamaOy/ce+n5G4E+RlEOeukD9NIBNDtctQ8C+JWxe0eGX1UgldtM= 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)(1800799024)(23010399003)(7416014)(376014)(82310400026)(10067099003)(56012099006)(261028144727099003)(261022113327099003)(261026140227099003)(261026121527099003)(261022075727099003)(261021123027099003)(261102123227099003)(261022105027099003)(261021121427099003)(261009223027099003)(18002099003)(11063799006)(6133799003)(13003099007)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: o5HVt7+s4cZPd8o4tYb45SO7+M33xoQfnCKc0jLlXPSewalgXSfyjPnkPfPCw9iP8QGkjcsz7nEL0Y5q7DbnJMabHcEH1dBtvQFsSlEn+i4hFiyRaiWuUXX4DrRD4yNIjmOlHOUl0pa1sl7V4GixXSgKgmKL/MYJLxhbPLOW4249xK8mtPmfOFHKo4GMzC3Okpfex26IjxiW6cqyHdLah33pKEmLFUTl5cIGUzquHmr5yWY1/vKfRBIFt+TOynKFhr7wHupLXxSMGlCrMd0lbjua0A9HEpanthENeqvMWIcWwv+3z1Ga2hB5mFb9ZwCJMbamyfTYt7fMISKIHt0HQ3Cfw8talBpFJ/nAq+6uXh5OJKZTxcfNBGO4jt55HkQuO0rCjsDt/RTUUbFnSOhUMpFaOuumcLMcokC7c9t6dbs7wSLiZSmg+c6wN6S2VWoU X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2026 22:30:13.4869 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ae42538-e02e-4c86-08a6-08df4e6855ef 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: IA0PR12MB8350 Disclaimer: A large part of my understanding of shadow stack and some parts of this series are from interactions with AI agents. Please forgive any slop. Introduction ============ A query on supervisor shadow stacks brought Dave's series [1] to my attention and getting it to boot on a zEn6 machine revealed a couple early problems. 1. AMD processors supporting FRED don't have SERIALIZE and sync_core() defaults to IRET-to-self which tries to pop a { CS, LIP, SS } frame that doesn't exist on shadow stack. 2. The kernel text patching requires emulating RET and CALL instructions. RET is simple enough and follows similar footsteps as regs_set_return_ip() but emulating CALL is more challenging since, unlike the regular stack that has FRED REDZONE, the shadow stack has no gaps to push a return frame. The code that got to prompt was horrible so over the past couple of weeks I tried to understand shadow stacks better and hopefully have turned the essence of initial slop that booted to prompt into a reviewable series. This is a more principled approach to enabling a bunch of features to work with shadow stacks on FRED enabled systems and beyond. Ugly is reserved for the end. 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. Making IRET-to-self work needs 3 dummy CALLs + 3 WRSS to setup the shadow stack which might be too heavy handed for sync_core(). Enabling shaddow stack at early boot ==================================== The idle tasks are given their own shadow stack and are switched in with restorprevss at early boot just after enabling shadow stacks in S_CET. This avoids complicated handling in context switch path. Note: Enable, disable kernel shadow stack helpers are ugly since they have to be __always_inline so they can be called from spots with a shallow stack to enable shadow stack with a single return entry. start_kernel() and start_secondary() both are noreturn and a shallow call location in their chain is a good point to enable shadow stacks with just a single return slot whose corresponding RET jumps into the noreturn function. 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. Ftrace, Kprobe, Rethooks ======================== Tracing can occur in three context - int3, fentry call, or a fentry trampoline like: caller traced function int3 asm_fred_entrypoint_kernel exec_int3() rethook_hook() caller call traced_function call ftrace_caller call ftrace_handlers rethook_hook() caller call traced_function jmp optprobe_template_entry call probe_handlers rethook_hook() In each of these context, regs->ip modification, and regs->sp[0] changes need to target a specific shadow stack frame to ensure the shadow stack is consistent with the actual redirection. Each context builds a copy of pt_regs and the same metadata frame can be constructed here with the SSP at the time of pt_regs snapshot. The metadata advertises if it came from a FRED entrypoint, ftrace caller, or optprobe. Based on the context, either FRED frame is modified, or corresponding slot on shadows tack is modified to either hijack the return from function, or return from ftrac caller. Note: To keep any exploit surface minimal, the ftrace_.*caller do not correct the shadow stack. The ftrace / kprobe handlers are expected to use the CET aware regs_* helper to steer regs->ip or add a return trampoline. The return trampolines are also made context aware to set regs->ip back to the original caller. Note: This may break a bunch of modules but for everyone's safety, they must adapt. It is easy to sync the shadow stack at ftrace_.*caller but is that the right thing to do? BPF JIT ======= BPF JIT only unwinds the stack (incsspq), skip's ftrace_caller's return from the direct trampoline (incsspq) or can override return with a trampoline (error injection). All three are covered with the addition of context information. BPF JIT only has to emit an incsspq in the unwinder and tasmpoline return. Retpolines, SRSO, CALL Thunks ============================= All three can fix their shadow stack by either doing a WRSS of the correct return address for retpoline, or do an incsspq for SRSO and CALL depth stuffing. Fill RSB loop also uses incsspq to dispose the frames injected by the stuffing. As a consequence, all the thunks are much bigger since registers cannot be clobbered and rdsspq, incsspq both need a register operand. SRSO loses the handle_interrupted_saferet() fixup since it emulates a CALL, LEA, RET sequence and an incsspq between that is complicated thus making those systems slower and unsafe to interrupts during Safe-RET :-( A possible way to solve this is to push a stack canary before pushing additional data to restore and use the canary position + whether regs->ip is past incsspq to emulate the RET while restoring register state and stack. When this started out, I didn't realize we may get to IDT systems so interrupted SRSO is still unhandled in the series. Since shadow stacks can be disabled during offline, suspend, kexec, and during early start_secondary, patched retpoline, SRSO thunk cannot assume wrss / incsspq is available else it will fault. All thunks need to first do a rdsspq to see if shadow stack is enabled or not and then continue which adds to the thunk size. KEXEC, Suspend-Resume, Hibernation ================================== All have to save SSP and disable shadow stack on the way out. On the way back in, read the saved data to enable shadow stacks again and restore the SSP at the same nesting level. All are adapted to fit the existing save restore pattern in their path except KDUMP. Path to IDT =========== At this point, the handling of patching was very modular and just pushing the metadata frame around the pt_regs at IDT entry just worked since the same { CS, LIP, SSP } is pushed for kernel events. There are additional setssbsy, clrssbsy handling to assert the SSP0 token in the syscall path and there is a need for supervisor token at base for INT_SSP_TAB but apart from that, things are simple. Nested NMI is as complicated as stack management and the NMI from kernel has to clear the IST gate 1 shadow stack (which makes SSP0), switch back to the same shadow stack past the hardware populated frames, write two copies (inner and outer) on top and continue. The structure of shadow stack is as follows: +-------------------------------+ | supervisor token | +-------------------------------+ | Original CS | | Original LIP | Hardware overwrites this slot | Original SSP | +-------------------------------+ | Inner CS | | Inner LIP | Copied from first NMI | Inner SSP | +-------------------------------+ | Outer CS | | Outer LIP | For the IRET from first NMI | Outer SSP | +-------------------------------+ A nested NMI will use the same shadow stack, the hardware overxrwrites the lower frames, sees it is nested, and will modify the outer shadow stack frame to make the first NMI return back to repeat_nmi. If there are no nested NMIs, the outer frame is used for IRET which is same as th original frame. This has been tested on a DEBUG_ENTRY kernel with sysrq trigger, kprobe on NMI, and perf record going at it but did not #CP/#GP/#DF do I'm assuming it works. Testing ======= Changes have been tested on a Zen6 (1024 CPUs; FRED), Zen4 (512 CPUs; IDT, SRSO), and a Granite Rapids (256 CPUs; IDT) server with Ftrace selftest, BPF selftest, and NMI stress test on a DEBUG_ENTRY kernel. Credits ======= All the credits for the effort goes to Dave. Without the strong foundations from his series, this iteration would not have been possible. How to apply ============ These patches cleany apply on top of Dave's series from [1] which in turn in applied on top of v7.3-rc6. For convenience a tree is present at: https://github.com/kudureranganath/linux.git x86/shstk_rfc_v1 Tree also contains a reference build config that I have been testing with. Your mileage may vary. References ========== [1] https://lore.kernel.org/all/20261021195120.E61EC737@davehans-spike.ostc.intel.com/ --- Andrew Cooper (1): x86/entry: Parameterize kernel shadow stack handling at FRED entry K Prateek Nayak (26): x86/perf_regs: Rename pt_regs_offset array to prevent build failure x86/cet: Fix build for KERN_SHADOW_STACK and !USER_SHADOW_STACK x86/cet: Make kernel shadow stack #CP fatal instead of livelocking x86/sync_core: Don't use IRET-to-self with kernel shadow stacks x86/process: Initialize and enable kernel shadow stack at boot x86/entry: Handle int3 text patching with kernel shadow stack x86/retpoline: Handle retpolies and thunks with kernel shadow stack x86/ftrace: Prepare ftrace trampolines to handle shadow stack x86/kprobes: Prepare optprobe trampoline to handle shadow stacks x86/rethook: Prepare the rethook trampoline to handle shadow stack x86/cet: Make regs_set_return_ip() helpers context aware x86/cet: Introduce regs_set_return_trampoline() for rethook trampoline x86/ftrace,livepatch: Use CET helpers for ftrace regs->ip and trampoline redirection x86/rethook: Make the trampoline insert and return shadow stack aware x86/error_inject: Use CET helpers to insert just_return_func trampoline x86/kprobes: Use CET helpers in kprobe core to modify regs->ip x86/bpf: Make BPF JIT aware of CET handling x86/shstk: Remove profiling related dependencies for KERN_SHADOW_STACK x86/shstk: Disable kenrel shadow stack when CPU is offlined x86/shstsk: Allow suspend-resume and hibernation with kernel shadow stack x86/shstk: Save and restore shadow stack pointer during kexec x86/idt: Map MCE shadow stack and populate the INT_SPP table x86/process: Initialize shadow stack for IDT systems x86/entry: Prepare IDT entry for shadow stacks x86/syscall: Toggle shadow stack busy on entry and exit from syscall x86/entry: Handle shadow stack on nested NMI arch/x86/Kconfig | 51 ---- arch/x86/entry/calling.h | 99 ++++++++ arch/x86/entry/entry_64.S | 350 ++++++++++++++++++++------ arch/x86/entry/entry_64_compat.S | 10 + arch/x86/entry/entry_64_fred.S | 39 +-- arch/x86/include/asm/alternative.h | 3 +- arch/x86/include/asm/cpu.h | 106 ++++++++ arch/x86/include/asm/cpu_entry_area.h | 2 + arch/x86/include/asm/entry-common.h | 19 +- arch/x86/include/asm/fred.h | 7 - arch/x86/include/asm/ftrace.h | 7 +- arch/x86/include/asm/insn-eval.h | 27 +- arch/x86/include/asm/nospec-branch.h | 82 +++++- arch/x86/include/asm/suspend.h | 2 + arch/x86/include/asm/sync_core.h | 11 + arch/x86/include/asm/text-patching.h | 7 +- arch/x86/include/asm/traps.h | 1 + arch/x86/kernel/Makefile | 3 +- arch/x86/kernel/acpi/wakeup_64.S | 6 + arch/x86/kernel/alternative.c | 4 +- arch/x86/kernel/asm-offsets.c | 3 + arch/x86/kernel/cet.c | 348 +++++++++++++++++++++++-- arch/x86/kernel/cpu/common.c | 2 + arch/x86/kernel/ftrace.c | 20 +- arch/x86/kernel/ftrace_64.S | 121 +++++++-- arch/x86/kernel/idt.c | 30 +++ arch/x86/kernel/kprobes/core.c | 14 +- arch/x86/kernel/kprobes/ftrace.c | 2 + arch/x86/kernel/kprobes/opt.c | 28 ++- arch/x86/kernel/machine_kexec_64.c | 4 + arch/x86/kernel/perf_regs.c | 6 +- arch/x86/kernel/process.c | 68 ++++- arch/x86/kernel/rethook.c | 42 +++- arch/x86/kernel/shstk.c | 8 +- arch/x86/kernel/smpboot.c | 3 + arch/x86/kernel/traps.c | 4 +- arch/x86/kernel/vmlinux.lds.S | 8 + arch/x86/lib/error-inject.c | 2 +- arch/x86/lib/retpoline.S | 92 ++++++- arch/x86/mm/cpu_entry_area.c | 27 ++ arch/x86/mm/pat/set_memory.c | 17 ++ arch/x86/net/bpf_jit_comp.c | 18 +- arch/x86/power/hibernate.c | 2 + arch/x86/power/hibernate_32.c | 16 +- arch/x86/power/hibernate_asm_64.S | 7 + kernel/bpf/helpers.c | 3 +- kernel/trace/fgraph.c | 1 + 47 files changed, 1471 insertions(+), 261 deletions(-) -- 2.43.0