KVM
hyperv.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __KVM_X86_VMX_HYPERV_H
3 #define __KVM_X86_VMX_HYPERV_H
4 
5 #include <linux/kvm_host.h>
6 #include "vmcs12.h"
7 #include "vmx.h"
8 
9 #define EVMPTR_INVALID (-1ULL)
10 #define EVMPTR_MAP_PENDING (-2ULL)
11 
17 };
18 
19 #ifdef CONFIG_KVM_HYPERV
20 static inline bool evmptr_is_valid(u64 evmptr)
21 {
22  return evmptr != EVMPTR_INVALID && evmptr != EVMPTR_MAP_PENDING;
23 }
24 
25 static inline bool nested_vmx_is_evmptr12_valid(struct vcpu_vmx *vmx)
26 {
27  return evmptr_is_valid(vmx->nested.hv_evmcs_vmptr);
28 }
29 
30 static inline bool evmptr_is_set(u64 evmptr)
31 {
32  return evmptr != EVMPTR_INVALID;
33 }
34 
35 static inline bool nested_vmx_is_evmptr12_set(struct vcpu_vmx *vmx)
36 {
37  return evmptr_is_set(vmx->nested.hv_evmcs_vmptr);
38 }
39 
40 static inline struct hv_enlightened_vmcs *nested_vmx_evmcs(struct vcpu_vmx *vmx)
41 {
42  return vmx->nested.hv_evmcs;
43 }
44 
45 static inline bool guest_cpuid_has_evmcs(struct kvm_vcpu *vcpu)
46 {
47  /*
48  * eVMCS is exposed to the guest if Hyper-V is enabled in CPUID and
49  * eVMCS has been explicitly enabled by userspace.
50  */
51  return vcpu->arch.hyperv_enabled &&
53 }
54 
55 u64 nested_get_evmptr(struct kvm_vcpu *vcpu);
56 uint16_t nested_get_evmcs_version(struct kvm_vcpu *vcpu);
57 int nested_enable_evmcs(struct kvm_vcpu *vcpu,
58  uint16_t *vmcs_version);
59 void nested_evmcs_filter_control_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata);
61 bool nested_evmcs_l2_tlb_flush_enabled(struct kvm_vcpu *vcpu);
62 void vmx_hv_inject_synthetic_vmexit_post_tlb_flush(struct kvm_vcpu *vcpu);
63 #else
64 static inline bool evmptr_is_valid(u64 evmptr)
65 {
66  return false;
67 }
68 
69 static inline bool nested_vmx_is_evmptr12_valid(struct vcpu_vmx *vmx)
70 {
71  return false;
72 }
73 
74 static inline bool evmptr_is_set(u64 evmptr)
75 {
76  return false;
77 }
78 
79 static inline bool nested_vmx_is_evmptr12_set(struct vcpu_vmx *vmx)
80 {
81  return false;
82 }
83 
84 static inline struct hv_enlightened_vmcs *nested_vmx_evmcs(struct vcpu_vmx *vmx)
85 {
86  return NULL;
87 }
88 #endif
89 
90 #endif /* __KVM_X86_VMX_HYPERV_H */
bool enlightened_vmcs_enabled
Definition: vmx.h:186
Definition: vmx.h:251
struct nested_vmx nested
Definition: vmx.h:329
Definition: vmcs12.h:27
bool nested_evmcs_l2_tlb_flush_enabled(struct kvm_vcpu *vcpu)
Definition: hyperv.c:211
int nested_enable_evmcs(struct kvm_vcpu *vcpu, uint16_t *vmcs_version)
Definition: hyperv.c:198
void vmx_hv_inject_synthetic_vmexit_post_tlb_flush(struct kvm_vcpu *vcpu)
Definition: hyperv.c:226
void nested_evmcs_filter_control_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata)
Definition: hyperv.c:111
u64 nested_get_evmptr(struct kvm_vcpu *vcpu)
Definition: hyperv.c:16
int nested_evmcs_check_controls(struct vmcs12 *vmcs12)
Definition: hyperv.c:161
uint16_t nested_get_evmcs_version(struct kvm_vcpu *vcpu)
Definition: hyperv.c:29
static bool evmptr_is_valid(u64 evmptr)
Definition: hyperv.h:64
#define EVMPTR_MAP_PENDING
Definition: hyperv.h:10
nested_evmptrld_status
Definition: hyperv.h:12
@ EVMPTRLD_ERROR
Definition: hyperv.h:16
@ EVMPTRLD_DISABLED
Definition: hyperv.h:13
@ EVMPTRLD_VMFAIL
Definition: hyperv.h:15
@ EVMPTRLD_SUCCEEDED
Definition: hyperv.h:14
static bool evmptr_is_set(u64 evmptr)
Definition: hyperv.h:74
static bool nested_vmx_is_evmptr12_valid(struct vcpu_vmx *vmx)
Definition: hyperv.h:69
#define EVMPTR_INVALID
Definition: hyperv.h:9
static bool nested_vmx_is_evmptr12_set(struct vcpu_vmx *vmx)
Definition: hyperv.h:79
static struct hv_enlightened_vmcs * nested_vmx_evmcs(struct vcpu_vmx *vmx)
Definition: hyperv.h:84
static __always_inline struct vcpu_vmx * to_vmx(struct kvm_vcpu *vcpu)
Definition: vmx.h:657