Skip to content

Commit

Permalink
[Review] Add support for compressed early TAs
Browse files Browse the repository at this point in the history
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
  • Loading branch information
jforissier committed Aug 4, 2017
1 parent ab1e016 commit 9ec0c57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions core/arch/arm/kernel/early_ta.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
#include <kernel/early_ta.h>
#include <kernel/linker.h>
#include <kernel/user_ta.h>
#include <zlib.h>
#include <stdio.h>
#include <string.h>
#include <trace.h>
#include <util.h>
#include <zlib.h>

#include "elf_load.h"

Expand Down Expand Up @@ -80,9 +80,10 @@ static bool decompression_init(z_stream *strm,
strm->zfree = zfree;
st = inflateInit(strm);
if (st != Z_OK) {
DMSG("Early TA decompression initialization error (%d)", st);
EMSG("Decompression initialization error (%d)", st);
return false;
}

return true;
}

Expand All @@ -108,7 +109,6 @@ static TEE_Result early_ta_open(const TEE_UUID *uuid,
free(handle);
return TEE_ERROR_BAD_FORMAT;
}

}
handle->early_ta = ta;
*h = handle;
Expand Down Expand Up @@ -166,7 +166,7 @@ static TEE_Result read_compressed(struct user_ta_store_handle *h, void *data,
strm->avail_out = MIN(len, 1024U);
tmpbuf = malloc(strm->avail_out);
if (!tmpbuf) {
DMSG("Could not allocate temporary buffer");
EMSG("Out of memory");
return TEE_ERROR_OUT_OF_MEMORY;
}
strm->next_out = tmpbuf;
Expand All @@ -192,14 +192,15 @@ static TEE_Result read_compressed(struct user_ta_store_handle *h, void *data,
}
} while ((st == Z_OK || st == Z_BUF_ERROR) && (total != len));
if (st != Z_OK && st != Z_STREAM_END && st != Z_BUF_ERROR) {
DMSG("TA decompression error (%d)", st);
EMSG("Decompression error (%d)", st);
ret = TEE_ERROR_GENERIC;
goto out;
}
ret = TEE_SUCCESS;
out:
if (!data)
free(tmpbuf);

return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/ta_bin_to_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import os
import re
import uuid
import zlib

def get_args():

Expand All @@ -52,7 +53,6 @@ def get_args():
return parser.parse_args()

def main():
import zlib

args = get_args();

Expand Down

0 comments on commit 9ec0c57

Please sign in to comment.