#include <stdint.h>
#include <sys/mman.h>
#include "partition_alloc/build_config.h"
#include "partition_alloc/buildflags.h"
#include "partition_alloc/page_allocator.h"
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING) || \
(defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1))
struct __ifunc_arg_t;
#include "partition_alloc/aarch64_support.h"
#define NEEDS_HANDLING_OF_HW_CAPABILITIES
#endif
#define PA_PROT_BTI …
#define PA_PROT_MTE …
namespace partition_alloc::internal {
namespace {
int GetAccessFlags(PageAccessibilityConfiguration accessibility,
bool mte_enabled,
bool bti_enabled) { … }
template <bool MteEnabled, bool BtiEnabled>
int GetAccessFlags(PageAccessibilityConfiguration accessibility) { … }
}
#if defined(NEEDS_HANDLING_OF_HW_CAPABILITIES)
using GetAccessFlagsInternalFn = int(PageAccessibilityConfiguration);
extern "C" GetAccessFlagsInternalFn* ResolveGetAccessFlags(
uint64_t hwcap,
struct __ifunc_arg_t* hw) {
if (IsMteEnabled(hwcap, hw)) {
if (IsBtiEnabled(hwcap, hw)) {
return GetAccessFlags<true, true>;
} else {
return GetAccessFlags<true, false>;
}
} else {
if (IsBtiEnabled(hwcap, hw)) {
return GetAccessFlags<false, true>;
} else {
return GetAccessFlags<false, false>;
}
}
}
#endif
int GetAccessFlags(PageAccessibilityConfiguration accessibility)
#if defined(NEEDS_HANDLING_OF_HW_CAPABILITIES)
__attribute__((ifunc("ResolveGetAccessFlags")));
#else
{ … }
#endif
}