Re: [PATCH] x86/bhi: BHI mitigation can trigger warning in #DB handler

From: Alexandre Chartre
Date: Thu May 23 2024 - 13:04:47 EST



On 5/23/24 17:36, Dave Hansen wrote:
On 5/23/24 07:52, Alexandre Chartre wrote:
Should we wrap up this gem and put it with the other entry selftests?

It looks like tools/testing/selftests/x86/single_step_syscall.c tests
sysenter with TF set but it doesn't check if the kernel issues any
warning.

Does it actually trip the warning though? I'm a bit surprised that
nobody reported it if so.

single_step_syscall does trigger the warning:

$ ./single_step_syscall
[RUN] Set TF and check nop
[OK] Survived with TF set and 26 traps
[RUN] Set TF and check syscall-less opportunistic sysret
[OK] Survived with TF set and 30 traps
[RUN] Set TF and check a fast syscall
[OK] Survived with TF set and 40 traps
[RUN] Fast syscall with TF cleared
[OK] Nothing unexpected happened
[RUN] Set TF and check SYSENTER
Got SIGSEGV with RIP=ed7fe579, TF=256
[RUN] Fast syscall with TF cleared
[OK] Nothing unexpected happened

On the console:

[ 1546.656252] WARNING: CPU: 124 PID: 8413 at arch/x86/kernel/traps.c:1009 exc_debug_kernel+0xd2/0x160
..
[ 1546.656352] RIP: 0010:clear_bhb_loop+0x0/0xb0


alex.