From nobody Sun Feb 8 05:28:36 2026 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 31C59156866 for ; Tue, 9 Apr 2024 17:51:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712685074; cv=none; b=GHDRynp1WTRzCHsZlShQAaNnEa5nfWF4iwgzaz+C03Y6TBB1PyRQGJPf3hlIyQFveYTYqclXvLHXUnGx2Tb63PZLO+hj/Tverewqs4tyQEpCiJeyDbDnruhGZdTYxSI4NHFDW2MRVB7XGonnHmleCzoBkx274R9/hEybycbR+pI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712685074; c=relaxed/simple; bh=s2tc144aBgNbfS3s/tihGdBDGVdjaSbfQ+SMtFuveA0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=p1SyUohIsEh7EYt4yEvNtLpgJfuDZpMn2bxsDRvGuO2kUNXXSM9N0pjyVIoXXLmfQpBlxeP7tsNjp89zNvLzxNGFxxGrgqoNeIKjf0Ee3uS4o4zZY4aNo2OXzeSflQPutr0kOGA6WBKGr1pzmsa8C33bbcjZTUs2iWH+0Gy33tE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=iZ6RqVLR; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="iZ6RqVLR" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6167463c60cso66825867b3.1 for ; Tue, 09 Apr 2024 10:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712685072; x=1713289872; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:from:to:cc:subject:date :message-id:reply-to; bh=/vL198wTn+Uk37UUg6mX+X5B2xDFF41dQr7U2AoMPZ0=; b=iZ6RqVLR8jrY5bVAUNJRGENQq2blNMurn4IYjP67hksPv3HrFsQ75oZ3tHBUorGCwS 2CxkLbEfy1iEgqpXcMbC2J+f4Rj58jweu0OvAljFu29ig2Yry2oi3pipyqWqip3bB0sL 2xyXKAvcPNnjAwaWf254RKGECXXg2xWFgceKA7eqOAgmdLiNBrbJ/HeLjbHc6I/jq02n owK87ZZ2KPD4DoBljFPtmspGt39bAmf7ZR/Ka+p1oJsTF/SrN4kgVFm6Kd822Fb3RyUS UHBRX0pJb8k2ra5JZWqgbOANyf8izTBwsaJUXtCKA56d7BP4E8xMClr68GaCWpo4sLol m8wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712685072; x=1713289872; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=/vL198wTn+Uk37UUg6mX+X5B2xDFF41dQr7U2AoMPZ0=; b=Z2zpQITWgosyQilG8brHah0gLyBIlN7kjmjFBAOI78iPjCj8oarQTMz0Vgy5loEbVo Ug4+b9egizzQeD6jTukSr5BsaZvzcCx+XGbmTGK60eFcs62uPqJPWgKcWwrI5GK5AIeZ S+VIlNHze2zD8peHiYqbjvVt9qr6VfCjJop0lJAd8FPPxjCAvZthwfBRPHnhH78Gjv7k PMdBQblrajuTzatw/NxMxjRyDaX02fDBB/gklaeEw5FvDDXoh7qUXqGCvwjPAIlxKWcC Xdc/Iw73bFfYIWpP1TLxk9xCm8T98uupSqJ+lMVHO5a5m7vj2fFNlkbsuQ7r2+Kio9/k ztCA== X-Forwarded-Encrypted: i=1; AJvYcCWVBl7RxVF4PbTQesv1LLAc0hUaZqXVHs9juAZzzDEE9atK7G5OMdZX20OjmitmjlMLyH1R4ynEV3BvYNTHNdc/RYM3NMUe+MYaG+8s X-Gm-Message-State: AOJu0YyGY5ij44g4cP06SFPfngJF4yVAmtq88QF0t+z9D7sPuYiBgiP+ 8dzjQb6IpU47dMY+AtjPf7XueXAX62nkr8qBQJogt+P9RVNRLzbbXmGJZj5Gi4pgcPz9nI10eTW mKg== X-Google-Smtp-Source: AGHT+IHACX2l7YRowPE7LBYQgfxO9IwPoJAvZuIh2hi8AYJti5CEda5NxgViN/ORL+KHH0LXS6bpmGpI3cA= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:a002:0:b0:614:2a7d:5ad3 with SMTP id x2-20020a81a002000000b006142a7d5ad3mr819172ywg.0.1712685072337; Tue, 09 Apr 2024 10:51:12 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 9 Apr 2024 10:51:05 -0700 In-Reply-To: <20240409175108.1512861-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240409175108.1512861-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240409175108.1512861-2-seanjc@google.com> Subject: [PATCH 1/3] x86/cpu: Actually turn off mitigations by default for SPECULATION_MITIGATIONS=n From: Sean Christopherson To: Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Josh Poimboeuf Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , Pawan Gupta , Daniel Sneddon Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Initialize cpu_mitigations to CPU_MITIGATIONS_OFF if the kernel is built with CONFIG_SPECULATION_MITIGATIONS=3Dn, as the help text quite clearly states that disabling SPECULATION_MITIGATIONS is supposed to turn off all mitigations by default. =E2=94=82 If you say N, all mitigations will be disabled. You really =E2=94=82 should know what you are doing to say so. As is, the kernel still defaults to CPU_MITIGATIONS_AUTO, which results in some mitigations being enabled in spite of SPECULATION_MITIGATIONS=3Dn. Fixes: f43b9876e857 ("x86/retbleed: Add fine grained Kconfig knobs") Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Reviewed-by: Daniel Sneddon Tested-by: Geert Uytterhoeven --- kernel/cpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index 8f6affd051f7..07ad53b7f119 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -3207,7 +3207,8 @@ enum cpu_mitigations { }; =20 static enum cpu_mitigations cpu_mitigations __ro_after_init =3D - CPU_MITIGATIONS_AUTO; + IS_ENABLED(CONFIG_SPECULATION_MITIGATIONS) ? CPU_MITIGATIONS_AUTO : + CPU_MITIGATIONS_OFF; =20 static int __init mitigations_parse_cmdline(char *arg) { --=20 2.44.0.478.gd926399ef9-goog From nobody Sun Feb 8 05:28:36 2026 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (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 6BF30156998 for ; Tue, 9 Apr 2024 17:51:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712685076; cv=none; b=TuLVeJ667QuYet91pAyHaeZYUxJb0ufSEVV9UL++dPWXODRdRyqZ4HUSU5KlUnv7oj3RUQLpjULkp0ApqyJnrBo/kA3VTo99aJZix9Y4rNzPw3X38CTH53L/NBquHKtUSf+fartv2Aq2rtYSwfVJ7rkFNuOpxamjXcjM+Snqsbs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712685076; c=relaxed/simple; bh=QVtEQp4/Pcfuor0ucORpy+mLoe+0G9NQLRsGApm4biU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=B+/KbfDB+6GsOfhO3f4oKJ2+BMm30cu/ezjM4Wg0zmf5xuRw+PcyYbER+81XV+Y+69YyJM2Q/r+9kUWMENwM0J5sSXhycMOY6dtS0SlvcECuwBBkPAE499TTN67mOXXnMQrxo75KsUwK4cFyqAHK4c2BwhY/a9yPMLrpq/SkHwo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=itkF8bUI; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="itkF8bUI" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-5c6245bc7caso4156337a12.3 for ; Tue, 09 Apr 2024 10:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712685075; x=1713289875; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=A7D9RJgwpQ1W8M/aA/vuUOPVBx7m9VVMSR4azYK+r2U=; b=itkF8bUIabXOiKwdBCbeeKobhWElxIjYrJNzz526HLsXUB4YJyUFvtlf9irtdKrGJN sU4lz+itK40DWd6VluXd3Cqk3StVNb+rbnGQ02l2F381EX0kQcW1yjQQ5yAwnjYC5Zff YSLS/OuWJCQ/WQ5xi916NnQD8d4P75LlyqekEzVMvKf70TJ4n8zBXloWAtMAmCd9hapM Nh+Vdp+TrPSk2r+W80MGduWh+HCHuEZj0IM4U9IvdXnWW53jtsLTG1u+SPOO76eyab7C VS0Y2kZPPVs4oN4mdFKSNQDR9u0BooXAYn7L29wdLetkqur41XLZRH3Dl9P2vM7snd2h DoBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712685075; x=1713289875; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=A7D9RJgwpQ1W8M/aA/vuUOPVBx7m9VVMSR4azYK+r2U=; b=Yp7cD+3/rokL3scKUb+Z3Q9NiGJFTM5E2PqkzRcRhGZQRjIr0739/pm2wfY7CrnZr4 2Dgft9SgbOv/z7dSJUUi2j1umsZnUfAAKDuG6ZvsdIcC3Nr3uCek/rA2u2W+GNTYS03t JsjFtvVMODbG8PEAt4EJb4fZLKF/3KIxHCNklgoqkS3fAodUCLrxLWblRKEvXIbiPqwU iyyIc0gLlcE/bbEkC7kNR5pyVY9FwqZVg3JwSpQikMeboktm5YJDgXM8BAV8FoGZ96kM s44WgY6DW80JIU0EXmgh1ChtwisYZWpUqtUwqI7JEE4eylbXkfGHv3yDUdtRsH++n+Wf sN9Q== X-Forwarded-Encrypted: i=1; AJvYcCXCBO8BZEXf3tPqxJytwZTYlmLzw7U2FHhauv362IB8wUzcV2iywKa+f/LNXqgYX9+EH/YHOwOOpk1Mz/UgVV+TzBL+GHG92ibNHHJN X-Gm-Message-State: AOJu0YyV3Fg5eFcaPCaEW7Q9nu6jxEOQegM+K0sn5dP3AVrm2/tq+ZNz EC/zkKnreuZB2qq6P5kp8Ivxt99pGdY3AC/FYf0cqaFrRjC/W3nIdgxcYnd8sOef65j2+VabPE+ XlA== X-Google-Smtp-Source: AGHT+IH/KQ46x00AZLl2fd+Lf61jBhBT8o2VrRznGwLDVKKAWw/UNewgQ/kzIVWdr4XXtJVvXT21E0kiGIY= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a02:682:b0:5cd:8454:38b2 with SMTP id ca2-20020a056a02068200b005cd845438b2mr10850pgb.11.1712685073964; Tue, 09 Apr 2024 10:51:13 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 9 Apr 2024 10:51:06 -0700 In-Reply-To: <20240409175108.1512861-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240409175108.1512861-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240409175108.1512861-3-seanjc@google.com> Subject: [PATCH 2/3] x86/cpu: Disable BHI mitigation by default when SPECULATION_MITIGATIONS=n From: Sean Christopherson To: Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Josh Poimboeuf Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , Pawan Gupta , Daniel Sneddon Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rework the initialization of bhi_mitigation to use positive CONFIG tests for the ON/AUTO cases so that lack of *any* CONFIG_SPECTRE_BHI_* #define, i.e. when the kernel is built with CONFIG_SPECULATION_MITIGATIONS=3Dn, results in the mitigation being OFF by default, not AUTO. Per the help text for SPECULATION_MITIGATIONS, the intent is that 'N' disables all mitigations. Fixes: ec9404e40e8f ("x86/bhi: Add BHI mitigation knob") Cc: stable@vger.kernel.org Cc: Pawan Gupta Cc: Daniel Sneddon Signed-off-by: Sean Christopherson Reviewed-by: Daniel Sneddon --- arch/x86/kernel/cpu/bugs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 295463707e68..e1775debeafe 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1630,9 +1630,9 @@ enum bhi_mitigations { }; =20 static enum bhi_mitigations bhi_mitigation __ro_after_init =3D - IS_ENABLED(CONFIG_SPECTRE_BHI_ON) ? BHI_MITIGATION_ON : - IS_ENABLED(CONFIG_SPECTRE_BHI_OFF) ? BHI_MITIGATION_OFF : - BHI_MITIGATION_AUTO; + IS_ENABLED(CONFIG_SPECTRE_BHI_ON) ? BHI_MITIGATION_ON : + IS_ENABLED(CONFIG_SPECTRE_BHI_AUTO) ? BHI_MITIGATION_AUTO : + BHI_MITIGATION_OFF; =20 static int __init spectre_bhi_parse_cmdline(char *str) { --=20 2.44.0.478.gd926399ef9-goog From nobody Sun Feb 8 05:28:36 2026 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (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 65DD3156C60 for ; Tue, 9 Apr 2024 17:51:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712685078; cv=none; b=V5ks8TN9A1v5pI1uqCWXWnMpgmJvVg3cvd6WT6nFMIqRgckgzDgiGHCoZ6AsBztmmob4RI8kg2+ev/M1QHtllJcD5Qzam93yL40lIVLX7a/cC6au+nRcpo/qEI4GenKimEanNLKL6u10LJHJzbNxdypSF2cF9casn+Rhd12IK68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712685078; c=relaxed/simple; bh=4Mv4JnaamEMFtqjppXQOdNnTp12kg+C/D7qGCSJVY+U=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=m9ELzIP6FS8STgriN4QHptKRGRlXc8Xp8Gk7L5A1yuTOFgYAA54wbI+Gjv+aE2AA1Db8+pULcW6OskdP1WTV8hI6+boiQ6L58Ng435VngYDKGGvErlUmr/QY1rqj77wv9T5wyJt9+oKaOAPoFTNF0onS+CvpLcs4Q9JZwVWLWS8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=CuBDkDVy; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CuBDkDVy" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-6ece02cfbf2so5407642b3a.2 for ; Tue, 09 Apr 2024 10:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712685077; x=1713289877; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=qSb1EMKIyurI6CZqrBQhbOzp5bKMnooWMDlfmCQHkvY=; b=CuBDkDVyvnYV65R62JtrzAncdWzBNd+OxfSnfDLeunsyaH6WMcuplmieKR0/UEffl4 6lTZIdzqMKz5tyuniZAp7seVDIS+lmOwQWdMCRrLZJGHC56HoyT5+zTZvD41+uvEG02Q IYLSEnRUS7DUDSdzTDyo3vLFPeoSD0oPEBQ+MVIUbTnaeC2xneSK+38kJlDsp4tlI5jQ bS4zNOL6dgouOw8ybh0gSWPZm4gd5aeYyITBgvizoxRO3epFUtB/8Ay3miWILAQq0JHL dfUTFLBH3qbjp18Wgd7UU+jvLpv8QMjcuVgpxeAWlIdAWrBkA8KaGx5cCC6EoKhM1xo9 JE5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712685077; x=1713289877; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qSb1EMKIyurI6CZqrBQhbOzp5bKMnooWMDlfmCQHkvY=; b=KRu1NsDtmCcl9ITlNLanDmDZu8D+YFA57oaOdWJHU9ML/QW/6ZdGwjZAHhJ0v8esQ2 /IbZup8C3xtLOThTjszCmEJUT5lMW9xMUIoFSbcHmdJfr5R7byWu0mhQFuegFHc7oh0p lJ4Mgrm0lV/tLAkDcHfPHW7dNWZm4sxMC+R0aoDFbHK5bANIOad/tyN9F3R6FZqX6DJf BAFDwev+K6fLHDxzbkRXAVqpCa2K5woGd5zi4ikW98L8Wweua1i6OqmgqP7sX3b1+gv1 Ekgk8UYGwUJ4cY9DtWd8OauHI0HV3RSWnbo4TRIju9q4yHh58Jbmp9giiKj2AxrIWUAe qqeQ== X-Forwarded-Encrypted: i=1; AJvYcCU33ZmCBW4h2ar9/YnVCxN3HqfZHIA3HJjtsQmsnCHBzMyvFKxZs/DL/B7t8R1VkmMj4znX+Gmw/az3rmxT2LuD7qpP2KUoTGpmJn8z X-Gm-Message-State: AOJu0YxK01epqxi86d7WmzfS9oZYry7pCKuSHVzsrKL2x7kR/1kBH3BZ Is3fbTU/msfMP0WQFxuZ2MSWtc51A5uckXkffEKyJB8533IuYACzrcHSOvpZfDotntFUBp7rkzM a5g== X-Google-Smtp-Source: AGHT+IFBk9SVlkSEc4xukn3nQNTD/u4a73A5Zc/qt1mZJNwu/MInQ+Oti0Aw/jqgBed6aGrOn/f0orNgOzQ= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:4fca:b0:6ea:baf6:57a3 with SMTP id le10-20020a056a004fca00b006eabaf657a3mr4590pfb.6.1712685076626; Tue, 09 Apr 2024 10:51:16 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 9 Apr 2024 10:51:07 -0700 In-Reply-To: <20240409175108.1512861-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240409175108.1512861-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240409175108.1512861-4-seanjc@google.com> Subject: [PATCH 3/3] x86/cpu: Ignore "mitigations" kernel parameter if SPECULATION_MITIGATIONS=n From: Sean Christopherson To: Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Josh Poimboeuf Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , Pawan Gupta , Daniel Sneddon Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Explicitly disallow enabling mitigations at runtime for kernels that were built with CONFIG_SPECULATION_MITIGATIONS=3Dn. Because more Kconfigs are buried behind SPECULATION_MITIGATIONS, trying to provide sane behavior for retroactively enabling mitigations is extremely difficult, bordering on impossible. E.g. page table isolation and call depth tracking requrie build-time support, BHI mitigations will still be off without additional kernel parameters, etc. Signed-off-by: Sean Christopherson Reviewed-by: Daniel Sneddon --- Documentation/admin-guide/kernel-parameters.txt | 3 +++ arch/x86/Kconfig | 10 +++++++--- kernel/cpu.c | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index 70046a019d42..7d623df11a1a 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3423,6 +3423,9 @@ arch-independent options, each of which is an aggregation of existing arch-specific options. =20 + Note, "mitigations" is supported on x86 if and only if + the kernel was built with SPECULATION_MITIGATIONS=3Dy. + off Disable all optional CPU mitigations. This improves system performance, but it may also diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 10a6251f58f3..f4e4dd360636 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2493,10 +2493,14 @@ menuconfig SPECULATION_MITIGATIONS default y help Say Y here to enable options which enable mitigations for - speculative execution hardware vulnerabilities. + speculative execution hardware vulnerabilities. Mitigations can + be disabled or restricted to SMT systems at runtime via the + "mitigations" kernel parameter. =20 - If you say N, all mitigations will be disabled. You really - should know what you are doing to say so. + If you say N, all mitigations will be disabled. This CANNOT be + overridden at runtime. + + Say 'Y', unless you really know what you are doing. =20 if SPECULATION_MITIGATIONS =20 diff --git a/kernel/cpu.c b/kernel/cpu.c index 07ad53b7f119..d445763d8047 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -3214,6 +3214,8 @@ static int __init mitigations_parse_cmdline(char *arg) { if (!strcmp(arg, "off")) cpu_mitigations =3D CPU_MITIGATIONS_OFF; + else if (!IS_ENABLED(CONFIG_SPECULATION_MITIGATIONS)) + pr_crit("Kernel compiled without mitigations, system may still be vulner= able\n"); else if (!strcmp(arg, "auto")) cpu_mitigations =3D CPU_MITIGATIONS_AUTO; else if (!strcmp(arg, "auto,nosmt")) --=20 2.44.0.478.gd926399ef9-goog