Skip to content

Commit 384dea1

Browse files
franciozzybonzini
authored andcommitted
KVM: x86: respect singlestep when emulating instruction
When userspace configures KVM_GUESTDBG_SINGLESTEP, KVM will manage the presence of X86_EFLAGS_TF via kvm_set/get_rflags on vcpus. The actual rflag bit is therefore hidden from callers. That includes init_emulate_ctxt() which uses the value returned from kvm_get_flags() to set ctxt->tf. As a result, x86_emulate_instruction() will skip a single step, leaving singlestep_rip stale and not returning to userspace. This resolves the issue by observing the vcpu guest_debug configuration alongside ctxt->tf in x86_emulate_instruction(), performing the single step if set. Cc: [email protected] Signed-off-by: Felipe Franciosi <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 7e46477 commit 384dea1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kvm/x86.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7010,7 +7010,7 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
70107010
if (!ctxt->have_exception ||
70117011
exception_type(ctxt->exception.vector) == EXCPT_TRAP) {
70127012
kvm_rip_write(vcpu, ctxt->eip);
7013-
if (r && ctxt->tf)
7013+
if (r && (ctxt->tf || (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)))
70147014
r = kvm_vcpu_do_singlestep(vcpu);
70157015
if (kvm_x86_ops.update_emulated_instruction)
70167016
kvm_x86_ops.update_emulated_instruction(vcpu);

0 commit comments

Comments
 (0)