* [PATCH 0/2] Miscellaneous SEV fixes
@ 2018-09-14 22:32 Janakarajan Natarajan
2018-09-14 22:32 ` [PATCH 1/2] Fix static checker warning Janakarajan Natarajan
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Janakarajan Natarajan @ 2018-09-14 22:32 UTC (permalink / raw)
To: linux-crypto, linux-kernel
Cc: Tom Lendacky, Gary Hook, Herbert Xu, David S . Miller,
Brijesh Singh, 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.
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(-)
--
2.7.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] Fix static checker warning
2018-09-14 22:32 [PATCH 0/2] Miscellaneous SEV fixes Janakarajan Natarajan
@ 2018-09-14 22:32 ` Janakarajan Natarajan
2018-09-19 13:40 ` Gary R Hook
2018-09-14 22:32 ` [PATCH 2/2] Allow SEV firmware to be chosen based on Family and Model Janakarajan Natarajan
2018-09-21 5:46 ` [PATCH 0/2] Miscellaneous SEV fixes Herbert Xu
2 siblings, 1 reply; 10+ messages in thread
From: Janakarajan Natarajan @ 2018-09-14 22:32 UTC (permalink / raw)
To: linux-crypto, linux-kernel
Cc: Tom Lendacky, Gary Hook, Herbert Xu, David S . Miller,
Brijesh Singh, Janakarajan Natarajan, Dan Carpenter
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 <Dan.Carpenter@oracle.com>
Reported-by: Dan Carpenter <Dan.Carpenter@oracle.com>
Signed-off-by: Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>
---
drivers/crypto/ccp/psp-dev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
index 72790d8..f541e60 100644
--- a/drivers/crypto/ccp/psp-dev.c
+++ b/drivers/crypto/ccp/psp-dev.c
@@ -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);
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] Allow SEV firmware to be chosen based on Family and Model
2018-09-14 22:32 [PATCH 0/2] Miscellaneous SEV fixes Janakarajan Natarajan
2018-09-14 22:32 ` [PATCH 1/2] Fix static checker warning Janakarajan Natarajan
@ 2018-09-14 22:32 ` Janakarajan Natarajan
2018-09-19 13:29 ` Lendacky, Thomas
2018-09-19 13:41 ` Gary R Hook
2018-09-21 5:46 ` [PATCH 0/2] Miscellaneous SEV fixes Herbert Xu
2 siblings, 2 replies; 10+ messages in thread
From: Janakarajan Natarajan @ 2018-09-14 22:32 UTC (permalink / raw)
To: linux-crypto, linux-kernel
Cc: Tom Lendacky, Gary Hook, Herbert Xu, David S . Miller,
Brijesh Singh, 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.
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 <Janakarajan.Natarajan@amd.com>
---
drivers/crypto/ccp/psp-dev.c | 44 ++++++++++++++++++++++++++++++++++++++++----
1 file changed, 40 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
index f541e60..3b33863 100644
--- a/drivers/crypto/ccp/psp-dev.c
+++ b/drivers/crypto/ccp/psp-dev.c
@@ -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 64
static 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
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] Allow SEV firmware to be chosen based on Family and Model
2018-09-14 22:32 ` [PATCH 2/2] Allow SEV firmware to be chosen based on Family and Model Janakarajan Natarajan
@ 2018-09-19 13:29 ` Lendacky, Thomas
2018-09-19 13:41 ` Gary R Hook
1 sibling, 0 replies; 10+ messages in thread
From: Lendacky, Thomas @ 2018-09-19 13:29 UTC (permalink / raw)
To: Natarajan, Janakarajan, linux-crypto, linux-kernel
Cc: Hook, Gary, Herbert Xu, David S . Miller, Singh, Brijesh
On 09/14/2018 05:32 PM, Janakarajan Natarajan wrote:
> 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.
>
> 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 <Janakarajan.Natarajan@amd.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
> drivers/crypto/ccp/psp-dev.c | 44 ++++++++++++++++++++++++++++++++++++++++----
> 1 file changed, 40 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
> index f541e60..3b33863 100644
> --- a/drivers/crypto/ccp/psp-dev.c
> +++ b/drivers/crypto/ccp/psp-dev.c
> @@ -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 64
>
> static 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
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] Fix static checker warning
2018-09-14 22:32 ` [PATCH 1/2] Fix static checker warning Janakarajan Natarajan
@ 2018-09-19 13:40 ` Gary R Hook
2018-09-19 13:57 ` Dan Carpenter
0 siblings, 1 reply; 10+ messages in thread
From: Gary R Hook @ 2018-09-19 13:40 UTC (permalink / raw)
To: Natarajan, Janakarajan, linux-crypto, linux-kernel
Cc: Lendacky, Thomas, Hook, Gary, Herbert Xu, David S . Miller,
Singh, Brijesh, Dan Carpenter
On 09/14/2018 05:32 PM, Janakarajan Natarajan wrote:
> 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 <Dan.Carpenter@oracle.com>
> Reported-by: Dan Carpenter <Dan.Carpenter@oracle.com>
> Signed-off-by: Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>
Acked-by: Gary R Hook <gary.hook@amd.com>
> ---
> drivers/crypto/ccp/psp-dev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
> index 72790d8..f541e60 100644
> --- a/drivers/crypto/ccp/psp-dev.c
> +++ b/drivers/crypto/ccp/psp-dev.c
> @@ -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);
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] Allow SEV firmware to be chosen based on Family and Model
2018-09-14 22:32 ` [PATCH 2/2] Allow SEV firmware to be chosen based on Family and Model Janakarajan Natarajan
2018-09-19 13:29 ` Lendacky, Thomas
@ 2018-09-19 13:41 ` Gary R Hook
1 sibling, 0 replies; 10+ messages in thread
From: Gary R Hook @ 2018-09-19 13:41 UTC (permalink / raw)
To: Natarajan, Janakarajan, linux-crypto, linux-kernel
Cc: Lendacky, Thomas, Hook, Gary, Herbert Xu, David S . Miller,
Singh, Brijesh
On 09/14/2018 05:32 PM, Janakarajan Natarajan wrote:
> 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.
>
> 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 <Janakarajan.Natarajan@amd.com>
Acked-by: Gary R Hook <gary.hook@amd.com>
> ---
> drivers/crypto/ccp/psp-dev.c | 44 ++++++++++++++++++++++++++++++++++++++++----
> 1 file changed, 40 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
> index f541e60..3b33863 100644
> --- a/drivers/crypto/ccp/psp-dev.c
> +++ b/drivers/crypto/ccp/psp-dev.c
> @@ -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 64
>
> static 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
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] Fix static checker warning
2018-09-19 13:40 ` Gary R Hook
@ 2018-09-19 13:57 ` Dan Carpenter
2018-09-20 15:43 ` Natarajan, Janakarajan
0 siblings, 1 reply; 10+ messages in thread
From: Dan Carpenter @ 2018-09-19 13:57 UTC (permalink / raw)
To: Gary R Hook
Cc: Natarajan, Janakarajan, linux-crypto, linux-kernel, Lendacky,
Thomas, Hook, Gary, Herbert Xu, David S . Miller, Singh, Brijesh
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] Fix static checker warning
2018-09-19 13:57 ` Dan Carpenter
@ 2018-09-20 15:43 ` Natarajan, Janakarajan
2018-09-21 4:52 ` Herbert Xu
0 siblings, 1 reply; 10+ messages in thread
From: Natarajan, Janakarajan @ 2018-09-20 15:43 UTC (permalink / raw)
To: Dan Carpenter, Hook, Gary
Cc: linux-crypto, linux-kernel, Lendacky, Thomas, Hook, Gary,
Herbert Xu, David S . Miller, Singh, Brijesh
On 9/19/2018 8:57 AM, Dan Carpenter wrote:
> 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.
>
> I don't know if Herbert fixes those things up himself normally?
>
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] Fix static checker warning
2018-09-20 15:43 ` Natarajan, Janakarajan
@ 2018-09-21 4:52 ` Herbert Xu
0 siblings, 0 replies; 10+ messages in thread
From: Herbert Xu @ 2018-09-21 4:52 UTC (permalink / raw)
To: Natarajan, Janakarajan
Cc: Dan Carpenter, Hook, Gary, linux-crypto, linux-kernel, Lendacky,
Thomas, David S . Miller, Singh, Brijesh
On Thu, Sep 20, 2018 at 03:43:48PM +0000, Natarajan, Janakarajan wrote:
> On 9/19/2018 8:57 AM, Dan Carpenter wrote:
> > 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,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] Miscellaneous SEV fixes
2018-09-14 22:32 [PATCH 0/2] Miscellaneous SEV fixes Janakarajan Natarajan
2018-09-14 22:32 ` [PATCH 1/2] Fix static checker warning Janakarajan Natarajan
2018-09-14 22:32 ` [PATCH 2/2] Allow SEV firmware to be chosen based on Family and Model Janakarajan Natarajan
@ 2018-09-21 5:46 ` Herbert Xu
2 siblings, 0 replies; 10+ messages in thread
From: Herbert Xu @ 2018-09-21 5:46 UTC (permalink / raw)
To: Janakarajan Natarajan
Cc: linux-crypto, linux-kernel, Tom Lendacky, Gary Hook,
David S . Miller, Brijesh Singh
On Fri, Sep 14, 2018 at 05:32:02PM -0500, Janakarajan Natarajan wrote:
> 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(-)
All applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2018-09-21 5:46 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-14 22:32 [PATCH 0/2] Miscellaneous SEV fixes Janakarajan Natarajan
2018-09-14 22:32 ` [PATCH 1/2] Fix static checker warning Janakarajan Natarajan
2018-09-19 13:40 ` Gary R Hook
2018-09-19 13:57 ` Dan Carpenter
2018-09-20 15:43 ` Natarajan, Janakarajan
2018-09-21 4:52 ` Herbert Xu
2018-09-14 22:32 ` [PATCH 2/2] Allow SEV firmware to be chosen based on Family and Model Janakarajan Natarajan
2018-09-19 13:29 ` Lendacky, Thomas
2018-09-19 13:41 ` Gary R Hook
2018-09-21 5:46 ` [PATCH 0/2] Miscellaneous SEV fixes Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).