* [PATCH v1 2/2] crypto: ccp - Drop support for SNP without INIT_EX
2026-11-03 18:10 [PATCH v1 1/2] crypto: ccp - Bump minimum firmware version for SEV-SNP support Tycho Andersen
@ 2026-11-03 18:10 ` Tycho Andersen
0 siblings, 0 replies; 2+ messages in thread
From: Tycho Andersen @ 2026-11-03 18:10 UTC (permalink / raw)
To: Ashish Kalra, Tom Lendacky, Herbert Xu, David S. Miller
Cc: linux-crypto, linux-kernel, Tycho Andersen (AMD)
From: "Tycho Andersen (AMD)" <tycho@kernel.org>
Now that the minimum version of firmware allowed is 1.55,
__sev_snp_init_locked() no longer needs the special case for version 1.52
so delete it and its associated locals.
Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
---
drivers/crypto/ccp/sev-dev.c | 110 +++++++++++++++--------------------
1 file changed, 46 insertions(+), 64 deletions(-)
diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 13e6af5549f5..ad296c5e94dd 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -1511,8 +1511,8 @@ static int __sev_snp_init_locked(int *error, unsigned int max_snp_asid)
struct psp_device *psp = psp_master;
struct sev_data_snp_init_ex data = {};
struct sev_device *sev;
- void *arg = &data;
- int cmd, rc = 0;
+ bool tio_supp;
+ int rc = 0;
if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
return -ENODEV;
@@ -1532,73 +1532,56 @@ static int __sev_snp_init_locked(int *error, unsigned int max_snp_asid)
if (rc)
return rc;
+ tio_supp = !!(sev->snp_feat_info_0.ebx & SNP_SEV_TIO_SUPPORTED);
+
/*
- * Starting in SNP firmware v1.52, the SNP_INIT_EX command takes a list
- * of system physical address ranges to convert into HV-fixed page
- * states during the RMP initialization. For instance, the memory that
- * UEFI reserves should be included in the that list. This allows system
- * components that occasionally write to memory (e.g. logging to UEFI
- * reserved regions) to not fail due to RMP initialization and SNP
- * enablement.
- *
+ * Firmware checks that the pages containing the ranges enumerated
+ * in the RANGES structure are either in the default page state or in the
+ * firmware page state.
*/
- if (sev_version_greater_or_equal(SNP_MIN_API_MAJOR, 52)) {
- bool tio_supp = !!(sev->snp_feat_info_0.ebx & SNP_SEV_TIO_SUPPORTED);
-
- /*
- * Firmware checks that the pages containing the ranges enumerated
- * in the RANGES structure are either in the default page state or in the
- * firmware page state.
- */
- snp_range_list = kzalloc(PAGE_SIZE, GFP_KERNEL);
- if (!snp_range_list) {
- dev_err(sev->dev,
- "SEV: SNP_INIT_EX range list memory allocation failed\n");
- return -ENOMEM;
- }
-
- /*
- * Retrieve all reserved memory regions from the e820 memory map
- * to be setup as HV-fixed pages.
- */
- rc = walk_iomem_res_desc(IORES_DESC_NONE, IORESOURCE_MEM, 0, ~0,
- snp_range_list, snp_filter_reserved_mem_regions);
- if (rc) {
- dev_err(sev->dev,
- "SEV: SNP_INIT_EX walk_iomem_res_desc failed rc = %d\n", rc);
- return rc;
- }
+ snp_range_list = kzalloc(PAGE_SIZE, GFP_KERNEL);
+ if (!snp_range_list) {
+ dev_err(sev->dev,
+ "SEV: SNP_INIT_EX range list memory allocation failed\n");
+ return -ENOMEM;
+ }
- /*
- * Add HV_Fixed pages from other PSP sub-devices, such as SFS to the
- * HV_Fixed page list.
- */
- snp_add_hv_fixed_pages(sev, snp_range_list);
+ /*
+ * Retrieve all reserved memory regions from the e820 memory map
+ * to be setup as HV-fixed pages.
+ */
+ rc = walk_iomem_res_desc(IORES_DESC_NONE, IORESOURCE_MEM, 0, ~0,
+ snp_range_list, snp_filter_reserved_mem_regions);
+ if (rc) {
+ dev_err(sev->dev,
+ "SEV: SNP_INIT_EX walk_iomem_res_desc failed rc = %d\n", rc);
+ return rc;
+ }
- if (max_snp_asid) {
- data.ciphertext_hiding_en = 1;
- data.max_snp_asid = max_snp_asid;
- }
+ /*
+ * Add HV_Fixed pages from other PSP sub-devices, such as SFS to the
+ * HV_Fixed page list.
+ */
+ snp_add_hv_fixed_pages(sev, snp_range_list);
- data.init_rmp = 1;
- data.list_paddr_en = 1;
- data.list_paddr = __psp_pa(snp_range_list);
+ if (max_snp_asid) {
+ data.ciphertext_hiding_en = 1;
+ data.max_snp_asid = max_snp_asid;
+ }
- data.tio_en = tio_supp && sev_tio_enabled && amd_iommu_sev_tio_supported();
+ data.init_rmp = 1;
+ data.list_paddr_en = 1;
+ data.list_paddr = __psp_pa(snp_range_list);
- /*
- * When psp_init_on_probe is disabled, the userspace calling
- * SEV ioctl can inadvertently shut down SNP and SEV-TIO causing
- * unexpected state loss.
- */
- if (data.tio_en && !psp_init_on_probe)
- dev_warn(sev->dev, "SEV-TIO as incompatible with psp_init_on_probe=0\n");
+ data.tio_en = tio_supp && sev_tio_enabled && amd_iommu_sev_tio_supported();
- cmd = SEV_CMD_SNP_INIT_EX;
- } else {
- cmd = SEV_CMD_SNP_INIT;
- arg = NULL;
- }
+ /*
+ * When psp_init_on_probe is disabled, the userspace calling
+ * SEV ioctl can inadvertently shut down SNP and SEV-TIO causing
+ * unexpected state loss.
+ */
+ if (data.tio_en && !psp_init_on_probe)
+ dev_warn(sev->dev, "SEV-TIO as incompatible with psp_init_on_probe=0\n");
/*
* The following sequence must be issued before launching the first SNP
@@ -1612,10 +1595,9 @@ static int __sev_snp_init_locked(int *error, unsigned int max_snp_asid)
*/
wbinvd_on_all_cpus();
- rc = __sev_do_cmd_locked(cmd, arg, error);
+ rc = __sev_do_cmd_locked(SEV_CMD_SNP_INIT_EX, &data, error);
if (rc) {
- dev_err(sev->dev, "SEV-SNP: %s failed rc %d, error %#x\n",
- cmd == SEV_CMD_SNP_INIT_EX ? "SNP_INIT_EX" : "SNP_INIT",
+ dev_err(sev->dev, "SEV-SNP: SNP_INIT_EX failed rc %d, error %#x\n",
rc, *error);
return rc;
}
--
2.56.0
^ permalink raw reply [flat|nested] 2+ messages in thread