lkml.org 
[lkml]   [2021]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    Subject[PATCH 1/2] KVM: x86/mmu: Use vCPU's APICv status when handling APIC_ACCESS memslot
    From
    Query the vCPU's APICv status, not the overall VM's status, when handling
    a page fault that hit the APIC Access Page memslot. If an APICv status
    update is pending, using the VM's status is non-deterministic as the
    initiating vCPU may or may not have updated overall VM's status. E.g. if
    a vCPU hits an APIC Access page fault with APICv disabled and a different
    vCPU is simultaneously performing an APICv update, the page fault handler
    will incorrectly skip the special APIC access page MMIO handling.

    Using the vCPU's status in the page fault handler is correct regardless
    of any pending APICv updates, as the vCPU's status is accurate with
    respect to the last VM-Enter, and thus reflects the context in which the
    page fault occurred.

    Cc: Maxim Levitsky <mlevitsk@redhat.com>
    Fixes: 9cc13d60ba6b ("KVM: x86/mmu: allow APICv memslot to be enabled but invisible")
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    ---
    arch/x86/kvm/mmu/mmu.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
    index 24a9f4c3f5e7..d36e205b90a5 100644
    --- a/arch/x86/kvm/mmu/mmu.c
    +++ b/arch/x86/kvm/mmu/mmu.c
    @@ -3853,7 +3853,7 @@ static bool kvm_faultin_pfn(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault,
    * when the AVIC is re-enabled.
    */
    if (slot && slot->id == APIC_ACCESS_PAGE_PRIVATE_MEMSLOT &&
    - !kvm_apicv_activated(vcpu->kvm)) {
    + !kvm_vcpu_apicv_active(vcpu)) {
    *r = RET_PF_EMULATE;
    return true;
    }
    --
    2.33.0.882.g93a45727a2-goog
    \
     
     \ /
      Last update: 2021-10-09 03:02    [W:4.109 / U:0.028 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site