File msr-tools-xen_physical_msr_support.patch of Package msr-tools
From: Jan Beulich <JBeulich@novell.com>
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 <trenn@suse.de>
CC: H. Peter Anvin <hpa@linux.intel.com>
---
rdmsr.c | 11 +++++++++--
wrmsr.c | 12 ++++++++++--
2 files changed, 19 insertions(+), 4 deletions(-)
Index: msr-tools-1.3/rdmsr.c
===================================================================
--- msr-tools-1.3.orig/rdmsr.c
+++ msr-tools-1.3/rdmsr.c
@@ -45,12 +45,15 @@ 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 *msr_file_pattern = "/dev/cpu/%d/msr";
/* Number of decimal digits for a certain number of bits */
/* (int) ceil(log(2^n)/log(10)) */
@@ -90,6 +93,7 @@ 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);
}
@@ -167,6 +171,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) {
@@ -213,7 +220,7 @@ void rdmsr_on_cpu(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) {
Index: msr-tools-1.3/wrmsr.c
===================================================================
--- msr-tools-1.3.orig/wrmsr.c
+++ msr-tools-1.3/wrmsr.c
@@ -36,10 +36,13 @@ 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 *msr_file_pattern = "/dev/cpu/%d/msr";
const char *program;
@@ -49,6 +52,7 @@ 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);
}
@@ -101,6 +105,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) {
@@ -138,7 +145,7 @@ void wrmsr_on_cpu(uint32_t reg, 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) {