arch/powerpc/kernel/dexcr.c
Source file repositories/reference/linux-study-clean/arch/powerpc/kernel/dexcr.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/kernel/dexcr.c- Extension
.c- Size
- 2633 bytes
- Lines
- 125
- 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/capability.hlinux/cpu.hlinux/init.hlinux/prctl.hlinux/sched.hasm/cpu_has_feature.hasm/cputable.hasm/processor.hasm/reg.h
Detected Declarations
function init_task_dexcrfunction prctl_to_aspectfunction get_dexcr_prctlfunction set_dexcr_prctl
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
#include <linux/capability.h>
#include <linux/cpu.h>
#include <linux/init.h>
#include <linux/prctl.h>
#include <linux/sched.h>
#include <asm/cpu_has_feature.h>
#include <asm/cputable.h>
#include <asm/processor.h>
#include <asm/reg.h>
static int __init init_task_dexcr(void)
{
if (!early_cpu_has_feature(CPU_FTR_ARCH_31))
return 0;
current->thread.dexcr_onexec = mfspr(SPRN_DEXCR);
return 0;
}
early_initcall(init_task_dexcr)
/* Allow thread local configuration of these by default */
#define DEXCR_PRCTL_EDITABLE ( \
DEXCR_PR_IBRTPD | \
DEXCR_PR_SRAPD | \
DEXCR_PR_NPHIE)
static int prctl_to_aspect(unsigned long which, unsigned int *aspect)
{
switch (which) {
case PR_PPC_DEXCR_SBHE:
*aspect = DEXCR_PR_SBHE;
break;
case PR_PPC_DEXCR_IBRTPD:
*aspect = DEXCR_PR_IBRTPD;
break;
case PR_PPC_DEXCR_SRAPD:
*aspect = DEXCR_PR_SRAPD;
break;
case PR_PPC_DEXCR_NPHIE:
*aspect = DEXCR_PR_NPHIE;
break;
default:
return -ENODEV;
}
return 0;
}
int get_dexcr_prctl(struct task_struct *task, unsigned long which)
{
unsigned int aspect;
int ret;
ret = prctl_to_aspect(which, &aspect);
if (ret)
return ret;
if (aspect & DEXCR_PRCTL_EDITABLE)
ret |= PR_PPC_DEXCR_CTRL_EDITABLE;
if (aspect & mfspr(SPRN_DEXCR))
ret |= PR_PPC_DEXCR_CTRL_SET;
else
ret |= PR_PPC_DEXCR_CTRL_CLEAR;
if (aspect & task->thread.dexcr_onexec)
ret |= PR_PPC_DEXCR_CTRL_SET_ONEXEC;
else
ret |= PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC;
return ret;
}
int set_dexcr_prctl(struct task_struct *task, unsigned long which, unsigned long ctrl)
{
unsigned long dexcr;
unsigned int aspect;
int err = 0;
err = prctl_to_aspect(which, &aspect);
if (err)
return err;
if (!(aspect & DEXCR_PRCTL_EDITABLE))
return -EPERM;
Annotation
- Immediate include surface: `linux/capability.h`, `linux/cpu.h`, `linux/init.h`, `linux/prctl.h`, `linux/sched.h`, `asm/cpu_has_feature.h`, `asm/cputable.h`, `asm/processor.h`.
- Detected declarations: `function init_task_dexcr`, `function prctl_to_aspect`, `function get_dexcr_prctl`, `function set_dexcr_prctl`.
- 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.