Re: [PATCH v2 10/12] x86_64/bug: Implement __WARN_printf()

From: Peter Zijlstra
Date: Tue Nov 11 2025 - 05:02:01 EST


On Mon, Nov 10, 2025 at 12:46:43PM +0100, Peter Zijlstra wrote:

> #endif /* _ASM_X86_BUG_H */
> --- a/arch/x86/kernel/traps.c
> +++ b/arch/x86/kernel/traps.c
> @@ -102,25 +102,37 @@ __always_inline int is_valid_bugaddr(uns
> * UBSan{0}: 67 0f b9 00 ud1 (%eax),%eax
> * UBSan{10}: 67 0f b9 40 10 ud1 0x10(%eax),%eax
> * static_call: 0f b9 cc ud1 %esp,%ecx
> + * __WARN_trap: 67 48 0f b9 39 ud1 (%ecx),%reg
> *
> - * Notably UBSAN uses EAX, static_call uses ECX.
> + * Notable, since __WARN_trap can use all registers, the distinction between
> + * UD1 users is through R/M.
> */

Maciej; you were working on making KASAN emit UD1 instructions, right?
Where are you with those patches and are we conflicting on the encoding?

/me goes find the emails.. Yeah, I suggested UD1 /1, specifically:

ud1 xx(%ecx), %ecx

and that does conflict. How about I switch to using:

ud1 (%edx), %reg

for this?