]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
crypto: ccp - Add new HV-Fixed page allocation/free API
authorAshish Kalra <ashish.kalra@amd.com>
Tue, 16 Sep 2025 21:29:33 +0000 (21:29 +0000)
committerBorislav Petkov (AMD) <bp@alien8.de>
Wed, 17 Sep 2025 10:11:39 +0000 (12:11 +0200)
commite09701dcdd9ca06be249091eeb786d57e67b613e
tree73606dca173df7f348b1e10cf4df059497ac7ab6
parente4c00c4ce2aafe61dc7436e763a78d6d112d9e2f
crypto: ccp - Add new HV-Fixed page allocation/free API

When SEV-SNP is active, the TEE extended command header page and all output
buffers for TEE extended commands (such as used by Seamless Firmware servicing
support) must be in hypervisor-fixed state, assigned to the hypervisor and
marked immutable in the RMP entrie(s).

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

If SNP is not enabled then the allocator is simply a wrapper over
alloc_pages() and __free_pages().

When the sub device free the pages, they are put on a free list and future
allocation requests will try to re-use the freed pages from this list. But
this list is not preserved across PSP driver load/unload hence this free/reuse
support is only supported while PSP driver is loaded. As HV_FIXED page state
is only changed at reboot, these pages are leaked as they cannot be returned
back to the page allocator and then potentially allocated to guests, which
will cause SEV-SNP guests to fail to start or terminate when accessing the
HV_FIXED page.

Suggested-by: Thomas Lendacky <Thomas.Lendacky@amd.com>
Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Link: https://lore.kernel.org/cover.1758057691.git.ashish.kalra@amd.com
drivers/crypto/ccp/sev-dev.c
drivers/crypto/ccp/sev-dev.h