Skip to content

Commit 8c4182b

Browse files
committed
KVM: VMX: optimize #PF injection when MAXPHYADDR does not match
Ignore non-present page faults, since those cannot have reserved bits set. When running access.flat with "-cpu Haswell,phys-bits=36", the number of trapped page faults goes down from 8872644 to 3978948. Signed-off-by: Paolo Bonzini <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 1dbf5d6 commit 8c4182b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

arch/x86/kvm/vmx/vmx.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4355,6 +4355,16 @@ static void init_vmcs(struct vcpu_vmx *vmx)
43554355
vmx->pt_desc.guest.output_mask = 0x7F;
43564356
vmcs_write64(GUEST_IA32_RTIT_CTL, 0);
43574357
}
4358+
4359+
/*
4360+
* If EPT is enabled, #PF is only trapped if MAXPHYADDR is mismatched
4361+
* between guest and host. In that case we only care about present
4362+
* faults.
4363+
*/
4364+
if (enable_ept) {
4365+
vmcs_write32(PAGE_FAULT_ERROR_CODE_MASK, PFERR_PRESENT_MASK);
4366+
vmcs_write32(PAGE_FAULT_ERROR_CODE_MATCH, PFERR_PRESENT_MASK);
4367+
}
43584368
}
43594369

43604370
static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)

0 commit comments

Comments
 (0)