From: Sean Christopherson Date: Wed, 2 Feb 2022 00:49:45 +0000 (+0000) Subject: KVM: x86: Bail to userspace if emulation of atomic user access faults X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=5d6c7de6446e9ab3fb41d6f7d82770e50998f3de;p=linux.git KVM: x86: Bail to userspace if emulation of atomic user access faults 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 Message-Id: <20220202004945.2540433-6-seanjc@google.com> Signed-off-by: Paolo Bonzini --- diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index e5b0dd24b200a..4e7f3a8da16a6 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -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;