arch/x86/kernel/cpu/mce/dev-mcelog.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/cpu/mce/dev-mcelog.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/cpu/mce/dev-mcelog.c- Extension
.c- Size
- 8288 bytes
- Lines
- 366
- 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.
- 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/miscdevice.hlinux/slab.hlinux/kmod.hlinux/poll.hinternal.h
Detected Declarations
function dev_mce_logfunction mce_do_triggerfunction mce_work_triggerfunction show_triggerfunction set_triggerfunction mce_chrdev_openfunction mce_chrdev_releasefunction __mce_read_apeifunction mce_chrdev_readfunction mce_chrdev_pollfunction mce_chrdev_ioctlfunction mce_register_injector_chainfunction mce_unregister_injector_chainfunction mce_chrdev_writefunction dev_mcelog_init_deviceexport mce_register_injector_chainexport mce_unregister_injector_chain
Annotated Snippet
static const struct file_operations mce_chrdev_ops = {
.open = mce_chrdev_open,
.release = mce_chrdev_release,
.read = mce_chrdev_read,
.write = mce_chrdev_write,
.poll = mce_chrdev_poll,
.unlocked_ioctl = mce_chrdev_ioctl,
.compat_ioctl = compat_ptr_ioctl,
};
static struct miscdevice mce_chrdev_device = {
MISC_MCELOG_MINOR,
"mcelog",
&mce_chrdev_ops,
};
static __init int dev_mcelog_init_device(void)
{
int mce_log_len;
int err;
mce_log_len = max(MCE_LOG_MIN_LEN, num_online_cpus());
mcelog = kzalloc_flex(*mcelog, entry, mce_log_len);
if (!mcelog)
return -ENOMEM;
memcpy(mcelog->signature, MCE_LOG_SIGNATURE, sizeof(mcelog->signature));
mcelog->len = mce_log_len;
mcelog->recordlen = sizeof(struct mce);
/* register character device /dev/mcelog */
err = misc_register(&mce_chrdev_device);
if (err) {
if (err == -EBUSY)
/* Xen dom0 might have registered the device already. */
pr_info("Unable to init device /dev/mcelog, already registered");
else
pr_err("Unable to init device /dev/mcelog (rc: %d)\n", err);
kfree(mcelog);
return err;
}
mce_register_decode_chain(&dev_mcelog_nb);
return 0;
}
device_initcall_sync(dev_mcelog_init_device);
Annotation
- Immediate include surface: `linux/miscdevice.h`, `linux/slab.h`, `linux/kmod.h`, `linux/poll.h`, `internal.h`.
- Detected declarations: `function dev_mce_log`, `function mce_do_trigger`, `function mce_work_trigger`, `function show_trigger`, `function set_trigger`, `function mce_chrdev_open`, `function mce_chrdev_release`, `function __mce_read_apei`, `function mce_chrdev_read`, `function mce_chrdev_poll`.
- 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.
- 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.