From patchwork Mon Dec 4 20:35:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10091487 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 2365360327 for ; Mon, 4 Dec 2017 20:36:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16FCB290AA for ; Mon, 4 Dec 2017 20:36:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BACA293F1; Mon, 4 Dec 2017 20:36:56 +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 A1D2D290AA for ; Mon, 4 Dec 2017 20:36:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752648AbdLDUgf (ORCPT ); Mon, 4 Dec 2017 15:36:35 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:39105 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752691AbdLDUgM (ORCPT ); Mon, 4 Dec 2017 15:36:12 -0500 Received: by mail-wm0-f67.google.com with SMTP id i11so16609854wmf.4 for ; Mon, 04 Dec 2017 12:36:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=christofferdall-dk.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=w7+JCGDxXqRgNaEBotBwTBmOyxryFF6QgFJkBNxEQw0=; b=h/dh5LaopPGXmYs8XtM+73ZeJb3p91UMamvk5JbgHsFslqpln0UfNl/vuiKODM0zsP w4M1VXrPaRGL9EMjKTVhwwgeDSnuK0+2MDNndtzx/DoM6fwdW6MwGi28TdlqEdWtDpJ8 WdaPwDZR3L3o90CCMf3CsJmWIZ0lmyoVVpdEmDP1s3EuVstFweGq3vxDtgL48JXHZ6iO W0P3DJ98RAgk0oTvfbv5S2Dz+aI8vohuuMatIgOjn0q+Z5p/LvFvfMlTcNcKF4i/ZEod NNN14AvyYEvalrE0zfeLoL5kIUOOjC2mii7aYAQ5vm9dsljj3gSg+7XyNJPrG0tv5g/v qt9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=w7+JCGDxXqRgNaEBotBwTBmOyxryFF6QgFJkBNxEQw0=; b=eA0Zozd1VwLKRkzbboKgHsn/OvsGKY9Qysxhp/CyjEuDRwCiobKaXN2LiDNPX7RLCY gDxF47lDQSHaBVmZ5rBMZdh38Owuf5xhOAZj6CnTBp76v+l1XzXpqK9GqCCldOw4823S FohC2DuluxufI3c2qkPNjtKqniC3cXufWEC5FnBWNfFK3JQm2/psOuGYGwdLGGD4yx2t 7ksuMURkHrqyG2bV384RQ+l0oGMnU6s31I3bG0+lwwafSXVYeM/+d7fS8aSi7GZza5tb HXY9eenTLOCtK6BcJ1mssxhSIyR+ScJzAOL91W7Uv2+ElBW4IYzQC9zDtL3ii+U/6vLc afhQ== X-Gm-Message-State: AJaThX7fEdBilQh6LbGUj9+uEBx7C8DQzqCJ0OySVm0rxyHRfwZjR+tD v0Izv/Y2PC2v+MJ//VZJY0inRu3BxJNd/w== X-Google-Smtp-Source: AGs4zMZ6Y4WDcT4SznLIfPz97t6CterTEhftdBUtiB25cG0lA6iTH2+99q2DmJh3M7dXw2PkpRJuwQ== X-Received: by 10.80.137.244 with SMTP id h49mr32741666edh.303.1512419771048; Mon, 04 Dec 2017 12:36:11 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id k42sm8434943edb.94.2017.12.04.12.36.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 12:36:10 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Cc: Andrew Jones , Christoffer Dall , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Marc Zyngier , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, James Hogan , linux-mips@linux-mips.org, Paul Mackerras , kvm-ppc@vger.kernel.org, Christian Borntraeger , Cornelia Huck , linux-s390@vger.kernel.org Subject: [PATCH v3 16/16] KVM: arm/arm64: Move vcpu_load call after kvm_vcpu_first_run_init Date: Mon, 4 Dec 2017 21:35:38 +0100 Message-Id: <20171204203538.8370-17-cdall@kernel.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171204203538.8370-1-cdall@kernel.org> References: <20171204203538.8370-1-cdall@kernel.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christoffer Dall Moving the call to vcpu_load() in kvm_arch_vcpu_ioctl_run() to after we've called kvm_vcpu_first_run_init() simplifies some of the vgic and there is also no need to do vcpu_load() for things such as handling the immediate_exit flag. Signed-off-by: Christoffer Dall --- virt/kvm/arm/arch_timer.c | 4 ---- virt/kvm/arm/arm.c | 12 +++++------- virt/kvm/arm/vgic/vgic-init.c | 11 ----------- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 4151250ce8da..801fecfee299 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -839,11 +839,7 @@ int kvm_timer_enable(struct kvm_vcpu *vcpu) return ret; no_vgic: - preempt_disable(); timer->enabled = 1; - kvm_timer_vcpu_load_vgic(vcpu); - preempt_enable(); - return 0; } diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index a760ef1803be..991f1aa70fb9 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -622,8 +622,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) if (unlikely(!kvm_vcpu_initialized(vcpu))) return -ENOEXEC; - vcpu_load(vcpu); - ret = kvm_vcpu_first_run_init(vcpu); if (ret) goto out; @@ -631,13 +629,13 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) if (run->exit_reason == KVM_EXIT_MMIO) { ret = kvm_handle_mmio_return(vcpu, vcpu->run); if (ret) - goto out; + return ret; } - if (run->immediate_exit) { - ret = -EINTR; - goto out; - } + if (run->immediate_exit) + return -EINTR; + + vcpu_load(vcpu); if (vcpu->sigset_active) sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c index 62310122ee78..a0688ef52ad7 100644 --- a/virt/kvm/arm/vgic/vgic-init.c +++ b/virt/kvm/arm/vgic/vgic-init.c @@ -300,17 +300,6 @@ int vgic_init(struct kvm *kvm) dist->initialized = true; - /* - * If we're initializing GICv2 on-demand when first running the VCPU - * then we need to load the VGIC state onto the CPU. We can detect - * this easily by checking if we are in between vcpu_load and vcpu_put - * when we just initialized the VGIC. - */ - preempt_disable(); - vcpu = kvm_arm_get_running_vcpu(); - if (vcpu) - kvm_vgic_load(vcpu); - preempt_enable(); out: return ret; }