i386/sev: Add a sev_snp_enabled() helper
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>
This commit is contained in:
parent
7b34df4426
commit
99190f805d
@ -325,12 +325,21 @@ sev_enabled(void)
|
|||||||
return !!object_dynamic_cast(OBJECT(cgs), TYPE_SEV_COMMON);
|
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
|
bool
|
||||||
sev_es_enabled(void)
|
sev_es_enabled(void)
|
||||||
{
|
{
|
||||||
ConfidentialGuestSupport *cgs = MACHINE(qdev_get_machine())->cgs;
|
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
|
uint32_t
|
||||||
@ -946,7 +955,9 @@ static int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
|
|||||||
"support", __func__);
|
"support", __func__);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sev_es_enabled() && !sev_snp_enabled()) {
|
||||||
if (!(status.flags & SEV_STATUS_FLAGS_CONFIG_ES)) {
|
if (!(status.flags & SEV_STATUS_FLAGS_CONFIG_ES)) {
|
||||||
error_setg(errp, "%s: guest policy requires SEV-ES, but "
|
error_setg(errp, "%s: guest policy requires SEV-ES, but "
|
||||||
"host SEV-ES support unavailable",
|
"host SEV-ES support unavailable",
|
||||||
|
@ -45,9 +45,11 @@ typedef struct SevKernelLoaderContext {
|
|||||||
#ifdef CONFIG_SEV
|
#ifdef CONFIG_SEV
|
||||||
bool sev_enabled(void);
|
bool sev_enabled(void);
|
||||||
bool sev_es_enabled(void);
|
bool sev_es_enabled(void);
|
||||||
|
bool sev_snp_enabled(void);
|
||||||
#else
|
#else
|
||||||
#define sev_enabled() 0
|
#define sev_enabled() 0
|
||||||
#define sev_es_enabled() 0
|
#define sev_es_enabled() 0
|
||||||
|
#define sev_snp_enabled() 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t sev_get_cbit_position(void);
|
uint32_t sev_get_cbit_position(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user