Skip to contentSkip to conversation

x86/debug: Verify DR6 is always empty on an INT1/ICEBP #DB

PATCH Applied Sean Christopherson 1 participant 2 messages May 14 – May 27 KVM

lore
Share & tools
lore

Sean Christopherson

author reviewer
#0 lore raw

PATCH 1/1 x86/debug: Verify DR6 is always empty on an INT1/ICEBP #DB

Extend the single-step + INT/ICEBP #DB testcase to verify that DR6.BS==0 on the ICEBP #DB, even when single-step is fully enabled. Per the SDM:

The INT1 instruction also uses a one-byte opcode (F1) and generates a debug exception (#DB) without setting any bits in DR6.

---
 x86/debug.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
x86/debug.c +7 -5
index 09f06ef5..36235370 100644
@@ -281,11 +281,12 @@ static noinline unsigned long singlestep_with_movss_blocking(void)
 static void report_singlestep_with_movss_blocking_and_icebp(unsigned long start,
 							    const char *usermode)
 {
-	report(n == 4 &&
+	report(n == 5 &&
 	       is_icebp_db(dr6[0]) && db_addr[0] == start &&
-	       is_single_step_db(dr6[1]) && db_addr[1] == start + 6 &&
-	       is_single_step_db(dr6[2]) && db_addr[2] == start + 6 + 1 &&
-	       is_single_step_db(dr6[3]) && db_addr[3] == start + 6 + 1 + 1,
+	       is_icebp_db(dr6[1]) && db_addr[1] == start + 1 &&
+	       is_single_step_db(dr6[2]) && db_addr[2] == start + 1 + 6 &&
+	       is_single_step_db(dr6[3]) && db_addr[3] == start + 1 + 6 + 1 &&
+	       is_single_step_db(dr6[4]) && db_addr[4] == start + 1 + 6 + 1 + 1,
 	       "%sSingle-Step + ICEBP #DB w/ MOVSS blocking", usermode);
 }
 
@@ -311,7 +312,8 @@ static noinline unsigned long singlestep_with_movss_blocking_and_icebp(void)
 		"popf\n\t"
 		"mov %%ax, %%ss\n\t"
 		".byte 0xf1;"
-		"1:and $~(1<<8),%%rax\n\t"
+		"1:.byte 0xf1;"
+		"and $~(1<<8),%%rax\n\t"
 		"push %%rax\n\t"
 		"popf\n\t"
 		"lea 1b(%%rip),%0\n\t"

base-commit: 9eb6c57313060d34f7e5b2ac6f90bb5873bbe2ff

Signature · 1 line
2.54.0.563.g4f69b47b94-goog
author reviewer Applied
#1 lore raw
Quoted 8 lines · Sean Christopherson

Extend the single-step + INT/ICEBP #DB testcase to verify that DR6.BS==0 on the ICEBP #DB, even when single-step is fully enabled. Per the SDM:

The INT1 instruction also uses a one-byte opcode (F1) and generates a debug exception (#DB) without setting any bits in DR6.

[...]

Applied to kvm-x86 next, thanks!

[1/1] x86/debug: Verify DR6 is always empty on an INT1/ICEBP #DB

      https://github.com/kvm-x86/kvm-unit-tests/commit/027ea799b859

--
https://github.com/kvm-x86/kvm-unit-tests/tree/next