Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1759852rwd; Sun, 21 May 2023 05:55:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zYwb1yl64h1IAuUZBniqDv1S/bBeWtJXd2yWmS45zKNPkwzNz153W97fxbMZHIv2b5LHd X-Received: by 2002:a17:902:efd5:b0:1ae:4a0b:5957 with SMTP id ja21-20020a170902efd500b001ae4a0b5957mr7683384plb.54.1684673703156; Sun, 21 May 2023 05:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684673703; cv=none; d=google.com; s=arc-20160816; b=gdeDMGwOKlVDXxaGlypYDROHZyCjAdihCQ4rKtsuVONNoq3pFAGH5pwM5pFPwtJtss 1X8Kw5d4epFxglVElj7f9DkgjUeWHZ6l5AQ6Btey9XGHnDOAul07vKqDwvlmDQ7ChJ8C NWA/9FRztJ7y6Z1yi1ZrLKk0pWEmbI8Gf2pYfCkED3C/8O861J+OahnwaAaAtTluqOGi YykFTpfui5zCYiyrnGFuweJSlPdWpdLFjcKE5calIk3k/+Wycxz65Emu9W/qMJBrHvFq uKOE7qxQgmq9goT7ES7/UNaGGD75yEPWYxKgIXJ0QSkt/+ghagRYuAaBh/dfkoUDAnFf pzGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=gCQhfyocdNJg7JBZuCgN+i/MRYWlhtctk+fKrb2mi9Q=; b=moxDX8kpNk4M1wDMk43xNLV+I7UbJv5QsfNCrJd6obzpfSqG1fpvjmpt1Z91M19t1i sM4e84sD47HQHRzvFy5mQ022vwUDZj6YZVtUQkorUUJk3nT9FE3fVQ6HyluOMXn1lx6h VIgRYA7nO3PpmkkNqyCwaGysBkwi+KxHTEFkG3PVYRDQ8qtb2umqn0EniJyVrFL9e4hA 4fQXEHB7DO31huyfoYiots2x/Dl5WQPyd4lg5sWyTR6yMHTUztcjaCVAACIX/D1FSO+F ZhvKfAxS3+KuGZigv/5IZVU+4QaZmcm1gLxwNXKkrkKmCz50hFPc2St0lFp38LKGKas6 miLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GsRudyw5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y19-20020a1709029b9300b001aafda896b3si2995256plp.626.2023.05.21.05.54.44; Sun, 21 May 2023 05:55:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GsRudyw5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230241AbjEUMiK (ORCPT + 99 others); Sun, 21 May 2023 08:38:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230120AbjEUMiJ (ORCPT ); Sun, 21 May 2023 08:38:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D359DC2; Sun, 21 May 2023 05:38:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7267D60F4F; Sun, 21 May 2023 12:38:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0BA3C433AC; Sun, 21 May 2023 12:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684672687; bh=F/yfHoeQVFg/Iszqcubt0GmafBS2VeuM5J2EsdRkorE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=GsRudyw5Le/vW1MxI7Egj44IrRtSsL2qcnDSjrbRH9Jjk5Ftslq5CeBx+YTYNOVnp zPI4QxGvX6UmdJ2hQXABKjZ/TnJI6Gu1nAdoE/ygYblhEol7yjGpfurUT+q/FbrHCX c6Qpz14ATiApAPJEd846Ff6EFttbhO2GRnsJB3FjQSvchIdGYoOQJSyLiShVsUkTky TT8cxlNuYWxw551hKixFJcTsmMKRBal2jwmyxan9z5XLR2zSSVRCUz3wnPUqfzbRVu 66vc1GoxLlK1smyqnhQh5h2wqoKUz8HUL8RSlY5DmMg/uUSnpNutUHzxCbHl9PEYdH 2I9XSGQzykHVQ== Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-510db954476so6656329a12.0; Sun, 21 May 2023 05:38:07 -0700 (PDT) X-Gm-Message-State: AC+VfDxNp/q4HH0i2I8pIPMDVnjUZBPNTHaj4Wp8pb3vIdD3i20k7V2u p+nMeeFJDd6cVXMV+9aJHVU3jl68qS97yL7XjEc= X-Received: by 2002:a05:6402:1210:b0:510:5d6d:552e with SMTP id c16-20020a056402121000b005105d6d552emr5870163edw.40.1684672685946; Sun, 21 May 2023 05:38:05 -0700 (PDT) MIME-Version: 1.0 References: <668be661-728d-b87f-b827-4345ad07cc61@sifive.com> In-Reply-To: <668be661-728d-b87f-b827-4345ad07cc61@sifive.com> From: Guo Ren Date: Sun, 21 May 2023 20:37:54 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 00/22] riscv: s64ilp32: Running 32-bit Linux kernel on 64-bit supervisor mode To: Paul Walmsley Cc: Palmer Dabbelt , Arnd Bergmann , tglx@linutronix.de, peterz@infradead.org, luto@kernel.org, Conor Dooley , heiko@sntech.de, jszhang@kernel.org, chenhuacai@kernel.org, apatel@ventanamicro.com, atishp@atishpatra.org, Mark Rutland , bjorn@kernel.org, Catalin Marinas , Will Deacon , rppt@kernel.org, anup@brainfault.org, shihua@iscas.ac.cn, jiawei@iscas.ac.cn, liweiwei@iscas.ac.cn, luxufan@iscas.ac.cn, chunyu@iscas.ac.cn, tsu.yubo@gmail.com, wefu@redhat.com, wangjunqiang@iscas.ac.cn, kito.cheng@sifive.com, andy.chiu@sifive.com, vincent.chen@sifive.com, greentime.hu@sifive.com, corbet@lwn.net, wuwei2016@iscas.ac.cn, jrtc27@jrtc27.com, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, guoren@linux.alibaba.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 19, 2023 at 8:14=E2=80=AFAM Paul Walmsley wrote: > > On Thu, 18 May 2023, Palmer Dabbelt wrote: > > > On Thu, 18 May 2023 06:09:51 PDT (-0700), guoren@kernel.org wrote: > > > > > This patch series adds s64ilp32 support to riscv. The term s64ilp32 > > > means smode-xlen=3D64 and -mabi=3Dilp32 (ints, longs, and pointers ar= e all > > > 32-bit), i.e., running 32-bit Linux kernel on pure 64-bit supervisor > > > mode. There have been many 64ilp32 abis existing, such as mips-n32 [1= ], > > > arm-aarch64ilp32 [2], and x86-x32 [3], but they are all about userspa= ce. > > > Thus, this should be the first time running a 32-bit Linux kernel wit= h > > > the 64ilp32 ABI at supervisor mode (If not, correct me). > > > > Does anyone actually want this? At a bare minimum we'd need to add it = to the > > psABI, which would presumably also be required on the compiler side of = things. > > > > It's not even clear anyone wants rv64/ilp32 in userspace, the kernel se= ems > > like it'd be even less widely used. > > We've certainly talked to folks who are interested in RV64 ILP32 userspac= e > with an LP64 kernel. The motivation is the usual one: to reduce data siz= e > and therefore (ideally) BOM cost. I think this work, if it goes forward, > would need to go hand in hand with the RVIA psABI group. > > The RV64 ILP32 kernel and ILP32 userspace approach implemented by this > patch is intriguing, but I guess for me, the question is whether it's > worth the extra hassle vs. a pure RV32 kernel & userspace. Running pure RV32 kernel on 64-bit hardware is not an intelligent choice (such as cortex-a35/a53/a55), because they wasted 64-bit hw capabilities, and the hardware designer would waste additional resources & time on 32-bit machine & supervisor modes (In arm it is called EL3/EL2/EL1 modes). Think about too many PMP CSRs, PMU CSRs, and mode switch ... it's definitely wrong to follow the cortex-a35/a53/a55 way to deal with riscv32 on a 64-bit hardware. The chapter "Why s64ilp32 has better performance?" give out the improvement v.s. pure 32-bit, I repeat it here: - memcpy/memset/strcmp (s64ilp32 has half of the number of instructions and double the bandwidth per load/store instruction than s32ilp32.) - ebpf JIT is a 64-bit virtual ISA, which couldn't be sufficient mapping by s32ilp32, but s64ilp32 could (just like s64lp64). - Atomic64 (s64ilp32 has the exact native instructions mapping as s64lp64, but s32ilp32 only uses generic_atomic64, a tradeoff & limited software solution.) - 64-bit native arithmetic instructions for "long long" type - riscv s64ilp32 could support cmxchg_double for slub (The 2nd 32-bit Linux supports the feature, the 1st is i386.) > > > - Paul --=20 Best Regards Guo Ren