| 12d739bd | 20-Dec-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: use raw_malloc_*() as more primitive bget wrappers
The malloc implementation is layered on top of BGET, where the raw_malloc_*() layer is the most primitive layer on top of BGET. This lay
libutils: use raw_malloc_*() as more primitive bget wrappers
The malloc implementation is layered on top of BGET, where the raw_malloc_*() layer is the most primitive layer on top of BGET. This layer is unlocked so it's up to the caller to handle eventual synchronization.
Until now this rule hasn't been followed completely by letting raw_malloc_get_stats() call gen_malloc_get_stats() and not the other way around. So fix this and also provide raw_malloc_buffer_overlaps_heap() and raw_malloc_buffer_is_within_alloced().
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| f21d4ead | 04-May-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: fix MTE error in realloc()
With memory tagging realloc() should only untag the old buffer if the allocation of a new buffer is successful.
The implementation of realloc() prior to this pa
libutils: fix MTE error in realloc()
With memory tagging realloc() should only untag the old buffer if the allocation of a new buffer is successful.
The implementation of realloc() prior to this patch is based on bgetr(). This is not so convenient with MTE enabled since the old buffer must be untagged before calling bgetr(). If realloc() fails the memory tags must be restored, but this was not done.
Restoring the tags is made somewhat more complicated by the fact that the size reported by bget_buf_size() may actually be larger than the size of the tagged buffer. Memalign() is sometimes forced to allocate buffers larger than requested in order to honor the requested alignment.
So instead of using bgetr(), realloc() is implemented using bget(), memcpy(), memset() and brel() as needed. This is the same thing that bgetr() did, except that the old buffer is not untagged until a new buffer has been successfully allocated.
Fixes: 08a5c4f9ae42 ("libutils: add MTE support in malloc() and friends") Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (vexpress-qemu_armv8a gp_20056) Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|