mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
KVM: selftests: Teach sev_*_test about revoking VM types
Instead of using CPUID, use the VM type bit to determine support, since those now reflect the correct status of support by the kernel and firmware configurations. Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org> Tested-by: Tycho Andersen (AMD) <tycho@kernel.org> Link: https://patch.msgid.link/20260416232329.3408497-8-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
d8355a92df
commit
accb7f3a63
|
|
@ -136,16 +136,14 @@ int main(int argc, char *argv[])
|
|||
kvm_check_cap(KVM_CAP_VM_TYPES), 1 << KVM_X86_SEV_VM);
|
||||
|
||||
TEST_REQUIRE(kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SEV_VM));
|
||||
have_sev_es = kvm_cpu_has(X86_FEATURE_SEV_ES);
|
||||
have_sev_es = kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SEV_ES_VM);
|
||||
|
||||
TEST_ASSERT(have_sev_es == !!(kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SEV_ES_VM)),
|
||||
"sev-es: KVM_CAP_VM_TYPES (%x) does not match cpuid (checking %x)",
|
||||
kvm_check_cap(KVM_CAP_VM_TYPES), 1 << KVM_X86_SEV_ES_VM);
|
||||
TEST_ASSERT(!have_sev_es || kvm_cpu_has(X86_FEATURE_SEV_ES),
|
||||
"sev-es: SEV_ES_VM supported without SEV_ES in CPUID");
|
||||
|
||||
have_snp = kvm_cpu_has(X86_FEATURE_SEV_SNP);
|
||||
TEST_ASSERT(have_snp == !!(kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SNP_VM)),
|
||||
"sev-snp: KVM_CAP_VM_TYPES (%x) indicates SNP support (bit %d), but CPUID does not",
|
||||
kvm_check_cap(KVM_CAP_VM_TYPES), KVM_X86_SNP_VM);
|
||||
have_snp = kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SNP_VM);
|
||||
TEST_ASSERT(!have_snp || kvm_cpu_has(X86_FEATURE_SEV_SNP),
|
||||
"sev-snp: SNP_VM supported without SEV_SNP in CPUID");
|
||||
|
||||
test_vm_types();
|
||||
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SEV));
|
||||
|
||||
have_sev_es = kvm_cpu_has(X86_FEATURE_SEV_ES);
|
||||
have_sev_es = kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SEV_ES_VM);
|
||||
|
||||
if (kvm_has_cap(KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM)) {
|
||||
test_sev_migrate_from(/* es= */ false);
|
||||
|
|
|
|||
|
|
@ -249,10 +249,10 @@ int main(int argc, char *argv[])
|
|||
|
||||
test_sev_smoke(guest_sev_code, KVM_X86_SEV_VM, 0);
|
||||
|
||||
if (kvm_cpu_has(X86_FEATURE_SEV_ES))
|
||||
if (kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SEV_ES_VM))
|
||||
test_sev_smoke(guest_sev_es_code, KVM_X86_SEV_ES_VM, SEV_POLICY_ES);
|
||||
|
||||
if (kvm_cpu_has(X86_FEATURE_SEV_SNP))
|
||||
if (kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SNP_VM))
|
||||
test_sev_smoke(guest_snp_code, KVM_X86_SNP_VM, snp_default_policy());
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user