Skip to contentSkip to conversation

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

PATCH In review Huw Davies 3 participants 3 messages Apr 16, 2014 – Apr 28, 2014

Subsystems (3)
lore
Share & tools
lore

Huw Davies

author
#0 lore raw

PATCH v2 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

---
v2: Mask off DR6_RESERVED before comparing to zero.

 arch/x86/kvm/vmx.c | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/kvm/vmx.c +3 -0
index 1f68c58..930a0df 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 & ~DR6_RESERVED)) /* icebp */
+				skip_emulated_instruction(vcpu);
+
 			kvm_queue_exception(vcpu, DB_VECTOR);
 			return 1;
 		}
Signature · 1 line
1.8.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 19 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

---
v2: Mask off DR6_RESERVED before comparing to zero.

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

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

Quoted 9 lines
arch/x86/kvm/vmx.c +3 -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 & ~DR6_RESERVED)) /* icebp */
+				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
maintainer
#2 lore raw
In reply to Huw Davies

Il 16/04/2014 11:02, Huw Davies ha scritto:

Quoted 19 lines

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

---
v2: Mask off DR6_RESERVED before comparing to zero.

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

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

Quoted 9 lines
arch/x86/kvm/vmx.c +3 -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 & ~DR6_RESERVED)) /* icebp */
+				skip_emulated_instruction(vcpu);
+
 			kvm_queue_exception(vcpu, DB_VECTOR);
 			return 1;
 		}

This was applied to kvm/next by Marcelo. Thanks for contributing to KVM!

Paolo