|
24 | 24 | #include <linux/kvm_host.h> |
25 | 25 | #include "x86.h" |
26 | 26 |
|
| 27 | +#ifdef CONFIG_KVM_HYPERV |
| 28 | + |
27 | 29 | /* "Hv#1" signature */ |
28 | 30 | #define HYPERV_CPUID_SIGNATURE_EAX 0x31237648 |
29 | 31 |
|
@@ -105,6 +107,17 @@ int kvm_hv_synic_set_irq(struct kvm *kvm, u32 vcpu_id, u32 sint); |
105 | 107 | void kvm_hv_synic_send_eoi(struct kvm_vcpu *vcpu, int vector); |
106 | 108 | int kvm_hv_activate_synic(struct kvm_vcpu *vcpu, bool dont_zero_synic_pages); |
107 | 109 |
|
| 110 | +static inline bool kvm_hv_synic_has_vector(struct kvm_vcpu *vcpu, int vector) |
| 111 | +{ |
| 112 | + return to_hv_vcpu(vcpu) && test_bit(vector, to_hv_synic(vcpu)->vec_bitmap); |
| 113 | +} |
| 114 | + |
| 115 | +static inline bool kvm_hv_synic_auto_eoi_set(struct kvm_vcpu *vcpu, int vector) |
| 116 | +{ |
| 117 | + return to_hv_vcpu(vcpu) && |
| 118 | + test_bit(vector, to_hv_synic(vcpu)->auto_eoi_bitmap); |
| 119 | +} |
| 120 | + |
108 | 121 | void kvm_hv_vcpu_uninit(struct kvm_vcpu *vcpu); |
109 | 122 |
|
110 | 123 | bool kvm_hv_assist_page_enabled(struct kvm_vcpu *vcpu); |
@@ -236,6 +249,76 @@ static inline int kvm_hv_verify_vp_assist(struct kvm_vcpu *vcpu) |
236 | 249 | return kvm_hv_get_assist_page(vcpu); |
237 | 250 | } |
238 | 251 |
|
| 252 | +static inline void kvm_hv_nested_transtion_tlb_flush(struct kvm_vcpu *vcpu, |
| 253 | + bool tdp_enabled) |
| 254 | +{ |
| 255 | + /* |
| 256 | + * KVM_REQ_HV_TLB_FLUSH flushes entries from either L1's VP_ID or |
| 257 | + * L2's VP_ID upon request from the guest. Make sure we check for |
| 258 | + * pending entries in the right FIFO upon L1/L2 transition as these |
| 259 | + * requests are put by other vCPUs asynchronously. |
| 260 | + */ |
| 261 | + if (to_hv_vcpu(vcpu) && tdp_enabled) |
| 262 | + kvm_make_request(KVM_REQ_HV_TLB_FLUSH, vcpu); |
| 263 | +} |
| 264 | + |
239 | 265 | int kvm_hv_vcpu_flush_tlb(struct kvm_vcpu *vcpu); |
| 266 | +#else /* CONFIG_KVM_HYPERV */ |
| 267 | +static inline void kvm_hv_setup_tsc_page(struct kvm *kvm, |
| 268 | + struct pvclock_vcpu_time_info *hv_clock) {} |
| 269 | +static inline void kvm_hv_request_tsc_page_update(struct kvm *kvm) {} |
| 270 | +static inline void kvm_hv_init_vm(struct kvm *kvm) {} |
| 271 | +static inline void kvm_hv_destroy_vm(struct kvm *kvm) {} |
| 272 | +static inline int kvm_hv_vcpu_init(struct kvm_vcpu *vcpu) |
| 273 | +{ |
| 274 | + return 0; |
| 275 | +} |
| 276 | +static inline void kvm_hv_vcpu_uninit(struct kvm_vcpu *vcpu) {} |
| 277 | +static inline bool kvm_hv_hypercall_enabled(struct kvm_vcpu *vcpu) |
| 278 | +{ |
| 279 | + return false; |
| 280 | +} |
| 281 | +static inline int kvm_hv_hypercall(struct kvm_vcpu *vcpu) |
| 282 | +{ |
| 283 | + return HV_STATUS_ACCESS_DENIED; |
| 284 | +} |
| 285 | +static inline void kvm_hv_vcpu_purge_flush_tlb(struct kvm_vcpu *vcpu) {} |
| 286 | +static inline void kvm_hv_free_pa_page(struct kvm *kvm) {} |
| 287 | +static inline bool kvm_hv_synic_has_vector(struct kvm_vcpu *vcpu, int vector) |
| 288 | +{ |
| 289 | + return false; |
| 290 | +} |
| 291 | +static inline bool kvm_hv_synic_auto_eoi_set(struct kvm_vcpu *vcpu, int vector) |
| 292 | +{ |
| 293 | + return false; |
| 294 | +} |
| 295 | +static inline void kvm_hv_synic_send_eoi(struct kvm_vcpu *vcpu, int vector) {} |
| 296 | +static inline bool kvm_hv_invtsc_suppressed(struct kvm_vcpu *vcpu) |
| 297 | +{ |
| 298 | + return false; |
| 299 | +} |
| 300 | +static inline void kvm_hv_set_cpuid(struct kvm_vcpu *vcpu, bool hyperv_enabled) {} |
| 301 | +static inline bool kvm_hv_has_stimer_pending(struct kvm_vcpu *vcpu) |
| 302 | +{ |
| 303 | + return false; |
| 304 | +} |
| 305 | +static inline bool kvm_hv_is_tlb_flush_hcall(struct kvm_vcpu *vcpu) |
| 306 | +{ |
| 307 | + return false; |
| 308 | +} |
| 309 | +static inline bool guest_hv_cpuid_has_l2_tlb_flush(struct kvm_vcpu *vcpu) |
| 310 | +{ |
| 311 | + return false; |
| 312 | +} |
| 313 | +static inline int kvm_hv_verify_vp_assist(struct kvm_vcpu *vcpu) |
| 314 | +{ |
| 315 | + return 0; |
| 316 | +} |
| 317 | +static inline u32 kvm_hv_get_vpindex(struct kvm_vcpu *vcpu) |
| 318 | +{ |
| 319 | + return vcpu->vcpu_idx; |
| 320 | +} |
| 321 | +static inline void kvm_hv_nested_transtion_tlb_flush(struct kvm_vcpu *vcpu, bool tdp_enabled) {} |
| 322 | +#endif /* CONFIG_KVM_HYPERV */ |
240 | 323 |
|
241 | | -#endif |
| 324 | +#endif /* __ARCH_X86_KVM_HYPERV_H__ */ |
0 commit comments