crypto: ccp - Bump minimum firmware version for SEV-SNP support
Subsystems (3)
PATCH 1/2 crypto: ccp - Bump minimum firmware version for SEV-SNP support
From: "Tycho Andersen (AMD)" <[email protected]>
The SEV firmware has received many critical bug and security fixes since 1.52. Bump the minimum supported firmware version for SEV-SNP to 1.55 (first available in linux-firmware release 20230919). See
https://www.amd.com/en/developer/sev.html for firmware release notes with exact bug fixes and CVE details.
While these macros are called SNP_MIN_API_*, since 6131e119f579 ("crypto:
ccp - Abort doing SEV INIT if SNP INIT fails") both SEV and SNP fail if SNP fails to initialize, so this firmware requirement really applies to SEV hosts that are SNP capable at the time of init.
Also upgrade the debug log to an error log to give people some idea about why things failed.
--- drivers/crypto/ccp/sev-dev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/crypto/ccp/sev-dev.c +3 -3
@@ -43,9 +43,9 @@#define SEV_FW_FILE "amd/sev.fw"#define SEV_FW_NAME_SIZE 64 -/* Minimum firmware version required for the SEV-SNP support */ +/* Minimum firmware version required for SEV-SNP support */ #define SNP_MIN_API_MAJOR 1 -#define SNP_MIN_API_MINOR 51 +#define SNP_MIN_API_MINOR 55/* * Maximum number of firmware-writable buffers that might be specified
@@ -1523,7 +1523,7 @@ static int __sev_snp_init_locked(int *error, unsigned int max_snp_asid)return 0 ;if (!sev_version_greater_or_equal (SNP_MIN_API_MAJOR ,SNP_MIN_API_MINOR )) { -dev_dbg (sev->dev,"SEV-SNP support requires firmware version >= %d:%d\n" , +dev_err (sev->dev,"SEV-SNP support requires firmware version >= %d:%d\n" ,SNP_MIN_API_MAJOR ,SNP_MIN_API_MINOR );return -EOPNOTSUPP ; }
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.56.0
PATCH 2/2 crypto: ccp - Drop support for SNP without INIT_EX
From: "Tycho Andersen (AMD)" <[email protected]>
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.
--- drivers/crypto/ccp/sev-dev.c | 110 +++++++++++++++-------------------- 1 file changed, 46 insertions(+), 64 deletions(-)
drivers/crypto/ccp/sev-dev.c +46 -64
@@ -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; }
Signature · 1 line
2.56.0