|
28 | 28 | int kvm_fd;
|
29 | 29 | u64 supported_vmsa_features;
|
30 | 30 | bool have_sev_es;
|
| 31 | +bool have_snp; |
31 | 32 |
|
32 | 33 | static int __sev_ioctl(int vm_fd, int cmd_id, void *data)
|
33 | 34 | {
|
@@ -83,6 +84,9 @@ void test_vm_types(void)
|
83 | 84 | if (have_sev_es)
|
84 | 85 | test_init2(KVM_X86_SEV_ES_VM, &(struct kvm_sev_init){});
|
85 | 86 |
|
| 87 | + if (have_snp) |
| 88 | + test_init2(KVM_X86_SNP_VM, &(struct kvm_sev_init){}); |
| 89 | + |
86 | 90 | test_init2_invalid(0, &(struct kvm_sev_init){},
|
87 | 91 | "VM type is KVM_X86_DEFAULT_VM");
|
88 | 92 | if (kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SW_PROTECTED_VM))
|
@@ -138,15 +142,24 @@ int main(int argc, char *argv[])
|
138 | 142 | "sev-es: KVM_CAP_VM_TYPES (%x) does not match cpuid (checking %x)",
|
139 | 143 | kvm_check_cap(KVM_CAP_VM_TYPES), 1 << KVM_X86_SEV_ES_VM);
|
140 | 144 |
|
| 145 | + have_snp = kvm_cpu_has(X86_FEATURE_SEV_SNP); |
| 146 | + TEST_ASSERT(have_snp == !!(kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SNP_VM)), |
| 147 | + "sev-snp: KVM_CAP_VM_TYPES (%x) indicates SNP support (bit %d), but CPUID does not", |
| 148 | + kvm_check_cap(KVM_CAP_VM_TYPES), KVM_X86_SNP_VM); |
| 149 | + |
141 | 150 | test_vm_types();
|
142 | 151 |
|
143 | 152 | test_flags(KVM_X86_SEV_VM);
|
144 | 153 | if (have_sev_es)
|
145 | 154 | test_flags(KVM_X86_SEV_ES_VM);
|
| 155 | + if (have_snp) |
| 156 | + test_flags(KVM_X86_SNP_VM); |
146 | 157 |
|
147 | 158 | test_features(KVM_X86_SEV_VM, 0);
|
148 | 159 | if (have_sev_es)
|
149 | 160 | test_features(KVM_X86_SEV_ES_VM, supported_vmsa_features);
|
| 161 | + if (have_snp) |
| 162 | + test_features(KVM_X86_SNP_VM, supported_vmsa_features); |
150 | 163 |
|
151 | 164 | return 0;
|
152 | 165 | }
|
0 commit comments