Re: [RFC PATCH v5 1/2] selftests/x86: sysret_rip: Handle syscall in a FRED system

Ammar Faizi
2023-01-25T08:54:32Z

On Wed, Jan 25, 2023 at 12:39:26AM -0800, H. Peter Anvin wrote:
> > + ret = check_regs_result(ctx->uc_mcontext.gregs[REG_R11],
> > + ctx->uc_mcontext.gregs[REG_RCX],
> > + ctx->uc_mcontext.gregs[REG_RBX]);
> > +
> > + assert(ret != REGS_ERROR);
> > +
>
> This instance, too, needs to be checked against regs_ok_result. It would
> make most sense to move that handling, and the assert() into
> check_regs_result() or into a separate function around it.

OK. Sounds better.

> > /* Set IP and CX to match so that SYSRET can happen. */
> > ctx->uc_mcontext.gregs[REG_RIP] = rip;
> > ctx->uc_mcontext.gregs[REG_RCX] = rip;
>
> It would be interesting to have the syscall handler try both with and
> without this (so it would end up doing both IRET and SYSCALL on legacy.)
> Perhaps SIGUSR1 versus SIGUSR2...

We will have a new separate patch for that.

--
Ammar Faizi