4949#include <asm/spec-ctrl.h>
5050#include <asm/vmx.h>
5151
52+ #include <trace/events/ipi.h>
53+
5254#include "capabilities.h"
5355#include "cpuid.h"
5456#include "hyperv.h"
@@ -1281,8 +1283,6 @@ void vmx_prepare_switch_to_guest(struct kvm_vcpu *vcpu)
12811283 u16 fs_sel , gs_sel ;
12821284 int i ;
12831285
1284- vmx -> req_immediate_exit = false;
1285-
12861286 /*
12871287 * Note that guest MSRs to be saved/restored can also be changed
12881288 * when guest state is loaded. This happens when guest transitions
@@ -5988,7 +5988,8 @@ static int handle_pml_full(struct kvm_vcpu *vcpu)
59885988 return 1 ;
59895989}
59905990
5991- static fastpath_t handle_fastpath_preemption_timer (struct kvm_vcpu * vcpu )
5991+ static fastpath_t handle_fastpath_preemption_timer (struct kvm_vcpu * vcpu ,
5992+ bool force_immediate_exit )
59925993{
59935994 struct vcpu_vmx * vmx = to_vmx (vcpu );
59945995
@@ -6004,7 +6005,7 @@ static fastpath_t handle_fastpath_preemption_timer(struct kvm_vcpu *vcpu)
60046005 * If the timer expired because KVM used it to force an immediate exit,
60056006 * then mission accomplished.
60066007 */
6007- if (vmx -> req_immediate_exit )
6008+ if (force_immediate_exit )
60086009 return EXIT_FASTPATH_EXIT_HANDLED ;
60096010
60106011 /*
@@ -7166,13 +7167,13 @@ static void atomic_switch_perf_msrs(struct vcpu_vmx *vmx)
71667167 msrs [i ].host , false);
71677168}
71687169
7169- static void vmx_update_hv_timer (struct kvm_vcpu * vcpu )
7170+ static void vmx_update_hv_timer (struct kvm_vcpu * vcpu , bool force_immediate_exit )
71707171{
71717172 struct vcpu_vmx * vmx = to_vmx (vcpu );
71727173 u64 tscl ;
71737174 u32 delta_tsc ;
71747175
7175- if (vmx -> req_immediate_exit ) {
7176+ if (force_immediate_exit ) {
71767177 vmcs_write32 (VMX_PREEMPTION_TIMER_VALUE , 0 );
71777178 vmx -> loaded_vmcs -> hv_timer_soft_disabled = false;
71787179 } else if (vmx -> hv_deadline_tsc != -1 ) {
@@ -7225,7 +7226,8 @@ void noinstr vmx_spec_ctrl_restore_host(struct vcpu_vmx *vmx,
72257226 barrier_nospec ();
72267227}
72277228
7228- static fastpath_t vmx_exit_handlers_fastpath (struct kvm_vcpu * vcpu )
7229+ static fastpath_t vmx_exit_handlers_fastpath (struct kvm_vcpu * vcpu ,
7230+ bool force_immediate_exit )
72297231{
72307232 /*
72317233 * If L2 is active, some VMX preemption timer exits can be handled in
@@ -7239,7 +7241,7 @@ static fastpath_t vmx_exit_handlers_fastpath(struct kvm_vcpu *vcpu)
72397241 case EXIT_REASON_MSR_WRITE :
72407242 return handle_fastpath_set_msr_irqoff (vcpu );
72417243 case EXIT_REASON_PREEMPTION_TIMER :
7242- return handle_fastpath_preemption_timer (vcpu );
7244+ return handle_fastpath_preemption_timer (vcpu , force_immediate_exit );
72437245 default :
72447246 return EXIT_FASTPATH_NONE ;
72457247 }
@@ -7382,7 +7384,9 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu, bool force_immediate_exit)
73827384 vmx_passthrough_lbr_msrs (vcpu );
73837385
73847386 if (enable_preemption_timer )
7385- vmx_update_hv_timer (vcpu );
7387+ vmx_update_hv_timer (vcpu , force_immediate_exit );
7388+ else if (force_immediate_exit )
7389+ smp_send_reschedule (vcpu -> cpu );
73867390
73877391 kvm_wait_lapic_expire (vcpu );
73887392
@@ -7446,7 +7450,7 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu, bool force_immediate_exit)
74467450 vmx_recover_nmi_blocking (vmx );
74477451 vmx_complete_interrupts (vmx );
74487452
7449- return vmx_exit_handlers_fastpath (vcpu );
7453+ return vmx_exit_handlers_fastpath (vcpu , force_immediate_exit );
74507454}
74517455
74527456static void vmx_vcpu_free (struct kvm_vcpu * vcpu )
@@ -7926,11 +7930,6 @@ static __init void vmx_set_cpu_caps(void)
79267930 kvm_cpu_cap_check_and_set (X86_FEATURE_WAITPKG );
79277931}
79287932
7929- static void vmx_request_immediate_exit (struct kvm_vcpu * vcpu )
7930- {
7931- to_vmx (vcpu )-> req_immediate_exit = true;
7932- }
7933-
79347933static int vmx_check_intercept_io (struct kvm_vcpu * vcpu ,
79357934 struct x86_instruction_info * info )
79367935{
@@ -8383,8 +8382,6 @@ static struct kvm_x86_ops vmx_x86_ops __initdata = {
83838382 .check_intercept = vmx_check_intercept ,
83848383 .handle_exit_irqoff = vmx_handle_exit_irqoff ,
83858384
8386- .request_immediate_exit = vmx_request_immediate_exit ,
8387-
83888385 .sched_in = vmx_sched_in ,
83898386
83908387 .cpu_dirty_log_size = PML_ENTITY_NUM ,
@@ -8644,7 +8641,6 @@ static __init int hardware_setup(void)
86448641 if (!enable_preemption_timer ) {
86458642 vmx_x86_ops .set_hv_timer = NULL ;
86468643 vmx_x86_ops .cancel_hv_timer = NULL ;
8647- vmx_x86_ops .request_immediate_exit = __kvm_request_immediate_exit ;
86488644 }
86498645
86508646 kvm_caps .supported_mce_cap |= MCG_LMCE_P ;
0 commit comments