arch/x86/kvm/vmx/nested.h
Source file repositories/reference/linux-study-clean/arch/x86/kvm/vmx/nested.h
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kvm/vmx/nested.h- Extension
.h- Size
- 9886 bytes
- Lines
- 324
- 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
regs.hhyperv.hvmcs12.hvmx.h
Detected Declarations
enum nvmx_vmentry_statusfunction nested_vmx_vmexitfunction vmx_has_valid_vmcs12function nested_get_vpid02function nested_ept_get_eptpfunction nested_ept_ad_enabledfunction hypervisorfunction nested_read_cr4function nested_cpu_vmx_misc_cr3_countfunction nested_cpu_has_vmwrite_any_fieldfunction nested_cpu_has_zero_length_injectionfunction nested_cpu_supports_monitor_trap_flagfunction nested_cpu_has_vmx_shadow_vmcsfunction nested_cpu_hasfunction nested_cpu_has2function nested_cpu_has_preemption_timerfunction nested_cpu_has_nmi_exitingfunction nested_cpu_has_virtual_nmisfunction nested_cpu_has_mtffunction nested_cpu_has_eptfunction nested_cpu_has_xsavesfunction nested_cpu_has_pmlfunction nested_cpu_has_virt_x2apic_modefunction nested_cpu_has_vpidfunction nested_cpu_has_apic_reg_virtfunction nested_cpu_has_vidfunction nested_cpu_has_posted_intrfunction nested_cpu_has_vmfuncfunction nested_cpu_has_eptp_switchingfunction nested_cpu_has_shadow_vmcsfunction nested_cpu_has_save_preemption_timerfunction nested_exit_on_nmifunction nested_exit_on_intrfunction nested_cpu_has_encls_exitfunction fixed_bits_validfunction nested_guest_cr0_validfunction nested_host_cr0_validfunction nested_cr4_validfunction nested_cpu_has_no_hw_errcode_cc
Annotated Snippet
#ifndef __KVM_X86_VMX_NESTED_H
#define __KVM_X86_VMX_NESTED_H
#include "regs.h"
#include "hyperv.h"
#include "vmcs12.h"
#include "vmx.h"
/*
* Status returned by nested_vmx_enter_non_root_mode():
*/
enum nvmx_vmentry_status {
NVMX_VMENTRY_SUCCESS, /* Entered VMX non-root mode */
NVMX_VMENTRY_VMFAIL, /* Consistency check VMFail */
NVMX_VMENTRY_VMEXIT, /* Consistency check VMExit */
NVMX_VMENTRY_KVM_INTERNAL_ERROR,/* KVM internal error */
};
void vmx_leave_nested(struct kvm_vcpu *vcpu);
void nested_vmx_setup_ctls_msrs(struct vmcs_config *vmcs_conf, u32 ept_caps);
void nested_vmx_hardware_unsetup(void);
__init int nested_vmx_hardware_setup(int (*exit_handlers[])(struct kvm_vcpu *));
void nested_vmx_set_vmcs_shadowing_bitmap(void);
int nested_vmx_check_restored_vmcs12(struct kvm_vcpu *vcpu);
void nested_vmx_free_vcpu(struct kvm_vcpu *vcpu);
enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu,
bool from_vmentry);
bool nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu);
void __nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 vm_exit_reason,
u32 exit_intr_info, unsigned long exit_qualification,
u32 exit_insn_len);
static inline void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 vm_exit_reason,
u32 exit_intr_info,
unsigned long exit_qualification)
{
u32 exit_insn_len;
if (to_vmx(vcpu)->fail || vm_exit_reason == -1 ||
(vm_exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY))
exit_insn_len = 0;
else
exit_insn_len = vmcs_read32(VM_EXIT_INSTRUCTION_LEN);
__nested_vmx_vmexit(vcpu, vm_exit_reason, exit_intr_info,
exit_qualification, exit_insn_len);
}
void nested_sync_vmcs12_to_shadow(struct kvm_vcpu *vcpu);
int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data);
int vmx_get_vmx_msr(struct nested_vmx_msrs *msrs, u32 msr_index, u64 *pdata);
int get_vmx_mem_address(struct kvm_vcpu *vcpu, unsigned long exit_qualification,
u32 vmx_instruction_info, bool wr, int len, gva_t *ret);
bool nested_vmx_check_io_bitmaps(struct kvm_vcpu *vcpu, unsigned int port,
int size);
static inline struct vmcs12 *get_vmcs12(struct kvm_vcpu *vcpu)
{
lockdep_assert_once(lockdep_is_held(&vcpu->mutex) ||
!refcount_read(&vcpu->kvm->users_count));
return to_vmx(vcpu)->nested.cached_vmcs12;
}
static inline struct vmcs12 *get_shadow_vmcs12(struct kvm_vcpu *vcpu)
{
lockdep_assert_once(lockdep_is_held(&vcpu->mutex) ||
!refcount_read(&vcpu->kvm->users_count));
return to_vmx(vcpu)->nested.cached_shadow_vmcs12;
}
/*
* Note: the same condition is checked against the state provided by userspace
* in vmx_set_nested_state; if it is satisfied, the nested state must include
* the VMCS12.
*/
static inline int vmx_has_valid_vmcs12(struct kvm_vcpu *vcpu)
{
struct vcpu_vmx *vmx = to_vmx(vcpu);
/* 'hv_evmcs_vmptr' can also be EVMPTR_MAP_PENDING here */
return vmx->nested.current_vmptr != -1ull ||
nested_vmx_is_evmptr12_set(vmx);
}
static inline u16 nested_get_vpid02(struct kvm_vcpu *vcpu)
{
struct vcpu_vmx *vmx = to_vmx(vcpu);
Annotation
- Immediate include surface: `regs.h`, `hyperv.h`, `vmcs12.h`, `vmx.h`.
- Detected declarations: `enum nvmx_vmentry_status`, `function nested_vmx_vmexit`, `function vmx_has_valid_vmcs12`, `function nested_get_vpid02`, `function nested_ept_get_eptp`, `function nested_ept_ad_enabled`, `function hypervisor`, `function nested_read_cr4`, `function nested_cpu_vmx_misc_cr3_count`, `function nested_cpu_has_vmwrite_any_field`.
- 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.