Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/cpuctl/arch If the IOC_CPU_UCODE_GET_VERSION fails ...



details:   https://anonhg.NetBSD.org/src/rev/83565944d706
branches:  trunk
changeset: 783715:83565944d706
user:      dsl <dsl%NetBSD.org@localhost>
date:      Sat Jan 05 16:38:12 2013 +0000

description:
If the IOC_CPU_UCODE_GET_VERSION fails with ENOTTY, try issuing the
request that the amd64 kernel understands.

diffstat:

 usr.sbin/cpuctl/arch/i386.c |  22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diffs (51 lines):

diff -r 98f08e9e3033 -r 83565944d706 usr.sbin/cpuctl/arch/i386.c
--- a/usr.sbin/cpuctl/arch/i386.c       Sat Jan 05 16:36:38 2013 +0000
+++ b/usr.sbin/cpuctl/arch/i386.c       Sat Jan 05 16:38:12 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i386.c,v 1.34 2013/01/05 15:27:45 dsl Exp $    */
+/*     $NetBSD: i386.c,v 1.35 2013/01/05 16:38:12 dsl Exp $    */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: i386.c,v 1.34 2013/01/05 15:27:45 dsl Exp $");
+__RCSID("$NetBSD: i386.c,v 1.35 2013/01/05 16:38:12 dsl Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -67,6 +67,7 @@
 #include <sys/ioctl.h>
 #include <sys/cpuio.h>
 
+#include <errno.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -1530,9 +1531,22 @@
                ucode.loader_version = CPU_UCODE_LOADER_INTEL1;
        else
                return;
+
        ucode.data = &ucvers;
-       if (ioctl(fd, IOC_CPU_UCODE_GET_VERSION, &ucode) < 0)
-               return;
+       if (ioctl(fd, IOC_CPU_UCODE_GET_VERSION, &ucode) < 0) {
+#ifdef __i386__
+               struct cpu_ucode_version_64 ucode_64;
+               if (errno != ENOTTY)
+                       return;
+               /* Try the 64 bit ioctl */
+               memset(&ucode_64, 0, sizeof ucode_64);
+               ucode_64.data = &ucvers;
+               ucode_64.loader_version = ucode.loader_version;
+               if (ioctl(fd, IOC_CPU_UCODE_GET_VERSION_64, &ucode_64) < 0)
+                       return;
+#endif
+       }
+
        if (cpu_vendor == CPUVENDOR_AMD)
                printf("%s: UCode version: 0x%"PRIx64"\n", cpuname, ucvers.amd.version);
        else if (cpu_vendor == CPUVENDOR_INTEL)



Home | Main Index | Thread Index | Old Index