Loading...
--- libmalloc/libmalloc-792.80.2/src/malloc_exclaves.c
+++ libmalloc/libmalloc-715.140.5/src/malloc_exclaves.c
@@ -42,10 +42,6 @@
 
 bool malloc_sanitizer_enabled = false;
 
-#if CONFIG_MTE
-bool malloc_has_sec_transition = false;
-uint32_t malloc_sec_transition_policy = 0;
-#endif
 
 #if __LIBLIBC_F_ASAN_INSTRUMENTATION
 static struct malloc_sanitizer_poison malloc_poison_default = {
@@ -150,12 +146,10 @@
 	logical_ncpus = _liblibc_plat_num_cpus;
 	phys_ncpus = _liblibc_plat_num_cpus;
 
-#if CONFIG_MTE
-	malloc_has_sec_transition = xrt__has_sec_transition();
-#endif
 
 	const unsigned malloc_debug_flags = MALLOC_ABORT_ON_CORRUPTION |
 			MALLOC_ABORT_ON_ERROR;
+	mfm_initialize();
 	malloc_zone_t *xzone = xzm_main_malloc_zone_create(malloc_debug_flags,
 			NULL, args, NULL);
 	_malloc_zone_register(xzone, true);
@@ -299,7 +293,7 @@
 
 	// excludes 0 == alignment
 	// relies on sizeof(void *) being a power of two.
-	if (alignment < MALLOC_ZONE_MALLOC_DEFAULT_ALIGN ||
+	if (alignment < sizeof(void *) ||
 			0 != (alignment & (alignment - 1))) {
 		err = EINVAL;
 		goto out;
@@ -335,12 +329,11 @@
 
 MALLOC_NOINLINE
 void * __sized_by_or_null(size)
-malloc_zone_malloc_with_options(malloc_zone_t *zone, size_t align,
-		size_t size, malloc_zone_malloc_options_t options)
-{
-	if (align != MALLOC_ZONE_MALLOC_DEFAULT_ALIGN &&
-			(os_unlikely((align != 0) && (!powerof2(align) ||
-			((size & (align-1)) != 0))))) { // equivalent to (size % align != 0)
+malloc_zone_malloc_with_options_np(malloc_zone_t *zone, size_t align,
+		size_t size, malloc_options_np_t options)
+{
+	if (os_unlikely((align != 0) && (!powerof2(align) ||
+			((size & (align-1)) != 0)))) { // equivalent to (size % align != 0)
 		return NULL;
 	}
 
@@ -352,25 +345,17 @@
 		return zone->malloc_with_options(zone, align, size, options);
 	}
 
-	if (align > MALLOC_ZONE_MALLOC_DEFAULT_ALIGN) {
+	if (align) {
 		void *ptr = zone->memalign(zone, align, size);
-		if (ptr && (options & MALLOC_ZONE_MALLOC_OPTION_CLEAR)) {
+		if (ptr && (options & MALLOC_NP_OPTION_CLEAR)) {
 			memset(ptr, 0, size);
 		}
 		return ptr;
-	} else if (options & MALLOC_ZONE_MALLOC_OPTION_CLEAR) {
+	} else if (options & MALLOC_NP_OPTION_CLEAR) {
 		return zone->calloc(zone, 1, size);
 	} else {
 		return zone->malloc(zone, size);
 	}
-}
-
-MALLOC_NOINLINE
-void * __sized_by_or_null(size)
-malloc_zone_malloc_with_options_np(malloc_zone_t *zone, size_t align,
-		size_t size, malloc_options_np_t options)
-{
-	return malloc_zone_malloc_with_options(zone, align, size, options);
 }
 
 boolean_t
@@ -584,7 +569,7 @@
 		// the test made in malloc_zone_memalign to vet each request. Only if
 		// that test fails and returns NULL, do we arrive here to detect the
 		// bogus alignment and give the required EINVAL return.
-		if (alignment < MALLOC_ZONE_MALLOC_DEFAULT_ALIGN || // excludes 0 == alignment
+		if (alignment < sizeof(void *) ||             // excludes 0 == alignment
 				0 != (alignment & (alignment - 1))) { // relies on sizeof(void *)
 													  // being a power of two.
 			return EINVAL;