summaryrefslogtreecommitdiff
path: root/src/common/x64/cpu_detect.cpp
diff options
context:
space:
mode:
authorGravatar Marshall Mohror2022-07-06 13:00:00 -0500
committerGravatar Marshall Mohror2022-07-06 13:00:00 -0500
commite71d457af923f373505729fe5a335e6768f6144a (patch)
tree535a7a3ddd28e3a98f5984e0730277cd74850cea /src/common/x64/cpu_detect.cpp
parentcommon/x64: Use TSC clock rate from CPUID when available (diff)
downloadyuzu-e71d457af923f373505729fe5a335e6768f6144a.tar.gz
yuzu-e71d457af923f373505729fe5a335e6768f6144a.tar.xz
yuzu-e71d457af923f373505729fe5a335e6768f6144a.zip
guard against div-by-zero
Diffstat (limited to 'src/common/x64/cpu_detect.cpp')
-rw-r--r--src/common/x64/cpu_detect.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/common/x64/cpu_detect.cpp b/src/common/x64/cpu_detect.cpp
index 4230b2da6..1a27532d4 100644
--- a/src/common/x64/cpu_detect.cpp
+++ b/src/common/x64/cpu_detect.cpp
@@ -170,8 +170,11 @@ static CPUCaps Detect() {
170 // The CPU model can be detected to use the values from turbostat 170 // The CPU model can be detected to use the values from turbostat
171 // https://github.com/torvalds/linux/blob/master/tools/power/x86/turbostat/turbostat.c#L5569 171 // https://github.com/torvalds/linux/blob/master/tools/power/x86/turbostat/turbostat.c#L5569
172 // but it's easier to just estimate the TSC tick rate for these cases. 172 // but it's easier to just estimate the TSC tick rate for these cases.
173 caps.tsc_frequency = static_cast<u64>(caps.crystal_frequency) * 173 if (caps.tsc_crystal_ratio_denominator) {
174 caps.tsc_crystal_ratio_numerator / caps.tsc_crystal_ratio_denominator; 174 caps.tsc_frequency = static_cast<u64>(caps.crystal_frequency) *
175 caps.tsc_crystal_ratio_numerator /
176 caps.tsc_crystal_ratio_denominator;
177 }
175 } 178 }
176 179
177 if (max_std_fn >= 0x16) { 180 if (max_std_fn >= 0x16) {