Jayanth Othayoth | b1eda6a | 2021-06-28 00:26:30 -0500 | [diff] [blame] | 1 | extern "C" |
| 2 | { |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 3 | #include <libpdbg.h> |
Jayanth Othayoth | b1eda6a | 2021-06-28 00:26:30 -0500 | [diff] [blame] | 4 | #include <libpdbg_sbe.h> |
| 5 | } |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 6 | |
Zane Shelley | a06dcf8 | 2021-11-03 10:23:21 -0500 | [diff] [blame] | 7 | #include <config.h> |
| 8 | |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 9 | #ifdef CONFIG_PHAL_API |
| 10 | #include <libphal.H> |
| 11 | #endif |
| 12 | |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 13 | #include <analyzer/analyzer_main.hpp> |
Ben Tyner | b797b3e | 2020-06-29 10:12:05 -0500 | [diff] [blame] | 14 | #include <attn/attention.hpp> |
Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 15 | #include <attn/attn_common.hpp> |
Ben Tyner | b797b3e | 2020-06-29 10:12:05 -0500 | [diff] [blame] | 16 | #include <attn/attn_config.hpp> |
Ben Tyner | 4bbcb38 | 2021-02-22 09:29:00 -0600 | [diff] [blame] | 17 | #include <attn/attn_dbus.hpp> |
Ben Tyner | b797b3e | 2020-06-29 10:12:05 -0500 | [diff] [blame] | 18 | #include <attn/attn_handler.hpp> |
| 19 | #include <attn/attn_logging.hpp> |
| 20 | #include <attn/bp_handler.hpp> |
| 21 | #include <attn/ti_handler.hpp> |
Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 22 | #include <attn/vital_handler.hpp> |
Ben Tyner | fe2c50d | 2021-07-23 13:38:53 -0500 | [diff] [blame] | 23 | #include <util/dbus.hpp> |
Ben Tyner | 76e52f6 | 2022-02-01 10:46:44 -0600 | [diff] [blame] | 24 | #include <util/ffdc_file.hpp> |
| 25 | #include <util/trace.hpp> |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 26 | |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 27 | #include <algorithm> |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 28 | #include <iomanip> |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 29 | #include <map> |
Ben Tyner | 9ae5ca4 | 2020-02-28 13:13:50 -0600 | [diff] [blame] | 30 | #include <sstream> |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 31 | #include <vector> |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 32 | |
| 33 | namespace attn |
| 34 | { |
| 35 | |
| 36 | /** |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 37 | * @brief Handle checkstop attention |
| 38 | * |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 39 | * @param i_attention Attention object |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 40 | * @return 0 indicates that the checkstop attention was successfully handled |
| 41 | * 1 indicates that the checkstop attention was NOT successfully |
| 42 | * handled. |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 43 | */ |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 44 | int handleCheckstop(Attention* i_attention); |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * @brief Handle special attention |
| 48 | * |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 49 | * @param i_attention Attention object |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 50 | * @return 0 indicates that the special attention was successfully handled |
| 51 | * 1 indicates that the special attention was NOT successfully handled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 52 | */ |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 53 | int handleSpecial(Attention* i_attention); |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 54 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 55 | /** @brief Determine if attention is active and not masked */ |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 56 | bool activeAttn(uint32_t i_val, uint32_t i_mask, uint32_t i_attn); |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 57 | |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 58 | #ifdef CONFIG_PHAL_API |
| 59 | /** @brief Handle phal sbe exception */ |
| 60 | void phalSbeExceptionHandler(openpower::phal::exception::SbeError& e, |
Ben Tyner | 76e52f6 | 2022-02-01 10:46:44 -0600 | [diff] [blame] | 61 | uint32_t chipPosition, uint32_t command); |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 62 | #endif |
| 63 | |
| 64 | /** @brief Get static TI info data based on host state */ |
| 65 | void getStaticTiInfo(uint8_t*& tiInfoPtr); |
| 66 | |
| 67 | /** @brief Check if TI info data is valid */ |
| 68 | bool tiInfoValid(uint8_t* tiInfo); |
| 69 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 70 | /** |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 71 | * @brief The main attention handler logic |
Ben Tyner | 970fd4f | 2020-02-19 13:46:42 -0600 | [diff] [blame] | 72 | * |
| 73 | * @param i_breakpoints true = breakpoint special attn handling enabled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 74 | */ |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 75 | void attnHandler(Config* i_config) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 76 | { |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 77 | // Vector of active attentions to be handled |
| 78 | std::vector<Attention> active_attentions; |
| 79 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 80 | uint32_t isr_val, isr_mask; |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 81 | |
| 82 | // loop through processors looking for active attentions |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 83 | trace<level::INFO>("Attention handler started"); |
Ben Tyner | 117af99 | 2020-05-22 13:32:11 -0500 | [diff] [blame] | 84 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 85 | pdbg_target* target; |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 86 | pdbg_for_each_class_target("proc", target) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 87 | { |
| 88 | if (PDBG_TARGET_ENABLED == pdbg_target_probe(target)) |
| 89 | { |
Zane Shelley | a79f6c8 | 2021-01-12 16:38:49 -0600 | [diff] [blame] | 90 | auto proc = pdbg_target_index(target); // get processor number |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 91 | |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 92 | // Use PIB target to determine if a processor is enabled |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 93 | char path[16]; |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 94 | sprintf(path, "/proc%d/pib", proc); |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 95 | pdbg_target* pibTarget = pdbg_target_from_path(nullptr, path); |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 96 | |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 97 | // sanity check |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 98 | if (nullptr == pibTarget) |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 99 | { |
| 100 | trace<level::INFO>("pib path or target not found"); |
| 101 | continue; |
| 102 | } |
| 103 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 104 | // check if pib target is enabled |
| 105 | if (PDBG_TARGET_ENABLED == pdbg_target_probe(pibTarget)) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 106 | { |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 107 | // The processor FSI target is required for CFAM read |
| 108 | sprintf(path, "/proc%d/fsi", proc); |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 109 | pdbg_target* fsiTarget = pdbg_target_from_path(nullptr, path); |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 110 | |
| 111 | // sanity check |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 112 | if (nullptr == fsiTarget) |
Ben Tyner | b83c852 | 2020-11-20 10:45:26 -0600 | [diff] [blame] | 113 | { |
| 114 | trace<level::INFO>("fsi path or target not found"); |
| 115 | continue; |
| 116 | } |
| 117 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 118 | // trace the proc number |
| 119 | std::string traceMsg = "proc: " + std::to_string(proc); |
| 120 | trace<level::INFO>(traceMsg.c_str()); |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 121 | |
Ben Tyner | 5adc96e | 2020-11-20 10:54:12 -0600 | [diff] [blame] | 122 | isr_val = 0xffffffff; // invalid isr value |
| 123 | |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 124 | // get active attentions on processor |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 125 | if (RC_SUCCESS != fsi_read(fsiTarget, 0x1007, &isr_val)) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 126 | { |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 127 | // log cfam read error |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 128 | trace<level::INFO>("Error! cfam read 0x1007 FAILED"); |
Ben Tyner | 7a0dd54 | 2021-02-12 09:33:44 -0600 | [diff] [blame] | 129 | eventAttentionFail((int)AttnSection::attnHandler | |
| 130 | ATTN_PDBG_CFAM); |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 131 | } |
Ben Tyner | 5adc96e | 2020-11-20 10:54:12 -0600 | [diff] [blame] | 132 | else if (0xffffffff == isr_val) |
| 133 | { |
| 134 | trace<level::INFO>("Error! cfam read 0x1007 INVALID"); |
| 135 | continue; |
| 136 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 137 | else |
| 138 | { |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 139 | // trace isr value |
| 140 | std::stringstream ssIsr; |
| 141 | ssIsr << "cfam 0x1007 = 0x" << std::setw(8) |
| 142 | << std::setfill('0') << std::hex << isr_val; |
| 143 | std::string strobjIsr = ssIsr.str(); |
| 144 | trace<level::INFO>(strobjIsr.c_str()); |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 145 | |
Ben Tyner | 5adc96e | 2020-11-20 10:54:12 -0600 | [diff] [blame] | 146 | isr_mask = 0xffffffff; // invalid isr mask |
| 147 | |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 148 | // get interrupt enabled special attentions mask |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 149 | if (RC_SUCCESS != fsi_read(fsiTarget, 0x100d, &isr_mask)) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 150 | { |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 151 | // log cfam read error |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 152 | trace<level::INFO>("Error! cfam read 0x100d FAILED"); |
Ben Tyner | 7a0dd54 | 2021-02-12 09:33:44 -0600 | [diff] [blame] | 153 | eventAttentionFail((int)AttnSection::attnHandler | |
| 154 | ATTN_PDBG_CFAM); |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 155 | } |
Ben Tyner | 5adc96e | 2020-11-20 10:54:12 -0600 | [diff] [blame] | 156 | else if (0xffffffff == isr_mask) |
| 157 | { |
| 158 | trace<level::INFO>("Error! cfam read 0x100d INVALID"); |
| 159 | continue; |
| 160 | } |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 161 | else |
| 162 | { |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 163 | // trace true mask |
| 164 | std::stringstream ssMask; |
| 165 | ssMask << "cfam 0x100d = 0x" << std::setw(8) |
| 166 | << std::setfill('0') << std::hex << isr_mask; |
| 167 | std::string strobjMask = ssMask.str(); |
| 168 | trace<level::INFO>(strobjMask.c_str()); |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 169 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 170 | // SBE vital attention active and not masked? |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 171 | if (true == activeAttn(isr_val, isr_mask, SBE_ATTN)) |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 172 | { |
| 173 | active_attentions.emplace_back(Attention::Vital, |
| 174 | handleVital, target, |
| 175 | i_config); |
| 176 | } |
| 177 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 178 | // Checkstop attention active and not masked? |
| 179 | if (true == |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 180 | activeAttn(isr_val, isr_mask, CHECKSTOP_ATTN)) |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 181 | { |
| 182 | active_attentions.emplace_back(Attention::Checkstop, |
| 183 | handleCheckstop, |
| 184 | target, i_config); |
| 185 | } |
| 186 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 187 | // Special attention active and not masked? |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 188 | if (true == activeAttn(isr_val, isr_mask, SPECIAL_ATTN)) |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 189 | { |
| 190 | active_attentions.emplace_back(Attention::Special, |
| 191 | handleSpecial, |
| 192 | target, i_config); |
| 193 | } |
| 194 | } // cfam 0x100d valid |
| 195 | } // cfam 0x1007 valid |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 196 | } // fsi target enabled |
| 197 | } // pib target enabled |
Ben Tyner | 5e622d8 | 2020-09-11 10:10:24 -0500 | [diff] [blame] | 198 | } // next processor |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 199 | |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 200 | // convert to heap, highest priority is at front |
| 201 | if (!std::is_heap(active_attentions.begin(), active_attentions.end())) |
| 202 | { |
| 203 | std::make_heap(active_attentions.begin(), active_attentions.end()); |
| 204 | } |
| 205 | |
| 206 | // call the attention handler until one is handled or all were attempted |
| 207 | while (false == active_attentions.empty()) |
| 208 | { |
| 209 | // handle highest priority attention, done if successful |
| 210 | if (RC_SUCCESS == active_attentions.front().handle()) |
| 211 | { |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 212 | // an attention was handled so we are done |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 213 | break; |
| 214 | } |
| 215 | |
| 216 | // move attention to back of vector |
| 217 | std::pop_heap(active_attentions.begin(), active_attentions.end()); |
| 218 | |
| 219 | // remove attention from vector |
| 220 | active_attentions.pop_back(); |
| 221 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | /** |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 225 | * @brief Handle checkstop attention |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 226 | * |
| 227 | * @param i_attention Attention object |
| 228 | * @return 0 indicates that the checkstop attention was successfully handled |
| 229 | * 1 indicates that the checkstop attention was NOT successfully |
| 230 | * handled. |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 231 | */ |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 232 | int handleCheckstop(Attention* i_attention) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 233 | { |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 234 | int rc = RC_SUCCESS; // assume checkstop handled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 235 | |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 236 | trace<level::INFO>("checkstop handler started"); |
| 237 | |
Ben Tyner | b833556 | 2021-07-16 12:43:52 -0500 | [diff] [blame] | 238 | // capture some additional data for logs/traces |
| 239 | addHbStatusRegs(); |
| 240 | |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 241 | // if checkstop handling enabled, handle checkstop attention |
| 242 | if (false == (i_attention->getConfig()->getFlag(enCheckstop))) |
| 243 | { |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 244 | trace<level::INFO>("Checkstop handling disabled"); |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 245 | } |
| 246 | else |
| 247 | { |
Ben Tyner | 07ebb9b | 2021-12-01 12:16:24 -0600 | [diff] [blame] | 248 | // wait for power fault handling before starting analyses |
| 249 | sleepSeconds(POWER_FAULT_WAIT); |
| 250 | |
Zane Shelley | 9fb7393 | 2020-09-15 13:34:57 -0500 | [diff] [blame] | 251 | // Look for any attentions found in hardware. This will generate and |
Zane Shelley | 7ae9c8c | 2020-12-02 20:10:31 -0600 | [diff] [blame] | 252 | // commit a PEL if any errors are found. |
Ben Tyner | 7029e52 | 2021-08-09 19:18:24 -0500 | [diff] [blame] | 253 | DumpParameters dumpParameters; |
Zane Shelley | ebff0d3 | 2021-11-21 10:52:07 -0600 | [diff] [blame] | 254 | auto logid = analyzer::analyzeHardware( |
| 255 | analyzer::AnalysisType::SYSTEM_CHECKSTOP, dumpParameters); |
Zane Shelley | 611b344 | 2021-11-19 16:02:01 -0600 | [diff] [blame] | 256 | if (0 == logid) |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 257 | { |
Zane Shelley | 611b344 | 2021-11-19 16:02:01 -0600 | [diff] [blame] | 258 | // A PEL should exist for a checkstop attention. |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 259 | rc = RC_ANALYZER_ERROR; |
| 260 | } |
Ben Tyner | 7029e52 | 2021-08-09 19:18:24 -0500 | [diff] [blame] | 261 | else |
| 262 | { |
Zane Shelley | 611b344 | 2021-11-19 16:02:01 -0600 | [diff] [blame] | 263 | requestDump(logid, dumpParameters); |
Ben Tyner | 7029e52 | 2021-08-09 19:18:24 -0500 | [diff] [blame] | 264 | util::dbus::transitionHost(util::dbus::HostState::Quiesce); |
| 265 | } |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 266 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 267 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 268 | return rc; |
| 269 | } |
| 270 | |
| 271 | /** |
| 272 | * @brief Handle special attention |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 273 | * |
| 274 | * @param i_attention Attention object |
| 275 | * @return 0 indicates that the special attention was successfully handled |
| 276 | * 1 indicates that the special attention was NOT successfully handled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 277 | */ |
Ben Tyner | b481d90 | 2020-03-05 10:24:23 -0600 | [diff] [blame] | 278 | int handleSpecial(Attention* i_attention) |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 279 | { |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 280 | int rc = RC_SUCCESS; // assume special attention handled |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 281 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 282 | // The TI info chipop will give us a pointer to the TI info data |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 283 | uint8_t* tiInfo = nullptr; // ptr to TI info data |
| 284 | uint32_t tiInfoLen = 0; // length of TI info data |
| 285 | pdbg_target* attnProc = i_attention->getTarget(); // proc with attention |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 286 | |
Ben Tyner | 29651ef | 2021-02-08 10:51:03 -0600 | [diff] [blame] | 287 | bool tiInfoStatic = false; // assume TI info was provided (not created) |
| 288 | |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 289 | // need proc target to get dynamic TI info |
| 290 | if (nullptr != attnProc) |
Ben Tyner | 89c0a7a | 2020-08-07 12:07:35 -0500 | [diff] [blame] | 291 | { |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 292 | #ifdef CONFIG_PHAL_API |
| 293 | trace<level::INFO>("using libphal to get TI info"); |
| 294 | |
| 295 | // phal library uses proc target for get ti info |
| 296 | if (PDBG_TARGET_ENABLED == pdbg_target_probe(attnProc)) |
| 297 | { |
| 298 | try |
| 299 | { |
| 300 | // get dynamic TI info |
| 301 | openpower::phal::sbe::getTiInfo(attnProc, &tiInfo, &tiInfoLen); |
| 302 | } |
Ben Tyner | 76e52f6 | 2022-02-01 10:46:44 -0600 | [diff] [blame] | 303 | catch (openpower::phal::exception::SbeError& sbeError) |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 304 | { |
| 305 | // library threw an exception |
Ben Tyner | 76e52f6 | 2022-02-01 10:46:44 -0600 | [diff] [blame] | 306 | // note: phal::sbe::getTiInfo = command class | command == |
| 307 | // 0xa900 | 0x04 = 0xa904. The sbe fifo command class and |
| 308 | // commands are defined in the sbefifo library source code but |
| 309 | // do not seem to be exported/installed for consumption |
| 310 | // externally. |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 311 | uint32_t procNum = pdbg_target_index(attnProc); |
Ben Tyner | 76e52f6 | 2022-02-01 10:46:44 -0600 | [diff] [blame] | 312 | phalSbeExceptionHandler(sbeError, procNum, 0xa904); |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 313 | } |
| 314 | } |
| 315 | #else |
| 316 | trace<level::INFO>("using libpdbg to get TI info"); |
| 317 | |
| 318 | // pdbg library uses pib target for get ti info |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 319 | char path[16]; |
| 320 | sprintf(path, "/proc%d/pib", pdbg_target_index(attnProc)); |
| 321 | pdbg_target* tiInfoTarget = pdbg_target_from_path(nullptr, path); |
| 322 | |
| 323 | if (nullptr != tiInfoTarget) |
Ben Tyner | 89c0a7a | 2020-08-07 12:07:35 -0500 | [diff] [blame] | 324 | { |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 325 | if (PDBG_TARGET_ENABLED == pdbg_target_probe(tiInfoTarget)) |
| 326 | { |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 327 | sbe_mpipl_get_ti_info(tiInfoTarget, &tiInfo, &tiInfoLen); |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 328 | } |
Ben Tyner | 89c0a7a | 2020-08-07 12:07:35 -0500 | [diff] [blame] | 329 | } |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 330 | #endif |
Ben Tyner | 89c0a7a | 2020-08-07 12:07:35 -0500 | [diff] [blame] | 331 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 332 | |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 333 | // dynamic TI info is not available |
| 334 | if (nullptr == tiInfo) |
Ben Tyner | 970fd4f | 2020-02-19 13:46:42 -0600 | [diff] [blame] | 335 | { |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 336 | trace<level::INFO>("TI info data ptr is invalid"); |
| 337 | getStaticTiInfo(tiInfo); |
| 338 | tiInfoStatic = true; |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 339 | } |
Ben Tyner | 0fe5df4 | 2020-12-03 08:57:17 -0600 | [diff] [blame] | 340 | |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 341 | // check TI info for validity and handle |
| 342 | if (true == tiInfoValid(tiInfo)) |
| 343 | { |
| 344 | // TI info is valid handle TI if support enabled |
| 345 | if (true == (i_attention->getConfig()->getFlag(enTerminate))) |
| 346 | { |
| 347 | // Call TI special attention handler |
| 348 | rc = tiHandler((TiDataArea*)tiInfo); |
| 349 | } |
| 350 | } |
| 351 | else |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 352 | { |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 353 | trace<level::INFO>("TI info NOT valid"); |
Ben Tyner | 98430b3 | 2020-08-19 19:14:02 -0500 | [diff] [blame] | 354 | |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 355 | // if configured to handle TI as default special attention |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 356 | if (i_attention->getConfig()->getFlag(dfltTi)) |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 357 | { |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 358 | // TI handling may be disabled |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 359 | if (true == (i_attention->getConfig()->getFlag(enTerminate))) |
| 360 | { |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 361 | // Call TI special attention handler |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 362 | rc = tiHandler((TiDataArea*)tiInfo); |
Ben Tyner | e4f5dbe | 2020-10-19 07:19:33 -0500 | [diff] [blame] | 363 | } |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 364 | } |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 365 | // configured to handle breakpoint as default special attention |
Ben Tyner | fe15649 | 2021-04-08 07:28:13 -0500 | [diff] [blame] | 366 | else |
| 367 | { |
| 368 | // breakpoint handling may be disabled |
| 369 | if (true == (i_attention->getConfig()->getFlag(enBreakpoints))) |
| 370 | { |
| 371 | // Call the breakpoint special attention handler |
| 372 | rc = bpHandler(); |
| 373 | } |
| 374 | } |
Ben Tyner | 970fd4f | 2020-02-19 13:46:42 -0600 | [diff] [blame] | 375 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 376 | |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 377 | // release TI data buffer if not ours |
| 378 | if (false == tiInfoStatic) |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 379 | { |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 380 | // sanity check |
| 381 | if (nullptr != tiInfo) |
| 382 | { |
| 383 | free(tiInfo); |
| 384 | } |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 385 | } |
| 386 | |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 387 | // trace non-successful exit condition |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 388 | if (RC_SUCCESS != rc) |
| 389 | { |
Ben Tyner | 792f32f | 2020-06-02 08:50:47 -0500 | [diff] [blame] | 390 | trace<level::INFO>("Special attn not handled"); |
Ben Tyner | 3fb52e5 | 2020-03-31 10:10:07 -0500 | [diff] [blame] | 391 | } |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 392 | |
| 393 | return rc; |
| 394 | } |
| 395 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 396 | /** |
| 397 | * @brief Determine if attention is active and not masked |
| 398 | * |
| 399 | * Determine whether an attention needs to be handled and trace details of |
| 400 | * attention type and whether it is masked or not. |
| 401 | * |
| 402 | * @param i_val attention status register |
| 403 | * @param i_mask attention true mask register |
| 404 | * @param i_attn attention type |
| 405 | * @param i_proc processor associated with registers |
| 406 | * |
| 407 | * @return true if attention is active and not masked, otherwise false |
| 408 | */ |
Ben Tyner | 1965e50 | 2020-11-20 10:32:24 -0600 | [diff] [blame] | 409 | bool activeAttn(uint32_t i_val, uint32_t i_mask, uint32_t i_attn) |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 410 | { |
Zane Shelley | 9fb657f | 2021-01-12 15:30:58 -0600 | [diff] [blame] | 411 | bool rc = false; // assume attn masked and/or inactive |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 412 | |
| 413 | // if attention active |
| 414 | if (0 != (i_val & i_attn)) |
| 415 | { |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 416 | std::stringstream ss; |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 417 | |
Zane Shelley | 9fb657f | 2021-01-12 15:30:58 -0600 | [diff] [blame] | 418 | bool validAttn = true; // known attention type |
| 419 | |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 420 | switch (i_attn) |
| 421 | { |
| 422 | case SBE_ATTN: |
| 423 | ss << "SBE attn"; |
| 424 | break; |
| 425 | case CHECKSTOP_ATTN: |
| 426 | ss << "Checkstop attn"; |
| 427 | break; |
| 428 | case SPECIAL_ATTN: |
| 429 | ss << "Special attn"; |
| 430 | break; |
| 431 | default: |
| 432 | ss << "Unknown attn"; |
| 433 | validAttn = false; |
| 434 | } |
| 435 | |
| 436 | // see if attention is masked |
| 437 | if (true == validAttn) |
| 438 | { |
| 439 | if (0 != (i_mask & i_attn)) |
| 440 | { |
| 441 | rc = true; // attention active and not masked |
| 442 | } |
| 443 | else |
| 444 | { |
| 445 | ss << " masked"; |
| 446 | } |
| 447 | } |
| 448 | |
Ben Tyner | 8882c32 | 2021-02-05 12:13:21 -0600 | [diff] [blame] | 449 | std::string strobj = ss.str(); // ss.str() is temporary |
| 450 | trace<level::INFO>(strobj.c_str()); // commit trace stream |
Ben Tyner | fb19054 | 2020-11-06 09:27:56 -0600 | [diff] [blame] | 451 | } |
| 452 | |
| 453 | return rc; |
| 454 | } |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 455 | |
| 456 | #ifdef CONFIG_PHAL_API |
Ben Tyner | 76e52f6 | 2022-02-01 10:46:44 -0600 | [diff] [blame] | 457 | |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 458 | /** |
| 459 | * @brief Handle phal sbe exception |
| 460 | * |
| 461 | * @param[in] e - exception object |
| 462 | * @param[in] procNum - processor number associated with sbe exception |
| 463 | */ |
Ben Tyner | 76e52f6 | 2022-02-01 10:46:44 -0600 | [diff] [blame] | 464 | void phalSbeExceptionHandler(openpower::phal::exception::SbeError& sbeError, |
| 465 | uint32_t chipPosition, uint32_t command) |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 466 | { |
Ben Tyner | 76e52f6 | 2022-02-01 10:46:44 -0600 | [diff] [blame] | 467 | trace::err("Attention handler phal exception handler"); |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 468 | |
Ben Tyner | 76e52f6 | 2022-02-01 10:46:44 -0600 | [diff] [blame] | 469 | // Trace exception details |
| 470 | trace::err(sbeError.what()); |
| 471 | |
| 472 | // Create event log entry with SBE FFDC data if provided |
| 473 | auto fd = sbeError.getFd(); |
| 474 | if (fd > 0) |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 475 | { |
Ben Tyner | 76e52f6 | 2022-02-01 10:46:44 -0600 | [diff] [blame] | 476 | trace::err("SBE FFDC data is available"); |
| 477 | |
| 478 | // FFDC parser expects chip position and command (command class | |
| 479 | // command) to be in the additional data. |
| 480 | std::map<std::string, std::string> additionalData = { |
| 481 | {"SRC6", std::to_string((chipPosition << 16) | command)}}; |
| 482 | |
| 483 | // See phosphor-logging/extensions/openpower-pels/README.md, "Self Boot |
| 484 | // Engine(SBE) First Failure Data Capture(FFDC)" - SBE FFDC file type |
| 485 | // is 0xCB, version is 0x01. |
| 486 | std::vector<util::FFDCTuple> ffdc{util::FFDCTuple{ |
| 487 | util::FFDCFormat::Custom, static_cast<uint8_t>(0xCB), |
| 488 | static_cast<uint8_t>(0x01), fd}}; |
| 489 | |
| 490 | // Create event log entry with FFDC data |
| 491 | createPel("org.open_power.Processor.Error.SbeChipOpFailure", |
| 492 | additionalData, ffdc); |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 493 | } |
| 494 | } |
| 495 | #endif |
| 496 | |
| 497 | /** |
| 498 | * @brief Get static TI info data based on host state |
| 499 | * |
| 500 | * @param[out] tiInfo - pointer to static TI info data |
| 501 | */ |
| 502 | void getStaticTiInfo(uint8_t*& tiInfo) |
| 503 | { |
| 504 | util::dbus::HostRunningState runningState = util::dbus::hostRunningState(); |
| 505 | |
| 506 | // assume host state is unknown |
| 507 | std::string stateString = "host state unknown"; |
| 508 | |
| 509 | if ((util::dbus::HostRunningState::Started == runningState) || |
| 510 | (util::dbus::HostRunningState::Unknown == runningState)) |
| 511 | { |
| 512 | if (util::dbus::HostRunningState::Started == runningState) |
| 513 | { |
| 514 | stateString = "host started"; |
| 515 | } |
| 516 | tiInfo = (uint8_t*)defaultPhypTiInfo; |
| 517 | } |
| 518 | else |
| 519 | { |
| 520 | stateString = "host not started"; |
| 521 | tiInfo = (uint8_t*)defaultHbTiInfo; |
| 522 | } |
| 523 | |
| 524 | // trace host state |
| 525 | trace<level::INFO>(stateString.c_str()); |
| 526 | } |
| 527 | |
| 528 | /** |
| 529 | * @brief Check if TI info data is valid |
| 530 | * |
| 531 | * @param[in] tiInfo - pointer to TI info data |
| 532 | * @return true if TI info data is valid, else false |
| 533 | */ |
| 534 | bool tiInfoValid(uint8_t* tiInfo) |
| 535 | { |
| 536 | bool tiInfoValid = false; // assume TI info invalid |
| 537 | |
| 538 | // TI info data[0] non-zero indicates TI info valid (usually) |
| 539 | if ((nullptr != tiInfo) && (0 != tiInfo[0])) |
| 540 | { |
| 541 | TiDataArea* tiDataArea = (TiDataArea*)tiInfo; |
| 542 | |
| 543 | std::stringstream ss; // string stream object for tracing |
| 544 | std::string strobj; // string object for tracing |
| 545 | |
| 546 | // trace a few known TI data area values |
| 547 | ss.str(std::string()); // empty the stream |
| 548 | ss.clear(); // clear the stream |
| 549 | ss << "TI data command = 0x" << std::setw(2) << std::setfill('0') |
| 550 | << std::hex << (int)tiDataArea->command; |
| 551 | strobj = ss.str(); |
| 552 | trace<level::INFO>(strobj.c_str()); |
| 553 | |
| 554 | // Another check for valid TI Info since it has been seen that |
| 555 | // tiInfo[0] != 0 but TI info is not valid |
| 556 | if (0xa1 == tiDataArea->command) |
| 557 | { |
| 558 | tiInfoValid = true; |
| 559 | |
| 560 | // trace some more data since TI info appears valid |
| 561 | ss.str(std::string()); // empty the stream |
| 562 | ss.clear(); // clear the stream |
| 563 | ss << "TI data term-type = 0x" << std::setw(2) << std::setfill('0') |
| 564 | << std::hex << (int)tiDataArea->hbTerminateType; |
| 565 | strobj = ss.str(); |
| 566 | trace<level::INFO>(strobj.c_str()); |
| 567 | |
| 568 | ss.str(std::string()); // empty the stream |
| 569 | ss.clear(); // clear the stream |
| 570 | ss << "TI data SRC format = 0x" << std::setw(2) << std::setfill('0') |
| 571 | << std::hex << (int)tiDataArea->srcFormat; |
| 572 | strobj = ss.str(); |
| 573 | trace<level::INFO>(strobj.c_str()); |
| 574 | |
| 575 | ss.str(std::string()); // empty the stream |
| 576 | ss.clear(); // clear the stream |
| 577 | ss << "TI data source = 0x" << std::setw(2) << std::setfill('0') |
| 578 | << std::hex << (int)tiDataArea->source; |
| 579 | strobj = ss.str(); |
| 580 | trace<level::INFO>(strobj.c_str()); |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | return tiInfoValid; |
| 585 | } |
| 586 | |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 587 | } // namespace attn |