From: Conor Dooley <conor@kernel.org>
To: "Björn Töpel" <bjorn@kernel.org>
Cc: "Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
linux-riscv@lists.infradead.org,
"Christoph Muellner" <christoph.muellner@vrull.eu>,
"Heiko Stuebner" <heiko.stuebner@vrull.eu>,
"Björn Töpel" <bjorn@rivosinc.com>,
"Conor Dooley" <conor.dooley@microchip.com>,
"Guenter Roeck" <linux@roeck-us.net>,
"Andrew Jones" <ajones@ventanamicro.com>
Subject: Re: [PATCH] riscv, lib: Fix Zbb strncmp
Date: Tue, 28 Feb 2023 19:12:37 +0000 [thread overview]
Message-ID: <Y/5SJc1AlfnY/l3l@spud> (raw)
In-Reply-To: <20230228184211.1585641-1-bjorn@kernel.org>
[-- Attachment #1.1: Type: text/plain, Size: 1368 bytes --]
On Tue, Feb 28, 2023 at 07:42:10PM +0100, Björn Töpel wrote:
> From: Björn Töpel <bjorn@rivosinc.com>
>
> The Zbb optimized strncmp has two parts; a fast path that does XLEN/8B
> per iteration, and a slow that does one byte per iteration.
>
> The idea is to compare aligned XLEN chunks for most of strings, and do
> the remainder tail in the slow path.
>
> The Zbb strncmp has two issues in the fast path:
>
> Incorrect remainder handling (wrong compare): Assume that the string
> length is 9. On 64b systems, the fast path should do one iteration,
> and one iteration in the slow path. Instead, both were done in the
> fast path, which lead to incorrect results. An example:
>
> strncmp("/dev/vda", "/dev/", 5);
>
> Correct by changing "bgt" to "bge".
>
> Missing NULL checks in the second string: This could lead to incorrect
> results for:
>
> strncmp("/dev/vda", "/dev/vda\0", 8);
>
> Correct by adding an additional check.
>
> Fixes: b6fcdb191e36 ("RISC-V: add zbb support to string functions")
> Suggested-by: Heiko Stuebner <heiko.stuebner@vrull.eu>
> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
With your new selftest stuff & on a JH7110:
Tested-by: Conor Dooley <conor.dooley@microchip.com>
Also, given the reporter, this should be:
Reported-by: Guenter Roeck <linux@roeck-us.net>
no?
Thanks,
Conor.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
[-- Attachment #2: Type: text/plain, Size: 161 bytes --]
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2023-02-28 19:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-28 18:42 [PATCH] riscv, lib: Fix Zbb strncmp Björn Töpel
2023-02-28 19:12 ` Conor Dooley [this message]
2023-02-28 19:41 ` Björn Töpel
2023-02-28 19:53 ` Guenter Roeck
2023-02-28 21:18 ` Guenter Roeck
2023-02-28 21:55 ` Palmer Dabbelt
2023-03-01 3:20 ` patchwork-bot+linux-riscv
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=Y/5SJc1AlfnY/l3l@spud \
--to=conor@kernel.org \
--cc=ajones@ventanamicro.com \
--cc=aou@eecs.berkeley.edu \
--cc=bjorn@kernel.org \
--cc=bjorn@rivosinc.com \
--cc=christoph.muellner@vrull.eu \
--cc=conor.dooley@microchip.com \
--cc=heiko.stuebner@vrull.eu \
--cc=linux-riscv@lists.infradead.org \
--cc=linux@roeck-us.net \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
/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