Skip to content

Commit

Permalink
KVM: x86: Bail to userspace if emulation of atomic user access faults
Browse files Browse the repository at this point in the history
Exit to userspace when emulating an atomic guest access if the CMPXCHG on
the userspace address faults.  Emulating the access as a write and thus
likely treating it as emulated MMIO is wrong, as KVM has already
confirmed there is a valid, writable memslot.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20220202004945.2540433-6-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Sean Christopherson authored and Paolo Bonzini committed Apr 13, 2022
1 parent 1c2361f commit 5d6c7de
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -7319,7 +7319,7 @@ static int emulator_cmpxchg_emulated(struct x86_emulate_ctxt *ctxt,
}

if (r < 0)
goto emul_write;
return X86EMUL_UNHANDLEABLE;
if (r)
return X86EMUL_CMPXCHG_FAILED;

Expand Down

0 comments on commit 5d6c7de

Please sign in to comment.