Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Feb 2004 21:15:23 +0000
From:      Bruce Cran <bruce@cran.org.uk>
To:        freebsd-current@freebsd.org
Subject:   64-bit values in sysctl
Message-ID:  <20040225211523.GA3031@box1.cran>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040225211523.GA3031>