[patch] export CPU physical and virtual address sizes in sysctl oids using do_cpuid
Sofian Brabez
sbz at FreeBSD.org
Sun May 5 23:37:05 UTC 2013
This patch uses do_cpuid function to fetch CPU Physical and Virtual address sizes
and adds 2 new sysctl machine dependant OIDs (machdep.cpu_physical_address_bits
and machdep.cpu_virtual_address_bits).
In order to retrieve the information, it calls do_cpuid by setting eax register
to 0x80000008 value like referenced in chapter 5.2.7 in the CPUID specification [1]
Apple, Inc. in xnu kernel do the same thing but they created a specific node called
'machdep.cpu' to store CPU Vendor information, the sysctls are
machdep.cpu.address_bits.virtual and machdep.cpu.address_bits.virtual.
I really would like to see this patch in our operating system because it's a
valuable information nowdays and should be provided like others.
Thus, I would like advices to see if before to be imported it needs modification
to fit like Apple (i.e using a new sysctl node) or stay like that.
Also, I profited of this changes to patch sys/modules/linprocfs in order to
display the address sizes values in the output of /usr/compat/linux/proc/cpuinfo
like it's done in Linux procfs [2].
I filled a pr referenced as amd64/178357 [3]. My kernel was rebuilt without any
problems in r250287 and it works as expected.
You could find details here [4] and patch in attachment.
Regards
[1] http://www.intel.com/content/dam/www/public/us/en/documents/application-notes/processor-identification-cpuid-instruction-note.pdf
[2] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/cpu/proc.c#n113
[3] http://www.freebsd.org/cgi/query-pr.cgi?pr=178357
[4] http://people.freebsd.org/~sbz/cpu/
--
Sofian Brabez
-------------- next part --------------
A non-text attachment was scrubbed...
Name: address_sizes.diff
Type: text/x-diff
Size: 2915 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20130506/99011115/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20130506/99011115/attachment.sig>
More information about the freebsd-hackers
mailing list