Re: [PATCH v7 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor
From: David Hildenbrand
Date: Fri Aug 04 2017 - 10:42:12 EST
Looks very good to me now. :)
> /*
> @@ -7820,6 +7834,88 @@ static int handle_preemption_timer(struct kvm_vcpu *vcpu)
> return 1;
> }
>
> +static bool valid_ept_address(struct kvm_vcpu *vcpu, u64 address)
> +{
> + struct vcpu_vmx *vmx = to_vmx(vcpu);
> + u64 mask = address & 0x7;
> + int maxphyaddr = cpuid_maxphyaddr(vcpu);
> +
> + /* Check for memory type validity */
> + switch (mask) {
> + case 0:
> + if (!(vmx->nested.nested_vmx_ept_caps & VMX_EPTP_UC_BIT))
> + return false;
> + break;
> + case 6:
> + if (!(vmx->nested.nested_vmx_ept_caps & VMX_EPTP_WB_BIT))
> + return false;
> + break;
KVM always sets 6 without checking. But there is also a TODO left in
construct_eptp(). But we could hit this case probably only in very
strange environments (e.g. revoking it for our L1, so it cannot use WB
memory for L2). So we should be safe by requiring WB for now.