Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp449948rdg; Thu, 12 Oct 2023 10:06:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwxMrNTqul/+IhuNNouLLQmeCoJZ9Ii2ax3D7yQtI+StHXEZDYr2FuiZCc1Twi6Zh95RWA X-Received: by 2002:a05:6a20:4292:b0:14c:a53c:498c with SMTP id o18-20020a056a20429200b0014ca53c498cmr26251342pzj.10.1697130385052; Thu, 12 Oct 2023 10:06:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697130385; cv=none; d=google.com; s=arc-20160816; b=dP6YnIovsLoU+u/tkiQW9ptzlMrsg5xmSsY5wCAIZJwdB2zqO/moKbcHf4daplehE3 TGMr8e4rs1bAdUevKM4nv4ScfXlXiP8vNcIOLounkVgfr/wK/FYfY0bVQv8eH7uAorwJ oF+nMSkmyVB1RLOPSFJ/HOHEovDjLJIlfyT+JReQOktRJhb1WWfuw3OAwCvpcTJI0uTK 54Hf5QoE8O47bchIFg29WE9xVMR2n2IYlxIgnBielv1t4rCfuvxGGuePJlavHvHo48QY ehwTodt/4roSE6Le+DkgRSCgP0ikOAkPBlMofZse74/4zFXhQdS1/4u9tojfHlNuDzFl yA8w== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Vh4smv6G9oHf8Sf+8luio6s0uyX/gdb7rPtAFy26eBI=; fh=VU9KxgYkl2lnFiPBRBOM4a9B0TE0+01Phxd+prXJyOA=; b=SZr5n8SyrToUAEPyCk5P+RAW5Lp2nboZoGI6ggk/Rt+tweMynVR/aR/iFCaLtRQexU 8dM29NeyFohPGJ5yQ75DbG7kwab39wflQglBy82FjrK53MTLybn0gamPt7EC3eWIdCx6 wUL5TmMuIjhCbibjDGknIVPnLnRkFgvsnD27ck6IXTQhisbIsxA1Qhb+uirN4pF9NPT7 RvXq6rFm7Pjft3f9HaGt/29+xn2gum2vvBiJrNcJNlzOsts5Q08nOc1oBwK3nnqKb8He QmYJTUWhJ9rEnT6KSn692RJlIY2ucUjX0Dvj/nS71N0HWLNcZVNNb9rM1lrYMHhC8VEU T8fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H6u+XazX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id b11-20020a170902d88b00b001c3e8a6748asi2444686plz.644.2023.10.12.10.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 10:06:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H6u+XazX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id F295B8039FFC; Thu, 12 Oct 2023 10:06:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378915AbjJLRFy (ORCPT + 99 others); Thu, 12 Oct 2023 13:05:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344085AbjJLRFw (ORCPT ); Thu, 12 Oct 2023 13:05:52 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 386BFB7 for ; Thu, 12 Oct 2023 10:05:51 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BF44C433C8; Thu, 12 Oct 2023 17:05:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697130350; bh=qoB/kNnsksIOBWuSeqG2ewxVesEUJ5BMIGU22oh6agA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=H6u+XazX43tSdnEm8nhbDaCxcFioSoyj8ZzXQ9rVMX3nLFbAFcFf/q2uTtuTJ0gMT ODMxVo2cGyJ/aUKQwSCbjN/aRRT3/BGfp3EmwXhLSv0QZmgv/aOnTUopmO7ONnY8GB h3tqpP09ySx5dUtApAr0vDj3QKMHFYPlSh2ULw4YoUNBS/dmVPhmF14fnOjS4dany5 Yflp7OB87Aa5hFpR9WxPiMnX9wI8Ebqj15n65UW47RrtAs5FWixf25smfpHbLWn8jw 0CCaj/8n15jWg+WH6yynDnhLRXgM0gZo8K3BFo3FUJ4kLv7kclB5FDSdWxxKQChpbk EmjvCBVtvgm0Q== Date: Thu, 12 Oct 2023 10:05:48 -0700 From: Josh Poimboeuf To: Breno Leitao Cc: Ingo Molnar , tglx@linutronix.de, bp@alien8.de, Ingo Molnar , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Pawan Gupta , leit@meta.com, "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Subject: Re: [PATCH v4] x86/bugs: Add a separate config for each mitigation Message-ID: <20231012170548.o5vi4kgpvpjyld7s@treble> References: <20231010103028.4192223-1-leitao@debian.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, 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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 12 Oct 2023 10:06:02 -0700 (PDT) On Thu, Oct 12, 2023 at 06:02:41AM -0700, Breno Leitao wrote: > > Yeah, so this #ifdeffery is unnecessarily ugly - we can actually assign > > integer values in the Kconfig language and use that for initialization. > > > > Is there a reason why we wouldn't want to do something like: > > > > static enum retbleed_mitigation_cmd retbleed_cmd __ro_after_init = CONFIG_BOOT_DEFAULT_X86_MITIGATE_RETBLEED; > > > > ... or so? > > Yes. There are two reasons rigth now: > > 1) How to avoid the "undefined" behaviour when > CONFIG_BOOT_DEFAULT_X86_MITIGATE_RETBLEED is not defined ? Something as: > > error: ‘CONFIG_BOOT_DEFAULT_X86_MITIGATE_RETBLEED’ undeclared (first use in this function) > > 2) Right now, these _cmd values are all different by default. Here are a few > examples when the kernel is compiled with the mitigations: > > retbleed_cmd = RETBLEED_CMD_AUTO (1) > spectre_v2_mitigation_cmd = SPECTRE_V2_CMD_AUTO (1) > ssb_mitigation_cmd = SPEC_STORE_BYPASS_CMD_AUTO (1) > l1tf_mitigation = L1TF_MITIGATION_FLUSH(2) > mds_mitigation = MDS_MITIGATION_FULL(1) > taa_mitigation = TAA_MITIGATION_VERW (2) > mmio_mitigation = MMIO_MITIGATION_VERW (2) > gds_mitigation = GDS_MITIGATION_FULL (3) > > If there is a solution for 1, then I _think_ we can probably reorder the > enums, so, the "AUTO" value is always 1?! I'd rather avoid hard-coding enums as that adds fragility into the mix. Another way to avoid ifdeffery: static enum retbleed_mitigation_cmd retbleed_cmd __ro_after_init = IS_ENABLED(CONFIG_MITIGATION_RETBLEED) ? RETBLEED_CMD_AUTO : RETBLEED_CMD_OFF; > > 3) > > > > And yes, now that the rush of CPU vulnerabilities seems to be ebbing, we > > should probably consider unifying the existing hodgepodge of mitigation > > Kconfig options as well, to not build up even more technical debt. > > What do you mean by unifying the existing hodgepodge of mitigation > Kconfigs? If you are implying to just have fewer config options, I think > that is the opposite of what Linus has suggested previously: > > https://lore.kernel.org/all/CAHk-=wjTHeQjsqtHcBGvy9TaJQ5uAm5HrCDuOD9v7qA9U1Xr4w@mail.gmail.com/ I read that as Ingo agreeing with me that we should rename all the existing options for consistency. > > 4) > > > > Fourth, I think we should inform users (in the boot log) when a kernel > > .config changes a mitigation default value compared from what the upstream > > kernel thinks is a suitable default. > > > > Sometimes it can be a simple configuration mistake, or a user might have > > different opinion about the importance of a particular mitigation. Nothing > > heavy-handed, just a simple pr_info() table of changes? > > That could be done, but, right now messages are printed in regard to the > mitigations. Aren't these enough? > > Here are some examples: > > pr_info("MDS: %s\n", mds_strings[mds_mitigation]); > pr_info("TAA: %s\n", taa_strings[taa_mitigation]); > pr_info("MMIO Stale Data: %s\n", mmio_strings[mmio_mitigation]); > pr_info("MMIO Stale Data: Unknown: No mitigations\n"); > pr_info("%s\n", srbds_strings[srbds_mitigation]); > pr_info("%s\n", gds_strings[gds_mitigation]); > pr_info("%s\n", spectre_v1_strings[spectre_v1_mitigation]); > pr_info("%s\n", spectre_v2_user_strings[mode]); > pr_info("%s\n", retbleed_strings[retbleed_mitigation]); > pr_info("%s\n", ssb_strings[ssb_mode]); But notice many/most of those functions exit early if the mitigation is turned off, thereby skipping the pr_info(). It might be a matter of just tweaking the print behavior and making it consistent across all the mitigations. -- Josh