virt/coco/sev-guest: Check SEV_SNP attribute at probe time
authorBorislav Petkov (AMD) <bp@alien8.de>
Wed, 15 Feb 2023 10:01:42 +0000 (11:01 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Mar 2023 12:34:05 +0000 (13:34 +0100)
commit d6fd48eff7506bb866a54e40369df8899f2078a9 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) <bp@alien8.de>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/r/20230307192449.24732-3-bp@alien8.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kernel/sev.c
drivers/virt/coco/sev-guest/sev-guest.c

index a428c62330d371a6742ada0a2e9e578dd3f1def6..2e739b0b75331fe9d5619bb6a6acc7360d0fc6a7 100644 (file)
@@ -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;
 
index 6de888bce1bb17652ec819f31a0eeab74a9f928b..57089c092d8a347c56099a05c9111516cf498f6f 100644 (file)
@@ -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;