umber-kernel/drivers/crypto/ccp
Mario Limonciello (AMD) eb0e8003d9 crypto: ccp - Send PSP_CMD_TEE_RING_DESTROY when PSP_CMD_TEE_RING_INIT fails
[ Upstream commit 7b85137caf110a09a4a18f00f730de4709f9afc8 ]

The hibernate resume sequence involves loading a resume kernel that is just
used for loading the hibernate image before shifting back to the existing
kernel.

During that hibernate resume sequence the resume kernel may have loaded
the ccp driver.  If this happens the resume kernel will also have called
PSP_CMD_TEE_RING_INIT but it will never have called
PSP_CMD_TEE_RING_DESTROY.

This is problematic because the existing kernel needs to re-initialize the
ring.  One could argue that the existing kernel should call destroy
as part of restore() but there is no guarantee that the resume kernel did
or didn't load the ccp driver.  There is also no callback opportunity for
the resume kernel to destroy before handing back control to the existing
kernel.

Similar problems could potentially exist with the use of kdump and
crash handling. I actually reproduced this issue like this:

1) rmmod ccp
2) hibernate the system
3) resume the system
4) modprobe ccp

The resume kernel will have loaded ccp but never destroyed and then when
I try to modprobe it fails.

Because of these possible cases add a flow that checks the error code from
the PSP_CMD_TEE_RING_INIT call and tries to call PSP_CMD_TEE_RING_DESTROY
if it failed.  If this succeeds then call PSP_CMD_TEE_RING_INIT again.

Fixes: f892a21f51 ("crypto: ccp - use generic power management")
Reported-by: Lars Francke <lars.francke@gmail.com>
Closes: https://lore.kernel.org/platform-driver-x86/CAD-Ua_gfJnQSo8ucS_7ZwzuhoBRJ14zXP7s8b-zX3ZcxcyWePw@mail.gmail.com/
Tested-by: Yijun Shen <Yijun.Shen@Dell.com>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
Reviewed-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://patch.msgid.link/20260116041132.153674-6-superm1@kernel.org
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2026-02-26 14:59:26 -08:00
..
Kconfig
Makefile crypto: ccp - Add AMD Seamless Firmware Servicing (SFS) driver 2025-09-17 12:17:05 +02:00
ccp-crypto-aes-cmac.c
ccp-crypto-aes-galois.c
ccp-crypto-aes-xts.c
ccp-crypto-aes.c crypto: ccp - Add missing header inclusions 2025-04-16 15:16:21 +08:00
ccp-crypto-des3.c crypto: ccp - Add missing header inclusions 2025-04-16 15:16:21 +08:00
ccp-crypto-main.c crypto: ccp - Add missing header inclusions 2025-04-16 15:16:21 +08:00
ccp-crypto-rsa.c
ccp-crypto-sha.c
ccp-crypto.h
ccp-debugfs.c crypto: ccp - Fix crash when rebind ccp device for ccp.ko 2025-07-07 15:31:43 +12:00
ccp-dev-v3.c
ccp-dev-v5.c
ccp-dev.c
ccp-dev.h
ccp-dmaengine.c
ccp-ops.c crypto: ccp - Fix a crash due to incorrect cleanup usage of kfree 2026-02-26 14:59:04 -08:00
dbc.c
dbc.h
hsti.c crypto: ccp - Fix incorrect payload size calculation in psp_poulate_hsti() 2025-09-13 12:11:05 +08:00
hsti.h
platform-access.c
platform-access.h
psp-dev.c crypto: ccp - Add an S4 restore flow 2026-02-26 14:59:26 -08:00
psp-dev.h crypto: ccp - Add AMD Seamless Firmware Servicing (SFS) driver 2025-09-17 12:17:05 +02:00
sev-dev.c crypto: ccp - narrow scope of snp_range_list 2026-02-26 14:59:04 -08:00
sev-dev.h This update includes the following changes: 2025-10-04 14:59:29 -07:00
sfs.c crypto: ccp - Add AMD Seamless Firmware Servicing (SFS) driver 2025-09-17 12:17:05 +02:00
sfs.h crypto: ccp - Add AMD Seamless Firmware Servicing (SFS) driver 2025-09-17 12:17:05 +02:00
sp-dev.c crypto: ccp - Add an S4 restore flow 2026-02-26 14:59:26 -08:00
sp-dev.h crypto: ccp - Add an S4 restore flow 2026-02-26 14:59:26 -08:00
sp-pci.c crypto: ccp - Add an S4 restore flow 2026-02-26 14:59:26 -08:00
sp-platform.c
tee-dev.c crypto: ccp - Send PSP_CMD_TEE_RING_DESTROY when PSP_CMD_TEE_RING_INIT fails 2026-02-26 14:59:26 -08:00
tee-dev.h crypto: ccp - Add an S4 restore flow 2026-02-26 14:59:26 -08:00