drivers/virt/coco/tdx-guest/tdx-guest.c
Source file repositories/reference/linux-study-clean/drivers/virt/coco/tdx-guest/tdx-guest.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/virt/coco/tdx-guest/tdx-guest.c- Extension
.c- Size
- 11487 bytes
- Lines
- 457
- Domain
- Driver Families
- Bucket
- drivers/virt
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/kernel.hlinux/miscdevice.hlinux/mm.hlinux/module.hlinux/mod_devicetable.hlinux/string.hlinux/uaccess.hlinux/set_memory.hlinux/io.hlinux/delay.hlinux/sockptr.hlinux/tsm.hlinux/tsm-mr.huapi/linux/tdx-guest.hasm/cpu_device_id.hasm/tdx.h
Detected Declarations
struct tdx_quote_buffunction tdx_do_reportfunction tdx_do_extendfunction tdx_mr_refreshfunction tdx_mr_extendfunction tdx_mr_deinitfunction tdx_get_report0function free_quote_buffunction wait_for_quote_completionfunction tdx_report_new_lockedfunction tdx_report_newfunction tdx_report_attr_visiblefunction tdx_report_bin_attr_visiblefunction tdx_guest_ioctlfunction tdx_guest_initfunction tdx_guest_exitmodule init tdx_guest_init
Annotated Snippet
static const struct file_operations tdx_guest_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = tdx_guest_ioctl,
};
static const struct attribute_group *tdx_attr_groups[] = {
NULL, /* measurements */
NULL
};
static struct miscdevice tdx_misc_dev = {
.name = KBUILD_MODNAME,
.minor = MISC_DYNAMIC_MINOR,
.fops = &tdx_guest_fops,
.groups = tdx_attr_groups,
};
static const struct x86_cpu_id tdx_guest_ids[] = {
X86_MATCH_FEATURE(X86_FEATURE_TDX_GUEST, NULL),
{}
};
MODULE_DEVICE_TABLE(x86cpu, tdx_guest_ids);
static const struct tsm_report_ops tdx_tsm_ops = {
.name = KBUILD_MODNAME,
.report_new = tdx_report_new,
.report_attr_visible = tdx_report_attr_visible,
.report_bin_attr_visible = tdx_report_bin_attr_visible,
};
static int __init tdx_guest_init(void)
{
int ret;
if (!x86_match_cpu(tdx_guest_ids))
return -ENODEV;
tdx_attr_groups[0] = tdx_mr_init();
if (IS_ERR(tdx_attr_groups[0]))
return PTR_ERR(tdx_attr_groups[0]);
ret = misc_register(&tdx_misc_dev);
if (ret)
goto deinit_mr;
quote_data = alloc_quote_buf();
if (!quote_data) {
pr_err("Failed to allocate Quote buffer\n");
ret = -ENOMEM;
goto free_misc;
}
ret = tsm_report_register(&tdx_tsm_ops, NULL);
if (ret)
goto free_quote;
return 0;
free_quote:
free_quote_buf(quote_data);
free_misc:
misc_deregister(&tdx_misc_dev);
deinit_mr:
tdx_mr_deinit(tdx_attr_groups[0]);
return ret;
}
module_init(tdx_guest_init);
static void __exit tdx_guest_exit(void)
{
tsm_report_unregister(&tdx_tsm_ops);
free_quote_buf(quote_data);
misc_deregister(&tdx_misc_dev);
tdx_mr_deinit(tdx_attr_groups[0]);
}
module_exit(tdx_guest_exit);
MODULE_AUTHOR("Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>");
MODULE_DESCRIPTION("TDX Guest Driver");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/miscdevice.h`, `linux/mm.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/string.h`, `linux/uaccess.h`, `linux/set_memory.h`.
- Detected declarations: `struct tdx_quote_buf`, `function tdx_do_report`, `function tdx_do_extend`, `function tdx_mr_refresh`, `function tdx_mr_extend`, `function tdx_mr_deinit`, `function tdx_get_report0`, `function free_quote_buf`, `function wait_for_quote_completion`, `function tdx_report_new_locked`.
- Atlas domain: Driver Families / drivers/virt.
- Implementation status: pattern 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.