Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp288811lqg; Thu, 11 Apr 2024 03:03:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWmCyiuvIXcympl4xrFBnBpf2AUM3bE2OmQUavxNVcdIZynLDJ8IWGiw0vEhK/eZJDKfdfrVMvAR6MbCHdeG3/+AXBvuNkdjYh9AQEywA== X-Google-Smtp-Source: AGHT+IGxT3mvqOeLICKJYDFQTxADQ5kLPWvP6PBgCSMrkoTudAWGRL+Oqd1gPbWwv6SxXQxUhReo X-Received: by 2002:a05:622a:10b:b0:436:5628:d6a6 with SMTP id u11-20020a05622a010b00b004365628d6a6mr2087221qtw.48.1712829789939; Thu, 11 Apr 2024 03:03:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712829789; cv=pass; d=google.com; s=arc-20160816; b=hxzBhepb1a9c4eGK7tg9go5o6tnAW6dqJlpDtPmUi6Vjxy7U/RauiwcAdJcJGbZn6l IHHXUZpke6EgnjYETQx2Pw+CaF3qnGikMlWhHxGNOQNIKwx0ngpG2Wbn8jKe4H9NI9Sm 2lgbk9vwotM+20o0vd/5I2jzmkGKsLO2X9aiR8+TKWmeqqr7KOJHvFB/UmESbbKK9BFJ 3J84FG/EgY6SwruqlRSuakZ8xCMTJjPSsf0/W0OCHRADY1Q+37YIzF3NYJ1WKHEZcbqS NU0g+NSr8sQtBHVVedlKvoTw5WwkWzWrfktc47bvuBersLM7zR4bCedPuJpOkuxzhlzS uUdw== 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=o+AspwhJmQ76OGtD91I870XVEIgHFgybT47G/5Z+w+8=; fh=w5B2SRupPaAk6pgTTP3JnOYGqQqtR05cDvTlCBpT9aM=; b=LePbz0NFl+Un3BKGC/dnakaA5O1USSpfNv9RexvDIDCQCUOaa1AAEGm1z7n4eo070A vYLxH42q9SBbVsDGwbMDjximYtWKUOfHQKwe29dVuLEgfCl3kMaa8JVG8pO4O3XWi6qS +c3Cyg0nECUM//AhZuErlFrV6DGxgg8gjKwvJAA7wueSmAiZROmSy64u419YSGiCfc/g yg2KLgVx0nYzVaBHvGEky8Ag8cisaRePFonDrinXoqm7Xq4fNRndTHF1RKJtFvyLjv7i 0EpxiVrHfRh903lEkpXrlNq+i0PpBNgRhz4C9CNQy6mBsCNMtwSfxxH9rj8dRvZd9t7N Qugw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=ZbjcFwJ9; 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-140216-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140216-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h13-20020ac87d4d000000b004349bf16b99si1168706qtb.363.2024.04.11.03.03.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 03:03:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-140216-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=ZbjcFwJ9; 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-140216-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140216-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 53E211C223F0 for ; Thu, 11 Apr 2024 10:03:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1DEC9145B13; Thu, 11 Apr 2024 10:02:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="ZbjcFwJ9" Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 648AE14430D for ; Thu, 11 Apr 2024 10:02:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712829767; cv=none; b=d+oU/cRr4/zc03PTNHiZjvtGeuIlMkrNnYFoSjebnj+ClZFVTqqMvEKzF67YkiyeG0aHoF03q6ibjHZ6Sn2YsbieuX5JJgYHviURQ2a0TEf2TNi8iwbOxXL5d7hHicM2JTEbmOEt3EKW+F8kpcD91Cf6hRoWXd/bYhqfN1+GcPg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712829767; c=relaxed/simple; bh=aBGu/AorSZ4xR7dSnqJY4y3hCOGSUldjshMOd1dQTOE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=shCu1qN17to9dePbjF7k9hji1PAIHRs0r5ibwCoB6ogulpVIy9JSL2B003pHORK9lGR85jkFaYRNj7bxp+kfHREM8j1i5vcS0wojka4mQGKNkt4Qy6O4+E+Z1dFl63E84rTLkhAt+t9oeZDBb0Hi/7X3q11xB9i8osdFy1H3wjo= 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=ZbjcFwJ9; arc=none smtp.client-ip=209.85.218.53 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-ej1-f53.google.com with SMTP id a640c23a62f3a-a51b5633c9cso669371766b.2 for ; Thu, 11 Apr 2024 03:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1712829763; x=1713434563; 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=o+AspwhJmQ76OGtD91I870XVEIgHFgybT47G/5Z+w+8=; b=ZbjcFwJ9ogtsgUCBGhqE4mhfGEnTa/gcHn7Om+JnItRaidsWFeSSM/nOJXF+PIFy/Z zwrldLkW+/PJq4WtSoLm7LIhjPnaJraBrKUyupSZMFn7e+qBGiQ1m2/jQza76MqVNujU WqEiSjwPIzWh/fI0Fa5KA+r+naeXbMkJoBxmw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712829763; x=1713434563; 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=o+AspwhJmQ76OGtD91I870XVEIgHFgybT47G/5Z+w+8=; b=pgIVZvRMIJMhgxgBBxgrVaFF2VrHtdS9i72UX1ZNxpHmET5JsLyW9DB8EGKicNPxNJ pgHzSVE4sPDy+kEwCSNzO1q0LrjQkdqpVQqH768K1qDZ2y3oPgg9tEReCeJZRUpiPdmq JwG02GIw7c9VyapLvulzrovDecSKIWo407b/fIAIY8ZiqltwDVk+m7wEz2cRH1kciUKg DhGX4qmouZEawOCy7yCW3gjf46oeIVvEdXclwAUG8VLPFGaQqnOhrwhxF/FXMotOUE95 qlHfafQUCgi0IvMSeH2vdBQ+ggG4vCdT0ttoOJmo50+FNrugJelje8aMBRpPxc5NccCx FrSQ== X-Gm-Message-State: AOJu0YxNlKgXen4grfjpzhuZDj/B6Oplt0fnI/xm5HWB7eKdJqf0SnzG 9xHhMqsrChrdpvaeN3PJmwqaH51kycAN85xtUS4UtRKAkyH0935cgixbjQI7I2A= X-Received: by 2002:a17:906:240e:b0:a52:2231:f005 with SMTP id z14-20020a170906240e00b00a522231f005mr725598eja.49.1712829763397; Thu, 11 Apr 2024 03:02:43 -0700 (PDT) Received: from [10.80.67.140] (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id w22-20020a170907271600b00a4e48e52ecbsm591439ejk.198.2024.04.11.03.02.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Apr 2024 03:02:43 -0700 (PDT) Message-ID: <997d9bf9-2a8b-452f-b458-2fa15f92918e@citrix.com> Date: Thu, 11 Apr 2024 11:02:42 +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 3/7] x86/bugs: Fix BHI handling of RRSBA To: Josh Poimboeuf , x86@kernel.org Cc: 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 , Dave Hansen , Nikolay Borisov , KP Singh , Waiman Long , Borislav Petkov References: <6f56f13da34a0834b69163467449be7f58f253dc.1712813475.git.jpoimboe@kernel.org> 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 CwUWAgMBAAIeAQIXgAUCWKD95wIZAQAKCRBlw/kGpdefoHbdD/9AIoR3k6fKl+RFiFpyAhvO 59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RP9UQ3lkmkmc0+XCHmj5WhwNNYjgbbmML7y0fsJT5RgvefAIFfHBg7fTY/i kBEimoUsTEQz+N4hbKwo1hULfVxDJStE4sbPhjbsPCrlXf6W9CxSyQ0qmZ2bXsLQYRj2xqd1 bpA+1o1j2N4/au1R/uSiUFjewJdT/LX1EklKDcQwpk06Af/N7VZtSfEJeRV04unbsKVXWZAk uAJyDDKN99ziC0Wz5kcPyVD1HNf8bgaqGDzrv3TfYjwqayRFcMf7xJaL9xXedMcAEQEAAcLB XwQYAQgACQUCUuE2fwIbDAAKCRBlw/kGpdefoG4XEACD1Qf/er8EA7g23HMxYWd3FXHThrVQ HgiGdk5Yh632vjOm9L4sd/GCEACVQKjsu98e8o3ysitFlznEns5EAAXEbITrgKWXDDUWGYxd pnjj2u+GkVdsOAGk0kxczX6s+VRBhpbBI2PWnOsRJgU2n10PZ3mZD4Xu9kU2IXYmuW+e5KCA vTArRUdCrAtIa1k01sPipPPw6dfxx2e5asy21YOytzxuWFfJTGnVxZZSCyLUO83sh6OZhJkk b9rxL9wPmpN/t2IPaEKoAc0FTQZS36wAMOXkBh24PQ9gaLJvfPKpNzGD8XWR5HHF0NLIJhgg 4ZlEXQ2fVp3XrtocHqhu4UZR4koCijgB8sB7Tb0GCpwK+C4UePdFLfhKyRdSXuvY3AHJd4CP 4JzW0Bzq/WXY3XMOzUTYApGQpnUpdOmuQSfpV9MQO+/jo7r6yPbxT7CwRS5dcQPzUiuHLK9i nvjREdh84qycnx0/6dDroYhp0DFv4udxuAvt1h4wGwTPRQZerSm4xaYegEFusyhbZrI0U9tJ B8WrhBLXDiYlyJT6zOV2yZFuW47VrLsjYnHwn27hmxTC/7tvG3euCklmkn9Sl9IAKFu29RSo d5bD8kMSCYsTqtTfT6W4A3qHGvIDta3ptLYpIAOD2sY3GYq2nf3Bbzx81wZK14JdDDHUX2Rs 6+ahAA== In-Reply-To: <6f56f13da34a0834b69163467449be7f58f253dc.1712813475.git.jpoimboe@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 11/04/2024 6:40 am, Josh Poimboeuf wrote: > The ARCH_CAP_RRSBA check isn't correct: RRSBA may have already been > disabled by the Spectre v2 mitigation (or can otherwise be disabled by > the BHI mitigation itself if needed). In that case retpolines are fine. > > Fixes: ec9404e40e8f ("x86/bhi: Add BHI mitigation knob") > Signed-off-by: Josh Poimboeuf > --- > arch/x86/kernel/cpu/bugs.c | 30 ++++++++++++++++++------------ > 1 file changed, 18 insertions(+), 12 deletions(-) > > diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c > index 27d6d64eeec3..0755600d5d18 100644 > --- a/arch/x86/kernel/cpu/bugs.c > +++ b/arch/x86/kernel/cpu/bugs.c > @@ -1538,20 +1538,25 @@ static enum spectre_v2_mitigation __init spectre_v2_select_retpoline(void) > return SPECTRE_V2_RETPOLINE; > } > > +static bool __ro_after_init rrsba_disabled; > + > /* Disable in-kernel use of non-RSB RET predictors */ > static void __init spec_ctrl_disable_kernel_rrsba(void) > { > - u64 ia32_cap; > + if (rrsba_disabled) > + return; > + > + if (!(ia32_cap & ARCH_CAP_RRSBA)) { > + rrsba_disabled = true; > + return; > + } You'll take this path if you have out-of-date microcode. RRSBA is only enumerated from September last year, IIRC.  (Definitely from this point on some CPUs.) When RRSBA was introduced, I was under the (false) impression that all eIBRS systems suffered RRSBA, but it turns out that select parts (ICX,TGL,RKL) are non-RRSBA despite not having RRSBA_CTRL. ~Andrew