Skip to contentSkip to conversation

KVM: vmx: Advance rip to after an ICEBP instruction.

PATCH Superseded Huw Davies 2 participants 2 messages Apr 15, 2014

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Huw Davies

author
#0 lore raw

PATCH 1/1 KVM: vmx: Advance rip to after an ICEBP instruction.

When entering an exception after an ICEBP, the saved instruction pointer should point to after the instruction.

This fixes the bug here: https://bugs.launchpad.net/qemu/+bug/1119686

---
 arch/x86/kvm/vmx.c | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/kvm/vmx.c +3 -0
index 1f68c58..4c41d7a 100644
@@ -4841,6 +4841,9 @@ static int handle_exception(struct kvm_vcpu *vcpu)
 		      (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))) {
 			vcpu->arch.dr6 &= ~15;
 			vcpu->arch.dr6 |= dr6;
+			if (dr6 == 0) /* icebp */
+				skip_emulated_instruction(vcpu);
+
 			kvm_queue_exception(vcpu, DB_VECTOR);
 			return 1;
 		}
Signature · 1 line
1.8.0
#1 lore raw
Quoted 15 lines · Huw Davies

When entering an exception after an ICEBP, the saved instruction pointer should point to after the instruction.

This fixes the bug here: https://bugs.launchpad.net/qemu/+bug/1119686

---
 arch/x86/kvm/vmx.c | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/kvm/vmx.c +0 -0
index 1f68c58..4c41d7a 100644

arch/x86/kvm/vmx.c static int handle_exception(struct kvm_vcpu *vcpu) · line 4844

Quoted 4 lines
arch/x86/kvm/vmx.c +1 -0
@@ -4841,6 +4841,9 @@ static int handle_exception(struct kvm_vcpu *vcpu)
 		      (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))) {
 			vcpu->arch.dr6 &= ~15;
 			vcpu->arch.dr6 |= dr6;
+			if (dr6 == 0) /* icebp */

In arch/x86/kernel/traps.c, DR6_RESERVED is first masked out before testing the result against 0 - that's probably more robust here, too.

Jan

Quoted 6 lines
arch/x86/kvm/vmx.c +2 -0
+				skip_emulated_instruction(vcpu);
+
 			kvm_queue_exception(vcpu, DB_VECTOR);
 			return 1;
 		}
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux