Re: [PATCH] x86: add hintable NOPs emulation
From: Ahmed S. Darwish
Date: Wed Aug 20 2025 - 06:15:04 EST
On Wed, 20 Aug 2025, Marcos Del Sol Vives wrote:
>
> But I think the kernel should let the user know the binaries they're
> running are having some performance penalty due to this emulation, in case
> they want to recompile without the offending flags.
>
> Without the logging, they'd be in the dark and might get confused on why
> their programs are running slower than on other machines.
>
Not convinced; especially all the extra 'thread_struct' noise.
>
> I originally did that, but then realized it was not possible due to
> "handle_hnop" depending on the conditionally-available "hnop_warn" flag.
>
Please do:
#ifdef CONFIG_X86_HNOP_EMU
static bool handle_hnop(struct pt_regs *regs)
{
// Reference 'hnop_warn' as much as you like
}
#else
static bool handle_hnop(struct pt_regs *regs)
{
return false;
}
# endif
Then this ugliness:
static inline void handle_invalid_op(struct pt_regs *regs)
{
#ifdef CONFIG_X86_HNOP_EMU
if (user_mode(regs) && handle_hnop(regs))
return;
#endif
...
}
can become normal code:
static inline void handle_invalid_op(struct pt_regs *regs)
{
if (user_mode(regs) && handle_hnop(regs))
return;
...
}
Good luck,
--
Ahmed S. Darwish
Linutronix GmbH