Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp931699lqo; Wed, 8 May 2024 22:24:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUhBRrC9zQeCRQ2OTJZrukI41EYHQiW/JPbHUGDP+IkSnI3Na4uNpAn/np323LT96rOT5VIyrIG66Zlg0F9KuXRf2CAJMis39sZQUiUBw== X-Google-Smtp-Source: AGHT+IGDUu89YL9RSAnxabsOnyWSg7MyHBDuDFP/pbG9uW95IInMtSiNgpPkWMonOuA73Xc9Y5mg X-Received: by 2002:a17:902:ac96:b0:1e2:718c:61e with SMTP id d9443c01a7336-1eeb03a0509mr41990385ad.27.1715232295307; Wed, 08 May 2024 22:24:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715232295; cv=pass; d=google.com; s=arc-20160816; b=mbIxInZ0CRHi6+iVPZfmOyUK9K+LrXvWaa5vGEkDtSCjW7i3iIb2HxbCNdwyMV9yMj nXOmupd8dK36Iv94RnE6oEIfIw3vZc1GkwJhrhsYHn5dmhk2Dpn38+fA/WDH/9NtbxPs c4IxxGWA6fk3YZNfw/+cwxmGe81tSb4kQGT9M7Cu2WYTR27wu+ZQjlru/P1iqdbrwGVu MK7m62syo8pbWmr+j9l8U5+icPpCtLgbFDAcm6spGjmv3HSJQ3WxH21laufEhjkV73I0 JHTx7q4/+w2KkyoJZiwpPgdzZvaSVuE2xCxD4YPJ9OcpNfU1mIb5qcRc52oQQmw6W/WX b3Vw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=LBzfW8/Pln1DjneWG6xva98FsEWziGA585tuHpvbkw4=; fh=GtG0QUykxsHNHWQKk/gvXU/7oo4BT5e/ClWUfkHVbIw=; b=P8HNaOG3FXiRHgQvx6zKs+taddRtZ1Bx9uUjiVRA7f17bK3UYjzZra/UUCK4l79g0K s2I9Bex03/6agVuxtxCkNq0ryW18q/zJ8KpUxTHIWPQc4BhluDULA0eOicVZ3yEYdR6R Hw7iaqT22o8cSHnNj3OqupReAT8UuRKmjodanWCjYWHgvqXLI0Pg6f2geAFoEwsWBzf9 aXYUytJPcs2kbKYEJ+cAeEZyz67edmEnHBcWhFd/UtZqsu5mmIfh1b+LdQp5ceHAY0JS kd0aRv2fQz2Vy8PFJGzXB5TRUmqPPeeFL1sHokcE5cYk6z4pbb8sRxFeEjnQ2WJD9CX3 IagQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SmzWW8zg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-174152-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174152-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0bad6198si6753675ad.164.2024.05.08.22.24.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 22:24:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174152-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SmzWW8zg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-174152-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174152-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7869C284EA2 for ; Thu, 9 May 2024 05:24:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9314B1494AD; Thu, 9 May 2024 05:24:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SmzWW8zg" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BEAD314901B for ; Thu, 9 May 2024 05:24:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715232289; cv=none; b=ZA88F9KWvS10uRV38IcpMPFgv6hwdxuNSq9EH0pVbDBo8TRD1eGtTWI6SKyinvUvFCHwPrTbBxAe8LtCO2251ldLf9PCjeZfMR6mxa0jNql0uUKlHeTic/x453jcidqm41Y5O5mrkP7G+5mpKTB7otKXicCbhLgcVys2MqSBoxM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715232289; c=relaxed/simple; bh=ZMwEX+o/EJkHcRC3vFU2GlG5OYSdAKOVflztUOttcbE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SAjBNVT0FmRV0+GzDOQS4SPj8U67YNb86sj7PR6x33SR6uJ+8vsRcg6HmZ9lVMa4rUNjn9QUnu4ls+q4ionPx3alEG8Nb6pBR87JtRsxR96sOqJD/71kwdYbcryvyNOjCWJt5C07i6/ad6lNMxg9TDOcwku2I18FXcSTefcIEnc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SmzWW8zg; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC9B2C116B1; Thu, 9 May 2024 05:24:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715232289; bh=ZMwEX+o/EJkHcRC3vFU2GlG5OYSdAKOVflztUOttcbE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SmzWW8zg9hGq1aNGq5zj376fYeWWvFV1RPodmTzTuiLXGjPLihiIy4iQh7tP148ba 1a0t9C/CKL1hNKXCq6XZC9k8eT6AyD2Na/xCcz9ugr1rEc2DBNwuRe8glbKgGFwoaU 50neVaXpRtp0f8YgOHrGm73eAKPRNEtZmkzz0rjrJ4K8vuzXquKydVysgY7kPlsQIp 0fk+ibm8nVlwypVXgFUelQ5JZA2bUEbUBxVTtYQZ/N7dANJJNBY4kbuMGbjp8FWGRV m19ee0koBSB3SSOk2KVs5ZcIAUBDvoF5z0eC6vgHUb1YVpLqrcuR15+hFt9pZztZtQ ZGveAl8Wa7gIw== Date: Wed, 8 May 2024 22:24:47 -0700 From: Josh Poimboeuf To: Nikolay Borisov Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds , Daniel Sneddon , Pawan Gupta , Thomas Gleixner , Alexandre Chartre , Konrad Rzeszutek Wilk , Peter Zijlstra , Greg Kroah-Hartman , Sean Christopherson , Andrew Cooper , Dave Hansen , KP Singh , Waiman Long , Borislav Petkov , Ingo Molnar , Maksim Davydov Subject: Re: [PATCH v5 3/3] x86/bugs: Add 'spectre_bhi=vmexit' cmdline option Message-ID: <20240509052447.kwdlruqad7r5h4pi@treble> References: <66327dcf87284a09ed17ac24227695ea3ba1f287.1715059256.git.jpoimboe@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Wed, May 08, 2024 at 06:10:21PM +0300, Nikolay Borisov wrote: > > @@ -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; > > + } > > nit: How about setting CLEAR_BHB_LOOP_ON_VMEXIT unconditionally, then > afterwards checking if MITIGATION_VMEXIT_ONLY is set and if yes simply > return, that way you don't duplicate the setup of the VMEXIT code I think the duplication actually makes it more readable. In both cases it puts the setting of the features together along with the corresponding pr_info(). -- Josh