From pavel@SLAC.Stanford.EDU  Fri Mar  6 09:17:44 1998
Received: from serv05.slac.stanford.edu (SERV05.SLAC.Stanford.EDU [134.79.16.135])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA18290
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 6 Mar 1998 09:17:44 -0800 (PST)
          (envelope-from pavel@SLAC.Stanford.EDU)
Received: from mailbox.SLAC.Stanford.EDU (root@[134.79.18.29])
 by SERV05.SLAC.STANFORD.EDU (PMDF V5.1-10 #23033)
 with ESMTP id <01IUCAAHQVDO002WA5@SERV05.SLAC.STANFORD.EDU> for
 FreeBSD-gnats-submit@freebsd.org; Fri, 6 Mar 1998 09:17:43 PST
Received: from mach1.slac.stanford.edu
 (MACH1.SLAC.Stanford.EDU [134.79.128.63]) by mailbox.SLAC.Stanford.EDU
 (8.8.5/8.6.11) with ESMTP id JAA03669 for <FreeBSD-gnats-submit@freebsd.org>;
 Fri, 06 Mar 1998 09:17:41 -0800 (PST)
Message-Id: <199803061717.JAA03669@mailbox.SLAC.Stanford.EDU>
Date: Fri, 06 Mar 1998 09:17:41 -0800
From: Tom Pavel <pavel@SLAC.Stanford.EDU>
Reply-To: pavel@SLAC.Stanford.EDU
To: FreeBSD-gnats-submit@freebsd.org
Subject: perfmon kernel code should check for non-Intel CPUs
X-Send-Pr-Version: 3.2

>Number:         5932
>Category:       i386
>Synopsis:       perfmon kernel code should check for non-Intel CPUs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar  6 09:20:01 PST 1998
>Closed-Date:    Fri Aug 15 22:26:44 PDT 2003
>Last-Modified:  Fri Aug 15 22:26:44 PDT 2003
>Originator:     Tom Pavel
>Release:        FreeBSD 2.2.5-STABLE i386
>Organization:
Stanford Linear Accelerator Center
>Environment:


>Description:

Before I researched the fact that AMD does not actually implement any
of the msr 0x11 performance counters in the K6 that Intel does in the
Pentium and PPro, I thought I would try out the perfmon program in
/usr/share/examples/perfmon on my K6 machine.  This brought my machine
to an immediate halt.  I figured it out soon enough, but this case
should probably be caught in the perfmon code...


>How-To-Repeat:

Do any of the PMIO ioctl() calls on /dev/perfmon on an AMD K6 machine.
 

>Fix:
	
I think you just need to check that the CPU is actually an Intel one,
rather than checking for the generic 586/686 cpu_class.  Here is a
possible fix:

bozon[111]% diff -c /usr/src/sys/i386/i386/perfmon.c-ORIG  perfmon.c
*** /usr/src/sys/i386/i386/perfmon.c-ORIG       Thu Oct 10 03:18:48 1996
--- perfmon.c   Thu Mar  5 23:34:38 1998
***************
*** 38,43 ****
--- 38,44 ----
  
  #include <machine/cpu.h>
  #include <machine/cputypes.h>
+ #include <machine/md_var.h>
  #include <machine/clock.h>
  #include <machine/perfmon.h>
  
***************
*** 57,62 ****
--- 58,71 ----
  void
  perfmon_init(void)
  {
+       /* Unfortunately, all of the perfmon registers only exist on
+        * "GenuineIntel" Pentiums and P6's.  Trying to use msr 0x11 on my K6
+        * cause a seize-up... (pavel 5-Mar-1998)  */
+       if (strcmp(cpu_vendor, "GenuineIntel") != 0) {
+           perfmon_cpuok = 0;
+           return;
+       }
+ 
        switch(cpu_class) {
        case CPUCLASS_586:
                perfmon_cpuok = 1;


Tom Pavel

Stanford Linear Accelerator Center
pavel@slac.stanford.edu                 http://www.slac.stanford.edu/~pavel/
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: kris 
State-Changed-When: Thu May 24 12:55:10 PDT 2001 
State-Changed-Why:  
Is this still relevant? 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=5932 
State-Changed-From-To: analyzed->feedback 
State-Changed-By: johan 
State-Changed-When: Tue Aug 20 08:09:10 PDT 2002 
State-Changed-Why:  
As Kirs asked: Is this still relevant? 

Please followup by sending a mail to 
freebsd-gnats-submit@FreeBSD.org 
with the subject of this mail intact. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=5932 

From: "First Electronics Service" <firsttv@1sttv.omhcoxmail.com>
To: <freebsd-gnats-submit@FreeBSD.org>, <pavel@SLAC.Stanford.EDU>
Cc:  
Subject: Re: i386/5932: perfmon kernel code should check for non-Intel CPUs
Date: Sat, 21 Dec 2002 13:23:11 -0600

 You can change "if  (strcmp(cpu_vendor, "GenuineIntel") != 0)" to "if
 (strcmp(cpu_vendor,"GenuineIntel"))".
 
 Lucas
 
 
State-Changed-From-To: feedback->closed 
State-Changed-By: kris 
State-Changed-When: Fri Aug 15 22:26:34 PDT 2003 
State-Changed-Why:  
Feedback timeout 

http://www.freebsd.org/cgi/query-pr.cgi?pr=5932 
>Unformatted:
