[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 22/45] i386/sev: Add a sev_snp_enabled() helper
From: |
Paolo Bonzini |
Subject: |
[PULL 22/45] i386/sev: Add a sev_snp_enabled() helper |
Date: |
Tue, 4 Jun 2024 08:43:46 +0200 |
From: Michael Roth <michael.roth@amd.com>
Add a simple helper to check if the current guest type is SNP. Also have
SNP-enabled imply that SEV-ES is enabled as well, and fix up any places
where the sev_es_enabled() check is expecting a pure/non-SNP guest.
Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-9-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/i386/sev.h | 2 ++
target/i386/sev.c | 13 ++++++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/target/i386/sev.h b/target/i386/sev.h
index bedc667eeba..94295ee74f7 100644
--- a/target/i386/sev.h
+++ b/target/i386/sev.h
@@ -45,9 +45,11 @@ typedef struct SevKernelLoaderContext {
#ifdef CONFIG_SEV
bool sev_enabled(void);
bool sev_es_enabled(void);
+bool sev_snp_enabled(void);
#else
#define sev_enabled() 0
#define sev_es_enabled() 0
+#define sev_snp_enabled() 0
#endif
uint32_t sev_get_cbit_position(void);
diff --git a/target/i386/sev.c b/target/i386/sev.c
index a81b3228d4c..4edfedc1393 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -325,12 +325,21 @@ sev_enabled(void)
return !!object_dynamic_cast(OBJECT(cgs), TYPE_SEV_COMMON);
}
+bool
+sev_snp_enabled(void)
+{
+ ConfidentialGuestSupport *cgs = MACHINE(qdev_get_machine())->cgs;
+
+ return !!object_dynamic_cast(OBJECT(cgs), TYPE_SEV_SNP_GUEST);
+}
+
bool
sev_es_enabled(void)
{
ConfidentialGuestSupport *cgs = MACHINE(qdev_get_machine())->cgs;
- return sev_enabled() && (SEV_GUEST(cgs)->policy & SEV_POLICY_ES);
+ return sev_snp_enabled() ||
+ (sev_enabled() && SEV_GUEST(cgs)->policy & SEV_POLICY_ES);
}
uint32_t
@@ -946,7 +955,9 @@ static int sev_kvm_init(ConfidentialGuestSupport *cgs,
Error **errp)
"support", __func__);
goto err;
}
+ }
+ if (sev_es_enabled() && !sev_snp_enabled()) {
if (!(status.flags & SEV_STATUS_FLAGS_CONFIG_ES)) {
error_setg(errp, "%s: guest policy requires SEV-ES, but "
"host SEV-ES support unavailable",
--
2.45.1
- [PULL 14/45] linux-headers: Update to current kvm/next, (continued)
- [PULL 14/45] linux-headers: Update to current kvm/next, Paolo Bonzini, 2024/06/04
- [PULL 15/45] update-linux-headers: import linux/kvm_para.h header, Paolo Bonzini, 2024/06/04
- [PULL 16/45] machine: allow early use of machine_require_guest_memfd, Paolo Bonzini, 2024/06/04
- [PULL 17/45] i386/sev: Replace error_report with error_setg, Paolo Bonzini, 2024/06/04
- [PULL 18/45] i386/sev: Introduce "sev-common" type to encapsulate common SEV state, Paolo Bonzini, 2024/06/04
- [PULL 19/45] i386/sev: Move sev_launch_update to separate class method, Paolo Bonzini, 2024/06/04
- [PULL 20/45] i386/sev: Move sev_launch_finish to separate class method, Paolo Bonzini, 2024/06/04
- [PULL 21/45] i386/sev: Introduce 'sev-snp-guest' object, Paolo Bonzini, 2024/06/04
- [PULL 22/45] i386/sev: Add a sev_snp_enabled() helper,
Paolo Bonzini <=
- [PULL 23/45] i386/sev: Add sev_kvm_init() override for SEV class, Paolo Bonzini, 2024/06/04
- [PULL 24/45] i386/sev: Add snp_kvm_init() override for SNP class, Paolo Bonzini, 2024/06/04
- [PULL 27/45] i386/sev: Add a class method to determine KVM VM type for SNP guests, Paolo Bonzini, 2024/06/04
- [PULL 32/45] hw/i386/sev: Add function to get SEV metadata from OVMF header, Paolo Bonzini, 2024/06/04
- [PULL 41/45] i386/sev: Reorder struct declarations, Paolo Bonzini, 2024/06/04
- [PULL 30/45] i386/sev: Add handling to encrypt/finalize guest launch data, Paolo Bonzini, 2024/06/04
- [PULL 26/45] i386/sev: Don't return launch measurements for SEV-SNP guests, Paolo Bonzini, 2024/06/04
- [PULL 25/45] i386/cpu: Set SEV-SNP CPUID bit when SNP enabled, Paolo Bonzini, 2024/06/04
- [PULL 34/45] i386/sev: Add support for SNP CPUID validation, Paolo Bonzini, 2024/06/04