From: David Laight <David.Laight@ACULAB.COM>
To: 'Guo Ren' <guoren@kernel.org>,
Celeste Liu <coelacanthushex@gmail.com>,
Huacai Chen <chenhuacai@kernel.org>
Cc: "Palmer Dabbelt" <palmer@rivosinc.com>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Björn Töpel" <bjorn@rivosinc.com>,
"Conor Dooley" <conor.dooley@microchip.com>,
"linux-riscv@lists.infradead.org"
<linux-riscv@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Felix Yan" <felixonmars@archlinux.org>,
"Ruizhe Pan" <c141028@gmail.com>,
"Shiqi Zhang" <shiqi@isrc.iscas.ac.cn>
Subject: RE: [PATCH v3] riscv: entry: set a0 = -ENOSYS only when syscall != -1
Date: Wed, 19 Jul 2023 13:13:33 +0000 [thread overview]
Message-ID: <0aab577b941e4c3483ad4a7af3b42c1f@AcuMS.aculab.com> (raw)
In-Reply-To: <CAJF2gTRf0UOYhqwUm6=1YMvZt8q_72WRUHqN=L+nOWaipL+H1Q@mail.gmail.com>
...
> > + /*
> > + * 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)
next prev parent reply other threads:[~2023-07-19 13:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-18 20:57 Celeste Liu
2023-07-18 21:20 ` Björn Töpel
2023-07-18 23:40 ` Guo Ren
2023-07-19 13:13 ` David Laight [this message]
2023-07-19 7:21 ` Andreas Schwab
2023-07-19 16:28 ` Björn Töpel
2023-07-20 6:46 ` Celeste Liu
2023-07-20 9:08 ` Björn Töpel
2023-07-20 19:24 ` Celeste Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0aab577b941e4c3483ad4a7af3b42c1f@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=aou@eecs.berkeley.edu \
--cc=bjorn@rivosinc.com \
--cc=c141028@gmail.com \
--cc=chenhuacai@kernel.org \
--cc=coelacanthushex@gmail.com \
--cc=conor.dooley@microchip.com \
--cc=felixonmars@archlinux.org \
--cc=guoren@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@rivosinc.com \
--cc=paul.walmsley@sifive.com \
--cc=shiqi@isrc.iscas.ac.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®