1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __KVM_X86_VMX_X86_OPS_H 3 #define __KVM_X86_VMX_X86_OPS_H 4 5 #include <linux/kvm_host.h> 6 7 #include "x86.h" 8 9 __init int vmx_hardware_setup(void); 10 11 extern struct kvm_x86_ops vt_x86_ops __initdata; 12 extern struct kvm_x86_init_ops vt_init_ops __initdata; 13 14 void vmx_hardware_unsetup(void); 15 int vmx_check_processor_compat(void); 16 int vmx_hardware_enable(void); 17 void vmx_hardware_disable(void); 18 int vmx_vm_init(struct kvm *kvm); 19 void vmx_vm_destroy(struct kvm *kvm); 20 int vmx_vcpu_precreate(struct kvm *kvm); 21 int vmx_vcpu_create(struct kvm_vcpu *vcpu); 22 int vmx_vcpu_pre_run(struct kvm_vcpu *vcpu); 23 fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu, bool force_immediate_exit); 24 void vmx_vcpu_free(struct kvm_vcpu *vcpu); 25 void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event); 26 void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu); 27 void vmx_vcpu_put(struct kvm_vcpu *vcpu); 28 int vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath); 29 void vmx_handle_exit_irqoff(struct kvm_vcpu *vcpu); 30 int vmx_skip_emulated_instruction(struct kvm_vcpu *vcpu); 31 void vmx_update_emulated_instruction(struct kvm_vcpu *vcpu); 32 int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info); 33 #ifdef CONFIG_KVM_SMM 34 int vmx_smi_allowed(struct kvm_vcpu *vcpu, bool for_injection); 35 int vmx_enter_smm(struct kvm_vcpu *vcpu, union kvm_smram *smram); 36 int vmx_leave_smm(struct kvm_vcpu *vcpu, const union kvm_smram *smram); 37 void vmx_enable_smi_window(struct kvm_vcpu *vcpu); 38 #endif 39 int vmx_check_emulate_instruction(struct kvm_vcpu *vcpu, int emul_type, 40 void *insn, int insn_len); 41 int vmx_check_intercept(struct kvm_vcpu *vcpu, 42 struct x86_instruction_info *info, 43 enum x86_intercept_stage stage, 44 struct x86_exception *exception); 45 bool vmx_apic_init_signal_blocked(struct kvm_vcpu *vcpu); 46 void vmx_migrate_timers(struct kvm_vcpu *vcpu); 47 void vmx_set_virtual_apic_mode(struct kvm_vcpu *vcpu); 48 void vmx_apicv_pre_state_restore(struct kvm_vcpu *vcpu); 49 bool vmx_check_apicv_inhibit_reasons(enum kvm_apicv_inhibit reason); 50 void vmx_hwapic_irr_update(struct kvm_vcpu *vcpu, int max_irr); 51 void vmx_hwapic_isr_update(int max_isr); 52 bool vmx_guest_apic_has_interrupt(struct kvm_vcpu *vcpu); 53 int vmx_sync_pir_to_irr(struct kvm_vcpu *vcpu); 54 void vmx_deliver_interrupt(struct kvm_lapic *apic, int delivery_mode, 55 int trig_mode, int vector); 56 void vmx_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu); 57 bool vmx_has_emulated_msr(struct kvm *kvm, u32 index); 58 void vmx_msr_filter_changed(struct kvm_vcpu *vcpu); 59 void vmx_prepare_switch_to_guest(struct kvm_vcpu *vcpu); 60 void vmx_update_exception_bitmap(struct kvm_vcpu *vcpu); 61 int vmx_get_msr_feature(struct kvm_msr_entry *msr); 62 int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info); 63 u64 vmx_get_segment_base(struct kvm_vcpu *vcpu, int seg); 64 void vmx_get_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg); 65 void vmx_set_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg); 66 int vmx_get_cpl(struct kvm_vcpu *vcpu); 67 void vmx_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l); 68 bool vmx_is_valid_cr0(struct kvm_vcpu *vcpu, unsigned long cr0); 69 void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0); 70 void vmx_load_mmu_pgd(struct kvm_vcpu *vcpu, hpa_t root_hpa, int root_level); 71 void vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4); 72 bool vmx_is_valid_cr4(struct kvm_vcpu *vcpu, unsigned long cr4); 73 int vmx_set_efer(struct kvm_vcpu *vcpu, u64 efer); 74 void vmx_get_idt(struct kvm_vcpu *vcpu, struct desc_ptr *dt); 75 void vmx_set_idt(struct kvm_vcpu *vcpu, struct desc_ptr *dt); 76 void vmx_get_gdt(struct kvm_vcpu *vcpu, struct desc_ptr *dt); 77 void vmx_set_gdt(struct kvm_vcpu *vcpu, struct desc_ptr *dt); 78 void vmx_set_dr7(struct kvm_vcpu *vcpu, unsigned long val); 79 void vmx_sync_dirty_debug_regs(struct kvm_vcpu *vcpu); 80 void vmx_cache_reg(struct kvm_vcpu *vcpu, enum kvm_reg reg); 81 unsigned long vmx_get_rflags(struct kvm_vcpu *vcpu); 82 void vmx_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags); 83 bool vmx_get_if_flag(struct kvm_vcpu *vcpu); 84 void vmx_flush_tlb_all(struct kvm_vcpu *vcpu); 85 void vmx_flush_tlb_current(struct kvm_vcpu *vcpu); 86 void vmx_flush_tlb_gva(struct kvm_vcpu *vcpu, gva_t addr); 87 void vmx_flush_tlb_guest(struct kvm_vcpu *vcpu); 88 void vmx_set_interrupt_shadow(struct kvm_vcpu *vcpu, int mask); 89 u32 vmx_get_interrupt_shadow(struct kvm_vcpu *vcpu); 90 void vmx_patch_hypercall(struct kvm_vcpu *vcpu, unsigned char *hypercall); 91 void vmx_inject_irq(struct kvm_vcpu *vcpu, bool reinjected); 92 void vmx_inject_nmi(struct kvm_vcpu *vcpu); 93 void vmx_inject_exception(struct kvm_vcpu *vcpu); 94 void vmx_cancel_injection(struct kvm_vcpu *vcpu); 95 int vmx_interrupt_allowed(struct kvm_vcpu *vcpu, bool for_injection); 96 int vmx_nmi_allowed(struct kvm_vcpu *vcpu, bool for_injection); 97 bool vmx_get_nmi_mask(struct kvm_vcpu *vcpu); 98 void vmx_set_nmi_mask(struct kvm_vcpu *vcpu, bool masked); 99 void vmx_enable_nmi_window(struct kvm_vcpu *vcpu); 100 void vmx_enable_irq_window(struct kvm_vcpu *vcpu); 101 void vmx_update_cr8_intercept(struct kvm_vcpu *vcpu, int tpr, int irr); 102 void vmx_set_apic_access_page_addr(struct kvm_vcpu *vcpu); 103 void vmx_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu); 104 void vmx_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap); 105 int vmx_set_tss_addr(struct kvm *kvm, unsigned int addr); 106 int vmx_set_identity_map_addr(struct kvm *kvm, u64 ident_addr); 107 u8 vmx_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio); 108 void vmx_get_exit_info(struct kvm_vcpu *vcpu, u32 *reason, 109 u64 *info1, u64 *info2, u32 *intr_info, u32 *error_code); 110 u64 vmx_get_l2_tsc_offset(struct kvm_vcpu *vcpu); 111 u64 vmx_get_l2_tsc_multiplier(struct kvm_vcpu *vcpu); 112 void vmx_write_tsc_offset(struct kvm_vcpu *vcpu); 113 void vmx_write_tsc_multiplier(struct kvm_vcpu *vcpu); 114 void vmx_request_immediate_exit(struct kvm_vcpu *vcpu); 115 void vmx_sched_in(struct kvm_vcpu *vcpu, int cpu); 116 void vmx_update_cpu_dirty_logging(struct kvm_vcpu *vcpu); 117 #ifdef CONFIG_X86_64 118 int vmx_set_hv_timer(struct kvm_vcpu *vcpu, u64 guest_deadline_tsc, 119 bool *expired); 120 void vmx_cancel_hv_timer(struct kvm_vcpu *vcpu); 121 #endif 122 void vmx_setup_mce(struct kvm_vcpu *vcpu); 123 124 #endif /* __KVM_X86_VMX_X86_OPS_H */ 125