-
Notifications
You must be signed in to change notification settings - Fork 63
/
unknown.c
85 lines (73 loc) · 2.17 KB
/
unknown.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* Copyright (C) 20014 Intel Corporation
Author: Rui Wang
Handle all other unknown error requests.
mcelog 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; version
2.
mcelog is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should find a copy of v2 of the GNU General Public License somewhere
on your Linux system. */
#define _GNU_SOURCE 1
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include "memutil.h"
#include "mcelog.h"
#include "config.h"
#include "trigger.h"
#include "unknown.h"
static char *unknown_trigger;
enum {
MAX_ENV = 20,
};
void unknown_setup(void)
{
unknown_trigger = config_string("socket", "unknown-threshold-trigger");
if (unknown_trigger && trigger_check(unknown_trigger) < 0) {
SYSERRprintf("Cannot access unknown threshold trigger `%s'",
unknown_trigger);
exit(1);
}
}
void run_unknown_trigger(int socket, int cpu, struct mce *log)
{
int ei = 0;
char *env[MAX_ENV];
int i;
char *msg;
char *location;
if (!unknown_trigger)
return;
if (socket >= 0)
xasprintf(&location, "CPU %d on socket %d", cpu, socket);
else
xasprintf(&location, "CPU %d", cpu);
xasprintf(&msg, "%s received unknown error", location);
xasprintf(&env[ei++], "LOCATION=%s", location);
free(location);
location = NULL;
if (socket >= 0)
xasprintf(&env[ei++], "SOCKETID=%d", socket);
xasprintf(&env[ei++], "MESSAGE=%s", msg);
xasprintf(&env[ei++], "CPU=%d", cpu);
xasprintf(&env[ei++], "STATUS=%llx", log->status);
xasprintf(&env[ei++], "MISC=%llx", log->misc);
xasprintf(&env[ei++], "ADDR=%llx", log->addr);
xasprintf(&env[ei++], "MCGSTATUS=%llx", log->mcgstatus);
xasprintf(&env[ei++], "MCGCAP=%llx", log->mcgcap);
env[ei] = NULL;
assert(ei < MAX_ENV);
run_trigger(unknown_trigger, NULL, env, false, "unknown");
for (i = 0; i < ei; i++) {
free(env[i]);
env[i] = NULL;
}
free(msg);
msg = NULL;
}