3 #ifndef __ARCH_X86_KVM_VMX_ONHYPERV_H__
4 #define __ARCH_X86_KVM_VMX_ONHYPERV_H__
6 #include <asm/hyperv-tlfs.h>
7 #include <asm/mshyperv.h>
9 #include <linux/jump_label.h>
15 #define current_evmcs ((struct hv_enlightened_vmcs *)this_cpu_read(current_vmcs))
17 #if IS_ENABLED(CONFIG_HYPERV)
23 return static_branch_unlikely(&__kvm_is_using_evmcs);
26 static __always_inline
int get_evmcs_offset(
unsigned long field,
31 WARN_ONCE(offset < 0,
"accessing unsupported EVMCS field %lx\n", field);
35 static __always_inline
void evmcs_write64(
unsigned long field, u64 value)
38 int offset = get_evmcs_offset(field, &clean_field);
48 static __always_inline
void evmcs_write32(
unsigned long field, u32 value)
51 int offset = get_evmcs_offset(field, &clean_field);
60 static __always_inline
void evmcs_write16(
unsigned long field, u16 value)
63 int offset = get_evmcs_offset(field, &clean_field);
72 static __always_inline u64
evmcs_read64(
unsigned long field)
74 int offset = get_evmcs_offset(field, NULL);
82 static __always_inline u32
evmcs_read32(
unsigned long field)
84 int offset = get_evmcs_offset(field, NULL);
92 static __always_inline u16
evmcs_read16(
unsigned long field)
94 int offset = get_evmcs_offset(field, NULL);
104 struct hv_vp_assist_page *vp_ap =
105 hv_get_vp_assist_page(smp_processor_id());
107 if (
current_evmcs->hv_enlightenments_control.nested_flush_hypercall)
108 vp_ap->nested_control.features.directhypercall = 1;
109 vp_ap->current_nested_vmcs = phys_addr;
110 vp_ap->enlighten_vmentry = 1;
116 static __always_inline
void evmcs_write64(
unsigned long field, u64 value) {}
117 static __always_inline
void evmcs_write32(
unsigned long field, u32 value) {}
118 static __always_inline
void evmcs_write16(
unsigned long field, u16 value) {}
119 static __always_inline u64
evmcs_read64(
unsigned long field) {
return 0; }
120 static __always_inline u32
evmcs_read32(
unsigned long field) {
return 0; }
121 static __always_inline u16
evmcs_read16(
unsigned long field) {
return 0; }
static __always_inline int evmcs_field_offset(unsigned long field, u16 *clean_field)
DECLARE_STATIC_KEY_FALSE(kvm_has_noapic_vcpu)
void evmcs_sanitize_exec_ctrls(struct vmcs_config *vmcs_conf)
static __always_inline void evmcs_write16(unsigned long field, u16 value)
static __always_inline void evmcs_write32(unsigned long field, u32 value)
static __always_inline u16 evmcs_read16(unsigned long field)
static __always_inline u64 evmcs_read64(unsigned long field)
static __always_inline bool kvm_is_using_evmcs(void)
static __always_inline void evmcs_write64(unsigned long field, u64 value)
static __always_inline u32 evmcs_read32(unsigned long field)
static void evmcs_load(u64 phys_addr)