From owner-freebsd-bugs@FreeBSD.ORG Thu Sep 4 10:10:11 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D75C916A4BF for ; Thu, 4 Sep 2003 10:10:11 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5D62D43FE0 for ; Thu, 4 Sep 2003 10:10:10 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h84HAAUp025144 for ; Thu, 4 Sep 2003 10:10:10 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h84HAA4r025143; Thu, 4 Sep 2003 10:10:10 -0700 (PDT) Resent-Date: Thu, 4 Sep 2003 10:10:10 -0700 (PDT) Resent-Message-Id: <200309041710.h84HAA4r025143@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Simon Barner Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3CF4616A4BF for ; Thu, 4 Sep 2003 10:07:03 -0700 (PDT) Received: from mailout.informatik.tu-muenchen.de (mailout.informatik.tu-muenchen.de [131.159.0.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9F4DF43FE5 for ; Thu, 4 Sep 2003 10:07:01 -0700 (PDT) (envelope-from barner@in.tum.de) Received: by zi025.glhnet.mhn.de (Postfix, from userid 1000) id CC47F38A92; Thu, 4 Sep 2003 19:06:59 +0200 (CEST) Message-Id: <20030904170659.CC47F38A92@zi025.glhnet.mhn.de> Date: Thu, 4 Sep 2003 19:06:59 +0200 (CEST) From: Simon Barner To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/56451: /compat/linux/proc/cpuinfo gives wrong CPU model X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Simon Barner List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Sep 2003 17:10:12 -0000 >Number: 56451 >Category: kern >Synopsis: /compat/linux/proc/cpuinfo gives wrong CPU model >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Sep 04 10:10:09 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Simon Barner >Release: FreeBSD 4.9-PRERELEASE i386 >Organization: >Environment: System: FreeBSD zi025.glhnet.mhn.de 4.9-PRERELEASE FreeBSD 4.9-PRERELEASE #0: Thu Sep 4 17:34:02 CEST 2003 simon@zi025.glhnet.mhn.de:/usr/src/sys/compile/KISTE i386 >From dmesg: [...] Timecounter "i8254" frequency 1193182 Hz CPU: AMD-K6(tm) 3D+ Processor (400.91-MHz 586-class CPU) Origin = "AuthenticAMD" Id = 0x591 Stepping = 1 Features=0x8021bf AMD Features=0x80000800 real memory = 201326592 (196608K bytes) avail memory = 192172032 (187668K bytes) Preloaded elf kernel "kernel" at 0xc03ab000. Preloaded userconfig_script "/boot/kernel.conf" at 0xc03ab09c. Preloaded elf module "bktr_mem.ko" at 0xc03ab0ec. Preloaded elf module "bktr.ko" at 0xc03ab18c. bktr_mem: memory holder loaded netsmb_dev: loaded K6-family MTRR support enabled (2 registers) md0: Malloc disk [...] >Description: I noticed that linprocfs' cpuinfo gives me the wrong CPU model (according to the cpu_id, which is 0x591, it should be 9 instead of 5). % cat /compat/linux/proc/cpuinfo processor : 0 vendor_id : AuthenticAMD cpu family : 5 model : 5 <--- wrong! stepping : 1 flags : fpu vme de pse tsc msr mce cx8 pge mmx cpu MHz : 400.91 bogomips : 400.91 I came across the problem when I tried the latest Mplayer pre-release, which is not yet in the ports. Its configure script uses FreeBSD's linprocfs in order to determine the CPU it is being compiled on. Of course, it would be an easy task to patch Mplayer's configure script, which as a fallback cpu identification program (which uses the CPUID assembler instruction and works correctly btw.). But, IMO this is a bug in linprocfs and should be fixed. >How-To-Repeat: cat /compat/linux/proc/cpuinfo on 586+ class CPUs. >Fix: Since I do not know a lot about i386-class processor detection, my suggestions might be wrong, but I'll send them anyway: As far as I can see, the problem is here: i386/linux/linprocfs/linprocfs_misc.c, l. 199 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\t: %d\n" "vendor_id\t: %.20s\n" "cpu family\t: %d\n" "model\t\t: %d\n" "stepping\t: %d\n", 0, cpu_vendor, class, cpu, cpu_id & 0xf); ps += sprintf(ps, "flags\t\t:"); Since pre-i586 CPUs do not support the CPUID instruction and cpu_id is not set on these CPUs (I am right here?), the information is collected from cpu_class, cpu (and cpu_id for the stepping). AFAIK, on a i586+class CPU, one could extract all the information from the cpu_id variable: 0, cpu_vendor, cpu_id & 0xf00, cpu_id & 0xf0, cpu_id & 0xf); I am not sure if there is a `model' specification for pre-i586 CPUs, and if there is one, how to extract it. Perhaps this here might be a solution, that keeps compatibility with older CPUs, but sets the model for newer ones correctly: 0, cpu_vendor, class, cpu_id & 0xf0, cpu_id & 0xf); >Release-Note: >Audit-Trail: >Unformatted: