From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47F11C4360F for ; Fri, 5 Apr 2019 13:57:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 009C72186A for ; Fri, 5 Apr 2019 13:57:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="R/osybCq"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=alien8.de header.i=@alien8.de header.b="Ei8Tz4yR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 009C72186A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=alien8.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Evms+R0fiZ3hDAbFf27qa3wIBPFvr5/K21tUVlkh8K8=; b=R/osybCqNWaueF NFV1GZBhiGKZkXnM+KfuYsf8Xc2ZVKwDGQZvQF8xxNVwMtJzU26ajwE5TDAm4UO8kK5ibL41m3cMy WDDxq2On7O7h6vyvnMPsiBMjUhyzGSqWf88P/BmbGA/1csW8NHo3s/dPlkRyYEvVmzVlnp3lEYWNN EIu/k8WwOwMVebaoBat/jzI4uYH4ImvzE/argy1TtkjBnzKT7nJWp6qKk9fshX0+UR+Zh2YsVG6NU wf6dwCXvt5n4yHYwTJMfaC0pTI0GC14TSOeHHSy0tittbZ2o5a0mpVZEBqqQWNtnT0lOnXF1hlLtt rwGeSVWnea+SzUb6O/nw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hCPLP-0007Gx-Kt; Fri, 05 Apr 2019 13:57:23 +0000 Received: from mail.skyhub.de ([5.9.137.197]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hCPLM-0007GB-2u for linux-arm-kernel@lists.infradead.org; Fri, 05 Apr 2019 13:57:21 +0000 Received: from zn.tnic (p200300EC2F148A00329C23FFFEA6A903.dip0.t-ipconnect.de [IPv6:2003:ec:2f14:8a00:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 6E5271EC05A6; Fri, 5 Apr 2019 15:57:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1554472638; 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: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=O4UcyGkVKqjCMDV4RKEHL/ZfLzZq+tk55TxsL4ffLco=; b=Ei8Tz4yR7zuJn7CJE0n6hAz17WJzl2w7nRekqRrJkkwm9Sz/RvpX4BO771fbchCcS0Et2t LPkAwY8rKoOxG2rez//jKqS+1a0Yshr6pQN01btrJJLe9aI8+l1VGgaMdUHr7qYzPwRFQn kO/gruRXjd/9x1fQyut47HXgp08BeYs= Date: Fri, 5 Apr 2019 15:57:12 +0200 From: Borislav Petkov To: Josh Poimboeuf Subject: Re: [PATCH RFC 2/5] x86/speculation: Add support for 'cpu_spec_mitigations=' cmdline options Message-ID: <20190405135712.GF23348@zn.tnic> References: <78c63cb08f36f55407f534d49cc2543079e44dbb.1554396090.git.jpoimboe@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <78c63cb08f36f55407f534d49cc2543079e44dbb.1554396090.git.jpoimboe@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190405_065720_286332_FCD6CA15 X-CRM114-Status: GOOD ( 22.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , Benjamin Herrenschmidt , Heiko Carstens , Paul Mackerras , "H . Peter Anvin" , Ingo Molnar , Andrea Arcangeli , linux-s390@vger.kernel.org, Michael Ellerman , x86@kernel.org, Will Deacon , Linus Torvalds , Catalin Marinas , Waiman Long , linux-arch@vger.kernel.org, Jon Masters , Jiri Kosina , Andy Lutomirski , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Tyler Hicks , Martin Schwidefsky , linuxppc-dev@lists.ozlabs.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Apr 04, 2019 at 11:44:12AM -0500, Josh Poimboeuf wrote: > Configure x86 runtime CPU speculation bug mitigations in accordance with > the 'cpu_spec_mitigations=' cmdline options. This affects Meltdown, > Spectre v2, Speculative Store Bypass, and L1TF. > > The default behavior is unchanged. > > Signed-off-by: Josh Poimboeuf > --- > .../admin-guide/kernel-parameters.txt | 15 +++++++++ > arch/x86/include/asm/processor.h | 1 + > arch/x86/kernel/cpu/bugs.c | 32 ++++++++++++++++--- > arch/x86/kvm/vmx/vmx.c | 2 ++ > arch/x86/mm/pti.c | 4 ++- > 5 files changed, 49 insertions(+), 5 deletions(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index ac42e510bd6e..29dc03971630 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -2552,6 +2552,11 @@ > > off > Disable all speculative CPU mitigations. > + Equivalent to: nopti [x86] > + nospectre_v2 [x86] > + spectre_v2_user=off [x86] > + spec_store_bypass_disable=off [x86] > + l1tf=off [x86] > > auto (default) > Mitigate all speculative CPU vulnerabilities, > @@ -2560,12 +2565,22 @@ > surprised by SMT getting disabled across kernel > upgrades, or who have other ways of avoiding > SMT-based attacks. > + Equivalent to: pti=auto [x86] > + spectre_v2=auto [x86] > + spectre_v2_user=auto [x86] > + spec_store_bypass_disable=auto [x86] > + l1tf=flush [x86] > > auto,nosmt > Mitigate all speculative CPU vulnerabilities, > disabling SMT if needed. This is for users who > always want to be fully mitigated, even if it > means losing SMT. > + Equivalent to: pti=auto [x86] > + spectre_v2=auto [x86] > + spectre_v2_user=auto [x86] > + spec_store_bypass_disable=auto [x86] > + l1tf=flush,nosmt [x86] > > mminit_loglevel= > [KNL] When CONFIG_DEBUG_MEMORY_INIT is set, this Yap, those sets look ok. > diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h > index 2bb3a648fc12..7e95b310f869 100644 > --- a/arch/x86/include/asm/processor.h > +++ b/arch/x86/include/asm/processor.h > @@ -982,6 +982,7 @@ void microcode_check(void); > > enum l1tf_mitigations { > L1TF_MITIGATION_OFF, > + L1TF_MITIGATION_DEFAULT, > L1TF_MITIGATION_FLUSH_NOWARN, > L1TF_MITIGATION_FLUSH, > L1TF_MITIGATION_FLUSH_NOSMT, > diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c > index 2da82eff0eb4..65b95fb95ba5 100644 > --- a/arch/x86/kernel/cpu/bugs.c > +++ b/arch/x86/kernel/cpu/bugs.c > @@ -308,8 +308,11 @@ spectre_v2_parse_user_cmdline(enum spectre_v2_mitigation_cmd v2_cmd) > > ret = cmdline_find_option(boot_command_line, "spectre_v2_user", > arg, sizeof(arg)); > - if (ret < 0) > + if (ret < 0) { > + if (cpu_spec_mitigations == CPU_SPEC_MITIGATIONS_OFF) > + return SPECTRE_V2_USER_CMD_NONE; Instead of sprinkling that test in those three functions, just do it once above in check_bugs(), before those *_select_mitigation() functions get to run and depending on the value, you either run them or use the default settings, for the OFF case, for example. > return SPECTRE_V2_USER_CMD_AUTO; > + } > > for (i = 0; i < ARRAY_SIZE(v2_user_options); i++) { > if (match_option(arg, ret, v2_user_options[i].option)) { > @@ -444,8 +447,11 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void) > return SPECTRE_V2_CMD_NONE; > > ret = cmdline_find_option(boot_command_line, "spectre_v2", arg, sizeof(arg)); > - if (ret < 0) > + if (ret < 0) { > + if (cpu_spec_mitigations == CPU_SPEC_MITIGATIONS_OFF) > + return SPECTRE_V2_CMD_NONE; > return SPECTRE_V2_CMD_AUTO; > + } > > for (i = 0; i < ARRAY_SIZE(mitigation_options); i++) { > if (!match_option(arg, ret, mitigation_options[i].option)) > @@ -677,8 +683,11 @@ static enum ssb_mitigation_cmd __init ssb_parse_cmdline(void) > } else { > ret = cmdline_find_option(boot_command_line, "spec_store_bypass_disable", > arg, sizeof(arg)); > - if (ret < 0) > + if (ret < 0) { > + if (cpu_spec_mitigations == CPU_SPEC_MITIGATIONS_OFF) > + return SPEC_STORE_BYPASS_CMD_NONE; > return SPEC_STORE_BYPASS_CMD_AUTO; > + } > > for (i = 0; i < ARRAY_SIZE(ssb_mitigation_options); i++) { > if (!match_option(arg, ret, ssb_mitigation_options[i].option)) > @@ -955,7 +964,7 @@ void x86_spec_ctrl_setup_ap(void) > #define pr_fmt(fmt) "L1TF: " fmt > > /* Default mitigation for L1TF-affected CPUs */ > -enum l1tf_mitigations l1tf_mitigation __ro_after_init = L1TF_MITIGATION_FLUSH; > +enum l1tf_mitigations l1tf_mitigation __ro_after_init = L1TF_MITIGATION_DEFAULT; > #if IS_ENABLED(CONFIG_KVM_INTEL) > EXPORT_SYMBOL_GPL(l1tf_mitigation); > #endif > @@ -1010,8 +1019,23 @@ static void __init l1tf_select_mitigation(void) > > override_cache_bits(&boot_cpu_data); > > + if (l1tf_mitigation == L1TF_MITIGATION_DEFAULT) { > + switch (cpu_spec_mitigations) { > + case CPU_SPEC_MITIGATIONS_OFF: > + l1tf_mitigation = L1TF_MITIGATION_OFF; > + break; > + case CPU_SPEC_MITIGATIONS_AUTO: > + l1tf_mitigation = L1TF_MITIGATION_FLUSH; > + break; > + case CPU_SPEC_MITIGATIONS_AUTO_NOSMT: > + l1tf_mitigation = L1TF_MITIGATION_FLUSH_NOSMT; > + break; > + } > + } > + > switch (l1tf_mitigation) { > case L1TF_MITIGATION_OFF: > + case L1TF_MITIGATION_DEFAULT: > case L1TF_MITIGATION_FLUSH_NOWARN: > case L1TF_MITIGATION_FLUSH: > break; > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index ab432a930ae8..83b5bdc3c777 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -233,6 +233,7 @@ static int vmx_setup_l1d_flush(enum vmx_l1d_flush_state l1tf) > case L1TF_MITIGATION_FLUSH_NOWARN: > case L1TF_MITIGATION_FLUSH: > case L1TF_MITIGATION_FLUSH_NOSMT: > + case L1TF_MITIGATION_DEFAULT: > l1tf = VMENTER_L1D_FLUSH_COND; > break; > case L1TF_MITIGATION_FULL: > @@ -6686,6 +6687,7 @@ static int vmx_vm_init(struct kvm *kvm) > case L1TF_MITIGATION_FLUSH: > case L1TF_MITIGATION_FLUSH_NOSMT: > case L1TF_MITIGATION_FULL: > + case L1TF_MITIGATION_DEFAULT: > /* > * Warn upon starting the first VM in a potentially > * insecure environment. The L1TF bits need to be a separate patch. Thx. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel