Skip to content

Commit

Permalink
KVM: nVMX: Clear reserved bits of #DB exit qualification
Browse files Browse the repository at this point in the history
[ Upstream commit cfb634f ]

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]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
jsmattsonjr authored and gregkh committed Nov 13, 2018
1 parent be5658a commit 7d6c6f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions arch/x86/include/asm/kvm_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ enum {

#define DR6_BD (1 << 13)
#define DR6_BS (1 << 14)
#define DR6_BT (1 << 15)
#define DR6_RTM (1 << 16)
#define DR6_FIXED_1 0xfffe0ff0
#define DR6_INIT 0xffff0ff0
Expand Down
7 changes: 5 additions & 2 deletions arch/x86/kvm/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2733,10 +2733,13 @@ static int nested_vmx_check_exception(struct kvm_vcpu *vcpu, unsigned long *exit
}
} else {
if (vmcs12->exception_bitmap & (1u << nr)) {
if (nr == DB_VECTOR)
if (nr == DB_VECTOR) {
*exit_qual = vcpu->arch.dr6;
else
*exit_qual &= ~(DR6_FIXED_1 | DR6_BT);
*exit_qual ^= DR6_RTM;
} else {
*exit_qual = 0;
}
return 1;
}
}
Expand Down

0 comments on commit 7d6c6f8

Please sign in to comment.