mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-24 10:17:28 +00:00
hv: nested: implement the framework for VMX MSR emulation
Define LIST_OF_VMX_MSRS which includes a list of MSRs that are visible to L1 guests if nested virtualization is enabled. - If CONFIG_NVMX_ENABLED is set, these MSRs are included in emulated_guest_msrs[]. - otherwise, they are included in unsupported_msrs[]. In this way we can take advantage of the existing infrastructure to emulate these MSRs. Tracked-On: #5923 Spick igned-off-by: Zide Chen <zide.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
61
hypervisor/include/arch/x86/asm/guest/nested.h
Normal file
61
hypervisor/include/arch/x86/asm/guest/nested.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef NESTED_H
|
||||
#define NESTED_H
|
||||
|
||||
#include <lib/errno.h>
|
||||
|
||||
/*
|
||||
* Following MSRs are supported if nested virtualization is enabled
|
||||
* - If CONFIG_NVMX_ENABLED is set, these MSRs are included in emulated_guest_msrs[]
|
||||
* - otherwise, they are included in unsupported_msrs[]
|
||||
*/
|
||||
#define NUM_VMX_MSRS 20U
|
||||
#define LIST_OF_VMX_MSRS \
|
||||
MSR_IA32_SMBASE, \
|
||||
MSR_IA32_VMX_BASIC, \
|
||||
MSR_IA32_VMX_PINBASED_CTLS, \
|
||||
MSR_IA32_VMX_PROCBASED_CTLS, \
|
||||
MSR_IA32_VMX_EXIT_CTLS, \
|
||||
MSR_IA32_VMX_ENTRY_CTLS, \
|
||||
MSR_IA32_VMX_MISC, \
|
||||
MSR_IA32_VMX_CR0_FIXED0, \
|
||||
MSR_IA32_VMX_CR0_FIXED1, \
|
||||
MSR_IA32_VMX_CR4_FIXED0, \
|
||||
MSR_IA32_VMX_CR4_FIXED1, \
|
||||
MSR_IA32_VMX_VMCS_ENUM, \
|
||||
MSR_IA32_VMX_PROCBASED_CTLS2, \
|
||||
MSR_IA32_VMX_EPT_VPID_CAP, \
|
||||
MSR_IA32_VMX_TRUE_PINBASED_CTLS, \
|
||||
MSR_IA32_VMX_TRUE_PROCBASED_CTLS, \
|
||||
MSR_IA32_VMX_TRUE_EXIT_CTLS, \
|
||||
MSR_IA32_VMX_TRUE_ENTRY_CTLS, \
|
||||
MSR_IA32_VMX_VMFUNC, \
|
||||
MSR_IA32_VMX_PROCBASED_CTLS3
|
||||
|
||||
#ifdef CONFIG_NVMX_ENABLED
|
||||
bool is_vmx_msr(uint32_t msr);
|
||||
void init_vmx_msrs(struct acrn_vcpu *vcpu);
|
||||
int32_t read_vmx_msr(__unused struct acrn_vcpu *vcpu, uint32_t msr, uint64_t *val);
|
||||
#else
|
||||
static inline bool is_vmx_msr(__unused uint32_t msr)
|
||||
{
|
||||
/*
|
||||
* if nested virtualization is disabled, return false so that
|
||||
* it can be treated as unsupported MSR.
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void init_vmx_msrs(__unused struct acrn_vcpu *vcpu) {}
|
||||
|
||||
static inline int32_t read_vmx_msr(__unused struct acrn_vcpu *vcpu,
|
||||
__unused uint32_t msr, __unused uint64_t *val)
|
||||
{
|
||||
return -EACCES;
|
||||
}
|
||||
#endif /* CONFIG_NVMX_ENABLED */
|
||||
#endif /* NESTED_H */
|
@@ -27,6 +27,7 @@
|
||||
#include <asm/msr.h>
|
||||
#include <asm/cpu.h>
|
||||
#include <asm/guest/instr_emul.h>
|
||||
#include <asm/guest/nested.h>
|
||||
#include <asm/vmx.h>
|
||||
|
||||
/**
|
||||
@@ -172,7 +173,11 @@ enum reset_mode;
|
||||
|
||||
#define NUM_WORLD_MSRS 2U
|
||||
#define NUM_COMMON_MSRS 22U
|
||||
#ifdef CONFIG_NVMX_ENABLED
|
||||
#define NUM_GUEST_MSRS (NUM_WORLD_MSRS + NUM_COMMON_MSRS + NUM_VMX_MSRS)
|
||||
#else
|
||||
#define NUM_GUEST_MSRS (NUM_WORLD_MSRS + NUM_COMMON_MSRS)
|
||||
#endif
|
||||
|
||||
#define EOI_EXIT_BITMAP_SIZE 256U
|
||||
|
||||
|
Reference in New Issue
Block a user