// SPDX-License-Identifier: GPL-2.0 /* * Intel Transactional Synchronization Extensions (TSX) control. * * Copyright (C) 2019-2021 Intel Corporation * * Author: * Pawan Gupta <[email protected]> */ #include <linux/cpufeature.h> #include <asm/cmdline.h> #include <asm/cpu.h> #include "cpu.h" #undef pr_fmt #define pr_fmt(fmt) … enum tsx_ctrl_states tsx_ctrl_state __ro_after_init = …; static void tsx_disable(void) { … } static void tsx_enable(void) { … } static enum tsx_ctrl_states x86_get_tsx_auto_mode(void) { … } /* * Disabling TSX is not a trivial business. * * First of all, there's a CPUID bit: X86_FEATURE_RTM_ALWAYS_ABORT * which says that TSX is practically disabled (all transactions are * aborted by default). When that bit is set, the kernel unconditionally * disables TSX. * * In order to do that, however, it needs to dance a bit: * * 1. The first method to disable it is through MSR_TSX_FORCE_ABORT and * the MSR is present only when *two* CPUID bits are set: * * - X86_FEATURE_RTM_ALWAYS_ABORT * - X86_FEATURE_TSX_FORCE_ABORT * * 2. The second method is for CPUs which do not have the above-mentioned * MSR: those use a different MSR - MSR_IA32_TSX_CTRL and disable TSX * through that one. Those CPUs can also have the initially mentioned * CPUID bit X86_FEATURE_RTM_ALWAYS_ABORT set and for those the same strategy * applies: TSX gets disabled unconditionally. * * When either of the two methods are present, the kernel disables TSX and * clears the respective RTM and HLE feature flags. * * An additional twist in the whole thing presents late microcode loading * which, when done, may cause for the X86_FEATURE_RTM_ALWAYS_ABORT CPUID * bit to be set after the update. * * A subsequent hotplug operation on any logical CPU except the BSP will * cause for the supported CPUID feature bits to get re-detected and, if * RTM and HLE get cleared all of a sudden, but, userspace did consult * them before the update, then funny explosions will happen. Long story * short: the kernel doesn't modify CPUID feature bits after booting. * * That's why, this function's call in init_intel() doesn't clear the * feature flags. */ static void tsx_clear_cpuid(void) { … } /* * Disable TSX development mode * * When the microcode released in Feb 2022 is applied, TSX will be disabled by * default on some processors. MSR 0x122 (TSX_CTRL) and MSR 0x123 * (IA32_MCU_OPT_CTRL) can be used to re-enable TSX for development, doing so is * not recommended for production deployments. In particular, applying MD_CLEAR * flows for mitigation of the Intel TSX Asynchronous Abort (TAA) transient * execution attack may not be effective on these processors when Intel TSX is * enabled with updated microcode. */ static void tsx_dev_mode_disable(void) { … } void __init tsx_init(void) { … } void tsx_ap_init(void) { … }