Lines 1-12
Link Here
|
1 |
--- ./mcelog.c.orig 2009-12-15 07:18:40.000000000 -0500 |
1 |
--- mcelog.c.orig 2010-01-20 18:36:52.000000000 -0800 |
2 |
+++ ./mcelog.c 2011-10-14 22:37:22.000000000 -0400 |
2 |
+++ mcelog.c 2012-09-22 02:34:19.182116917 -0700 |
3 |
@@ -20,8 +20,21 @@ |
3 |
@@ -20,9 +20,22 @@ |
4 |
#define _GNU_SOURCE 1 |
4 |
#define _GNU_SOURCE 1 |
5 |
#include <sys/fcntl.h> |
5 |
#include <sys/fcntl.h> |
6 |
#include <sys/ioctl.h> |
6 |
#include <sys/ioctl.h> |
7 |
+#ifdef __Linux__ |
7 |
+#ifdef __Linux__ |
8 |
#include <asm/types.h> |
8 |
#include <asm/types.h> |
9 |
#include <asm/ioctls.h> |
9 |
#include <asm/ioctls.h> |
|
|
10 |
#include <linux/limits.h> |
10 |
+#endif |
11 |
+#endif |
11 |
+#ifdef __FreeBSD__ |
12 |
+#ifdef __FreeBSD__ |
12 |
+#include <sys/types.h> |
13 |
+#include <sys/types.h> |
Lines 22-43
Link Here
|
22 |
#include <stdlib.h> |
23 |
#include <stdlib.h> |
23 |
#include <stdio.h> |
24 |
#include <stdio.h> |
24 |
#include <string.h> |
25 |
#include <string.h> |
25 |
@@ -57,9 +70,25 @@ |
26 |
@@ -58,9 +71,25 @@ |
26 |
#include "yellow.h" |
27 |
#include "yellow.h" |
27 |
#include "page.h" |
28 |
#include "page.h" |
28 |
|
29 |
|
29 |
+struct mca_record { |
30 |
+struct mca_record { |
30 |
+ uint64_t mr_status; |
31 |
+ uint64_t mr_status; |
31 |
+ uint64_t mr_addr; |
32 |
+ uint64_t mr_addr; |
32 |
+ uint64_t mr_misc; |
33 |
+ uint64_t mr_misc; |
33 |
+ uint64_t mr_tsc; |
34 |
+ uint64_t mr_tsc; |
34 |
+ int mr_apic_id; |
35 |
+ int mr_apic_id; |
35 |
+ int mr_bank; |
36 |
+ int mr_bank; |
36 |
+ uint64_t mr_mcg_cap; |
37 |
+ uint64_t mr_mcg_cap; |
37 |
+ uint64_t mr_mcg_status; |
38 |
+ uint64_t mr_mcg_status; |
38 |
+ int mr_cpu_id; |
39 |
+ int mr_cpu_id; |
39 |
+ int mr_cpu_vendor_id; |
40 |
+ int mr_cpu_vendor_id; |
40 |
+ int mr_cpu; |
41 |
+ int mr_cpu; |
41 |
+}; |
42 |
+}; |
42 |
+ |
43 |
+ |
43 |
enum cputype cputype = CPU_GENERIC; |
44 |
enum cputype cputype = CPU_GENERIC; |
Lines 48-54
Link Here
|
48 |
|
49 |
|
49 |
int ignore_nodev; |
50 |
int ignore_nodev; |
50 |
int filter_bogus = 1; |
51 |
int filter_bogus = 1; |
51 |
@@ -70,12 +99,18 @@ |
52 |
@@ -71,12 +100,18 @@ |
52 |
int dump_raw_ascii; |
53 |
int dump_raw_ascii; |
53 |
int daemon_mode; |
54 |
int daemon_mode; |
54 |
static char *inputfile; |
55 |
static char *inputfile; |
Lines 67-73
Link Here
|
67 |
|
68 |
|
68 |
static void check_cpu(void); |
69 |
static void check_cpu(void); |
69 |
|
70 |
|
70 |
@@ -388,6 +423,7 @@ |
71 |
@@ -393,6 +428,7 @@ |
71 |
Wprintf("\n"); |
72 |
Wprintf("\n"); |
72 |
} |
73 |
} |
73 |
|
74 |
|
Lines 75-81
Link Here
|
75 |
void check_cpu(void) |
76 |
void check_cpu(void) |
76 |
{ |
77 |
{ |
77 |
enum { |
78 |
enum { |
78 |
@@ -455,7 +491,44 @@ |
79 |
@@ -460,7 +496,45 @@ |
79 |
} else |
80 |
} else |
80 |
Eprintf("warning: Cannot open /proc/cpuinfo\n"); |
81 |
Eprintf("warning: Cannot open /proc/cpuinfo\n"); |
81 |
} |
82 |
} |
Lines 92-97
Link Here
|
92 |
+ |
93 |
+ |
93 |
+ if (checked) |
94 |
+ if (checked) |
94 |
+ return; |
95 |
+ return; |
|
|
96 |
+ |
95 |
+ checked = 1; |
97 |
+ checked = 1; |
96 |
+ |
98 |
+ |
97 |
+ do_cpuid(0, regs); |
99 |
+ do_cpuid(0, regs); |
Lines 104-126
Link Here
|
104 |
+ cpu_id = regs[0]; |
106 |
+ cpu_id = regs[0]; |
105 |
+ family = CPUID_TO_FAMILY(cpu_id); |
107 |
+ family = CPUID_TO_FAMILY(cpu_id); |
106 |
+ model = CPUID_TO_MODEL(cpu_id); |
108 |
+ model = CPUID_TO_MODEL(cpu_id); |
107 |
|
109 |
+ |
108 |
+ if (cpu_forced) |
110 |
+ if (cpu_forced) |
109 |
+ ; |
111 |
+ ; |
110 |
+ else if (!strcmp(vendor,"AuthenticAMD") && |
112 |
+ else if (!strcmp(vendor,"AuthenticAMD") && |
111 |
+ (family == 15 || family == 16 || family == 17)) |
113 |
+ (family == 15 || family == 16 || family == 17)) |
112 |
+ cputype = CPU_K8; |
114 |
+ cputype = CPU_K8; |
113 |
+ else if (!strcmp(vendor,"GenuineIntel")) |
115 |
+ else if (!strcmp(vendor,"GenuineIntel")) |
114 |
+ cputype = select_intel_cputype(family, model); |
116 |
+ cputype = select_intel_cputype(family, model); |
115 |
+ /* Add checks for other CPUs here */ |
117 |
+ /* Add checks for other CPUs here */ |
116 |
+} |
118 |
+} |
117 |
+#endif |
119 |
+#endif |
118 |
+ |
120 |
|
119 |
+#ifdef __Linux__ |
121 |
+#ifdef __Linux__ |
120 |
static char *skipspace(char *s) |
122 |
static char *skipspace(char *s) |
121 |
{ |
123 |
{ |
122 |
while (isspace(*s)) |
124 |
while (isspace(*s)) |
123 |
@@ -479,6 +552,7 @@ |
125 |
@@ -484,6 +558,7 @@ |
124 |
} |
126 |
} |
125 |
return skipspace(s); |
127 |
return skipspace(s); |
126 |
} |
128 |
} |
Lines 128-142
Link Here
|
128 |
|
130 |
|
129 |
static void dump_mce_final(struct mce *m, char *symbol, int missing, int recordlen, |
131 |
static void dump_mce_final(struct mce *m, char *symbol, int missing, int recordlen, |
130 |
int dseen) |
132 |
int dseen) |
131 |
@@ -501,6 +575,7 @@ |
133 |
@@ -507,6 +582,7 @@ |
132 |
if (recordlen < endof_field(struct mce, f)) \ |
|
|
133 |
recordlen = endof_field(struct mce, f) |
134 |
recordlen = endof_field(struct mce, f) |
134 |
|
135 |
|
135 |
+#ifdef __Linux__ |
|
|
136 |
/* Decode ASCII input for fatal messages */ |
136 |
/* Decode ASCII input for fatal messages */ |
|
|
137 |
+#ifdef __Linux__ |
137 |
static void decodefatal(FILE *inf) |
138 |
static void decodefatal(FILE *inf) |
138 |
{ |
139 |
{ |
139 |
@@ -646,6 +721,227 @@ |
140 |
struct mce m; |
|
|
141 |
@@ -651,6 +727,227 @@ |
140 |
if (data) |
142 |
if (data) |
141 |
dump_mce_final(&m, symbol, missing, recordlen, disclaimer_seen); |
143 |
dump_mce_final(&m, symbol, missing, recordlen, disclaimer_seen); |
142 |
} |
144 |
} |
Lines 364-381
Link Here
|
364 |
|
366 |
|
365 |
static void remove_pidfile(void) |
367 |
static void remove_pidfile(void) |
366 |
{ |
368 |
{ |
367 |
@@ -686,6 +982,10 @@ |
369 |
@@ -709,6 +1006,10 @@ |
368 |
" mcelog [options] --ascii < log\n" |
370 |
" mcelog [options] --ascii < log\n" |
369 |
" mcelog [options] --ascii --file log\n" |
371 |
" mcelog [options] --ascii --file log\n" |
370 |
"Decode machine check ASCII output from kernel logs\n" |
372 |
"Decode machine check ASCII output from kernel logs\n" |
371 |
+#ifdef __FreeBSD__ |
373 |
+#ifdef __FreeBSD_ |
372 |
+" mcelog [options] -M vmcore -N kernel\n" |
374 |
+" mcelog [options] -M vmcore -N kernel\n" |
373 |
+"Decode machine check error records from kernel crashdump.\n" |
375 |
+"Decode machine check error records from kernel crashdump.\n" |
374 |
+#endif |
376 |
+#endif |
375 |
"Options:\n" |
377 |
"Options:\n" |
376 |
"--cpu CPU Set CPU type CPU to decode (see below for valid types)\n" |
378 |
"--cpu CPU Set CPU type CPU to decode (see below for valid types)\n" |
377 |
"--cpumhz MHZ Set CPU Mhz to decode time (output unreliable, not needed on new kernels)\n" |
379 |
"--cpumhz MHZ Set CPU Mhz to decode time (output unreliable, not needed on new kernels)\n" |
378 |
@@ -866,6 +1166,14 @@ |
380 |
@@ -889,6 +1190,14 @@ |
379 |
case O_CONFIG_FILE: |
381 |
case O_CONFIG_FILE: |
380 |
/* parsed in config.c */ |
382 |
/* parsed in config.c */ |
381 |
break; |
383 |
break; |
Lines 390-396
Link Here
|
390 |
case 0: |
392 |
case 0: |
391 |
break; |
393 |
break; |
392 |
default: |
394 |
default: |
393 |
@@ -900,8 +1208,10 @@ |
395 |
@@ -923,8 +1232,10 @@ |
394 |
|
396 |
|
395 |
static void general_setup(void) |
397 |
static void general_setup(void) |
396 |
{ |
398 |
{ |
Lines 401-407
Link Here
|
401 |
config_cred("global", "run-credentials", &runcred); |
403 |
config_cred("global", "run-credentials", &runcred); |
402 |
if (config_bool("global", "filter-memory-errors") == 1) |
404 |
if (config_bool("global", "filter-memory-errors") == 1) |
403 |
filter_memory_errors = 1; |
405 |
filter_memory_errors = 1; |
404 |
@@ -924,6 +1234,7 @@ |
406 |
@@ -947,6 +1258,7 @@ |
405 |
} |
407 |
} |
406 |
} |
408 |
} |
407 |
|
409 |
|
Lines 409-415
Link Here
|
409 |
static void process(int fd, unsigned recordlen, unsigned loglen, char *buf) |
411 |
static void process(int fd, unsigned recordlen, unsigned loglen, char *buf) |
410 |
{ |
412 |
{ |
411 |
int i; |
413 |
int i; |
412 |
@@ -964,6 +1275,173 @@ |
414 |
@@ -987,6 +1299,173 @@ |
413 |
if (finish) |
415 |
if (finish) |
414 |
exit(0); |
416 |
exit(0); |
415 |
} |
417 |
} |
Lines 583-589
Link Here
|
583 |
|
585 |
|
584 |
static void noargs(int ac, char **av) |
586 |
static void noargs(int ac, char **av) |
585 |
{ |
587 |
{ |
586 |
@@ -1022,22 +1500,30 @@ |
588 |
@@ -1045,22 +1524,30 @@ |
587 |
char *buf; |
589 |
char *buf; |
588 |
}; |
590 |
}; |
589 |
|
591 |
|
Lines 607-622
Link Here
|
607 |
|
609 |
|
608 |
parse_config(av); |
610 |
parse_config(av); |
609 |
|
611 |
|
610 |
- while ((opt = getopt_long(ac, av, "", options, NULL)) != -1) { |
|
|
611 |
+#ifdef __FreeBSD__ |
612 |
+#ifdef __FreeBSD__ |
612 |
+ while ((opt = getopt_long(ac, av, "M:N:", options, NULL)) != -1) { |
613 |
+ while ((opt = getopt_long(ac, av, "M:N:", options, NULL)) != -1) { |
613 |
+#else |
614 |
+#else |
614 |
+ while ((opt = getopt_long(ac, av, "", options, NULL)) != -1) { |
615 |
while ((opt = getopt_long(ac, av, "", options, NULL)) != -1) { |
615 |
+#endif |
616 |
+#endif |
616 |
if (opt == '?') { |
617 |
if (opt == '?') { |
617 |
usage(); |
618 |
usage(); |
618 |
} else if (combined_modifier(opt) > 0) { |
619 |
} else if (combined_modifier(opt) > 0) { |
619 |
@@ -1057,13 +1543,21 @@ |
620 |
@@ -1080,13 +1567,21 @@ |
620 |
} else if (opt == 0) |
621 |
} else if (opt == 0) |
621 |
break; |
622 |
break; |
622 |
} |
623 |
} |
Lines 638-644
Link Here
|
638 |
fd = open(logfn, O_RDONLY); |
639 |
fd = open(logfn, O_RDONLY); |
639 |
if (fd < 0) { |
640 |
if (fd < 0) { |
640 |
if (ignore_nodev) |
641 |
if (ignore_nodev) |
641 |
@@ -1078,24 +1572,39 @@ |
642 |
@@ -1101,24 +1596,39 @@ |
642 |
err("MCE_GET_LOG_LEN"); |
643 |
err("MCE_GET_LOG_LEN"); |
643 |
|
644 |
|
644 |
d.buf = xalloc(d.recordlen * d.loglen); |
645 |
d.buf = xalloc(d.recordlen * d.loglen); |