Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2413578lqt; Mon, 22 Apr 2024 09:59:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXY193EPkMEX93+yvnBdqZr0xRE2L59J4ZbPmNxMKORK2N2HSttT5YDkzNGK8xgR9fnx9xFf6yvMPLV4acWRzeVOxwas0D7ysSewmwa2Q== X-Google-Smtp-Source: AGHT+IHb7mhvKH9FkhTVH5Z3SKHFAUMpg738bBhJoc7wVb3R2W1XHiTFDVGX7cllBhJXK2Iolvif X-Received: by 2002:a05:6358:ed07:b0:183:f0e8:b625 with SMTP id hy7-20020a056358ed0700b00183f0e8b625mr13024290rwb.16.1713805140141; Mon, 22 Apr 2024 09:59:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713805140; cv=pass; d=google.com; s=arc-20160816; b=0PGX+OAuNi3E2za3684E9ScfYrIxt3IZvfhnwpkgsTK0PoIL+E+Sqjpi1x0tbCtOw9 CXSiJD/GwdyplbRhsejVCMtfo1acH7NlvC7lo5qWy0G8dUuQ3p3D2CNFnIsqFcRk0lYP djN9pOeP9eGqkN11Z6K2GvoddRNlwBWyVF4LQ0lZe4z5w1uwZ9H7mORtQNs0HcJe61Zc BQi7lPrWGFaqavvqSeiFln7VizJNKSTZJ5mlhae2wkUus1eolZvlylAoR0/Ogkk3YW/8 CuAv570o75M1CxXdtSUBUh1dWHmbr0B5X6D5fxDx/A1fzQVz+t4hxx1rTShDNu9Xetf7 4USw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=2+Xvj/XO4sTHp5aN1cVE+tNgMsTv2wp93ECmexNu930=; fh=RVdohLdYJrVbJ5wbqJjd2ffE5LHfO9+2ihKD86MZiMA=; b=PA0Xp/UlybvDR9PI9NJA/oyHWg7p7CXFW409XlDQzjgJDvs0QCmHSrUuF1sBcOQWVb VknhR+3biBpaDGPutrJO4YT8xYCq2Sw6M5ASmJi6YwMqmFfYL8eeAxH7BKDQLRK7ocK9 uKlvt9gAMDvLRCgy3etTnle4UdEHKGlWi6FJWzTkkZL7qgSrdBTKZMaguZVth/5Uhv0f Yyn2xuuDgHCAre5nEICFpQevWVHp5ci+MurM6LIAvD9teNtpDnrkmcL3Jwk1Rg+mS/Aq 8IIltQYCrCsIuOGVee3e3O/o5e3iDUyluwK9LSHlUcQtQ8iG9TwWkQb7gnHyDT8vPA6e Gt/A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-153764-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153764-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ay15-20020a05622a228f00b0043971372e18si6076330qtb.47.2024.04.22.09.58.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 09:59:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153764-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; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-153764-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153764-linux.lists.archive=gmail.com@vger.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id BB5381C21348 for ; Mon, 22 Apr 2024 16:58:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63F2C153834; Mon, 22 Apr 2024 16:58:51 +0000 (UTC) Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (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 1BC25153825 for ; Mon, 22 Apr 2024 16:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713805130; cv=none; b=BSRvzsN/+UN9LjGLmT1LLyRKN1kS4GyJQWqPiyT+kMeYTc3x892EzT6963+pIeoij1IOUHaew4Mcw56id/5YsPmbdsKJDr/k2jJPiP5s9Ha+V2XomjF3ccyCajySPjrASQXpNlisQ6UpqoPic2DrzUn7edzCnqfQIw+alMnNK1Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713805130; c=relaxed/simple; bh=jjj5jPrwF+lxQV91ehefWDPdbAf+KONmwhC5TEerBzw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=NXx3gbP9ZPlYX8Qpb76cLXzW0B9QdyMwEJqYudvs/d3uUQk2kfZ9CYBkbXPkqVx7pqfl47k28IvEKoX80eHNfRQ+dqjaoPUkui3R+dCvDH6Z+dZyj/36T3Z/86+eMrX7vYpGESesBRPW3LvIQz/FiDhg5EAUgkdJfh23GQAANTY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a5544fd07easo519543466b.0 for ; Mon, 22 Apr 2024 09:58:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713805127; x=1714409927; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2+Xvj/XO4sTHp5aN1cVE+tNgMsTv2wp93ECmexNu930=; b=Idp2jjR7xORgE5rk9hYYcJtCnGPNwl/AM4GoCVlLeFWJCf/VPwYNAPK5IqC4mSSgGL /70heihXQ8rvrrj3sY3EIO/QU+4G2HgNAofA2mkzlvt8PYeBmyvb0TXLIshKAwWJ3NoS XYusMKiCPTy0hZhMHCi5hCfd5aWIx4QkDsS/2NQtHTWTN9sYIbDaTCmphwKwHK3mdlvh +TsdcHfKx0P7aEnF31EiD8MFNkquAn1aF6YJVl1DqoK44903z+jvS/pE6wfcI+s5Tb/7 UR4t3+7+n2IuoEj0VHfPhNFm7YOt/jfyuGzELtAwOPlI+9giCsFZ9Kaq3PxC/q1BJ7SE XZyQ== X-Forwarded-Encrypted: i=1; AJvYcCXBT62wIObc7DKqEQWscAAJ4dLAlGSaqV4Szbntv2821ROE3GQiqItaR/eXmjcq1UzaLmVAI6vyFI73iLuyVaQNJm+xxKNL8Llyh9X9 X-Gm-Message-State: AOJu0YwmEpCDPs226CMtbMP/PWfVyP3X84YA5itkn4vDUSIT/giOEuEm ZbhLBg6UfMaqxPLq1oretjqbwlb3V5G8da52aYxYRVSoRliuS2/1 X-Received: by 2002:a17:906:f757:b0:a58:72ae:722c with SMTP id jp23-20020a170906f75700b00a5872ae722cmr528052ejb.29.1713805126999; Mon, 22 Apr 2024 09:58:46 -0700 (PDT) Received: from localhost (fwdproxy-lla-003.fbsv.net. [2a03:2880:30ff:3::face:b00c]) by smtp.gmail.com with ESMTPSA id be11-20020a1709070a4b00b00a5588a9fe66sm4433425ejc.86.2024.04.22.09.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 09:58:46 -0700 (PDT) From: Breno Leitao To: jpoimboe@kernel.org, mingo@redhat.com Cc: x86@kernel.org, tglx@linutronix.de, bp@alien8.de, linux-kernel@vger.kernel.org, pawan.kumar.gupta@linux.intel.com Subject: [PATCH v3 00/10] x86/bugs: Separate config for mitigations Date: Mon, 22 Apr 2024 09:58:14 -0700 Message-ID: <20240422165830.2142904-1-leitao@debian.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The current CONFIG_SPECULATION_MITIGATIONS namespace is only halfway populated, where some mitigations have entries in Kconfig, and they could be modified, while others mitigations do not have Kconfig entries, and can not be controlled at build time. New mitigations, such as BHI, were properly added, i.e, having an independent Kconfig, which depends on CONFIG_SPECULATION_MITIGATIONS, so, you can enable/disable at compilation time. This patch set aims to have the old mitigations in the same format, bringing some uniformity to the mitigations. These are the advantages of having fine-grained control for the mitigations: 1) Users can choose and pick only mitigations that are important for their workloads. 2) Users and developers can choose to disable mitigations that mangle the assembly code generation, making it hard to read. 3) Separate Kconfigs for just source code readability, so that we see *which* butt-ugly piece of crap code is for what reason... In most cases, if a mitigation is disabled at compilation time, it can still be enabled at runtime using kernel command line arguments. This is the second part of the initial patchset[1] that got half landed. The first patch did some code re-organization. This second part contains the exact missing patches from the initial patchset, and basically adds build-time configuration for the other mitigations that are currently only disabled at boot time. Here is a detailed view of each patch: With this patch applied, setting CONFIG_SPECULATION_MITIGATIONS=n, a simple script[2] shows that all the mitigations are disabled: spectre_v2_user_stibp SPECTRE_V2_USER_NONE spectre_v2_user_ibpb SPECTRE_V2_USER_NONE spectre_v2_cmd SPECTRE_V2_CMD_NONE ssb_mode SPEC_STORE_BYPASS_NONE l1tf_mitigation L1TF_MITIGATION_OFF srso_mitigation SRSO_MITIGATION_NONE srso_cmd SRSO_CMD_SAFE_RET mds_mitigation MDS_MITIGATION_OFF taa_mitigation TAA_MITIGATION_OFF mmio_mitigation MMIO_MITIGATION_OFF srbds_mitigation SRBDS_MITIGATION_OFF gds_mitigation GDS_MITIGATION_OFF spectre_v1_mitigation SPECTRE_V1_MITIGATION_NONE spectre_v2_enabled SPECTRE_V2_NONE retbleed_mitigation RETBLEED_MITIGATION_NONE [1] https://lore.kernel.org/all/ZZ7c9EbJ71zU5TOF@gmail.com/#t [2] https://github.com/leitao/debug/blob/main/spec/dump_speculation.py Changelog: v3: * Rebased the patch on top of linux-next, since BHI mitigation added some hunk to original patch series. * Broke down the patches even further, creating one patch for each mitigation. This make the review code easier (I hope). * Nothing was changed, code-wise. The code is *exactly* the * same * Dropped the "spectre_v2_user default mode depends on main default" patch, that will be sent later, since there is no dependency to this patch series. Hopping to make the review/acceptance easier as well. v2: * Patch 2: Changed `mode` type from int to `enum spectre_v2_user_cmd` as suggested by Pawan Gupta * Patch 3: Change MITIGATION_RETBLEED dependency to match the code. * https://lore.kernel.org/all/20240208174555.44200-1-leitao@debian.org/ v1: * https://lore.kernel.org/all/20240118173213.2008115-1-leitao@debian.org/ Breno Leitao (10): x86/bugs: Add a separate config for GDS x86/bugs: Add a separate config for MDS x86/bugs: Add a separate config for TAA x86/bugs: Add a separate config for MMIO Stable Data x86/bugs: Add a separate config for L1TF x86/bugs: Add a separate config for RETBLEED x86/bugs: Add a separate config for Spectre v1 x86/bugs: Add a separate config for SRBDS x86/bugs: Add a separate config for Spectre V2 x86/bugs: Add a separate config for SSB arch/x86/Kconfig | 117 +++++++++++++++++++++++++++++++++++-- arch/x86/kernel/cpu/bugs.c | 46 +++++++++------ 2 files changed, 140 insertions(+), 23 deletions(-) -- 2.43.0