Re: [PATCH 13/14] x86: BHI stubs
From: Peter Zijlstra
Date: Sat Sep 28 2024 - 09:23:47 EST
On Fri, Sep 27, 2024 at 06:37:36PM -0700, Josh Poimboeuf wrote:
> On Fri, Sep 27, 2024 at 09:49:09PM +0200, Peter Zijlstra wrote:
> > +static void *bhi_args_1(u8 args, void *addr)
> > +{
> > + u8 bytes[5];
> > +
> > + for (int i = 0; i < 6; i++) {
> > + if (args != BIT(i))
> > + continue;
> > +
> > + bytes[0] = 0x2e;
> > + memcpy(&bytes[1], &__bhi_args_6c1[i], 4);
> > +
> > + text_poke_early(addr, bytes, 5);
> > +
> > + return NULL;
>
> I assume there's some good reason this doesn't return a pointer to the
> code like the others?
The 1 bit case is different in that it does in-place CMOVcc while the
others do a CALL to an external stub.
Not saying this is the best way to do it, but it's what I ended up with
back then.