Skip to content

Commit 19d5f10

Browse files
ekorenevskybonzini
authored andcommitted
KVM: nVMX: consult PFEC_MASK and PFEC_MATCH when generating #PF VM-exit
When generating #PF VM-exit, check equality: (PFEC & PFEC_MASK) == PFEC_MATCH If there is equality, the 14 bit of exception bitmap is used to take decision about generating #PF VM-exit. If there is inequality, inverted 14 bit is used. Signed-off-by: Eugene Korenevsky <ekorenevsky@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent e9ac033 commit 19d5f10

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

arch/x86/kvm/vmx.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8206,15 +8206,26 @@ static void nested_ept_uninit_mmu_context(struct kvm_vcpu *vcpu)
82068206
vcpu->arch.walk_mmu = &vcpu->arch.mmu;
82078207
}
82088208

8209+
static bool nested_vmx_is_page_fault_vmexit(struct vmcs12 *vmcs12,
8210+
u16 error_code)
8211+
{
8212+
bool inequality, bit;
8213+
8214+
bit = (vmcs12->exception_bitmap & (1u << PF_VECTOR)) != 0;
8215+
inequality =
8216+
(error_code & vmcs12->page_fault_error_code_mask) !=
8217+
vmcs12->page_fault_error_code_match;
8218+
return inequality ^ bit;
8219+
}
8220+
82098221
static void vmx_inject_page_fault_nested(struct kvm_vcpu *vcpu,
82108222
struct x86_exception *fault)
82118223
{
82128224
struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
82138225

82148226
WARN_ON(!is_guest_mode(vcpu));
82158227

8216-
/* TODO: also check PFEC_MATCH/MASK, not just EB.PF. */
8217-
if (vmcs12->exception_bitmap & (1u << PF_VECTOR))
8228+
if (nested_vmx_is_page_fault_vmexit(vmcs12, fault->error_code))
82188229
nested_vmx_vmexit(vcpu, to_vmx(vcpu)->exit_reason,
82198230
vmcs_read32(VM_EXIT_INTR_INFO),
82208231
vmcs_readl(EXIT_QUALIFICATION));

0 commit comments

Comments
 (0)