Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp865785rwl; Fri, 24 Mar 2023 03:08:46 -0700 (PDT) X-Google-Smtp-Source: AKy350YaRLCJM1Jvz9bAhuGZWI+LBHZ3qluMcEEDeVyHD8njL1XGLnPEucncm2Xv7V1/oA+iXUSm X-Received: by 2002:a17:906:d201:b0:8f1:949f:37b5 with SMTP id w1-20020a170906d20100b008f1949f37b5mr2110346ejz.32.1679652526605; Fri, 24 Mar 2023 03:08:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679652526; cv=none; d=google.com; s=arc-20160816; b=nS32K1bHYqbm18MdO1BYSHx6SnMrN0deV18QytCJE5ixS5IvAU+yujt1Mvb/MWIRjI YQmJHVCNL2q/W5a2RbpUenzKcz+cxTevrc/j5kT5k3d4W8qETmgUnAxzu8sZCdlfkQrd nzq1ATs2VsW//yqMlw4SIl8gZWq7WBwnmKwmuj8XmFluCKTfKqFDtYvo9pLQsjIeAiFN LpDdf/xKRJLCX/mbMYqFoEtWKJeofcmmQPg0a5hStk7RpHeadqVOK8ClqLaucJc67LXt Q7JQ/8decSuvtd7P3xhLR/o7xo98uUof9gZYX6SWrs9DYYSPwxjN7l/L+xbgQnpxQnx5 6XfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=E6AwixfBQbne28OyhNf/gJ+5yFp3V81EKq5FyKRx8Nc=; b=HJ0gIvrqkT4q3li4hDB5MWRt+rd6uL+jq9QihNQQpJJCWmIjEuv+7xzmrbo5ygjVZ9 lA3zKbXhXaiRXXU0woNozXzxO4vvkNmqt3xoYhD9HpJvFFL/zCEIrHrfIAYVNRhqTg1R rIbSBKC2i/qY9pqf4KZsyhhpAHGweI4UmhEYNtchRLkt22UPqs7z5L+tVRLG2YvU1H0K NQZX9THa4tyqSuCD7t9+e+S/HL/U32pxMPcLIBh204l856zIxecsjMBuqHAy8ASRUMhM 3LQgQoodpgt06+knre7GX1C6sJTzx963NwfgfwjFGggDi8xQ599Z8aROXFpPkkMmMPp1 dgbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=XxQ6QUci; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xi14-20020a170906dace00b0093348ceb372si17795381ejb.742.2023.03.24.03.08.22; Fri, 24 Mar 2023 03:08:46 -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=@microchip.com header.s=mchp header.b=XxQ6QUci; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229997AbjCXKGk (ORCPT + 99 others); Fri, 24 Mar 2023 06:06:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229623AbjCXKGi (ORCPT ); Fri, 24 Mar 2023 06:06:38 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DE211B2F8 for ; Fri, 24 Mar 2023 03:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1679652395; x=1711188395; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=htACZM7UlhSwkOQstbGQxtdxCYSPTGxE1Ea6gOWEefY=; b=XxQ6QUciyX9sSfnoQBrw4ot0anmP/F4HsnVFJiAIp1WH+zx6JVVhMrMu cttue8adNtwYYJpT4cte4d7zqshoe6b77XUBodR4bYej5peQoGVngbnD6 LyHyoZ2tEYxjVykMZDxWe06yHYl44Xxkb6xlq/mLkBFTOqJ4Gvu6Nnd4a 92oKPbAx5/XN3LkvIwkqGikulh8QEf7AFGx7QA2gXkrmfTBvar6y8YGPV MThVgNtexbclcuubRL/HxQpyn0ErJ6Zif69NzRIj/EKrYsfgdLKsszc4a 1ghfZ84NsWAEV1pNrCmwwv1YltPMZdcChd5hlCDanXn0KeCB3aHOIimFU A==; X-IronPort-AV: E=Sophos;i="5.98,287,1673938800"; d="scan'208";a="207071497" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Mar 2023 03:06:33 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Fri, 24 Mar 2023 03:06:30 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Fri, 24 Mar 2023 03:06:28 -0700 From: Conor Dooley To: CC: , , Paul Walmsley , Heiko Stuebner , "Andrew Jones" , Anup Patel , Jisheng Zhang , "Jason A . Donenfeld" , , Subject: [PATCH v1 0/2] RISC-V: Fixes for riscv_has_extension[un]likely()'s alternative dependency Date: Fri, 24 Mar 2023 10:05:37 +0000 Message-ID: <20230324100538.3514663-1-conor.dooley@microchip.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2362; i=conor.dooley@microchip.com; h=from:subject; bh=htACZM7UlhSwkOQstbGQxtdxCYSPTGxE1Ea6gOWEefY=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDCmypS92qRYZn+/YlrjG1sNGZr34v4z95suYXz++czb4TPqu CFeZjlIWBjEOBlkxRZbE230tUuv/uOxw7nkLM4eVCWQIAxenAExEVImR4eHLHNk3rpevrGdmW7vnjd H5wBD+vRMavs5abMKx67HCvUBGhu/lbb3nd1vNtrNOMVC5eefqYzVxUY/eXbGPF+48a7ViMz8A X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 Here's my attempt at fixing both the use of an FPU on XIP kernels and the issue that Jason ran into where CONFIG_FPU, which needs the alternatives frame work for has_fpu() checks, could be enabled without the alternatives actually being present. For the former, a "slow" fallback that does not use alternatives is added to riscv_has_extension_[un]likely() that can be used with XIP. Obviously, we want to make use of Jisheng's alternatives based approach where possible, so any users of riscv_has_extension_[un]likely() will want to make sure that they select RISCV_ALTERNATIVE. If they don't however, they'll hit the fallback path which (should, sparing a silly mistake from me!) behave in the same way, thus succeeding silently. Sounds like a To prevent "depends on !XIP_KERNEL; select RISCV_ALTERNATIVE" spreading like the plague through the various places that want to check for the presence of extensions, and sidestep the potential silent "success" mentioned above, all users RISCV_ALTERNATIVE are converted from selects to dependencies, with the option being selected for all !XIP_KERNEL builds. I know that the VDSO was a key place that Jisheng wanted to use the new helper rather than static branches, and I think the fallback path should not cause issues there. See the thread at [1] for the prior discussion. Cheers, Conor. 1 - https://lore.kernel.org/linux-riscv/20230128172856.3814-1-jszhang@kernel.org/T/#m21390d570997145d31dd8bb95002fd61f99c6573 CC: Paul Walmsley CC: Palmer Dabbelt CC: Conor Dooley CC: Heiko Stuebner CC: Andrew Jones CC: Anup Patel CC: Jisheng Zhang CC: Andrew Jones CC: Jason A. Donenfeld CC: linux-riscv@lists.infradead.org CC: linux-kernel@vger.kernel.org Conor Dooley (2): RISC-V: add non-alternative fallback for riscv_has_extension_[un]likely() RISC-V: always select RISCV_ALTERNATIVE for non-xip kernels arch/riscv/Kconfig | 12 ++++---- arch/riscv/Kconfig.erratas | 6 ++-- arch/riscv/include/asm/hwcap.h | 50 ++++++++++++++++++++-------------- 3 files changed, 38 insertions(+), 30 deletions(-) -- 2.39.2