RE: [PATCH v3] riscv: entry: set a0 = -ENOSYS only when syscall != -1

From: David Laight
Date: Wed Jul 19 2023 - 09:13:41 EST


...
> > + /*
> > + * Convert negative numbers to very high and thus out of range
> > + * numbers for comparisons.
> > + */
> > ulong syscall = regs->a7;
> >
> > regs->epc += 4;
> > @@ -308,7 +312,7 @@ asmlinkage __visible __trap_section void do_trap_ecall_u(struct pt_regs *regs)
> >
> > if (syscall < NR_syscalls)

If you leave 'syscall' signed and write:
if (syscall >= 0 && syscall < NR_syscalls)
the compiler will use a single unsigned compare.
There is no need to 'optimise' it yourself.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)