arch/x86/boot/startup/sev-startup.c
Source file repositories/reference/linux-study-clean/arch/x86/boot/startup/sev-startup.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/boot/startup/sev-startup.c- Extension
.c- Size
- 5708 bytes
- Lines
- 222
- Domain
- Architecture Layer
- Bucket
- arch/x86
- Inferred role
- Architecture Layer: implementation source
- Status
- source 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 or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/percpu-defs.hlinux/cc_platform.hlinux/printk.hlinux/mm_types.hlinux/set_memory.hlinux/memblock.hlinux/kernel.hlinux/mm.hlinux/cpumask.hlinux/efi.hlinux/io.hlinux/psp-sev.huapi/linux/sev-guest.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.hasm/cmdline.h../../coco/sev/internal.hsev-shared.c
Detected Declarations
function Copyrightfunction early_snp_set_memory_privatefunction early_snp_set_memory_sharedfunction find_cc_blobfunction svsm_setupfunction snp_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* AMD Memory Encryption Support
*
* Copyright (C) 2019 SUSE
*
* Author: Joerg Roedel <jroedel@suse.de>
*/
#define pr_fmt(fmt) "SEV: " fmt
#include <linux/percpu-defs.h>
#include <linux/cc_platform.h>
#include <linux/printk.h>
#include <linux/mm_types.h>
#include <linux/set_memory.h>
#include <linux/memblock.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/cpumask.h>
#include <linux/efi.h>
#include <linux/io.h>
#include <linux/psp-sev.h>
#include <uapi/linux/sev-guest.h>
#include <asm/init.h>
#include <asm/cpu_entry_area.h>
#include <asm/stacktrace.h>
#include <asm/sev.h>
#include <asm/insn-eval.h>
#include <asm/fpu/xcr.h>
#include <asm/processor.h>
#include <asm/realmode.h>
#include <asm/setup.h>
#include <asm/traps.h>
#include <asm/svm.h>
#include <asm/smp.h>
#include <asm/cpu.h>
#include <asm/apic.h>
#include <asm/cpuid/api.h>
#include <asm/cmdline.h>
#include "../../coco/sev/internal.h"
/* Include code shared with pre-decompression boot stage */
#include "sev-shared.c"
void
early_set_pages_state(unsigned long vaddr, unsigned long paddr,
unsigned long npages, const struct psc_desc *desc)
{
unsigned long paddr_end;
vaddr = vaddr & PAGE_MASK;
paddr = paddr & PAGE_MASK;
paddr_end = paddr + (npages << PAGE_SHIFT);
while (paddr < paddr_end) {
__page_state_change(vaddr, paddr, desc);
vaddr += PAGE_SIZE;
paddr += PAGE_SIZE;
}
}
void __init early_snp_set_memory_private(unsigned long vaddr, unsigned long paddr,
unsigned long npages)
{
struct psc_desc d = {
SNP_PAGE_STATE_PRIVATE,
rip_rel_ptr(&boot_svsm_ca_page),
boot_svsm_caa_pa
};
/*
* This can be invoked in early boot while running identity mapped, so
* use an open coded check for SNP instead of using cc_platform_has().
* This eliminates worries about jump tables or checking boot_cpu_data
* in the cc_platform_has() function.
*/
if (!(sev_status & MSR_AMD64_SEV_SNP_ENABLED))
return;
/*
* Ask the hypervisor to mark the memory pages as private in the RMP
* table.
*/
early_set_pages_state(vaddr, paddr, npages, &d);
}
Annotation
- Immediate include surface: `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`, `linux/mm.h`.
- Detected declarations: `function Copyright`, `function early_snp_set_memory_private`, `function early_snp_set_memory_shared`, `function find_cc_blob`, `function svsm_setup`, `function snp_init`.
- Atlas domain: Architecture Layer / arch/x86.
- 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.