summaryrefslogtreecommitdiff
path: root/sysutils
diff options
context:
space:
mode:
authorStanislav Sedov <stas@FreeBSD.org>2008-12-30 19:55:23 +0000
committerStanislav Sedov <stas@FreeBSD.org>2008-12-30 19:55:23 +0000
commitf01aaa89f6139bfd3eb2025c267bb335446b4a94 (patch)
treea6b9dbfd5f9d326109e4bef4896f60d88e7e4edd /sysutils
parentDocument twiki - multiple vulnerabilities (diff)
- Update to 1.23.
This revision includes the new tool called lsmsr, which lists all known MSRs of a specific cpu. Check lsmsr.8 for details.
Notes
Notes: svn path=/head/; revision=225016
Diffstat (limited to 'sysutils')
-rw-r--r--sysutils/x86info/Makefile12
-rw-r--r--sysutils/x86info/distinfo6
-rw-r--r--sysutils/x86info/files/patch-Intel_topology.c20
-rw-r--r--sysutils/x86info/files/patch-Makefile18
-rw-r--r--sysutils/x86info/files/patch-bench_benchmarks.c16
-rw-r--r--sysutils/x86info/files/patch-cpuid.c51
-rw-r--r--sysutils/x86info/files/patch-lsmsr.c72
-rw-r--r--sysutils/x86info/files/patch-rdmsr.c18
-rw-r--r--sysutils/x86info/files/patch-x86info.h18
9 files changed, 181 insertions, 50 deletions
diff --git a/sysutils/x86info/Makefile b/sysutils/x86info/Makefile
index 2480aa87bead..ad6473743a96 100644
--- a/sysutils/x86info/Makefile
+++ b/sysutils/x86info/Makefile
@@ -6,8 +6,8 @@
#
PORTNAME= x86info
-PORTVERSION= 1.21
-PORTREVISION= 1
+PORTVERSION= 1.23
+PORTREVISION= 0
CATEGORIES= sysutils
MASTER_SITES= http://www.codemonkey.org.uk/projects/x86info/
EXTRACT_SUFX= .tgz
@@ -15,9 +15,11 @@ EXTRACT_SUFX= .tgz
MAINTAINER= stas@FreeBSD.org
COMMENT= Utility to display information about the systems x86 processor(s)
+USE_GMAKE= yes
ONLY_FOR_ARCHS= i386 amd64
-PLIST_FILES= bin/x86info
+PLIST_FILES= bin/x86info bin/lsmsr
MAN1= x86info.1
+MAN8= lsmsr.8
MAKE_ARGS= CFLAGS="${CFLAGS}"
.include <bsd.port.pre.mk>
@@ -28,6 +30,8 @@ CFLAGS+= -I"${LOCALBASE}"/include
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/x86info ${PREFIX}/bin
- ${INSTALL_MAN} ${WRKSRC}/x86info.1 ${MAN1PREFIX}/man/man1
+ ${INSTALL_PROGRAM} ${WRKSRC}/lsmsr ${PREFIX}/bin
+ ${INSTALL_MAN} ${MAN1:S,^,${WRKSRC}/,} ${MAN1PREFIX}/man/man1
+ ${INSTALL_MAN} ${MAN8:S,^,${WRKSRC}/,} ${MAN8PREFIX}/man/man8
.include <bsd.port.post.mk>
diff --git a/sysutils/x86info/distinfo b/sysutils/x86info/distinfo
index f9fc31e648be..0a67396c24ac 100644
--- a/sysutils/x86info/distinfo
+++ b/sysutils/x86info/distinfo
@@ -1,3 +1,3 @@
-MD5 (x86info-1.21.tgz) = 1fbfaa392170e2636006603659dec0f0
-SHA256 (x86info-1.21.tgz) = 2bb3fb33832e073452657adf9f946b2d73d32c7382382f2136750c29d2637fe1
-SIZE (x86info-1.21.tgz) = 59354
+MD5 (x86info-1.23.tgz) = 2313f797b605fc46419d8fe08e1ff821
+SHA256 (x86info-1.23.tgz) = 15cf5bb4a6ff90dd1f6486f12684986139ef2b4c98d9a259b5abb39b4655177a
+SIZE (x86info-1.23.tgz) = 77055
diff --git a/sysutils/x86info/files/patch-Intel_topology.c b/sysutils/x86info/files/patch-Intel_topology.c
new file mode 100644
index 000000000000..ea48ffbd757e
--- /dev/null
+++ b/sysutils/x86info/files/patch-Intel_topology.c
@@ -0,0 +1,20 @@
+--- Intel/topology.c.orig 2008-12-30 22:21:53.000000000 +0300
++++ Intel/topology.c 2008-12-30 22:22:23.000000000 +0300
+@@ -20,7 +20,7 @@
+ * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
+ */
+
+-static int fls(int x)
++static int priv_fls(int x)
+ {
+ int r = 32;
+
+@@ -55,7 +55,7 @@
+ {
+ unsigned int MaskWidth = 0;
+
+- MaskWidth = fls(item)-1;
++ MaskWidth = priv_fls(item)-1;
+ return MaskWidth;
+ }
+
diff --git a/sysutils/x86info/files/patch-Makefile b/sysutils/x86info/files/patch-Makefile
index a8ace0d5414d..484a3df508ae 100644
--- a/sysutils/x86info/files/patch-Makefile
+++ b/sysutils/x86info/files/patch-Makefile
@@ -1,11 +1,11 @@
---- Makefile.orig Sun Aug 24 16:14:00 2003
-+++ Makefile Sun Aug 24 16:15:05 2003
-@@ -4,7 +4,7 @@
- #CFLAGS += -mwin32 -DWIN32_LEAN_AND_MEAN
- SHELL = /bin/sh
+--- Makefile.orig 2008-12-30 22:24:01.000000000 +0300
++++ Makefile 2008-12-30 22:24:09.000000000 +0300
+@@ -15,7 +15,7 @@
+ $(CC) $(CFLAGS) -o $@ -c $<
--all: x86info test
-+all: x86info
- OBJS =\
- AMD/identify.o\
+-all: x86info test lsmsr
++all: x86info lsmsr
+
+
+ LSMSR_TMP_HEADERS=AMD/k8.h AMD/fam10h.h generic_msr.h
diff --git a/sysutils/x86info/files/patch-bench_benchmarks.c b/sysutils/x86info/files/patch-bench_benchmarks.c
deleted file mode 100644
index 4627173af5b3..000000000000
--- a/sysutils/x86info/files/patch-bench_benchmarks.c
+++ /dev/null
@@ -1,16 +0,0 @@
---- bench/benchmarks.c.orig 2008-09-04 03:03:34.000000000 +0400
-+++ bench/benchmarks.c 2008-09-04 03:04:55.000000000 +0400
-@@ -21,8 +21,13 @@
- #endif
- TIME(asm volatile("cpuid": : :"ax", "dx", "cx", "bx"), "cpuid");
-
-+#ifdef __i386__
- TIME(asm volatile("addl $1,0(%esp)"), "addl");
- TIME(asm volatile("lock ; addl $1,0(%esp)"), "locked add");
-+#elif defined(__amd64__)
-+ TIME(asm volatile("addl $1,0(%rsp)"), "addl");
-+ TIME(asm volatile("lock ; addl $1,0(%rsp)"), "locked add");
-+#endif
-
- TIME(asm volatile("bswap %0" : "=r" (tmp) : "0" (tmp)), "bswap");
- }
diff --git a/sysutils/x86info/files/patch-cpuid.c b/sysutils/x86info/files/patch-cpuid.c
index 6a3977c4661a..e2444f6b54d5 100644
--- a/sysutils/x86info/files/patch-cpuid.c
+++ b/sysutils/x86info/files/patch-cpuid.c
@@ -1,7 +1,7 @@
---- cpuid.c.orig 2007-11-27 03:37:20.000000000 +0300
-+++ cpuid.c 2008-08-09 23:02:57.000000000 +0400
-@@ -21,8 +21,15 @@
- #include <errno.h>
+--- cpuid.c.orig 2008-12-16 22:09:47.000000000 +0300
++++ cpuid.c 2008-12-30 22:36:09.000000000 +0300
+@@ -23,8 +23,15 @@
+ #include <sched.h>
#if defined(__FreeBSD__)
+# include <sys/param.h>
@@ -17,7 +17,31 @@
#endif
#include "x86info.h"
-@@ -38,7 +45,11 @@
+@@ -33,7 +40,9 @@
+ unsigned int *eax, unsigned int *ebx,
+ unsigned int *ecx, unsigned int *edx)
+ {
++#if defined(__linux__)
+ cpu_set_t set;
++#endif
+ unsigned int a = 0, b = 0, c = 0, d = 0;
+
+ if (eax != NULL)
+@@ -45,11 +54,13 @@
+ if (edx != NULL)
+ d = *edx;
+
++#if defined(__linux__)
+ if (sched_getaffinity(getpid(), sizeof(set), &set) == 0) {
+ CPU_ZERO(&set);
+ CPU_SET(cpunr, &set);
+ sched_setaffinity(getpid(), sizeof(set), &set);
+ }
++#endif
+
+ asm("cpuid"
+ : "=a" (a),
+@@ -79,7 +90,11 @@
char cpuname[20];
unsigned char buffer[16];
int fh;
@@ -27,9 +51,9 @@
+ cpuctl_cpuid_args_t args;
+#endif
- if (nodriver==1) {
- cpuid_UP(idx, eax, ebx, ecx, edx);
-@@ -47,10 +58,14 @@
+ if (nodriver == 1) {
+ native_cpuid(CPU_number, idx, eax,ebx,ecx,edx);
+@@ -88,10 +103,14 @@
args.level = idx;
/* Ok, use the /dev/CPU interface in preference to the _up code. */
@@ -45,7 +69,16 @@
perror(cpuname);
exit(EXIT_FAILURE);
}
-@@ -107,7 +122,7 @@
+@@ -106,8 +125,6 @@
+ } else {
+ /* Something went wrong, just do UP and hope for the best. */
+ nodriver = 1;
+- if (!silent && nrCPUs != 1)
+- perror(cpuname);
+ used_UP = 1;
+ native_cpuid(CPU_number, idx, eax,ebx,ecx,edx);
+ return;
+@@ -154,7 +171,7 @@
fh = open(cpuname, O_RDONLY);
if (fh != -1) {
#ifndef S_SPLINT_S
diff --git a/sysutils/x86info/files/patch-lsmsr.c b/sysutils/x86info/files/patch-lsmsr.c
new file mode 100644
index 000000000000..d579497bd3f1
--- /dev/null
+++ b/sysutils/x86info/files/patch-lsmsr.c
@@ -0,0 +1,72 @@
+--- lsmsr.c.orig 2008-12-16 22:09:47.000000000 +0300
++++ lsmsr.c 2008-12-30 22:35:23.000000000 +0300
+@@ -31,6 +31,18 @@
+ #include "AMD/fam10h.h"
+ #include "generic_msr.h"
+
++#if defined(__FreeBSD__)
++# include <sys/param.h>
++# include <sys/ioctl.h>
++# if __FreeBSD_version < 800042
++# define CPUDEV "/dev/cpu%d"
++# include <cpu.h>
++# else
++# define CPUDEV "/dev/cpuctl%d"
++# include <sys/cpuctl.h>
++# endif
++#endif
++
+ /* Todos:
+ * - add (list and eventually write) support for write-only MSR
+ * - add decoding support for bit fields
+@@ -120,6 +132,32 @@
+ fprintf(stdout, "%s version %s\n", g.prog, VERSION);
+ }
+
++#if defined(__FreeBSD__)
++
++int get_msr_val(unsigned int msr, unsigned long long *val)
++{
++#if __FreeBSD_version < 800042
++ cpu_msr_args_t args;
++#else
++ cpuctl_msr_args_t args;
++#endif
++
++ args.msr = msr;
++#if __FreeBSD_version < 800042
++ if (ioctl(g.fd, CPU_RDMSR, &args) != 0) {
++#else
++ if (ioctl(g.fd, CPUCTL_RDMSR, &args) != 0) {
++#endif
++ return 0;
++ }
++
++ *val = args.data;
++
++ return 0;
++}
++
++#else /* !__FreeBSD__ */
++
+ int get_msr_val(unsigned int msr, unsigned long long *val)
+ {
+ off64_t off;
+@@ -145,11 +183,17 @@
+ return 0;
+ }
+
++#endif
++
+ static int open_dev(int cpu)
+ {
+ char s[20];
+
++#ifdef __FreeBSD__
++ snprintf(s, sizeof(s), CPUDEV, cpu);
++#else
+ snprintf(s, sizeof(s), "/dev/cpu/%d/msr", cpu);
++#endif
+ g.fd = open(s, O_RDONLY);
+ if (g.fd < 0)
+ fprintf(stderr, "could not open device %s: %s\n", s,
diff --git a/sysutils/x86info/files/patch-rdmsr.c b/sysutils/x86info/files/patch-rdmsr.c
index fc4bed205f75..b2895a4e7485 100644
--- a/sysutils/x86info/files/patch-rdmsr.c
+++ b/sysutils/x86info/files/patch-rdmsr.c
@@ -1,13 +1,12 @@
---- rdmsr.c.orig 2007-11-27 03:37:20.000000000 +0300
-+++ rdmsr.c 2008-08-09 23:03:05.000000000 +0400
+--- rdmsr.c.orig 2008-12-16 22:09:47.000000000 +0300
++++ rdmsr.c 2008-12-30 22:11:46.000000000 +0300
@@ -17,8 +17,15 @@
#include "x86info.h"
#if defined(__FreeBSD__)
--# include <sys/ioctl.h>
--# include <cpu.h>
+# include <sys/param.h>
-+# include <sys/ioctl.h>
+ # include <sys/ioctl.h>
+-# include <cpu.h>
+# if __FreeBSD_version < 800042
+# define CPUDEV "/dev/cpu%d"
+# include <cpu.h>
@@ -39,12 +38,13 @@
@@ -46,7 +57,11 @@
}
- args.msr = idx;
+ args.msr = idx;
+- if (ioctl(fh, CPU_RDMSR, &args) != 0) {
+#if __FreeBSD_version < 800042
- if (ioctl(fh, CPU_RDMSR, &args) != 0) {
++ if (ioctl(fh, CPU_RDMSR, &args) != 0) {
+#else
+ if (ioctl(fh, CPUCTL_RDMSR, &args) != 0) {
+#endif
- if (close(fh) == -1) {
- perror("close");
+ if (close(fh) == -1) {
+ perror("close");
exit(EXIT_FAILURE);
diff --git a/sysutils/x86info/files/patch-x86info.h b/sysutils/x86info/files/patch-x86info.h
new file mode 100644
index 000000000000..ff697e093aca
--- /dev/null
+++ b/sysutils/x86info/files/patch-x86info.h
@@ -0,0 +1,18 @@
+--- x86info.h.orig 2008-12-30 22:20:56.000000000 +0300
++++ x86info.h 2008-12-30 22:21:20.000000000 +0300
+@@ -183,6 +183,7 @@
+ #include <unistd.h>
+ static inline void bind_cpu(struct cpudata *cpu)
+ {
++#if defined(__linux__)
+ cpu_set_t set;
+
+ if (sched_getaffinity(getpid(), sizeof(set), &set) == 0) {
+@@ -190,6 +191,7 @@
+ CPU_SET(cpu->number, &set);
+ sched_setaffinity(getpid(), sizeof(set), &set);
+ }
++#endif
+ }
+
+ #endif /* _X86INFO_H */