vm_type
u8 vm_type;
return kvm->arch.vm_type == KVM_X86_TDX_VM;
if (vcpu->kvm->arch.vm_type == KVM_X86_TDX_VM)
vcpu->kvm->arch.vm_type == KVM_X86_SW_PROTECTED_VM &&
return kvm->arch.vm_type == KVM_X86_DEFAULT_VM &&
if (kvm->arch.vm_type == KVM_X86_TDX_VM)
if (vcpu->kvm->arch.vm_type != KVM_X86_DEFAULT_VM) {
if (kvm->arch.vm_type != source_kvm->arch.vm_type ||
static int sev_asid_new(struct kvm_sev_info *sev, unsigned long vm_type)
if (vm_type == KVM_X86_SNP_VM) {
switch (kvm->arch.vm_type) {
WARN_ONCE(1, "Unsupported VM type %u", kvm->arch.vm_type);
unsigned long vm_type)
bool es_active = vm_type != KVM_X86_SEV_VM;
bool snp_active = vm_type == KVM_X86_SNP_VM;
ret = sev_asid_new(sev, vm_type);
unsigned long vm_type;
if (kvm->arch.vm_type != KVM_X86_DEFAULT_VM)
vm_type = (argp->id == KVM_SEV_INIT ? KVM_X86_SEV_VM : KVM_X86_SEV_ES_VM);
if (vm_type == KVM_X86_SEV_ES_VM)
return __sev_guest_init(kvm, argp, &data, vm_type);
if (kvm->arch.vm_type != KVM_X86_SEV_VM &&
kvm->arch.vm_type != KVM_X86_SEV_ES_VM &&
kvm->arch.vm_type != KVM_X86_SNP_VM)
return __sev_guest_init(kvm, argp, &data, kvm->arch.vm_type);
char *vm_type;
vm_type = is_sev_snp_guest(vcpu) ? "SEV-SNP" :
vm_type, vcpu->vcpu_id, svm->current_vmcb->ptr, vcpu->arch.last_vmentry_cpu);
return kvm->arch.vm_type == KVM_X86_TDX_VM;
kvm->arch.vm_type = type;
enum vm_type *vm_type;
vm_type = hnode->ptr;
if (*vm_type == VM_TYPE_USERPTR) {
enum vm_type *vm_type;
vm_type = hnode->ptr;
if (*vm_type == VM_TYPE_USERPTR) {
enum vm_type *vm_type;
vm_type = hnode->ptr;
if (((*vm_type == VM_TYPE_USERPTR) && is_pmmu) ||
((*vm_type == VM_TYPE_PHYS_PACK) && !is_pmmu))
vm_type = hnode->ptr;
if ((*vm_type == VM_TYPE_USERPTR) && (is_pmmu)) {
} else if ((*vm_type == VM_TYPE_PHYS_PACK) && (!is_pmmu)) {
enum vm_type vm_type; /* must be first */
enum vm_type vm_type; /* must be first */
enum vm_type *vm_type;
vm_type = (enum vm_type *) userptr;
vm_type = (enum vm_type *) phys_pg_pack;
rc = hl_mmu_invalidate_cache_range(hdev, false, *vm_type | MMU_OP_SKIP_LOW_CACHE_INV,
rc = hl_mmu_prefetch_cache_range(ctx, *vm_type, ctx->asid, ret_vaddr,
hnode->ptr = vm_type;
enum vm_type *vm_type;
vm_type = hnode->ptr;
if (*vm_type == VM_TYPE_USERPTR) {
} else if (*vm_type == VM_TYPE_PHYS_PACK) {
phys_pg_pack->vm_type = VM_TYPE_PHYS_PACK;
rc = hl_mmu_invalidate_cache_range(hdev, true, *vm_type, ctx->asid, vaddr,
if (phys_pg_pack->vm_type != VM_TYPE_PHYS_PACK) {
userptr->vm_type = VM_TYPE_USERPTR;
phys_pg_pack->vm_type = userptr->vm_type;
static void test_guest_memfd(unsigned long vm_type)
struct kvm_vm *vm = vm_create_barebones_type(vm_type);
unsigned long vm_types, vm_type;
for_each_set_bit(vm_type, &vm_types, BITS_PER_TYPE(vm_types))
test_guest_memfd(vm_type);
static void __test_pre_fault_memory(unsigned long vm_type, bool private)
.type = vm_type,
static void test_pre_fault_memory(unsigned long vm_type, bool private)
if (vm_type && !(kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(vm_type))) {
pr_info("Skipping tests for vm_type 0x%lx\n", vm_type);
__test_pre_fault_memory(vm_type, private);
test_init2_invalid(vm_type,
void test_features(u32 vm_type, u64 supported_features)
test_init2_invalid(vm_type,
test_init2(vm_type,
static void test_init2(unsigned long vm_type, struct kvm_sev_init *init)
vm = vm_create_barebones_type(vm_type);
static void test_init2_invalid(unsigned long vm_type, struct kvm_sev_init *init, const char *msg)
vm = vm_create_barebones_type(vm_type);
void test_flags(u32 vm_type)