From: Borislav Petkov (AMD) Date: Wed, 15 Feb 2023 10:01:42 +0000 (+0100) Subject: virt/coco/sev-guest: Check SEV_SNP attribute at probe time X-Git-Tag: baikal/mips/sdk6.1~12 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=68a23b0fa2e3688e162e8f1102e145c03ef1c26b;p=kernel.git virt/coco/sev-guest: Check SEV_SNP attribute at probe time commit 7d93816303e99668d547b9e165b2dc51cea43a54 upstream. No need to check it on every ioctl. And yes, this is a common SEV driver but it does only SNP-specific operations currently. This can be revisited later, when more use cases appear. No functional changes. Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Tom Lendacky Link: https://lore.kernel.org/r/20230307192449.24732-3-bp@alien8.de Signed-off-by: Greg Kroah-Hartman --- diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c index a428c62330d37..2e739b0b75331 100644 --- a/arch/x86/kernel/sev.c +++ b/arch/x86/kernel/sev.c @@ -2183,9 +2183,6 @@ int snp_issue_guest_request(u64 exit_code, struct snp_req_data *input, unsigned struct ghcb *ghcb; int ret; - if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP)) - return -ENODEV; - if (!fw_err) return -EINVAL; diff --git a/drivers/virt/coco/sev-guest/sev-guest.c b/drivers/virt/coco/sev-guest/sev-guest.c index 6de888bce1bb1..57089c092d8a3 100644 --- a/drivers/virt/coco/sev-guest/sev-guest.c +++ b/drivers/virt/coco/sev-guest/sev-guest.c @@ -705,6 +705,9 @@ static int __init sev_guest_probe(struct platform_device *pdev) void __iomem *mapping; int ret; + if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP)) + return -ENODEV; + if (!dev->platform_data) return -ENODEV;