linux-mips
[Top] [All Lists]

[PATCH v3 16/16] KVM: arm/arm64: Move vcpu_load call after kvm_vcpu_firs

To: kvm@vger.kernel.org
Subject: [PATCH v3 16/16] KVM: arm/arm64: Move vcpu_load call after kvm_vcpu_first_run_init
From: Christoffer Dall <cdall@kernel.org>
Date: Mon, 4 Dec 2017 21:35:38 +0100
Cc: Andrew Jones <drjones@redhat.com>, Christoffer Dall <christoffer.dall@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Radim Krčmář <rkrcmar@redhat.com>, Marc Zyngier <marc.zyngier@arm.com>, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, James Hogan <jhogan@kernel.org>, linux-mips@linux-mips.org, Paul Mackerras <paulus@ozlabs.org>, kvm-ppc@vger.kernel.org, Christian Borntraeger <borntraeger@de.ibm.com>, Cornelia Huck <cohuck@redhat.com>, linux-s390@vger.kernel.org
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==
In-reply-to: <20171204203538.8370-1-cdall@kernel.org>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20171204203538.8370-1-cdall@kernel.org>
Sender: linux-mips-bounce@linux-mips.org
From: Christoffer Dall <christoffer.dall@linaro.org>

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 <christoffer.dall@linaro.org>
---
 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;
 }
-- 
2.14.2


<Prev in Thread] Current Thread [Next in Thread>