]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.173/kvm-x86-fix-single-step-debugging.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.173 / kvm-x86-fix-single-step-debugging.patch
1 From 5cc244a20b86090c087073c124284381cdf47234 Mon Sep 17 00:00:00 2001
2 From: Alexander Popov <alex.popov@linux.com>
3 Date: Mon, 21 Jan 2019 15:48:40 +0300
4 Subject: KVM: x86: Fix single-step debugging
5
6 From: Alexander Popov <alex.popov@linux.com>
7
8 commit 5cc244a20b86090c087073c124284381cdf47234 upstream.
9
10 The single-step debugging of KVM guests on x86 is broken: if we run
11 gdb 'stepi' command at the breakpoint when the guest interrupts are
12 enabled, RIP always jumps to native_apic_mem_write(). Then other
13 nasty effects follow.
14
15 Long investigation showed that on Jun 7, 2017 the
16 commit c8401dda2f0a00cd25c0 ("KVM: x86: fix singlestepping over syscall")
17 introduced the kvm_run.debug corruption: kvm_vcpu_do_singlestep() can
18 be called without X86_EFLAGS_TF set.
19
20 Let's fix it. Please consider that for -stable.
21
22 Signed-off-by: Alexander Popov <alex.popov@linux.com>
23 Cc: stable@vger.kernel.org
24 Fixes: c8401dda2f0a00cd25c0 ("KVM: x86: fix singlestepping over syscall")
25 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27
28 ---
29 arch/x86/kvm/x86.c | 3 +--
30 1 file changed, 1 insertion(+), 2 deletions(-)
31
32 --- a/arch/x86/kvm/x86.c
33 +++ b/arch/x86/kvm/x86.c
34 @@ -5524,8 +5524,7 @@ restart:
35 toggle_interruptibility(vcpu, ctxt->interruptibility);
36 vcpu->arch.emulate_regs_need_sync_to_vcpu = false;
37 kvm_rip_write(vcpu, ctxt->eip);
38 - if (r == EMULATE_DONE &&
39 - (ctxt->tf || (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)))
40 + if (r == EMULATE_DONE && ctxt->tf)
41 kvm_vcpu_do_singlestep(vcpu, &r);
42 if (!ctxt->have_exception ||
43 exception_type(ctxt->exception.vector) == EXCPT_TRAP)