* updated firefox (133.0.3 -> 134.0.2)
[t2sde.git] / package / x86 / msr-tools / 19a8432-unbreak-non-seq-a.patch
blobcf2f7e0b5379b03fdacb1fa4c66521fd8d05643c
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
6 encountered error.
8 ---
9 rdmsr.c | 9 ++++++++-
10 wrmsr.c | 4 ++++
11 2 files changed, 12 insertions(+), 1 deletion(-)
13 diff --git a/rdmsr.c b/rdmsr.c
14 index d3e3c22..d1acca5 100644
15 --- a/rdmsr.c
16 +++ b/rdmsr.c
17 @@ -50,6 +50,7 @@ static const struct option long_options[] = {
18 {0, 0, 0, 0}
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);
28 if (cpu == -1) {
29 + doing_for_all = 1;
30 rdmsr_on_all_cpus(reg);
32 else
33 @@ -216,6 +218,8 @@ void rdmsr_on_cpu(uint32_t reg, int cpu)
34 fd = open(msr_file_name, O_RDONLY);
35 if (fd < 0) {
36 if (errno == ENXIO) {
37 + if (doing_for_all)
38 + return;
39 fprintf(stderr, "rdmsr: No CPU %d\n", cpu);
40 exit(2);
41 } else if (errno == EIO) {
42 @@ -350,7 +354,10 @@ void rdmsr_on_cpu(uint32_t reg, int cpu)
43 if (width < 1)
44 width = 1;
46 - if (pat)
47 + if (pat) {
48 + if (doing_for_all)
49 + printf("CPU %d: ", cpu);
50 printf(pat, width, data);
51 + }
52 return;
54 diff --git a/wrmsr.c b/wrmsr.c
55 index 8a601b9..af16a8d 100644
56 --- a/wrmsr.c
57 +++ b/wrmsr.c
58 @@ -39,6 +39,7 @@ static const struct option long_options[] = {
59 {0, 0, 0, 0}
61 static const char short_options[] = "hVap:";
62 +static int doing_for_all = 0;
64 const char *program;
66 @@ -123,6 +124,7 @@ int main(int argc, char *argv[])
67 reg = strtoul(argv[optind++], NULL, 0);
69 if (cpu == -1) {
70 + doing_for_all = 1;
71 wrmsr_on_all_cpus(reg, argc - optind, &argv[optind]);
72 } else {
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);
76 if (fd < 0) {
77 if (errno == ENXIO) {
78 + if (doing_for_all)
79 + return;
80 fprintf(stderr, "wrmsr: No CPU %d\n", cpu);
81 exit(2);
82 } else if (errno == EIO) {