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.

Dependency Surface

Detected Declarations

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

Implementation Notes