arch/powerpc/platforms/pseries/papr-phy-attest.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/pseries/papr-phy-attest.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/pseries/papr-phy-attest.c- Extension
.c- Size
- 8398 bytes
- Lines
- 289
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/build_bug.hlinux/file.hlinux/fs.hlinux/init.hlinux/lockdep.hlinux/kernel.hlinux/miscdevice.hlinux/signal.hlinux/slab.hlinux/string.hlinux/string_helpers.hlinux/uaccess.hasm/machdep.hasm/rtas-work-area.hasm/rtas.huapi/asm/papr-physical-attestation.hpapr-rtas-common.h
Detected Declarations
struct rtas_phy_attest_paramsfunction rtas_physical_attestationfunction phy_attest_sequence_beginfunction phy_attest_sequence_endfunction papr_rtas_blob_generatefunction papr_phy_attest_create_handlefunction papr_phy_attest_dev_ioctlfunction papr_phy_attest_init
Annotated Snippet
static const struct file_operations papr_phy_attest_handle_ops = {
.read = papr_rtas_common_handle_read,
.llseek = papr_rtas_common_handle_seek,
.release = papr_rtas_common_handle_release,
};
/**
* papr_phy_attest_create_handle() - Create a fd-based handle for
* reading the response for the given attestation command.
* @ulc: Attestation command in user memory; defines the scope of
* data for the attestation command to retrieve.
*
* Handler for PAPR_PHYSICAL_ATTESTATION_IOC_CREATE_HANDLE ioctl
* command. Validates @ulc and instantiates an immutable response
* "blob" for attestation command. The blob is attached to a file
* descriptor for reading by user space. The memory backing the blob
* is freed when the file is released.
*
* The entire requested response buffer for the attestation command
* retrieved by this call and all necessary RTAS interactions are
* performed before returning the fd to user space. This keeps the
* read handler simple and ensures that kernel can prevent
* interleaving ibm,physical-attestation call sequences.
*
* Return: The installed fd number if successful, -ve errno otherwise.
*/
static long papr_phy_attest_create_handle(struct papr_phy_attest_io_block __user *ulc)
{
struct rtas_phy_attest_params *params;
struct papr_rtas_sequence seq = {};
int fd;
/*
* Freed in phy_attest_sequence_end().
*/
params = kzalloc_obj(*params, GFP_KERNEL_ACCOUNT);
if (!params)
return -ENOMEM;
if (copy_from_user(¶ms->cmd, ulc,
sizeof(struct papr_phy_attest_io_block)))
return -EFAULT;
params->cmd_len = be32_to_cpu(params->cmd.length);
seq = (struct papr_rtas_sequence) {
.begin = phy_attest_sequence_begin,
.end = phy_attest_sequence_end,
.work = phy_attest_sequence_fill_work_area,
};
seq.params = (void *)params;
fd = papr_rtas_setup_file_interface(&seq,
&papr_phy_attest_handle_ops,
"[papr-physical-attestation]");
return fd;
}
/*
* Top-level ioctl handler for /dev/papr-physical-attestation.
*/
static long papr_phy_attest_dev_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
{
void __user *argp = (__force void __user *)arg;
long ret;
switch (ioctl) {
case PAPR_PHY_ATTEST_IOC_HANDLE:
ret = papr_phy_attest_create_handle(argp);
break;
default:
ret = -ENOIOCTLCMD;
break;
}
return ret;
}
static const struct file_operations papr_phy_attest_ops = {
.unlocked_ioctl = papr_phy_attest_dev_ioctl,
};
static struct miscdevice papr_phy_attest_dev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "papr-physical-attestation",
.fops = &papr_phy_attest_ops,
};
static __init int papr_phy_attest_init(void)
{
Annotation
- Immediate include surface: `linux/build_bug.h`, `linux/file.h`, `linux/fs.h`, `linux/init.h`, `linux/lockdep.h`, `linux/kernel.h`, `linux/miscdevice.h`, `linux/signal.h`.
- Detected declarations: `struct rtas_phy_attest_params`, `function rtas_physical_attestation`, `function phy_attest_sequence_begin`, `function phy_attest_sequence_end`, `function papr_rtas_blob_generate`, `function papr_phy_attest_create_handle`, `function papr_phy_attest_dev_ioctl`, `function papr_phy_attest_init`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.