Some TZ backend fixes. 69/177269/7
authorr.tyminski <r.tyminski@partner.samsung.com>
Thu, 26 Apr 2018 13:23:53 +0000 (15:23 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 12 Oct 2018 12:33:19 +0000 (12:33 +0000)
- pass TEEC_Context by reference, not by value.
- print return origin from TEEC_InvokeCommand

Change-Id: Ib26415d0dfb454540c0f0b85d2dc50466f63ae14

src/manager/crypto/tz-backend/tz-context.cpp
src/manager/crypto/tz-backend/tz-memory.cpp
src/manager/crypto/tz-backend/tz-memory.h

index 83ac694..c6f2527 100644 (file)
@@ -997,9 +997,10 @@ void TrustZoneContext::Reload()
 
 void TrustZoneContext::Execute(tz_command commandID, TEEC_Operation* op)
 {
+       uint32_t retOrigin = 0;
        LogDebug("Executing TZ operation " << commandID);
 
-       TEEC_Result result = TEEC_InvokeCommand(&m_Session, static_cast<unsigned int>(commandID), op, NULL);
+       TEEC_Result result = TEEC_InvokeCommand(&m_Session, static_cast<unsigned int>(commandID), op, &retOrigin);
        if (result != TEEC_SUCCESS) {
                switch (result) {
                case TEEC_ERROR_TARGET_DEAD:
@@ -1011,7 +1012,8 @@ void TrustZoneContext::Execute(tz_command commandID, TEEC_Operation* op)
                default:
                        ThrowErr(Exc::Crypto::InternalError, "TA failed to invoke command ",
                                        static_cast<unsigned int>(commandID), " with error: ", std::hex,
-                                       static_cast<unsigned int>(result));
+                                       static_cast<unsigned int>(result), " with origin: ", std::hex,
+                                       retOrigin);
                }
        }
 
index 1f76e41..324463d 100644 (file)
@@ -31,7 +31,7 @@ namespace Crypto {
 namespace TZ {
 namespace Internals {
 
-TrustZoneMemory::TrustZoneMemory(TEEC_Context context, const size_t size, const uint32_t flags)
+TrustZoneMemory::TrustZoneMemory(TEEC_Context &context, const size_t size, const uint32_t flags)
 {
        Allocate(context, size, flags);
 }
@@ -41,7 +41,7 @@ TrustZoneMemory::~TrustZoneMemory()
        Release();
 }
 
-void TrustZoneMemory::Allocate(TEEC_Context context, const size_t size, const uint32_t flags)
+void TrustZoneMemory::Allocate(TEEC_Context &context, const size_t size, const uint32_t flags)
 {
        m_SharedMemory.size = size;
        m_SharedMemory.flags = flags;
index e4f559c..74e505c 100644 (file)
@@ -32,7 +32,7 @@ namespace Internals {
 class TrustZoneMemory final
 {
 public:
-    TrustZoneMemory(TEEC_Context context, const size_t size, const uint32_t flags);
+    TrustZoneMemory(TEEC_Context &context, const size_t size, const uint32_t flags);
     TrustZoneMemory(const TrustZoneMemory&) = delete;
     TrustZoneMemory(TrustZoneMemory &&) = delete;
     TrustZoneMemory& operator=(const TrustZoneMemory&) = delete;
@@ -42,7 +42,7 @@ public:
     TEEC_SharedMemory* Get() const;
 
 private:
-    void Allocate(TEEC_Context context, const size_t size, const uint32_t flags);
+    void Allocate(TEEC_Context &context, const size_t size, const uint32_t flags);
     void Release();
 
     mutable TEEC_SharedMemory m_SharedMemory;