lkml.org 
[lkml]   [2023]   [Nov]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v2] riscv: fix incorrect use of __user pointer
Date
...
> @@ -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?
In any case, for a misaligned read why not just read (addr & ~7)[0]
and (if needed) (addr & ~7)[1] and then ahift and or together?

clang will do it for misaligned structure members with known
misalignment, but it is almost certainly also better for reads
with unknown misalignment.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
\
 
 \ /
  Last update: 2023-11-25 16:38    [W:0.092 / U:0.712 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site