summaryrefslogtreecommitdiffstats
path: root/src/usr/isteps/istep06/host_gard.C
blob: 4a9852e176c6cf3b2392fa751330fcd5502383ae (plain)
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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/isteps/istep06/host_gard.C $                          */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2019                        */
/* [+] 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                                                     */

#include <hwas/common/hwas.H>
#include <hwas/common/hwasCommon.H>
#include <hwas/common/hwas_reasoncodes.H>
#include <hwas/hwasPlat.H>

#include <hwas/common/deconfigGard.H>

#include <initservice/taskargs.H>
#include <initservice/isteps_trace.H>
#include <initservice/initserviceif.H>
#include <isteps/hwpisteperror.H>

#include <targeting/attrsync.H>
#include <targeting/namedtarget.H>

#include <sbe/sbeif.H>
#include <sbe/sbe_update.H>

//  targeting support.
#include  <targeting/common/utilFilter.H>
#include  <targeting/common/commontargeting.H>
#include  <targeting/common/entitypath.H>

#include  <errl/errludtarget.H>

#include <console/consoleif.H>

// Custom compile configs
#include <config.h>

#ifdef CONFIG_DRTM
#include <secureboot/drtm.H>
#endif

#ifdef CONFIG_ENABLE_CHECKSTOP_ANALYSIS
  #include <diag/attn/attn.H>
#endif

namespace ISTEP_06
{

void* host_gard( void *io_pArgs )
{
    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "host_gard entry" );
    errlHndl_t l_err;
    ISTEP_ERROR::IStepError l_stepError;

    do {
        TARGETING::Target* l_pTopLevel = NULL;
        TARGETING::targetService().getTopLevelTarget( l_pTopLevel );
        assert(l_pTopLevel, "host_gard: no TopLevelTarget");

#ifdef CONFIG_ENABLE_CHECKSTOP_ANALYSIS
        TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                   INFO_MRK"host_gard: invoke PRD to check for previous CS" );

        l_err = ATTN::checkForCSAttentions();
        if ( NULL != l_err )
        {
            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                       ERR_MRK"host_gard: error from checkForCSAttentions" );
            // commit and continue
            errlCommit (l_err, ISTEP_COMP_ID);
        }
#endif

        // Check whether we're in MPIPL mode
        if (l_pTopLevel->getAttr<TARGETING::ATTR_IS_MPIPL_HB>())
        {
            TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                      "host_gard: MPIPL mode");

            TARGETING::PredicateCTM l_coreFilter(TARGETING::CLASS_UNIT,
                                                 TARGETING::TYPE_CORE);
            TARGETING::PredicateCTM l_exFilter(TARGETING::CLASS_UNIT,
                                               TARGETING::TYPE_EX);
            TARGETING::PredicateCTM l_eqFilter(TARGETING::CLASS_UNIT,
                                               TARGETING::TYPE_EQ);

            TARGETING::PredicatePostfixExpr l_coreExEq;
            l_coreExEq.push(&l_coreFilter)
                      .push(&l_exFilter)
                      .push(&l_eqFilter).Or().Or();

            l_err = HWAS::collectGard(&l_coreExEq);
            if(l_err)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,"host_gard: "
                          "collectGard for core, EX, or EQ targets returned "
                          "error; breaking out");
                break;
            }
        }
        else
        {
            TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                      "host_gard: Normal IPL mode");

            l_err = HWAS::collectGard();
            if(l_err)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,"host_gard: "
                   "collectGard returned error; breaking out");
                break;
            }
        }

        // Put out some helpful messages that show which targets are usable
        std::map<TARGETING::TYPE,uint64_t> l_funcData;
        for (auto target : TARGETING::targetService())
        {
            if (!(target->getAttr<TARGETING::ATTR_HWAS_STATE>().functional))
            {
                continue;
            }
            TARGETING::TYPE l_type =target->getAttr<TARGETING::ATTR_TYPE>();
            TARGETING::ATTR_FAPI_POS_type l_pos = 0;
            if( target->tryGetAttr<TARGETING::ATTR_FAPI_POS>(l_pos) )
            {
                l_funcData[l_type] |= (0x8000000000000000 >> l_pos);
            }
        }
        TARGETING::EntityPath l_epath;
        for( auto l_data : l_funcData)
        {
            auto l_type = l_data.first;
            uint64_t l_val = l_data.second;
            //Only want to display procs, dimms, and cores
            if((l_type != TARGETING::TYPE_DIMM) &&
               (l_type != TARGETING::TYPE_PROC) &&
               (l_type != TARGETING::TYPE_CORE))
            {
                continue;
            }
            TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                      "FUNCTIONAL> %s[%.2X]=%.8X%.8X",
                      l_epath.pathElementTypeAsString(l_type),
                      l_type,
                      l_val>>32, l_val&0xFFFFFFFF);

#if (!defined(CONFIG_CONSOLE_OUTPUT_TRACE) && defined(CONFIG_CONSOLE))
            CONSOLE::displayf("HWAS", "FUNCTIONAL> %s[%.2X]=%.8X%.8X",
                              l_epath.pathElementTypeAsString(l_type),
                              l_type,
                              l_val>>32,
                              l_val&0xFFFFFFFF );
#endif
            }

        //  check and see if we still have enough hardware to continue
        l_err = HWAS::checkMinimumHardware();
        if(l_err)
        {
            TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                ERR_MRK"host_gard: "
                "check minimum hardware returned error; breaking out");
            break;
        }

        // If targets are deconfigured as a result of host_gard, they are
        // done so using the PLID as the reason for deconfiguration.  This
        // triggers the reconfigure loop attribute to be set, which causes
        // undesirable behavior, so we need to reset it here:

        // Read current value
        TARGETING::ATTR_RECONFIGURE_LOOP_type l_reconfigAttr =
            l_pTopLevel->getAttr<TARGETING::ATTR_RECONFIGURE_LOOP>();
        // Turn off deconfigure bit
        l_reconfigAttr &= ~TARGETING::RECONFIGURE_LOOP_DECONFIGURE;
        // Write back to attribute
        l_pTopLevel->setAttr<TARGETING::ATTR_RECONFIGURE_LOOP>
                (l_reconfigAttr);


        // Send message to FSP with HUID of master core
        msg_t * core_msg = msg_allocate();
        core_msg->type = SBE::MSG_IPL_MASTER_CORE;
        const TARGETING::Target*  l_masterCore  = TARGETING::getMasterCore( );

        if (l_masterCore == NULL)
        {
            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, ERR_MRK"host_gard: "
                 "No masterCore Found." );
            if( INITSERVICE::spBaseServicesEnabled() )
            {
                const bool hbSwError = true;
                l_err = new ERRORLOG::ErrlEntry
                    (ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM,
                     ISTEP::MOD_HOST_GARD,
                     ISTEP::RC_MASTER_CORE_NULL,
                     0, 0, hbSwError);
            }
            else
            {
                // The masterCore may have a GARD record, update SBE
                // and let it reboot to another core
                TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, ERR_MRK"host_gard: "
                    "Calling updateProcessorSbeSeeproms..." );
                l_err = SBE::updateProcessorSbeSeeproms();
                if(l_err)
                {
                    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                        "host_gard: Error calling updateProcessorSbeSeeproms");
                }
            }
            break;
        }

        core_msg->data[0] = TARGETING::get_huid(l_masterCore);
        core_msg->extra_data = NULL;

        //data[1] is unused
        core_msg->data[1] = 0;


        TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,"host_gard: "
              "Sending MSG_MASTER_CORE message with HUID %08x",
              core_msg->data[0]);
        l_err = MBOX::send(MBOX::IPL_SERVICE_QUEUE,core_msg);
        if (l_err)
        {
            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, ERR_MRK"host_gard: "
                       "MBOX::send failed sending Master Core message");
            msg_free(core_msg);
            break;
        }

#ifdef CONFIG_DRTM
        bool drtmMpipl = false;
        SECUREBOOT::DRTM::isDrtmMpipl(drtmMpipl);
        if(drtmMpipl)
        {
            l_err = SECUREBOOT::DRTM::validateDrtmHwSignature();
            if(l_err)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, ERR_MRK
                    "host_gard: Failed in call to validateDrtmHwSignature");
                break;
            }
        }
#endif

    } while (0);

    if (l_err)
    {
        // Create IStep error log and cross reference occurred error
        l_stepError.addErrorDetails( l_err );
        // Commit Error
        errlCommit (l_err, ISTEP_COMP_ID);
    }

    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "host_gard exit" );
    return l_stepError.getErrorHandle();
}

};
OpenPOWER on IntegriCloud