Skip to contentSkip to conversation

crypto: ccp - allow callers to use HV-Fixed page API when SEV is disabled

PATCH In review Ashish Kalra 3 participants 3 messages Feb 6 – Feb 28

Subsystems (3)
lore
Share & tools
lore

Ashish Kalra

author maintainer
#0 lore raw

PATCH 1/1 crypto: ccp - allow callers to use HV-Fixed page API when SEV is disabled

From: Ashish Kalra <[email protected]>

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 e09701dcdd9c ("crypto: ccp - Add new HV-Fixed page allocation/free API")
---
 drivers/crypto/ccp/sev-dev.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/crypto/ccp/sev-dev.c +4 -6
index 1cdadddb744e..0d90b5f6a454 100644
@@ -1105,15 +1105,12 @@ struct page *snp_alloc_hv_fixed_pages(unsigned int num_2mb_pages)
 {
 	struct psp_device *psp_master = psp_get_master_device();
 	struct snp_hv_fixed_pages_entry *entry;
-	struct sev_device *sev;
 	unsigned int order;
 	struct page *page;
 
-	if (!psp_master || !psp_master->sev_data)
+	if (!psp_master)
 		return NULL;
 
-	sev = psp_master->sev_data;
-
 	order = get_order(PMD_SIZE * num_2mb_pages);
 
 	/*
@@ -1126,7 +1123,8 @@ struct page *snp_alloc_hv_fixed_pages(unsigned int num_2mb_pages)
 	 * This API uses SNP_INIT_EX to transition allocated pages to HV_Fixed
 	 * page state, fail if SNP is already initialized.
 	 */
-	if (sev->snp_initialized)
+	if (psp_master->sev_data &&
+	    ((struct sev_device *)psp_master->sev_data)->snp_initialized)
 		return NULL;
 
 	/* Re-use freed pages that match the request */
@@ -1162,7 +1160,7 @@ void snp_free_hv_fixed_pages(struct page *page)
 	struct psp_device *psp_master = psp_get_master_device();
 	struct snp_hv_fixed_pages_entry *entry, *nentry;
 
-	if (!psp_master || !psp_master->sev_data)
+	if (!psp_master)
 		return;
 
 	/*
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Ashish Kalra

From: Ashish Kalra <[email protected]>

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 e09701dcdd9c ("crypto: ccp - Add new HV-Fixed page allocation/free API")
Quoted 44 lines
---
 drivers/crypto/ccp/sev-dev.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/crypto/ccp/sev-dev.c +4 -6
index 1cdadddb744e..0d90b5f6a454 100644
@@ -1105,15 +1105,12 @@ struct page *snp_alloc_hv_fixed_pages(unsigned int num_2mb_pages)
 {
 	struct psp_device *psp_master = psp_get_master_device();
 	struct snp_hv_fixed_pages_entry *entry;
-	struct sev_device *sev;
 	unsigned int order;
 	struct page *page;
 
-	if (!psp_master || !psp_master->sev_data)
+	if (!psp_master)
 		return NULL;
 
-	sev = psp_master->sev_data;
-
 	order = get_order(PMD_SIZE * num_2mb_pages);
 
 	/*
@@ -1126,7 +1123,8 @@ struct page *snp_alloc_hv_fixed_pages(unsigned int num_2mb_pages)
 	 * This API uses SNP_INIT_EX to transition allocated pages to HV_Fixed
 	 * page state, fail if SNP is already initialized.
 	 */
-	if (sev->snp_initialized)
+	if (psp_master->sev_data &&
+	    ((struct sev_device *)psp_master->sev_data)->snp_initialized)
 		return NULL;
 
 	/* Re-use freed pages that match the request */
@@ -1162,7 +1160,7 @@ void snp_free_hv_fixed_pages(struct page *page)
 	struct psp_device *psp_master = psp_get_master_device();
 	struct snp_hv_fixed_pages_entry *entry, *nentry;
 
-	if (!psp_master || !psp_master->sev_data)
+	if (!psp_master)
 		return;
 
 	/*
maintainer
#2 lore raw
In reply to Ashish Kalra
Quoted 8 lines · Ashish Kalra

From: Ashish Kalra <[email protected]>

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.

Quoted 6 lines
Fixes e09701dcdd9c ("crypto: ccp - Add new HV-Fixed page allocation/free API")
---
 drivers/crypto/ccp/sev-dev.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt