drivers/virt/coco/efi_secret/efi_secret.c
Source file repositories/reference/linux-study-clean/drivers/virt/coco/efi_secret/efi_secret.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/virt/coco/efi_secret/efi_secret.c- Extension
.c- Size
- 8213 bytes
- Lines
- 320
- Domain
- Driver Families
- Bucket
- drivers/virt
- Inferred role
- Driver Families: implementation source
- Status
- source 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 or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/platform_device.hlinux/seq_file.hlinux/fs.hlinux/kernel.hlinux/init.hlinux/module.hlinux/io.hlinux/security.hlinux/efi.hlinux/cacheflush.h
Detected Declarations
struct efi_secretstruct secret_headerstruct secret_entryfunction secret_entry_data_lenfunction efi_secret_bin_file_showfunction wipe_memoryfunction efi_secret_unlinkfunction efi_secret_map_areafunction efi_secret_securityfs_teardownfunction efi_secret_securityfs_setupfunction efi_secret_unmap_areafunction efi_secret_probefunction efi_secret_remove
Annotated Snippet
struct efi_secret {
struct dentry *secrets_dir;
void __iomem *secret_data;
u64 secret_data_len;
};
/*
* Structure of the EFI secret area
*
* Offset Length
* (bytes) (bytes) Usage
* ------- ------- -----
* 0 16 Secret table header GUID (must be 1e74f542-71dd-4d66-963e-ef4287ff173b)
* 16 4 Length of bytes of the entire secret area
*
* 20 16 First secret entry's GUID
* 36 4 First secret entry's length in bytes (= 16 + 4 + x)
* 40 x First secret entry's data
*
* 40+x 16 Second secret entry's GUID
* 56+x 4 Second secret entry's length in bytes (= 16 + 4 + y)
* 60+x y Second secret entry's data
*
* (... and so on for additional entries)
*
* The GUID of each secret entry designates the usage of the secret data.
*/
/**
* struct secret_header - Header of entire secret area; this should be followed
* by instances of struct secret_entry.
* @guid: Must be EFI_SECRET_TABLE_HEADER_GUID
* @len: Length in bytes of entire secret area, including header
*/
struct secret_header {
efi_guid_t guid;
u32 len;
} __attribute((packed));
/**
* struct secret_entry - Holds one secret entry
* @guid: Secret-specific GUID (or NULL_GUID if this secret entry was deleted)
* @len: Length of secret entry, including its guid and len fields
* @data: The secret data (full of zeros if this secret entry was deleted)
*/
struct secret_entry {
efi_guid_t guid;
u32 len;
u8 data[];
} __attribute((packed));
static size_t secret_entry_data_len(struct secret_entry *e)
{
return e->len - sizeof(*e);
}
static struct efi_secret the_efi_secret;
static inline struct efi_secret *efi_secret_get(void)
{
return &the_efi_secret;
}
static int efi_secret_bin_file_show(struct seq_file *file, void *data)
{
struct secret_entry *e = file->private;
if (e)
seq_write(file, e->data, secret_entry_data_len(e));
return 0;
}
DEFINE_SHOW_ATTRIBUTE(efi_secret_bin_file);
/*
* Overwrite memory content with zeroes, and ensure that dirty cache lines are
* actually written back to memory, to clear out the secret.
*/
static void wipe_memory(void *addr, size_t size)
{
memzero_explicit(addr, size);
#ifdef CONFIG_X86
clflush_cache_range(addr, size);
#endif
}
static int efi_secret_unlink(struct inode *dir, struct dentry *dentry)
{
struct inode *inode = d_inode(dentry);
struct secret_entry *e = (struct secret_entry *)inode->i_private;
Annotation
- Immediate include surface: `linux/platform_device.h`, `linux/seq_file.h`, `linux/fs.h`, `linux/kernel.h`, `linux/init.h`, `linux/module.h`, `linux/io.h`, `linux/security.h`.
- Detected declarations: `struct efi_secret`, `struct secret_header`, `struct secret_entry`, `function secret_entry_data_len`, `function efi_secret_bin_file_show`, `function wipe_memory`, `function efi_secret_unlink`, `function efi_secret_map_area`, `function efi_secret_securityfs_teardown`, `function efi_secret_securityfs_setup`.
- Atlas domain: Driver Families / drivers/virt.
- 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.