Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1752552rwd; Thu, 15 Jun 2023 15:24:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7tz1136idNruoJqCohy9eco6ZcfTwhmlLldszIYTC8fsgAFmww9QCcBZnX3bt5duIGv0z7 X-Received: by 2002:a92:c991:0:b0:340:7430:2315 with SMTP id y17-20020a92c991000000b0034074302315mr714445iln.23.1686867842503; Thu, 15 Jun 2023 15:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686867842; cv=none; d=google.com; s=arc-20160816; b=BLRMBI0kRFJynBWJPRg94go2h0/dQ1k6lo8DPpJMi9C/Tf2WUCbWEcqjZe6SfsOXn2 RsrNxW6jKCg/x2u9YhFLozpWl7cVmS69IdqJzu8gRxb5YmPWRyyTgEyDmvpic2X+HECW 1y5y24rGSkuYhIp34mtY5v6cmZZU1pgEn477CUIBzsFeDLY2pc9C23FOpLcqbkRYO4LJ EkuAopWc/dWrmF56Rv9dVFmwWN59JvEM8AqF8+7jHZQXvn7/hD7l5N1xixiiYZF9G8Ki TcpCYNNKyVb9NELWvIIkf8FanI7xHJIiz6knBd5AR6HNJ/Onr2OEgqNytDJXYIL8JzK9 ehow== 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=uhWJ5ml6c2grIR5qp4w7yTxLb1IJly640qPhh4gR2oQ=; b=pHjtgfG5LkrZ6jS/G9tkFpeUivEnGqF77ewQlFO0yONSl4jS1b5AVke6X//RI0RPPJ SBnlZHVLm5frWXSv76eBrVQowAQBMCYSrM/3jwxDsSgtZh+qdzut56QnlLGX9ieuAqsN uHTBf8l1PsjPKzGGVGFza2HNecVSaLvsvp4K9xmB8pUJeQ/vQ09pek2CF5xFwYBbktlR AFgTIzosVhdMda7EZ0NMxnRpWVuw6o9KsVP3fjWgsS59Xzyhkw+pS/HZduqZ6FiCmOL8 KUfUkMvSQuTVTUZvti7Oa+YEgm0mIGi/CCdV3xzxrX2LNvh8p+KXPMX9Zh0dvWu8qodL bx4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=daDlw3z6; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s70-20020a632c49000000b0053f2551834fsi13965547pgs.552.2023.06.15.15.23.50; Thu, 15 Jun 2023 15:24:02 -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=@intel.com header.s=Intel header.b=daDlw3z6; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238959AbjFOWO1 (ORCPT + 99 others); Thu, 15 Jun 2023 18:14:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232199AbjFOWOW (ORCPT ); Thu, 15 Jun 2023 18:14:22 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAEA5296C for ; Thu, 15 Jun 2023 15:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686867256; x=1718403256; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=o6CzlnOxUp7Pn23UIx3PBDccZCaI5gkIID8mocI167g=; b=daDlw3z6GB+u8bYWoMsRpr9l5SJkJxLkcakFIUr6iPpZJzvUwnzWvHB8 B3Y/b9+IhcvdvN8+TAzA7QnLDq2x93sAAAXDRzo41e4qgLE1TEfNOIgJj 1k8cWSW/VmcytjlMWZLyZJQdcJKv1Ipikh4GhyNLboSS/rrYAY/IOMoKi JbXlRFdhnyjNzEwdAEw5ldMCISMvJT1vX/KSpqQcBzRo8p0MM3i92Lo1T FpVf2bGSqVIyf8epeMtVVQoIg1NH0nVj+D5JPuGIQAVv2LvnJ/i9HthED /ESeus24kqF4DfUIcZKyOdOORkaOXjLjgdOBjM1v6R6RSy6BGXC7H5wdD A==; X-IronPort-AV: E=McAfee;i="6600,9927,10742"; a="356543710" X-IronPort-AV: E=Sophos;i="6.00,245,1681196400"; d="scan'208";a="356543710" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2023 15:13:54 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10742"; a="745846573" X-IronPort-AV: E=Sophos;i="6.00,245,1681196400"; d="scan'208";a="745846573" Received: from ckale-mobl1.amr.corp.intel.com (HELO desk) ([10.212.176.170]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2023 15:13:54 -0700 Date: Thu, 15 Jun 2023 15:13:47 -0700 From: Pawan Gupta To: Breno Leitao Cc: jpoimboe@kernel.org, peterz@infradead.org, tglx@linutronix.de, bp@alien8.de, Ingo Molnar , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , leit@fb.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] x86/bugs: Create an option to disable MDS Message-ID: <20230615221347.6ghb4d33tituxht4@desk> References: <20230615164417.3588162-1-leitao@debian.org> <20230615164417.3588162-2-leitao@debian.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230615164417.3588162-2-leitao@debian.org> X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On Thu, Jun 15, 2023 at 09:44:12AM -0700, Breno Leitao wrote: > diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c > index 182af64387d0..50f12829dce9 100644 > --- a/arch/x86/kernel/cpu/bugs.c > +++ b/arch/x86/kernel/cpu/bugs.c > @@ -269,6 +269,7 @@ static void x86_amd_ssb_disable(void) > /* Default mitigation for MDS-affected CPUs */ > static enum mds_mitigations mds_mitigation __ro_after_init = MDS_MITIGATION_FULL; > static bool mds_nosmt __ro_after_init = false; > +#define MDS_WARN_MSG "WARNING: Microarchitectural Data Sampling (MDS) speculative mitigation disabled!\n" > > static const char * const mds_strings[] = { > [MDS_MITIGATION_OFF] = "Vulnerable", > @@ -278,11 +279,17 @@ static const char * const mds_strings[] = { > > static void __init mds_select_mitigation(void) > { > - if (!boot_cpu_has_bug(X86_BUG_MDS) || cpu_mitigations_off()) { > + if (!boot_cpu_has_bug(X86_BUG_MDS)) { > mds_mitigation = MDS_MITIGATION_OFF; > return; > } > > + if (cpu_mitigations_off() || !IS_ENABLED(CONFIG_MITIGATE_MDS)) { > + mds_mitigation = MDS_MITIGATION_OFF; > + pr_err(MDS_WARN_MSG); > + return; Why does compile time config needs to be so restrictive that it does not allow runtime override with mds= cmdline? I believe Kconfig should only be setting the mitigation default, allowing users to select mitigation at runtime: --- diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 182af64387d0..50e1ca4ea68b 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -267,7 +267,11 @@ static void x86_amd_ssb_disable(void) #define pr_fmt(fmt) "MDS: " fmt /* Default mitigation for MDS-affected CPUs */ +#if IS_ENABLED(CONFIG_MITIGATE_MDS) static enum mds_mitigations mds_mitigation __ro_after_init = MDS_MITIGATION_FULL; +#else +static enum mds_mitigations mds_mitigation __ro_after_init = MDS_MITIGATION_OFF; +#endif static bool mds_nosmt __ro_after_init = false; static const char * const mds_strings[] = {