diff options
author | Mike Leach <mike.leach@linaro.org> | 2023-11-06 14:48:39 +0000 |
---|---|---|
committer | Mike Leach <mike.leach@linaro.org> | 2023-12-18 14:57:54 +0000 |
commit | 1d44e99cded93bb97dc5febbf660e1723eee56ec (patch) | |
tree | 59f8191215259bb811c7b9527484ae7efdcc0336 | |
parent | 47c98f1cbe4a119f9bf67177e2c980e5c8915578 (diff) |
opencsd: memacc: add in Realm and Root memory spaces
Decode defines memory spaces used to access program image.
RME requires that new spaces for Realm and Root are required.
New types defined to allow clients to set memory blocks / handle callbacks
for these memory spaces.
Signed-off-by: Mike Leach <mike.leach@linaro.org>
-rw-r--r-- | decoder/include/opencsd/ocsd_if_types.h | 21 | ||||
-rw-r--r-- | decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp | 30 | ||||
-rw-r--r-- | decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp | 6 |
3 files changed, 45 insertions, 12 deletions
diff --git a/decoder/include/opencsd/ocsd_if_types.h b/decoder/include/opencsd/ocsd_if_types.h index cd96018cbb43..9e05416264c0 100644 --- a/decoder/include/opencsd/ocsd_if_types.h +++ b/decoder/include/opencsd/ocsd_if_types.h @@ -426,14 +426,19 @@ typedef struct _ocsd_pe_context { /** memory space bitfield enum for available security states and exception levels used when accessing memory. */ typedef enum _ocsd_mem_space_acc_t { - OCSD_MEM_SPACE_EL1S = 0x1, /**< S EL1/0 */ - OCSD_MEM_SPACE_EL1N = 0x2, /**< NS EL1/0 */ - OCSD_MEM_SPACE_EL2 = 0x4, /**< NS EL2 */ - OCSD_MEM_SPACE_EL3 = 0x8, /**< S EL3 */ - OCSD_MEM_SPACE_EL2S = 0x10, /**< S EL2 */ - OCSD_MEM_SPACE_S = 0x19, /**< Any S */ - OCSD_MEM_SPACE_N = 0x6, /**< Any NS */ - OCSD_MEM_SPACE_ANY = 0x1F, /**< Any sec level / EL - live system use current EL + sec state */ + OCSD_MEM_SPACE_NONE = 0x0, /**< Mem space unknown / not yet set */ + OCSD_MEM_SPACE_EL1S = 0x1, /**< Secure EL1/0 */ + OCSD_MEM_SPACE_EL1N = 0x2, /**< Non Secure EL1/0 */ + OCSD_MEM_SPACE_EL2 = 0x4, /**< Non Secure EL2 */ + OCSD_MEM_SPACE_EL3 = 0x8, /**< Secure EL3 */ + OCSD_MEM_SPACE_EL2S = 0x10, /**< Secure EL2 */ + OCSD_MEM_SPACE_EL1R = 0x20, /**< Realm EL1/0 */ + OCSD_MEM_SPACE_EL2R = 0x40, /**< Realm EL2 */ + OCSD_MEM_SPACE_ROOT = 0x80, /**< Root */ + OCSD_MEM_SPACE_S = 0x19, /**< Any Secure */ + OCSD_MEM_SPACE_N = 0x6, /**< Any Non Secure */ + OCSD_MEM_SPACE_R = 0x60, /**< Any Realm */ + OCSD_MEM_SPACE_ANY = 0xFF, /**< Any sec level / EL - live system use current EL + sec state */ } ocsd_mem_space_acc_t; /** diff --git a/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp b/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp index b96301252c4e..8f087c55cc4b 100644 --- a/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp +++ b/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp @@ -1995,7 +1995,6 @@ ocsd_err_t TrcPktDecodeEtmV4I::handlePacketErr(ocsd_err_t err, ocsd_err_severity } - inline ocsd_mem_space_acc_t TrcPktDecodeEtmV4I::getCurrMemSpace() { static ocsd_mem_space_acc_t SMemSpace[] = { @@ -2012,12 +2011,37 @@ inline ocsd_mem_space_acc_t TrcPktDecodeEtmV4I::getCurrMemSpace() OCSD_MEM_SPACE_EL3 }; + static ocsd_mem_space_acc_t RMemSpace[] = { + OCSD_MEM_SPACE_EL1R, + OCSD_MEM_SPACE_EL1R, + OCSD_MEM_SPACE_EL2R, + OCSD_MEM_SPACE_ROOT + }; + /* if no valid EL value - just use S/NS */ if (!outElem().context.el_valid) return m_is_secure ? OCSD_MEM_SPACE_S : OCSD_MEM_SPACE_N; - + /* mem space according to EL + S/NS */ + ocsd_mem_space_acc_t mem_space = OCSD_MEM_SPACE_NONE; int el = (int)(outElem().context.exception_level) & 0x3; - return m_is_secure ? SMemSpace[el] : NSMemSpace[el]; + + switch (outElem().context.security_level) + { + case ocsd_sec_root: + mem_space = OCSD_MEM_SPACE_ROOT; + break; + case ocsd_sec_realm: + mem_space = RMemSpace[el]; + break; + case ocsd_sec_nonsecure: + mem_space = NSMemSpace[el]; + break; + case ocsd_sec_secure: + mem_space = SMemSpace[el]; + break; + }; + + return mem_space; } /* End of File trc_pkt_decode_etmv4i.cpp */ diff --git a/decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp b/decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp index 825b5f79e41b..8475d7ee021d 100644 --- a/decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp +++ b/decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp @@ -666,7 +666,11 @@ void EtmV4ITrcPacket::contextStr(std::string &ctxtStr) const std::ostringstream oss; if(context.updated) { - oss << "Ctxt: " << (context.SF ? "AArch64," : "AArch32, ") << "EL" << context.EL << ", " << (context.NS ? "NS; " : "S; "); + oss << "Ctxt: " << (context.SF ? "AArch64," : "AArch32, ") << "EL" << context.EL << ", "; + if (context.NSE) + oss << (context.NS ? "Realm; " : "Root; "); + else + oss << (context.NS ? "NS; " : "S; "); if(context.updated_c) { oss << "CID=0x" << std::hex << std::setfill('0') << std::setw(8) << context.ctxtID << "; "; |