Miscellaneous SEV fixes
Subsystems (2)
cover Miscellaneous SEV fixes
The first patch provides a fix for a static checker warning.
The second patch allows for the SEV firmware blob, which will be searched for when updating SEV during PSP initialization, to be named based on the family and model of the processor.
Janakarajan Natarajan (2):
Fix static checker warning
Allow SEV firmware to be chosen based on Family and Model
drivers/crypto/ccp/psp-dev.c | 46 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/2 Fix static checker warning
Under certain configuration SEV functions can be defined as no-op. In such a case error can be uninitialized.
Initialize the variable to 0.
--- drivers/crypto/ccp/psp-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/ccp/psp-dev.c +1 -1
@@ -423,7 +423,7 @@ EXPORT_SYMBOL_GPL(psp_copy_user_blob);static int sev_get_api_version (void ) {struct sev_user_data_status *status; -int error, ret; +int error =0 , ret; status = &psp_master->status_cmd_buf; ret =sev_platform_status (status, &error);
Signature · 1 line
2.7.4
Re: [PATCH 1/2] Fix static checker warning
Quoted 8 lines · Janakarajan Natarajan
Under certain configuration SEV functions can be defined as no-op. In such a case error can be uninitialized.
Initialize the variable to 0.
Cc Dan Carpenter <[email protected]>Reported-by Dan Carpenter <[email protected]>Signed-off-by Janakarajan Natarajan <[email protected]>
Quoted 18 lines
--- drivers/crypto/ccp/psp-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/crypto/ccp/psp-dev.c +1
-1@@ -423,7 +423,7 @@ EXPORT_SYMBOL_GPL(psp_copy_user_blob);static int sev_get_api_version (void ) {struct sev_user_data_status *status; -int error, ret; +int error =0 , ret; status = &psp_master->status_cmd_buf; ret =sev_platform_status (status, &error);
Re: [PATCH 1/2] Fix static checker warning
Sounds reasonable. The subject needs a subsystem prefix and it might be better to make it more specific. Like so:
[PATCH 1/2] crypto: ccp - potential uninitialized variable
I don't know if Herbert fixes those things up himself normally?
regards,
dan carpenter
Re: [PATCH 1/2] Fix static checker warning
Quoted 4 lines · Dan Carpenter
Sounds reasonable. The subject needs a subsystem prefix and it might be better to make it more specific. Like so:
[PATCH 1/2] crypto: ccp - potential uninitialized variable
I'll put out a v2 with the subjects fixed.
Thanks.
Quoted 6 lines
I don't know if Herbert fixes those things up himself normally?
regards,
dan carpenter
Herbert Xu
maintainerRe: [PATCH 1/2] Fix static checker warning
Quoted 7 lines · Janakarajan
Quoted 4 lines · Dan Carpenter
Sounds reasonable. The subject needs a subsystem prefix and it might be better to make it more specific. Like so:
[PATCH 1/2] crypto: ccp - potential uninitialized variable
I'll put out a v2 with the subjects fixed.
This is not necessary. I'll fix it up when I apply the patch.
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
PATCH 2/2 Allow SEV firmware to be chosen based on Family and Model
In reply to Janakarajan NatarajanDuring PSP initialization, there is an attempt to update the SEV firmware by looking in /lib/firmware/amd/. Currently, sev.fw is the expected name of the firmware blob.
This patch will allow for firmware filenames based on the family and model of the processor.
Model specific firmware files are given highest priority. Followed by firmware for a subset of models. Lastly, failing the previous two options, fallback to looking for sev.fw.
--- drivers/crypto/ccp/psp-dev.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-)
drivers/crypto/ccp/psp-dev.c +40 -4
@@ -31,8 +31,9 @@ ((psp_master->api_major) >= _maj && \ (psp_master->api_minor) >= _min) -#define DEVICE_NAME "sev" -#define SEV_FW_FILE "amd/sev.fw" +#define DEVICE_NAME "sev" +#define SEV_FW_FILE "amd/sev.fw" +#define SEV_FW_NAME_SIZE 64static DEFINE_MUTEX (sev_cmd_mutex);static struct sev_misc_dev *misc_dev;
@@ -440,6 +441,40 @@ static int sev_get_api_version(void)return 0 ; } +int sev_get_firmware (struct device *dev,const struct firmware **firmware) +{ +char fw_name_specific[SEV_FW_NAME_SIZE ]; +char fw_name_subset[SEV_FW_NAME_SIZE ]; + +snprintf (fw_name_specific,sizeof (fw_name_specific), +"amd/amd_sev_fam%.2xh_model%.2xh.sbin" , + boot_cpu_data.x86, boot_cpu_data.x86_model); + +snprintf (fw_name_subset,sizeof (fw_name_subset), +"amd/amd_sev_fam%.2xh_model%.1xxh.sbin" , + boot_cpu_data.x86, (boot_cpu_data.x86_model &0xf0 ) >>4 ); + +/* Check for SEV FW for a particular model. +* Ex. amd_sev_fam17h_model00h.sbin for Family 17h Model 00h +* +* or +* +* Check for SEV FW common to a subset of models. +* Ex. amd_sev_fam17h_model0xh.sbin for +* Family 17h Model 00h -- Family 17h Model 0Fh +* +* or +* +* Fall-back to using generic name: sev.fw +*/ +if ((firmware_request_nowarn (firmware, fw_name_specific, dev) >=0 ) || + (firmware_request_nowarn (firmware, fw_name_subset, dev) >=0 ) || + (firmware_request_nowarn (firmware,SEV_FW_FILE , dev) >=0 )) +return 0 ; + +return -ENOENT ; +} +/* Don't fail if SEV FW couldn't be updated. Continue with existing SEV FW */ static int sev_update_firmware (struct device *dev) {
@@ -449,9 +484,10 @@ static int sev_update_firmware(struct device *dev)struct page *p;u64 data_size; - ret =request_firmware (&firmware,SEV_FW_FILE , dev); -if (ret <0 ) +if (sev_get_firmware (dev, &firmware) == -ENOENT ) { +dev_dbg (dev,"No SEV firmware file present\n" );return -1 ; + }/* * SEV FW expects the physical address given to it to be 32
Signature · 1 line
2.7.4
Re: [PATCH 2/2] Allow SEV firmware to be chosen based on Family and Model
Quoted 4 lines · Janakarajan Natarajan
During PSP initialization, there is an attempt to update the SEV firmware by looking in
/lib/firmware/amd/. Currently, sev.fw is the expected name of the firmware blob.
Quoted 8 lines
This patch will allow for firmware filenames based on the family and model of the processor.
Model specific firmware files are given highest priority. Followed by firmware for a subset of models. Lastly, failing the previous two options, fallback to looking for sev.fw.
Signed-off-by Janakarajan Natarajan <[email protected]>
Quoted 75 lines
--- drivers/crypto/ccp/psp-dev.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-)drivers/crypto/ccp/psp-dev.c +40
-4@@ -31,8 +31,9 @@ ((psp_master->api_major) >= _maj && \ (psp_master->api_minor) >= _min) -#define DEVICE_NAME "sev" -#define SEV_FW_FILE "amd/sev.fw" +#define DEVICE_NAME "sev" +#define SEV_FW_FILE "amd/sev.fw" +#define SEV_FW_NAME_SIZE 64static DEFINE_MUTEX (sev_cmd_mutex);static struct sev_misc_dev *misc_dev;@@ -440,6 +441,40 @@ static int sev_get_api_version(void)return 0 ; } +int sev_get_firmware (struct device *dev,const struct firmware **firmware) +{ +char fw_name_specific[SEV_FW_NAME_SIZE ]; +char fw_name_subset[SEV_FW_NAME_SIZE ]; + +snprintf (fw_name_specific,sizeof (fw_name_specific), +"amd/amd_sev_fam%.2xh_model%.2xh.sbin" , + boot_cpu_data.x86, boot_cpu_data.x86_model); + +snprintf (fw_name_subset,sizeof (fw_name_subset), +"amd/amd_sev_fam%.2xh_model%.1xxh.sbin" , + boot_cpu_data.x86, (boot_cpu_data.x86_model &0xf0 ) >>4 ); + +/* Check for SEV FW for a particular model. +* Ex. amd_sev_fam17h_model00h.sbin for Family 17h Model 00h +* +* or +* +* Check for SEV FW common to a subset of models. +* Ex. amd_sev_fam17h_model0xh.sbin for +* Family 17h Model 00h -- Family 17h Model 0Fh +* +* or +* +* Fall-back to using generic name: sev.fw +*/ +if ((firmware_request_nowarn (firmware, fw_name_specific, dev) >=0 ) || + (firmware_request_nowarn (firmware, fw_name_subset, dev) >=0 ) || + (firmware_request_nowarn (firmware,SEV_FW_FILE , dev) >=0 )) +return 0 ; + +return -ENOENT ; +} +/* Don't fail if SEV FW couldn't be updated. Continue with existing SEV FW */ static int sev_update_firmware (struct device *dev) {@@ -449,9 +484,10 @@ static int sev_update_firmware(struct device *dev)struct page *p;u64 data_size; - ret =request_firmware (&firmware,SEV_FW_FILE , dev); -if (ret <0 ) +if (sev_get_firmware (dev, &firmware) == -ENOENT ) { +dev_dbg (dev,"No SEV firmware file present\n" );return -1 ; + }/* * SEV FW expects the physical address given to it to be 32
Re: [PATCH 2/2] Allow SEV firmware to be chosen based on Family and Model
In reply to Janakarajan NatarajanQuoted 4 lines · Janakarajan Natarajan
During PSP initialization, there is an attempt to update the SEV firmware by looking in
/lib/firmware/amd/. Currently, sev.fw is the expected name of the firmware blob.
Quoted 8 lines
This patch will allow for firmware filenames based on the family and model of the processor.
Model specific firmware files are given highest priority. Followed by firmware for a subset of models. Lastly, failing the previous two options, fallback to looking for sev.fw.
Signed-off-by Janakarajan Natarajan <[email protected]>
Quoted 75 lines
--- drivers/crypto/ccp/psp-dev.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-)drivers/crypto/ccp/psp-dev.c +40
-4@@ -31,8 +31,9 @@ ((psp_master->api_major) >= _maj && \ (psp_master->api_minor) >= _min) -#define DEVICE_NAME "sev" -#define SEV_FW_FILE "amd/sev.fw" +#define DEVICE_NAME "sev" +#define SEV_FW_FILE "amd/sev.fw" +#define SEV_FW_NAME_SIZE 64static DEFINE_MUTEX (sev_cmd_mutex);static struct sev_misc_dev *misc_dev;@@ -440,6 +441,40 @@ static int sev_get_api_version(void)return 0 ; } +int sev_get_firmware (struct device *dev,const struct firmware **firmware) +{ +char fw_name_specific[SEV_FW_NAME_SIZE ]; +char fw_name_subset[SEV_FW_NAME_SIZE ]; + +snprintf (fw_name_specific,sizeof (fw_name_specific), +"amd/amd_sev_fam%.2xh_model%.2xh.sbin" , + boot_cpu_data.x86, boot_cpu_data.x86_model); + +snprintf (fw_name_subset,sizeof (fw_name_subset), +"amd/amd_sev_fam%.2xh_model%.1xxh.sbin" , + boot_cpu_data.x86, (boot_cpu_data.x86_model &0xf0 ) >>4 ); + +/* Check for SEV FW for a particular model. +* Ex. amd_sev_fam17h_model00h.sbin for Family 17h Model 00h +* +* or +* +* Check for SEV FW common to a subset of models. +* Ex. amd_sev_fam17h_model0xh.sbin for +* Family 17h Model 00h -- Family 17h Model 0Fh +* +* or +* +* Fall-back to using generic name: sev.fw +*/ +if ((firmware_request_nowarn (firmware, fw_name_specific, dev) >=0 ) || + (firmware_request_nowarn (firmware, fw_name_subset, dev) >=0 ) || + (firmware_request_nowarn (firmware,SEV_FW_FILE , dev) >=0 )) +return 0 ; + +return -ENOENT ; +} +/* Don't fail if SEV FW couldn't be updated. Continue with existing SEV FW */ static int sev_update_firmware (struct device *dev) {@@ -449,9 +484,10 @@ static int sev_update_firmware(struct device *dev)struct page *p;u64 data_size; - ret =request_firmware (&firmware,SEV_FW_FILE , dev); -if (ret <0 ) +if (sev_get_firmware (dev, &firmware) == -ENOENT ) { +dev_dbg (dev,"No SEV firmware file present\n" );return -1 ; + }/* * SEV FW expects the physical address given to it to be 32
Herbert Xu
maintainerQuoted 6 lines · Janakarajan Natarajan
The first patch provides a fix for a static checker warning.
The second patch allows for the SEV firmware blob, which will be searched for when updating SEV during PSP initialization, to be named based on the family and model of the processor.
Quoted 6 lines
Janakarajan Natarajan (2):
Fix static checker warning
Allow SEV firmware to be chosen based on Family and Modeldrivers/crypto/ccp/psp-dev.c | 46 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-)
All 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