From: "Clément Léger" <cleger@rivosinc.com>
To: Christoph Hellwig <hch@infradead.org>,
Ben Dooks <ben.dooks@codethink.co.uk>
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
paul.walmsley@sifive.com, palmer@dabbelt.com,
aou@eecs.berkeley.edu
Subject: Re: [PATCH] riscv: fix __user annotation in traps_misaligned.c
Date: Fri, 24 Nov 2023 11:28:08 +0100 [thread overview]
Message-ID: <7232f08e-dfe3-43d6-a4f7-abf8360bbfc1@rivosinc.com> (raw)
In-Reply-To: <ZWA9HwUNHDFIw0wP@infradead.org>
On 24/11/2023 07:05, Christoph Hellwig wrote:
> On Thu, Nov 23, 2023 at 02:16:17PM +0000, Ben Dooks wrote:
>> @@ -319,7 +319,7 @@ static inline int get_insn(struct pt_regs *regs, ulong mepc, ulong *r_insn)
>> static inline int load_u8(struct pt_regs *regs, const u8 *addr, u8 *r_val)
>> {
>> if (user_mode(regs)) {
>> - return __get_user(*r_val, addr);
>> + return __get_user(*r_val, (u8 __user *)addr);
>> } else {
>> *r_val = *addr;
>> return 0;
>
> This is the wrong way to approach it. Pass the untype unsigned long
> from the caller instead and do a single round of casts from that
> depending on the address_space.
I sent a similar patch two days ago with the same modification. I'm not
sure to get it. Why is it better to pass the "unsigned long" type from
the caller ? I mean, the resulting code would look like this right ?
static inline int store_u8(struct pt_regs *regs, unsigned long addr, u8 val)
{
if (user_mode(regs)) {
return __put_user(val, (u8 __user *)addr);
} else {
*addr = (u8 *)val;
return 0;
}
}
Is this better from a "semantic" point of view and be sure the casts are
done in a single place ?
>
> And please also remove this horrible else after return entipattern
> while you're at it.
Acked,
Thanks,
>
>
> _______________________________________________
> 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-24 10:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-23 14:16 Ben Dooks
2023-11-24 6:05 ` Christoph Hellwig
2023-11-24 10:28 ` Clément Léger [this message]
2023-11-24 10:45 ` Christoph Hellwig
2023-11-24 10:46 ` Clément Léger
2023-11-24 10:21 ` Clément Léger
2024-01-11 14:50 ` 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=7232f08e-dfe3-43d6-a4f7-abf8360bbfc1@rivosinc.com \
--to=cleger@rivosinc.com \
--cc=aou@eecs.berkeley.edu \
--cc=ben.dooks@codethink.co.uk \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--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
all inboxes | Powered by JetHome®