Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2008871rdg; Sun, 15 Oct 2023 07:12:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVtxoGH4ZfpQYYvCDS336KWIZK9SRP8/cCQ/Z976MA94PeIa0PcziFGDRmKw7GdAEnfZDZ X-Received: by 2002:a17:902:f544:b0:1c5:c546:fece with SMTP id h4-20020a170902f54400b001c5c546fecemr7920406plf.34.1697379136690; Sun, 15 Oct 2023 07:12:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697379136; cv=none; d=google.com; s=arc-20160816; b=caRNVFHcW6Fn2wHFc/80+B3hgKJWgdrPa9cE0uqbQWQga6kFV6fTrHKwqxXBTsqbht 6JnYr0PGjpD069jE+SChMvAg4pIqvaf9UA+8j6aF/dJRs4A4xacsZbKn1ZrtOkgZ0H86 nRVm8jdIqU/8CjEBewGCZUE7r4G25BATIlmFdKOy2ZP6ko23mHaLCWB9e9yrIT7CWoHP av5m9KPP0b8w2HDAFeAwqXtS/stWQgFoz5gzrJkylmEKH4BdrABSkPnV4EZ5GvsgPg+g /FFDQZySNKmA52j9zohLb1XihOxgJegYXq4cEw5bFaGkSuvh0N5Q4WaMFzHw28w2AQox 5TwA== 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=Ise+C5cKUotgz+3PuJu2pk3lDJnX7Jy8snFVt0KMCj4=; fh=ZX/Oy7MD3c04GUTZ42O9/FGc0/XhwpKeKJgqQzkb4Ss=; b=PuUK7AdYbxAW2XBLjcqGIzaiZw5LTHkk8YSKzkAqtuRp8sGZzJD/TxriOFXuvKgrBL Ws0ESadNi1LsO5cPVOOLKWh/V9UR8ccB0TBnoE/k4nkD6YM4/F+6L/yH1lIumsK+zxmF rtuXk4VqO1qfsfrgU/AJzJ7lZOH5ODYW4Xqg9tDq9S9iMG5zMS4N9SScLaQkDcyGlX+w olCmpE6b7Ubxv2uvqwjZAzSXzax1NjpX+fMJX8v+stFAo1FZiOZNfLZDfqhDSahtAMhp ImEvVtF7JXPNVD3NlTXzyGc9Fa9vtHKOFXCraRkCmC/uKXF/aXLD25EBTsbxS0Wr8cT2 jCQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=skSL6MG8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id w9-20020a170902e88900b001b80de4d3f7si9199637plg.558.2023.10.15.07.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 07:12:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=skSL6MG8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 4208680755D8; Sun, 15 Oct 2023 07:12:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229772AbjJOOLw (ORCPT + 99 others); Sun, 15 Oct 2023 10:11:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjJOOLu (ORCPT ); Sun, 15 Oct 2023 10:11:50 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4DA4C1 for ; Sun, 15 Oct 2023 07:11:49 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4D07C433C8; Sun, 15 Oct 2023 14:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697379109; bh=LFNdNsGAMbqe7hSeH1fGRFeRTjU002PIz9XKawV1Jzo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=skSL6MG8l7wMkAGqXvF0oJSKdTWKSwCtreJt4iU3vrdia+jazYFbeFh9ga4kFr0t2 SFof4vJLThtIW7J5PEvtHq+vZCIY2gRxipBudDHBo5a8ycvbU4/dO7HHmxXCoeH1QM l/ZvHKdWZ9z7OZE+BkgzgQvFmX9xSSnjnTrwR4DA4Ojstc6neVFx83HPkEo80VY459 4wW25wZFKcR1qML96cT7WnjviyydeaQ9s3BMwwlN8+lpWn4HnB0VcJLXOfz8rd0ML6 qgfFyWCDXc3PHUQ1JfrT2+syhy6ZNIx0zsUDCmW/1TCh8VL1MPbjlAzpxr819M6dLF 8RPX3Ei2Mwbvw== Date: Sun, 15 Oct 2023 07:11:47 -0700 From: Josh Poimboeuf To: Ingo Molnar Cc: Breno Leitao , 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: <20231015141147.qeczgcfnl73zcqao@treble> References: <20231010103028.4192223-1-leitao@debian.org> <20231012170548.o5vi4kgpvpjyld7s@treble> <20231012204347.4aei5jr64fsv2iv5@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 15 Oct 2023 07:12:07 -0700 (PDT) On Fri, Oct 13, 2023 at 12:50:59PM +0200, Ingo Molnar wrote: > > * Josh Poimboeuf wrote: > > > On Thu, Oct 12, 2023 at 08:51:24PM +0200, Ingo Molnar wrote: > > > > 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; > > > > > > I think we could make it a simple: > > > > > > static enum retbleed_mitigation_cmd retbleed_cmd __ro_after_init = IS_ENABLED(CONFIG_MITIGATION_RETBLEED); > > > > > > Because RETBLEED_CMD_AUTO && RETBLEED_CMD_OFF maps naturally to 1 and 0. > > > Maybe add a comment to the enum to maintain this property in the future > > > too. > > > > Hm, that both obfuscates the default and makes it fragile. The fact > > that it would need a comment to try to prevent breaking it in the future > > is a clue that maybe we shouldn't do it ;-) > > Can be enforced with BUILD_BUG_ON(). That replaces fragility with brittleness. If we change a default then we have to go rearrange the corresponding enum, and update the BUILD_BUG_ONs. More importantly, it's still less readable because the reader now has to go read the enum values to cross-reference the hard-coded values of 0 and 1 with the enums which are used everywhere else. -- Josh