symbolize.py: translate TA panic codes
When a TA panics, the TEE core shows the panic code as follows:
E/TC:? 0 TA panicked with code 0xffff000f
The value is whatever was passed to TEE_Panic() by the TA or the library
that caused the panic; typically, the TEE Intenal Core API functions
implemented in libutee. It quite often happens that this value is a
TEE_Result code. Therefore it is convenient to translate the hexadecimal
value to a symbolic name (TEE_ERROR_*). With this commit, if a match is
found, the name is shown in parentheses like so:
E/TC:? 0 TA panicked with code 0xffff000f (TEE_ERROR_SECURITY)
If the code doesn't correspond to a known TEE_Result value however
nothing is appended to the output.
Suggested-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Peter Griffin <peter.griffin@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/scripts/symbolize.py b/scripts/symbolize.py
index d763fb0..998bada 100755
--- a/scripts/symbolize.py
+++ b/scripts/symbolize.py
@@ -21,6 +21,7 @@
STACK_ADDR_RE = re.compile(
r'[UEIDFM]/(TC|LD):(\?*|[0-9]*) [0-9]* +(?P<addr>0x[0-9a-f]+)')
ABORT_ADDR_RE = re.compile(r'-abort at address (?P<addr>0x[0-9a-f]+)')
+TA_PANIC_RE = re.compile(r'TA panicked with code (?P<code>0x[0-9a-f]+)')
REGION_RE = re.compile(r'region +[0-9]+: va (?P<addr>0x[0-9a-f]+) '
r'pa 0x[0-9a-f]+ size (?P<size>0x[0-9a-f]+)'
r'( flags .{4} (\[(?P<elf_idx>[0-9]+)\])?)?')
@@ -75,6 +76,39 @@
^D
'''
+tee_result_names = {
+ '0xf0100001': 'TEE_ERROR_CORRUPT_OBJECT',
+ '0xf0100002': 'TEE_ERROR_CORRUPT_OBJECT_2',
+ '0xf0100003': 'TEE_ERROR_STORAGE_NOT_AVAILABLE',
+ '0xf0100004': 'TEE_ERROR_STORAGE_NOT_AVAILABLE_2',
+ '0xf0100006': 'TEE_ERROR_CIPHERTEXT_INVALID ',
+ '0xffff0000': 'TEE_ERROR_GENERIC',
+ '0xffff0001': 'TEE_ERROR_ACCESS_DENIED',
+ '0xffff0002': 'TEE_ERROR_CANCEL',
+ '0xffff0003': 'TEE_ERROR_ACCESS_CONFLICT',
+ '0xffff0004': 'TEE_ERROR_EXCESS_DATA',
+ '0xffff0005': 'TEE_ERROR_BAD_FORMAT',
+ '0xffff0006': 'TEE_ERROR_BAD_PARAMETERS',
+ '0xffff0007': 'TEE_ERROR_BAD_STATE',
+ '0xffff0008': 'TEE_ERROR_ITEM_NOT_FOUND',
+ '0xffff0009': 'TEE_ERROR_NOT_IMPLEMENTED',
+ '0xffff000a': 'TEE_ERROR_NOT_SUPPORTED',
+ '0xffff000b': 'TEE_ERROR_NO_DATA',
+ '0xffff000c': 'TEE_ERROR_OUT_OF_MEMORY',
+ '0xffff000d': 'TEE_ERROR_BUSY',
+ '0xffff000e': 'TEE_ERROR_COMMUNICATION',
+ '0xffff000f': 'TEE_ERROR_SECURITY',
+ '0xffff0010': 'TEE_ERROR_SHORT_BUFFER',
+ '0xffff0011': 'TEE_ERROR_EXTERNAL_CANCEL',
+ '0xffff300f': 'TEE_ERROR_OVERFLOW',
+ '0xffff3024': 'TEE_ERROR_TARGET_DEAD',
+ '0xffff3041': 'TEE_ERROR_STORAGE_NO_SPACE',
+ '0xffff3071': 'TEE_ERROR_MAC_INVALID',
+ '0xffff3072': 'TEE_ERROR_SIGNATURE_INVALID',
+ '0xffff5000': 'TEE_ERROR_TIME_NOT_SET',
+ '0xffff5001': 'TEE_ERROR_TIME_NEEDS_RESET',
+ }
+
def get_args():
parser = argparse.ArgumentParser(
@@ -445,6 +479,13 @@
self._elfs[i] = [match.group('uuid'), match.group('load_addr'),
line]
return
+ match = re.search(TA_PANIC_RE, line)
+ if match:
+ code = match.group('code')
+ if code in tee_result_names:
+ line = line.strip() + ' (' + tee_result_names[code] + ')\n'
+ self._out.write(line)
+ return
match = re.search(TEE_LOAD_ADDR_RE, line)
if match:
self._tee_load_addr = match.group('load_addr')