/
istepdispatcher.C
2986 lines (2627 loc) · 106 KB
/
istepdispatcher.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
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
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/initservice/istepdispatcher/istepdispatcher.C $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2011,2018 */
/* [+] Google Inc. */
/* [+] 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 */
/**
* @file istepdispatcher.C
*
* IStep Dispatcher code. Launched from Extended Initialization Service
*
* PNOR Driver and Trace should be available by the time this is launched.
*
*/
/******************************************************************************/
// Includes
/******************************************************************************/
#include <stdint.h>
#include <sys/time.h> //nanosleep
#include <kernel/console.H> // printk status
#include <vfs/vfs.H> // for VFS::module_load
#include <sys/task.h> // tid_t, task_create, etc
#include <sys/misc.h> // cpu_all_winkle
#include <errl/errlentry.H> // errlHndl_t
#include <errl/errlmanager.H>
#include <initservice/isteps_trace.H> // ISTEPS_TRACE buffer
#include <initservice/initsvcudistep.H> // InitSvcUserDetailsIstep
#include <initservice/taskargs.H> // TASK_ENTRY_MACRO
#include <targeting/common/targetservice.H>
#include <targeting/attrsync.H>
#include <fapi2/plat_attr_override_sync.H>
#include <mbox/mbox_queues.H> // HB_ISTEP_MSGQ
#include <mbox/mboxif.H> // register mailbox
#include <intr/interrupt.H>
#include <isteps/istepmasterlist.H>
#include "istepdispatcher.H"
#include "istep_mbox_msgs.H"
#include "splesscommon.H"
#include <diag/attn/attn.H>
#include <isteps/istep_reasoncodes.H>
#include <hwas/common/deconfigGard.H>
#include <hwas/common/hwas.H>
#include <hwas/hwasPlat.H>
#include <targeting/attrPlatOverride.H>
#include <console/consoleif.H>
#include <isteps/hwpisteperror.H>
#include <pnor/pnorif.H>
#include <lpc/lpcif.H>
#include <istep18/establish_system_smp.H>
#ifdef CONFIG_BMC_IPMI
#include <ipmi/ipmiwatchdog.H> //IPMI watchdog timer
#include <ipmi/ipmipowerstate.H> //IPMI System ACPI Power State
#include <ipmi/ipmichassiscontrol.H>
#include <ipmi/ipmisensor.H>
#include <ipmi/ipmiif.H>
#endif
#include <config.h>
#include <initservice/bootconfigif.H>
#include <trace/trace.H>
#include <util/utilmbox_scratch.H>
#include <secureboot/service.H>
#include <p9_perst_phb.H>
#include <plat_hwp_invoker.H>
// ---------------------------
// Used to grab SBE boot side
#include <sbe/sbe_update.H>
#include <devicefw/userif.H>
#include <p9_perv_scom_addresses.H>
// ---------------------------
namespace ISTEPS_TRACE
{
// declare storage for isteps_trace!
trace_desc_t * g_trac_isteps_trace = NULL;
TRAC_INIT(&ISTEPS_TRACE::g_trac_isteps_trace, "ISTEPS_TRACE", 2*KILOBYTE);
}
namespace INITSERVICE
{
/******************************************************************************/
// Globals/Constants
/******************************************************************************/
extern trace_desc_t *g_trac_initsvc;
const MBOX::queue_id_t HWSVRQ = MBOX::IPL_SERVICE_QUEUE;
const uint8_t SW_RECONFIG_START_STEP = 7;
const uint8_t SW_RECONFIG_START_SUBSTEP = 1;
const uint8_t HB_START_ISTEP = 6;
// @todo RTC 124679 - Remove Once BMC Monitors Shutdown Attention
// Set Watchdog Timer To 15 seconds before calling doShutdown()
const uint16_t SET_WD_TIMER_IN_SECS = 15;
/**
* _start() task entry procedure using the macro in taskargs.H
*/
TASK_ENTRY_MACRO( IStepDispatcher::getTheInstance().init );
// ----------------------------------------------------------------------------
// IstepDispatcher()
// ----------------------------------------------------------------------------
IStepDispatcher::IStepDispatcher() :
iv_syncPointReached(false),
iv_istepModulesLoaded(0),
iv_progressThreadStarted(false),
iv_highestIStepDone(0),
iv_highestSubstepDone(0),
iv_curIStep(0),
iv_curSubStep(0),
iv_pIstepMsg(NULL),
iv_shutdown(false),
iv_futureShutdown(false),
iv_istepToCompleteBeforeShutdown(0),
iv_substepToCompleteBeforeShutdown(0),
iv_acceptIstepMessages(true),
iv_newGardRecord(false),
iv_stopIpl(false),
iv_p9_phbPerstLibLoaded(false)
{
mutex_init(&iv_bkPtMutex);
mutex_init(&iv_mutex);
sync_cond_init(&iv_cond);
TARGETING::Target* l_pSys = NULL;
TARGETING::targetService().getTopLevelTarget(l_pSys);
iv_mpiplMode = l_pSys->getAttr<TARGETING::ATTR_IS_MPIPL_HB>();
TRACFCOMP(g_trac_initsvc, "IStepDispatcher: MPIPL Mode: %d", iv_mpiplMode);
iv_spBaseServicesEnabled = spBaseServicesEnabled();
TRACFCOMP(g_trac_initsvc, "IStepDispatcher: SP base Services Enabled: %d",
iv_spBaseServicesEnabled);
iv_mailboxEnabled = MBOX::mailbox_enabled();
TRACFCOMP(g_trac_initsvc, "IStepDispatcher: Mailbox Enabled: %d",
iv_mailboxEnabled);
if (iv_spBaseServicesEnabled)
{
// SP Base Services Enabled implies that HWSV is running. If this is
// true then the mailbox must be enabled
assert(iv_mailboxEnabled);
}
// Note that if SP Base Services are not enabled and the Mailbox is enabled
// then Cronus is sending messages to Hostboot.
clock_gettime(CLOCK_MONOTONIC, &iv_lastProgressMsgTime);
iv_msgQ = msg_q_create();
}
// ----------------------------------------------------------------------------
// ~IstepDispatcher()
// ----------------------------------------------------------------------------
IStepDispatcher::~IStepDispatcher ()
{
TRACFCOMP( g_trac_initsvc, ENTER_MRK "IStepDispatcher::~IStepDispatcher "
"destructor" );
// Singleton destructor gets run when module gets unloaded.
// The istepdispatcher module never gets unloaded. So rather to send a
// message to error log daemon and tell it to shutdown and delete
// the queue we will assert here because the destructor never gets
// call.
assert(0);
}
// ----------------------------------------------------------------------------
// IstepDispatcher::getTheInstance()
// ----------------------------------------------------------------------------
IStepDispatcher& IStepDispatcher::getTheInstance()
{
return Singleton<IStepDispatcher>::instance();
}
// ----------------------------------------------------------------------------
// IStepDispatcher::init()
// ----------------------------------------------------------------------------
void IStepDispatcher::init(errlHndl_t &io_rtaskRetErrl)
{
errlHndl_t err = NULL;
printk( "IStepDispatcher entry.\n" );
TRACFCOMP( g_trac_initsvc, "IStepDispatcher entry." );
// Read and process the Hostboot configuration flags
BOOTCONFIG::readAndProcessBootConfig();
TARGETING::Target* l_pTopLevelTarget = NULL;
TARGETING::targetService().getTopLevelTarget(l_pTopLevelTarget);
assert(l_pTopLevelTarget != NULL );
do
{
// Need to get ATTR overrides first if non FSP system
if(!iv_spBaseServicesEnabled)
{
PNOR::SectionInfo_t l_sectionInfo;
// Get temporary attribute overrides from pnor
err = PNOR::getSectionInfo(PNOR::ATTR_TMP, l_sectionInfo);
// Attr override sections are optional so just delete error
if (err)
{
delete err;
err = NULL;
}
else
{
TRACFCOMP(g_trac_initsvc,"init: processing temporary "
"overrides");
err = TARGETING::getAttrOverrides(l_sectionInfo);
if (err)
{
TRACFCOMP(g_trac_initsvc,"Failed getAttrOverrides: "
"getting temporary overrides");
break;
}
}
// Get permanent attribute overrides from pnor
err = PNOR::getSectionInfo(PNOR::ATTR_PERM, l_sectionInfo);
// Attr override sections are optional so just delete error
if (err)
{
delete err;
err = NULL;
}
else
{
TRACFCOMP(g_trac_initsvc,"init: processing permanent"
" overrides");
err = TARGETING::getAttrOverrides(l_sectionInfo);
if (err)
{
TRACFCOMP(g_trac_initsvc,"Failed getAttrOverrides: "
"getting permanent overrides");
break;
}
}
}
iv_istepMode = l_pTopLevelTarget->getAttr<TARGETING::ATTR_ISTEP_MODE>();
TRACFCOMP(g_trac_initsvc, "IStepDispatcher: IStep Mode: %d", iv_istepMode);
// Get tracelite setting from top level target attributes
TARGETING::Target* l_pSys = NULL;
TARGETING::targetService().getTopLevelTarget(l_pSys);
#ifdef CONFIG_INCLUDE_XML_OPENPOWER
uint8_t l_tlEnabled = l_pSys->getAttr<TARGETING::ATTR_OP_TRACE_LITE>();
TRACE::setTraceLite(l_tlEnabled);
#endif
//////////////////
// Send to console which SBE side we are currently on
//////////////////
SBE::sbeSeepromSide_t l_bootside = SBE::SBE_SEEPROM_INVALID;
TARGETING::Target * l_masterTarget = nullptr;
TARGETING::targetService().masterProcChipTargetHandle(l_masterTarget);
// NOTE: can't just call SBE::getSbeBootSeeprom(..) as it isn't loaded
uint64_t scomData = 0x0;
// Read PERV_SB_CS_SCOM 0x00050008
size_t op_size = sizeof(scomData);
err = deviceRead( l_masterTarget,
&scomData,
op_size,
DEVICE_SCOM_ADDRESS(PERV_SB_CS_SCOM) );
if( err )
{
TRACFCOMP( g_trac_initsvc, ERR_MRK"IStepDispatcher() - "
"Unable to find SBE boot side, Error "
"reading SB CS SCOM (0x%.8X) from Target :"
"HUID=0x%.8X, RC=0x%X, PLID=0x%lX",
PERV_SB_CS_SCOM, // 0x00050008
TARGETING::get_huid(l_masterTarget),
ERRL_GETRC_SAFE(err),
ERRL_GETPLID_SAFE(err));
err->collectTrace("INITSVC", 1024);
errlCommit(err, INITSVC_COMP_ID );
}
else
{
if(scomData & SBE::SBE_BOOT_SELECT_MASK)
{
l_bootside = SBE::SBE_SEEPROM1;
}
else
{
l_bootside = SBE::SBE_SEEPROM0;
}
TRACFCOMP( g_trac_initsvc,
INFO_MRK"IStepDispatcher(): SBE boot side %d for proc=%.8X",
l_bootside, TARGETING::get_huid(l_masterTarget) );
#ifdef CONFIG_CONSOLE
// Sending to console SBE side
CONSOLE::displayf( NULL,
"Booting from SBE side %d on master proc=%.8X",
l_bootside, TARGETING::get_huid(l_masterTarget) );
CONSOLE::flush();
#endif
}
////////////////
if(iv_mailboxEnabled)
{
// Register message Q with FSP Mailbox
err = MBOX::msgq_register( MBOX::HB_ISTEP_MSGQ, iv_msgQ );
if(err)
{
if (err->sev() == ERRORLOG::ERRL_SEV_INFORMATIONAL)
{
err->setSev(ERRORLOG::ERRL_SEV_UNRECOVERABLE);
}
TRACFCOMP(g_trac_initsvc,
"ERROR: Failed to register mailbox, terminating");
break;
}
}
#ifdef CONFIG_BMC_IPMI
//set ACPI power state
errlHndl_t err_ipmi = IPMI::setACPIPowerState();
if(err_ipmi)
{
TRACFCOMP(g_trac_initsvc,
"init: ERROR: IPMI set ACPI Power State Failed");
err_ipmi->collectTrace("INITSVC", 1024);
errlCommit(err_ipmi, INITSVC_COMP_ID );
}
#endif
if(iv_istepMode)
{
// In IStep mode (receive messages to run individual steps)
// always listen to debug interface. If on FSP this allows
// both HWSV, Cronus, and debug tools to control the IPL
TRACFCOMP(g_trac_initsvc, "IStep mode, start debug 'spless' interface");
tid_t spTaskTid = task_create(spTask, iv_msgQ);
assert(spTaskTid > 0);
// Call the message handler to handle messages from FSP or SPless
// user console, these messages include the IStep messages. This
// function never returns.
msgHndlr();
}
else
{
#ifdef CONFIG_BMC_IPMI
//run the ipmi watchdog in non istep mode only
errlHndl_t err_ipmi = IPMIWATCHDOG::setWatchDogTimer(
IPMIWATCHDOG::DEFAULT_WATCHDOG_COUNTDOWN);
if(err_ipmi)
{
TRACFCOMP(g_trac_initsvc,
"init: ERROR: Set IPMI watchdog Failed");
err_ipmi->collectTrace("INITSVC", 1024);
errlCommit(err_ipmi, INITSVC_COMP_ID );
}
#endif
// Non-IStep mode (run all isteps automatically)
if(iv_spBaseServicesEnabled)
{
// Base Services available. Figure out if HWSV has overrides
uint8_t l_attrOverridesExist = 0;
l_attrOverridesExist = l_pTopLevelTarget->
getAttr<TARGETING::ATTR_PLCK_IPL_ATTR_OVERRIDES_EXIST>();
if (l_attrOverridesExist && SECUREBOOT::allowAttrOverrides())
{
fapi2::theAttrOverrideSync().getAttrOverridesFromFsp();
}
// Start a new thread to handle non-IStep messages from the FSP
// (e.g. sync point reached)
tid_t msgHndlrTaskTid = task_create(startMsgHndlrThread, this);
assert(msgHndlrTaskTid > 0);
}
//Update Targeting in the Event Attribute Overrides apply to that logic
// This will refresh cached values for attrs like
// ATTR_HIDDEN_ERRLOGS_ENABLE
ERRORLOG::ErrlManager::errlResourceReady(ERRORLOG::TARG);
err = executeAllISteps();
if(err)
{
TRACFCOMP(g_trac_initsvc, "ERROR: Failed executing all isteps,"
" see %x for details", err->eid());
break;
}
// Send the potentially modified set of Attribute overrides and any
// Attributes to sync to the FSP
if(iv_spBaseServicesEnabled)
{
fapi2::theAttrOverrideSync().sendAttrOverridesAndSyncsToFsp();
}
}
} while(0);
TRACFCOMP( g_trac_initsvc, "IStepDispatcher finished.");
printk( "IStepDispatcher exit.\n" );
io_rtaskRetErrl = err;
}
// ----------------------------------------------------------------------------
// IStepDispatcher::executeAllISteps()
// ----------------------------------------------------------------------------
errlHndl_t IStepDispatcher::executeAllISteps()
{
errlHndl_t err = NULL;
uint32_t istep = 0;
uint32_t substep = 0;
bool l_doReconfig = false;
uint32_t numReconfigs = 0;
bool l_manufacturingMode = false;
// soft reconfig loops happen really fast
// and since for scale-out systems it only happens for istep 7
// there is no significant max time delay to recover the system
// because all in all other steps it will result in TI
const uint32_t MAX_NUM_RECONFIG_ATTEMPTS = 30;
TRACFCOMP(g_trac_initsvc, ENTER_MRK"IStepDispatcher::executeAllISteps()");
// Find out if in manufacturing mode
TARGETING::Target* l_pTopLevel = nullptr;
TARGETING::targetService().getTopLevelTarget(l_pTopLevel);
// Assert if we still have a nullptr target
assert(l_pTopLevel != nullptr,"IstepDispatcher::executeAllISteps()"
" expected top level target, but got nullptr.");
auto l_mnfgFlags =
l_pTopLevel->getAttr<TARGETING::ATTR_MNFG_FLAGS>();
// Check to see if SRC_TERM bit is set in MNFG flags
if (l_mnfgFlags & TARGETING::MNFG_FLAG_SRC_TERM)
{
TRACFCOMP(g_trac_initsvc, ERR_MRK"executeAllISteps:"
" In manufacturing mode");
l_manufacturingMode = true;
}
while (istep < MaxISteps)
{
substep = 0;
while (substep < g_isteps[istep].numitems)
{
if( iv_stopIpl == true )
{
#ifdef CONFIG_BMC_IPMI
// if we came in here and we are connected to a BMC, then
// we are in the process of an orderly shutdown, reset the
// watchdog to give ample time for the graceful shutdown
// to proceed.
errlHndl_t err_ipmi = IPMIWATCHDOG::resetWatchDogTimer();
if(err_ipmi)
{
TRACFCOMP(g_trac_initsvc,
"init: ERROR: reset IPMI watchdog Failed");
err_ipmi->collectTrace("INITSVC", 1024);
errlCommit(err_ipmi, INITSVC_COMP_ID );
}
#endif
stop();
}
err = doIstep(istep, substep, l_doReconfig);
if (l_doReconfig)
{
// Something occurred that requires a reconfig loop
TRACFCOMP(g_trac_initsvc, ERR_MRK"executeAllISteps:"
" Reconfig required after IStep %d:%d",
istep, substep);
// Find out if in MPIPL mode
bool l_MPIPLMode = false;
if (l_pTopLevel->getAttr<TARGETING::ATTR_IS_MPIPL_HB>())
{
TRACFCOMP(g_trac_initsvc, ERR_MRK"executeAllISteps:"
" In MPIPL mode");
l_MPIPLMode = true;
}
uint8_t newIstep = 0;
uint8_t newSubstep = 0;
if ((checkReconfig(istep, substep, newIstep, newSubstep)) &&
(numReconfigs < MAX_NUM_RECONFIG_ATTEMPTS) &&
(!l_manufacturingMode) &&
(!l_MPIPLMode) )
{
// Within the Reconfig Loop, going to loop back
// first, check to make sure we still have a bootable system
errlHndl_t l_errl = HWAS::checkMinimumHardware();
if (l_errl)
{
// non-bootable system - we want to return this error.
TRACFCOMP(g_trac_initsvc,
ERR_MRK"Error from checkMinimumHardware");
if (err == NULL)
{
err = l_errl;
l_errl = NULL;
}
else
{
// The IStep returned an error and this is likely
// the generic 'IStep failed' from the
// IStepError class; real errors detailing the
// failure have already been committed. Record the
// PLID and delete it if 'Istep failed' or
// commit it otherwised. This will be replaced by
// the checkMinimumHardware error with the same
// plid that matches the real errors
const uint32_t l_plid = err->plid();
if (ISTEP::RC_FAILURE == err->reasonCode())
{
delete err;
err = nullptr;
}
else
{
errlCommit(err, INITSVC_COMP_ID);
}
err = l_errl;
l_errl = NULL;
err->plid(l_plid);
}
// Break out of the istep loop with the error
break;
} // if error from checkMinimumHardware
// we have a bootable system, so loop back
numReconfigs++;
uint32_t l_plid = 0;
if (err)
{
// The IStep returned an error, This is the generic
// 'IStep failed' from the IStepError class, the real
// errors detailing the failure have already been
// committed. Record the PLID and delete it. This will
// be replaced by the ReconfigLoop info error with the
// same plid that matches the real errors
l_plid = err->plid();
delete err;
err = NULL;
}
// Create a new info error stating that a reconfig loop is
// about to be performed
uint64_t errWord = FOUR_UINT16_TO_UINT64(
istep, substep, newIstep, newSubstep);
/*@
* @errortype
* @reasoncode ISTEP_RECONFIG_LOOP_ENTERED
* @severity ERRORLOG::ERRL_SEV_INFORMATIONAL
* @moduleid ISTEP_INITSVC_MOD_ID
* @userdata1[0:15] Istep that failed
* @userdata1[16:31] Substep that failed
* @userdata1[32:47] Istep that reconfig looped back to
* @userdata1[48:63] Substep that reconfig looped back to
* @userdata2 The number of reconfigs loops tried
* @devdesc IStep failed and HW deconfigured.
* Looped back to an earlier istep
* (Reconfigure loop).
*/
err = new ERRORLOG::ErrlEntry(
ERRORLOG::ERRL_SEV_INFORMATIONAL,
ISTEP_INITSVC_MOD_ID,
ISTEP_RECONFIG_LOOP_ENTERED,
errWord,
numReconfigs);
err->collectTrace("HWAS_I", 1024);
if (l_plid != 0)
{
// Use the same plid as the IStep error
err->plid(l_plid);
}
errlCommit(err, INITSVC_COMP_ID);
istep = newIstep;
substep = newSubstep;
TRACFCOMP(g_trac_initsvc, ERR_MRK"executeAllISteps: "
"Reconfig Loop: Back to %d:%d",
istep, substep);
continue;
}
else
{
if (!err)
{
// Reconfig loop required, but the istep is either outside
// of the reconfig loop, too many reconfigs have been
// attempted, in manufacturing mode, or in MPIPL.
// Return an error to cause termination on FSP systems
if (iv_spBaseServicesEnabled)
{
err = failedDueToDeconfig(istep, substep,
newIstep, newSubstep);
}
else if (!l_manufacturingMode)
{
#ifdef CONFIG_BMC_IPMI
// Check the newGardRecord instance variable
if(iv_newGardRecord)
{
// We have a new gard record committed. We need
// to increment the reboot count
uint16_t l_count = 0;
SENSOR::RebootCountSensor l_sensor;
// Read reboot count sensor
err = l_sensor.getRebootCount(l_count);
if (err)
{
TRACFCOMP(g_trac_initsvc, ERR_MRK"executeAllISteps: getRebootCount failed");
break;
}
// Increment reboot count
l_count++;
err = l_sensor.setRebootCount(l_count);
if (err)
{
TRACFCOMP(g_trac_initsvc, ERR_MRK"executeAllISteps: setRebootCount failed");
break;
}
}
else
{
// We are in a reconfig loop, but no new gard
// records have been set. We will not increment
// the reboot count.
TRACFCOMP(g_trac_initsvc, "Reconfig loop needed "
"but no new gard records were committed. Do "
"not increment reboot count.");
}
// Request BMC to do power cycle that sends shutdown
// and reset the host
requestReboot();
#endif
#ifdef CONFIG_CONSOLE
auto l_reconfigAttr =
l_pTopLevel->getAttr<TARGETING::ATTR_RECONFIGURE_LOOP>();
bool l_deconfig = false;
if( l_reconfigAttr ==
TARGETING::RECONFIGURE_LOOP_DECONFIGURE )
{
l_deconfig = true;
}
CONSOLE::displayf(NULL,
"System Shutting Down"
"To Perform Reconfiguration After %s",
l_deconfig ? "Deconfig" : "Recoverable Error" );
CONSOLE::flush();
#endif
#ifndef CONFIG_BMC_IPMI
shutdownDuringIpl();
#endif
}
}
// else return the error from doIstep
}
}
#ifdef CONFIG_BMC_IPMI
if(l_manufacturingMode &&
(ERRORLOG::ErrlManager::errlCommittedThisBoot()))
{
TRACFCOMP(g_trac_initsvc, "Manufacturing Mode is set and an "
"error log has been committed. Stopping the IPL.");
#ifdef CONFIG_CONSOLE
CONSOLE::displayf(NULL, "Manufacturing Mode is set and an "
"error log has been committed. Stopping the IPL.");
CONSOLE::flush();
#endif
// Turn off the watchdog so it doesn't trip
errlHndl_t err_ipmi = IPMIWATCHDOG::setWatchDogTimer(
IPMIWATCHDOG::DEFAULT_WATCHDOG_COUNTDOWN,
static_cast<uint8_t>
(IPMIWATCHDOG::DO_NOT_STOP |
IPMIWATCHDOG::BIOS_FRB2),
IPMIWATCHDOG::NO_ACTIONS); // do nothing
if(err_ipmi)
{
TRACFCOMP(g_trac_initsvc,
"init: ERROR: Failed to disable IPMI "
" watchdog");
err_ipmi->collectTrace("INITSVC");
errlCommit(err_ipmi, INITSVC_COMP_ID );
}
// Flush out the error logs so we can get as much info as
// possible
ERRORLOG::ErrlManager::callFlushErrorLogs();
// Quiesce new isteps, including external requests
(void)setStopIpl();
#ifdef CONFIG_HANG_ON_MFG_SRC_TERM
// Stop the IPL
stop();
#else
//Disable reboots so system really halts
SENSOR::RebootControlSensor l_rbotCtl;
err_ipmi = l_rbotCtl.setRebootControl(
SENSOR::RebootControlSensor::autoRebootSetting::DISABLE_REBOOTS
);
if(err_ipmi)
{
#ifdef CONFIG_CONSOLE
CONSOLE::displayf(NULL, "Failed to disable BMC auto reboots....");
CONSOLE::flush();
#endif
TRACFCOMP(g_trac_initsvc,
"Failed to disable BMC auto reboots....");
err_ipmi->collectTrace("INITSVC");
errlCommit(err_ipmi, INITSVC_COMP_ID );
}
// Shutdown with a TI
doShutdown( SHUTDOWN_MFG_TERM );
#endif
}
#endif
if (err)
{
TRACFCOMP(g_trac_initsvc, ERR_MRK"executeAllISteps: "
"IStep Error on %d:%d", istep, substep);
break;
}
substep++;
}
if (err)
{
// Ensure severity reflects IPL will be terminated
if (err->sev() != ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM)
{
err->setSev(ERRORLOG::ERRL_SEV_UNRECOVERABLE);
}
break;
}
istep++;
}
TRACFCOMP(g_trac_initsvc, EXIT_MRK"IStepDispatcher::executeAllISteps()");
return err;
}
//-----------------------------------------------------------------------------
// IStepDispatcher::stop()
// ---------------------------------------------------------------------------
void IStepDispatcher::stop()
{
#ifdef CONFIG_CONSOLE
CONSOLE::displayf(NULL,"Stopping istep dispatcher");
CONSOLE::flush();
#endif
TRACFCOMP(g_trac_initsvc, "IStepDispatcher::stop() - Stopping istep"
"dispatcher.");
printk( "IStepDispatcher stopping" );
while(1)
{
task_yield();
}
}
// ----------------------------------------------------------------------------
// IStepDispatcher::doIstep()
// ----------------------------------------------------------------------------
errlHndl_t IStepDispatcher::doIstep(uint32_t i_istep,
uint32_t i_substep,
bool & o_doReconfig)
{
errlHndl_t err = NULL;
o_doReconfig = false;
// Get the Task Info for this step
const TaskInfo * theStep = findTaskInfo(i_istep, i_substep);
do {
// If the step has valid work to be done, then execute it.
if(NULL != theStep)
{
#ifdef CONFIG_P9_VPO_COMPILE //extra traces to printk for vpo debug
printk("doIstep: step %d, substep %d, "
"task %s\n", i_istep, i_substep, theStep->taskname);
#endif
TRACFCOMP(g_trac_initsvc,ENTER_MRK"doIstep: step %d, substep %d, "
"task %s", i_istep, i_substep, theStep->taskname);
#ifdef CONFIG_SECUREBOOT
if (SECUREBOOT::enabled())
{
auto nextIStepAllowed = iv_highestIStepDone;
auto nextSubstepAllowed = iv_highestSubstepDone;
auto rc = getNextIStep(nextIStepAllowed, nextSubstepAllowed);
if (rc && (i_istep > nextIStepAllowed ||
(i_istep == nextIStepAllowed &&
i_substep > nextSubstepAllowed))
)
{
TRACFCOMP(g_trac_initsvc,
ERR_MRK"doIstep: failed on requested step %d,"
" and substep %d, next allowed by secure boot is "
"step %d and substep %d", i_istep, i_substep,
nextIStepAllowed, nextSubstepAllowed);
/*@
* @errortype
* @reasoncode ISTEP_SKIP_ATTEMPTED
* @moduleid ISTEP_INITSVC_MOD_ID
* @userdata1[00:31] istep requested
* @userdata1[32:64] substep requested
* @userdata2[00:31] highest istep allowed
* @userdata2[32:64] highest substep allowed
* @devdesc Istep skip prevented in secure mode
* @custdesc An internal firmware error occured
*/
err = new ERRORLOG::ErrlEntry(
ERRORLOG::ERRL_SEV_INFORMATIONAL,
ISTEP_INITSVC_MOD_ID,
ISTEP_SKIP_ATTEMPTED,
TWO_UINT32_TO_UINT64(
i_istep,
i_substep),
TWO_UINT32_TO_UINT64(
nextIStepAllowed,
nextSubstepAllowed));
break;
}
}
#endif // CONFIG_SECUREBOOT
// Record current IStep, SubStep
mutex_lock(&iv_mutex);
iv_curIStep = i_istep;
iv_curSubStep = i_substep;
mutex_unlock(&iv_mutex);
// Send progress codes if in run-all mode
if (!iv_istepMode)
{
// If a shutdown request has been received
if (isShutdownRequested())
{
// Do not begin new IStep and shutdown
shutdownDuringIpl();
}
else
{
mutex_lock(&iv_mutex);
// Send Progress Code
err = this->sendProgressCode(false);
mutex_unlock(&iv_mutex);
if(err)
{
// Commit the error and continue
errlCommit(err, INITSVC_COMP_ID);
}
// Start progress thread, if not yet started
if (!iv_progressThreadStarted)
{
tid_t l_progTid = task_create(startProgressThread,this);
assert( l_progTid > 0 );
iv_progressThreadStarted = true;
}
}
}
if(iv_istepModulesLoaded != i_istep)
{
// unload the modules from the previous step
unLoadModules(iv_istepModulesLoaded);
// load modules for this step
loadModules(i_istep);
iv_istepModulesLoaded = i_istep;
}
// Zero ATTR_RECONFIGURE_LOOP
TARGETING::Target* l_pTopLevel = NULL;
TARGETING::targetService().getTopLevelTarget(l_pTopLevel);
l_pTopLevel->setAttr<TARGETING::ATTR_RECONFIGURE_LOOP>(0);
// Read ATTR_ISTEP_PAUSE_ENABLE attribute
TARGETING::ATTR_ISTEP_PAUSE_ENABLE_type l_istepPauseEn =
l_pTopLevel->getAttr<TARGETING::ATTR_ISTEP_PAUSE_ENABLE>();
// If istep pause is enabled then call istepPauseSet
if (l_istepPauseEn)
{
TRACFCOMP(g_trac_initsvc, INFO_MRK"doIstep: Pause before "
"istep is enabled");
istepPauseSet(i_istep, i_substep);
}
#ifdef CONFIG_BMC_IPMI
if(theStep->taskflags.fwprogtype != PHASE_NA)
{
SENSOR::FirmwareProgressSensor l_progressSensor;
errlHndl_t err_fwprog = l_progressSensor.setBootProgressPhase(
theStep->taskflags.fwprogtype);
if(err_fwprog)
{
TRACFCOMP(g_trac_initsvc,
"init: ERROR: Update FW Progress Phase Failed");
errlCommit(err_fwprog, INITSVC_COMP_ID);
}
}
#endif
err = InitService::getTheInstance().executeFn(theStep, NULL);
// flush contTrace immediately after each i_istep/substep returns
TRAC_FLUSH_BUFFERS();
// sync the attributes to fsp in single step mode but only after step 6
// is complete to allow discoverTargets() to run before the sync is done
if(iv_istepMode && (i_istep > HB_START_ISTEP))
{
if(isAttrSyncEnabled())
{
TRACFCOMP(g_trac_initsvc,
INFO_MRK"doIstep: sync attributes to FSP");
errlHndl_t l_errl = TARGETING::syncAllAttributesToFsp();
if(l_errl)
{
TRACFCOMP(g_trac_initsvc, ERR_MRK"doIstep: sync attributes"
" failed, see 0x%08X for details", l_errl->eid());
errlCommit(l_errl, INITSVC_COMP_ID);
}
}
}
if(err)
{
TRACFCOMP(g_trac_initsvc, ERR_MRK"doIstep: Istep failed, plid 0x%x",