From patchwork Wed Nov 29 16:41:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10082843 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 CA40A60353 for ; Wed, 29 Nov 2017 16:49:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2A3629B5B for ; Wed, 29 Nov 2017 16:49:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6E0029B7B; Wed, 29 Nov 2017 16:49:47 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 35A9529B5B for ; Wed, 29 Nov 2017 16:49:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=jL5zRu9PdR50XPDnr4KIpWgBc7YD7DKgB/uY4qsow1M=; b=q5omPqELvKhlLgXlbrHJTVWJBL 6C3vAct08da1ccqAKftVQwug53lMAoWWJNWy5fUwwNqKpQYaRHgCoOqjw7kgcbOt3El6Pypu2v+03 N+BXtlEVIuoRWiJVFVq7H0ISvexb8DBJ3GENX1XnxoZnrhmnv7dqnZKT5NzCQ4HWUiTHzcsDRkQhc Vq2EFhNgUjU1a/1yqENDMK7Ihmomh7t/jW5Rag43J3WW7o9+ABs8TiN3ITon3P2/cEstiGr9U6dbK IauPlYLP1+qdVHn81BhVZGSM8nEuAgS6lD7nPV3OTYnKUMxVf54661Ps+gEgFH/g93zae6zbvuGHx 4WGvgitA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eK5YP-0006L0-M4; Wed, 29 Nov 2017 16:49:45 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eK5XF-0003nP-8Z for linux-arm-kernel@bombadil.infradead.org; Wed, 29 Nov 2017 16:48:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ywQGXelM8cu9WcC20/xaCoB0QEIpo4uOC6enEQqIrU0=; b=KPFbH8xvF32gborhW6Fx92SUi l+F1uz/HZ175YTLaJhDelK4lfz3DSFJ70txPj65ENbGTC2G3NqV2k+Z8H3agceidX7T512UiPXOJ/ s5YFXA/UR+nlFKZ5fsxgj6UQQ/GVMPCO8lysNN/s4qYuKILx/F7G8dQ0+i6lv7YtbPI28jpI9IeuG fhxWl17hMriCHCgju8hD/oxzbEKeJ2NmFN8CGbmvvXN3iF3YRtHGNoebPOUnhZsEzHUUJYi182Zxh D9CnKZiyB0byB6/OLx2XatSJwAAf3dpeUWN6b2DcSKqEf+YE4i+1Nx7FN9J0WOuZKXcxiS42iLztG +3BogvrJw==; Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eK5R2-0004mE-BM for linux-arm-kernel@lists.infradead.org; Wed, 29 Nov 2017 16:42:10 +0000 Received: by mail-wr0-x242.google.com with SMTP id o2so3973756wro.5 for ; Wed, 29 Nov 2017 08:41:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ywQGXelM8cu9WcC20/xaCoB0QEIpo4uOC6enEQqIrU0=; b=a46of1KFRDfoN3tKWCkfzVWqob4qwyDPBDZMQ0V6qsJ+duLP2hjxH9qJYltIiFVKJx VCX3ca0rP3RuXcJh4kWRqwNTZoQ5rX/jt8nupGtwrwIHPwEmLVIkh5w6GaYCJfq0EZeg w1rFQkRT7C8dKatXmv0kLbhE3IrhAxZ1is9Rs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ywQGXelM8cu9WcC20/xaCoB0QEIpo4uOC6enEQqIrU0=; b=lVmhDb1YM/az5bW9rDSBEWgoRcXy+pyYLc15l7PnPyENCWXVQxkjhnhu6Dy30Oj3F+ onqS+WviahRFBzcQvnLEEP6KKFvUFsf67OYsM89lpFKT0s09fw+hfJrTh3qCiuTBc9zs 6nxbcnNAaJSi3MqxUDT0FtfJOoJH9b63GWVUpMxPEi1JJOAhksv5MFXL/PYzHI29dtDP xEyy3m97am7EoYTXLO1TqC4Ht44hXeRdgxmfKWIpaAwhXUv8U4vPVd2xva/5gRw+uYJZ EFLYQdyS8LAyRoNjjwWnXj4J/AtC+O7UpX9zb1+1+dVwsjIuXkSZc8GnazBtuXi+eNer w+QQ== X-Gm-Message-State: AJaThX7yf7s1GwGOWwGbHfZmc9FGGHAwt/iWKmCGPuNDlenFa5Nbr51q j/sLivrpLRE1iWuW+FoSCnPr6g== X-Google-Smtp-Source: AGs4zMbgzH+o10zXeL/u60y+96rKQY/kNlgPwPnfc03K9+M9GKzprVWFjViGTeJHZTf0jJSvj52d3g== X-Received: by 10.223.138.182 with SMTP id y51mr3255350wry.273.1511973706566; Wed, 29 Nov 2017 08:41:46 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id e71sm2080765wma.13.2017.11.29.08.41.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Nov 2017 08:41:45 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Subject: [PATCH v2 16/16] KVM: arm/arm64: Move vcpu_load call after kvm_vcpu_first_run_init Date: Wed, 29 Nov 2017 17:41:16 +0100 Message-Id: <20171129164116.16167-17-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171129164116.16167-1-christoffer.dall@linaro.org> References: <20171129164116.16167-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171129_164208_403196_254EE0C6 X-CRM114-Status: GOOD ( 16.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mips@linux-mips.org, Andrew Jones , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Marc Zyngier , James Hogan , Cornelia Huck , Christian Borntraeger , kvm-ppc@vger.kernel.org, Alexander Graf , linux-arm-kernel@lists.infradead.org, Paolo Bonzini , linux-s390@vger.kernel.org, kvmarm@lists.cs.columbia.edu, Christoffer Dall MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 4151250..801fecf 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 a760ef1..991f1aa 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 6231012..a0688ef 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; }