KVM: VMX: Fix exceptions of mov to dr
Injecting GP without an error code is a bad idea (causes unhandled guest exits). Moreover, we must not skip the instruction if we injected an exception. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
This commit is contained in:
parent
b60d513c32
commit
f248341529
1 changed files with 8 additions and 5 deletions
|
@ -3045,6 +3045,7 @@ static int handle_dr(struct kvm_vcpu *vcpu)
|
||||||
unsigned long val;
|
unsigned long val;
|
||||||
int dr, reg;
|
int dr, reg;
|
||||||
|
|
||||||
|
/* Do not handle if the CPL > 0, will trigger GP on re-entry */
|
||||||
if (!kvm_require_cpl(vcpu, 0))
|
if (!kvm_require_cpl(vcpu, 0))
|
||||||
return 1;
|
return 1;
|
||||||
dr = vmcs_readl(GUEST_DR7);
|
dr = vmcs_readl(GUEST_DR7);
|
||||||
|
@ -3099,20 +3100,22 @@ static int handle_dr(struct kvm_vcpu *vcpu)
|
||||||
vcpu->arch.eff_db[dr] = val;
|
vcpu->arch.eff_db[dr] = val;
|
||||||
break;
|
break;
|
||||||
case 4 ... 5:
|
case 4 ... 5:
|
||||||
if (kvm_read_cr4_bits(vcpu, X86_CR4_DE))
|
if (kvm_read_cr4_bits(vcpu, X86_CR4_DE)) {
|
||||||
kvm_queue_exception(vcpu, UD_VECTOR);
|
kvm_queue_exception(vcpu, UD_VECTOR);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
if (val & 0xffffffff00000000ULL) {
|
if (val & 0xffffffff00000000ULL) {
|
||||||
kvm_queue_exception(vcpu, GP_VECTOR);
|
kvm_inject_gp(vcpu, 0);
|
||||||
break;
|
return 1;
|
||||||
}
|
}
|
||||||
vcpu->arch.dr6 = (val & DR6_VOLATILE) | DR6_FIXED_1;
|
vcpu->arch.dr6 = (val & DR6_VOLATILE) | DR6_FIXED_1;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
if (val & 0xffffffff00000000ULL) {
|
if (val & 0xffffffff00000000ULL) {
|
||||||
kvm_queue_exception(vcpu, GP_VECTOR);
|
kvm_inject_gp(vcpu, 0);
|
||||||
break;
|
return 1;
|
||||||
}
|
}
|
||||||
vcpu->arch.dr7 = (val & DR7_VOLATILE) | DR7_FIXED_1;
|
vcpu->arch.dr7 = (val & DR7_VOLATILE) | DR7_FIXED_1;
|
||||||
if (!(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP)) {
|
if (!(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP)) {
|
||||||
|
|
Loading…
Reference in a new issue