arch/x86/kvm/x86.h
Source file repositories/reference/linux-study-clean/arch/x86/kvm/x86.h
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kvm/x86.h- Extension
.h- Size
- 21759 bytes
- Lines
- 706
- 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/kvm_host.hasm/fpu/xstate.hasm/mce.hasm/pvclock.hregs.hkvm_emulate.hcpuid.h
Detected Declarations
struct kvm_capsstruct kvm_host_valuesenum kvm_msr_accessfunction __grow_ple_windowfunction __shrink_ple_windowfunction kvm_leave_nestedfunction kvm_nested_vmexit_handle_ibrsfunction modefunction kvm_warn_on_nested_run_pendingfunction kvm_set_mp_statefunction kvm_is_exception_pendingfunction kvm_clear_exception_queuefunction kvm_queue_interruptfunction kvm_clear_interrupt_queuefunction kvm_event_needs_reinjectionfunction kvm_exception_is_softfunction x86_exception_has_error_codefunction mmu_is_nestedfunction vcpu_virt_addr_bitsfunction max_host_virt_addr_bitsfunction is_noncanonical_addressfunction is_noncanonical_msr_addressfunction is_noncanonical_base_addressfunction is_noncanonical_invlpg_addressfunction vcpu_cache_mmio_infofunction vcpu_match_mmio_genfunction vcpu_clear_mmio_infofunction vcpu_match_mmio_gvafunction vcpu_match_mmio_gpafunction kvm_check_has_quirkfunction kvm_request_l1tf_flush_l1dfunction kvm_get_filtered_xcr0function kvm_mpx_supportedfunction kvm_pr_unimpl_wrmsrfunction kvm_pr_unimpl_rdmsrfunction nsec_to_cyclesfunction kvm_disable_exitsfunction kvm_mwait_in_guestfunction kvm_hlt_in_guestfunction kvm_pause_in_guestfunction kvm_cstate_in_guestfunction kvm_aperfmperf_in_guestfunction kvm_notify_vmexit_enabledfunction kvm_before_interruptfunction kvm_after_interruptfunction kvm_handling_nmi_from_guestfunction kvm_pat_validfunction __kvm_pv_async_pf_enabled
Annotated Snippet
struct kvm_caps {
/* control of guest tsc rate supported? */
bool has_tsc_control;
/* maximum supported tsc_khz for guests */
u32 max_guest_tsc_khz;
/* number of bits of the fractional part of the TSC scaling ratio */
u8 tsc_scaling_ratio_frac_bits;
/* maximum allowed value of TSC scaling ratio */
u64 max_tsc_scaling_ratio;
/* 1ull << kvm_caps.tsc_scaling_ratio_frac_bits */
u64 default_tsc_scaling_ratio;
/* bus lock detection supported? */
bool has_bus_lock_exit;
/* notify VM exit supported? */
bool has_notify_vmexit;
/* bit mask of VM types */
u32 supported_vm_types;
u64 supported_mce_cap;
u64 supported_xcr0;
u64 supported_xss;
u64 supported_perf_cap;
u64 supported_quirks;
u64 inapplicable_quirks;
};
struct kvm_host_values {
/*
* The host's raw MAXPHYADDR, i.e. the number of non-reserved physical
* address bits irrespective of features that repurpose legal bits,
* e.g. MKTME.
*/
u8 maxphyaddr;
u64 efer;
u64 xcr0;
u64 xss;
u64 s_cet;
u64 arch_capabilities;
};
void kvm_spurious_fault(void);
#define SIZE_OF_MEMSLOTS_HASHTABLE \
(sizeof(((struct kvm_memslots *)0)->id_hash) * 2 * KVM_MAX_NR_ADDRESS_SPACES)
/* Sanity check the size of the memslot hash tables. */
static_assert(SIZE_OF_MEMSLOTS_HASHTABLE ==
(1024 * (1 + IS_ENABLED(CONFIG_X86_64)) * (1 + IS_ENABLED(CONFIG_KVM_SMM))));
/*
* Assert that "struct kvm_{svm,vmx,tdx}" is an order-0 or order-1 allocation.
* Spilling over to an order-2 allocation isn't fundamentally problematic, but
* isn't expected to happen in the foreseeable future (O(years)). Assert that
* the size is an order-0 allocation when ignoring the memslot hash tables, to
* help detect and debug unexpected size increases.
*/
#define KVM_SANITY_CHECK_VM_STRUCT_SIZE(x) \
do { \
BUILD_BUG_ON(get_order(sizeof(struct x) - SIZE_OF_MEMSLOTS_HASHTABLE) && \
!IS_ENABLED(CONFIG_DEBUG_KERNEL) && !IS_ENABLED(CONFIG_KASAN)); \
BUILD_BUG_ON(get_order(sizeof(struct x)) > 1 && \
!IS_ENABLED(CONFIG_DEBUG_KERNEL) && !IS_ENABLED(CONFIG_KASAN)); \
} while (0)
#define KVM_NESTED_VMENTER_CONSISTENCY_CHECK(consistency_check) \
({ \
bool failed = (consistency_check); \
if (failed) \
trace_kvm_nested_vmenter_failed(#consistency_check, 0); \
failed; \
})
/*
* The first...last VMX feature MSRs that are emulated by KVM. This may or may
* not cover all known VMX MSRs, as KVM doesn't emulate an MSR until there's an
* associated feature that KVM supports for nested virtualization.
*/
#define KVM_FIRST_EMULATED_VMX_MSR MSR_IA32_VMX_BASIC
#define KVM_LAST_EMULATED_VMX_MSR MSR_IA32_VMX_VMFUNC
#define KVM_DEFAULT_PLE_GAP 128
#define KVM_VMX_DEFAULT_PLE_WINDOW 4096
#define KVM_DEFAULT_PLE_WINDOW_GROW 2
#define KVM_DEFAULT_PLE_WINDOW_SHRINK 0
#define KVM_VMX_DEFAULT_PLE_WINDOW_MAX UINT_MAX
#define KVM_SVM_DEFAULT_PLE_WINDOW_MAX USHRT_MAX
#define KVM_SVM_DEFAULT_PLE_WINDOW 3000
Annotation
- Immediate include surface: `linux/kvm_host.h`, `asm/fpu/xstate.h`, `asm/mce.h`, `asm/pvclock.h`, `regs.h`, `kvm_emulate.h`, `cpuid.h`.
- Detected declarations: `struct kvm_caps`, `struct kvm_host_values`, `enum kvm_msr_access`, `function __grow_ple_window`, `function __shrink_ple_window`, `function kvm_leave_nested`, `function kvm_nested_vmexit_handle_ibrs`, `function mode`, `function kvm_warn_on_nested_run_pending`, `function kvm_set_mp_state`.
- 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.