arch/x86/boot/compressed/sev-handle-vc.c
Source file repositories/reference/linux-study-clean/arch/x86/boot/compressed/sev-handle-vc.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/boot/compressed/sev-handle-vc.c- Extension
.c- Size
- 2795 bytes
- Lines
- 137
- 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
misc.herror.hsev.hlinux/kernel.hlinux/string.hasm/insn.hasm/pgtable_types.hasm/ptrace.hasm/sev.hasm/trapnr.hasm/trap_pf.hasm/fpu/xcr.h../../lib/inat.c../../lib/insn.c../../coco/sev/vc-shared.c
Detected Declarations
function insn_has_rep_prefixfunction for_each_insn_prefixfunction vc_decode_insnfunction insn_get_seg_basefunction vc_write_memfunction vc_read_memfunction vc_ioio_checkfunction fault_in_kernel_spacefunction do_boot_stage2_vc
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include "misc.h"
#include "error.h"
#include "sev.h"
#include <linux/kernel.h>
#include <linux/string.h>
#include <asm/insn.h>
#include <asm/pgtable_types.h>
#include <asm/ptrace.h>
#include <asm/sev.h>
#include <asm/trapnr.h>
#include <asm/trap_pf.h>
#include <asm/fpu/xcr.h>
#define __BOOT_COMPRESSED
#undef __init
#define __init
/* Basic instruction decoding support needed */
#include "../../lib/inat.c"
#include "../../lib/insn.c"
/*
* Copy a version of this function here - insn-eval.c can't be used in
* pre-decompression code.
*/
bool insn_has_rep_prefix(struct insn *insn)
{
insn_byte_t p;
insn_get_prefixes(insn);
for_each_insn_prefix(insn, p) {
if (p == 0xf2 || p == 0xf3)
return true;
}
return false;
}
enum es_result vc_decode_insn(struct es_em_ctxt *ctxt)
{
char buffer[MAX_INSN_SIZE];
int ret;
memcpy(buffer, (unsigned char *)ctxt->regs->ip, MAX_INSN_SIZE);
ret = insn_decode(&ctxt->insn, buffer, MAX_INSN_SIZE, INSN_MODE_64);
if (ret < 0)
return ES_DECODE_FAILED;
return ES_OK;
}
extern void sev_insn_decode_init(void) __alias(inat_init_tables);
/*
* Only a dummy for insn_get_seg_base() - Early boot-code is 64bit only and
* doesn't use segments.
*/
static unsigned long insn_get_seg_base(struct pt_regs *regs, int seg_reg_idx)
{
return 0UL;
}
static enum es_result vc_write_mem(struct es_em_ctxt *ctxt,
void *dst, char *buf, size_t size)
{
memcpy(dst, buf, size);
return ES_OK;
}
static enum es_result vc_read_mem(struct es_em_ctxt *ctxt,
void *src, char *buf, size_t size)
{
memcpy(buf, src, size);
return ES_OK;
}
static enum es_result vc_ioio_check(struct es_em_ctxt *ctxt, u16 port, size_t size)
{
return ES_OK;
}
static bool fault_in_kernel_space(unsigned long address)
{
Annotation
- Immediate include surface: `misc.h`, `error.h`, `sev.h`, `linux/kernel.h`, `linux/string.h`, `asm/insn.h`, `asm/pgtable_types.h`, `asm/ptrace.h`.
- Detected declarations: `function insn_has_rep_prefix`, `function for_each_insn_prefix`, `function vc_decode_insn`, `function insn_get_seg_base`, `function vc_write_mem`, `function vc_read_mem`, `function vc_ioio_check`, `function fault_in_kernel_space`, `function do_boot_stage2_vc`.
- 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.