summaryrefslogtreecommitdiffstats
path: root/src/usr/isteps/istep14/call_host_mpipl_service.C
blob: 6801d66723e8c28c41738c8c74ad6be503972f3c (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/isteps/istep14/call_host_mpipl_service.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 <errl/errlentry.H>
#include <errl/errlmanager.H>
#include <errl/errludtarget.H>

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

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

#include <runtime/runtime.H>

#include <p9_mpipl_chip_cleanup.H>
#include <fapi2/plat_hwp_invoker.H>

#include <vfs/vfs.H>
#include <dump/dumpif.H>


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

using   namespace   ISTEP;
using   namespace   ISTEP_ERROR;
using   namespace   ERRORLOG;
using   namespace   TARGETING;

namespace ISTEP_14
{
void* call_host_mpipl_service (void *io_pArgs)
{

    IStepError l_StepError;

    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
              "call_host_mpipl_service entry" );

    if (!TARGETING::UTIL::isCurrentMasterNode())
    {
        TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
              "call_host_mpipl_service cannot run on slave node, skipping");
    }
    else
    {
        errlHndl_t l_err = NULL;
        // call proc_mpipl_chip_cleanup.C
        TARGETING::TargetHandleList l_procTargetList;
        getAllChips(l_procTargetList, TYPE_PROC );

        //  ---------------------------------------------------------------
        //  run proc_mpipl_chip_cleanup.C on all proc chips
        //  ---------------------------------------------------------------
        for (const auto & l_pProcTarget : l_procTargetList)
        {
            //  write HUID of target
            TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                    "target HUID %.8X", TARGETING::get_huid(l_pProcTarget));

            fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> l_fapi_pProcTarget((const_cast<TARGETING::Target*> (l_pProcTarget)) );

            //  call the HWP with each fapi::Target
            FAPI_INVOKE_HWP(l_err, p9_mpipl_chip_cleanup, l_fapi_pProcTarget );

            if ( l_err )
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                        "ERROR : returned from p9_mpipl_chip_cleanup" );

                // capture the target data in the elog
                ERRORLOG::ErrlUserDetailsTarget(l_pProcTarget).addToLog(l_err);

                // since we are doing an mpipl break out, the mpipl has failed
                break;
            }

        }

#ifdef CONFIG_DRTM

        if(!l_err)
        {
            do {

            bool drtmMpipl = false;
            SECUREBOOT::DRTM::isDrtmMpipl(drtmMpipl);
            if(drtmMpipl)
            {
                l_err = SECUREBOOT::DRTM::validateDrtmPayload();
                if(l_err)
                {
                    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, ERR_MRK
                        "call_host_mpipl_service: Failed in call to "
                        "validateDrtmPayload()");
                    break;
                }

                l_err = SECUREBOOT::DRTM::completeDrtm();
                if(l_err)
                {
                    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, ERR_MRK
                        "call_host_mpipl_service: Failed in call to "
                        "completeDrtm()" );
                    break;
                }
            }

            } while(0);
        }

#endif

        // No error on the procedure.. proceed to collect the dump.
        if (!l_err)
        {

            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                       "SUCCESS : proc_mpipl_ex_cleanup" );

            // currently according to Adriana, the dump calls should only cause
            // an istep failure when the dump collect portion of this step
            // fails..  We will not fail the istep on any mbox message failures.
            // instead we will simply commit the errorlog and continue.

            errlHndl_t l_errMsg = NULL;

            // Use relocated payload base to get MDST, MDDT, MDRT details
            RUNTIME::useRelocatedPayloadAddr(true);

            do
            {
                // In non-FSP based system SBE collects architected register
                // data. Copy architected register data from Reserved Memory
                // to hypervisor memory.
                if ( !INITSERVICE::spBaseServicesEnabled() )
                {
                    l_err = DUMP::copyArchitectedRegs();
                    if (l_err)
                    {
                        TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                           "ERROR : returned from DUMP::copyArchitectedRegs()");
                        break;
                    }
                }

                // send the start message
                l_errMsg = DUMP::sendMboxMsg(DUMP::DUMP_MSG_START_MSG_TYPE);

                // If error, commit and send error message.
                if (l_errMsg)
                {
                    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                   "ERROR : returned from DUMP::sendMboxMsg - dump start" );

                    errlCommit( l_errMsg, HWPF_COMP_ID );

                    // don't break in this case because we not want to fail
                    // the istep on the dump collect so we will continue
                    // after we log the errhandle that we can't send a
                    // message.
                }

                // Call the dump collect
                l_err = DUMP::doDumpCollect();

                // Got a Dump Collect error.. Commit the dumpCollect
                // errorlog and then send an dump Error mbox message
                // and FSP will decide what to do.
                // We do not want dump Collect failures to terminate the
                // istep.
                if (l_err)
                {
                    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                         "ERROR : returned from DUMP::HbDumpCopySrcToDest");

                    break;
                }

            } while(0);

            DUMP::DUMP_MSG_TYPE msgType = DUMP::DUMP_MSG_END_MSG_TYPE;

            // Send dumpCollect success trace
            if (!l_err)
            {
                TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                           "SUCCESS : doDumpCollect" );
            }
            // got an error that we need to send a ERROR message to FSP
            // and commit the errorlog from dumpCollect.
            else
            {
                msgType = DUMP::DUMP_MSG_ERROR_MSG_TYPE;

                // Commit the dumpCollect errorlog from above as
                // we dont want dump collect to kill the istep
                errlCommit( l_err, HWPF_COMP_ID );

            }

            // Send an Error mbox msg to FSP (either end or error)
            l_errMsg = DUMP::sendMboxMsg(msgType);

            if (l_errMsg)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                          "ERROR : returned from DUMP::sendMboxMsg" );

                errlCommit( l_errMsg, HWPF_COMP_ID );
            }

             RUNTIME::useRelocatedPayloadAddr(false);
             // Wipe out our cache of the NACA/SPIRA pointers
             RUNTIME::rediscover_hdat();
        }

        // If got an error in the procedure or collection of the dump kill the
        // istep
        if( l_err )
        {
            // Create IStep error log and cross reference to error that occurred
            l_StepError.addErrorDetails( l_err );

            // Commit Error
            errlCommit( l_err, HWPF_COMP_ID );
        }
    }

    TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
               "call_host_mpipl_service exit" );

    return l_StepError.getErrorHandle();
}

};
OpenPOWER on IntegriCloud