64-bit values in sysctl

From: Bruce Cran <bruce_at_cran.org.uk>
Date: Wed, 25 Feb 2004 21:15:23 +0000
After investigating whether FreeBSD will be able to show the correct speed of a
4.3GHz CPU (http://www.theinquirer.net/?article=14319), I found that the sysctl
infrastructure doesn't currently have support for 64-bit integers, on a 32-bit 
platform at least.   The only type pertaining to 64-bits is CTLTYPE_QUAD, but since
there's no corresponding sysctl_handle_quad, it's still handled as a 32-bit integer.
I found PR kern/39681 which explains that it's apparently not as simple as adding a
sysctl_handle_quad function.  With CPUs getting faster and a few people adding more
then 4GB RAM to their machines, there's a need for some sort of solution IMO.  
In addition, the only place a CTLTYPE_QUAD is used is in sys/i386/i386/tsc.c, and
then it mixed CTLTYPE_QUAD and sizeof(u_int).   I've also noticed that the 
machdep.[i8254_freq, tsc_freq, acpi_timer_freq] are all writable, whereas I think they
should probably be read-only, as should kern.bootfile.   One last thing I've noticed 
during my look into the kernel code is that a lot of the sysctls are defined as signed
integers - wouldn't it be better if these were converted to be unsigned, so that it
would be impossible for the writable ones to be set to negative values and thus avoid
possible foot-shooting?  I already have some diffs, so I could put together a PR if
some of these changes (such as making some sysctls read-only) are valid.

--
Bruce Cran
Received on Wed Feb 25 2004 - 12:12:49 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:44 UTC