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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/errl/runtime/rt_errlmanager.C $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2013,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
/* implied. See the License for the specific language governing */
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
/*****************************************************************************/
// I n c l u d e s
/*****************************************************************************/
#include <errl/errlmanager.H>
#include <trace/interface.H>
#include <errl/errlentry.H>
#include <sys/task.h>
#include <stdlib.h>
#include <string.h>
#include <runtime/interface.h> // g_hostInterfaces
#include <util/runtime/rt_fwreq_helper.H> // firmware_request_helper
#include <targeting/common/targetservice.H>
#include <pnor/pnorif.H>
#include <hwas/common/deconfigGard.H>
#include <initservice/initserviceif.H> // spBaseServiceEnabled()
namespace ERRORLOG
{
// Allow Hidden error logs to be shown by default
uint8_t ErrlManager::iv_hiddenErrLogsEnable =
TARGETING::HIDDEN_ERRLOGS_ENABLE_ALLOW_ALL_LOGS;
extern trace_desc_t* g_trac_errl;
//////////////////////////////////////////////////////////////////////////////
// Local functions
//////////////////////////////////////////////////////////////////////////////
/**
* Override the HWAS processCallout function at runtime
* @param[in] io_errl Error log handle reference
* @param[in] i_pData Pointer to the callout bundle
* @param[in] i_Size size of the data in the callout bundle
* @param[in] i_DeferredOnly bool - true if ONLY check for defered deconfig
*/
bool rt_processCallout(errlHndl_t &io_errl,
uint8_t * i_pData,
uint64_t i_Size,
bool i_DeferredOnly);
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
ErrlManager::ErrlManager() :
iv_currLogId(0),
iv_baseNodeId(ERRLOG_PLID_BASE_MASK),
iv_pnorReadyForErrorLogs(true),
iv_pStorage(NULL),
iv_hwasProcessCalloutFn(NULL),
iv_pnorAddr(NULL),
iv_maxErrlInPnor(0),
iv_pnorOpenSlot(0),
iv_isSpBaseServices(false),
#ifdef CONFIG_BMC_IPMI
iv_isIpmiEnabled(true)
#else
iv_isIpmiEnabled(false)
#endif
{
TRACFCOMP( g_trac_errl, ENTER_MRK "ErrlManager::ErrlManager constructor." );
iv_hwasProcessCalloutFn = rt_processCallout;
// determine starting PLID value
TARGETING::Target * sys = NULL;
if( TARGETING::targetService().isInitialized() )
{
TARGETING::targetService().getTopLevelTarget( sys );
}
else
{
TRACFCOMP( g_trac_errl, "Error log being created before "
"TARGETING is ready..." );
}
if(sys)
{
iv_currLogId = sys->getAttr<TARGETING::ATTR_HOSTSVC_PLID>();
TRACFCOMP( g_trac_errl,"Initial Error Log ID = %.8X", iv_currLogId );
// set whether we want to skip certain error logs or not.
iv_hiddenErrLogsEnable =
sys->getAttr<TARGETING::ATTR_HIDDEN_ERRLOGS_ENABLE>();
TRACFCOMP( g_trac_errl,"iv_hiddenErrorLogsEnable = 0x%x",
iv_hiddenErrLogsEnable );
}
else
{
iv_currLogId = 0x89bad000;
TRACFCOMP( g_trac_errl, ERR_MRK"HOSTSVC_PLID not available" );
}
// check if there's an FSP. if not, then we write to PNOR
TARGETING::SpFunctions spfn;
if (!(sys &&
sys->tryGetAttr<TARGETING::ATTR_SP_FUNCTIONS>(spfn) &&
spfn.baseServices))
{
iv_isSpBaseServices = false;
TRACFCOMP( g_trac_errl, INFO_MRK"no baseServices, setting "
"up to save to pnor" );
setupPnorInfo();
}
else
{
iv_isSpBaseServices = true;
}
TRACFCOMP( g_trac_errl, EXIT_MRK "ErrlManager::ErrlManager constructor." );
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
ErrlManager::~ErrlManager()
{
TRACFCOMP( g_trac_errl, INFO_MRK"ErrlManager::ErrlManager destructor" );
if (!iv_isSpBaseServices)
{
// if we saved to PNOR, we need to flush
TRACFCOMP( g_trac_errl, INFO_MRK"no baseServices, flushing pnor" );
PNOR::flush(PNOR::HB_ERRLOGS);
}
}
///////////////////////////////////////////////////////////////////////////////
// ErrlManager::sendMboxMsg()
///////////////////////////////////////////////////////////////////////////////
void ErrlManager::sendMboxMsg ( errlHndl_t& io_err )
{
// Put the handle to the firmware_request request struct
// out here so it is easier to free later
hostInterfaces::hbrt_fw_msg *l_req_fw_msg = nullptr;
do
{
if (!iv_isSpBaseServices)
{
// save to PNOR
TRACFCOMP( g_trac_errl, INFO_MRK"no baseServices, saving to pnor" );
bool l_savedToPnor = saveErrLogToPnor(io_err);
if (!l_savedToPnor)
{
TRACFCOMP( g_trac_errl, ENTER_MRK"saveErrLogToPnor "
"didn't save 0x%X", io_err->eid());
}
}
#ifdef CONFIG_BMC_IPMI
TRACFCOMP(g_trac_errl,INFO_MRK"Send msg to BMC for errlogId [0x%08x]",
io_err->plid() );
// convert to SEL/eSEL and send to BMC over IPMI
sendErrLogToBmc(io_err);
#else
TRACDCOMP(g_trac_errl,
INFO_MRK"Send msg to FSP for errlogId [0x%08x]",
io_err->plid() );
if(g_hostInterfaces)
{
uint32_t l_msgSize = io_err->flattenedSize();
if (g_hostInterfaces->sendErrorLog)
{
uint8_t * temp_buff = new uint8_t [l_msgSize ];
io_err->flatten ( temp_buff, l_msgSize );
size_t rc = g_hostInterfaces->sendErrorLog(io_err->plid(),
l_msgSize,
temp_buff);
if(rc)
{
TRACFCOMP(g_trac_errl,
ERR_MRK"Failed sending error log to FSP via "
"sendErrorLog. rc: %d. plid: 0x%08x",
rc,
io_err->plid() );
}
delete [] temp_buff;
}
else if (g_hostInterfaces->firmware_request)
{
// Get an accurate size of memory needed to transport
// the data for the firmware_request request struct
uint64_t l_req_fw_msg_size =
hostInterfaces::HBRT_FW_MSG_BASE_SIZE +
sizeof(hostInterfaces::hbrt_fw_msg::error_log) +
l_msgSize -
sizeof(hostInterfaces::hbrt_fw_msg::error_log.i_data);
// Create the firmware_request request struct to send data
hostInterfaces::hbrt_fw_msg *l_req_fw_msg =
(hostInterfaces::hbrt_fw_msg *)malloc(l_req_fw_msg_size);
memset(l_req_fw_msg, 0, l_req_fw_msg_size);
// Populate the firmware_request request struct with given data
l_req_fw_msg->io_type =
hostInterfaces::HBRT_FW_MSG_TYPE_ERROR_LOG;
l_req_fw_msg->error_log.i_plid = io_err->plid();
l_req_fw_msg->error_log.i_errlSize = l_msgSize;
io_err->flatten (&(l_req_fw_msg->error_log.i_data), l_msgSize);
// Trace out firmware request info
TRACFCOMP(g_trac_errl,
INFO_MRK"Error log firmware request info: "
"io_type:%d, plid: 0x%08x, errlSize:%d",
l_req_fw_msg->io_type,
l_req_fw_msg->error_log.i_plid,
l_req_fw_msg->error_log.i_errlSize);
TRACFBIN(g_trac_errl, "Error log firmware request data: ",
&(l_req_fw_msg->error_log.i_data),
l_req_fw_msg->error_log.i_errlSize);
// Create the firmware_request response struct to receive data
hostInterfaces::hbrt_fw_msg l_resp_fw_msg;
uint64_t l_resp_fw_msg_size = sizeof(l_resp_fw_msg);
memset(&l_resp_fw_msg, 0, l_resp_fw_msg_size);
// Make the firmware_request call
errlHndl_t l_err = firmware_request_helper(l_req_fw_msg_size,
l_req_fw_msg,
&l_resp_fw_msg_size,
&l_resp_fw_msg);
// Should not get an error log, but if it happens,
// just delete it.
delete l_err, l_err = nullptr;
}
else
{
TRACFCOMP(g_trac_errl, ERR_MRK
"Host interfaces sendErrorLog and firmware_request "
"not initialized, error log not sent. plid: 0x%08x",
io_err->plid()
);
}
}
else
{
TRACFCOMP(g_trac_errl, ERR_MRK
"Host interfaces not initialized, error log not sent. "
"plid: 0x%08x",
io_err->plid()
);
}
#endif
delete io_err;
io_err = NULL;
} while (0);
// Release the firmware_request request struct
free(l_req_fw_msg);
l_req_fw_msg = nullptr;
TRACFCOMP( g_trac_errl, EXIT_MRK"sendToHypervisor()" );
return;
}
///////////////////////////////////////////////////////////////////////////////
// Handling commit error log.
///////////////////////////////////////////////////////////////////////////////
void ErrlManager::commitErrLog(errlHndl_t& io_err, compId_t i_committerComp )
{
TRACDCOMP( g_trac_errl, ENTER_MRK"ErrlManager::commitErrLog" );
do
{
if (io_err == NULL)
{
// put out warning trace
TRACFCOMP(g_trac_errl, ERR_MRK "commitErrLog() - NULL pointer");
break;
}
// Increment our persistent counter so we don't reuse EIDs
// after reboots or mpipl
TARGETING::Target * sys = NULL;
if( TARGETING::targetService().isInitialized() )
{
TARGETING::targetService().getTopLevelTarget( sys );
sys->setAttr<TARGETING::ATTR_HOSTSVC_PLID>(io_err->eid()+1);
}
TRACFCOMP(g_trac_errl, "commitErrLog() called by %.4X for plid=0x%X,"
"Reasoncode=%.4X", i_committerComp,
io_err->plid(), io_err->reasonCode() );
// Deferred callouts not allowed at runtime - this call will check,
// flag and change any that are found.
io_err->deferredDeconfigure();
TRACFCOMP( g_trac_errl, INFO_MRK
"Send an error log to hypervisor to commit. plid=0x%X",
io_err->plid() );
io_err->commit(i_committerComp);
sendMboxMsg(io_err);
io_err = NULL;
} while( 0 );
TRACDCOMP( g_trac_errl, EXIT_MRK"ErrlManager::commitErrLog" );
return;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void ErrlManager::setHwasProcessCalloutFn(HWAS::processCalloutFn i_fn)
{
ERRORLOG::theErrlManager::instance().iv_hwasProcessCalloutFn = i_fn;
}
// Runtime processCallout
bool rt_processCallout(errlHndl_t &io_errl,
uint8_t * i_pData,
uint64_t i_Size,
bool i_DeferredOnly)
{
HWAS::callout_ud_t *pCalloutUD = (HWAS::callout_ud_t *)i_pData;
if(i_DeferredOnly)
{
if ((pCalloutUD->type == HWAS::HW_CALLOUT) &&
((pCalloutUD->deconfigState == HWAS::DELAYED_DECONFIG) ||
(pCalloutUD->deconfigState == HWAS::DECONFIG)))
{
pCalloutUD->deconfigState = HWAS::NO_DECONFIG;
TRACFCOMP( g_trac_errl, ERR_MRK
"Runtime errorlog callout with DELAYED_DECONFIG or "
"DECONFIG not allowed! Changed to NO_DECONFIG. "
" plid: 0x%X. Deconfig State: 0x%x", io_errl->plid(),
pCalloutUD->deconfigState);
}
}
// Gard callouts are handled by the HWSV if there is an FSP
// if we attempt to create a gard record it requires us to read
// PNOR which we cannot do on FSP based machines
if(!INITSERVICE::spBaseServicesEnabled())
{
if ((pCalloutUD->type == HWAS::HW_CALLOUT) &&
(pCalloutUD->gardErrorType != HWAS::GARD_NULL))
{
TARGETING::Target *pTarget = NULL;
uint8_t * l_uData = (uint8_t *)(pCalloutUD + 1);
bool l_err = HWAS::retrieveTarget(l_uData, pTarget, io_errl);
if (!l_err)
{
errlHndl_t errl = HWAS::theDeconfigGard().platCreateGardRecord
(pTarget,
io_errl->eid(),
pCalloutUD->gardErrorType);
if (errl)
{
TRACFCOMP( g_trac_errl, ERR_MRK
"rt_processCallout: error from platCreateGardRecord");
errlCommit(errl, HWAS_COMP_ID);
}
}
}
}
return true;
}
} // End namespace
//------------------------------------------------------------------------
void initErrlManager(void)
{
// Note: rtPnor needs to be setup before this is called
// call errlManager ctor so that we're ready and waiting for errors.
ERRORLOG::theErrlManager::instance();
}
struct registerInitErrlManager
{
registerInitErrlManager()
{
// Register interface for Host to call
postInitCalls_t * rt_post = getPostInitCalls();
rt_post->callInitErrlManager = &initErrlManager;
}
};
registerInitErrlManager g_registerInitErrlManager;
|