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

From: Maciej Wieczór-Retman
Date: Mon Nov 17 2025 - 04:23:21 EST


On 2025-11-11 at 10:54:42 +0100, Peter Zijlstra wrote:
>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?

I noticed your comment on my KASAN series so I'll just reply there.

>
>/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?

Thanks for asking, that sounds good :)