arch/x86/coco/sev/core.c
Source file repositories/reference/linux-study-clean/arch/x86/coco/sev/core.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/coco/sev/core.c- Extension
.c- Size
- 52371 bytes
- Lines
- 2052
- Domain
- Architecture Layer
- Bucket
- arch/x86
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/sched/debug.hlinux/percpu-defs.hlinux/cc_platform.hlinux/printk.hlinux/mm_types.hlinux/set_memory.hlinux/memblock.hlinux/kernel.hlinux/mm.hlinux/cpumask.hlinux/efi.hlinux/platform_device.hlinux/io.hlinux/psp-sev.hlinux/dmi.huapi/linux/sev-guest.hcrypto/gcm.hasm/init.hasm/cpu_entry_area.hasm/stacktrace.hasm/sev.hasm/insn-eval.hasm/fpu/xcr.hasm/processor.hasm/realmode.hasm/setup.hasm/traps.hasm/svm.hasm/smp.hasm/cpu.hasm/apic.hasm/cpuid/api.h
Detected Declarations
function get_snp_jump_table_addrfunction get_jump_table_addrfunction pval_pagesfunction pvalidate_pagesfunction vmgexit_pscfunction __set_pages_statefunction set_pages_statefunction snp_set_memory_sharedfunction snp_set_memory_privatefunction snp_accept_memoryfunction vmgexit_ap_controlfunction snp_set_vmsafunction snp_cleanup_vmsafunction set_pte_encfunction unshare_all_memoryfunction for_each_possible_cpufunction snp_kexec_beginfunction shutdown_all_apsfunction enc_kexec_finishfunction snp_kexec_finishfunction for_each_possible_cpufunction wakeup_cpu_via_vmgexitfunction snp_set_wakeup_secondary_cpufunction sev_es_setup_ap_jump_tablefunction sev_es_efi_map_ghcbs_casfunction for_each_possible_cpufunction savic_ghcb_msr_readfunction savic_ghcb_msr_writefunction savic_register_gpafunction savic_unregister_gpafunction snp_register_per_cpu_ghcbfunction setup_ghcbfunction sev_es_ap_hlt_loopfunction sev_es_play_deadfunction sev_es_setup_play_deadfunction sev_es_setup_play_deadfunction init_ghcbfunction sev_es_init_vc_handlingfunction snp_dmi_setupfunction dump_cpuid_tablefunction report_snp_infofunction snp_issue_guest_requestfunction SNP_GUEST_VMM_ERRfunction snp_init_platform_devicefunction sev_show_statusfunction vmpl_showfunction sev_sysfs_initfunction free_shared_pages
Annotated Snippet
device_initcall(snp_init_platform_device);
void sev_show_status(void)
{
int i;
pr_info("Status: ");
for (i = 0; i < MSR_AMD64_SNP_RESV_BIT; i++) {
if (sev_status & BIT_ULL(i)) {
if (!sev_status_feat_names[i])
continue;
pr_cont("%s ", sev_status_feat_names[i]);
}
}
pr_cont("\n");
}
#ifdef CONFIG_SYSFS
static ssize_t vmpl_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return sysfs_emit(buf, "%d\n", snp_vmpl);
}
static struct kobj_attribute vmpl_attr = __ATTR_RO(vmpl);
static struct attribute *vmpl_attrs[] = {
&vmpl_attr.attr,
NULL
};
static struct attribute_group sev_attr_group = {
.attrs = vmpl_attrs,
};
static int __init sev_sysfs_init(void)
{
struct kobject *sev_kobj;
struct device *dev_root;
int ret;
if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP))
return -ENODEV;
dev_root = bus_get_dev_root(&cpu_subsys);
if (!dev_root)
return -ENODEV;
sev_kobj = kobject_create_and_add("sev", &dev_root->kobj);
put_device(dev_root);
if (!sev_kobj)
return -ENOMEM;
ret = sysfs_create_group(sev_kobj, &sev_attr_group);
if (ret)
kobject_put(sev_kobj);
return ret;
}
arch_initcall(sev_sysfs_init);
#endif // CONFIG_SYSFS
static void free_shared_pages(void *buf, size_t sz)
{
unsigned int npages = PAGE_ALIGN(sz) >> PAGE_SHIFT;
int ret;
if (!buf)
return;
ret = set_memory_encrypted((unsigned long)buf, npages);
if (ret) {
WARN_ONCE(ret, "failed to restore encryption mask (leak it)\n");
return;
}
__free_pages(virt_to_page(buf), get_order(sz));
}
static void *alloc_shared_pages(size_t sz)
{
unsigned int npages = PAGE_ALIGN(sz) >> PAGE_SHIFT;
struct page *page;
int ret;
page = alloc_pages(GFP_KERNEL_ACCOUNT, get_order(sz));
if (!page)
return NULL;
Annotation
- Immediate include surface: `linux/sched/debug.h`, `linux/percpu-defs.h`, `linux/cc_platform.h`, `linux/printk.h`, `linux/mm_types.h`, `linux/set_memory.h`, `linux/memblock.h`, `linux/kernel.h`.
- Detected declarations: `function get_snp_jump_table_addr`, `function get_jump_table_addr`, `function pval_pages`, `function pvalidate_pages`, `function vmgexit_psc`, `function __set_pages_state`, `function set_pages_state`, `function snp_set_memory_shared`, `function snp_set_memory_private`, `function snp_accept_memory`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: integration 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.