KVM: VMX: update PFEC_MASK/PFEC_MATCH together with PF intercept
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 29 Sep 2020 12:31:32 +0000 (08:31 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 3 Oct 2020 09:07:40 +0000 (05:07 -0400)
commitb502e6ecdc3b6d381bd72c5f879bc1e00d6fe7db
treeee7378f38763f315a253ef615ea26cc163c41bed
parent4bb05f30483fd21ea5413eaf1182768f251cf625
KVM: VMX: update PFEC_MASK/PFEC_MATCH together with PF intercept

The PFEC_MASK and PFEC_MATCH fields in the VMCS reverse the meaning of
the #PF intercept bit in the exception bitmap when they do not match.
This means that, if PFEC_MASK and/or PFEC_MATCH are set, the
hypervisor can get a vmexit for #PF exceptions even when the
corresponding bit is clear in the exception bitmap.

This is unexpected and is promptly detected by a WARN_ON_ONCE.
To fix it, reset PFEC_MASK and PFEC_MATCH when the #PF intercept
is disabled (as is common with enable_ept && !allow_smaller_maxphyaddr).

Reported-by: Qian Cai <cai@redhat.com>>
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/vmx.c