summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJi Luo <ji.luo@nxp.com>2019-02-20 10:04:20 +0800
committerJi Luo <ji.luo@nxp.com>2019-02-21 18:05:35 +0800
commita418bbd42ce5a8c2773640fe64ad2c5bb2ea4cfa (patch)
tree4abda1e9c00132b601811f0ade9bbbaf9f283e98 /lib
parent8f3f0d339783e066f7815408949677b62e465b62 (diff)
MA-14043 Fix avb verify fail in adb reboot test
During AVB verify, CAAM will be invoked to calculate the hash of boot.img and dtbo.img. ALLOC_CACHE_ALIGN_BUFFER() supports allocate cache aligned buffer on *stack*, which may cause 'dirty' dcache data be flushed to dram after CAAM operations complete. Use memalign() to allocate cache aligned buffer on *heap* to fix this issue. Test: 1200 times reboot test on imx8qm and 2300 times reboot on imx8qxp. Change-Id: I8f86248df318093d44a46dcab76306377898766e Signed-off-by: Ji Luo <ji.luo@nxp.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/avb/libavb/avb_slot_verify.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/avb/libavb/avb_slot_verify.c b/lib/avb/libavb/avb_slot_verify.c
index bcb0357e3a..8651dfb0ed 100644
--- a/lib/avb/libavb/avb_slot_verify.c
+++ b/lib/avb/libavb/avb_slot_verify.c
@@ -300,7 +300,12 @@ static AvbSlotVerifyResult load_and_verify_hash_partition(
if (avb_strcmp((const char*)hash_desc.hash_algorithm, "sha256") == 0) {
#if defined(CONFIG_IMX_TRUSTY_OS) && !defined(CONFIG_AVB_ATX)
/* DMA requires cache aligned input/output buffer */
- ALLOC_CACHE_ALIGN_BUFFER(uint8_t, hash_out, AVB_SHA256_DIGEST_SIZE);
+ uint8_t *hash_out = memalign(ARCH_DMA_MINALIGN, AVB_SHA256_DIGEST_SIZE);
+ if (hash_out == NULL) {
+ avb_error("failed to alloc memory!\n");
+ return AVB_SLOT_VERIFY_RESULT_ERROR_OOM;
+ goto out;
+ }
uint32_t round_buf_size = ROUND(hash_desc.salt_len + hash_desc.image_size,
ARCH_DMA_MINALIGN);
uint8_t *hash_buf = memalign(ARCH_DMA_MINALIGN, round_buf_size);
@@ -383,6 +388,8 @@ static AvbSlotVerifyResult load_and_verify_hash_partition(
out:
+ if (digest != NULL)
+ free(digest);
/* If it worked and something was loaded, copy to slot_data. */
if ((ret == AVB_SLOT_VERIFY_RESULT_OK || result_should_continue(ret)) &&
image_buf != NULL) {