]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86: always stop emulation on page fault
authorJan Dakinevich <jan.dakinevich@virtuozzo.com>
Tue, 27 Aug 2019 13:07:09 +0000 (13:07 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 11 Sep 2019 15:58:08 +0000 (17:58 +0200)
commit1d681356e8a587b52198e8a75ab4e6a3df398009
tree426b429da6ab334669cb97592cab7c0a3b954ce6
parent9f482adfea423b257b90843a2508bb195303014f
KVM: x86: always stop emulation on page fault

inject_emulated_exception() returns true if and only if nested page
fault happens. However, page fault can come from guest page tables
walk, either nested or not nested. In both cases we should stop an
attempt to read under RIP and give guest to step over its own page
fault handler.

This is also visible when an emulated instruction causes a #GP fault
and the VMware backdoor is enabled.  To handle the VMware backdoor,
KVM intercepts #GP faults; with only the next patch applied,
x86_emulate_instruction() injects a #GP but returns EMULATE_FAIL
instead of EMULATE_DONE.   EMULATE_FAIL causes handle_exception_nmi()
(or gp_interception() for SVM) to re-inject the original #GP because it
thinks emulation failed due to a non-VMware opcode.  This patch prevents
the issue as x86_emulate_instruction() will return EMULATE_DONE after
injecting the #GP.

Fixes: 2000e4acf214 ("KVM: x86: inject exceptions produced by x86_decode_insn")
Cc: stable@vger.kernel.org
Cc: Denis Lunev <den@virtuozzo.com>
Cc: Roman Kagan <rkagan@virtuozzo.com>
Cc: Denis Plotnikov <dplotnikov@virtuozzo.com>
Signed-off-by: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c