From patchwork Mon Jul 9 17:05:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 1174171 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 0461440B30 for ; Mon, 9 Jul 2012 17:06:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752620Ab2GIRGD (ORCPT ); Mon, 9 Jul 2012 13:06:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27992 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752480Ab2GIRGB (ORCPT ); Mon, 9 Jul 2012 13:06:01 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q69H60WM019378 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 9 Jul 2012 13:06:00 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q69H5mDK016692; Mon, 9 Jul 2012 13:05:59 -0400 From: Avi Kivity To: Marcelo Tosatti Cc: kvm@vger.kernel.org Subject: [PATCH v3 6/6] KVM: Clean up vcpu->requests == 0 processing Date: Mon, 9 Jul 2012 20:05:45 +0300 Message-Id: <1341853545-3023-7-git-send-email-avi@redhat.com> In-Reply-To: <1341853545-3023-1-git-send-email-avi@redhat.com> References: <1341853545-3023-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org A previous patch introduced a goto to make the patch clearer. This patch cleans up the code but has no functionality changes. Signed-off-by: Avi Kivity --- arch/x86/kvm/x86.c | 148 ++++++++++++++++++++++++++--------------------------- 1 file changed, 72 insertions(+), 76 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 9296dce..44a2c87 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5226,86 +5226,82 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) if (unlikely(req_int_win)) kvm_make_request(KVM_REQ_EVENT, vcpu); - if (!vcpu->requests) - goto no_requests; - - for_each_set_bit(req, &vcpu->requests, BITS_PER_LONG) { - clear_bit(req, &vcpu->requests); - switch (req) { - case KVM_REQ_MMU_RELOAD: - kvm_mmu_unload(vcpu); - r = kvm_mmu_reload(vcpu); - if (unlikely(r)) { - kvm_make_request(KVM_REQ_MMU_RELOAD, vcpu); + if (vcpu->requests) + for_each_set_bit(req, &vcpu->requests, BITS_PER_LONG) { + clear_bit(req, &vcpu->requests); + switch (req) { + case KVM_REQ_MMU_RELOAD: + kvm_mmu_unload(vcpu); + r = kvm_mmu_reload(vcpu); + if (unlikely(r)) { + kvm_make_request(KVM_REQ_MMU_RELOAD, vcpu); + goto out; + } + break; + case KVM_REQ_MIGRATE_TIMER: + __kvm_migrate_timers(vcpu); + break; + case KVM_REQ_CLOCK_UPDATE: + r = kvm_guest_time_update(vcpu); + if (unlikely(r)) + goto out; + break; + case KVM_REQ_MMU_SYNC: + kvm_mmu_sync_roots(vcpu); + break; + case KVM_REQ_TLB_FLUSH: + kvm_x86_ops->tlb_flush(vcpu); + break; + case KVM_REQ_REPORT_TPR_ACCESS: + vcpu->run->exit_reason = KVM_EXIT_TPR_ACCESS; + r = 0; goto out; - } - break; - case KVM_REQ_MIGRATE_TIMER: - __kvm_migrate_timers(vcpu); - break; - case KVM_REQ_CLOCK_UPDATE: - r = kvm_guest_time_update(vcpu); - if (unlikely(r)) + case KVM_REQ_TRIPLE_FAULT: + vcpu->run->exit_reason = KVM_EXIT_SHUTDOWN; + r = 0; goto out; - break; - case KVM_REQ_MMU_SYNC: - kvm_mmu_sync_roots(vcpu); - break; - case KVM_REQ_TLB_FLUSH: - kvm_x86_ops->tlb_flush(vcpu); - break; - case KVM_REQ_REPORT_TPR_ACCESS: - vcpu->run->exit_reason = KVM_EXIT_TPR_ACCESS; - r = 0; - goto out; - case KVM_REQ_TRIPLE_FAULT: - vcpu->run->exit_reason = KVM_EXIT_SHUTDOWN; - r = 0; - goto out; - case KVM_REQ_DEACTIVATE_FPU: - vcpu->fpu_active = 0; - kvm_x86_ops->fpu_deactivate(vcpu); - break; - case KVM_REQ_APF_HALT: - /* Page is swapped out. Do synthetic halt */ - vcpu->arch.apf.halted = true; - r = 1; - goto out; - case KVM_REQ_STEAL_UPDATE: - record_steal_time(vcpu); - break; - case KVM_REQ_NMI: - process_nmi(vcpu); - break; - case KVM_REQ_IMMEDIATE_EXIT: - req_immediate_exit = true; - break; - case KVM_REQ_PMU: - kvm_handle_pmu_event(vcpu); - break; - case KVM_REQ_PMI: - kvm_deliver_pmi(vcpu); - break; - case KVM_REQ_EVENT: - inject_pending_event(vcpu); - - /* enable NMI/IRQ window open exits if needed */ - if (vcpu->arch.nmi_pending) - kvm_x86_ops->enable_nmi_window(vcpu); - else if (kvm_cpu_has_interrupt(vcpu) || req_int_win) - kvm_x86_ops->enable_irq_window(vcpu); - - if (kvm_lapic_enabled(vcpu)) { - update_cr8_intercept(vcpu); - kvm_lapic_sync_to_vapic(vcpu); + case KVM_REQ_DEACTIVATE_FPU: + vcpu->fpu_active = 0; + kvm_x86_ops->fpu_deactivate(vcpu); + break; + case KVM_REQ_APF_HALT: + /* Page is swapped out. Do synthetic halt */ + vcpu->arch.apf.halted = true; + r = 1; + goto out; + case KVM_REQ_STEAL_UPDATE: + record_steal_time(vcpu); + break; + case KVM_REQ_NMI: + process_nmi(vcpu); + break; + case KVM_REQ_IMMEDIATE_EXIT: + req_immediate_exit = true; + break; + case KVM_REQ_PMU: + kvm_handle_pmu_event(vcpu); + break; + case KVM_REQ_PMI: + kvm_deliver_pmi(vcpu); + break; + case KVM_REQ_EVENT: + inject_pending_event(vcpu); + + /* enable NMI/IRQ window open exits if needed */ + if (vcpu->arch.nmi_pending) + kvm_x86_ops->enable_nmi_window(vcpu); + else if (kvm_cpu_has_interrupt(vcpu) || req_int_win) + kvm_x86_ops->enable_irq_window(vcpu); + + if (kvm_lapic_enabled(vcpu)) { + update_cr8_intercept(vcpu); + kvm_lapic_sync_to_vapic(vcpu); + } + break; + default: + BUG(); } - break; - default: - BUG(); } - } - -no_requests: preempt_disable();