From nobody Sun Feb 8 17:14:31 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E5BFEB64D9 for ; Thu, 15 Jun 2023 16:45:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236145AbjFOQpV (ORCPT ); Thu, 15 Jun 2023 12:45:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236130AbjFOQog (ORCPT ); Thu, 15 Jun 2023 12:44:36 -0400 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0F4130C6 for ; Thu, 15 Jun 2023 09:44:28 -0700 (PDT) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-30e412a852dso6024947f8f.0 for ; Thu, 15 Jun 2023 09:44:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686847467; x=1689439467; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h/iaRHbMZknbdlPyOxZE8eGdzil5wkV0A7XuLO8jEos=; b=e19iUv80fm9DHni/on1OhVwGrsi36TWIKh3BdUodXdtJRIqR5uTOVColyzZw23E46l H7vZyfteDVCh4PWoRIN6GB6F8gjWV+3xkJbJLJHVORYyTGi+RjJpRkCfTl2L346U+eWB jBFNHt3Yl1NyiyRO6ULLe6DfS3fQAH3ZNxgLcmJejJK3KRqEpwH2IPFDSI3PN0NQTCNG xAGsyZJA3keMYoGZbzn3p9f9uAQI55ROds5KXT7GrYateTi4huXWXdWwuBVK30U4ycYD mz7cO7323IgsxAAwBlg5SyNxfU2qC5sCyeB2P6Y1TqN/shhZucokHwZFRMtEzTkx3dh8 QrtA== X-Gm-Message-State: AC+VfDyHJvMPeRqw+x5gpIGUfNKvb7kGBW2j21U0zLfM8cx/MpNS3vhR 3CotD+L9fVemd1Nfwe9NRdN7GAIyMWs= X-Google-Smtp-Source: ACHHUZ4Tf3U78NbDvBaXcy6pNpUoCEg1zhXEIHFBt0r8wCtMdvb9HiNSl0VLtsWo59p+6m3X7D1VUw== X-Received: by 2002:a5d:4cc1:0:b0:30f:c142:5330 with SMTP id c1-20020a5d4cc1000000b0030fc1425330mr7815963wrt.27.1686847467003; Thu, 15 Jun 2023 09:44:27 -0700 (PDT) Received: from localhost (fwdproxy-cln-020.fbsv.net. [2a03:2880:31ff:14::face:b00c]) by smtp.gmail.com with ESMTPSA id a8-20020a5d5088000000b0030f9c3219aasm19257509wrt.47.2023.06.15.09.44.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 09:44:26 -0700 (PDT) From: Breno Leitao To: pawan.kumar.gupta@linux.intel.com, jpoimboe@kernel.org, peterz@infradead.org, tglx@linutronix.de, bp@alien8.de, Ingo Molnar , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: leit@fb.com, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] x86/bugs: Create an option to disable MDS Date: Thu, 15 Jun 2023 09:44:12 -0700 Message-Id: <20230615164417.3588162-2-leitao@debian.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230615164417.3588162-1-leitao@debian.org> References: <20230615164417.3588162-1-leitao@debian.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There is no way to disable MDS mitigation today at compilation time. MDS is enabled even if CONFIG_SPECULATION_MITIGATIONS is unset. Create a new KCONFIG option that allow MDS mitigations to be disabled in compilation time. Signed-off-by: Breno Leitao --- arch/x86/Kconfig | 11 +++++++++++ arch/x86/kernel/cpu/bugs.c | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 53bab123a8ee..d25132b2d54f 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2649,6 +2649,17 @@ config SLS against straight line speculation. The kernel image might be slightly larger. =20 +config MITIGATE_MDS + bool "Mitigate Microarchitectural Data Sampling (MDS) hardware bug" + depends on CPU_SUP_INTEL && X86_64 + default y + help + Enable mitigation for Microarchitectural Data Sampling (MDS). MDS is + a hardware vulnerability which allows unprivileged speculative access + to data which is available in various CPU internal buffer. Deeper + technical information is available in the MDS specific x86 architecture + section: Documentation/arch/x86/mds.rst. + endif =20 config ARCH_HAS_ADD_PAGES diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 182af64387d0..50f12829dce9 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -269,6 +269,7 @@ static void x86_amd_ssb_disable(void) /* Default mitigation for MDS-affected CPUs */ static enum mds_mitigations mds_mitigation __ro_after_init =3D MDS_MITIGAT= ION_FULL; static bool mds_nosmt __ro_after_init =3D false; +#define MDS_WARN_MSG "WARNING: Microarchitectural Data Sampling (MDS) spec= ulative mitigation disabled!\n" =20 static const char * const mds_strings[] =3D { [MDS_MITIGATION_OFF] =3D "Vulnerable", @@ -278,11 +279,17 @@ static const char * const mds_strings[] =3D { =20 static void __init mds_select_mitigation(void) { - if (!boot_cpu_has_bug(X86_BUG_MDS) || cpu_mitigations_off()) { + if (!boot_cpu_has_bug(X86_BUG_MDS)) { mds_mitigation =3D MDS_MITIGATION_OFF; return; } =20 + if (cpu_mitigations_off() || !IS_ENABLED(CONFIG_MITIGATE_MDS)) { + mds_mitigation =3D MDS_MITIGATION_OFF; + pr_err(MDS_WARN_MSG); + return; + } + if (mds_mitigation =3D=3D MDS_MITIGATION_FULL) { if (!boot_cpu_has(X86_FEATURE_MD_CLEAR)) mds_mitigation =3D MDS_MITIGATION_VMWERV; --=20 2.34.1 From nobody Sun Feb 8 17:14:31 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BCCCEB64D9 for ; Thu, 15 Jun 2023 16:45:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237057AbjFOQph (ORCPT ); Thu, 15 Jun 2023 12:45:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237015AbjFOQo5 (ORCPT ); Thu, 15 Jun 2023 12:44:57 -0400 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BE7030FA for ; Thu, 15 Jun 2023 09:44:35 -0700 (PDT) Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-3f8d2bfec9bso22127965e9.0 for ; Thu, 15 Jun 2023 09:44:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686847474; x=1689439474; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C7eq1USby5ztEf/7JC2Lke/melezYmsYGTiWNlQ9QdE=; b=IV6LxR5o3aMYTfUtYytMr644MIV6Oiajfl225yCbT6QpDlJ4T+ohDQrmkDuIAkaSJ9 W9zACqMgQpXStIhSHZoUCLNPFszhOcFqzUMKIaAtAUfe4C1ImyeazH5XOgv8CpFoUW7y NqUazOoJliX5PyvjE6BS3LBvnScaocmURFhqXFbtaVAu/9JeZ1gpnCm5WCIH/R2KGSXO +vuM4TabZLT6Ae5bh1wXr6CrxvcqYzA7TZyiuRGYRbVKkob8rllzzuUPSNoHtOKxo0U/ jtSZq9FhUF+Yrhh4JAFU1WnHjagbInW11r7UvPF9HmR+Q+p0HinUazCY3MAei7y2v9fi P8Bw== X-Gm-Message-State: AC+VfDzQgbNSB8iIBKhR/clsLUsbq+4vzkSQqIj3RC74GuhfMoUul8lj rzXX56ZEEEZQqmZvzkdlDc4= X-Google-Smtp-Source: ACHHUZ5vMzpzcEwea8p6zmZXyM0paKmFlSUyMnQ4eN2gvbq1e5scVMSPYhTePZDDNsVHDD4QsZ9Bkw== X-Received: by 2002:a1c:ed06:0:b0:3f7:f584:5796 with SMTP id l6-20020a1ced06000000b003f7f5845796mr15079346wmh.2.1686847473943; Thu, 15 Jun 2023 09:44:33 -0700 (PDT) Received: from localhost (fwdproxy-cln-012.fbsv.net. [2a03:2880:31ff:c::face:b00c]) by smtp.gmail.com with ESMTPSA id h4-20020a05600c314400b003f1978bbcd6sm4683036wmo.3.2023.06.15.09.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 09:44:33 -0700 (PDT) From: Breno Leitao To: pawan.kumar.gupta@linux.intel.com, jpoimboe@kernel.org, peterz@infradead.org, tglx@linutronix.de, bp@alien8.de, Ingo Molnar , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: leit@fb.com, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] x86/speculation: Disable mitigations if CONFIG says so Date: Thu, 15 Jun 2023 09:44:16 -0700 Message-Id: <20230615164417.3588162-6-leitao@debian.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230615164417.3588162-1-leitao@debian.org> References: <20230615164417.3588162-1-leitao@debian.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There is no way to disable certain mitigations(MDS, TAA, MMIO) today. They are enabled even when the kernel has CONFIG_SPECULATION_MITIGATIONS=3Dn. Create a function that says if the speculative mitigations are enabled or not. They should use CONFIG_SPECULATION_MITIGATIONS as one source of information. Just enable MDS, TAA, MMIO mitigations if speculative mitigations are enabled. Signed-off-by: Breno Leitao --- arch/x86/kernel/cpu/bugs.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 182af64387d0..703649a29181 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -87,6 +87,12 @@ void update_spec_ctrl_cond(u64 val) wrmsrl(MSR_IA32_SPEC_CTRL, val); } =20 +static inline bool cpu_speculative_mitigations_off(void) +{ + return cpu_mitigations_off() || + !IS_ENABLED(CONFIG_SPECULATION_MITIGATIONS); +} + noinstr u64 spec_ctrl_current(void) { return this_cpu_read(x86_spec_ctrl_current); @@ -278,7 +284,7 @@ static const char * const mds_strings[] =3D { =20 static void __init mds_select_mitigation(void) { - if (!boot_cpu_has_bug(X86_BUG_MDS) || cpu_mitigations_off()) { + if (!boot_cpu_has_bug(X86_BUG_MDS) || cpu_speculative_mitigations_off()) { mds_mitigation =3D MDS_MITIGATION_OFF; return; } @@ -352,7 +358,7 @@ static void __init taa_select_mitigation(void) return; } =20 - if (cpu_mitigations_off()) { + if (cpu_speculative_mitigations_off()) { taa_mitigation =3D TAA_MITIGATION_OFF; return; } @@ -443,7 +449,7 @@ static void __init mmio_select_mitigation(void) =20 if (!boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA) || boot_cpu_has_bug(X86_BUG_MMIO_UNKNOWN) || - cpu_mitigations_off()) { + cpu_speculative_mitigations_off()) { mmio_mitigation =3D MMIO_MITIGATION_OFF; return; } @@ -516,7 +522,7 @@ early_param("mmio_stale_data", mmio_stale_data_parse_cm= dline); =20 static void __init md_clear_update_mitigation(void) { - if (cpu_mitigations_off()) + if (cpu_speculative_mitigations_off()) return; =20 if (!static_key_enabled(&mds_user_clear)) --=20 2.34.1 From nobody Sun Feb 8 17:14:31 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C0F3EB64DA for ; Thu, 15 Jun 2023 16:45:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236787AbjFOQp2 (ORCPT ); Thu, 15 Jun 2023 12:45:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236242AbjFOQoo (ORCPT ); Thu, 15 Jun 2023 12:44:44 -0400 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B60C42D75 for ; Thu, 15 Jun 2023 09:44:30 -0700 (PDT) Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-30fc90f359fso3238477f8f.3 for ; Thu, 15 Jun 2023 09:44:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686847469; x=1689439469; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yDJSQzuktanU2Jg2xVD0F/r0980umpPsJ0j0RWDQ1rg=; b=ZqnggpNQElkv8Bi/QjIOp18QIt0ami4HaITF+tfhLAR+5n6Gs6Vi8mFIUsypSpJOge uASjsFw3S9D9E8TR1v+lXftx6F+q/bDqFKcIBoHLesIJ73I8NclCbWht2uLm/xCXbENC UEwIXQXbyheEtoHD/oJQ35gQzbbrNALWaE4PZnXmjcC0nhpHCX+7ALXvokERcVcp8RnD DZToMahPtCi72n50cwxGjfbaq07VCu0oh6JQilwZaKDlm6APRFfoWmpt5g8h7/czFbIF QUG3MMq9xys9UgtT4rp5PX2j2Tclqvcd5iCpRbqD5NNrhjavBMo2UQrVphB82CPgHebl jzCQ== X-Gm-Message-State: AC+VfDzrgjyCu2YwULkvoGsfuJAlvb/IwASvdkVJ6uKdR14s7O+KjVNA QSDv/PmPg/ZHRpAZsRhZlE8= X-Google-Smtp-Source: ACHHUZ6MTnd9tDwMGRx7ahXOqi0IkgjY8BrdmE322JxFQy4hyHZc6iJBneVWxvJcemvZc7PGVZNSbg== X-Received: by 2002:a05:6000:1:b0:30f:bbf1:d195 with SMTP id h1-20020a056000000100b0030fbbf1d195mr9842573wrx.36.1686847468817; Thu, 15 Jun 2023 09:44:28 -0700 (PDT) Received: from localhost (fwdproxy-cln-116.fbsv.net. [2a03:2880:31ff:74::face:b00c]) by smtp.gmail.com with ESMTPSA id d17-20020a5d6dd1000000b003095bd71159sm21615015wrz.7.2023.06.15.09.44.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 09:44:28 -0700 (PDT) From: Breno Leitao To: pawan.kumar.gupta@linux.intel.com, jpoimboe@kernel.org, peterz@infradead.org, tglx@linutronix.de, bp@alien8.de, Ingo Molnar , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: leit@fb.com, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] x86/bugs: Create an option to disable TAA Date: Thu, 15 Jun 2023 09:44:13 -0700 Message-Id: <20230615164417.3588162-3-leitao@debian.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230615164417.3588162-1-leitao@debian.org> References: <20230615164417.3588162-1-leitao@debian.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There is no way to disable TAA mitigation today at compilation time. TAA is enabled even if CONFIG_SPECULATION_MITIGATIONS is unset. Create a new KCONFIG option that allow TAA mitigation to be disabled in compilation time. Signed-off-by: Breno Leitao --- arch/x86/Kconfig | 10 ++++++++++ arch/x86/kernel/cpu/bugs.c | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index d25132b2d54f..140af3b30c45 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2660,6 +2660,16 @@ config MITIGATE_MDS technical information is available in the MDS specific x86 architecture section: Documentation/arch/x86/mds.rst. =20 +config MITIGATE_TAA + bool "Mitigate TSX Asynchronous Abort (TAA) hardware bug" + depends on CPU_SUP_INTEL && X86_64 + default y + help + Enable mitigation for TSX Asynchronous Abort (TAA). TAA is a hardware + vulnerability that allows unprivileged speculative access to data + which is available in various CPU internal buffers by using + asynchronous aborts within an Intel TSX transactional region. + endif =20 config ARCH_HAS_ADD_PAGES diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 50f12829dce9..3615bda9573f 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -336,6 +336,7 @@ enum taa_mitigations { /* Default mitigation for TAA-affected CPUs */ static enum taa_mitigations taa_mitigation __ro_after_init =3D TAA_MITIGAT= ION_VERW; static bool taa_nosmt __ro_after_init; +#define TAA_WARN_MSG "WARNING: TSX Asynchronous Abort (TAA) speculative mi= tigation disabled!\n" =20 static const char * const taa_strings[] =3D { [TAA_MITIGATION_OFF] =3D "Vulnerable", @@ -359,8 +360,9 @@ static void __init taa_select_mitigation(void) return; } =20 - if (cpu_mitigations_off()) { + if (cpu_mitigations_off() || !IS_ENABLED(CONFIG_MITIGATE_TAA)) { taa_mitigation =3D TAA_MITIGATION_OFF; + pr_err(TAA_WARN_MSG); return; } =20 --=20 2.34.1 From nobody Sun Feb 8 17:14:31 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CF47EB64D9 for ; Thu, 15 Jun 2023 16:45:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237103AbjFOQpn (ORCPT ); Thu, 15 Jun 2023 12:45:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237188AbjFOQpA (ORCPT ); Thu, 15 Jun 2023 12:45:00 -0400 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC8F53590 for ; Thu, 15 Jun 2023 09:44:37 -0700 (PDT) Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2b4470e1500so12167911fa.1 for ; Thu, 15 Jun 2023 09:44:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686847476; x=1689439476; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0LSIDuAzGUjwULNEFFLWoff2MIu4uiigVl6eBKjinCo=; b=CPAnbxpwtfqlBayL9sHpYGgnC+f7w+Vj7Q3286vJdWis0ZeWkObFo9tgWBlFKuwblV M8IiwwkPQBcPXwJ3LZElvpco29ASkJo5om5TT+VMJwOqpAmPkzwvzRN8miLFRFmbAEdi dpowGxLm6i/fBrxA3b9M9s6g8t1AWuCGWXjyjyO85jCz8qRJwOpj1IlREFcB3lc0gM36 Grzt3+6Dtcv8e2dPKOHDFYMSZouR/T0zU0h+S1VYi4cid+kiA0MszqszJG038nkR2nWg S5aARFN/Lm52iK81dLRUAqb9B8siWMaMbBdmK0QVDksbPXUdoRBJjMIQYORbNEImCXIz ng6A== X-Gm-Message-State: AC+VfDwMBzfrFOp7PQOCOatctZHDpaU/MXT4W4mPxHJEziSGIZ9qLq/5 Upzp5S+9u1GKCWa+pI0WwSY= X-Google-Smtp-Source: ACHHUZ4pR9WDwMlm3g3HwOYKuBIeEK8y7RWOY4bSgnAnd5UNBpuROzozma91VhwiCiN8B79aBFE6yg== X-Received: by 2002:a2e:90cd:0:b0:2ac:8261:5f4b with SMTP id o13-20020a2e90cd000000b002ac82615f4bmr5658ljg.28.1686847476025; Thu, 15 Jun 2023 09:44:36 -0700 (PDT) Received: from localhost (fwdproxy-cln-011.fbsv.net. [2a03:2880:31ff:b::face:b00c]) by smtp.gmail.com with ESMTPSA id m1-20020a5d4a01000000b003062ad45243sm21533276wrq.14.2023.06.15.09.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 09:44:35 -0700 (PDT) From: Breno Leitao To: pawan.kumar.gupta@linux.intel.com, jpoimboe@kernel.org, peterz@infradead.org, tglx@linutronix.de, bp@alien8.de, Ingo Molnar , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: leit@fb.com, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] x86/speculation: Print error when mitigations are disabled Date: Thu, 15 Jun 2023 09:44:17 -0700 Message-Id: <20230615164417.3588162-7-leitao@debian.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230615164417.3588162-1-leitao@debian.org> References: <20230615164417.3588162-1-leitao@debian.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If mitigations are disabled for MDS, TAA, MMIO we want to let users aware. This is either disabled by "mitigations=3Doff" kernel argument, or, by CONFIG_SPECULATION_MITIGATIONS=3Dn Signed-off-by: Breno Leitao --- arch/x86/kernel/cpu/bugs.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 703649a29181..b678cdd95dc1 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -275,6 +275,7 @@ static void x86_amd_ssb_disable(void) /* Default mitigation for MDS-affected CPUs */ static enum mds_mitigations mds_mitigation __ro_after_init =3D MDS_MITIGAT= ION_FULL; static bool mds_nosmt __ro_after_init =3D false; +#define MDS_WARN_MSG "WARNING: Microarchitectural Data Sampling (MDS) spec= ulative mitigation disabled!\n" =20 static const char * const mds_strings[] =3D { [MDS_MITIGATION_OFF] =3D "Vulnerable", @@ -284,11 +285,16 @@ static const char * const mds_strings[] =3D { =20 static void __init mds_select_mitigation(void) { - if (!boot_cpu_has_bug(X86_BUG_MDS) || cpu_speculative_mitigations_off()) { + if (!boot_cpu_has_bug(X86_BUG_MDS)) { mds_mitigation =3D MDS_MITIGATION_OFF; return; } =20 + if (cpu_speculative_mitigations_off()) { + pr_err(MDS_WARN_MSG); + mds_mitigation =3D MDS_MITIGATION_OFF; + } + if (mds_mitigation =3D=3D MDS_MITIGATION_FULL) { if (!boot_cpu_has(X86_FEATURE_MD_CLEAR)) mds_mitigation =3D MDS_MITIGATION_VMWERV; @@ -335,6 +341,7 @@ enum taa_mitigations { /* Default mitigation for TAA-affected CPUs */ static enum taa_mitigations taa_mitigation __ro_after_init =3D TAA_MITIGAT= ION_VERW; static bool taa_nosmt __ro_after_init; +#define TAA_WARN_MSG "WARNING: TSX Asynchronous Abort (TAA) speculative mi= tigation disabled!\n" =20 static const char * const taa_strings[] =3D { [TAA_MITIGATION_OFF] =3D "Vulnerable", @@ -359,6 +366,7 @@ static void __init taa_select_mitigation(void) } =20 if (cpu_speculative_mitigations_off()) { + pr_err(TAA_WARN_MSG); taa_mitigation =3D TAA_MITIGATION_OFF; return; } @@ -436,6 +444,7 @@ enum mmio_mitigations { /* Default mitigation for Processor MMIO Stale Data vulnerabilities */ static enum mmio_mitigations mmio_mitigation __ro_after_init =3D MMIO_MITI= GATION_VERW; static bool mmio_nosmt __ro_after_init =3D false; +#define MMIO_WARN_MSG "WARNING: MMIO Stale Data speculative mitigation dis= abled!\n" =20 static const char * const mmio_strings[] =3D { [MMIO_MITIGATION_OFF] =3D "Vulnerable", @@ -448,12 +457,16 @@ static void __init mmio_select_mitigation(void) u64 ia32_cap; =20 if (!boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA) || - boot_cpu_has_bug(X86_BUG_MMIO_UNKNOWN) || - cpu_speculative_mitigations_off()) { + boot_cpu_has_bug(X86_BUG_MMIO_UNKNOWN)) { mmio_mitigation =3D MMIO_MITIGATION_OFF; return; } =20 + if (cpu_speculative_mitigations_off()) { + pr_err(MMIO_WARN_MSG); + mmio_mitigation =3D MMIO_MITIGATION_OFF; + } + if (mmio_mitigation =3D=3D MMIO_MITIGATION_OFF) return; =20 --=20 2.34.1 From nobody Sun Feb 8 17:14:31 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45999EB64DA for ; Thu, 15 Jun 2023 16:45:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236909AbjFOQpb (ORCPT ); Thu, 15 Jun 2023 12:45:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232053AbjFOQoq (ORCPT ); Thu, 15 Jun 2023 12:44:46 -0400 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F6F830D6 for ; Thu, 15 Jun 2023 09:44:32 -0700 (PDT) Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-3f8cec6641bso22528605e9.1 for ; Thu, 15 Jun 2023 09:44:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686847471; x=1689439471; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cnu101MlL/lBc9D51wfUyU127xq92KgSEDJgVIsZ6RU=; b=h8T/2GAVKqteALxJJb5540KEV/alCgtQntkyvSBDcvSa3xa5Rg4rmBbLAxqtO3pQjI lpGyOnZ7y+78365TIet/IfQSUFd5EvYPiivvc47gvuYWDQkTpi3VIq6Oxn4QbkN7aTo0 Fv7XTGWtgp7ihZ0RC4qg3cp8brgTFLXVRJsvjinPRUPc7VjcsVu4G+kSOOdwia9rHylk 6GGHz2tJyVzkSa0Q8ErmoQ0yYF1FAFkItR5bEcS8liPPSVartfCqoHP7vikJExHcKKRH sbKmRXAq+QIrpvrlicVaa8P3fFqZGY1/IZEUPkca9z3P6o3z1br3HkmUamAx992mMBPt CqlA== X-Gm-Message-State: AC+VfDxMYpjatdQeHEXNV+gH5mUqy0uJ8ncF5EI0zZgB/0EjKgYCWTAk uQlSoa6qKrHYV1bGcb4efL0= X-Google-Smtp-Source: ACHHUZ6tjv3xr59m+gYz8OVXnm1xmB74cCrv0sXwMg/z6UFWTLrHE2IEMmOXvM6S6QfjlV+oyShcwQ== X-Received: by 2002:a05:600c:295:b0:3f6:af2:8471 with SMTP id 21-20020a05600c029500b003f60af28471mr14466195wmk.26.1686847470651; Thu, 15 Jun 2023 09:44:30 -0700 (PDT) Received: from localhost (fwdproxy-cln-017.fbsv.net. [2a03:2880:31ff:11::face:b00c]) by smtp.gmail.com with ESMTPSA id u2-20020a5d4342000000b0030e5c8d55f2sm21453538wrr.6.2023.06.15.09.44.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 09:44:29 -0700 (PDT) From: Breno Leitao To: pawan.kumar.gupta@linux.intel.com, jpoimboe@kernel.org, peterz@infradead.org, tglx@linutronix.de, bp@alien8.de, Ingo Molnar , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: leit@fb.com, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] x86/bugs: Create an option to disable MMIO vulnerability Date: Thu, 15 Jun 2023 09:44:14 -0700 Message-Id: <20230615164417.3588162-4-leitao@debian.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230615164417.3588162-1-leitao@debian.org> References: <20230615164417.3588162-1-leitao@debian.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There is no way to disable MMIO Stale data mitigation today at compilation time. These mitigations are enabled even if CONFIG_SPECULATION_MITIGATIONS is unset. Create a new KCONFIG option that allow MMIO mitigation to be disabled in compilation time. Signed-off-by: Breno Leitao --- arch/x86/Kconfig | 10 ++++++++++ arch/x86/kernel/cpu/bugs.c | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 140af3b30c45..ba64f7c9b08d 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2670,6 +2670,16 @@ config MITIGATE_TAA which is available in various CPU internal buffers by using asynchronous aborts within an Intel TSX transactional region. =20 +config MITIGATE_MMIO_STALE_DATA + bool "Mitigate MMIO Stale Data hardware bug" + depends on CPU_SUP_INTEL && X86_64 + default y + help + Enable mitigation for MMIO Stale Data hardware bugs. Processor MMIO + Stale Data Vulnerabilities are a class of memory-mapped I/O (MMIO) + vulnerabilities that can expose data. The vulnerabilities require the + attacker to have access to MMIO. + endif =20 config ARCH_HAS_ADD_PAGES diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 3615bda9573f..b5c171feb05e 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -439,6 +439,7 @@ enum mmio_mitigations { /* Default mitigation for Processor MMIO Stale Data vulnerabilities */ static enum mmio_mitigations mmio_mitigation __ro_after_init =3D MMIO_MITI= GATION_VERW; static bool mmio_nosmt __ro_after_init =3D false; +#define MMIO_WARN_MSG "WARNING: MMIO Stale Data speculative mitigation dis= abled!\n" =20 static const char * const mmio_strings[] =3D { [MMIO_MITIGATION_OFF] =3D "Vulnerable", @@ -451,12 +452,17 @@ static void __init mmio_select_mitigation(void) u64 ia32_cap; =20 if (!boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA) || - boot_cpu_has_bug(X86_BUG_MMIO_UNKNOWN) || - cpu_mitigations_off()) { + boot_cpu_has_bug(X86_BUG_MMIO_UNKNOWN)) { mmio_mitigation =3D MMIO_MITIGATION_OFF; return; } =20 + if (cpu_mitigations_off() || !IS_ENABLED(CONFIG_MITIGATE_MDS)) { + mmio_mitigation =3D MMIO_MITIGATION_OFF; + pr_err(MMIO_WARN_MSG); + return; + } + if (mmio_mitigation =3D=3D MMIO_MITIGATION_OFF) return; =20 --=20 2.34.1