[tip:,x86/urgent] virt/coco/sev-guest: Check SEV_SNP attribute at probe time

Message ID 167871229135.5837.1913962659795610718.tip-bot2@tip-bot2
State New
Headers
Series [tip:,x86/urgent] virt/coco/sev-guest: Check SEV_SNP attribute at probe time |

Commit Message

tip-bot2 for Thomas Gleixner March 13, 2023, 12:58 p.m. UTC
  The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     d6fd48eff7506bb866a54e40369df8899f2078a9
Gitweb:        https://git.kernel.org/tip/d6fd48eff7506bb866a54e40369df8899f2078a9
Author:        Borislav Petkov (AMD) <bp@alien8.de>
AuthorDate:    Wed, 15 Feb 2023 11:01:42 +01:00
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 13 Mar 2023 11:20:20 +01:00

virt/coco/sev-guest: Check SEV_SNP attribute at probe time

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
---
 arch/x86/kernel/sev.c                   | 3 ---
 drivers/virt/coco/sev-guest/sev-guest.c | 3 +++
 2 files changed, 3 insertions(+), 3 deletions(-)
  

Patch

diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c
index 679026a..c644c34 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 7b4e900..ed5d6ae 100644
--- a/drivers/virt/coco/sev-guest/sev-guest.c
+++ b/drivers/virt/coco/sev-guest/sev-guest.c
@@ -703,6 +703,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;