Re: [PATCH v3] x86,entry: Use PUSH_AND_CLEAR_REGS for compat

From: Peter Zijlstra
Date: Fri Apr 29 2022 - 18:14:43 EST


On Fri, Apr 29, 2022 at 02:30:45PM -0700, Linus Torvalds wrote:
> On Fri, Apr 29, 2022 at 2:13 PM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> >
> > (Linus, can I add your SoB to the thing?)
>
> If you teste this with some actual old int80 compat syscalls, then absolutely:

I ran tools/testing/selftests/x86/*_32 on it. That definitely tickles
the int80 path. Also, without the off-by-one fixed that gives some
generous helpings of segfault.

> Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

Thanks!

> > + pushq %rdi /* pt_regs->di */
> > pushq %rsi /* pt_regs->si */
> > xorl %esi, %esi /* nospec si */
>
> It would probably make sense to add a comment about why %rdi isn't
> cleared when pushed, like all the other registers are.
>
> Even if that comment is just "%rdi will be overwritten as arg0 of the
> call to C, so no need to clear it".
>
> Maybe as part of the PUSH_AND_CLEAR_REGS changes?

I'll stick the comment on.