Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp7819099rwl; Thu, 23 Mar 2023 09:03:04 -0700 (PDT) X-Google-Smtp-Source: AK7set875ILHsAjXUFD3oiJM6QoPUthakQhun0Cd+J8Ag8I+qTt2YXV//HN0c8P19pIt8D9zDVnU X-Received: by 2002:a17:90b:3907:b0:23d:4e9d:2eb0 with SMTP id ob7-20020a17090b390700b0023d4e9d2eb0mr8042772pjb.36.1679587384650; Thu, 23 Mar 2023 09:03:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679587384; cv=none; d=google.com; s=arc-20160816; b=wKL/LFY5C+F78flOJyBVO9lR098ShUH4LOP5z7s64DXw+1s1SM3omog4WyGJpE2HrU g/sWTI13VKcxZJTYPl40RQd0p5c0lB9j2+Iz0uN2QXNrNcI4dz9g6NjMVdVROo+yeF8m s7jGQ5gpOwvCPWpuHNqzj2FARU6a4mbUeWgf3999G5psk049HKah1bnUh1gBRhUvy9b6 Rer+wjLTi5UQYXVJsNWpjj6S+56CNgu/yd3jhq3Z0XfAwHdUi26MmzWV9AhvWNWiZnjs y9G6RcjtLdYdUKhhV8RvncNY2A66RhiMi5QZgZ/dHspuSsJ+7NJrtNDWQTikgsumYeYg ciTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=E0QDLAcWMz6ZWQvPCSBnzoIiYMLhelgbcARCDPPOWLE=; b=qvX2J3fM+Ux6Cj0BZorNeNpj5ZddX9e+emV/c1Zhr9VQBVGyyu1d+pXZiFWYnIA+yi weChpcVbh2/hRFFEPsUGWkUxMhMRN/1vKhUpJttef9yIF14/1cW4e9E3QhmZQtw/ER0+ CgSusSytr9Qg30sKnfi7Obb9s4umagwEdJTAhR7Q90B14z7wU9+Fc1JjF9lX/jn3zTc0 ZhCrpsU5C2lGqGLm4P5YuyhRgpAY1pCS11r61MG9VulHZ9xyLgmSRQbGvHSAYq6jYAp2 lpt9A8S0AdXi7d+ndPhEQSBJLPU0is64Fj/P6uxLl/odNwXqMgIQfEzOaD6IdJx92+D6 Nrrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=A63aMhce; 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=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kx7-20020a170902f94700b0019c14335fc0si17759863plb.70.2023.03.23.09.02.51; Thu, 23 Mar 2023 09:03:04 -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=@zx2c4.com header.s=20210105 header.b=A63aMhce; 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=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232204AbjCWP4k (ORCPT + 99 others); Thu, 23 Mar 2023 11:56:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232196AbjCWP4i (ORCPT ); Thu, 23 Mar 2023 11:56:38 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FE91227A7; Thu, 23 Mar 2023 08:56:36 -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 B54E2B82193; Thu, 23 Mar 2023 15:56:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAF10C433D2; Thu, 23 Mar 2023 15:56:31 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="A63aMhce" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1679586989; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=E0QDLAcWMz6ZWQvPCSBnzoIiYMLhelgbcARCDPPOWLE=; b=A63aMhceMeMggmWfc1r72fOX8m28q7eHiq1pPxSfpctedpOcSEfTjKEPc4NstDyZLL39NB zpVsWtSG/hAldFxNq52W742ew8XAvTrO6D29HZpCIGbCRQeHlN3L4e/e1vDfG4BcArU7gR 0F+SzR1yMXW0XdwaIQSDwaxsPnj0ytQ= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id a8981c54 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 23 Mar 2023 15:56:28 +0000 (UTC) Date: Thu, 23 Mar 2023 16:56:24 +0100 From: "Jason A. Donenfeld" To: Conor Dooley Cc: Andrew Jones , Jisheng Zhang , Conor Dooley , Palmer Dabbelt , Paul Walmsley , Albert Ou , Anup Patel , Atish Patra , Heiko Stuebner , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, regressions@leemhuis.info, regressions@lists.linux.dev Subject: Re: [PATCH] riscv: require alternatives framework when selecting FPU support Message-ID: References: <20230322120907.2968494-1-Jason@zx2c4.com> <20230322124631.7p67thzeblrawsqj@orel> <1884bd96-2783-4556-bc57-8b733758baff@spud> <20230322192610.sad42xau33ye5ayn@orel> <2a3b08ce-5ab1-41b6-ad58-edbeff7b1acb@spud> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 On Thu, Mar 23, 2023 at 02:49:34PM +0000, Conor Dooley wrote: > This would requiring picking up your patch Jason, but with an > "if !XIP_KERNEL" added to the select. So the risk of making this all work is that we wind up forgetting to add `select alternatives if !xip` to various places that need it (fpu, kvm, maybe others? future others?), because it appears to work, thanks to the code in your patch. But making it work is also probably a good thing, since we obviously want the fpu and maybe other things to work on xip kernels. So maybe we should get rid of the CONFIG_RISCV_ALTERNATIVES knob entirely, making it "always enabled", and then conditonalize the alternatives code to BUILD_BUG_ON when called with CONFIG_XIP_KERNEL=y. Then, this build bug will get hit immediately by riscv_has_extension_*(), which will then require your patch, which can run in a `if (IS_ENABLED(XIP_KERNEL))` block or similar. The result of that will be: - !xip kernels properly use the fast riscv_has_extension_*() code and any alternatives code needed, since it's always selected. - xip kernels get a BUILD_BUG_ON if they use any alternatives-based code that doesn't have a xip fallback yet. What do you think of that approach? A "lighter weight" version of that approach would be to just remove all of the `select RISCV_ALTERNATIVES` lines, and instead make RISCV_ALTERNATIVES specify `default !XIP_KERNEL`. That would more or less amount to the above too, though with weirder error cases. Jason