From: David Laight <David.Laight@ACULAB.COM>
To: "'Clément Léger'" <cleger@rivosinc.com>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"linux-riscv@lists.infradead.org"
<linux-riscv@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Christoph Hellwig <hch@infradead.org>,
Ben Dooks <ben.dooks@codethink.co.uk>,
kernel test robot <lkp@intel.com>
Subject: RE: [PATCH v2] riscv: fix incorrect use of __user pointer
Date: Mon, 27 Nov 2023 10:35:42 +0000 [thread overview]
Message-ID: <72fb7d8085a644e4a3e2e540a9ed6847@AcuMS.aculab.com> (raw)
In-Reply-To: <9cb1fadf-bb83-4e9f-9c29-bff53e30b0c6@rivosinc.com>
From: Clément Léger
> Sent: 27 November 2023 10:24
>
> On 25/11/2023 16:37, David Laight wrote:
> > ...
> >> @@ -491,7 +486,7 @@ int handle_misaligned_load(struct pt_regs *regs)
> >>
> >> val.data_u64 = 0;
> >> for (i = 0; i < len; i++) {
> >> - if (load_u8(regs, (void *)(addr + i), &val.data_bytes[i]))
> >> + if (load_u8(regs, addr + i, &val.data_bytes[i]))
> >> return -1;
> >> }
> >
> > I'd really have thought that you'd want to pull the kernel/user
> > check way outside the loop?
>
> Hi David,
>
> I hope the compiler is able to extract that 'if' out of the loop since
> regs isn't modified in the loop. Nevertheless, that could be more
> "clear" if put outside indeed.
If has access regs->xxx then the compiler can't do so because it
will must assume that the assignment might alias into 'regs'.
That is even true for byte writes if 'strict-aliasing' is enabled
- which it isn't for linux kernel builds.
It might do so if 'regs' were 'const'; it tends to assume that if
it can't change something nothing can - although that isn't true.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2023-11-27 10:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-24 11:38 [PATCH v2] riscv: fix incorrect use of __user pointer Clément Léger
2023-11-25 6:22 ` Christoph Hellwig
2023-11-25 15:37 ` David Laight
2023-11-27 10:24 ` Clément Léger
2023-11-27 10:35 ` David Laight [this message]
2023-11-27 10:37 ` Clément Léger
2023-11-27 10:51 ` David Laight
2023-11-27 12:02 ` Ben Dooks
2023-11-27 12:46 ` Clément Léger
2023-11-27 12:57 ` Clément Léger
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=72fb7d8085a644e4a3e2e540a9ed6847@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=aou@eecs.berkeley.edu \
--cc=ben.dooks@codethink.co.uk \
--cc=cleger@rivosinc.com \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=lkp@intel.com \
--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