diff options
author | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2021-01-29 17:07:28 +0000 |
---|---|---|
committer | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2021-03-26 11:03:06 +0000 |
commit | c076a0bc698c537f72c33bad2925f4e3da59d23c (patch) | |
tree | 188e36bfaa2c51ca50df2f1ef882a8fd57a61780 /malloc/malloc.c | |
parent | 42bac88a211a7fac9dd1bfe7d1e45e59ac50c24f (diff) | |
download | glibc-c076a0bc698c537f72c33bad2925f4e3da59d23c.tar.gz glibc-c076a0bc698c537f72c33bad2925f4e3da59d23c.tar.xz glibc-c076a0bc698c537f72c33bad2925f4e3da59d23c.zip |
malloc: Only support zeroing and not arbitrary memset with mtag
The memset api is suboptimal and does not provide much benefit. Memory tagging only needs a zeroing memset (and only for memory that's sized and aligned to multiples of the tag granule), so change the internal api and the target hooks accordingly. This is to simplify the implementation of the target hook. Reviewed-by: DJ Delorie <dj@redhat.com>
Diffstat (limited to 'malloc/malloc.c')
-rw-r--r-- | malloc/malloc.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c index 9c3981febe..9cfea1f878 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -413,12 +413,11 @@ void *(*__morecore)(ptrdiff_t) = __default_morecore; operations can continue to be used. Support macros are used to do this: - void *tag_new_memset (void *ptr, int, val, size_t size) + void *tag_new_zero_region (void *ptr, size_t size) - Has the same interface as memset(), but additionally allocates a - new tag, colors the memory with that tag and returns a pointer that - is correctly colored for that location. The non-tagging version - will simply call memset. + Allocates a new tag, colors the memory with that tag, zeros the + memory and returns a pointer that is correctly colored for that + location. The non-tagging version will simply call memset with 0. void *tag_region (void *ptr, size_t size) @@ -458,11 +457,11 @@ tag_region (void *ptr, size_t size) } static __always_inline void * -tag_new_memset (void *ptr, int val, size_t size) +tag_new_zero_region (void *ptr, size_t size) { if (__glibc_unlikely (mtag_enabled)) - return __libc_mtag_memset_with_tag (__libc_mtag_new_tag (ptr), val, size); - return memset (ptr, val, size); + return __libc_mtag_tag_zero_region (__libc_mtag_new_tag (ptr), size); + return memset (ptr, 0, size); } /* Defined later. */ @@ -3679,7 +3678,7 @@ __libc_calloc (size_t n, size_t elem_size) regardless of MORECORE_CLEARS, so we zero the whole block while doing so. */ #ifdef USE_MTAG - return tag_new_memset (mem, 0, CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ); + return tag_new_zero_region (mem, CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ); #else INTERNAL_SIZE_T csz = chunksize (p); |