From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx> This is just for convenience for benchmark. Signed-off-by: Isaku Yamahata <isaku.yamahata@xxxxxxxxx> --- arch/x86/kvm/vmx.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 08d13febc4b5..a4971b778794 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -10096,6 +10096,9 @@ static int (*const kvm_vmx_exit_handlers_fast[]) (struct kvm_vcpu *vcpu) = { static const int kvm_vmx_max_exit_handlers_fast = ARRAY_SIZE(kvm_vmx_exit_handlers_fast); +static bool __ro_after_init enable_fast_exit_handler = true; +module_param_named(fast_exit_handler, enable_fast_exit_handler, bool, 0444); +static DEFINE_STATIC_KEY_TRUE(enable_fast_exit_handler_key); static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) { @@ -10370,7 +10373,8 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) vmx_complete_atomic_exit(vmx); vmx_recover_nmi_blocking(vmx); - if (!is_guest_mode(vcpu) && + if (static_branch_likely(&enable_fast_exit_handler_key) && + !is_guest_mode(vcpu) && vmx->exit_reason < kvm_vmx_max_exit_handlers_fast && kvm_vmx_exit_handlers_fast[vmx->exit_reason]) { bool idtv_info_valid = @@ -13291,6 +13295,11 @@ static int __init vmx_init(void) { int r; + if (enable_fast_exit_handler) + static_branch_enable(&enable_fast_exit_handler_key); + else + static_branch_disable(&enable_fast_exit_handler_key); + #if IS_ENABLED(CONFIG_HYPERV) /* * Enlightened VMCS usage should be recommended and the host needs -- 2.17.1