arch/x86/hyperv/hv_vtl.c
Source file repositories/reference/linux-study-clean/arch/x86/hyperv/hv_vtl.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/hyperv/hv_vtl.c- Extension
.c- Size
- 9474 bytes
- Lines
- 314
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hasm/acpi.hasm/apic.hasm/boot.hasm/desc.hasm/fpu/api.hasm/fpu/types.hasm/i8259.hasm/mshyperv.hasm/msr.hasm/realmode.hasm/reboot.hasm/smap.hlinux/export.h../kernel/smpboot.h../../kernel/fpu/legacy.h
Detected Declarations
function hv_vtl_msi_ext_dest_idfunction hv_vtl_emergency_restartfunction hv_vtl_restartfunction within_pagefunction hv_vtl_is_private_mmio_tdxfunction hv_vtl_init_platformfunction hv_vtl_system_desc_basefunction hv_vtl_system_desc_limitfunction hv_vtl_ap_entryfunction hv_vtl_bringup_vcpufunction hv_vtl_wakeup_secondary_cpufunction hv_vtl_early_initfunction mshv_vtl_return_call_initfunction mshv_vtl_return_callexport mshv_vtl_return_call_initexport mshv_vtl_return_call
Annotated Snippet
hv_result(status) != HV_STATUS_VTL_ALREADY_ENABLED) {
pr_err("HVCALL_ENABLE_VP_VTL failed for VP : %d ! [Err: %#llx\n]",
target_vp_index, status);
ret = -EINVAL;
goto free_lock;
}
status = hv_do_hypercall(HVCALL_START_VP, input, NULL);
if (!hv_result_success(status)) {
pr_err("HVCALL_START_VP failed for VP : %d ! [Err: %#llx]\n",
target_vp_index, status);
ret = -EINVAL;
}
free_lock:
local_irq_restore(irq_flags);
return ret;
}
static int hv_vtl_wakeup_secondary_cpu(u32 apicid, unsigned long start_eip, unsigned int cpu)
{
int vp_index;
pr_debug("Bringing up CPU with APIC ID %d in VTL2...\n", apicid);
vp_index = hv_apicid_to_vp_index(apicid);
if (vp_index < 0) {
pr_err("Couldn't find CPU with APIC ID %d\n", apicid);
return -EINVAL;
}
if (vp_index > ms_hyperv.max_vp_index) {
pr_err("Invalid CPU id %d for APIC ID %d\n", vp_index, apicid);
return -EINVAL;
}
return hv_vtl_bringup_vcpu(vp_index, cpu, start_eip);
}
int __init hv_vtl_early_init(void)
{
machine_ops.emergency_restart = hv_vtl_emergency_restart;
machine_ops.restart = hv_vtl_restart;
/*
* `boot_cpu_has` returns the runtime feature support,
* and here is the earliest it can be used.
*/
if (cpu_feature_enabled(X86_FEATURE_XSAVE))
panic("XSAVE has to be disabled as it is not supported by this module.\n"
"Please add 'noxsave' to the kernel command line.\n");
/*
* TDX confidential VMs do not trust the hypervisor and cannot use it to
* boot secondary CPUs. Instead, they will be booted using the wakeup
* mailbox if detected during boot. See setup_arch().
*
* There is no paravisor present if we are here.
*/
if (!hv_isolation_type_tdx())
apic_update_callback(wakeup_secondary_cpu_64, hv_vtl_wakeup_secondary_cpu);
return 0;
}
DEFINE_STATIC_CALL_NULL(__mshv_vtl_return_hypercall, void (*)(void));
void mshv_vtl_return_call_init(u64 vtl_return_offset)
{
static_call_update(__mshv_vtl_return_hypercall,
(void *)((u8 *)hv_hypercall_pg + vtl_return_offset));
}
EXPORT_SYMBOL(mshv_vtl_return_call_init);
void mshv_vtl_return_call(struct mshv_vtl_cpu_context *vtl0)
{
struct hv_vp_assist_page *hvp;
hvp = hv_vp_assist_page[smp_processor_id()];
hvp->vtl_ret_x64rax = vtl0->rax;
hvp->vtl_ret_x64rcx = vtl0->rcx;
kernel_fpu_begin_mask(0);
fxrstor(&vtl0->fx_state);
__mshv_vtl_return_call(vtl0);
fxsave(&vtl0->fx_state);
kernel_fpu_end();
}
EXPORT_SYMBOL(mshv_vtl_return_call);
Annotation
- Immediate include surface: `linux/acpi.h`, `asm/acpi.h`, `asm/apic.h`, `asm/boot.h`, `asm/desc.h`, `asm/fpu/api.h`, `asm/fpu/types.h`, `asm/i8259.h`.
- Detected declarations: `function hv_vtl_msi_ext_dest_id`, `function hv_vtl_emergency_restart`, `function hv_vtl_restart`, `function within_page`, `function hv_vtl_is_private_mmio_tdx`, `function hv_vtl_init_platform`, `function hv_vtl_system_desc_base`, `function hv_vtl_system_desc_limit`, `function hv_vtl_ap_entry`, `function hv_vtl_bringup_vcpu`.
- 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.