Re: [RFC PATCH V3 01/43] rv64ilp32_abi: uapi: Reuse lp64 ABI interface

Guo Ren
2025-03-26T06:34:48Z

On Wed, Mar 26, 2025 at 4:41 AM Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> On Tue, 25 Mar 2025 at 05:17, <guoren@kernel.org> wrote:
> >
> > The rv64ilp32 abi kernel accommodates the lp64 abi userspace and
> > leverages the lp64 abi Linux interface. Hence, unify the
> > BITS_PER_LONG = 32 memory layout to match BITS_PER_LONG = 64.
>
> No.
>
> This isn't happening.
>
> You can't do crazy things in the RISC-V code and then expect the rest
> of the kernel to just go "ok, we'll do crazy things".
>
> We're not doing crazy __riscv_xlen hackery with random structures
> containing 64-bit values that the kernel then only looks at the low 32
> bits. That's wrong on *so* many levels.
>
> I'm willing to say "big-endian is dead", but I'm not willing to accept
> this kind of crazy hackery.
>
> Not today, not ever.
>
> If you want to run a ilp32 kernel on 64-bit hardware (and support
> 64-bit ABI just in a 32-bit virtual memory size), I would suggest you
>
> (a) treat the kernel as natively 32-bit (obviously you can then tell
> the compiler to use the rv64 instructions, which I presume you're
> already doing - I didn't look)
I used CONFIG_32BIT in v1 and v2, but I've abandoned them because,
based on CONFIG_64BIT, I gain more functionality by inheriting the
lp64-abi kernel. I want the full functionality of the CONFIG_64BIT
Linux kernel, which can be equivalent, used interchangeably, and
seamlessly.

>
> (b) look at making the compat stuff do the conversion the "wrong way".
>
> And btw, that (b) implies *not* just ignoring the high bits. If
> user-space gives 64-bit pointer, you don't just treat it as a 32-bit
> one by dropping the high bits. You add some logic to convert it to an
> invalid pointer so that user space gets -EFAULT.
Thanks for the advice. I'm looking at how to make the compat stuff.

--
Best Regards
Guo Ren