]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: Reenter guest after emulation failure if due to access to non-mmio address
authorGleb Natapov <gleb@redhat.com>
Thu, 8 Jul 2010 09:41:12 +0000 (12:41 +0300)
committerAvi Kivity <avi@redhat.com>
Mon, 2 Aug 2010 03:40:34 +0000 (06:40 +0300)
commit69f48bae98e5c803d28a1e9e065d5bfba79f2ff6
tree440f44a7cad040393067c6aca37d2d9e013b155e
parent3a68cbaea25e54076688e3a82b9c35c084e66a35
KVM: Reenter guest after emulation failure if due to access to non-mmio address

When shadow pages are in use sometimes KVM try to emulate an instruction
when it accesses a shadowed page. If emulation fails KVM un-shadows the
page and reenter guest to allow vcpu to execute the instruction. If page
is not in shadow page hash KVM assumes that this was attempt to do MMIO
and reports emulation failure to userspace since there is no way to fix
the situation. This logic has a race though. If two vcpus tries to write
to the same shadowed page simultaneously both will enter emulator, but
only one of them will find the page in shadow page hash since the one who
founds it also removes it from there, so another cpu will report failure
to userspace and will abort the guest.

Fix this by checking (in addition to checking shadowed page hash) that
page that caused the emulation belongs to valid memory slot. If it is
then reenter the guest to allow vcpu to reexecute the instruction.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/x86.c