Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F150398829
D56056.id174321.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
761 B
Referenced Files
None
Subscribers
None
D56056.id174321.diff
View Options
diff --git a/sys/x86/x86/cpu_machdep.c b/sys/x86/x86/cpu_machdep.c
--- a/sys/x86/x86/cpu_machdep.c
+++ b/sys/x86/x86/cpu_machdep.c
@@ -425,6 +425,7 @@
uint64_t tsc1, tsc2;
uint64_t acnt, mcnt, perf;
register_t reg;
+ int error = 0;
if (pcpu_find(cpu_id) == NULL || rate == NULL)
return (EINVAL);
@@ -460,6 +461,11 @@
acnt = rdmsr(MSR_APERF);
tsc2 = rdtsc();
intr_restore(reg);
+ if (mcnt == 0) {
+ tsc_perf_stat = 0;
+ error = EOPNOTSUPP;
+ goto err;
+ }
perf = 1000 * acnt / mcnt;
*rate = (tsc2 - tsc1) * perf;
} else {
@@ -470,6 +476,7 @@
*rate = (tsc2 - tsc1) * 1000;
}
+err:
#ifdef SMP
if (smp_cpus > 1) {
thread_lock(curthread);
@@ -478,7 +485,7 @@
}
#endif
- return (0);
+ return (error);
}
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 1, 9:29 PM (10 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30429677
Default Alt Text
D56056.id174321.diff (761 B)
Attached To
Mode
D56056: x86: Guard clock frequency against a divide by 0
Attached
Detach File
Event Timeline
Log In to Comment