From patchwork Tue Nov 29 20:40:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Huey X-Patchwork-Id: 9453103 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 030886071E for ; Tue, 29 Nov 2016 20:41:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E652B2837F for ; Tue, 29 Nov 2016 20:41:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D919A2832C; Tue, 29 Nov 2016 20:41:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74F612832C for ; Tue, 29 Nov 2016 20:41:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757222AbcK2UlL (ORCPT ); Tue, 29 Nov 2016 15:41:11 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33401 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754298AbcK2Uk4 (ORCPT ); Tue, 29 Nov 2016 15:40:56 -0500 Received: by mail-pg0-f68.google.com with SMTP id 3so17380947pgd.0 for ; Tue, 29 Nov 2016 12:40:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kylehuey.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3iMKIqIuHvLYNST/EKsP1fcOqgEFUHo1zwT0AZFrKXM=; b=dAdthE9DfGOuWI4j6nl8iS23ee9Yj0HeuWozuWPWlLnwdRJfUs4JHb4BWWN7ac9ffj pfJ9PqErIrCxu3uAt6InixfY4jF88djqF2QzbclWvubZZj2fEIawCW0ny4Fj26Amkdaz EDye0STXjZ4VGIanmYMe/086vafYLou7VKw8JOY5uamfyFol7souPnl2LdJopFhxYPzW 6/VQUeYQz/YzlI99Q0LX4RXpEoSjrmlVjk+D8rQ6VQkOCjwfcV5lpQXJSC83iw7cFrPn R/WYEfWhemR04pCNNJtkd9j90+mBV3/fp2R4fHLzRVBNGIDSVljGn6Q4lb3P94rJeBHE Sy5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3iMKIqIuHvLYNST/EKsP1fcOqgEFUHo1zwT0AZFrKXM=; b=H7nroHDDtOdgkvp4HUo5l/jQHoBcY5EHsLny63PdpS4hIkhRt1cWIqPBSxH8q2b8r8 2yIBwzs9HowMTddwX/nRgqiqsBlwNY4d9bdKggfHAkcEG/Ax3ITH1C1Dk3PlvXJJ+KDH J4PUP/dpbgb5b6t7g86ln1I0NcCu3lR9r2JRtQmPtg+04vEUgZzjPzm48mehfIsgpA/s 8w46C+LJKUpzaMoH9GQsWdl9N7/nllb0ppp023rtbjVTPDuIHMN7XHEQidwy78Q+5QtA Ggj624F5lAAfiGwBY89z5JTwgcypYGkV9p8cBQm6cc/IEBwYeuAXQGrqHP5lH/wBBM60 t8KA== X-Gm-Message-State: AKaTC03HEJzjppPws35J+Hup77402SG/FYS8IKa8jZxajgb8TJuoWtAy1I+qXqy6mlbvZw== X-Received: by 10.98.54.68 with SMTP id d65mr29647006pfa.61.1480452050629; Tue, 29 Nov 2016 12:40:50 -0800 (PST) Received: from minbar.hsd1.ca.comcast.net (c-73-162-102-141.hsd1.ca.comcast.net. [73.162.102.141]) by smtp.gmail.com with ESMTPSA id p1sm42269642pgc.29.2016.11.29.12.40.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Nov 2016 12:40:50 -0800 (PST) From: Kyle Huey X-Google-Original-From: Kyle Huey To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Joerg Roedel Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/5] KVM: VMX: Reorder some skip_emulated_instruction calls Date: Tue, 29 Nov 2016 12:40:38 -0800 Message-Id: <20161129204041.8839-3-khuey@kylehuey.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161129204041.8839-1-khuey@kylehuey.com> References: <20161129204041.8839-1-khuey@kylehuey.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The functions being moved ahead of skip_emulated_instruction here don't need updated IPs, and skipping the emulated instruction at the end will make it easier to return its value. Signed-off-by: Kyle Huey --- arch/x86/kvm/vmx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index e4af9699..f2f9cf5 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -5703,18 +5703,18 @@ static int handle_cr(struct kvm_vcpu *vcpu) vcpu->run->exit_reason = KVM_EXIT_SET_TPR; return 0; } } break; case 2: /* clts */ handle_clts(vcpu); trace_kvm_cr_write(0, kvm_read_cr0(vcpu)); - skip_emulated_instruction(vcpu); vmx_fpu_activate(vcpu); + skip_emulated_instruction(vcpu); return 1; case 1: /*mov from cr*/ switch (cr) { case 3: val = kvm_read_cr3(vcpu); kvm_register_write(vcpu, reg, val); trace_kvm_cr_read(cr, val); skip_emulated_instruction(vcpu); @@ -6128,18 +6128,18 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu) static int handle_ept_misconfig(struct kvm_vcpu *vcpu) { int ret; gpa_t gpa; gpa = vmcs_read64(GUEST_PHYSICAL_ADDRESS); if (!kvm_io_bus_write(vcpu, KVM_FAST_MMIO_BUS, gpa, 0, NULL)) { - skip_emulated_instruction(vcpu); trace_kvm_fast_mmio(gpa); + skip_emulated_instruction(vcpu); return 1; } ret = handle_mmio_page_fault(vcpu, gpa, true); if (likely(ret == RET_MMIO_PF_EMULATE)) return x86_emulate_instruction(vcpu, gpa, 0, NULL, 0) == EMULATE_DONE; @@ -6502,18 +6502,18 @@ static __exit void hardware_unsetup(void) * Indicate a busy-waiting vcpu in spinlock. We do not enable the PAUSE * exiting, so only get here on cpu with PAUSE-Loop-Exiting. */ static int handle_pause(struct kvm_vcpu *vcpu) { if (ple_gap) grow_ple_window(vcpu); - skip_emulated_instruction(vcpu); kvm_vcpu_on_spin(vcpu); + skip_emulated_instruction(vcpu); return 1; } static int handle_nop(struct kvm_vcpu *vcpu) { skip_emulated_instruction(vcpu); return 1; @@ -6957,18 +6957,18 @@ static int handle_vmon(struct kvm_vcpu *vcpu) vmx->nested.vmcs02_num = 0; hrtimer_init(&vmx->nested.preemption_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED); vmx->nested.preemption_timer.function = vmx_preemption_timer_fn; vmx->nested.vmxon = true; - skip_emulated_instruction(vcpu); nested_vmx_succeed(vcpu); + skip_emulated_instruction(vcpu); return 1; out_shadow_vmcs: kfree(vmx->nested.cached_vmcs12); out_cached_vmcs12: free_page((unsigned long)vmx->nested.msr_bitmap); @@ -7078,18 +7078,18 @@ static void free_nested(struct vcpu_vmx *vmx) } /* Emulate the VMXOFF instruction */ static int handle_vmoff(struct kvm_vcpu *vcpu) { if (!nested_vmx_check_permission(vcpu)) return 1; free_nested(to_vmx(vcpu)); - skip_emulated_instruction(vcpu); nested_vmx_succeed(vcpu); + skip_emulated_instruction(vcpu); return 1; } /* Emulate the VMCLEAR instruction */ static int handle_vmclear(struct kvm_vcpu *vcpu) { struct vcpu_vmx *vmx = to_vmx(vcpu); gpa_t vmptr; @@ -7119,18 +7119,18 @@ static int handle_vmclear(struct kvm_vcpu *vcpu) } vmcs12 = kmap(page); vmcs12->launch_state = 0; kunmap(page); nested_release_page(page); nested_free_vmcs02(vmx, vmptr); - skip_emulated_instruction(vcpu); nested_vmx_succeed(vcpu); + skip_emulated_instruction(vcpu); return 1; } static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch); /* Emulate the VMLAUNCH instruction */ static int handle_vmlaunch(struct kvm_vcpu *vcpu) {