Skip to content

Commit cfb634f

Browse files
jsmattsonjrbonzini
authored andcommitted
KVM: nVMX: Clear reserved bits of #DB exit qualification
According to volume 3 of the SDM, bits 63:15 and 12:4 of the exit qualification field for debug exceptions are reserved (cleared to 0). However, the SDM is incorrect about bit 16 (corresponding to DR6.RTM). This bit should be set if a debug exception (#DB) or a breakpoint exception (#BP) occurred inside an RTM region while advanced debugging of RTM transactional regions was enabled. Note that this is the opposite of DR6.RTM, which "indicates (when clear) that a debug exception (#DB) or breakpoint exception (#BP) occurred inside an RTM region while advanced debugging of RTM transactional regions was enabled." There is still an issue with stale DR6 bits potentially being misreported for the current debug exception. DR6 should not have been modified before vectoring the #DB exception, and the "new DR6 bits" should be available somewhere, but it was and they aren't. Fixes: b96fb43 ("KVM: nVMX: fixes to nested virt interrupt injection") Signed-off-by: Jim Mattson <[email protected]> Reviewed-by: Sean Christopherson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 5b8ee87 commit cfb634f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ enum {
177177

178178
#define DR6_BD (1 << 13)
179179
#define DR6_BS (1 << 14)
180+
#define DR6_BT (1 << 15)
180181
#define DR6_RTM (1 << 16)
181182
#define DR6_FIXED_1 0xfffe0ff0
182183
#define DR6_INIT 0xffff0ff0

arch/x86/kvm/vmx.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3290,10 +3290,13 @@ static int nested_vmx_check_exception(struct kvm_vcpu *vcpu, unsigned long *exit
32903290
}
32913291
} else {
32923292
if (vmcs12->exception_bitmap & (1u << nr)) {
3293-
if (nr == DB_VECTOR)
3293+
if (nr == DB_VECTOR) {
32943294
*exit_qual = vcpu->arch.dr6;
3295-
else
3295+
*exit_qual &= ~(DR6_FIXED_1 | DR6_BT);
3296+
*exit_qual ^= DR6_RTM;
3297+
} else {
32963298
*exit_qual = 0;
3299+
}
32973300
return 1;
32983301
}
32993302
}

0 commit comments

Comments
 (0)