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