Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 1 | /* |
| 2 | * CAAM Error Reporting |
| 3 | * |
| 4 | * Copyright 2009-2011 Freescale Semiconductor, Inc. |
| 5 | */ |
| 6 | |
| 7 | #include "compat.h" |
| 8 | #include "regs.h" |
| 9 | #include "intern.h" |
| 10 | #include "desc.h" |
| 11 | #include "jr.h" |
| 12 | #include "error.h" |
| 13 | |
Marek Vasut | 9724d7a | 2014-04-24 20:05:13 +0200 | [diff] [blame] | 14 | static const struct { |
| 15 | u8 value; |
Marek Vasut | e397ee0 | 2014-04-24 20:05:21 +0200 | [diff] [blame^] | 16 | const char *error_text; |
Marek Vasut | 9724d7a | 2014-04-24 20:05:13 +0200 | [diff] [blame] | 17 | } desc_error_list[] = { |
| 18 | { 0x00, "No error." }, |
| 19 | { 0x01, "SGT Length Error. The descriptor is trying to read " |
| 20 | "more data than is contained in the SGT table." }, |
| 21 | { 0x02, "SGT Null Entry Error." }, |
| 22 | { 0x03, "Job Ring Control Error. There is a bad value in the " |
| 23 | "Job Ring Control register." }, |
| 24 | { 0x04, "Invalid Descriptor Command. The Descriptor Command " |
| 25 | "field is invalid." }, |
| 26 | { 0x05, "Reserved." }, |
| 27 | { 0x06, "Invalid KEY Command" }, |
| 28 | { 0x07, "Invalid LOAD Command" }, |
| 29 | { 0x08, "Invalid STORE Command" }, |
| 30 | { 0x09, "Invalid OPERATION Command" }, |
| 31 | { 0x0A, "Invalid FIFO LOAD Command" }, |
| 32 | { 0x0B, "Invalid FIFO STORE Command" }, |
| 33 | { 0x0C, "Invalid MOVE/MOVE_LEN Command" }, |
| 34 | { 0x0D, "Invalid JUMP Command. A nonlocal JUMP Command is " |
| 35 | "invalid because the target is not a Job Header " |
| 36 | "Command, or the jump is from a Trusted Descriptor to " |
| 37 | "a Job Descriptor, or because the target Descriptor " |
| 38 | "contains a Shared Descriptor." }, |
| 39 | { 0x0E, "Invalid MATH Command" }, |
| 40 | { 0x0F, "Invalid SIGNATURE Command" }, |
| 41 | { 0x10, "Invalid Sequence Command. A SEQ IN PTR OR SEQ OUT PTR " |
| 42 | "Command is invalid or a SEQ KEY, SEQ LOAD, SEQ FIFO " |
| 43 | "LOAD, or SEQ FIFO STORE decremented the input or " |
| 44 | "output sequence length below 0. This error may result " |
| 45 | "if a built-in PROTOCOL Command has encountered a " |
| 46 | "malformed PDU." }, |
| 47 | { 0x11, "Skip data type invalid. The type must be 0xE or 0xF."}, |
| 48 | { 0x12, "Shared Descriptor Header Error" }, |
| 49 | { 0x13, "Header Error. Invalid length or parity, or certain " |
| 50 | "other problems." }, |
| 51 | { 0x14, "Burster Error. Burster has gotten to an illegal " |
| 52 | "state" }, |
| 53 | { 0x15, "Context Register Length Error. The descriptor is " |
| 54 | "trying to read or write past the end of the Context " |
| 55 | "Register. A SEQ LOAD or SEQ STORE with the VLF bit " |
| 56 | "set was executed with too large a length in the " |
| 57 | "variable length register (VSOL for SEQ STORE or VSIL " |
| 58 | "for SEQ LOAD)." }, |
| 59 | { 0x16, "DMA Error" }, |
| 60 | { 0x17, "Reserved." }, |
| 61 | { 0x1A, "Job failed due to JR reset" }, |
| 62 | { 0x1B, "Job failed due to Fail Mode" }, |
| 63 | { 0x1C, "DECO Watchdog timer timeout error" }, |
| 64 | { 0x1D, "DECO tried to copy a key from another DECO but the " |
| 65 | "other DECO's Key Registers were locked" }, |
| 66 | { 0x1E, "DECO attempted to copy data from a DECO that had an " |
| 67 | "unmasked Descriptor error" }, |
| 68 | { 0x1F, "LIODN error. DECO was trying to share from itself or " |
| 69 | "from another DECO but the two Non-SEQ LIODN values " |
| 70 | "didn't match or the 'shared from' DECO's Descriptor " |
| 71 | "required that the SEQ LIODNs be the same and they " |
| 72 | "aren't." }, |
| 73 | { 0x20, "DECO has completed a reset initiated via the DRR " |
| 74 | "register" }, |
| 75 | { 0x21, "Nonce error. When using EKT (CCM) key encryption " |
| 76 | "option in the FIFO STORE Command, the Nonce counter " |
| 77 | "reached its maximum value and this encryption mode " |
| 78 | "can no longer be used." }, |
| 79 | { 0x22, "Meta data is too large (> 511 bytes) for TLS decap " |
| 80 | "(input frame; block ciphers) and IPsec decap (output " |
| 81 | "frame, when doing the next header byte update) and " |
| 82 | "DCRC (output frame)." }, |
| 83 | { 0x23, "Read Input Frame error" }, |
| 84 | { 0x24, "JDKEK, TDKEK or TDSK not loaded error" }, |
| 85 | { 0x80, "DNR (do not run) error" }, |
| 86 | { 0x81, "undefined protocol command" }, |
| 87 | { 0x82, "invalid setting in PDB" }, |
| 88 | { 0x83, "Anti-replay LATE error" }, |
| 89 | { 0x84, "Anti-replay REPLAY error" }, |
| 90 | { 0x85, "Sequence number overflow" }, |
| 91 | { 0x86, "Sigver invalid signature" }, |
| 92 | { 0x87, "DSA Sign Illegal test descriptor" }, |
| 93 | { 0x88, "Protocol Format Error - A protocol has seen an error " |
| 94 | "in the format of data received. When running RSA, " |
| 95 | "this means that formatting with random padding was " |
| 96 | "used, and did not follow the form: 0x00, 0x02, 8-to-N " |
| 97 | "bytes of non-zero pad, 0x00, F data." }, |
| 98 | { 0x89, "Protocol Size Error - A protocol has seen an error in " |
| 99 | "size. When running RSA, pdb size N < (size of F) when " |
| 100 | "no formatting is used; or pdb size N < (F + 11) when " |
| 101 | "formatting is used." }, |
| 102 | { 0xC1, "Blob Command error: Undefined mode" }, |
| 103 | { 0xC2, "Blob Command error: Secure Memory Blob mode error" }, |
| 104 | { 0xC4, "Blob Command error: Black Blob key or input size " |
| 105 | "error" }, |
| 106 | { 0xC5, "Blob Command error: Invalid key destination" }, |
| 107 | { 0xC8, "Blob Command error: Trusted/Secure mode error" }, |
| 108 | { 0xF0, "IPsec TTL or hop limit field either came in as 0, " |
| 109 | "or was decremented to 0" }, |
| 110 | { 0xF1, "3GPP HFN matches or exceeds the Threshold" }, |
| 111 | }; |
| 112 | |
| 113 | static const char * const cha_id_list[] = { |
| 114 | "", |
| 115 | "AES", |
| 116 | "DES", |
| 117 | "ARC4", |
| 118 | "MDHA", |
| 119 | "RNG", |
| 120 | "SNOW f8", |
| 121 | "Kasumi f8/9", |
| 122 | "PKHA", |
| 123 | "CRCA", |
| 124 | "SNOW f9", |
| 125 | "ZUCE", |
| 126 | "ZUCA", |
| 127 | }; |
| 128 | |
| 129 | static const char * const err_id_list[] = { |
| 130 | "No error.", |
| 131 | "Mode error.", |
| 132 | "Data size error.", |
| 133 | "Key size error.", |
| 134 | "PKHA A memory size error.", |
| 135 | "PKHA B memory size error.", |
| 136 | "Data arrived out of sequence error.", |
| 137 | "PKHA divide-by-zero error.", |
| 138 | "PKHA modulus even error.", |
| 139 | "DES key parity error.", |
| 140 | "ICV check failed.", |
| 141 | "Hardware error.", |
| 142 | "Unsupported CCM AAD size.", |
| 143 | "Class 1 CHA is not reset", |
| 144 | "Invalid CHA combination was selected", |
| 145 | "Invalid CHA selected.", |
| 146 | }; |
| 147 | |
| 148 | static const char * const rng_err_id_list[] = { |
| 149 | "", |
| 150 | "", |
| 151 | "", |
| 152 | "Instantiate", |
| 153 | "Not instantiated", |
| 154 | "Test instantiate", |
| 155 | "Prediction resistance", |
| 156 | "Prediction resistance and test request", |
| 157 | "Uninstantiate", |
| 158 | "Secure key generation", |
| 159 | }; |
| 160 | |
Marek Vasut | e397ee0 | 2014-04-24 20:05:21 +0200 | [diff] [blame^] | 161 | static void report_ccb_status(struct device *jrdev, const u32 status, |
| 162 | const char *error) |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 163 | { |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 164 | u8 cha_id = (status & JRSTA_CCBERR_CHAID_MASK) >> |
| 165 | JRSTA_CCBERR_CHAID_SHIFT; |
| 166 | u8 err_id = status & JRSTA_CCBERR_ERRID_MASK; |
Marek Vasut | 526243c | 2014-04-24 20:05:17 +0200 | [diff] [blame] | 167 | u8 idx = (status & JRSTA_DECOERR_INDEX_MASK) >> |
| 168 | JRSTA_DECOERR_INDEX_SHIFT; |
Marek Vasut | 1e16322 | 2014-04-24 20:05:18 +0200 | [diff] [blame] | 169 | char *idx_str; |
| 170 | const char *cha_str = "unidentified cha_id value 0x"; |
| 171 | char cha_err_code[3] = { 0 }; |
| 172 | const char *err_str = "unidentified err_id value 0x"; |
| 173 | char err_err_code[3] = { 0 }; |
Marek Vasut | 8a47582 | 2014-04-24 20:05:15 +0200 | [diff] [blame] | 174 | |
Marek Vasut | 526243c | 2014-04-24 20:05:17 +0200 | [diff] [blame] | 175 | if (status & JRSTA_DECOERR_JUMP) |
Marek Vasut | 1e16322 | 2014-04-24 20:05:18 +0200 | [diff] [blame] | 176 | idx_str = "jump tgt desc idx"; |
Marek Vasut | 526243c | 2014-04-24 20:05:17 +0200 | [diff] [blame] | 177 | else |
Marek Vasut | 1e16322 | 2014-04-24 20:05:18 +0200 | [diff] [blame] | 178 | idx_str = "desc idx"; |
Marek Vasut | 526243c | 2014-04-24 20:05:17 +0200 | [diff] [blame] | 179 | |
Marek Vasut | 1e16322 | 2014-04-24 20:05:18 +0200 | [diff] [blame] | 180 | if (cha_id < ARRAY_SIZE(cha_id_list)) |
| 181 | cha_str = cha_id_list[cha_id]; |
| 182 | else |
| 183 | snprintf(cha_err_code, sizeof(cha_err_code), "%02x", cha_id); |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 184 | |
Kim Phillips | 281922a | 2012-06-22 19:48:52 -0500 | [diff] [blame] | 185 | if ((cha_id << JRSTA_CCBERR_CHAID_SHIFT) == JRSTA_CCBERR_CHAID_RNG && |
| 186 | err_id < ARRAY_SIZE(rng_err_id_list) && |
| 187 | strlen(rng_err_id_list[err_id])) { |
| 188 | /* RNG-only error */ |
Marek Vasut | 1e16322 | 2014-04-24 20:05:18 +0200 | [diff] [blame] | 189 | err_str = rng_err_id_list[err_id]; |
| 190 | } else if (err_id < ARRAY_SIZE(err_id_list)) |
| 191 | err_str = err_id_list[err_id]; |
| 192 | else |
| 193 | snprintf(err_err_code, sizeof(err_err_code), "%02x", err_id); |
Marek Vasut | e75880d | 2014-04-24 20:05:16 +0200 | [diff] [blame] | 194 | |
Marek Vasut | 1e16322 | 2014-04-24 20:05:18 +0200 | [diff] [blame] | 195 | dev_err(jrdev, "%08x: %s: %s %d: %s%s: %s%s\n", |
| 196 | status, error, idx_str, idx, |
| 197 | cha_str, cha_err_code, |
| 198 | err_str, err_err_code); |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 199 | } |
| 200 | |
Marek Vasut | e397ee0 | 2014-04-24 20:05:21 +0200 | [diff] [blame^] | 201 | static void report_jump_status(struct device *jrdev, const u32 status, |
| 202 | const char *error) |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 203 | { |
Marek Vasut | e75880d | 2014-04-24 20:05:16 +0200 | [diff] [blame] | 204 | dev_err(jrdev, "%08x: %s: %s() not implemented\n", |
| 205 | status, error, __func__); |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 206 | } |
| 207 | |
Marek Vasut | e397ee0 | 2014-04-24 20:05:21 +0200 | [diff] [blame^] | 208 | static void report_deco_status(struct device *jrdev, const u32 status, |
| 209 | const char *error) |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 210 | { |
Marek Vasut | 4f0fa52 | 2014-04-24 20:05:19 +0200 | [diff] [blame] | 211 | u8 err_id = status & JRSTA_DECOERR_ERROR_MASK; |
Marek Vasut | 526243c | 2014-04-24 20:05:17 +0200 | [diff] [blame] | 212 | u8 idx = (status & JRSTA_DECOERR_INDEX_MASK) >> |
| 213 | JRSTA_DECOERR_INDEX_SHIFT; |
Marek Vasut | 4f0fa52 | 2014-04-24 20:05:19 +0200 | [diff] [blame] | 214 | char *idx_str; |
Marek Vasut | e397ee0 | 2014-04-24 20:05:21 +0200 | [diff] [blame^] | 215 | const char *err_str = "unidentified error value 0x"; |
Marek Vasut | 4f0fa52 | 2014-04-24 20:05:19 +0200 | [diff] [blame] | 216 | char err_err_code[3] = { 0 }; |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 217 | int i; |
| 218 | |
Marek Vasut | 526243c | 2014-04-24 20:05:17 +0200 | [diff] [blame] | 219 | if (status & JRSTA_DECOERR_JUMP) |
Marek Vasut | 4f0fa52 | 2014-04-24 20:05:19 +0200 | [diff] [blame] | 220 | idx_str = "jump tgt desc idx"; |
Marek Vasut | 526243c | 2014-04-24 20:05:17 +0200 | [diff] [blame] | 221 | else |
Marek Vasut | 4f0fa52 | 2014-04-24 20:05:19 +0200 | [diff] [blame] | 222 | idx_str = "desc idx"; |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 223 | |
Dan Carpenter | 6d00376 | 2011-03-23 21:21:53 +0800 | [diff] [blame] | 224 | for (i = 0; i < ARRAY_SIZE(desc_error_list); i++) |
Marek Vasut | 4f0fa52 | 2014-04-24 20:05:19 +0200 | [diff] [blame] | 225 | if (desc_error_list[i].value == err_id) |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 226 | break; |
| 227 | |
Marek Vasut | 4f0fa52 | 2014-04-24 20:05:19 +0200 | [diff] [blame] | 228 | if (i != ARRAY_SIZE(desc_error_list) && desc_error_list[i].error_text) |
| 229 | err_str = desc_error_list[i].error_text; |
| 230 | else |
| 231 | snprintf(err_err_code, sizeof(err_err_code), "%02x", err_id); |
Marek Vasut | e75880d | 2014-04-24 20:05:16 +0200 | [diff] [blame] | 232 | |
Marek Vasut | 4f0fa52 | 2014-04-24 20:05:19 +0200 | [diff] [blame] | 233 | dev_err(jrdev, "%08x: %s: %s %d: %s%s\n", |
| 234 | status, error, idx_str, idx, err_str, err_err_code); |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 235 | } |
| 236 | |
Marek Vasut | e397ee0 | 2014-04-24 20:05:21 +0200 | [diff] [blame^] | 237 | static void report_jr_status(struct device *jrdev, const u32 status, |
| 238 | const char *error) |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 239 | { |
Marek Vasut | e75880d | 2014-04-24 20:05:16 +0200 | [diff] [blame] | 240 | dev_err(jrdev, "%08x: %s: %s() not implemented\n", |
| 241 | status, error, __func__); |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 242 | } |
| 243 | |
Marek Vasut | e397ee0 | 2014-04-24 20:05:21 +0200 | [diff] [blame^] | 244 | static void report_cond_code_status(struct device *jrdev, const u32 status, |
| 245 | const char *error) |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 246 | { |
Marek Vasut | e75880d | 2014-04-24 20:05:16 +0200 | [diff] [blame] | 247 | dev_err(jrdev, "%08x: %s: %s() not implemented\n", |
| 248 | status, error, __func__); |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 249 | } |
| 250 | |
Marek Vasut | fa9659c | 2014-04-24 20:05:12 +0200 | [diff] [blame] | 251 | void caam_jr_strstatus(struct device *jrdev, u32 status) |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 252 | { |
Kim Phillips | 96aef9a | 2013-03-26 18:10:15 -0500 | [diff] [blame] | 253 | static const struct stat_src { |
Marek Vasut | e397ee0 | 2014-04-24 20:05:21 +0200 | [diff] [blame^] | 254 | void (*report_ssed)(struct device *jrdev, const u32 status, |
| 255 | const char *error); |
Marek Vasut | 8a47582 | 2014-04-24 20:05:15 +0200 | [diff] [blame] | 256 | const char *error; |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 257 | } status_src[] = { |
| 258 | { NULL, "No error" }, |
| 259 | { NULL, NULL }, |
| 260 | { report_ccb_status, "CCB" }, |
| 261 | { report_jump_status, "Jump" }, |
| 262 | { report_deco_status, "DECO" }, |
| 263 | { NULL, NULL }, |
| 264 | { report_jr_status, "Job Ring" }, |
| 265 | { report_cond_code_status, "Condition Code" }, |
| 266 | }; |
| 267 | u32 ssrc = status >> JRSTA_SSRC_SHIFT; |
Marek Vasut | e397ee0 | 2014-04-24 20:05:21 +0200 | [diff] [blame^] | 268 | const char *error = status_src[ssrc].error; |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 269 | |
Marek Vasut | 867e1ee | 2014-04-24 20:05:14 +0200 | [diff] [blame] | 270 | /* |
| 271 | * If there is no further error handling function, just |
Marek Vasut | e397ee0 | 2014-04-24 20:05:21 +0200 | [diff] [blame^] | 272 | * print the error code, error string and exit. Otherwise |
| 273 | * call the handler function. |
Marek Vasut | 867e1ee | 2014-04-24 20:05:14 +0200 | [diff] [blame] | 274 | */ |
Marek Vasut | e397ee0 | 2014-04-24 20:05:21 +0200 | [diff] [blame^] | 275 | if (!status_src[ssrc].report_ssed) |
Marek Vasut | 867e1ee | 2014-04-24 20:05:14 +0200 | [diff] [blame] | 276 | dev_err(jrdev, "%08x: %s: \n", status, status_src[ssrc].error); |
Marek Vasut | e397ee0 | 2014-04-24 20:05:21 +0200 | [diff] [blame^] | 277 | else |
| 278 | status_src[ssrc].report_ssed(jrdev, status, error); |
Kim Phillips | 8e8ec59 | 2011-03-13 16:54:26 +0800 | [diff] [blame] | 279 | } |
| 280 | EXPORT_SYMBOL(caam_jr_strstatus); |