Attention is currently required from: Angel Pons. Arthur Heymans has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/54092 )
Change subject: security/intel/txt: Split of microcode error type printing ......................................................................
Patch Set 3:
(3 comments)
File src/security/intel/txt/logging.c:
https://review.coreboot.org/c/coreboot/+/54092/comment/19245281_651a3852 PS3, Line 12: microcode
Document 315168-017 calls these "processor-initiated Intel TXT shutdowns". […]
Done
https://review.coreboot.org/c/coreboot/+/54092/comment/c0ce32d0_318235af PS3, Line 14: types
Maybe call this `names` to avoid confusion with the `type` parameter?
Done
https://review.coreboot.org/c/coreboot/+/54092/comment/fedd0921_95ff3dd3 PS3, Line 31: };
There's a much better way to do this:
const char *intel_txt_processor_error_type(uint8_t type) { static const char *const names[] = { [0] = "Legacy Shutdown", [5] = "Load memory type error in ACM area", [6] = "Unrecognized ACM format", [7] = "Failure to authenticate", [8] = "Invalid ACM format", [9] = "Unexpected Snoop hit", [10] = "Invalid event", [11] = "Invalid MLE", [12] = "Machine check event", [13] = "VMXAbort", [14] = "AC memory corruption", [15] = "Illegal voltage/bus ratio", }; return type < ARRAY_SIZE(names) && names[type] ? names[type] : "Unknown"; }
Done
This can be improved even further if one makes the function print the strings directly, and return nothing:
void intel_txt_log_processor_error(int loglevel, uint8_t type) { static const char *const names[] = { [0] = "Legacy Shutdown", [5] = "Load memory type error in ACM area", [6] = "Unrecognized ACM format", [7] = "Failure to authenticate", [8] = "Invalid ACM format", [9] = "Unexpected Snoop hit", [10] = "Invalid event", [11] = "Invalid MLE", [12] = "Machine check event", [13] = "VMXAbort", [14] = "AC memory corruption", [15] = "Illegal voltage/bus ratio", }; if (type < ARRAY_SIZE(names) && names[type]) printk(loglevel, "Error condition: %s\n", names[type]); else printk(loglevel, "Error condition: Unknown %u\n", type); }
I prefer to just return strings as it makes it easier to reuse in different error logging parts (cbnt).