Skip to content

Commit 8168a7b

Browse files
ashkalraherbertx
authored andcommitted
crypto: ccp - allow callers to use HV-Fixed page API when SEV is disabled
When SEV is disabled, the HV-Fixed page allocation call fails, which in turn causes SFS initialization to fail. Fix the HV-Fixed API so callers (for example, SFS) can use it even when SEV is disabled by performing normal page allocation and freeing. Fixes: e09701d ("crypto: ccp - Add new HV-Fixed page allocation/free API") Cc: stable@vger.kernel.org Signed-off-by: Ashish Kalra <ashish.kalra@amd.com> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 6de23f8 commit 8168a7b

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

drivers/crypto/ccp/sev-dev.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,15 +1105,12 @@ struct page *snp_alloc_hv_fixed_pages(unsigned int num_2mb_pages)
11051105
{
11061106
struct psp_device *psp_master = psp_get_master_device();
11071107
struct snp_hv_fixed_pages_entry *entry;
1108-
struct sev_device *sev;
11091108
unsigned int order;
11101109
struct page *page;
11111110

1112-
if (!psp_master || !psp_master->sev_data)
1111+
if (!psp_master)
11131112
return NULL;
11141113

1115-
sev = psp_master->sev_data;
1116-
11171114
order = get_order(PMD_SIZE * num_2mb_pages);
11181115

11191116
/*
@@ -1126,7 +1123,8 @@ struct page *snp_alloc_hv_fixed_pages(unsigned int num_2mb_pages)
11261123
* This API uses SNP_INIT_EX to transition allocated pages to HV_Fixed
11271124
* page state, fail if SNP is already initialized.
11281125
*/
1129-
if (sev->snp_initialized)
1126+
if (psp_master->sev_data &&
1127+
((struct sev_device *)psp_master->sev_data)->snp_initialized)
11301128
return NULL;
11311129

11321130
/* Re-use freed pages that match the request */
@@ -1162,7 +1160,7 @@ void snp_free_hv_fixed_pages(struct page *page)
11621160
struct psp_device *psp_master = psp_get_master_device();
11631161
struct snp_hv_fixed_pages_entry *entry, *nentry;
11641162

1165-
if (!psp_master || !psp_master->sev_data)
1163+
if (!psp_master)
11661164
return;
11671165

11681166
/*

0 commit comments

Comments
 (0)