[PATCH v6 0/3] crypto: ccp - Add AMD Seamless Firmware Servicing (SFS) driver

Ashish Kalra
2025-09-16T21:29:04Z

AMD Seamless Firmware Servicing (SFS) is a secure method to allow
non-persistent updates to running firmware and settings without
requiring BIOS reflash and/or system reset.

SFS does not address anything that runs on the x86 processors and
it can be used to update ASP firmware, modules, register settings
and update firmware for other microprocessors like TMPM, etc.

SFS driver support adds ioctl support to communicate the SFS
commands to the ASP/PSP by using the TEE mailbox interface.

The Seamless Firmware Servicing (SFS) driver is added as a
PSP sub-device.

Includes pre-patch to add new generic SEV API interface to allocate/free
hypervisor fixed pages which abstracts hypervisor fixed page allocation
and free for PSP sub devices. The API internally uses SNP_INIT_EX to
transition pages to HV-Fixed page state.

For detailed information, please look at the SFS specifications:
https://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/specifications/58604.pdf

v6:
- Rebase on top of the tip/master branch.

v5:
- Print pathname for firmware_request_nowarn() failure message.
- Changed all dev_warn() to dev_warn_ratelimited() for all ioctl
error mesages.
- Add Reviewed-by's for all patches.

v4:
- Ensure that sev_cmd_mutex is acquired before the snp_initialized check
in snp_alloc_hv_fixed_pages().
- Restore memory attributes back to the default "write-back" type in
sfs_dev_destroy() and cleanup path for the error handling in
sfs_dev_init().

v3:
- As not dumping the RMP entry is the rare case, crafting the APIs to
reflect that, i.e. make snp_leak_pages() a wrapper for the common case
to allow existing users to continue to dump RMP entries by calling
new __snp_leak_pages() API with dump_rmp bool parameter set to true.
The new parameter also adds support to continue adding pages to the
snp_leaked_pages_list but not issue dump_rmpentry().
- Fix kernel test robot build warning for uninitialized "ret" variable.

v2:
- Change API interface from adding/removing HV_Fixed pages to
allocate/free HV_Fixed pages.
- Move to guard() for all mutexes/spinlocks.
- Handle case of SFS capability bit being set on multiple PSPs, add
protection based on sev_dev_init() and sev_misc_init().
- Add new sfs_command structure and use it for programming both the
GetFirmareVersions and UpdatePackage command.
- Use sfs_user_get_fw_versions and sfs_user_update_package structures
for copy_to_/copy_from_user for the iotcls.
- Fix payload_path buffer size to prevent buffer overrun/stack
corruption issues and also sanitize user provided payload_name to
ensure it is null-terminated and use snprintf() to setup payload_path.
- Add new quiet parameter to snp_leak_pages() API and additionally change
all existing users of this API to pass quiet=false parameter
maintaining current behavior.
- Remove mutex_init() and mutex_destroy() calls for statically declared
mutex.
- Fix comments and commit logs.

Ashish Kalra (3):
x86/sev: Add new dump_rmp parameter to snp_leak_pages() API
crypto: ccp - Add new HV-Fixed page allocation/free API.
crypto: ccp - Add AMD Seamless Firmware Servicing (SFS) driver

arch/x86/include/asm/sev.h | 7 +-
arch/x86/virt/svm/sev.c | 7 +-
drivers/crypto/ccp/Makefile | 3 +-
drivers/crypto/ccp/psp-dev.c | 20 ++
drivers/crypto/ccp/psp-dev.h | 8 +-
drivers/crypto/ccp/sev-dev.c | 182 ++++++++++++++++
drivers/crypto/ccp/sev-dev.h | 3 +
drivers/crypto/ccp/sfs.c | 311 ++++++++++++++++++++++++++++
drivers/crypto/ccp/sfs.h | 47 +++++
include/linux/psp-platform-access.h | 2 +
include/uapi/linux/psp-sfs.h | 87 ++++++++
11 files changed, 671 insertions(+), 6 deletions(-)
create mode 100644 drivers/crypto/ccp/sfs.c
create mode 100644 drivers/crypto/ccp/sfs.h
create mode 100644 include/uapi/linux/psp-sfs.h

--
2.34.1