Skip to contentSkip to conversation

KVM: x86: Fix guest single-stepping while interruptible

PATCH Applied Jan Kiszka 2 participants 2 messages Oct 18, 2009 – Oct 19, 2009

Subsystems (3)
lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 KVM: x86: Fix guest single-stepping while interruptible

Commit 705c5323 opened the doors of hell by unconditionally injecting single-step flags as long as guest_debug signaled this. This doesn't work when the guest branches into some interrupt or exception handler and triggers a vmexit with flag reloading.

Fix it by saving cs:rip when user space requests single-stepping and restricting the trace flag injection to this guest code position.

---

 arch/x86/include/asm/kvm_host.h |    4 +++
 arch/x86/kvm/x86.c              |   47 +++++++++++++++++++++++----------------
 2 files changed, 32 insertions(+), 19 deletions(-)
arch/x86/include/asm/kvm_host.h +4 -0
index 179a919..c6094f1 100644
@@ -371,6 +371,10 @@ struct kvm_vcpu_arch {
 	u64 mcg_status;
 	u64 mcg_ctl;
 	u64 *mce_banks;
+
+	/* used for guest single stepping over the given code position */
+	u16 singlestep_cs;
+	unsigned long singlestep_rip;
 };
 
 struct kvm_mem_alias {
arch/x86/kvm/x86.c +28 -19

65 lines not on this page · raw message

#1 lore raw
Quoted 8 lines · Jan Kiszka

Commit 705c5323 opened the doors of hell by unconditionally injecting single-step flags as long as guest_debug signaled this. This doesn't work when the guest branches into some interrupt or exception handler and triggers a vmexit with flag reloading.

Fix it by saving cs:rip when user space requests single-stepping and restricting the trace flag injection to this guest code position.

Quoted 6 lines

---

 arch/x86/include/asm/kvm_host.h |    4 +++
 arch/x86/kvm/x86.c              |   47 +++++++++++++++++++++++----------------
 2 files changed, 32 insertions(+), 19 deletions(-)

Applied, thanks.