Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp2468849ybj; Mon, 23 Sep 2019 04:29:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6iKI3qnHBTdWsFTMGOGmrtlqJIMDwsFBrXse6oJFXaqhP2edumyUZ8r1g5HOg5qPQEoHk X-Received: by 2002:a17:906:7fda:: with SMTP id r26mr22422742ejs.170.1569238156505; Mon, 23 Sep 2019 04:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569238156; cv=none; d=google.com; s=arc-20160816; b=WM73QcGOfktA9F2wmdu9d4kh5BIh9hZVUsKTY1LeCOLZmBD8nPOWTeR7F1sTbU9Ux5 P2XsVes4I9yR6Wv6Tmj4+7x5yIx2rWtSJ4Ue3YdLkD2pObdEoCCVN/o3WN11L3yeiYZh bFZUJemPUI0cLgv5l2xGrcMIpJe2C6cQwDZ2ldCRqgZB2yaoKiOEEbCxKeFrxnrd2ZL8 bQ4ChjYBA3ZQVwHJODPeIODWnjhM84KsPwdM3cUkFgpY8JBADFyEcDAYlgOrC2OignS0 scVVHSI4jDY7KGEnzwpOJ+km7aWq+PYGtmtdJmRDtoqC8Wdjocx7KvA501r3GmgV+utS paaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=tq/cRPPgGd2IJZF1YyrmDcQmNppTzqEHJFuVmtjtmfg=; b=HO1DTgI9sQPo3QfSN7eVFDIs5u/WoeHUaYGOhVcMkSxEy7WWW0qXf+7QuEOPTawadG Sjheh6H8cN3ek7qbqx2J7WFYaN0Z4Ov+Gi7ynBhuDAR26Qd3rGhQxGDZIcgFOBcRDMNz 8V3LOOEEVA6oOESvACKZQj3Mvs/lJfPD+QRCsfScbt2H7MY9x7zD4kMjJSLEZn+sDmDR lwQk3Ze6r64fRo3Cu7anbpKAXiPKR7Y75MdRnf87nufqYXw4rbUGSM2KVeFs7dUr2Is8 Ofy9FwDLGXJXDpaX94szgrl943dixAaVMaE/F3SE3w762ny6gd9c33iA6U4zr8WPeY9n dAEQ== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17si6381723edp.400.2019.09.23.04.28.52; Mon, 23 Sep 2019 04:29:16 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393887AbfITVZX (ORCPT + 99 others); Fri, 20 Sep 2019 17:25:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50848 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393804AbfITVZQ (ORCPT ); Fri, 20 Sep 2019 17:25:16 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 075EF3082A6C; Fri, 20 Sep 2019 21:25:16 +0000 (UTC) Received: from mail (ovpn-120-159.rdu2.redhat.com [10.10.120.159]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC83C5F7D5; Fri, 20 Sep 2019 21:25:13 +0000 (UTC) From: Andrea Arcangeli To: Paolo Bonzini Cc: Vitaly Kuznetsov , "Dr. David Alan Gilbert" , Marcelo Tosatti , Peter Xu , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/17] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers Date: Fri, 20 Sep 2019 17:25:07 -0400 Message-Id: <20190920212509.2578-16-aarcange@redhat.com> In-Reply-To: <20190920212509.2578-1-aarcange@redhat.com> References: <20190920212509.2578-1-aarcange@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 20 Sep 2019 21:25:16 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 + 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 return kvm_vmx_exit_handlers[exit_reason](vcpu); - else { + } else { vcpu_unimpl(vcpu, "vmx: unexpected exit reason 0x%x\n", exit_reason); dump_vmcs();