From: Tom Lendacky Date: Wed, 3 Mar 2021 22:31:09 +0000 (-0600) Subject: crypto: ccp - Don't initialize SEV support without the SEV feature X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=1877c73b7c03c9f15c397e4e278ad3f551475ecf;p=uclinux-h8%2Flinux.git crypto: ccp - Don't initialize SEV support without the SEV feature If SEV has been disabled (e.g. through BIOS), the driver probe will still issue SEV firmware commands. The SEV INIT firmware command will return an error in this situation, but the error code is a general error code that doesn't highlight the exact reason. Add a check for X86_FEATURE_SEV in sev_dev_init() and emit a meaningful message and skip attempting to initialize the SEV firmware if the feature is not enabled. Since building the SEV code is dependent on X86_64, adding the check won't cause any build problems. Cc: John Allen Cc: Brijesh Singh Signed-off-by: Tom Lendacky Reviewed-By: Brijesh Singh Signed-off-by: Herbert Xu --- diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index cb9b4c4e371e..da3872c48308 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -972,6 +973,11 @@ int sev_dev_init(struct psp_device *psp) struct sev_device *sev; int ret = -ENOMEM; + if (!boot_cpu_has(X86_FEATURE_SEV)) { + dev_info_once(dev, "SEV: memory encryption not enabled by BIOS\n"); + return 0; + } + sev = devm_kzalloc(dev, sizeof(*sev), GFP_KERNEL); if (!sev) goto e_err;