Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp308506lqb; Tue, 16 Apr 2024 17:15:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVCBcuynXAh5f+ZnwRRQ78V9HwHbG+/aqzv3pQL7CuOK9v/ryf9Qppk3XB+HR7PvX+F0UVjPAoGCTP1luhoKoYKqmMZX7x+IYj+nDSR9g== X-Google-Smtp-Source: AGHT+IE9+J9orVsVIc5J9IUI/18G09TFfAtYwwQCIpZARAR+6m/X8s30B5zBKwn0yYIM2L6/sOJW X-Received: by 2002:ac8:5ad5:0:b0:435:4e0:cc24 with SMTP id d21-20020ac85ad5000000b0043504e0cc24mr18155704qtd.57.1713312943232; Tue, 16 Apr 2024 17:15:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713312943; cv=pass; d=google.com; s=arc-20160816; b=0ytbv5HE5ZOwSZJJa40MecEKqsN3ogjgHekujFbPSiRLKRRw7gXjUXs++ToJN5Wq30 3AIhBwngut709fy5ZnscbWpANXAjHxeOdYv3dDze5iUeujWuzcJ2SRsj4ngfWkoEIX7W hjWeRFzWg9XsQaRjsgrj18sDEJ73i8EziMMwAH2qfxsxbCJ5muwWdmR8DeILlIbLBtTS ZpN3/VdT143vfCPX5zGCUbAtdX1R3QTNI98L0VGHwUL6h613Huv49cnfLJIrtrSutr2k P/J2H1D+MvY0IFDd7RCfmCAz8Ca7EtD5RZa+qHHncwXP+yiuIR/SDsNmHmlV01iwNHXH gozA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=5ofQ3KH15PkqJ9IroccuDO0HaegnEECNOZCgmKj3yJg=; fh=k8qxEYwvtTvLbp2Gk03lX8o9Vf3DO7fq09WKICbp+rs=; b=pKm2MIE2WDfiJY8XFo2cDMqGSuQ8CYxI7dchV10iVE/KpXrVD4hgq5HChVw9FSOIoQ k+fervFx8w4aTp79dKqf2Q7GoLWg/9t/8JMw72ETGmaXC0Kntjz+hcn+E+aOosgquKev MCtNar1I0CfieBH2NaPBiEx5onI3LIOsLAfGjs/YnS6x6DIVm314A8jSWaeQ9t+qe7/H 2OnWgui50BMjS9GQxfBlXxPl/DwPlc7QMhK1U31zYD8hzcmXNvcQ0K1/DvsfFzFpLKT9 41sO0lN2tbhZq0AYri+R7cyg5pRyWPMtGZ+sVaOoNv2gGQMZ06/U+LhxuQkKCn2zuiWA Dkgw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=WFmPEmy9; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-147792-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147792-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 ey13-20020a05622a4c0d00b004370991f999si6233401qtb.40.2024.04.16.17.15.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 17:15:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147792-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=@google.com header.s=20230601 header.b=WFmPEmy9; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-147792-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147792-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 EF22E1C22447 for ; Wed, 17 Apr 2024 00:15:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 64EB24A1D; Wed, 17 Apr 2024 00:15:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="WFmPEmy9" Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 33AA6184D for ; Wed, 17 Apr 2024 00:15:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713312916; cv=none; b=jgvt5OKkvhFZMTYMiXKp64rTUvk7/0Xv7vWYni8AE71DjToexE+p+0DSlMvhi4diiARyRyDlM59qydjzvkcQJyE7rorTJe0/cWfQLIj0WSmXTLbqfBzfKj28DXfJIi1yLgg5rEhJdtCbVdCeDkQ/k6v73DfwDLkFbJ2+rTsjMcU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713312916; c=relaxed/simple; bh=0UVGRaaY/AaWE2yiYwE1iCIDluyE17+bs6H2PNq1AC8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tepJV6wrfiKYyNi43sMBZE93UqZ++AwXxNLEpTxd6cSliAwTG3eotvyrLar8CNZSfdIzmGjusLvT+17n6RV2nphtd7SW4h7ty6e34TomJ5+j9txo+mLo5hV0Ouk1uoRG2zfhErmuMpqZ1u3xOd5kGhKPO0LGATdVH6FGAvM6q/E= 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=WFmPEmy9; arc=none smtp.client-ip=209.85.216.74 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 Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2a4fc4cf54dso5098997a91.1 for ; Tue, 16 Apr 2024 17:15:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713312914; x=1713917714; 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=5ofQ3KH15PkqJ9IroccuDO0HaegnEECNOZCgmKj3yJg=; b=WFmPEmy9VC08Mr25XlxHqie6e1vIwxqgWC2JZy8a1HKzRHV12FPLSq5+kU1b8SvE+r HnBRbGsEq6k10t6olld2vfD2/EhaKY5F+I6cqVxsI9GienONj+iO+w1jzsy0JqoJq81V UT0cDrIrPtaWrjj9GTpnzcCGMFHcLC+/HbcXeWhsrCnNEwAAIfOL7a/GD1Lxkj++jurS A+Tzb5AslvTCmxvHLZfQcQ9P1t3jLBeEH0gedC7oTIoF6fkWw1SSnDyQWLgtEv19F4s4 2niVgkhkan+qLpjwdHPox9XoqVczMVf45kvAbBLu5Iq7uRm7ChXUyanWtNPBU7iLMRK2 IlqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713312914; x=1713917714; 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=5ofQ3KH15PkqJ9IroccuDO0HaegnEECNOZCgmKj3yJg=; b=xRaTUGpcwAnaB0bVmhcDrucYwm868Uc1mIGWu/DYGgPTXbal8Q/YGgWNyCAz1ag7Ip hvdkaDLfq9RhfNJOLhjOi74uMkXPEy8pmedLTXMnKu6BWl7yk0ozay+Qp94ap5oVAQGD 4UjjaY7SE9vAhZFo5cQI4/ciugoG4nG7JaPr4rkRbWURE9Iqoaga+guBW/lrvk6zsOu7 WCpon+SfyH6HeiBs+LuUGztEdnjroP/70+9X5ntT+B9RYnhTgHtoMZiYVQrFmWNDSJQ4 zDDpe2nbHFFhazil+oSe6d1SDsOCd1zsLcX/mBvaHsQJiNUgLnTlTlN9O4gfl11dJogt LwJw== X-Forwarded-Encrypted: i=1; AJvYcCXSgQ6+PSdXapV6oPvknQrZxT/y4ALwzxsJykFHQzkiUZhxaTq5ShGRlunU5eHs/m4/Op1U95wPLc8BLLeNzB1BFUQustabb5dhmbU3 X-Gm-Message-State: AOJu0YxsZkckmOk7kD3u3KgGAi/pJNVNQ/4B5RSuJy2m+OTrjXw7lMRA qQ1Zuc7P6w9aDizw/Oe3OBvQJK5wPZigSWw9VBiS1dKnvMHvZAevzqxvQyamd+ZWw5GU36QDeA2 icg== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90b:3108:b0:2a5:c859:f94f with SMTP id gc8-20020a17090b310800b002a5c859f94fmr58452pjb.3.1713312913929; Tue, 16 Apr 2024 17:15:13 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 16 Apr 2024 17:15:07 -0700 In-Reply-To: <20240417001507.2264512-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: <20240417001507.2264512-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.683.g7961c838ac-goog Message-ID: <20240417001507.2264512-3-seanjc@google.com> Subject: [PATCH 2/2] cpu: Ignore "mitigations" kernel parameter if CPU_MITIGATIONS=n From: Sean Christopherson To: Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Greg Kroah-Hartman , Peter Zijlstra Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Stephen Rothwell , Michael Ellerman , Geert Uytterhoeven , Sean Christopherson Content-Type: text/plain; charset="UTF-8" Explicitly disallow enabling mitigations at runtime for kernels that were built with CONFIG_CPU_MITIGATIONS=n, which currently is possible only on x86 (via x86's SPECULATION_MITIGATIONS menuconfig). On x86, a large pile of Kconfigs are buried behind SPECULATION_MITIGATIONS, and 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 --- 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/Documentation/admin-guide/kernel-parameters.txt index 902ecd92a29f..73cc672de9c3 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. + Note, "mitigations" is supported on x86 if and only if + the kernel was built with SPECULATION_MITIGATIONS=y. + 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 a0eca6313276..3021976e34cf 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2494,10 +2494,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. - 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. if SPECULATION_MITIGATIONS diff --git a/kernel/cpu.c b/kernel/cpu.c index bb0ff275fb46..e3f2b34bb378 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 = CPU_MITIGATIONS_OFF; + else if (!IS_ENABLED(CONFIG_CPU_MITIGATIONS)) + pr_crit("Kernel compiled without mitigations, ignoring 'mitigations'; system may still be vulnerable\n"); else if (!strcmp(arg, "auto")) cpu_mitigations = CPU_MITIGATIONS_AUTO; else if (!strcmp(arg, "auto,nosmt")) -- 2.44.0.683.g7961c838ac-goog