Date: Sat, 27 Jan 2007 10:40:18 GMT From: "Internet Partners, Inc. Tech Support" <support@ipinc.net> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/65627: [i386] [patch] store P3 serial number in sysctl Message-ID: <200701271040.l0RAeIY3020646@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701271040.l0RAeIY3020646>