#include "partition_alloc/thread_isolation/pkey.h"
#if PA_BUILDFLAG(ENABLE_PKEYS)
#include <sys/mman.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <cerrno>
#include "partition_alloc/partition_alloc_base/cpu.h"
#include "partition_alloc/partition_alloc_check.h"
#include "partition_alloc/thread_isolation/thread_isolation.h"
#if !PA_BUILDFLAG(IS_LINUX) && !PA_BUILDFLAG(IS_CHROMEOS)
#error "This pkey code is currently only supported on Linux and ChromeOS"
#endif
namespace partition_alloc::internal {
PA_COMPONENT_EXPORT(PARTITION_ALLOC)
bool CPUHasPkeySupport() { … }
PA_COMPONENT_EXPORT(PARTITION_ALLOC)
int PkeyMprotect(void* addr, size_t len, int prot, int pkey) { … }
void TagMemoryWithPkey(int pkey, void* address, size_t size) { … }
PA_COMPONENT_EXPORT(PARTITION_ALLOC)
int PkeyAlloc(int access_rights) { … }
PA_COMPONENT_EXPORT(PARTITION_ALLOC)
void PkeyFree(int pkey) { … }
uint32_t Rdpkru() { … }
void Wrpkru(uint32_t pkru) { … }
#if PA_BUILDFLAG(DCHECKS_ARE_ON)
LiftPkeyRestrictionsScope::LiftPkeyRestrictionsScope()
: … { … }
LiftPkeyRestrictionsScope::~LiftPkeyRestrictionsScope() { … }
#endif
}
#endif