linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Guo Ren <guoren@kernel.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Linus Torvalds <torvalds@linux-foundation.org>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	 Palmer Dabbelt <palmer@dabbelt.com>,
	Anup Patel <anup@brainfault.org>,
	 Atish Patra <atishp@atishpatra.org>,
	Oleg Nesterov <oleg@redhat.com>, Kees Cook <kees@kernel.org>,
	 Thomas Gleixner <tglx@linutronix.de>,
	Will Deacon <will@kernel.org>,
	 Mark Rutland <mark.rutland@arm.com>,
	Christian Brauner <brauner@kernel.org>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	 Eric Dumazet <edumazet@google.com>,
	Chen Wang <unicorn_wang@outlook.com>,
	 Inochi Amaoto <inochiama@outlook.com>,
	gaohan@iscas.ac.cn, shihua@iscas.ac.cn,  jiawei@iscas.ac.cn,
	wuwei2016@iscas.ac.cn, Drew Fustini <drew@pdp7.com>,
	 "Lad, Prabhakar" <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	ctsai390@andestech.com,  wefu@redhat.com,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	 Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>, Ingo Molnar <mingo@redhat.com>,
	 Boqun Feng <boqun.feng@gmail.com>,
	Xiao W Wang <xiao.w.wang@intel.com>,
	 qingfang.deng@siflower.com.cn,
	Leonardo Bras <leobras@redhat.com>,
	 Jisheng Zhang <jszhang@kernel.org>,
	"Conor.Dooley" <conor.dooley@microchip.com>,
	 Samuel Holland <samuel.holland@sifive.com>,
	yongxuan.wang@sifive.com,  Xu Lu <luxu.kernel@bytedance.com>,
	David Hildenbrand <david@redhat.com>,
	 Ruan Jinjie <ruanjinjie@huawei.com>,
	Yunhui Cui <cuiyunhui@bytedance.com>,
	 Kefeng Wang <wangkefeng.wang@huawei.com>,
	qiaozhe@iscas.ac.cn,  Ard Biesheuvel <ardb@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	linux-kernel@vger.kernel.org,  linux-riscv@lists.infradead.org,
	kvm@vger.kernel.org,  kvm-riscv@lists.infradead.org,
	linux-mm@kvack.org,  linux-crypto@vger.kernel.org,
	bpf@vger.kernel.org,  linux-input@vger.kernel.org,
	linux-perf-users@vger.kernel.org,  linux-serial@vger.kernel.org,
	linux-fsdevel@vger.kernel.org,
	 Linux-Arch <linux-arch@vger.kernel.org>,
	maple-tree@lists.infradead.org,
	 linux-trace-kernel@vger.kernel.org,
	Netdev <netdev@vger.kernel.org>,
	 linux-atm-general@lists.sourceforge.net,
	linux-btrfs@vger.kernel.org,  netfilter-devel@vger.kernel.org,
	coreteam@netfilter.org,  linux-nfs@vger.kernel.org,
	linux-sctp@vger.kernel.org,  linux-usb@vger.kernel.org,
	linux-media@vger.kernel.org
Subject: Re: [RFC PATCH V3 00/43] rv64ilp32_abi: Build CONFIG_64BIT kernel-self with ILP32 ABI
Date: Thu, 27 Mar 2025 21:13:43 +0800	[thread overview]
Message-ID: <CAJF2gTQtdKzq2Qc6s2qQs3pwMS79Re3vRY735kLM31qNFQD=rg@mail.gmail.com> (raw)
In-Reply-To: <a9dddc3d-d03d-4614-9d55-1ce48c6ad5ef@app.fastmail.com>

On Wed, Mar 26, 2025 at 2:56 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Wed, Mar 26, 2025, at 07:07, Guo Ren wrote:
> > On Tue, Mar 25, 2025 at 9:18 PM Arnd Bergmann <arnd@arndb.de> wrote:
> >> On Tue, Mar 25, 2025, at 13:26, Peter Zijlstra wrote:
> >> > On Tue, Mar 25, 2025 at 08:15:41AM -0400, guoren@kernel.org wrote:
> >>
> >> You declare the syscall ABI to be the native 64-bit ABI, but this
> >> is fundamentally not true because a many uapi structures are
> >> defined in terms of 'long' or pointer values, in particular in
> >> the ioctl call.
> >
> > I modified uapi with
> > void __user *msg_name;
> > ->
> > union {void __user *msg_name; u64 __msg_name;};
> > to make native 64-bit ABI.
> >
> > I would look at compat stuff instead of using __riscv_xlen macro.
>
> The problem I see here is that there are many more drivers
> that you did not modify than drivers that you did change this
> way.  The union is particularly ugly, but even if you find
> a nicer method of doing this, you now also put the burden
> on future driver writers to do this right for your platform.
Got it.

>
> >> As far as I can tell, there is no way to rectify this design flaw
> >> other than to drop support for 64-bit userspace and only support
> >> regular rv32 userspace. I'm also skeptical that supporting rv64
> >> userspace helps in practice other than for testing, since
> >> generally most memory overhead is in userspace rather than the
> >> kernel, and there is much more to gain from shrinking the larger
> >> userspace by running rv32 compat mode binaries on a 64-bit kernel
> >> than the other way round.
> >
> > The lp64-abi userspace rootfs works fine in this patch set, which
> > proves the technique is valid. But the modification on uapi is raw,
> > and I'm looking at compat stuff.
>
> There is a big difference between making it work for a particular
> set of userspace binaries and making it correct for the entire
> kernel ABI.
>
> I agree that limiting the hacks to the compat side while keeping
> the native ABI as ilp32 as in your previous versions is better,
> but I also don't think this can be easily done without major
> changes to how compat mode works in general, and that still
> seems like a show-stopper for two reasons:
>
> - it still puts the burden on driver writers to get it right
>   for your platform. The scope is a bit smaller than in the
>   current version because that would be limited to the compat
>   handlers and not change the native codepath, but that's
>   still a lot of drivers.
>
> - the way that I would imagine this to be implemented in
>   practice would require changing the compat code in a way that
>   allows multiple compat ABIs, so drivers can separate the
>   normal 32-on-64 handling from the 64-on-32 version you need.
>   We have discussed something like this in the past, but Linus
>   has already made it very clear that he doesn't want it done
>   that way. Whichever way you do it, this is unlikely to
>   find consensus.
Got it, thanks for analysing.

>
> > Supporting lp64-abi userspace is essential because riscv lp64-abi and
> > ilp32-abi userspace are hybrid deployments when the target is
> > ilp32-abi userspace. The lp64-abi provides a good supplement to
> > ilp32-abi which eases the development.
>
> I'm not following here, please clarify. I do understand that
> having a mixed 32/64 userspace can help for development, but
> that can already be done on a 64-bit kernel and it doesn't
> seem to be useful for deployment because having two sets of
> support libraries makes this counterproductive for the goal
> of saving RAM.
In my case, most binaries and libraries are based on 32-bit, but a
small part would remain on 64-bit, which may be statically linked.
For RISC-V, the rv64 ecosystem is more complete than the rv32's. So,
rv64-abi is always necessary, and rv32-abi is a supplement.

>
> >> If you remove the CONFIG_64BIT changes that Peter mentioned and
> >> the support for ilp64 userland from your series, you end up
> >> with a kernel that is very similar to a native rv32 kernel
> >> but executes as rv64ilp32 and runs rv32 userspace. I don't have
> >> any objections to that approach, and the same thing has come
> >> up on arm64 as a possible idea as well, but I don't know if
> >> that actually brings any notable advantage over an rv32 kernel.
> >>
> >> Are there CPUs that can run rv64 kernels and rv32 userspace
> >> but not rv32 kernels, similar to what we have on Arm Cortex-A76
> >> and Cortex-A510?
> >
> > Yes, there is, and it only supports rv32 userspace, not rv32 kernel.
> > https://www.xrvm.com/product/xuantie/C908
>
> Ok, thanks for the link.
>
>        Arnd
>


-- 
Best Regards
 Guo Ren


  reply	other threads:[~2025-03-27 13:14 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-25 12:15 guoren
2025-03-25 12:15 ` [RFC PATCH V3 01/43] rv64ilp32_abi: uapi: Reuse lp64 ABI interface guoren
2025-03-25 20:30   ` Jan Engelhardt
2025-03-26  3:35     ` Guo Ren
2025-03-25 20:41   ` Linus Torvalds
2025-03-26  6:34     ` Guo Ren
2025-03-27 16:20     ` Palmer Dabbelt
2025-03-25 12:15 ` [RFC PATCH V3 02/43] rv64ilp32_abi: riscv: Adapt Makefile and Kconfig guoren
2025-03-25 12:15 ` [RFC PATCH V3 03/43] rv64ilp32_abi: riscv: Adapt ULL & UL definition guoren
2025-03-25 12:15 ` [RFC PATCH V3 04/43] rv64ilp32_abi: riscv: Introduce xlen_t to adapt __riscv_xlen != BITS_PER_LONG guoren
2025-03-25 12:15 ` [RFC PATCH V3 05/43] rv64ilp32_abi: riscv: crc32: Utilize 64-bit width to improve the performance guoren
2025-03-25 12:15 ` [RFC PATCH V3 06/43] rv64ilp32_abi: riscv: csum: " guoren
2025-03-25 12:15 ` [RFC PATCH V3 07/43] rv64ilp32_abi: riscv: arch_hweight: Adapt cpopw & cpop of zbb extension guoren
2025-03-25 12:15 ` [RFC PATCH V3 08/43] rv64ilp32_abi: riscv: bitops: Adapt ctzw & clzw " guoren
2025-03-25 12:15 ` [RFC PATCH V3 09/43] rv64ilp32_abi: riscv: Reuse LP64 SBI interface guoren
2025-03-25 12:15 ` [RFC PATCH V3 10/43] rv64ilp32_abi: riscv: Update SATP.MODE.ASID width guoren
2025-03-25 12:15 ` [RFC PATCH V3 11/43] rv64ilp32_abi: riscv: Introduce PTR_L and PTR_S guoren
2025-03-25 12:15 ` [RFC PATCH V3 12/43] rv64ilp32_abi: riscv: Introduce cmpxchg_double guoren
2025-03-25 12:15 ` [RFC PATCH V3 13/43] rv64ilp32_abi: riscv: Correct stackframe layout guoren
2025-03-25 12:15 ` [RFC PATCH V3 14/43] rv64ilp32_abi: riscv: Adapt kernel module code guoren
2025-03-25 12:15 ` [RFC PATCH V3 15/43] rv64ilp32_abi: riscv: mm: Adapt MMU_SV39 for 2GiB address space guoren
2025-03-25 12:15 ` [RFC PATCH V3 16/43] rv64ilp32_abi: riscv: Support physical addresses >= 0x80000000 guoren
2025-03-25 12:15 ` [RFC PATCH V3 17/43] rv64ilp32_abi: riscv: Adapt kasan memory layout guoren
2025-03-25 12:15 ` [RFC PATCH V3 18/43] rv64ilp32_abi: riscv: kvm: Initial support guoren
2025-03-25 12:16 ` [RFC PATCH V3 19/43] rv64ilp32_abi: irqchip: irq-riscv-intc: Use xlen_t instead of ulong guoren
2025-03-25 12:16 ` [RFC PATCH V3 20/43] rv64ilp32_abi: drivers/perf: Adapt xlen_t of sbiret guoren
2025-03-25 12:16 ` [RFC PATCH V3 21/43] rv64ilp32_abi: asm-generic: Add custom BITS_PER_LONG definition guoren
2025-03-25 12:16 ` [RFC PATCH V3 22/43] rv64ilp32_abi: bpf: Change KERN_ARENA_SZ to 256MiB guoren
2025-03-25 12:16 ` [RFC PATCH V3 23/43] rv64ilp32_abi: compat: Correct compat_ulong_t cast guoren
2025-03-25 12:16 ` [RFC PATCH V3 24/43] rv64ilp32_abi: compiler_types: Add "long long" into __native_word() guoren
2025-03-25 12:16 ` [RFC PATCH V3 25/43] rv64ilp32_abi: exec: Adapt 64lp64 env and argv guoren
2025-03-25 17:19   ` Sergey Shtylyov
2025-03-26  9:22     ` Guo Ren
2025-03-25 12:16 ` [RFC PATCH V3 26/43] rv64ilp32_abi: file_ref: Use 32-bit width for refcnt guoren
2025-03-25 12:16 ` [RFC PATCH V3 27/43] rv64ilp32_abi: input: Adapt BITS_PER_LONG to dword guoren
2025-03-25 12:16 ` [RFC PATCH V3 28/43] rv64ilp32_abi: iov_iter: Resize kvec to match iov_iter's size guoren
2025-03-25 12:16 ` [RFC PATCH V3 29/43] rv64ilp32_abi: locking/atomic: Use BITS_PER_LONG for scripts guoren
2025-03-25 12:16 ` [RFC PATCH V3 30/43] rv64ilp32_abi: kernel/smp: Disable CSD_LOCK_WAIT_DEBUG guoren
2025-03-25 12:16 ` [RFC PATCH V3 31/43] rv64ilp32_abi: maple_tree: Use BITS_PER_LONG instead of CONFIG_64BIT guoren
2025-03-25 19:09   ` Liam R. Howlett
2025-03-27 12:47     ` Guo Ren
2025-03-25 12:16 ` [RFC PATCH V3 32/43] rv64ilp32_abi: mm: Remove _folio_nr_pages guoren
2025-03-25 12:16 ` [RFC PATCH V3 33/43] rv64ilp32_abi: mm/auxvec: Adapt mm->saved_auxv[] to Elf64 guoren
2025-03-25 12:16 ` [RFC PATCH V3 34/43] rv64ilp32_abi: mm: Adapt vm_flags_t struct guoren
2025-03-25 12:16 ` [RFC PATCH V3 35/43] rv64ilp32_abi: net: Use BITS_PER_LONG in struct dst_entry guoren
2025-03-25 12:16 ` [RFC PATCH V3 36/43] rv64ilp32_abi: printf: Use BITS_PER_LONG instead of CONFIG_64BIT guoren
2025-03-25 12:16 ` [RFC PATCH V3 37/43] rv64ilp32_abi: random: Adapt fast_pool struct guoren
2025-03-25 12:16 ` [RFC PATCH V3 38/43] rv64ilp32_abi: syscall: Use CONFIG_64BIT instead of BITS_PER_LONG guoren
2025-03-25 12:16 ` [RFC PATCH V3 39/43] rv64ilp32_abi: sysinfo: Adapt sysinfo structure to lp64 uapi guoren
2025-03-25 12:16 ` [RFC PATCH V3 40/43] rv64ilp32_abi: tracepoint-defs: Using u64 for trace_print_flags.mask guoren
2025-03-25 12:16 ` [RFC PATCH V3 41/43] rv64ilp32_abi: tty: Adapt ptr_to_compat guoren
2025-03-25 12:16 ` [RFC PATCH V3 42/43] rv64ilp32_abi: memfd: Use vm_flag_t guoren
2025-03-25 12:16 ` [RFC PATCH V3 43/43] riscv: Fixup address space overlay of print_mlk guoren
2025-03-25 12:26 ` [RFC PATCH V3 00/43] rv64ilp32_abi: Build CONFIG_64BIT kernel-self with ILP32 ABI Peter Zijlstra
2025-03-25 13:13   ` Guo Ren
2025-03-25 13:17   ` Arnd Bergmann
2025-03-26  6:07     ` Guo Ren
2025-03-26  6:55       ` Arnd Bergmann
2025-03-27 13:13         ` Guo Ren [this message]
2025-03-25 18:51   ` David Hildenbrand
2025-03-25 19:23     ` Liam R. Howlett
2025-03-27 16:20       ` Palmer Dabbelt
2025-03-27 21:06 ` David Laight
2025-03-31  9:38   ` Guo Ren

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='CAJF2gTQtdKzq2Qc6s2qQs3pwMS79Re3vRY735kLM31qNFQD=rg@mail.gmail.com' \
    --to=guoren@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=anup@brainfault.org \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=ast@kernel.org \
    --cc=atishp@atishpatra.org \
    --cc=boqun.feng@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=brauner@kernel.org \
    --cc=conor.dooley@microchip.com \
    --cc=coreteam@netfilter.org \
    --cc=ctsai390@andestech.com \
    --cc=cuiyunhui@bytedance.com \
    --cc=david@redhat.com \
    --cc=drew@pdp7.com \
    --cc=dsterba@suse.com \
    --cc=edumazet@google.com \
    --cc=gaohan@iscas.ac.cn \
    --cc=gregkh@linuxfoundation.org \
    --cc=inochiama@outlook.com \
    --cc=jiawei@iscas.ac.cn \
    --cc=josef@toxicpanda.com \
    --cc=jszhang@kernel.org \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=leobras@redhat.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-atm-general@lists.sourceforge.net \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-sctp@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=luxu.kernel@bytedance.com \
    --cc=maple-tree@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=pabeni@redhat.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=peterz@infradead.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=qiaozhe@iscas.ac.cn \
    --cc=qingfang.deng@siflower.com.cn \
    --cc=rostedt@goodmis.org \
    --cc=ruanjinjie@huawei.com \
    --cc=samuel.holland@sifive.com \
    --cc=shihua@iscas.ac.cn \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=unicorn_wang@outlook.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=wefu@redhat.com \
    --cc=will@kernel.org \
    --cc=wuwei2016@iscas.ac.cn \
    --cc=xiao.w.wang@intel.com \
    --cc=yongxuan.wang@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