From owner-freebsd-bugs@FreeBSD.ORG  Sat Jan 27 10:40:22 2007
Return-Path: <owner-freebsd-bugs@FreeBSD.ORG>
X-Original-To: freebsd-bugs@hub.freebsd.org
Delivered-To: freebsd-bugs@hub.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 7320416A4C9
	for <freebsd-bugs@hub.freebsd.org>;
	Sat, 27 Jan 2007 10:40:22 +0000 (UTC)
	(envelope-from gnats@FreeBSD.org)
Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40])
	by mx1.freebsd.org (Postfix) with ESMTP id 608D413C494
	for <freebsd-bugs@hub.freebsd.org>;
	Sat, 27 Jan 2007 10:40:18 +0000 (UTC)
	(envelope-from gnats@FreeBSD.org)
Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1])
	by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l0RAeIov020648
	for <freebsd-bugs@freefall.freebsd.org>; Sat, 27 Jan 2007 10:40:18 GMT
	(envelope-from gnats@freefall.freebsd.org)
Received: (from gnats@localhost)
	by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l0RAeIY3020646;
	Sat, 27 Jan 2007 10:40:18 GMT (envelope-from gnats)
Date: Sat, 27 Jan 2007 10:40:18 GMT
Message-Id: <200701271040.l0RAeIY3020646@freefall.freebsd.org>
To: freebsd-bugs@FreeBSD.org
From: "Internet Partners, Inc. Tech Support" <support@ipinc.net>
Cc: 
Subject: Re: kern/65627: [i386] [patch] store P3 serial number in sysctl
X-BeenThere: freebsd-bugs@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
Reply-To: "Internet Partners, Inc. Tech Support" <support@ipinc.net>
List-Id: Bug reports <freebsd-bugs.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-bugs>,
	<mailto:freebsd-bugs-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-bugs>
List-Post: <mailto:freebsd-bugs@freebsd.org>
List-Help: <mailto:freebsd-bugs-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-bugs>,
	<mailto:freebsd-bugs-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sat, 27 Jan 2007 10:40:22 -0000

The following reply was made to PR kern/65627; it has been noted by GNATS.

From: "Internet Partners, Inc. Tech Support" <support@ipinc.net>
To: <bug-followup@FreeBSD.org>, <gavin@ury.york.ac.uk>
Cc:  
Subject: Re: kern/65627: [i386] [patch] store P3 serial number in sysctl
Date: Sat, 27 Jan 2007 02:32:15 -0800

 Here is this patch updated for the FreeBSD 6.2-RELEASE kernel:
 
 
 diff -u sys/i386/i386/identcpu.c.orig sys/i386/i386/identcpu.c
 
 --- sys/i386/i386/identcpu.c.orig       Tue Aug  8 01:41:34 2006
 +++ sys/i386/i386/identcpu.c    Sat Jan 27 01:33:18 2007
 @@ -89,6 +89,13 @@
  SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,
      cpu_model, 0, "Machine model");
 
 +SYSCTL_NODE(_hw, OID_AUTO, cpu0, CTLFLAG_RD,
 +    0, "CPU 0 Information");
 +
 +static char cpu_serial[32];
 +SYSCTL_STRING(_hw_cpu0, OID_AUTO, serial, CTLFLAG_RD,
 +    cpu_serial, 0, "CPU serial number");
 +
  static int hw_clockrate;
  SYSCTL_INT(_hw, OID_AUTO, clockrate, CTLFLAG_RD,
      &hw_clockrate, 0, "CPU instruction clock rate");
 @@ -856,6 +863,21 @@
                          */
                         if (cpu_feature & CPUID_HTT)
                                 htt = (cpu_procinfo & CPUID_HTT_CORES) >>
 16;
 +                       /*
 +                        * Obtain the serial number if the CPU supports it
 +                        */
 +                       if (cpu_feature & CPUID_PSN) {
 +                               do_cpuid(3, regs);
 +                               snprintf(cpu_serial,
 +                                   sizeof(cpu_serial),
 +                                   "%04x-%04x-%04x-%04x-%04x-%04x",
 +                                   (cpu_id >> 16), (cpu_id & 0xffff),
 +                                   (regs[3] >> 16), (regs[3] & 0xffff),
 +                                   (regs[2] >> 16), (regs[2] & 0xffff));
 +                               if (bootverbose)
 +                                       printf("\n  Processor Serial Number:
 %s",
 +                                           cpu_serial);
 +                       }
                         if (strcmp(cpu_vendor, "AuthenticAMD") == 0 &&
                             (amd_feature2 & AMDID2_CMP))
                                 cmp = (cpu_procinfo2 & AMDID_CMP_CORES) + 1;
 
 
 To apply, place patch in /usr/src and run patch < psn.diff
 
 sysctl is hw.cpu0.serial
 
 here is a snippet from booting verbosely with this patch:
 
 CPU: Intel Pentium III (927.11-MHz 686-class CPU)
   Origin = "GenuineIntel"  Id = 0x683  Stepping = 3
 
 Features=0x387fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,
 CMOV,PAT,PSE36,PN,MMX,FXSR,SSE>
   Processor Serial Number: 0000-0623-0001-de43-1r2c-6123
 real memory  = 268435456 (256 MB)
 Physical memory chunk(s):
 
 so you can see what it looks like.
 
 Ted