chromium/base/allocator/partition_allocator/src/partition_alloc/thread_isolation/pkey.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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  // PA_BUILDFLAG(DCHECKS_ARE_ON)

}  // namespace partition_alloc::internal

#endif  // PA_BUILDFLAG(ENABLE_PKEYS)