From cfd571cfc2e35f8e6736eef9a26be673e5b73843 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sun, 2 Feb 2025 15:56:09 +0300 Subject: [PATCH 1/7] Re-enable TSC on ryzen CPUs --- rpcs3/util/sysinfo.cpp | 50 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/rpcs3/util/sysinfo.cpp b/rpcs3/util/sysinfo.cpp index 8c958e389d..270e45ae46 100755 --- a/rpcs3/util/sysinfo.cpp +++ b/rpcs3/util/sysinfo.cpp @@ -23,6 +23,7 @@ #endif #include +#include #include "util/asm.hpp" #include "util/fence.hpp" @@ -776,11 +777,6 @@ static const bool s_tsc_freq_evaluated = []() -> bool return 0; } - if (utils::get_cpu_brand().find("Ryzen") != umax) - { - return 0; - } - #ifdef _WIN32 LARGE_INTEGER freq; if (!QueryPerformanceFrequency(&freq)) @@ -795,6 +791,50 @@ static const bool s_tsc_freq_evaluated = []() -> bool const ullong timer_freq = freq.QuadPart; #else + +#ifdef __linux__ + // Check if system clocksource is TSC. If the kernel trusts the TSC, we should too. + // Some Ryzen laptops have broken firmware when running linux (requires a kernel patch). This is also a problem on some older intel CPUs. + const char* clocksource_file = "/sys/devices/system/clocksource/clocksource0/available_clocksource"; + if (!fs::is_file(clocksource_file)) + { + // OS doesn't support sysfs? + printf("[TSC calibration] Could not determine available clock sources. Disabling TSC.\n"); + return 0; + } + + std::string clock_sources; + std::ifstream file(clocksource_file); + std::getline(file, clock_sources); + + if (file.fail()) + { + printf("[TSC calibration] Could not read the available clock sources on this system. Disabling TSC.\n"); + return 0; + } + + printf("[TSC calibration] Available clock sources: '%s'\n", clock_sources.c_str()); + + // Check if the Kernel has blacklisted the TSC + const auto available_clocks = fmt::split(clock_sources, { " " }); + const bool tsc_reliable = std::find(available_clocks.begin(), available_clocks.end(), "tsc") != available_clocks.end(); + + if (!tsc_reliable) + { + printf("[TSC calibration] TSC is not a supported clock source on this system.\n"); + return 0; + } + + printf("[TSC calibration] Kernel reports the TSC is reliable.\n"); +#else + if (utils::get_cpu_brand().find("Ryzen") != umax) + { + // MacOS is arm-native these days and I don't know much about BSD to fix this if it's an issue. (kd-11) + // Having this check only for Ryzen is broken behavior - other CPUs can also have this problem. + return 0; + } +#endif + constexpr ullong timer_freq = 1'000'000'000; #endif From 3187dc816e375cec2cb1bca0dfca98e55f41cc5c Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 2 Feb 2025 16:07:19 +0100 Subject: [PATCH 2/7] Fix some warnings --- Utilities/JITLLVM.cpp | 2 +- rpcs3/Crypto/aes.cpp | 3 +++ rpcs3/Emu/Cell/PPUAnalyser.cpp | 2 +- rpcs3/Emu/Cell/PPUThread.cpp | 2 +- rpcs3/Emu/Cell/PPUTranslator.cpp | 2 -- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Utilities/JITLLVM.cpp b/Utilities/JITLLVM.cpp index 0f8d869f48..b6061634bb 100644 --- a/Utilities/JITLLVM.cpp +++ b/Utilities/JITLLVM.cpp @@ -636,7 +636,7 @@ jit_compiler::jit_compiler(const std::unordered_map& _link, co : m_context(new llvm::LLVMContext) , m_cpu(cpu(_cpu)) { - static const bool s_install_llvm_error_handler = []() + [[maybe_unused]] static const bool s_install_llvm_error_handler = []() { llvm::remove_fatal_error_handler(); llvm::install_fatal_error_handler([](void*, const char* msg, bool) diff --git a/rpcs3/Crypto/aes.cpp b/rpcs3/Crypto/aes.cpp index 034e192e2c..61ae4ae85c 100644 --- a/rpcs3/Crypto/aes.cpp +++ b/rpcs3/Crypto/aes.cpp @@ -598,7 +598,10 @@ int aes_setkey_dec( aes_context *ctx, const unsigned char *key, unsigned int key *RK++ = *SK++; *RK++ = *SK++; +#if defined(__SSE2__) || defined(_M_X64) done: +#endif + // Wipe the stack buffer clean std::fill_n(reinterpret_cast(&cty), sizeof(cty), 0); diff --git a/rpcs3/Emu/Cell/PPUAnalyser.cpp b/rpcs3/Emu/Cell/PPUAnalyser.cpp index 836897eae6..1a05e7e1e2 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.cpp +++ b/rpcs3/Emu/Cell/PPUAnalyser.cpp @@ -807,7 +807,7 @@ bool ppu_module::analyse(u32 lib_toc, u32 entry, const u32 sec_end, con ppu_log.trace("OPD: [0x%x] 0x%x (TOC=0x%x)", _ptr, addr, toc); TOCs.emplace(toc); - auto& func = add_func(addr, addr_heap.count(_ptr.addr()) ? toc : 0, 0); + add_func(addr, addr_heap.count(_ptr.addr()) ? toc : 0, 0); known_functions.emplace(addr); } } diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index d1d4ca3fc7..17ceeb6804 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -4910,7 +4910,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only, u64 file_s usz code_size_until_jump = umax; - auto func = build_function_asm(name, [&](native_asm& c, auto& args) + auto func = build_function_asm(name, [&](native_asm& c, auto& /*args*/) { #if defined(ARCH_X64) c.mov(x86::edx, func_addr - seg0); // Load PC diff --git a/rpcs3/Emu/Cell/PPUTranslator.cpp b/rpcs3/Emu/Cell/PPUTranslator.cpp index 9bda76ac87..3abf91c8c1 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.cpp +++ b/rpcs3/Emu/Cell/PPUTranslator.cpp @@ -358,8 +358,6 @@ Function* PPUTranslator::GetSymbolResolver(const ppu_module& info) // Create an array of function pointers std::vector functions; - const auto [min_addr, max_addr] = *ensure(info.jit_bounds); - for (const auto& f : info.get_funcs(false, true)) { if (!f.size) From 92979d23cfa72ff7566cc74492e4c5d29f400854 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 2 Feb 2025 16:07:39 +0100 Subject: [PATCH 3/7] Set openal system version to 10.0 --- 3rdparty/OpenAL/openal-soft.vcxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/3rdparty/OpenAL/openal-soft.vcxproj b/3rdparty/OpenAL/openal-soft.vcxproj index 37945fdf01..d309093527 100644 --- a/3rdparty/OpenAL/openal-soft.vcxproj +++ b/3rdparty/OpenAL/openal-soft.vcxproj @@ -49,11 +49,11 @@ call vsdevcmd.bat -arch=amd64 cd "$(SolutionDir)build\tmp\$(ProjectName)-$(Configuration)-$(Platform)" - cmake -G Ninja -DCMAKE_CXX_COMPILER="cl.exe" -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX="./Release" -DCMAKE_SYSTEM_VERSION=6.1 -DLIBTYPE=STATIC -DFORCE_STATIC_VCRT=true -DALSOFT_UTILS=false -DALSOFT_EXAMPLES=false -DALSOFT_INSTALL=false -DALSOFT_INSTALL_CONFIG=false -DALSOFT_INSTALL_HRTF_DATA=false -DALSOFT_INSTALL_AMBDEC_PRESETS=false -DALSOFT_INSTALL_EXAMPLES=false -DALSOFT_INSTALL_UTILS=false "$(SolutionDir)3rdparty\OpenAL\openal-soft" + cmake -G Ninja -DCMAKE_CXX_COMPILER="cl.exe" -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX="./Release" -DCMAKE_SYSTEM_VERSION=10.0 -DLIBTYPE=STATIC -DFORCE_STATIC_VCRT=true -DALSOFT_UTILS=false -DALSOFT_EXAMPLES=false -DALSOFT_INSTALL=false -DALSOFT_INSTALL_CONFIG=false -DALSOFT_INSTALL_HRTF_DATA=false -DALSOFT_INSTALL_AMBDEC_PRESETS=false -DALSOFT_INSTALL_EXAMPLES=false -DALSOFT_INSTALL_UTILS=false "$(SolutionDir)3rdparty\OpenAL\openal-soft" call vsdevcmd.bat -arch=amd64 cd "$(SolutionDir)build\tmp\$(ProjectName)-$(Configuration)-$(Platform)" - cmake -G Ninja -DCMAKE_CXX_COMPILER="cl.exe" -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_INSTALL_PREFIX="./Debug" -DCMAKE_SYSTEM_VERSION=6.1 -DLIBTYPE=STATIC -DALSOFT_UTILS=false -DALSOFT_EXAMPLES=false -DALSOFT_INSTALL=false -DALSOFT_INSTALL_CONFIG=false -DALSOFT_INSTALL_HRTF_DATA=false -DALSOFT_INSTALL_AMBDEC_PRESETS=false -DALSOFT_INSTALL_EXAMPLES=false -DALSOFT_INSTALL_UTILS=false "$(SolutionDir)3rdparty\OpenAL\openal-soft" + cmake -G Ninja -DCMAKE_CXX_COMPILER="cl.exe" -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_INSTALL_PREFIX="./Debug" -DCMAKE_SYSTEM_VERSION=10.0 -DLIBTYPE=STATIC -DALSOFT_UTILS=false -DALSOFT_EXAMPLES=false -DALSOFT_INSTALL=false -DALSOFT_INSTALL_CONFIG=false -DALSOFT_INSTALL_HRTF_DATA=false -DALSOFT_INSTALL_AMBDEC_PRESETS=false -DALSOFT_INSTALL_EXAMPLES=false -DALSOFT_INSTALL_UTILS=false "$(SolutionDir)3rdparty\OpenAL\openal-soft" echo Copying.. From 0770c28207301430226eea6506a8dec54155e118 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 2 Feb 2025 16:07:58 +0100 Subject: [PATCH 4/7] Update libpng to 1.6.46 --- 3rdparty/libpng/libpng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/libpng/libpng b/3rdparty/libpng/libpng index 51f5bd68b9..0024abd279 160000 --- a/3rdparty/libpng/libpng +++ b/3rdparty/libpng/libpng @@ -1 +1 @@ -Subproject commit 51f5bd68b9b806d2c92b4318164d28b49357da31 +Subproject commit 0024abd279d3a06435c0309a3f4172eed7c7a19a From 35fbdd0bae39546478377abcc1da7444b90a0729 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 2 Feb 2025 16:08:12 +0100 Subject: [PATCH 5/7] Update FAudio to 25.02 --- 3rdparty/FAudio | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/FAudio b/3rdparty/FAudio index 707114aef2..af74e661c1 160000 --- a/3rdparty/FAudio +++ b/3rdparty/FAudio @@ -1 +1 @@ -Subproject commit 707114aef2907793644d4067a6e7b09b51502ca9 +Subproject commit af74e661c1bd8b105840d14485cc01d9c782b513 From 88776ceaa67b3c25a29a4a27c793cb00adf41017 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 2 Feb 2025 16:08:26 +0100 Subject: [PATCH 6/7] Update Fusion to 1.2.8 --- 3rdparty/fusion/fusion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/fusion/fusion b/3rdparty/fusion/fusion index fecf2f0af3..066d4a63b2 160000 --- a/3rdparty/fusion/fusion +++ b/3rdparty/fusion/fusion @@ -1 +1 @@ -Subproject commit fecf2f0af3bd23cbba553ceedc2bc6c1cd410fc1 +Subproject commit 066d4a63b2c714b20b0a8073a01fda7c5c6763f6 From 7ffbada7258bb22d7b338f2050d84c28309f1cac Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 2 Feb 2025 16:08:42 +0100 Subject: [PATCH 7/7] Update SDL to 2.30.12 --- 3rdparty/libsdl-org/SDL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/libsdl-org/SDL b/3rdparty/libsdl-org/SDL index fa24d868ac..8236e01a9f 160000 --- a/3rdparty/libsdl-org/SDL +++ b/3rdparty/libsdl-org/SDL @@ -1 +1 @@ -Subproject commit fa24d868ac2f8fd558e4e914c9863411245db8fd +Subproject commit 8236e01a9f758d15927624925c6043f84d8a261f