Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3287697lfo; Mon, 23 May 2022 00:46:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrYm7yyI4ApMqLSt2DW3m8km4h6yV/QTsrUeC/bfe6nNc4Ho6tKI2b/lF4fQVqIjdi2zdF X-Received: by 2002:a05:6a00:1690:b0:517:cc9e:3e2d with SMTP id k16-20020a056a00169000b00517cc9e3e2dmr22434733pfc.0.1653291984592; Mon, 23 May 2022 00:46:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653291984; cv=none; d=google.com; s=arc-20160816; b=kwe7LogdlOUJuiGqGugtV00HaTck4uuTTR13mH6/ZuYm2/zU8c+yRRf25fC6LCYq1/ n2oE8mZYR6t7mlC85xtDr0lHHZChRCnKPs7oCZbpni4l6UUCEt06g0gmZNTLqFC3Pu6Q qJPz2rkCd75skkfeXHu+ogvS3ayF8fC4mZjgs0DXiRAz1YuBZ8jQG92GHvmLGI0cyaBt 9jWd2wg/byFtIMW5zwRstTTMf4vo2QVH7OOZ9mSd/w6TajUkaUXQXu8haza3ISdC+51B pj8WjaOKYUPuHijpDRHx1zF2cWgGKLdk4LzX45dfVatvIya8fKbAGi3RNwWo+cyU2Rnr iTyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=N0+fMy3LRNV0T9ZohrlGa4BOxOGgvZ1756cMszJvTdI=; b=D8pjqYr9KajdRKD8dj9N7NSw/J7Wjgztd+ORdDF32sWom37a3t1t5fkGj3A1Uke19v STyIhSe9+CLJynsr/EGBG+XuMI2j1i9o3wqraBiHP+00vhxg1H2EBNiG30vi/QnVvMr2 0zZtFUA9FnqCqb2KCmUsXrCtwthm7W4ScwQL934FHufa1ymfog36HYcXTdsWYnFqkl5/ 9Ir1p2Bawps1wy2BHgSLKgPABO3dYiD7WpPRTqO1rA7Iz+Kdj1bK+Kqm+L5vpJHDEzaJ kyndeS+PtzKszVRR+zOfZkKamhNVqf2ouq6IBkrHKb+25IbPjEkXHbLnV3amNlNjF92N W9xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YkuqlzhQ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i196-20020a636dcd000000b0039cef73106esi9440788pgc.511.2022.05.23.00.46.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:46:24 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YkuqlzhQ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C44E550B2C; Sun, 22 May 2022 23:51:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239728AbiEVM1Y (ORCPT + 99 others); Sun, 22 May 2022 08:27:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229928AbiEVM1U (ORCPT ); Sun, 22 May 2022 08:27:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90F4D3CA68 for ; Sun, 22 May 2022 05:27:19 -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 ams.source.kernel.org (Postfix) with ESMTPS id 52871B80C76 for ; Sun, 22 May 2022 12:27:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2009CC3411D for ; Sun, 22 May 2022 12:27:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653222437; bh=Nci77uD3HpKrTwmVZUdG4NYUnqtN/KNhXn7sZTDvIp0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=YkuqlzhQvNqLR2Zn0drk8XlKenZS/K6hBJIKPzx5IuRmNlqqEnNYyz/bIeZD8ju41 ZVTEBed3lMMFTrnQbU110T9t41OTk9Z5mZYJpAdFNfJIkzkDbIw69n08PLMpO3/+mG VNv/p2xJAOlen4sNmBfNMspNN4lXDJvA7RR4ve6JtNzTqg56T6Tv3CQa7lu2xPqOAS UV/eWf8FIL15XXoKdMKduuqteJ9kr1NsBK7udGnPoLkcW4N/OkL5652FuID+06rmyd Nu7zviIFr7An1XR1EDQPnd8SNCmCRCRNenvXPGuki7JILra3I0tfoDOsZ6y5QWuw5Y sgKMiBv+/9tIQ== Received: by mail-vs1-f43.google.com with SMTP id z6so12337750vsp.0 for ; Sun, 22 May 2022 05:27:17 -0700 (PDT) X-Gm-Message-State: AOAM53317po+zRr6tqkytT9IXs/40zRwRhBNmLNJ3WaKRE/JOu4OzSKy Xm8wvtEC4hrVBxdnxe0A3LMgkuhqrIeSipgmiIU= X-Received: by 2002:a05:6102:390b:b0:32d:5fc3:bd2c with SMTP id e11-20020a056102390b00b0032d5fc3bd2cmr6567800vsu.51.1653222435738; Sun, 22 May 2022 05:27:15 -0700 (PDT) MIME-Version: 1.0 References: <20220521193356.26562-1-palmer@rivosinc.com> In-Reply-To: <20220521193356.26562-1-palmer@rivosinc.com> From: Guo Ren Date: Sun, 22 May 2022 20:27:04 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3] RISC-V: Add CONFIG_{NON,}PORTABLE To: Palmer Dabbelt Cc: linux-riscv , Paul Walmsley , Palmer Dabbelt , Albert Ou , Randy Dunlap , Arnd Bergmann , Anup Patel , Alexandre Ghiti , damien.lemoal@opensource.wdc.com, Atish Patra , Jens Axboe , Mayuresh Chitale , Linux Kernel Mailing List , linux@rivosinc.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Reviewed-by: Guo Ren On Sun, May 22, 2022 at 4:46 AM Palmer Dabbelt wrote: > > From: Palmer Dabbelt > > The RISC-V port has collected a handful of options that are > fundamentally non-portable. To prevent users from shooting themselves > in the foot, hide them all behind a config entry that explicitly calls > out that non-portable binaries may be produced. > > Signed-off-by: Palmer Dabbelt > Reviewed-by: Arnd Bergmann > Signed-off-by: Palmer Dabbelt > --- > Changes since v2: > > * Update the nommu and rv32 defconfigs. I'm still getting some ugliness > like > > $ make.riscv rv32_defconfig > *** Default configuration is based on 'defconfig' > # > # configuration written to .config > # > Using .config as base > Merging ./arch/riscv/configs/32-bit.config > Value of CONFIG_PORTABLE is redefined by fragment ./arch/riscv/configs/32-bit.config: > Previous value: CONFIG_PORTABLE=y > New value: # CONFIG_PORTABLE is not set > > Value of CONFIG_NONPORTABLE is redefined by fragment ./arch/riscv/configs/32-bit.config: > Previous value: # CONFIG_NONPORTABLE is not set > New value: CONFIG_NONPORTABLE=y > > # > # merged configuration written to .config (needs make) > # > .config:3831:warning: override: ARCH_RV32I changes choice state > # > # configuration written to .config > # > > not sure if there's a better way to do this. > > Changes since v1: > > * Fix a bunch of spelling mistakes. > * Move NONPORTABLE under the "Platform type" sub-heading. > * Fix the rv32i dependency. > > --- > arch/riscv/Kconfig | 28 +++++++++++++++++-- > arch/riscv/configs/32-bit.config | 2 ++ > arch/riscv/configs/nommu_k210_defconfig | 1 + > .../riscv/configs/nommu_k210_sdcard_defconfig | 1 + > arch/riscv/configs/nommu_virt_defconfig | 1 + > arch/riscv/configs/rv32_defconfig | 1 + > 6 files changed, 32 insertions(+), 2 deletions(-) > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > index f863065b478c..cd67b09a80f5 100644 > --- a/arch/riscv/Kconfig > +++ b/arch/riscv/Kconfig > @@ -222,6 +222,21 @@ source "arch/riscv/Kconfig.erratas" > > menu "Platform type" > > +config NONPORTABLE > + bool "Allow configurations that result in non-portable kernels" > + help > + RISC-V kernel binaries are compatible between all known systems > + whenever possible, but there are some use cases that can only be > + satisfied by configurations that result in kernel binaries that are > + not portable between systems. > + > + Selecting N does not guarantee kernels will be portable to all known > + systems. Selecting any of the options guarded by NONPORTABLE will > + result in kernel binaries that are unlikely to be portable between > + systems. > + > + If unsure, say N. > + > choice > prompt "Base ISA" > default ARCH_RV64I > @@ -231,6 +246,7 @@ choice > > config ARCH_RV32I > bool "RV32I" > + depends on NONPORTABLE > select 32BIT > select GENERIC_LIB_ASHLDI3 > select GENERIC_LIB_ASHRDI3 > @@ -541,6 +557,7 @@ config STACKPROTECTOR_PER_TASK > > config PHYS_RAM_BASE_FIXED > bool "Explicitly specified physical RAM address" > + depends on NONPORTABLE > default n > > config PHYS_RAM_BASE > @@ -554,7 +571,7 @@ config PHYS_RAM_BASE > > config XIP_KERNEL > bool "Kernel Execute-In-Place from ROM" > - depends on MMU && SPARSEMEM > + depends on MMU && SPARSEMEM && NONPORTABLE > # This prevents XIP from being enabled by all{yes,mod}config, which > # fail to build since XIP doesn't support large kernels. > depends on !COMPILE_TEST > @@ -594,9 +611,16 @@ endmenu > > config BUILTIN_DTB > bool > - depends on OF > + depends on OF && NONPORTABLE > default y if XIP_KERNEL > > +config PORTABLE > + bool > + default !NONPORTABLE > + select EFI > + select OF > + select MMU > + > menu "Power management options" > > source "kernel/power/Kconfig" > diff --git a/arch/riscv/configs/32-bit.config b/arch/riscv/configs/32-bit.config > index 43f41323b67e..f6af0f708df4 100644 > --- a/arch/riscv/configs/32-bit.config > +++ b/arch/riscv/configs/32-bit.config > @@ -1,2 +1,4 @@ > CONFIG_ARCH_RV32I=y > CONFIG_32BIT=y > +# CONFIG_PORTABLE is not set > +CONFIG_NONPORTABLE=y > diff --git a/arch/riscv/configs/nommu_k210_defconfig b/arch/riscv/configs/nommu_k210_defconfig > index 2438fa39f8ae..96fe8def644c 100644 > --- a/arch/riscv/configs/nommu_k210_defconfig > +++ b/arch/riscv/configs/nommu_k210_defconfig > @@ -28,6 +28,7 @@ CONFIG_EMBEDDED=y > CONFIG_SLOB=y > # CONFIG_MMU is not set > CONFIG_SOC_CANAAN=y > +CONFIG_NONPORTABLE=y > CONFIG_SMP=y > CONFIG_NR_CPUS=2 > CONFIG_CMDLINE="earlycon console=ttySIF0" > diff --git a/arch/riscv/configs/nommu_k210_sdcard_defconfig b/arch/riscv/configs/nommu_k210_sdcard_defconfig > index 9a133e63ae5b..379740654373 100644 > --- a/arch/riscv/configs/nommu_k210_sdcard_defconfig > +++ b/arch/riscv/configs/nommu_k210_sdcard_defconfig > @@ -20,6 +20,7 @@ CONFIG_EMBEDDED=y > CONFIG_SLOB=y > # CONFIG_MMU is not set > CONFIG_SOC_CANAAN=y > +CONFIG_NONPORTABLE=y > CONFIG_SMP=y > CONFIG_NR_CPUS=2 > CONFIG_CMDLINE="earlycon console=ttySIF0 root=/dev/mmcblk0p1 rootwait ro" > diff --git a/arch/riscv/configs/nommu_virt_defconfig b/arch/riscv/configs/nommu_virt_defconfig > index 5269fbb6b4fc..1a56eda5ce46 100644 > --- a/arch/riscv/configs/nommu_virt_defconfig > +++ b/arch/riscv/configs/nommu_virt_defconfig > @@ -25,6 +25,7 @@ CONFIG_EXPERT=y > CONFIG_SLOB=y > # CONFIG_MMU is not set > CONFIG_SOC_VIRT=y > +CONFIG_NONPORTABLE=y > CONFIG_SMP=y > CONFIG_CMDLINE="root=/dev/vda rw earlycon=uart8250,mmio,0x10000000,115200n8 console=ttyS0" > CONFIG_CMDLINE_FORCE=y > diff --git a/arch/riscv/configs/rv32_defconfig b/arch/riscv/configs/rv32_defconfig > index 7e5efdc3829d..77bdb1d05a88 100644 > --- a/arch/riscv/configs/rv32_defconfig > +++ b/arch/riscv/configs/rv32_defconfig > @@ -18,6 +18,7 @@ CONFIG_EXPERT=y > CONFIG_PROFILING=y > CONFIG_SOC_SIFIVE=y > CONFIG_SOC_VIRT=y > +CONFIG_NONPORTABLE=y > CONFIG_ARCH_RV32I=y > CONFIG_SMP=y > CONFIG_HOTPLUG_CPU=y > -- > 2.34.1 > -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/