arch/powerpc/include/asm/pkeys.h
Source file repositories/reference/linux-study-clean/arch/powerpc/include/asm/pkeys.h
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/include/asm/pkeys.h- Extension
.h- Size
- 4218 bytes
- Lines
- 171
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/jump_label.hasm/firmware.hasm/book3s/64/pkeys.h
Detected Declarations
function pkey_to_vmflag_bitsfunction vma_pkeyfunction arch_max_pkeyfunction pkey_alloc_maskfunction mm_pkey_allocfunction mm_pkey_freefunction arch_override_mprotect_pkeyfunction arch_set_user_pkey_accessfunction arch_pkeys_enabled
Annotated Snippet
#ifndef _ASM_POWERPC_KEYS_H
#define _ASM_POWERPC_KEYS_H
#include <linux/jump_label.h>
#include <asm/firmware.h>
extern int num_pkey;
extern u32 reserved_allocation_mask; /* bits set for reserved keys */
#define ARCH_VM_PKEY_FLAGS (VM_PKEY_BIT0 | VM_PKEY_BIT1 | VM_PKEY_BIT2 | \
VM_PKEY_BIT3 | VM_PKEY_BIT4)
/* Override any generic PKEY permission defines */
#define PKEY_DISABLE_EXECUTE 0x4
#define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS | \
PKEY_DISABLE_WRITE | \
PKEY_DISABLE_EXECUTE)
#ifdef CONFIG_PPC_BOOK3S_64
#include <asm/book3s/64/pkeys.h>
#else
#error "Not supported"
#endif
static inline vm_flags_t pkey_to_vmflag_bits(u16 pkey)
{
return (((vm_flags_t)pkey << VM_PKEY_SHIFT) & ARCH_VM_PKEY_FLAGS);
}
static inline int vma_pkey(struct vm_area_struct *vma)
{
if (!mmu_has_feature(MMU_FTR_PKEY))
return 0;
return (vma->vm_flags & ARCH_VM_PKEY_FLAGS) >> VM_PKEY_SHIFT;
}
static inline int arch_max_pkey(void)
{
return num_pkey;
}
#define pkey_alloc_mask(pkey) (0x1 << pkey)
#define mm_pkey_allocation_map(mm) (mm->context.pkey_allocation_map)
#define __mm_pkey_allocated(mm, pkey) { \
mm_pkey_allocation_map(mm) |= pkey_alloc_mask(pkey); \
}
#define __mm_pkey_free(mm, pkey) { \
mm_pkey_allocation_map(mm) &= ~pkey_alloc_mask(pkey); \
}
#define __mm_pkey_is_allocated(mm, pkey) \
(mm_pkey_allocation_map(mm) & pkey_alloc_mask(pkey))
#define __mm_pkey_is_reserved(pkey) (reserved_allocation_mask & \
pkey_alloc_mask(pkey))
static inline bool mm_pkey_is_allocated(struct mm_struct *mm, int pkey)
{
if (pkey < 0 || pkey >= arch_max_pkey())
return false;
/* Reserved keys are never allocated. */
if (__mm_pkey_is_reserved(pkey))
return false;
return __mm_pkey_is_allocated(mm, pkey);
}
/*
* Returns a positive, 5-bit key on success, or -1 on failure.
* Relies on the mmap_lock to protect against concurrency in mm_pkey_alloc() and
* mm_pkey_free().
*/
static inline int mm_pkey_alloc(struct mm_struct *mm)
{
/*
* Note: this is the one and only place we make sure that the pkey is
* valid as far as the hardware is concerned. The rest of the kernel
* trusts that only good, valid pkeys come out of here.
*/
u32 all_pkeys_mask = (u32)(~(0x0));
int ret;
if (!mmu_has_feature(MMU_FTR_PKEY))
return -1;
/*
Annotation
- Immediate include surface: `linux/jump_label.h`, `asm/firmware.h`, `asm/book3s/64/pkeys.h`.
- Detected declarations: `function pkey_to_vmflag_bits`, `function vma_pkey`, `function arch_max_pkey`, `function pkey_alloc_mask`, `function mm_pkey_alloc`, `function mm_pkey_free`, `function arch_override_mprotect_pkey`, `function arch_set_user_pkey_access`, `function arch_pkeys_enabled`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.