Skip to content
Snippets Groups Projects
Commit 8630b2f8 authored by Vitaly Kuznetsov's avatar Vitaly Kuznetsov
Browse files

KVM: X86: avoid uninitialized 'fault.async_page_fault' from fixed-up #PF

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2119111

commit 2bc685e6
Author: Yu Zhang <yu.c.zhang@linux.intel.com>
Date:   Mon Jul 18 15:47:56 2022 +0800

    KVM: X86: avoid uninitialized 'fault.async_page_fault' from fixed-up #PF

    kvm_fixup_and_inject_pf_error() was introduced to fixup the error code(
    e.g., to add RSVD flag) and inject the #PF to the guest, when guest
    MAXPHYADDR is smaller than the host one.

    When it comes to nested, L0 is expected to intercept and fix up the #PF
    and then inject to L2 directly if
    - L2.MAXPHYADDR < L0.MAXPHYADDR and
    - L1 has no intention to intercept L2's #PF (e.g., L2 and L1 have the
      same MAXPHYADDR value && L1 is using EPT for L2),
    instead of constructing a #PF VM Exit to L1. Currently, with PFEC_MASK
    and PFEC_MATCH both set to 0 in vmcs02, the interception and injection
    may happen on all L2 #PFs.

    However, failing to initialize 'fault' in kvm_fixup_and_inject_pf_error()
    may cause the fault.async_page_fault being NOT zeroed, and later the #PF
    being treated as a nested async page fault, and then being injected to L1.
    Instead of zeroing 'fault' at the beginning of this function, we mannually
    set the value of 'fault.async_page_fault', because false is the value we
    really expect.

    Fixes: 89786147 ("KVM: x86: Add helper functions for illegal GPA checking and page fault injection")
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=216178


Reported-by: default avatarYang Lixiao <lixiao.yang@intel.com>
Signed-off-by: default avatarYu Zhang <yu.c.zhang@linux.intel.com>
Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
    Message-Id: <20220718074756.53788-1-yu.c.zhang@linux.intel.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>

Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
parent 32c1c915
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment