Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp67550lqo; Tue, 7 May 2024 12:20:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVrPn6kzarbmhSHpZiCNRiH3fGaI0I5HfgWH73vMY99dbaCBIwzi9EqD/6dARAsXkUYwre19n3L+jP5IJLp1LJCMejFWYRPn9OIKibClA== X-Google-Smtp-Source: AGHT+IGP2IhNeVaUhxT2WwUWGFiGauA/ToG0rvViRX9R/+AZqfc3UrysUtQnKJXgG72/E2q+XA4W X-Received: by 2002:a17:903:11c7:b0:1eb:6468:7fc3 with SMTP id d9443c01a7336-1eeb088e7a5mr5981055ad.62.1715109602609; Tue, 07 May 2024 12:20:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715109602; cv=pass; d=google.com; s=arc-20160816; b=PZAos+d7JB84e16AZR4SsC9vGhmseHgrKwLSKUrwpVfleYxfSZXVBfBFA3zFT4ZYRt qjSB2KdE4nCFZmZZ3+JfHIyoSLIzv/1e+F7pgmrGK5dZHyLSba//brqhAhv0sUXHYqsY q5q6vgJnezRRJj/uOBlYIyn0CvKXzgXh984hS/qNSzJqR8yyQlr7ipbr8/VjsZWLtuu/ h/8UG0QTWa6XGs1ICERdiUp2IyOb4zOqyj+gkUpihaIawFkPEAUyg+diA0xXAPpYIA6l QKm5F9xhqECBKw1Btd2AsmC1VqneJWpshbCdfpVSjNAoHg6nB+9QICJUs7rdBN86ivZg AcGQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=NsTQm30yvVupysJreZNZqKIPKoLRBOGU4Mc+Yooufj8=; fh=nYEO6pXRfxNUN5q6auxVeGSeXBp2Fa9QcasZ8BUeGGU=; b=x4r1WsRaA0TLAY+jZqae7m4hwaqo1WtT2w4lyH+4o2L8ogrhMykm8PgLFKxmNtdCl3 28sjR0WrxSn28rAhPHBVkwudqJvBJ/8DbtoOYuuNtyVuABitnpvId19JvPsr8UuTk3Me FbvuV05Jizkgoo/CAUn0mYHU+kiEO0Akk8tnPuw7ZVyfZjvSu8JSM/cFlQj/EDneyXNK pP1e4vOLaHVbqY6cxeBF32KiJIZwGNo44qenYRKL4k0b9GOfCvcq7jKDWgQWCXS2bkHr ob8sWI0/6daSuvnsEUadii9nMffYLVSN+TTnW9vuX1rg09sanrGTF2OBI8FczB1rC/tu PQ4g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PrqCTgKv; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-171635-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171635-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id ll12-20020a170903090c00b001ec7b2f40b1si11435237plb.573.2024.05.07.12.20.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 12:20:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171635-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PrqCTgKv; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-171635-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171635-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A9019B221B9 for ; Tue, 7 May 2024 14:58:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA2741607B6; Tue, 7 May 2024 14:58:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="PrqCTgKv" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6388716078B for ; Tue, 7 May 2024 14:58:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715093906; cv=none; b=lxzPiM6eR9JxtpnMbzTLdR0Tq51A3DSlxWOueo2KUNn9lDfT2AiutqUJcRQ+sUdkid2HHOc+bQ3J6lkC1Sxce1BOkFdpjewwclHUmOtYUHQNufIhQ8/KTlKBSgcRnmfYwQRw6vl31tJVtxkNcbusfkfF4Q9LNGk5X6bmbtpVfeg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715093906; c=relaxed/simple; bh=BoniYdVi6dZzCpHSJPcK6578i3gt0JCIXLT1l4PMHsA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Fr8A0ymAmKoEwNXfT92O4gqOSE1B4tfMZZAqgMvu8Qbmw+jcRdsvY9oB8vBs3ZeEocTggFhLPevytd372se9us8uazZGPh3Xdm5uc4et8aEag+q0hpV7gv7fjGlBxGNWer7cPncZFZHcm40Ph9qu1DNzyXaUVgzhPrCFmmFaCKA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=PrqCTgKv; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715093904; x=1746629904; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=BoniYdVi6dZzCpHSJPcK6578i3gt0JCIXLT1l4PMHsA=; b=PrqCTgKvMVw+vn7QaeEDgZn+WFkCp/dFyNN2E9SEGr1gFSK2d2Vqd4ND m5q9UJrqdf196kCE6mSCNhEyieg5Eth9y6ue4wbPJSN7jkE7J2zAqgTNe H4WtiH8CUfH6khzrNaiV5AgBgWElmdpO8Rfq+qGcYTvbXVnhPi00t1qXC tRqqInJObIBfqVOBmjCUcpNudmROz02CMmFWLiu0+DEjegOHL3SNnHAq4 AoVRRrmrl4RpFwe8wkjZfg+KmQB2f+b1YmszWrvqL3W28pEx7ll/Om1An 1Fx2dbFxPiyl4a0uq1kR5TmkpYQs2RKowcKKStViuT4dGzmwMwMAhQZs+ A==; X-CSE-ConnectionGUID: 0zQDDlPoR4esKTX/mhuumg== X-CSE-MsgGUID: ZH8ksL/TRX+vH/X26OS4qQ== X-IronPort-AV: E=McAfee;i="6600,9927,11066"; a="10827524" X-IronPort-AV: E=Sophos;i="6.08,142,1712646000"; d="scan'208";a="10827524" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 07:58:24 -0700 X-CSE-ConnectionGUID: ZTAuw5s8QYS94ZZgR+7DDA== X-CSE-MsgGUID: uBftWuxfScWPw1YcL5CBow== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,142,1712646000"; d="scan'208";a="29063162" Received: from bwkammey-mobl2.amr.corp.intel.com (HELO [10.125.19.152]) ([10.125.19.152]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 07:58:23 -0700 Message-ID: Date: Tue, 7 May 2024 07:58:07 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 3/3] x86/bugs: Add 'spectre_bhi=vmexit' cmdline option To: Josh Poimboeuf , x86@kernel.org Cc: linux-kernel@vger.kernel.org, Linus Torvalds , Pawan Gupta , Thomas Gleixner , Alexandre Chartre , Konrad Rzeszutek Wilk , Peter Zijlstra , Greg Kroah-Hartman , Sean Christopherson , Andrew Cooper , Dave Hansen , Nikolay Borisov , KP Singh , Waiman Long , Borislav Petkov , Ingo Molnar , Maksim Davydov References: <66327dcf87284a09ed17ac24227695ea3ba1f287.1715059256.git.jpoimboe@kernel.org> Content-Language: en-US From: Daniel Sneddon In-Reply-To: <66327dcf87284a09ed17ac24227695ea3ba1f287.1715059256.git.jpoimboe@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/6/24 22:30, Josh Poimboeuf wrote: > In cloud environments it can be useful to *only* enable the vmexit > mitigation and leave syscalls vulnerable. Add that as an option. > > This is similar to the old spectre_bhi=auto option which was removed > with the following commit: > > 36d4fe147c87 ("x86/bugs: Remove CONFIG_BHI_MITIGATION_AUTO and spectre_bhi=auto") > > with the main difference being that this has a more descriptive name and > is disabled by default. > > Requested-by: Maksim Davydov > Signed-off-by: Josh Poimboeuf > --- Does the KConfig option need to be updated to support this as well? Other than that, Reviewed-by: Daniel Sneddon > Documentation/admin-guide/kernel-parameters.txt | 12 +++++++++--- > arch/x86/kernel/cpu/bugs.c | 16 +++++++++++----- > 2 files changed, 20 insertions(+), 8 deletions(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index 213d0719e2b7..9c1f63f04502 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -6072,9 +6072,15 @@ > deployment of the HW BHI control and the SW BHB > clearing sequence. > > - on - (default) Enable the HW or SW mitigation > - as needed. > - off - Disable the mitigation. > + on - (default) Enable the HW or SW mitigation as > + needed. This protects the kernel from > + both syscalls and VMs. > + vmexit - On systems which don't have the HW mitigation > + available, enable the SW mitigation on vmexit > + ONLY. On such systems, the host kernel is > + protected from VM-originated BHI attacks, but > + may still be vulnerable to syscall attacks. > + off - Disable the mitigation. > > spectre_v2= [X86,EARLY] Control mitigation of Spectre variant 2 > (indirect branch speculation) vulnerability. > diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c > index ab18185894df..6974c8c9792d 100644 > --- a/arch/x86/kernel/cpu/bugs.c > +++ b/arch/x86/kernel/cpu/bugs.c > @@ -1625,6 +1625,7 @@ static bool __init spec_ctrl_bhi_dis(void) > enum bhi_mitigations { > BHI_MITIGATION_OFF, > BHI_MITIGATION_ON, > + BHI_MITIGATION_VMEXIT_ONLY, > }; > > static enum bhi_mitigations bhi_mitigation __ro_after_init = > @@ -1639,6 +1640,8 @@ static int __init spectre_bhi_parse_cmdline(char *str) > bhi_mitigation = BHI_MITIGATION_OFF; > else if (!strcmp(str, "on")) > bhi_mitigation = BHI_MITIGATION_ON; > + else if (!strcmp(str, "vmexit")) > + bhi_mitigation = BHI_MITIGATION_VMEXIT_ONLY; > else > pr_err("Ignoring unknown spectre_bhi option (%s)", str); > > @@ -1659,19 +1662,22 @@ static void __init bhi_select_mitigation(void) > return; > } > > + /* Mitigate in hardware if supported */ > if (spec_ctrl_bhi_dis()) > return; > > if (!IS_ENABLED(CONFIG_X86_64)) > return; > > - /* Mitigate KVM by default */ > - setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT); > - pr_info("Spectre BHI mitigation: SW BHB clearing on vm exit\n"); > + if (bhi_mitigation == BHI_MITIGATION_VMEXIT_ONLY) { > + pr_info("Spectre BHI mitigation: SW BHB clearing on vm exit only\n"); > + setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT); > + return; > + } > > - /* Mitigate syscalls when the mitigation is forced =on */ > + pr_info("Spectre BHI mitigation: SW BHB clearing on syscall and vm exit\n"); > setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_LOOP); > - pr_info("Spectre BHI mitigation: SW BHB clearing on syscall\n"); > + setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT); > } > > static void __init spectre_v2_select_mitigation(void)