arch/x86/kernel/cpu/mshyperv.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/cpu/mshyperv.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/cpu/mshyperv.c- Extension
.c- Size
- 22746 bytes
- Lines
- 812
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/time.hlinux/clocksource.hlinux/init.hlinux/export.hlinux/hardirq.hlinux/efi.hlinux/interrupt.hlinux/irq.hlinux/kexec.hlinux/random.hasm/processor.hasm/hypervisor.hasm/cpuid/api.hhyperv/hvhdk.hasm/mshyperv.hasm/desc.hasm/idtentry.hasm/irq_regs.hasm/i8259.hasm/apic.hasm/timer.hasm/reboot.hasm/msr.hasm/nmi.hclocksource/hyperv_timer.hasm/numa.hasm/svm.h
Detected Declarations
function hv_get_nested_msrfunction hv_get_non_nested_msrfunction hv_set_non_nested_msrfunction hv_para_set_sint_proxyfunction hv_para_get_synic_registerfunction hv_para_set_synic_registerfunction hv_get_msrfunction hv_set_msrfunction hv_setup_mshv_handlerfunction hv_setup_vmbus_handlerfunction hv_remove_vmbus_handlerfunction hv_setup_stimer0_handlerfunction hv_remove_stimer0_handlerfunction hv_setup_kexec_handlerfunction hv_remove_kexec_handlerfunction hv_setup_crash_handlerfunction hv_remove_crash_handlerfunction hv_machine_shutdownfunction hv_guest_crash_shutdownfunction save_hv_clock_tsc_statefunction restore_hv_clock_tsc_statefunction hv_save_sched_clock_statefunction hv_restore_sched_clock_statefunction x86_setup_ops_for_tsc_pg_clockfunction ms_hyperv_platformfunction hv_nmi_unknownfunction hv_get_tsc_khzfunction hv_smp_prepare_boot_cpufunction hv_smp_prepare_cpusfunction for_each_present_cpufunction for_each_present_cpufunction nr_legacy_irqsfunction hv_get_hypervisor_versionfunction hv_reserve_irq_vectorsfunction ms_hyperv_init_platformfunction ms_hyperv_x2apic_availablefunction ms_hyperv_msi_ext_dest_idfunction hv_sev_es_hcall_preparefunction hv_sev_es_hcall_finishexport hv_get_non_nested_msrexport hv_set_non_nested_msrexport hv_get_msrexport hv_set_msrexport hv_get_hypervisor_version
Annotated Snippet
if (hv_is_sint_msr(reg)) {
union hv_synic_sint sint = { .as_uint64 = value };
sint.proxy = hv_para_sint_proxy;
native_wrmsrq(reg, sint.as_uint64);
}
} else {
native_wrmsrq(reg, value);
}
}
EXPORT_SYMBOL_GPL(hv_set_non_nested_msr);
/*
* Enable or disable proxying synthetic interrupts
* to the paravisor.
*/
void hv_para_set_sint_proxy(bool enable)
{
hv_para_sint_proxy = enable;
}
/*
* Get the SynIC register value from the paravisor.
*/
u64 hv_para_get_synic_register(unsigned int reg)
{
if (WARN_ON(!ms_hyperv.paravisor_present || !hv_is_synic_msr(reg)))
return ~0ULL;
return native_read_msr(reg);
}
/*
* Set the SynIC register value with the paravisor.
*/
void hv_para_set_synic_register(unsigned int reg, u64 val)
{
if (WARN_ON(!ms_hyperv.paravisor_present || !hv_is_synic_msr(reg)))
return;
native_write_msr(reg, val);
}
u64 hv_get_msr(unsigned int reg)
{
if (hv_nested)
reg = hv_get_nested_msr(reg);
return hv_get_non_nested_msr(reg);
}
EXPORT_SYMBOL_GPL(hv_get_msr);
void hv_set_msr(unsigned int reg, u64 value)
{
if (hv_nested)
reg = hv_get_nested_msr(reg);
hv_set_non_nested_msr(reg, value);
}
EXPORT_SYMBOL_GPL(hv_set_msr);
static void (*mshv_handler)(void);
static void (*vmbus_handler)(void);
static void (*hv_stimer0_handler)(void);
static void (*hv_kexec_handler)(void);
static void (*hv_crash_handler)(struct pt_regs *regs);
DEFINE_IDTENTRY_SYSVEC(sysvec_hyperv_callback)
{
struct pt_regs *old_regs = set_irq_regs(regs);
inc_irq_stat(HYPERVISOR_CALLBACK);
if (mshv_handler)
mshv_handler();
if (vmbus_handler)
vmbus_handler();
add_interrupt_randomness(HYPERVISOR_CALLBACK_VECTOR);
if (ms_hyperv.hints & HV_DEPRECATING_AEOI_RECOMMENDED)
apic_eoi();
set_irq_regs(old_regs);
}
void hv_setup_mshv_handler(void (*handler)(void))
{
mshv_handler = handler;
}
void hv_setup_vmbus_handler(void (*handler)(void))
Annotation
- Immediate include surface: `linux/types.h`, `linux/time.h`, `linux/clocksource.h`, `linux/init.h`, `linux/export.h`, `linux/hardirq.h`, `linux/efi.h`, `linux/interrupt.h`.
- Detected declarations: `function hv_get_nested_msr`, `function hv_get_non_nested_msr`, `function hv_set_non_nested_msr`, `function hv_para_set_sint_proxy`, `function hv_para_get_synic_register`, `function hv_para_set_synic_register`, `function hv_get_msr`, `function hv_set_msr`, `function hv_setup_mshv_handler`, `function hv_setup_vmbus_handler`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.