lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 19 Jul 2023 13:13:33 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Guo Ren' <guoren@...nel.org>,
        Celeste Liu <coelacanthushex@...il.com>,
        Huacai Chen <chenhuacai@...nel.org>
CC:     Palmer Dabbelt <palmer@...osinc.com>,
        Paul Walmsley <paul.walmsley@...ive.com>,
        Albert Ou <aou@...s.berkeley.edu>,
        Björn Töpel <bjorn@...osinc.com>,
        Conor Dooley <conor.dooley@...rochip.com>,
        "linux-riscv@...ts.infradead.org" <linux-riscv@...ts.infradead.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Felix Yan <felixonmars@...hlinux.org>,
        "Ruizhe Pan" <c141028@...il.com>,
        Shiqi Zhang <shiqi@...c.iscas.ac.cn>
Subject: RE: [PATCH v3] riscv: entry: set a0 = -ENOSYS only when syscall != -1

...
> > +               /*
> > +                * 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)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ