Bug 85656

Summary: [i386] [patch] expose more i386 specific CPU information
Product: Base System Reporter: Ben Thomas <bthomas>
Component: i386Assignee: freebsd-i386 (Nobody) <i386>
Status: Closed Overcome By Events    
Severity: Affects Only Me CC: gonzo
Priority: Normal    
Version: 5.4-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
initcpu.c-DIFF
none
identcpu.c-DIFF
none
specialreg.h-DIFF none

Description Ben Thomas 2005-09-02 19:00:37 UTC
Add some i386 specific information and make a lot of it available
to user programs via sysctl.  We've had this change in our kernels
for some time.  Some appears to have moved into the 6.0 code, but
for what it's worth, here's the entire suggested change:

- add cpu extended features capture and output during boot

- add sysctls to expose a number of i386 information:
      hw.cpu_type
      hw.cpu_feature
      hw.cpu_efeature
      hw.cpu_high
      hw.cpu_id
      hw.cpu_procinfo
      hw.cpu_brand

This patch is against the 5_4_0_RELEASE code

Fix: --- /usr/src.original/sys/i386/include/md_var.h	Thu Jun 10 16:30:58 2004
+++ /usr/src/sys/i386/include/md_var.h	Fri Aug 12 17:32:43 2005
@@ -46,6 +46,7 @@
 extern	int	busdma_swi_pending;
 extern	u_int	cpu_exthigh;
 extern	u_int	cpu_feature;
+extern	u_int	cpu_efeature;
 extern	u_int	cpu_fxsr;
 extern	u_int	cpu_high;
 extern	u_int	cpu_id;
--- md_var.h-DIFF ends here ---

--- /usr/src.original/sys/i386/i386/locore.s	Fri Feb  4 20:01:40 2005
+++ /usr/src/sys/i386/i386/locore.s	Fri Aug 12 17:32:52 2005
@@ -680,6 +680,7 @@
 	cpuid					# cpuid 1
 	movl	%eax,R(cpu_id)			# store cpu_id
 	movl	%ebx,R(cpu_procinfo)		# store cpu_procinfo
+	movl	%ecx,R(cpu_efeature)		# store cpu extended features
 	movl	%edx,R(cpu_feature)		# store cpu_feature
 	rorl	$8,%eax				# extract family type
 	andl	$15,%eax
--- locore.s-DIFF ends here ---
Comment 1 Björn König 2005-09-02 20:12:10 UTC
Ben Thomas wrote:

> - add sysctls to expose a number of i386 information:
>       hw.cpu_type
>       hw.cpu_feature
>       hw.cpu_efeature
>       hw.cpu_high
>       hw.cpu_id
>       hw.cpu_procinfo
>       hw.cpu_brand
> 
> [...]

It might be better to use

       hw.cpu.type
       hw.cpu.feature
       hw.cpu.efeature
       [...]

instead. This allows you to see all CPU information by calling 'sysctl 
hw.cpu'. A lot of oids in the format parent.foo_bar has been converted 
to parent.foo.bar in past.

Regards Björn
Comment 2 Ben Thomas 2005-09-02 20:22:39 UTC
I completely agree.  It was a quick hack that we use locally and
could easily be improved.   I considered changing this before
I submitted the pr, but since it's taken me over a year to get
around to submitting it at all, I decided to submit the current
code that I use and not the better version.

Thanks,
-b


Björn König wrote:
> Ben Thomas wrote:
> 
>> - add sysctls to expose a number of i386 information:
>>       hw.cpu_type
>>       hw.cpu_feature
>>       hw.cpu_efeature
>>       hw.cpu_high
>>       hw.cpu_id
>>       hw.cpu_procinfo
>>       hw.cpu_brand
>>
>> [...]
> 
> 
> It might be better to use
> 
>       hw.cpu.type
>       hw.cpu.feature
>       hw.cpu.efeature
>       [...]
> 
> instead. This allows you to see all CPU information by calling 'sysctl 
> hw.cpu'. A lot of oids in the format parent.foo_bar has been converted 
> to parent.foo.bar in past.
> 
> Regards Björn
> 


-- 
------------------------------------------------------------------------
Ben Thomas                                         Virtual Iron Software
bthomas@virtualiron.com                            43 Nagog Park
978-849-1214                                       Acton, MA 01720
Comment 3 Remko Lodder freebsd_committer freebsd_triage 2011-03-23 07:21:54 UTC
State Changed
From-To: open->feedback

Hello, 

Is this still applicable?
Comment 4 Remko Lodder freebsd_committer freebsd_triage 2011-03-30 07:09:19 UTC
Responsible Changed
From-To: freebsd-i386->jhb

Hi John, another one I would like to ask you to have a look at.
Comment 5 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:30 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 6 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2019-01-24 07:21:01 UTC
I believe cpucontrol(8) can provide access to some of the information mentioned in this PR. Closing as OBE. Feel free to reopen if there is interest in adding suggested functionality.