On Mon, Sep 26, 2022, David Matlack wrote: > +bool kvm_vm_has_ept(struct kvm_vm *vm) > +{ > + struct kvm_vcpu *vcpu; > + uint64_t ctrl; > + > + vcpu = list_first_entry(&vm->vcpus, struct kvm_vcpu, list); > + TEST_ASSERT(vcpu, "Cannot determine EPT support without vCPUs.\n"); KVM_GET_MSRS is supported on /dev/kvm for feature MSRs, and is available for selftests via kvm_get_feature_msr(). > + > + ctrl = vcpu_get_msr(vcpu, MSR_IA32_VMX_TRUE_PROCBASED_CTLS) >> 32; > + if (!(ctrl & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS)) > + return false; > + > + ctrl = vcpu_get_msr(vcpu, MSR_IA32_VMX_PROCBASED_CTLS2) >> 32; > + return ctrl & SECONDARY_EXEC_ENABLE_EPT; > +} > + > void prepare_eptp(struct vmx_pages *vmx, struct kvm_vm *vm, > uint32_t eptp_memslot) > { > + TEST_REQUIRE(kvm_vm_has_ept(vm)); I would much rather this be an assert, i.e. force the test to do TEST_REQUIRE(), even if that means duplicate code. One of the roles of TEST_REQUIRE() is to document test requirements.