Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp904486ybn; Wed, 25 Sep 2019 09:22:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzIA1YgYNdlinlnm93h5OUmAXCJKdQDWhNZcWvCJiEGJD7pOYST5l3PaHuWdrNLKuRnt/e8 X-Received: by 2002:a05:6402:a48:: with SMTP id bt8mr3907088edb.298.1569428576722; Wed, 25 Sep 2019 09:22:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569428576; cv=none; d=google.com; s=arc-20160816; b=vRdOt+S4Uk8J/lkq8z8feIdK040l+AZuPNpq/sR2LOcRRrFjMOfhbgUEIKF+MvlpLl VKMp2+sA6pyhj1kCgx/pbtamMSeq0k68q2PGE7OA+zJb13qUArrg4ygW9lEXoIACwjOh y2kQGPK47uL7TJmE+KM9UhVgTpyl8MepCX5J9vKqpTf6kA76HoGyQigco6wZ7DnufA+7 RRCY6KOYk6b4Y3VKEoeG8+vmAEpZtld+cK0H2EooOdOfvJ2QYs8DOVb2jngHoizPYtYT /yubGxpeV0F8f019uLeWnVBxsE8uVG9TKGsvS23K5ATXIwqlNu35I6s7PQ4GBzZ9VUTM qGtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=8V3J3mZKXIMGBd+OjFDzSBLSo24LKJUHdAYzEYR+F7Y=; b=SKnAcc8sqQW0yUVzWSYwp0ANH2O3VZ5cAGSvLsJRp5dU2BcVWsTRR/Y2o4oRY97Y1/ ktwBoWw833QsPF8UPX8MUIfxxN5GgySJfpu0cQcQnKEoiNPRc9VIntRBJxSBjN47kpbq VH0eOwuVsEQsMIpcXUG51s5g1qQRHXbxnaEg6YGFZzRSiYNrwqpKQjDP11C3l8tu7Gc1 pqccmXke1NvVS2j/0kNPSnkCMUJ4jihuXlEsmi7ThJMOT1rgIPDtIVBAPXK2UL0k3pJW QFD9qeLIaC/d45gvJKJVjPp1mw1R1vEVpIPpr6R9Vf13cnpMOxQH73R8wpzcF1xC4y37 hIIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f13si3652105edl.170.2019.09.25.09.22.33; Wed, 25 Sep 2019 09:22:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732723AbfIWQ2j (ORCPT + 99 others); Mon, 23 Sep 2019 12:28:39 -0400 Received: from mga02.intel.com ([134.134.136.20]:26282 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726328AbfIWQ2j (ORCPT ); Mon, 23 Sep 2019 12:28:39 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 09:28:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,541,1559545200"; d="scan'208";a="189108811" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.41]) by fmsmga007.fm.intel.com with ESMTP; 23 Sep 2019 09:28:37 -0700 Date: Mon, 23 Sep 2019 09:28:37 -0700 From: Sean Christopherson To: Andrea Arcangeli Cc: Paolo Bonzini , Vitaly Kuznetsov , "Dr. David Alan Gilbert" , Marcelo Tosatti , Peter Xu , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 15/17] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers Message-ID: <20190923162837.GD18195@linux.intel.com> References: <20190920212509.2578-1-aarcange@redhat.com> <20190920212509.2578-16-aarcange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190920212509.2578-16-aarcange@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Subject should be something like: KVM: VMX: Make direct calls to fast path VM-Exit handlers On Fri, Sep 20, 2019 at 05:25:07PM -0400, Andrea Arcangeli wrote: > It's enough to check the exit value and issue a direct call to avoid > the retpoline for all the common vmexit reasons. > > Signed-off-by: Andrea Arcangeli > --- > arch/x86/kvm/vmx/vmx.c | 24 ++++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index a6e597025011..9aa73e216df2 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -5866,9 +5866,29 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu) > } > > if (exit_reason < kvm_vmx_max_exit_handlers > - && kvm_vmx_exit_handlers[exit_reason]) > + && kvm_vmx_exit_handlers[exit_reason]) { > +#ifdef CONFIG_RETPOLINE I'd strongly prefer to make any optimization of this type unconditional, i.e. not dependent on CONFIG_RETPOLINE. Today, I'm comfortable testing KVM only with CONFIG_RETPOLINE=y since the only KVM-specific difference is additive code in vmx_vmexit. That would no longer be the case if KVM has non-trivial code differences for retpoline. > + if (exit_reason == EXIT_REASON_MSR_WRITE) > + return handle_wrmsr(vcpu); > + else if (exit_reason == EXIT_REASON_PREEMPTION_TIMER) > + return handle_preemption_timer(vcpu); > + else if (exit_reason == EXIT_REASON_PENDING_INTERRUPT) > + return handle_interrupt_window(vcpu); > + else if (exit_reason == EXIT_REASON_EXTERNAL_INTERRUPT) > + return handle_external_interrupt(vcpu); > + else if (exit_reason == EXIT_REASON_HLT) > + return handle_halt(vcpu); > + else if (exit_reason == EXIT_REASON_PAUSE_INSTRUCTION) > + return handle_pause(vcpu); > + else if (exit_reason == EXIT_REASON_MSR_READ) > + return handle_rdmsr(vcpu); > + else if (exit_reason == EXIT_REASON_CPUID) > + return handle_cpuid(vcpu); > + else if (exit_reason == EXIT_REASON_EPT_MISCONFIG) > + return handle_ept_misconfig(vcpu); > +#endif This can be hoisted above the if statement. > return kvm_vmx_exit_handlers[exit_reason](vcpu); > - else { > + } else { > vcpu_unimpl(vcpu, "vmx: unexpected exit reason 0x%x\n", > exit_reason); > dump_vmcs();