Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp269972lqg; Thu, 11 Apr 2024 02:09:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVHLJNxb+O/jv/fh2Z/8sGTgpqxVPC2s1UyDJSSa1p7GcNQe9NWgqxUEQlJTmm/aH03efEADF/QV0TxTUBzFO3inVKjV9A+7jUcakcOlg== X-Google-Smtp-Source: AGHT+IHMLdM/etzbEIA/q1D8zSvCj0cE9UJ31fiQfqIE3WnOiCRsWJXngRnVdSAjyT7UNIDw1m1j X-Received: by 2002:a05:6871:e414:b0:22d:fcf9:f771 with SMTP id py20-20020a056871e41400b0022dfcf9f771mr5703042oac.25.1712826579108; Thu, 11 Apr 2024 02:09:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712826579; cv=pass; d=google.com; s=arc-20160816; b=bAqCLWJwvZrZ00GlaxULIfayTiySAEX1x1BFTXgvbLi4Dg0SHqqVy1YKgigA8VvttL 5nO9dE9EcifdBgbeqcxMlGR1BWO8kVSRrF9XZl2ZCDzjC10USSCJFE3jfk6z2epbMgCv VI16YN/Wxvyy9I/lN9mhOHJewnDNqO79n+yQmNgGgaOncsQSijmAVViKLamc+SRNNSFK 5KyECjt9FfzNqKesG8uD9EcAexVkmgex6c+nx09OlWvoHvd9WNAQg420eIpS4YSy+wKS HF5q+DWvBhlDsJ70ev15rpgRIbiiX3UKU1lElzpkOWNlJnKpAgofzFEqkWYMmz5TC4P2 /nZQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=0Lvrzy6gsavLoDn3zewsR3l1JDkSncM7fI8dzkelxIo=; fh=F0OX02PZmHDTQB9pyWdTaOVoJZAkU+U7NWd4Bjtfrwg=; b=sdsVszttGPAJjY5xZWwd6/nYQhKGwyhA1bDmxpd142yf5TiPzNXPVTBiOCAbX9N3bA /5o2ZjCo1gPV/sreLI1EDwWp2zkDolm1IWgZNG5SfdfyT1zv308WbBKtTUpKiq9C0Cee YTHXSuS2Oa8cxWjhem5PXSdqVl1vZFgCjLUPP2vN2+y2X7dAXEMtMkWqTFMD6Bm2qzpL j2qEXEb2CAj4xM2QES+H0njEH+5BB3IFnaNOg9ztRfkU3vLBrub3Ij4cIzHpy7en4vZW QNGCqUBQSFUpqRZAXX/7vTnKuJpj2MZp2bMKGAPQhnqElLWaXVR2K+U8N/BS3t2HTXqw Q2vA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=jvKLLlyy; arc=pass (i=1 spf=pass spfdomain=cloud.com dkim=pass dkdomain=citrix.com dmarc=pass fromdomain=citrix.com); spf=pass (google.com: domain of linux-kernel+bounces-140112-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140112-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.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 jw26-20020a056a00929a00b006e6a17088e1si1106492pfb.46.2024.04.11.02.09.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 02:09:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-140112-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=@citrix.com header.s=google header.b=jvKLLlyy; arc=pass (i=1 spf=pass spfdomain=cloud.com dkim=pass dkdomain=citrix.com dmarc=pass fromdomain=citrix.com); spf=pass (google.com: domain of linux-kernel+bounces-140112-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140112-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.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 6D07BB23503 for ; Thu, 11 Apr 2024 08:43:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0785B1419A6; Thu, 11 Apr 2024 08:43:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="jvKLLlyy" Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 535F713CF91 for ; Thu, 11 Apr 2024 08:43:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712824990; cv=none; b=NH8MvRVEGG6g2hPZtK6AUt0sqKg6DHgGhGLST9OrXhrhZJFzqh1XL4phom5DS5H2oQq0Q3bthePPkInq640BsgA/iWJcCt8H6B/nYoeg/v1YU0ON4EYP1jlyw0tOupcZQtvMbhMfvFYKTIalpurGc9AJFvVKVjnZPwmAydU0QNI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712824990; c=relaxed/simple; bh=rFnbY6the2DTWFxqzWAWtQZuwY6LG4HwFJznztvQg34=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=aCKrfgCjUyA6kvlvheWVMLIAWC6eoCzo7LGNxVg+rhoRXIY/2J7sbekkcyvr4/b52ZIrJkocvaCgkBPlxbpehkFvD39wJR2BsvRbuVb8iiQ9Y0rjF/qrBpYH3q8Q9Gf0SIwc5cI7P83hXmKYZwB5+aaODbGiFdyCx8+PpIbE+ko= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=citrix.com; spf=pass smtp.mailfrom=cloud.com; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b=jvKLLlyy; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=citrix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloud.com Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-346b96f1483so199249f8f.1 for ; Thu, 11 Apr 2024 01:43:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1712824986; x=1713429786; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=0Lvrzy6gsavLoDn3zewsR3l1JDkSncM7fI8dzkelxIo=; b=jvKLLlyyHphQ25WDhJSDv5Oc/4VUi5WPWl8712/+0hCu8iShkFGQGpmzy/8wmbBCOF UKIF1bM3mMZFqiZrfiIgZxdOBZDODhxPqjq+GGLUIwpyqzRN1R4EjX84Q7Y/nDaoPLa4 OjawMbdi91/JYJunfHuCQiV0Bg2NFdHVuXsVM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712824986; x=1713429786; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0Lvrzy6gsavLoDn3zewsR3l1JDkSncM7fI8dzkelxIo=; b=jrpOrlg9wEvFb5Y0cVaZ3EUKBISr9QfFf7hXs/tloySvKhss5f5X8YB2sucnp83m8g UOvV1w4I0vQUjGQdwJcfigwIoa8cFt+sQb1w9qaqKYN4bfZ4p6j9qoQ9qPNocTvObSS4 5I6OrmahLMNGFIClml8Dp6bn899bnXvVDYZ+SPE2znRh86TjOsMMnpWnoQPgWN/BaZRg Ju8MxmN9WqLkmKLNZ+SEhftZpA2iKgOcOn3vi0TA7nNCRzQez58ZuOxOFE16D8l9H8W7 QeHMU93QoinvfFPyX6Jei3R27W7yzujwLImz1ISdJLIMMZo1fVm7i77JeoSc4cpZowcm CeYA== X-Gm-Message-State: AOJu0YzLmJ89bpqDrNDsRl9LVYEzvdvJCLLzEgVcg3LavLZxW2oHO16I koOAZX6Xzsn5xFspePDUz8j2pEZg4bZbjCCtKJBcgXaAAuXFhsb0FSMqgqDNDKY= X-Received: by 2002:a5d:588b:0:b0:33e:c91b:9083 with SMTP id n11-20020a5d588b000000b0033ec91b9083mr1765564wrf.16.1712824986611; Thu, 11 Apr 2024 01:43:06 -0700 (PDT) Received: from [192.168.1.10] (host-92-3-248-192.as13285.net. [92.3.248.192]) by smtp.gmail.com with ESMTPSA id n14-20020a5d660e000000b003433a379a51sm1223176wru.101.2024.04.11.01.43.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Apr 2024 01:43:06 -0700 (PDT) Message-ID: <7f1faa48-6252-4409-aefc-2ed2f38fb1c3@citrix.com> Date: Thu, 11 Apr 2024 09:43:05 +0100 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] KVM: x86: Set BHI_NO in guest when host is not affected by BHI To: Alexandre Chartre , x86@kernel.org, kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, daniel.sneddon@linux.intel.com, pawan.kumar.gupta@linux.intel.com, tglx@linutronix.de, konrad.wilk@oracle.com, peterz@infradead.org, gregkh@linuxfoundation.org, seanjc@google.com, dave.hansen@linux.intel.com, nik.borisov@suse.com, kpsingh@kernel.org, longman@redhat.com, bp@alien8.de, pbonzini@redhat.com References: <20240411072445.522731-1-alexandre.chartre@oracle.com> Content-Language: en-GB From: Andrew Cooper Autocrypt: addr=andrew.cooper3@citrix.com; keydata= xsFNBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i446JOa2vpCI9GcjCzi3oHV e00bzYiHMIl0FICrNJU0Kjho8pdo0m2uxkn6SYEpogAy9pnatUlO+erL4LqFUO7GXSdBRbw5 gNt25XTLdSFuZtMxkY3tq8MFss5QnjhehCVPEpE6y9ZjI4XB8ad1G4oBHVGK5LMsvg22PfMJ ISWFSHoF/B5+lHkCKWkFxZ0gZn33ju5n6/FOdEx4B8cMJt+cWwARAQABzSlBbmRyZXcgQ29v cGVyIDxhbmRyZXcuY29vcGVyM0BjaXRyaXguY29tPsLBegQTAQgAJAIbAwULCQgHAwUVCgkI CwUWAgMBAAIeAQIXgAUCWKD95wIZA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522731-1-alexandre.chartre@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 11/04/2024 8:24 am, Alexandre Chartre wrote: > When a system is not affected by the BHI bug then KVM should > configure guests with BHI_NO to ensure they won't enable any > BHI mitigation. > > Signed-off-by: Alexandre Chartre > --- > arch/x86/kvm/x86.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 984ea2089efc..f43d3c15a6b7 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -1678,6 +1678,9 @@ static u64 kvm_get_arch_capabilities(void) > if (!boot_cpu_has_bug(X86_BUG_GDS) || gds_ucode_mitigated()) > data |= ARCH_CAP_GDS_NO; > > + if (!boot_cpu_has_bug(X86_BUG_BHI)) > + data |= ARCH_CAP_BHI_NO; This isn't true or safe. Linux only sets X86_BUG_BHI on a subset of affected parts. Skylake for example *is* affected by BHI.  It's just that existing mitigations are believed to suffice to mitigate BHI too. "you happen to be safe if you're doing something else too" doesn't remotely have the same meaning as "hardware doesn't have a history based predictor". ~Andrew