diff --git a/core/arch/arm/kernel/user_ta.c b/core/arch/arm/kernel/user_ta.c index 808cffd439f..e70061e3686 100644 --- a/core/arch/arm/kernel/user_ta.c +++ b/core/arch/arm/kernel/user_ta.c @@ -197,8 +197,12 @@ static struct mobj *alloc_ta_mem(size_t size) #else struct mobj *mobj = mobj_mm_alloc(mobj_sec_ddr, size, &tee_mm_sec_ddr); - if (mobj) - memset(mobj_get_va(mobj, 0), 0, size); + if (mobj) { + size_t granularity = BIT(tee_mm_sec_ddr.shift); + + /* Round up to allocation granularity size */ + memset(mobj_get_va(mobj, 0), 0, ROUNDUP(size, granularity)); + } return mobj; #endif }