1 From f2502a1201e95171265dfd707d3869e5f30ad01e Mon Sep 17 00:00:00 2001
2 From: Kanoj Sarcar <kanoj@google.com>
3 Date: Fri, 11 Mar 2016 14:50:59 -0800
4 Subject: [PATCH] Fix -a option for rdmsr/wrmsr. Current Linux creates /dev/cpu
5 files for non existant CPU's that trips up the "all" handling on the first
11 2 files changed, 12 insertions(+), 1 deletion(-)
13 diff --git a/rdmsr.c b/rdmsr.c
14 index d3e3c22..d1acca5 100644
17 @@ -50,6 +50,7 @@ static const struct option long_options[] = {
20 static const char short_options[] = "hVxXdoruc0ap:f:";
21 +static int doing_for_all = 0;
23 /* Number of decimal digits for a certain number of bits */
24 /* (int) ceil(log(2^n)/log(10)) */
25 @@ -196,6 +197,7 @@ int main(int argc, char *argv[])
26 reg = strtoul(argv[optind], NULL, 0);
30 rdmsr_on_all_cpus(reg);
33 @@ -216,6 +218,8 @@ void rdmsr_on_cpu(uint32_t reg, int cpu)
34 fd = open(msr_file_name, O_RDONLY);
39 fprintf(stderr, "rdmsr: No CPU %d\n", cpu);
41 } else if (errno == EIO) {
42 @@ -350,7 +354,10 @@ void rdmsr_on_cpu(uint32_t reg, int cpu)
49 + printf("CPU %d: ", cpu);
50 printf(pat, width, data);
54 diff --git a/wrmsr.c b/wrmsr.c
55 index 8a601b9..af16a8d 100644
58 @@ -39,6 +39,7 @@ static const struct option long_options[] = {
61 static const char short_options[] = "hVap:";
62 +static int doing_for_all = 0;
66 @@ -123,6 +124,7 @@ int main(int argc, char *argv[])
67 reg = strtoul(argv[optind++], NULL, 0);
71 wrmsr_on_all_cpus(reg, argc - optind, &argv[optind]);
73 wrmsr_on_cpu(reg, cpu, argc - optind, &argv[optind]);
74 @@ -141,6 +143,8 @@ void wrmsr_on_cpu(uint32_t reg, int cpu, int valcnt, char *regvals[])
75 fd = open(msr_file_name, O_WRONLY);
80 fprintf(stderr, "wrmsr: No CPU %d\n", cpu);
82 } else if (errno == EIO) {