Re: [PATCH 2/2] crypto/ccp: narrow scope of snp_range_list
From: Tom Lendacky
Date: Mon Jan 05 2026 - 12:44:11 EST
On 1/5/26 11:22, Tycho Andersen wrote:
> From: "Tycho Andersen (AMD)" <tycho@xxxxxxxxxx>
>
> snp_range_list is only used in __sev_snp_init_locked() in the SNP_INIT_EX
> case, move the declaration there and add a __free() cleanup helper for it
> instead of waiting until shutdown.
>
> Fixes: 1ca5614b84ee ("crypto: ccp: Add support to initialize the AMD-SP for SEV-SNP")
> Reviewed-by: Alexey Kardashevskiy <aik@xxxxxxx>
> Signed-off-by: Tycho Andersen (AMD) <tycho@xxxxxxxxxx>
Reviewed-by: Tom Lendacky <thomas.lendacky@xxxxxxx>
> ---
> drivers/crypto/ccp/sev-dev.c | 13 +------------
> 1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index 6e6011e363e3..1cdadddb744e 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -127,13 +127,6 @@ static size_t sev_es_tmr_size = SEV_TMR_SIZE;
> #define NV_LENGTH (32 * 1024)
> static void *sev_init_ex_buffer;
>
> -/*
> - * SEV_DATA_RANGE_LIST:
> - * Array containing range of pages that firmware transitions to HV-fixed
> - * page state.
> - */
> -static struct sev_data_range_list *snp_range_list;
> -
> static void __sev_firmware_shutdown(struct sev_device *sev, bool panic);
>
> static int snp_shutdown_on_panic(struct notifier_block *nb,
> @@ -1361,6 +1354,7 @@ static int snp_filter_reserved_mem_regions(struct resource *rs, void *arg)
>
> static int __sev_snp_init_locked(int *error, unsigned int max_snp_asid)
> {
> + struct sev_data_range_list *snp_range_list __free(kfree) = NULL;
> struct psp_device *psp = psp_master;
> struct sev_data_snp_init_ex data;
> struct sev_device *sev;
> @@ -2780,11 +2774,6 @@ static void __sev_firmware_shutdown(struct sev_device *sev, bool panic)
> sev_init_ex_buffer = NULL;
> }
>
> - if (snp_range_list) {
> - kfree(snp_range_list);
> - snp_range_list = NULL;
> - }
> -
> __sev_snp_shutdown_locked(&error, panic);
> }
>