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.200.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795991910; b=eWMPSyfSbF/ZgdXj/bFH9YYuV9Uatxec28tIzPz7YHfSBXyI+YEZYP3BIz4+GiTUokK5 5vqnF3B13a4MdLYtfMEGKNJg7U19R2JvNcZ4bgTaoCWUIZBsIlEsXry32xSbppzR6P/wP 3ydQafSmPVz10ZMq/EByXLWcN2zTjiLgVypCOVFIxBAxSziPgc+pMi3bs+8bnGq30y/eb T4xcEPK57qS2bnHYuA6JInuyJOgHi/9DsyD9phAUqLUu7wGw0zE0BpV+F0OtMGoCwcWFL HB/nQzgVNJy8wOHVq+OslmXWWsTJ1DT3YcMaWtwHvlH/vFVDIPYUV5B6keFteOCYV0w== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795991910; 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=wQPSiXmfseJPuPdnEa8jHkN7Qr/rwHBZoyw8gofwclg=; b=kQm+q2GhI9wbIb+KH0oZ20dC0KLJp+GleQmpp87MA75L+Y/QtXKMHq/+7MqZqF8ytdpB iIlHzlRCHAeSPSA4Bn+VXtmFT9ocZB23lazEnz/de6fCkJhUmzJ2INOjJqdcG3QZTqkqy 45uYwgrlCq9HYpvqQ3AzBz9ill/VhuG7o1XS0RXjQ0NFymUDhE+vyu9oCrvIJ2BruOmTj MvLcvI5tg/uMSXxdEYcHByC98/x19c9M8m9GpGFvrq/lqXWFK2udDlv2/i8ClCGkWFIPB ndzQUbCY8P7Tl4+h0tLMgZ75O8I0NAHpZqSvZ8Ev8kKAnf/mHI0x5Kh2bpDxe0OteLw== 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=fBRaKMqT; arc=pass header.oldest-pass=0 smtp.remote-ip=40.107.200.18 Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazon11012018.outbound.protection.outlook.com [40.107.200.18]) (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 675C5606A31C for ; Sun, 29 Nov 2026 22:38:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 675C5606A31C 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=fBRaKMqT ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dD/XpTkCF3vBFyFMTXIdP9wlQrvl1ILcb6MaOtTQxr2sKKTvfKsS/+xLQgnUqORlxSbcm5q0cLUlybqWnK3eCYvUAgU0n6NNpJpyW1AA/m28Q8sg86U27wejUhQ9GpmU7SeoNA9SZgFt387hnCIGm73SO7cMhHS4lB9Bw7vHleJZ5S0MiBN5E6indICm6WbbZKuvlUrBhlbuRrW0Vr3HEeAPJNoFiyF+T10RL9SYLACbrIrphE0r1LDC1tjbWeGsxU4afK5vrDEh1e/DXon/Eye8HX3pbvNzVnXVgib3u/J89ibvBHZRcGYecj6ptJKjAamkKDyNgz05/t0sAOe9EA== 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=wQPSiXmfseJPuPdnEa8jHkN7Qr/rwHBZoyw8gofwclg=; b=y9++jIRFDfXxP4fGXbY+cpNxV18EkmlBDCaToXz17R95FNhYxCBkBv01XYJwDXIRKx8XAwiXO6PkUnUaYkQLLnWRHfpmhnVmYnAXF/vaUbrtvOIHwpS7et18+wU8MSkKjJaI0G0R10fPs8xwLlnbTbUbfjxOBtnRyEPC6keuVDUqO8keSe6UizBTHNnGC/oKMoxU0yBcJ90KQFOV0zFY+g6kYxbvQjU32PHqiElAIhbj3glHpYeUbV1MEZMMS8wxwPv5w9qyo9AY+nR/WBLqkhWz1+GJ3QZbp5e3sM4UdzwMznMjc52zCCCMddYIdrEcuLZ9ZiXYXw85VI8lK+jBMA== 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=wQPSiXmfseJPuPdnEa8jHkN7Qr/rwHBZoyw8gofwclg=; b=fBRaKMqT3Wz1pL7CnUZUxsDo9GgZAqAXfyJmeSQUngd0XWclh56QfB2AUQyA1dEH8ncvjKSVP/Vff38W85bHUPem+mQnAdvD4SxIXvGEfblsoProq2nAyRL3M+xd8rF0neufQgqAYjZdl2nh9zmyEl9w05pMw08tMzONzKvF5cQ= Received: from CY5PR14CA0011.namprd14.prod.outlook.com (2603:10b6:930:2::20) by PH7PR12MB9076.namprd12.prod.outlook.com (2603:10b6:510:2f6::21) 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:36:22 +0000 Received: from CY7PEPF000000F7.namprd05.prod.outlook.com (2603:10b6:930:2:cafe::a5) by CY5PR14CA0011.outlook.office365.com (2603:10b6:930:2::20) 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:36:22 +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 CY7PEPF000000F7.mail.protection.outlook.com (10.167.247.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Sun, 29 Nov 2026 22:36:21 +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:36:17 -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 21/27] x86/shstsk: Allow suspend-resume and hibernation with kernel shadow stack Date: Sun, 29 Nov 2026 22:29:46 +0000 Message-ID: <20261129222953.9124-22-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: CY7PEPF000000F7:EE_|PH7PR12MB9076:EE_ X-MS-Office365-Filtering-Correlation-Id: 01109cd4-5263-4826-f0ed-08df4e693182 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|23010399003|1800799024|82310400026|7416014|376014|10067099003|56012099006|260925022911599003|260925021911599003|260925021311599003|261026121527099003|261022115727099003|261021123027099003|261021121427099003|261022113327099003|261022075727099003|261102123227099003|261009223027099003|18002099003|22082099003|5023799004|11063799006|6133799003; X-Microsoft-Antispam-Message-Info: ZM8ySq+oJ5dpPdmP4/CGqHqzF3ZZQ1kc+BVH2xGi40BRnoW/QNHPU6wAf0Hv7nWiM09RWh4BZgVizBvBAp8d6DgoDgC/jY2HTs/EoB1XhKZzknEzeo5rwla5M7MOjDtkjTUW9hywh5hm9dqgGCOJPjF0FXuD3HJbKIxxWq1Ase/HvonAmQB8t/eY/C6j4OZJA5008XfyWg5luVrJ9/mfxoqIpnsWjdgD9GoglxQ8TE2j4wA3Ur60U/c1VAzoLuu+8FvRVKiDncilfsOPr92+oMbmWy0CwB16Ws4ffZQ3i3+qEC09sD4ZIEqcr5i97V2B+ojhkREpAUt/yloAHAEdoq+ybVNOmigrkS4YLDHOpfYo8MjUqf2Pp1Qa6Ghz8MLkHehDIVlhzH3o5f/SY2zjp+tjoWe3JivZnHUol/YrWTcV1YNjquqiBKfF9amOF5GawB2fjGUNDTRPkgUA7u5yeObWQWAUAAc1Wjv+4FTh7j1KxUMH7PeCifrPnLUV+OPnLvFH3yBnTsNdEQIjJuYbc57IhIaXtdfZTenwQg9WqFQmgUSHsi8WBP1F16pgB9RE6XZv5SrOe8rNbb0c2ZRB4qaBLPV4d48QW0Vaousl2z5H5BP/vwUzinEhrkmUD4RS5wjGu38IE6qIxx1RzjHxBnsVOWfFI5yF7deSYahc8t3/AKb5wttDz/aGJCnjElam4zpCwfQpwpAQaPAxSMEWvg== 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)(1800799024)(82310400026)(7416014)(376014)(10067099003)(56012099006)(260925022911599003)(260925021911599003)(260925021311599003)(261026121527099003)(261022115727099003)(261021123027099003)(261021121427099003)(261022113327099003)(261022075727099003)(261102123227099003)(261009223027099003)(18002099003)(22082099003)(5023799004)(11063799006)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zguGmOB6JzziTldet0AU464GdDCDCAwxGxwWcFM+9zH+sE5pxKkqzLh5qizFzQW3yqmx1RnKZHwzo+1Evtvxy0DFd0VHah0Sspc5LB3kbA1AXK7kLFontwgYVq6NaLOoMeqehsFbw4FzCT1KfpYhfJQ5alC52/v9Y8CEuvlgqDw2+qn7UOUU4I0oQChwjdSMbqSd4gnykv/ZBpoIQeSaCoFQdA61Q7aiiWM15WredkmnF8/rBL6bGrx8qW94uiPr38UqiP2HhI3JcLrKAPeT6mynRekyspA/vsyFjz6j7KwocOyHnQd7F7a/mcwtGvbT2P/5kDx2Gr0W0TYkfLeyaysGdzOL5LqPxh1vTZsSnnEoG4d8HRiE8VKH9rt/igCyk7e2P1DGb+yhy7gYY50zlaY0TpwjKjPINfeBqn/+68bNQkewbiWN6zCqNPDGgxn7 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2026 22:36:21.8467 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 01109cd4-5263-4826-f0ed-08df4e693182 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: CY7PEPF000000F7.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9076 Save and restore the shadow stack pointers from the CPUs driving the suspend-resume / hibernation while disabling kernel shadow stack just before the system is suspended. Since APs are taken down, they would have disabled shadow stack before hitting the idle routine and only the BSP (CPU doing the final bits of suspend-resume) needs to cache its SSP with restore token, disable kernel shadow stack and execute the suspend routine. The caches SSP is restored on resume such that it finds the matching ret on the way out. For hibernation, the CPU restoring the image disables shadow stacks, and the restored kernel then enables and restores the SSP it had cached before the hibernation. Tested with: rtcwake -m mem -s 20 rtcwake -m freeze -s 30 rtcwake -m disk -s 100 Signed-off-by: K Prateek Nayak --- arch/x86/Kconfig | 7 ---- arch/x86/include/asm/nospec-branch.h | 55 ++++++++++++++++++++++++++++ arch/x86/include/asm/suspend.h | 2 + arch/x86/kernel/acpi/wakeup_64.S | 6 +++ arch/x86/power/hibernate.c | 2 + arch/x86/power/hibernate_32.c | 16 +++++--- arch/x86/power/hibernate_asm_64.S | 7 ++++ 7 files changed, 83 insertions(+), 12 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 21f2b41043f4..4f5097fdd365 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1911,13 +1911,6 @@ config X86_KERN_SHADOW_STACK # and uses "pushq $0 ... ret" as the handoff into purgatory. It # needs S_CET.SH_STK_EN cleared first, which nothing does yet. depends on !KEXEC_CORE - # restore_registers() RETs on a stack reloaded from the image - # with S_CET, the PLx/FRED_SSPx MSRs and SSP itself never saved or - # restored. Same problem for do_suspend_lowlevel()/wakeup_long64(), - # which resume with "jmp *%rax" into the middle of the function - # and then RET. - depends on !HIBERNATION - depends on !SUSPEND # __efi64_thunk() drops into 32-bit firmware with LRETQ and comes # back with LRET. Far returns are shadow stack checked and expect # a far CALL frame that was never pushed. diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h index 0872dceb3819..ff9449921106 100644 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -417,6 +417,61 @@ #define CLEAR_BRANCH_HISTORY_VMEXIT #endif +#ifdef CONFIG_X86_KERN_SHADOW_STACK + +.macro SUSPEND_KERNEL_SHSTK ssp_offset cet_offset + xorl %eax, %eax + rdsspq %rax + movq %rax, \ssp_offset(%rip) + testq %rax, %rax + jz .Lsusp_no_shstk\@ + + /* Write the restore token = saved_ssp | MODE64 */ + leaq 1(%rax), %rcx + wrssq %rcx, -8(%rax) + + /* Disable Shadow Stack */ + movl $MSR_IA32_S_CET, %ecx + rdmsr + movl %eax, \cet_offset(%rip) + movl %edx, \cet_offset+4(%rip) + andl $~(CET_SHSTK_EN | CET_WRSS_EN), %eax + wrmsr +.Lsusp_no_shstk\@: +.endm + +/* + * Call at .Lresume_point after CR4/CR3/CR0 and the GPRs are restored, + * before jmp restore_processor_state. Clobbers rax, rcx, rdx and flags. + */ +.macro RESUME_KERNEL_SHSTK ssp_offset cet_offset + cmpq $0, \ssp_offset(%rip) + je .Lres_no_shstk\@ + + movl $MSR_IA32_S_CET, %ecx + movl \cet_offset(%rip), %eax + movl \cet_offset+4(%rip), %edx + wrmsr + + movq \ssp_offset(%rip), %rax + + /* Consume and drop the token. */ + rstorssp -8(%rax) + movl $1, %ecx + incsspq %rcx +.Lres_no_shstk\@: +.endm + +#else /* !CONFIG_X86_KERN_SHADOW_STACK */ + +.macro SUSPEND_KERNEL_SHSTK ssp_offset cet_offset +.endm +.macro RESUME_KERNEL_SHSTK ssp_offset cet_offset +.endm + +#endif /* CONFIG_X86_KERN_SHADOW_STACK */ + + #else /* __ASSEMBLER__ */ #define ITS_THUNK_SIZE 64 diff --git a/arch/x86/include/asm/suspend.h b/arch/x86/include/asm/suspend.h index a892494ca5e4..7ea62a6624a0 100644 --- a/arch/x86/include/asm/suspend.h +++ b/arch/x86/include/asm/suspend.h @@ -9,6 +9,8 @@ extern unsigned long jump_address_phys; extern unsigned long restore_cr3 __visible; extern unsigned long temp_pgt __visible; extern unsigned long relocated_restore_code __visible; +extern unsigned long restore_ssp __visible; +extern unsigned long restore_s_cet __visible; extern int relocate_restore_code(void); /* Defined in hibernate_asm_32/64.S */ extern asmlinkage __visible int restore_image(void); diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S index 04f561f75e99..dc4ba38c4e40 100644 --- a/arch/x86/kernel/acpi/wakeup_64.S +++ b/arch/x86/kernel/acpi/wakeup_64.S @@ -79,6 +79,8 @@ SYM_FUNC_START(do_suspend_lowlevel) movq %rdi, saved_rdi(%rip) movq %rsi, saved_rsi(%rip) + SUSPEND_KERNEL_SHSTK saved_ssp, saved_s_cet + addq $8, %rsp movl $3, %edi xorl %eax, %eax @@ -126,6 +128,8 @@ SYM_FUNC_START(do_suspend_lowlevel) call kasan_unpoison_task_stack_below #endif + RESUME_KERNEL_SHSTK saved_ssp, saved_s_cet + xorl %eax, %eax addq $8, %rsp FRAME_END @@ -141,5 +145,7 @@ saved_rbx: .quad 0 saved_rip: .quad 0 saved_rsp: .quad 0 +saved_ssp: .quad 0 +saved_s_cet: .quad 0 SYM_DATA(saved_magic, .quad 0) diff --git a/arch/x86/power/hibernate.c b/arch/x86/power/hibernate.c index a2294c1649f6..940f8c6bfebc 100644 --- a/arch/x86/power/hibernate.c +++ b/arch/x86/power/hibernate.c @@ -39,6 +39,8 @@ unsigned long jump_address_phys; unsigned long restore_cr3 __visible; unsigned long temp_pgt __visible; unsigned long relocated_restore_code __visible; +unsigned long restore_ssp __visible; +unsigned long restore_s_cet __visible; /** * pfn_is_nosave - check if given pfn is in the 'nosave' section diff --git a/arch/x86/power/hibernate_32.c b/arch/x86/power/hibernate_32.c index 223d5bca29b8..0b5498585c25 100644 --- a/arch/x86/power/hibernate_32.c +++ b/arch/x86/power/hibernate_32.c @@ -170,29 +170,35 @@ static int set_up_temporary_text_mapping(pgd_t *pgd_base) asmlinkage int swsusp_arch_resume(void) { + unsigned long ssp = disable_kernel_shstk(); int error; resume_pg_dir = (pgd_t *)get_safe_page(GFP_ATOMIC); - if (!resume_pg_dir) - return -ENOMEM; + if (!resume_pg_dir) { + error = -ENOMEM; + goto out_error; + } resume_init_first_level_page_table(resume_pg_dir); error = set_up_temporary_text_mapping(resume_pg_dir); if (error) - return error; + goto out_error; error = resume_physical_mapping_init(resume_pg_dir); if (error) - return error; + goto out_error; temp_pgt = __pa(resume_pg_dir); error = relocate_restore_code(); if (error) - return error; + goto out_error; /* We have got enough memory and from now on we cannot recover */ restore_image(); return 0; +out_error: + disable_kernel_shstk(ssp); + return err; } diff --git a/arch/x86/power/hibernate_asm_64.S b/arch/x86/power/hibernate_asm_64.S index c73be0a02a6c..e41dadac5045 100644 --- a/arch/x86/power/hibernate_asm_64.S +++ b/arch/x86/power/hibernate_asm_64.S @@ -62,6 +62,8 @@ SYM_FUNC_START(restore_registers) /* Saved in save_processor_state. */ lgdt saved_context_gdt_desc(%rax) + RESUME_KERNEL_SHSTK restore_ssp, restore_s_cet + xorl %eax, %eax /* tell the hibernation core that we've just restored the memory */ @@ -94,9 +96,14 @@ SYM_FUNC_START(swsusp_arch_suspend) movq %cr3, %rax movq %rax, restore_cr3(%rip) + SUSPEND_KERNEL_SHSTK restore_ssp, restore_s_cet + FRAME_BEGIN call swsusp_save FRAME_END + + RESUME_KERNEL_SHSTK restore_ssp, restore_s_cet + RET SYM_FUNC_END(swsusp_arch_suspend) -- 2.43.0