Re: [PATCH v2 09/11] KVM: SEV: define VM types for SEV and SEV-ES

From: Sean Christopherson
Date: Fri Feb 23 2024 - 12:23:08 EST


On Fri, Feb 23, 2024, Paolo Bonzini wrote:
> @@ -3193,3 +3199,16 @@ void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector)
>
> ghcb_set_sw_exit_info_2(svm->sev_es.ghcb, 1);
> }
> +
> +bool sev_is_vm_type_supported(unsigned long type)
> +{
> + if (type == KVM_X86_SEV_VM)
> + return sev_enabled;

Oh, I almost forgot! This is the perfect way to solve the mess where sev_enabled
is true, but all ASIDs are binned to SEV-ES[1], which sefltests doesn't currently
handle because the info isn't surfaced to userspace[2].

So it'll end up like this?

if (sev_enabled && min_sev_asid <= max_sev_asid)
kvm_caps.supported_vm_types |= BIT(KVM_X86_SEV_VM);

[1] https://lore.kernel.org/all/20240131235609.4161407-1-seanjc@xxxxxxxxxx
[2] https://lore.kernel.org/all/ZdfQ4jI8yT-bvbV4@xxxxxxxxxx

> + if (type == KVM_X86_SEV_ES_VM)
> + return sev_es_enabled;