arch/x86/boot/startup/sev-shared.c
Source file repositories/reference/linux-study-clean/arch/x86/boot/startup/sev-shared.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/boot/startup/sev-shared.c- Extension
.c- Size
- 21553 bytes
- Lines
- 763
- 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
asm/setup_data.h
Detected Declarations
struct cc_setup_datafunction sev_es_terminatefunction get_hv_featuresfunction svsm_process_result_codesfunction svsm_issue_callfunction svsm_perform_msr_protocolfunction __sev_cpuid_hvfunction __sev_cpuid_hv_msrfunction snp_cpuid_calc_xsave_sizefunction snp_cpuid_get_validated_funcfunction snp_cpuid_hv_msrfunction snp_cpuid_postprocessfunction snp_cpuidfunction do_vc_no_ghcbfunction setup_cpuid_tablefunction svsm_call_msr_protocolfunction svsm_pval_4k_pagefunction pvalidate_4k_pagefunction __page_state_changefunction Area
Annotated Snippet
struct cc_setup_data {
struct setup_data header;
u32 cc_blob_address;
};
/*
* Search for a Confidential Computing blob passed in as a setup_data entry
* via the Linux Boot Protocol.
*/
static __init
struct cc_blob_sev_info *find_cc_blob_setup_data(struct boot_params *bp)
{
struct cc_setup_data *sd = NULL;
struct setup_data *hdr;
hdr = (struct setup_data *)bp->hdr.setup_data;
while (hdr) {
if (hdr->type == SETUP_CC_BLOB) {
sd = (struct cc_setup_data *)hdr;
return (struct cc_blob_sev_info *)(unsigned long)sd->cc_blob_address;
}
hdr = (struct setup_data *)hdr->next;
}
return NULL;
}
/*
* Initialize the kernel's copy of the SNP CPUID table, and set up the
* pointer that will be used to access it.
*
* Maintaining a direct mapping of the SNP CPUID table used by firmware would
* be possible as an alternative, but the approach is brittle since the
* mapping needs to be updated in sync with all the changes to virtual memory
* layout and related mapping facilities throughout the boot process.
*/
static void __init setup_cpuid_table(const struct cc_blob_sev_info *cc_info)
{
const struct snp_cpuid_table *cpuid_table_fw, *cpuid_table;
int i;
if (!cc_info || !cc_info->cpuid_phys || cc_info->cpuid_len < PAGE_SIZE)
sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_CPUID);
cpuid_table_fw = (const struct snp_cpuid_table *)cc_info->cpuid_phys;
if (!cpuid_table_fw->count || cpuid_table_fw->count > SNP_CPUID_COUNT_MAX)
sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_CPUID);
cpuid_table = snp_cpuid_get_table();
memcpy((void *)cpuid_table, cpuid_table_fw, sizeof(*cpuid_table));
/* Initialize CPUID ranges for range-checking. */
for (i = 0; i < cpuid_table->count; i++) {
const struct snp_cpuid_fn *fn = &cpuid_table->fn[i];
if (fn->eax_in == 0x0)
cpuid_std_range_max = fn->eax;
else if (fn->eax_in == 0x40000000)
cpuid_hyp_range_max = fn->eax;
else if (fn->eax_in == 0x80000000)
cpuid_ext_range_max = fn->eax;
}
}
static int svsm_call_msr_protocol(struct svsm_call *call)
{
int ret;
do {
ret = svsm_perform_msr_protocol(call);
} while (ret == -EAGAIN);
return ret;
}
static void svsm_pval_4k_page(unsigned long paddr, bool validate,
struct svsm_ca *caa, u64 caa_pa)
{
struct svsm_pvalidate_call *pc;
struct svsm_call call = {};
unsigned long flags;
u64 pc_pa;
/*
* This can be called very early in the boot, use native functions in
* order to avoid paravirt issues.
*/
flags = native_local_irq_save();
Annotation
- Immediate include surface: `asm/setup_data.h`.
- Detected declarations: `struct cc_setup_data`, `function sev_es_terminate`, `function get_hv_features`, `function svsm_process_result_codes`, `function svsm_issue_call`, `function svsm_perform_msr_protocol`, `function __sev_cpuid_hv`, `function __sev_cpuid_hv_msr`, `function snp_cpuid_calc_xsave_size`, `function snp_cpuid_get_validated_func`.
- 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.