Date: Tue, 18 Jul 2000 23:30:28 -0700 (PDT) From: brad@kazrak.com To: FreeBSD-gnats-submit@freebsd.org Subject: kern/20029: linprocfs does not accurately emulate Linux 2.2.x /proc/cpuinfo Message-ID: <20000719063028.8E88E433@pegasus.kazrak.com>
next in thread | raw e-mail | index | archive | help
>Number: 20029
>Category: kern
>Synopsis: linprocfs does not accurately emulate Linux 2.2.x /proc/cpuinfo
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Tue Jul 18 23:40:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: R Bradford Jones
>Release: FreeBSD 4.0-STABLE i386
>Organization:
Kazrak Enterprises
>Environment:
4.0-STABLE as of 20000709
>Description:
linprocfs does not accurately emulate the Linux 2.2.x /proc/cpuinfo file.
Specifically, it uses "cpu : 686" where Linux uses "cpu family : 6",
and does not include flags or clock speed.
>How-To-Repeat:
Compare the output of /compat/linux/proc/cpuinfo to real Linux /proc/cpuinfo:
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 7
model name : Pentium III (Katmai)
stepping : 2
cpu MHz : 448.975
cache size : 512 KB
fdiv_bug : no
hlt_bug : no
sep_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 3
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov
pat pse36 pn mmx fxsr xmm
bogomips : 894.57
>Fix:
The following patch will fix 'cpu family' lines and add 'flags' and 'cpu
MHz' lines.
*** /home/brad/linprocfs_misc.c Tue Jul 18 23:20:07 2000
--- linprocfs_misc.c Tue Jul 18 22:50:25 2000
***************
*** 59,64 ****
--- 59,66 ----
#include <machine/md_var.h>
#include <machine/cputypes.h>
+ #include <machine/clock.h>
+ #include <machine/md_var.h>
struct proc;
***************
*** 159,202 ****
int xlen;
int error;
char psbuf[512]; /* XXX - conservative */
! char *class;
#if 0
extern char *cpu_model; /* Yuck */
#endif
if (uio->uio_rw != UIO_READ)
return (EOPNOTSUPP);
switch (cpu_class) {
case CPUCLASS_286:
! class = "286";
break;
case CPUCLASS_386:
! class = "386";
break;
case CPUCLASS_486:
! class = "486";
break;
case CPUCLASS_586:
! class = "586";
break;
case CPUCLASS_686:
! class = "686";
break;
default:
! class = "unknown";
break;
}
ps = psbuf;
ps += sprintf(ps,
"processor : %d\n"
- "cpu : %.3s\n"
- "model : %.20s\n"
"vendor_id : %.20s\n"
"stepping : %d\n",
! 0, class, "unknown", cpu_vendor, cpu_id);
xlen = ps - psbuf;
xlen -= uio->uio_offset;
ps = psbuf + uio->uio_offset;
--- 161,239 ----
int xlen;
int error;
char psbuf[512]; /* XXX - conservative */
! int class;
! int i;
#if 0
extern char *cpu_model; /* Yuck */
#endif
+ /* We default the flags to include all non-conflicting flags,
+ and the Intel versions of conflicting flags. Note the space
+ before each name; that is significant, and should be
+ preserved. */
+
+ static char *flags[] = {" fpu", " vme", " de", " pse", " tsc",
+ " msr", " pae", " mce", " cx8", " apic",
+ " sep", " sep", " mtrr", " pge", " mca",
+ " cmov", " pat", " pse36", " pn", " b19",
+ " b20", " b21", " mmxext", " mmx", " fxsr",
+ " xmm", " b26", " b27", " b28", " b29",
+ " 3dnowext", " 3dnow"};
if (uio->uio_rw != UIO_READ)
return (EOPNOTSUPP);
switch (cpu_class) {
case CPUCLASS_286:
! class = 2;
break;
case CPUCLASS_386:
! class = 3;
break;
case CPUCLASS_486:
! class = 4;
break;
case CPUCLASS_586:
! class = 5;
break;
case CPUCLASS_686:
! class = 6;
break;
default:
! class = 0;
break;
}
ps = psbuf;
ps += sprintf(ps,
"processor : %d\n"
"vendor_id : %.20s\n"
+ "cpu family : %d\n"
+ "model : %d\n"
"stepping : %d\n",
! 0, cpu_vendor, class, cpu, cpu_id & 0xf);
+ ps += sprintf(ps,
+ "flags :");
+
+ if (!strcmp(cpu_vendor, "AuthenticAMD") && (class < 6)) {
+ flags[16] = " fcmov";
+ } else if (!strcmp(cpu_vendor, "CyrixInstead")) {
+ flags[24] = " cxmmx";
+ }
+
+ for (i = 0; i < 32; i++) {
+ if (cpu_feature & (1 << i)) {
+ ps += sprintf(ps, flags[i]);
+ }
+ }
+ if (class >= 5) {
+ ps += sprintf(ps, "\ncpu MHz : %d.%02d\n",
+ (tsc_freq + 4999) / 1000000,
+ ((tsc_freq + 4999) / 10000) % 100);
+ } else {
+ ps += sprintf(ps, "\n");
+ }
+
xlen = ps - psbuf;
xlen -= uio->uio_offset;
ps = psbuf + uio->uio_offset;
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000719063028.8E88E433>
