SPU/SYSINFO: Disable TSX by default for TSX-FA cpus (#11105)

- Also detect the new RTM_ALWAYS_ABORT bit in cpuid
- This new bit indicates that RTM is disabled in the microcode
- On cpus with RTM_ALWAYS_ABORT TSX can be renabled by writing 0x4 to the msr 0x0000010F
This commit is contained in:
Whatcookie 2021-11-04 12:44:25 -04:00 committed by GitHub
parent 1a0392bf15
commit bf6044fced
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View File

@ -713,7 +713,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool
initalize_timebased_time();
// Set RTM usage
g_use_rtm = utils::has_rtm() && ((utils::has_mpx() && g_cfg.core.enable_TSX == tsx_usage::enabled) || g_cfg.core.enable_TSX == tsx_usage::forced);
g_use_rtm = utils::has_rtm() && (((utils::has_mpx() && !utils::has_tsx_force_abort()) && g_cfg.core.enable_TSX == tsx_usage::enabled) || g_cfg.core.enable_TSX == tsx_usage::forced);
if (!add_only)
{
@ -726,7 +726,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool
#endif
sys_log.notice("Used configuration:\n%s\n", g_cfg.to_string());
if (g_use_rtm && !utils::has_mpx())
if (g_use_rtm && (!utils::has_mpx() || utils::has_tsx_force_abort()))
{
sys_log.warning("TSX forced by User");
}

View File

@ -82,6 +82,12 @@ bool utils::has_tsx_force_abort()
return g_value;
}
bool utils::has_rtm_always_abort()
{
static const bool g_value = get_cpuid(0, 0)[0] >= 0x7 && (get_cpuid(7, 0)[3] & 0x800) == 0x800;
return g_value;
}
bool utils::has_mpx()
{
static const bool g_value = get_cpuid(0, 0)[0] >= 0x7 && (get_cpuid(7, 0)[1] & 0x4000) == 0x4000;
@ -230,11 +236,15 @@ std::string utils::get_system_info()
result += "-FA";
}
if (!has_mpx())
if (!has_mpx() || has_tsx_force_abort())
{
result += " disabled by default";
}
}
else if (has_rtm_always_abort())
{
result += " | TSX disabled via microcode";
}
return result;
}

View File

@ -21,6 +21,8 @@ namespace utils
bool has_tsx_force_abort();
bool has_rtm_always_abort();
bool has_mpx();
bool has_avx512();