Skip to content

Commit 2c19dba

Browse files
committed
KVM: nSVM: trap #DB and #BP to userspace if guest debugging is on
Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 449aa90 commit 2c19dba

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arch/x86/kvm/svm/nested.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,11 @@ static int nested_svm_intercept_db(struct vcpu_svm *svm)
608608
{
609609
unsigned long dr6;
610610

611+
/* Always catch it and pass it to userspace if debugging. */
612+
if (svm->vcpu.guest_debug &
613+
(KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))
614+
return NESTED_EXIT_HOST;
615+
611616
/* if we're not singlestepping, it's not ours */
612617
if (!svm->nmi_singlestep)
613618
return NESTED_EXIT_DONE;
@@ -682,6 +687,9 @@ static int nested_svm_intercept(struct vcpu_svm *svm)
682687
if (svm->nested.intercept_exceptions & excp_bits) {
683688
if (exit_code == SVM_EXIT_EXCP_BASE + DB_VECTOR)
684689
vmexit = nested_svm_intercept_db(svm);
690+
else if (exit_code == SVM_EXIT_EXCP_BASE + BP_VECTOR &&
691+
svm->vcpu.guest_debug & KVM_GUESTDBG_USE_SW_BP)
692+
vmexit = NESTED_EXIT_HOST;
685693
else
686694
vmexit = NESTED_EXIT_DONE;
687695
}

0 commit comments

Comments
 (0)