arch/x86/kernel/kdebugfs.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/kdebugfs.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/kdebugfs.c- Extension
.c- Size
- 3898 bytes
- Lines
- 196
- Domain
- Architecture Layer
- Bucket
- arch/x86
- 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.
- 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/debugfs.hlinux/uaccess.hlinux/export.hlinux/slab.hlinux/init.hlinux/stat.hlinux/io.hlinux/mm.hasm/setup.h
Detected Declarations
struct setup_data_nodefunction setup_data_readfunction create_setup_data_nodefunction create_setup_data_nodesfunction boot_params_kdebugfs_initfunction arch_kdebugfs_initexport arch_debugfs_dir
Annotated Snippet
static const struct file_operations fops_setup_data = {
.read = setup_data_read,
.open = simple_open,
.llseek = default_llseek,
};
static void __init
create_setup_data_node(struct dentry *parent, int no,
struct setup_data_node *node)
{
struct dentry *d;
char buf[16];
sprintf(buf, "%d", no);
d = debugfs_create_dir(buf, parent);
debugfs_create_x32("type", S_IRUGO, d, &node->type);
debugfs_create_file("data", S_IRUGO, d, node, &fops_setup_data);
}
static int __init create_setup_data_nodes(struct dentry *parent)
{
struct setup_indirect *indirect;
struct setup_data_node *node;
struct setup_data *data;
u64 pa_data, pa_next;
struct dentry *d;
int error;
u32 len;
int no = 0;
d = debugfs_create_dir("setup_data", parent);
pa_data = boot_params.hdr.setup_data;
while (pa_data) {
node = kmalloc_obj(*node);
if (!node) {
error = -ENOMEM;
goto err_dir;
}
data = memremap(pa_data, sizeof(*data), MEMREMAP_WB);
if (!data) {
kfree(node);
error = -ENOMEM;
goto err_dir;
}
pa_next = data->next;
if (data->type == SETUP_INDIRECT) {
len = sizeof(*data) + data->len;
memunmap(data);
data = memremap(pa_data, len, MEMREMAP_WB);
if (!data) {
kfree(node);
error = -ENOMEM;
goto err_dir;
}
indirect = (struct setup_indirect *)data->data;
if (indirect->type != SETUP_INDIRECT) {
node->paddr = indirect->addr;
node->type = indirect->type;
node->len = indirect->len;
} else {
node->paddr = pa_data;
node->type = data->type;
node->len = data->len;
}
} else {
node->paddr = pa_data;
node->type = data->type;
node->len = data->len;
}
create_setup_data_node(d, no, node);
pa_data = pa_next;
memunmap(data);
no++;
}
return 0;
err_dir:
debugfs_remove_recursive(d);
return error;
}
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/uaccess.h`, `linux/export.h`, `linux/slab.h`, `linux/init.h`, `linux/stat.h`, `linux/io.h`, `linux/mm.h`.
- Detected declarations: `struct setup_data_node`, `function setup_data_read`, `function create_setup_data_node`, `function create_setup_data_nodes`, `function boot_params_kdebugfs_init`, `function arch_kdebugfs_init`, `export arch_debugfs_dir`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.