Hello community,

here is the log from the commit of package msr-tools for openSUSE:Factory
checked in at Thu Aug 18 09:45:41 CEST 2011.



--------
--- msr-tools/msr-tools.changes 2009-10-27 17:20:48.000000000 +0100
+++ /mounts/work_src_done/STABLE/msr-tools/msr-tools.changes    2011-08-16 
10:15:21.000000000 +0200
@@ -1,0 +2,18 @@
+Tue Aug 16 08:14:44 UTC 2011 - [email protected]
+
+- Add compile fix (+#define _XOPEN_SOURCE 500) again
+
+-------------------------------------------------------------------
+Tue Aug 16 08:04:43 UTC 2011 - [email protected]
+
+- MSR (Machine Specific Registers) should only exist on X86.
+  -> restrict msr-tools to X86 architectures
+
+-------------------------------------------------------------------
+Mon Aug 15 11:06:19 UTC 2011 - [email protected]
+
+- Update to latest git version (e37ee2a529baacde26b25795b4c3dec1c641862e)
+  This is Version 1.2 plus some even newer patches
+- Add Xen physical CPU support
+
+-------------------------------------------------------------------

calling whatdependson for head-i586


Old:
----
  msr-tools-1.1.2.tar.bz2

New:
----
  msr-tools-1.2.tar.bz2
  msr-tools-xen_physical_msr_support.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ msr-tools.spec ++++++
--- /var/tmp/diff_new_pack.0GZa1I/_old  2011-08-18 09:45:16.000000000 +0200
+++ /var/tmp/diff_new_pack.0GZa1I/_new  2011-08-18 09:45:16.000000000 +0200
@@ -1,7 +1,7 @@
 #
-# spec file for package msr-tools (Version 1.1.2)
+# spec file for package msr-tools
 #
-# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -21,14 +21,16 @@
 Name:           msr-tools
 Url:            http://www.kernel.org/pub/linux/utils/cpu/msr-tools/
 Summary:        Tool for reading and writing MSRs (model specific register)
-Version:        1.1.2
-Release:        35
+Version:        1.2
+Release:        1
 License:        GPL v2 or later
 Group:          System/Base
 Source:         %{name}-%{version}.tar.bz2
 Source1:        COPYING
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-Patch0:         %{name}-fix-compile-warning.diff
+Patch0:         msr-tools-fix-compile-warning.diff
+Patch1:         %{name}-xen_physical_msr_support.patch
+ExclusiveArch:  %ix86 x86_64
 
 %description
 Tool to read and write MSRs (model specific registers). You have to
@@ -43,6 +45,7 @@
 %prep
 %setup -q
 %patch0 -p1
+%patch1 -p1
 
 %build
 make CFLAGS="$RPM_OPT_FLAGS"

++++++ msr-tools-1.1.2.tar.bz2 -> msr-tools-1.2.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/msr-tools-1.1.2/.gitignore 
new/msr-tools-1.2/.gitignore
--- old/msr-tools-1.1.2/.gitignore      1970-01-01 01:00:00.000000000 +0100
+++ new/msr-tools-1.2/.gitignore        2010-08-05 08:35:51.000000000 +0200
@@ -0,0 +1,4 @@
+rdmsr
+wrmsr
+*.o
+*~
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/msr-tools-1.1.2/Makefile new/msr-tools-1.2/Makefile
--- old/msr-tools-1.1.2/Makefile        2004-07-20 17:54:59.000000000 +0200
+++ new/msr-tools-1.2/Makefile  2010-08-05 08:35:51.000000000 +0200
@@ -1,4 +1,3 @@
-#ident "$Id: Makefile,v 1.2 2004/07/20 15:54:59 hpa Exp $"
 ## -----------------------------------------------------------------------
 ##   
 ##   Copyright 2000 Transmeta Corporation - All Rights Reserved
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/msr-tools-1.1.2/rdmsr.c new/msr-tools-1.2/rdmsr.c
--- old/msr-tools-1.1.2/rdmsr.c 2004-07-20 17:54:59.000000000 +0200
+++ new/msr-tools-1.2/rdmsr.c   2010-08-05 08:35:51.000000000 +0200
@@ -1,13 +1,13 @@
-#ident "$Id: rdmsr.c,v 1.4 2004/07/20 15:54:59 hpa Exp $"
 /* ----------------------------------------------------------------------- *
- *   
+ *
  *   Copyright 2000 Transmeta Corporation - All Rights Reserved
+ *   Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
  *
  *   This program is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
- *   USA; either version 2 of the License, or (at your option) any later
- *   version; incorporated herein by reference.
+ *   the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ *   Boston MA 02110-1301, USA; either version 2 of the License, or
+ *   (at your option) any later version; incorporated herein by reference.
  *
  * ----------------------------------------------------------------------- */
 
@@ -28,33 +28,37 @@
 
 #include "version.h"
 
-struct option long_options[] = {
-  { "help",                0, 0, 'h' },
-  { "version",             0, 0, 'V' },
-  { "hexadecimal",         0, 0, 'x' },
-  { "capital-hexadecimal", 0, 0, 'X' },
-  { "decimal",             0, 0, 'd' },
-  { "signed-decimal",      0, 0, 'd' },
-  { "unsigned-decimal",    0, 0, 'u' },
-  { "octal",               0, 0, 'o' },
-  { "c-language",          0, 0, 'c' }, 
-  { "zero-fill",           0, 0, '0' },
-  { "zero-pad",            0, 0, '0' },
-  { "raw",                 0, 0, 'r' },
-  { "processor",           1, 0, 'p' },
-  { "cpu",                 1, 0, 'p' },
-  { "bitfield",            1, 0, 'f' },
-  { 0, 0, 0, 0 }
+static const struct option long_options[] = {
+       {"help",                0, 0, 'h'},
+       {"version",             0, 0, 'V'},
+       {"hexadecimal",         0, 0, 'x'},
+       {"capital-hexadecimal", 0, 0, 'X'},
+       {"decimal",             0, 0, 'd'},
+       {"signed-decimal",      0, 0, 'd'},
+       {"unsigned-decimal",    0, 0, 'u'},
+       {"octal",               0, 0, 'o'},
+       {"c-language",          0, 0, 'c'},
+       {"zero-fill",           0, 0, '0'},
+       {"zero-pad",            0, 0, '0'},
+       {"raw",                 0, 0, 'r'},
+       {"all",                 0, 0, 'a'},
+       {"processor",           1, 0, 'p'},
+       {"cpu",                 1, 0, 'p'},
+       {"bitfield",            1, 0, 'f'},
+       {0, 0, 0, 0}
 };
+static const char short_options[] = "hVxXdoruc0ap:f:";
+
+static const char *proc_stat = "/proc/stat";
 
 /* Number of decimal digits for a certain number of bits */
 /* (int) ceil(log(2^n)/log(10)) */
-int decdigits[] = {
-  1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5,
-  5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10,
-  10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 15,
-  15, 15, 16, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 19,
-  20
+static const int decdigits[] = {
+       1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5,
+       5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10,
+       10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 15,
+       15, 15, 16, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 19,
+       20
 };
 
 #define mo_hex  0x01
@@ -69,234 +73,299 @@
 
 const char *program;
 
-void usage(void)
+static void usage(void)
+{
+       fprintf(stderr,
+               "Usage: %s [options] regno\n"
+               "  --help         -h  Print this help\n"
+               "  --version      -V  Print current version\n"
+               "  --hexadecimal  -x  Hexadecimal output (lower case)\n"
+               "  --capital-hex  -X  Hexadecimal output (upper case)\n"
+               "  --decimal      -d  Signed decimal output\n"
+               "  --unsigned     -u  Unsigned decimal output\n"
+               "  --octal        -o  Octal output\n"
+               "  --c-language   -c  Format output as a C language constant\n"
+               "  --zero-pad     -0  Output leading zeroes\n"
+               "  --raw          -r  Raw binary output\n"
+               "  --all          -a  all processors\n"
+               "  --processor #  -p  Select processor number (default 0)\n"
+               "  --bitfield h:l -f  Output bits [h:l] only\n", program);
+}
+
+struct format {
+       unsigned int mode;
+       unsigned int highbit;
+       unsigned int lowbit;
+};
+
+static void rdmsr_on_cpu(const struct format *fmt, uint32_t reg, int cpu)
+{
+       uint64_t data;
+       int fd;
+       char *pat;
+       int width;
+       char msr_file_name[64];
+       unsigned int bits;
+
+       sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
+       fd = open(msr_file_name, O_RDONLY);
+       if (fd < 0) {
+               if (errno == ENXIO) {
+                       fprintf(stderr, "rdmsr: No CPU %d\n", cpu);
+                       exit(2);
+               } else if (errno == EIO) {
+                       fprintf(stderr, "rdmsr: CPU %d doesn't support MSRs\n",
+                               cpu);
+                       exit(3);
+               } else {
+                       perror("rdmsr: open");
+                       exit(127);
+               }
+       }
+
+       if (pread(fd, &data, sizeof data, reg) != sizeof data) {
+               if (errno == EIO) {
+                       fprintf(stderr, "rdmsr: CPU %d cannot read "
+                               "MSR 0x%08"PRIx32"\n",
+                               cpu, reg);
+                       exit(4);
+               } else {
+                       perror("rdmsr: pread");
+                       exit(127);
+               }
+       }
+
+       close(fd);
+
+       bits = fmt->highbit - fmt->lowbit + 1;
+       if (bits < 64) {
+               /* Show only part of register */
+               data >>= fmt->lowbit;
+               data &= (1ULL << bits) - 1;
+       }
+
+       pat = NULL;
+
+       width = 1;              /* Default */
+       switch (fmt->mode) {
+       case mo_hex:
+               pat = "%*llx\n";
+               break;
+       case mo_chx:
+               pat = "%*llX\n";
+               break;
+       case mo_dec:
+       case mo_dec | mo_c:
+       case mo_dec | mo_fill | mo_c:
+               /* Make sure we get sign correct */
+               if (data & (1ULL << (bits - 1))) {
+                       data &= ~(1ULL << (bits - 1));
+                       data = -data;
+               }
+               pat = "%*lld\n";
+               break;
+       case mo_uns:
+               pat = "%*llu\n";
+               break;
+       case mo_oct:
+               pat = "%*llo\n";
+               break;
+       case mo_hex | mo_c:
+               pat = "0x%*llx\n";
+               break;
+       case mo_chx | mo_c:
+               pat = "0x%*llX\n";
+               break;
+       case mo_oct | mo_c:
+               pat = "0%*llo\n";
+               break;
+       case mo_uns | mo_c:
+       case mo_uns | mo_fill | mo_c:
+               pat = "%*lluU\n";
+               break;
+       case mo_hex | mo_fill:
+               pat = "%0*llx\n";
+               width = (bits + 3) / 4;
+               break;
+       case mo_chx | mo_fill:
+               pat = "%0*llX\n";
+               width = (bits + 3) / 4;
+               break;
+       case mo_dec | mo_fill:
+               /* Make sure we get sign correct */
+               if (data & (1ULL << (bits - 1))) {
+                       data &= ~(1ULL << (bits - 1));
+                       data = -data;
+               }
+               pat = "%0*lld\n";
+               width = decdigits[bits - 1] + 1;
+               break;
+       case mo_uns | mo_fill:
+               pat = "%0*llu\n";
+               width = decdigits[bits];
+               break;
+       case mo_oct | mo_fill:
+               pat = "%0*llo\n";
+               width = (bits + 2) / 3;
+               break;
+       case mo_hex | mo_fill | mo_c:
+               pat = "0x%0*llx\n";
+               width = (bits + 3) / 4;
+               break;
+       case mo_chx | mo_fill | mo_c:
+               pat = "0x%0*llX\n";
+               width = (bits + 3) / 4;
+               break;
+       case mo_oct | mo_fill | mo_c:
+               pat = "0%0*llo\n";
+               width = (bits + 2) / 3;
+               break;
+       case mo_raw:
+       case mo_raw | mo_fill:
+               fwrite(&data, sizeof data, 1, stdout);
+               break;
+       case mo_raw | mo_c:
+       case mo_raw | mo_fill | mo_c:
+               {
+                       unsigned char *p = (unsigned char *)&data;
+                       int i;
+                       for (i = 0; i < sizeof data; i++) {
+                               printf("%s0x%02x", i ? "," : "{",
+                                      (unsigned int)(*p++));
+                       }
+                       printf("}\n");
+               }
+               break;
+       default:
+               fprintf(stderr, "%s: Impossible case, line %d\n", program,
+                       __LINE__);
+               exit(127);
+       }
+
+       if (width < 1)
+               width = 1;
+
+       if (pat)
+               printf(pat, width, data);
+       return;
+}
+
+static void rdmsr_on_all_cpus(const struct format *fmt, uint32_t reg)
 {
-  fprintf(stderr,
-         "Usage: %s [options] regno\n"
-         "  --help         -h  Print this help\n"
-         "  --version      -V  Print current version\n"
-         "  --hexadecimal  -x  Hexadecimal output (lower case)\n"
-         "  --capital-hex  -X  Hexadecimal output (upper case)\n"
-         "  --decimal      -d  Signed decimal output\n"
-         "  --unsigned     -u  Unsigned decimal output\n"
-         "  --octal        -o  Octal output\n"
-         "  --c-language   -c  Format output as a C language constant\n"
-         "  --zero-pad     -0  Output leading zeroes\n"
-         "  --raw          -r  Raw binary output\n"
-         "  --processor #  -p  Select processor number (default 0)\n"
-         "  --bitfield h:l -f  Output bits [h:l] only\n"
-         , program);
+       FILE *fp;
+       int retval;
+
+       fp = fopen(proc_stat, "r");
+       if (fp == NULL) {
+               perror(proc_stat);
+               exit(-1);
+       }
+
+       retval = fscanf(fp, "cpu %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d\n");
+       if (retval != 0) {
+               perror("/proc/stat format");
+               exit(-1);
+       }
+
+       for (;;) {
+               int cpu;
+
+               retval = fscanf(fp, "cpu%u %*d %*d %*d %*d %*d %*d %*d %*d %*d"
+                       " %*d\n", &cpu);
+               if (retval != 1)
+                       return;
+
+               rdmsr_on_cpu(fmt, reg, cpu);
+       }
+       fclose(fp);
 }
 
 int main(int argc, char *argv[])
 {
-  uint32_t reg;
-  uint64_t data;
-  int c, fd;
-  int mode = mo_hex;
-  int cpu = 0;
-  unsigned int highbit = 63, lowbit = 0, bits;
-  unsigned long arg;
-  char *endarg;
-  char *pat;
-  int width;
-  char msr_file_name[64];
-
-  program = argv[0];
-
-  while ( (c = getopt_long(argc,argv,"hVxXdoruc0p:f:",long_options,NULL)) != 
-1 ) {
-    switch ( c ) {
-    case 'h':
-      usage();
-      exit(0);
-    case 'V':
-      fprintf(stderr, "%s: version %s\n", program, VERSION_STRING);
-      exit(0);
-    case 'x':
-      mode = (mode & ~mo_mask) | mo_hex;
-      break;
-    case 'X':
-      mode = (mode & ~mo_mask) | mo_chx;
-      break;
-    case 'o':
-      mode = (mode & ~mo_mask) | mo_oct;
-      break;
-    case 'd':
-      mode = (mode & ~mo_mask) | mo_dec;
-      break;
-    case 'r':
-      mode = (mode & ~mo_mask) | mo_raw;
-      break;
-    case 'u':
-      mode = (mode & ~mo_mask) | mo_uns;
-      break;
-    case 'c':
-      mode |= mo_c;
-      break;
-    case '0':
-      mode |= mo_fill;
-      break;
-    case 'p':
-      arg = strtoul(optarg, &endarg, 0);
-      if ( *endarg || arg > 255 ) {
-       usage();
-       exit(127);
-      }
-      cpu = (int)arg;
-      break;
-    case 'f':
-      {
-       if ( sscanf(optarg, "%u:%u", &highbit, &lowbit) != 2 ||
-            highbit > 63 || lowbit > highbit ) {
-         usage();
-         exit(127);
+       uint32_t reg;
+       int c;
+       int cpu = 0;
+       unsigned long arg;
+       char *endarg;
+       struct format fmt;
+
+       fmt.mode    = mo_hex;
+       fmt.highbit = 63;
+       fmt.lowbit  = 0;
+
+       program = argv[0];
+
+       while ((c = getopt_long(argc, argv, short_options,
+                               long_options, NULL)) != -1) {
+               switch (c) {
+               case 'h':
+                       usage();
+                       exit(0);
+               case 'V':
+                       fprintf(stderr, "%s: version %s\n", program,
+                               VERSION_STRING);
+                       exit(0);
+               case 'x':
+                       fmt.mode = (fmt.mode & ~mo_mask) | mo_hex;
+                       break;
+               case 'X':
+                       fmt.mode = (fmt.mode & ~mo_mask) | mo_chx;
+                       break;
+               case 'o':
+                       fmt.mode = (fmt.mode & ~mo_mask) | mo_oct;
+                       break;
+               case 'd':
+                       fmt.mode = (fmt.mode & ~mo_mask) | mo_dec;
+                       break;
+               case 'r':
+                       fmt.mode = (fmt.mode & ~mo_mask) | mo_raw;
+                       break;
+               case 'u':
+                       fmt.mode = (fmt.mode & ~mo_mask) | mo_uns;
+                       break;
+               case 'c':
+                       fmt.mode |= mo_c;
+                       break;
+               case '0':
+                       fmt.mode |= mo_fill;
+                       break;
+               case 'a':
+                       cpu = -1;
+                       break;
+               case 'p':
+                       arg = strtoul(optarg, &endarg, 0);
+                       if (*endarg || arg > 255) {
+                               usage();
+                               exit(127);
+                       }
+                       cpu = (int)arg;
+                       break;
+               case 'f':
+                       if (sscanf(optarg, "%u:%u", &fmt.highbit, &fmt.lowbit)
+                           != 2 ||
+                           fmt.highbit > 63 ||
+                           fmt.lowbit > fmt.highbit) {
+                               usage();
+                               exit(127);
+                       }
+                       break;
+               default:
+                       usage();
+                       exit(127);
+               }
        }
-      }
-      break;
-    default:
-      usage();
-      exit(127);
-    }
-  }
-
-  if ( optind != argc-1 ) {
-    /* Should have exactly one argument */
-    usage();
-    exit(127);
-  }
-
-  reg = strtoul(argv[optind], NULL, 0);
-
-  sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
-  fd = open(msr_file_name, O_RDONLY);
-  if ( fd < 0 ) {
-    if ( errno == ENXIO ) {
-      fprintf(stderr, "rdmsr: No CPU %d\n", cpu);
-      exit(2);
-    } else if ( errno == EIO ) {
-      fprintf(stderr, "rdmsr: CPU %d doesn't support MSRs\n", cpu);
-      exit(3);
-    } else {
-      perror("rdmsr:open");
-      exit(127);
-    }
-  }
-  
-  if ( pread(fd, &data, sizeof data, reg) != sizeof data ) {
-    perror("rdmsr:pread");
-    exit(127);
-  }
-
-  close(fd);
-
-  bits = highbit-lowbit+1;
-  if ( bits < 64 ) {
-    /* Show only part of register */
-    data >>= lowbit;
-    data &= (1ULL << bits)-1;
-  }
-
-  pat = NULL;
-
-  width = 1;                   /* Default */
-  switch(mode) {
-  case mo_hex:
-    pat = "%*llx\n";
-    break;
-  case mo_chx:
-    pat = "%*llX\n";
-    break;
-  case mo_dec:
-  case mo_dec|mo_c:
-  case mo_dec|mo_fill|mo_c:
-    /* Make sure we get sign correct */
-    if ( data & (1ULL << (bits-1)) ) {
-      data &= ~(1ULL << (bits-1));
-      data = -data;
-    }
-    pat = "%*lld\n";
-    break;
-  case mo_uns:
-    pat = "%*llu\n";
-    break;
-  case mo_oct:
-    pat = "%*llo\n";
-    break;
-  case mo_hex|mo_c:
-    pat = "0x%*llx\n";
-    break;
-  case mo_chx|mo_c:
-    pat = "0x%*llX\n";
-    break;
-  case mo_oct|mo_c:
-    pat = "0%*llo\n";
-    break;
-  case mo_uns|mo_c:
-  case mo_uns|mo_fill|mo_c:
-    pat = "%*lluU\n";
-    break;
-  case mo_hex|mo_fill:
-    pat = "%0*llx\n";
-    width = (bits+3)/4;
-    break;
-  case mo_chx|mo_fill:
-    pat = "%0*llX\n";
-    width = (bits+3)/4;
-    break;
-  case mo_dec|mo_fill:
-    /* Make sure we get sign correct */
-    if ( data & (1ULL << (bits-1)) ) {
-      data &= ~(1ULL << (bits-1));
-      data = -data;
-    }
-    pat = "%0*lld\n";
-    width = decdigits[bits-1]+1;
-    break;
-  case mo_uns|mo_fill:
-    pat = "%0*llu\n";
-    width = decdigits[bits];
-    break;
-  case mo_oct|mo_fill:
-    pat = "%0*llo\n";
-    width = (bits+2)/3;
-    break;
-  case mo_hex|mo_fill|mo_c:
-    pat = "0x%0*llx\n";
-    width = (bits+3)/4;
-    break;
-  case mo_chx|mo_fill|mo_c:
-    pat = "0x%0*llX\n";
-    width = (bits+3)/4;
-    break;
-  case mo_oct|mo_fill|mo_c:
-    pat = "0%0*llo\n";
-    width = (bits+2)/3;
-    break;
-  case mo_raw:
-  case mo_raw|mo_fill:
-    fwrite(&data,sizeof data,1,stdout);
-    break;
-  case mo_raw|mo_c:
-  case mo_raw|mo_fill|mo_c:
-    {
-      unsigned char *p = (unsigned char *)&data;
-      int i;
-      for ( i = 0 ; i < sizeof data ; i++ ) {
-       printf("%s0x%02x", i?",":"{", (unsigned int)(*p++));
-      }
-      printf("}\n");
-    }
-  break;
-  default:
-    fprintf(stderr, "%s: Impossible case, line %d\n", program, __LINE__);
-    exit(127);
-  }
 
-  if ( width < 1 )
-    width = 1;
+       if (optind != argc - 1) {
+               /* Should have exactly one argument */
+               usage();
+               exit(127);
+       }
 
-  if ( pat )
-    printf(pat, width, data);
+       reg = strtoul(argv[optind], NULL, 0);
 
-  exit(0);
+       if (cpu == -1)
+               rdmsr_on_all_cpus(&fmt, reg);
+       else
+               rdmsr_on_cpu(&fmt, reg, cpu);
+       exit(0);
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/msr-tools-1.1.2/version.h new/msr-tools-1.2/version.h
--- old/msr-tools-1.1.2/version.h       2004-07-20 17:54:59.000000000 +0200
+++ new/msr-tools-1.2/version.h 2010-08-05 08:35:51.000000000 +0200
@@ -1,4 +1,4 @@
 #ifndef MSR_TOOLS_VERSION_H
 #define MSR_TOOLS_VERSION_H
-#define VERSION_STRING "msr-tools-1.1.2"
+#define VERSION_STRING "msr-tools-1.2"
 #endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/msr-tools-1.1.2/wrmsr.c new/msr-tools-1.2/wrmsr.c
--- old/msr-tools-1.1.2/wrmsr.c 2004-07-20 17:54:59.000000000 +0200
+++ new/msr-tools-1.2/wrmsr.c   2010-08-05 08:35:51.000000000 +0200
@@ -1,13 +1,13 @@
-#ident "$Id: wrmsr.c,v 1.3 2004/07/20 15:54:59 hpa Exp $"
 /* ----------------------------------------------------------------------- *
- *   
+ *
  *   Copyright 2000 Transmeta Corporation - All Rights Reserved
+ *   Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
  *
  *   This program is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
- *   USA; either version 2 of the License, or (at your option) any later
- *   version; incorporated herein by reference.
+ *   the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ *   Boston MA 02110-1301, USA; either version 2 of the License, or
+ *   (at your option) any later version; incorporated herein by reference.
  *
  * ----------------------------------------------------------------------- */
 
@@ -28,92 +28,147 @@
 
 #include "version.h"
 
-struct option long_options[] = {
-  { "help",        0, 0, 'h' },
-  { "version",     0, 0, 'V' },
-  { "processor",   1, 0, 'p' },
-  { "cpu",         1, 0, 'p' },
-  { 0, 0, 0, 0 }
+static const struct option long_options[] = {
+       {"help",        0, 0, 'h'},
+       {"version",     0, 0, 'V'},
+       {"all",         0, 0, 'a'},
+       {"processor",   1, 0, 'p'},
+       {"cpu",         1, 0, 'p'},
+       {0, 0, 0, 0}
 };
+static const char short_options[] = "hVap:";
 
+static const char *proc_stat = "/proc/stat";
 const char *program;
 
-void usage(void)
+static void usage(void)
 {
-  fprintf(stderr, "Usage: %s [options] regno value...\n"
-         "  --help         -h  Print this help\n"
-         "  --version      -V  Print current version\n"
-         "  --processor #  -p  Select processor number (default 0)\n"
-         , program);
+       fprintf(stderr, "Usage: %s [options] regno value...\n"
+               "  --help         -h  Print this help\n"
+               "  --version      -V  Print current version\n"
+               "  --all          -a  all processors\n"
+               "  --processor #  -p  Select processor number (default 0)\n",
+               program);
 }
 
-int main(int argc, char *argv[])
+static void wrmsr_on_cpu(uint32_t reg, uint64_t data, int cpu)
+{
+       int fd;
+       char msr_file_name[64];
+
+       sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
+       fd = open(msr_file_name, O_WRONLY);
+       if (fd < 0) {
+               if (errno == ENXIO) {
+                       fprintf(stderr, "wrmsr: No CPU %d\n", cpu);
+                       exit(2);
+               } else if (errno == EIO) {
+                       fprintf(stderr, "wrmsr: CPU %d doesn't support MSRs\n",
+                               cpu);
+                       exit(3);
+               } else {
+                       perror("wrmsr: open");
+                       exit(127);
+               }
+       }
+       if (pwrite(fd, &data, sizeof data, reg) != sizeof data) {
+               if (errno == EIO) {
+                       fprintf(stderr,
+                               "wrmsr: CPU %d cannot set MSR "
+                               "0x%08"PRIx32" to 0x%016"PRIx64"\n",
+                               cpu, reg, data);
+                       exit(4);
+               } else {
+                       perror("wrmsr: pwrite");
+                       exit(127);
+               }
+       }
+       close(fd);
+}
+
+
+static void wrmsr_on_all_cpus(uint32_t reg, uint64_t data)
 {
-  uint32_t reg;
-  uint64_t data;
-  int fd;
-  int c;
-  int cpu = 0;
-  unsigned long arg;
-  char *endarg;
-  char msr_file_name[64];
-
-  program = argv[0];
-
-  while ( (c = getopt_long(argc,argv,"hVp:",long_options,NULL)) != - 1 ) {
-    switch( c ) {
-    case 'h':
-      usage();
-      exit(0);
-    case 'V':
-      fprintf(stderr, "%s: version %s\n", program, VERSION_STRING);
-      exit(0);
-    case 'p':
-      arg = strtoul(optarg, &endarg, 0);
-      if ( *endarg || arg > 255 ) {
-       usage();
-       exit(127);
-      }
-      cpu = (int)arg;
-      break;
-    default:
-      usage();
-      exit(127);
-    }
-  }
-
-  if ( optind > argc-2 ) {
-    /* Should have at least two arguments */
-    usage();
-    exit(127);
-  }
-
-  reg = strtoul(argv[optind++], NULL, 0);
-
-  sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
-  fd = open(msr_file_name, O_WRONLY);
-  if ( fd < 0 ) {
-    if ( errno == ENXIO ) {
-      fprintf(stderr, "wrmsr: No CPU %d\n", cpu);
-      exit(2);
-    } else if ( errno == EIO ) {
-      fprintf(stderr, "wrmsr: CPU %d doesn't support MSRs\n", cpu);
-      exit(3);
-    } else {
-      perror("wrmsr:open");
-      exit(127);
-    }
-  }
-  
-  while ( optind < argc ) {
-    data = strtoull(argv[optind++], NULL, 0);
-    if ( pwrite(fd, &data, sizeof data, reg) != sizeof data ) {
-      perror("wrmsr:pwrite");
-      exit(127);
-    }
-  }
+       FILE *fp;
+       int retval;
 
-  close(fd);
+       fp = fopen(proc_stat, "r");
+       if (fp == NULL) {
+               perror(proc_stat);
+               exit(-1);
+       }
+
+       retval = fscanf(fp, "cpu %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d\n");
+       if (retval != 0) {
+               perror("/proc/stat format");
+               exit(-1);
+       }
+
+       for (;;) {
+               int cpu;
+
+               retval = fscanf(fp, "cpu%u %*d %*d %*d %*d %*d %*d %*d %*d "
+                       "%*d %*d\n", &cpu);
+               if (retval != 1)
+                       return;
+
+               wrmsr_on_cpu(reg, data, cpu);
+       }
+       fclose(fp);
+}
 
-  exit(0);
+int main(int argc, char *argv[])
+{
+       uint32_t reg;
+       uint64_t data;
+       int c;
+       int cpu = 0;
+       unsigned long arg;
+       char *endarg;
+
+       program = argv[0];
+
+       while ((c = getopt_long(argc, argv, short_options,
+                               long_options, NULL)) != -1) {
+               switch (c) {
+               case 'h':
+                       usage();
+                       exit(0);
+               case 'V':
+                       fprintf(stderr, "%s: version %s\n", program,
+                               VERSION_STRING);
+                       exit(0);
+               case 'a':
+                       cpu = -1;
+                       break;
+               case 'p':
+                       arg = strtoul(optarg, &endarg, 0);
+                       if (*endarg || arg > 255) {
+                               usage();
+                               exit(127);
+                       }
+                       cpu = (int)arg;
+                       break;
+               default:
+                       usage();
+                       exit(127);
+               }
+       }
+
+       if (optind > argc - 2) {
+               /* Should have at least two arguments */
+               usage();
+               exit(127);
+       }
+
+       reg = strtoul(argv[optind++], NULL, 0);
+
+       while (optind < argc) {
+               data = strtoull(argv[optind++], NULL, 0);
+               if (cpu == -1)
+                       wrmsr_on_all_cpus(reg, data);
+               else
+                       wrmsr_on_cpu(reg, data, cpu);
+       }
+       exit(0);
 }

++++++ msr-tools-xen_physical_msr_support.patch ++++++
From: Jan Beulich <[email protected]>

msr-tools: Provide access to physical msr Xen interface via parameter

Xen provides /dev/cpu/X/msr where virtual CPU msr access is emulated.
/dev/xen/cpu/X/msr is passed to the physical CPUs.
Provide access to both via -P parameter.

Signed-off-by: Thomas Renninger <[email protected]>
CC: H. Peter Anvin <[email protected]>

---
 rdmsr.c |   11 +++++++++--
 wrmsr.c |   12 ++++++++++--
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/rdmsr.c b/rdmsr.c
index 3f5e2b3..f0543b8 100644
--- a/rdmsr.c
+++ b/rdmsr.c
@@ -42,15 +42,18 @@ static const struct option long_options[] = {
        {"zero-pad",            0, 0, '0'},
        {"raw",                 0, 0, 'r'},
        {"all",                 0, 0, 'a'},
+       {"phys-cpu",            1, 0, 'P'},
        {"processor",           1, 0, 'p'},
        {"cpu",                 1, 0, 'p'},
        {"bitfield",            1, 0, 'f'},
        {0, 0, 0, 0}
 };
-static const char short_options[] = "hVxXdoruc0ap:f:";
+static const char short_options[] = "hVxXdoruc0aP:p:f:";
 
 static const char *proc_stat = "/proc/stat";
 
+static const char *msr_file_pattern = "/dev/cpu/%d/msr";
+
 /* Number of decimal digits for a certain number of bits */
 /* (int) ceil(log(2^n)/log(10)) */
 static const int decdigits[] = {
@@ -89,6 +92,7 @@ static void usage(void)
                "  --raw          -r  Raw binary output\n"
                "  --all          -a  all processors\n"
                "  --processor #  -p  Select processor number (default 0)\n"
+               "  --phys-cpu #   -P  Select (Xen) physical processor = 
number\n"
                "  --bitfield h:l -f  Output bits [h:l] only\n", program);
 }
 
@@ -107,7 +111,7 @@ static void rdmsr_on_cpu(const struct format *fmt, uint32_t 
reg, int cpu)
        char msr_file_name[64];
        unsigned int bits;
 
-       sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
+       sprintf(msr_file_name, msr_file_pattern, cpu);
        fd = open(msr_file_name, O_RDONLY);
        if (fd < 0) {
                if (errno == ENXIO) {
@@ -332,6 +336,9 @@ int main(int argc, char *argv[])
                case 'a':
                        cpu = -1;
                        break;
+               case 'P':
+                       msr_file_pattern = "/dev/xen/cpu/%d/msr";
+                       /* fall through */
                case 'p':
                        arg = strtoul(optarg, &endarg, 0);
                        if (*endarg || arg > 255) {
diff --git a/wrmsr.c b/wrmsr.c
index 9800841..cb4a7e4 100644
--- a/wrmsr.c
+++ b/wrmsr.c
@@ -33,12 +33,16 @@ static const struct option long_options[] = {
        {"version",     0, 0, 'V'},
        {"all",         0, 0, 'a'},
        {"processor",   1, 0, 'p'},
+       {"phys-cpu",    1, 0, 'P'},
        {"cpu",         1, 0, 'p'},
        {0, 0, 0, 0}
 };
-static const char short_options[] = "hVap:";
+static const char short_options[] = "hVaP:p:";
 
 static const char *proc_stat = "/proc/stat";
+
+static const char *msr_file_pattern = "/dev/cpu/%d/msr";
+
 const char *program;
 
 static void usage(void)
@@ -47,6 +51,7 @@ static void usage(void)
                "  --help         -h  Print this help\n"
                "  --version      -V  Print current version\n"
                "  --all          -a  all processors\n"
+               "  --phys-cpu #   -P  Select (Xen) physical processor = 
number\n"
                "  --processor #  -p  Select processor number (default 0)\n",
                program);
 }
@@ -56,7 +61,7 @@ static void wrmsr_on_cpu(uint32_t reg, uint64_t data, int cpu)
        int fd;
        char msr_file_name[64];
 
-       sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
+       sprintf(msr_file_name, msr_file_pattern, cpu);
        fd = open(msr_file_name, O_WRONLY);
        if (fd < 0) {
                if (errno == ENXIO) {
@@ -141,6 +146,9 @@ int main(int argc, char *argv[])
                case 'a':
                        cpu = -1;
                        break;
+               case 'P':
+                       msr_file_pattern = "/dev/xen/cpu/%d/msr";
+                       /* fall through */
                case 'p':
                        arg = strtoul(optarg, &endarg, 0);
                        if (*endarg || arg > 255) {

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



Remember to have fun...

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to