Revert "Add tagged pointers to bionic."

This reverts commit 43d5f9d4dd83d15a859d9be1359c4a4a47381fea.

Bug: 135754954
Bug: 147147490

Exempt-From-Owner-Approval: clean revert

Reason for revert: Breaks ART gtest, see:
https://ci.chromium.org/p/art/builders/ci/angler-armv8-non-gen-cc/561

The crash happens on mprotect of a page, the test crashes with ENOMEM.

Change-Id: I52eea1abbfaf8d8e2226f92d30aa55aba3810528
diff --git a/libc/bionic/malloc_common.cpp b/libc/bionic/malloc_common.cpp
index 199d7fc..a0da3db 100644
--- a/libc/bionic/malloc_common.cpp
+++ b/libc/bionic/malloc_common.cpp
@@ -43,7 +43,6 @@
 
 #include "malloc_common.h"
 #include "malloc_limit.h"
-#include "malloc_tagged_pointers.h"
 
 // =============================================================================
 // Global variables instantations.
@@ -62,18 +61,17 @@
 extern "C" void* calloc(size_t n_elements, size_t elem_size) {
   auto dispatch_table = GetDispatchTable();
   if (__predict_false(dispatch_table != nullptr)) {
-    return MaybeTagPointer(dispatch_table->calloc(n_elements, elem_size));
+    return dispatch_table->calloc(n_elements, elem_size);
   }
   void* result = Malloc(calloc)(n_elements, elem_size);
   if (__predict_false(result == nullptr)) {
     warning_log("calloc(%zu, %zu) failed: returning null pointer", n_elements, elem_size);
   }
-  return MaybeTagPointer(result);
+  return result;
 }
 
 extern "C" void free(void* mem) {
   auto dispatch_table = GetDispatchTable();
-  mem = MaybeUntagAndCheckPointer(mem);
   if (__predict_false(dispatch_table != nullptr)) {
     dispatch_table->free(mem);
   } else {
@@ -107,22 +105,18 @@
 
 extern "C" void* malloc(size_t bytes) {
   auto dispatch_table = GetDispatchTable();
-  void *result;
   if (__predict_false(dispatch_table != nullptr)) {
-    result = dispatch_table->malloc(bytes);
-  } else {
-    result = Malloc(malloc)(bytes);
+    return dispatch_table->malloc(bytes);
   }
+  void* result = Malloc(malloc)(bytes);
   if (__predict_false(result == nullptr)) {
     warning_log("malloc(%zu) failed: returning null pointer", bytes);
-    return nullptr;
   }
-  return MaybeTagPointer(result);
+  return result;
 }
 
 extern "C" size_t malloc_usable_size(const void* mem) {
   auto dispatch_table = GetDispatchTable();
-  mem = MaybeUntagAndCheckPointer(mem);
   if (__predict_false(dispatch_table != nullptr)) {
     return dispatch_table->malloc_usable_size(mem);
   }
@@ -132,52 +126,45 @@
 extern "C" void* memalign(size_t alignment, size_t bytes) {
   auto dispatch_table = GetDispatchTable();
   if (__predict_false(dispatch_table != nullptr)) {
-    return MaybeTagPointer(dispatch_table->memalign(alignment, bytes));
+    return dispatch_table->memalign(alignment, bytes);
   }
   void* result = Malloc(memalign)(alignment, bytes);
   if (__predict_false(result == nullptr)) {
     warning_log("memalign(%zu, %zu) failed: returning null pointer", alignment, bytes);
   }
-  return MaybeTagPointer(result);
+  return result;
 }
 
 extern "C" int posix_memalign(void** memptr, size_t alignment, size_t size) {
   auto dispatch_table = GetDispatchTable();
-  int result;
   if (__predict_false(dispatch_table != nullptr)) {
-    result = dispatch_table->posix_memalign(memptr, alignment, size);
-  } else {
-    result = Malloc(posix_memalign)(memptr, alignment, size);
+    return dispatch_table->posix_memalign(memptr, alignment, size);
   }
-  if (result == 0) {
-    *memptr = MaybeTagPointer(*memptr);
-  }
-  return result;
+  return Malloc(posix_memalign)(memptr, alignment, size);
 }
 
 extern "C" void* aligned_alloc(size_t alignment, size_t size) {
   auto dispatch_table = GetDispatchTable();
   if (__predict_false(dispatch_table != nullptr)) {
-    return MaybeTagPointer(dispatch_table->aligned_alloc(alignment, size));
+    return dispatch_table->aligned_alloc(alignment, size);
   }
   void* result = Malloc(aligned_alloc)(alignment, size);
   if (__predict_false(result == nullptr)) {
     warning_log("aligned_alloc(%zu, %zu) failed: returning null pointer", alignment, size);
   }
-  return MaybeTagPointer(result);
+  return result;
 }
 
 extern "C" __attribute__((__noinline__)) void* realloc(void* old_mem, size_t bytes) {
   auto dispatch_table = GetDispatchTable();
-  old_mem = MaybeUntagAndCheckPointer(old_mem);
   if (__predict_false(dispatch_table != nullptr)) {
-    return MaybeTagPointer(dispatch_table->realloc(old_mem, bytes));
+    return dispatch_table->realloc(old_mem, bytes);
   }
   void* result = Malloc(realloc)(old_mem, bytes);
   if (__predict_false(result == nullptr && bytes != 0)) {
     warning_log("realloc(%p, %zu) failed: returning null pointer", old_mem, bytes);
   }
-  return MaybeTagPointer(result);
+  return result;
 }
 
 extern "C" void* reallocarray(void* old_mem, size_t item_count, size_t item_size) {
@@ -195,66 +182,42 @@
 extern "C" void* pvalloc(size_t bytes) {
   auto dispatch_table = GetDispatchTable();
   if (__predict_false(dispatch_table != nullptr)) {
-    return MaybeTagPointer(dispatch_table->pvalloc(bytes));
+    return dispatch_table->pvalloc(bytes);
   }
   void* result = Malloc(pvalloc)(bytes);
   if (__predict_false(result == nullptr)) {
     warning_log("pvalloc(%zu) failed: returning null pointer", bytes);
   }
-  return MaybeTagPointer(result);
+  return result;
 }
 
 extern "C" void* valloc(size_t bytes) {
   auto dispatch_table = GetDispatchTable();
   if (__predict_false(dispatch_table != nullptr)) {
-    return MaybeTagPointer(dispatch_table->valloc(bytes));
+    return dispatch_table->valloc(bytes);
   }
   void* result = Malloc(valloc)(bytes);
   if (__predict_false(result == nullptr)) {
     warning_log("valloc(%zu) failed: returning null pointer", bytes);
   }
-  return MaybeTagPointer(result);
+  return result;
 }
 #endif
 // =============================================================================
 
-struct CallbackWrapperArg {
-  void (*callback)(uintptr_t base, size_t size, void* arg);
-  void* arg;
-};
-
-void CallbackWrapper(uintptr_t base, size_t size, void* arg) {
-  CallbackWrapperArg* wrapper_arg = reinterpret_cast<CallbackWrapperArg*>(arg);
-  wrapper_arg->callback(
-    reinterpret_cast<uintptr_t>(MaybeTagPointer(reinterpret_cast<void*>(base))),
-    size, wrapper_arg->arg);
-}
-
 // =============================================================================
 // Exported for use by libmemunreachable.
 // =============================================================================
 
 // Calls callback for every allocation in the anonymous heap mapping
-// [base, base+size). Must be called between malloc_disable and malloc_enable.
-// `base` in this can take either a tagged or untagged pointer, but we always
-// provide a tagged pointer to the `base` argument of `callback` if the kernel
-// supports tagged pointers.
+// [base, base+size).  Must be called between malloc_disable and malloc_enable.
 extern "C" int malloc_iterate(uintptr_t base, size_t size,
     void (*callback)(uintptr_t base, size_t size, void* arg), void* arg) {
   auto dispatch_table = GetDispatchTable();
-  // Wrap the malloc_iterate callback we were provided, in order to provide
-  // pointer tagging support.
-  CallbackWrapperArg wrapper_arg;
-  wrapper_arg.callback = callback;
-  wrapper_arg.arg = arg;
-  uintptr_t untagged_base =
-      reinterpret_cast<uintptr_t>(UntagPointer(reinterpret_cast<void*>(base)));
   if (__predict_false(dispatch_table != nullptr)) {
-    return dispatch_table->malloc_iterate(
-      untagged_base, size, CallbackWrapper, &wrapper_arg);
+    return dispatch_table->malloc_iterate(base, size, callback, arg);
   }
-  return Malloc(malloc_iterate)(
-    untagged_base, size, CallbackWrapper, &wrapper_arg);
+  return Malloc(malloc_iterate)(base, size, callback, arg);
 }
 
 // Disable calls to malloc so malloc_iterate gets a consistent view of