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: 10091651 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 E1AEF6035E for ; Mon, 4 Dec 2017 21:34:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D167C28161 for ; Mon, 4 Dec 2017 21:34:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C54B428249; Mon, 4 Dec 2017 21:34:44 +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 70F5528161 for ; Mon, 4 Dec 2017 21:34:44 +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=V/fPCgzgBzf7QOHaGE529o+2XmtR/5LMVSxwln/xeFI=; b=X9I67sJqR6f3sKWs//dLybGMkw 5/5b4wNFhwxTY/fQkyd1M6BwzPXdHGrk0+ieEEVCjuYAHvD482Lnl6WmjrR+fXkm9gmy4q9/PVxxE S0+bTURw8AUPpwgMzb8jiOapAYD7j9Iv3jTncgzX3EFckOyucwp3Z0wpqbFahaSiu4Lh7bWp5uJgO 5j1/VgMxMFK57CbO9m9VVwNaORDp87x+fWNg1gSzpB9NLXlpaiCctQsR/0TxR6jNd17HPDGTBcyEI ZmQB5YnRIVbVxRdGQAj6xChR+Pb/tqsdkHKbHFHVntTUH0t8AcwMtgCCD4ot0hIECYPiE4UC1HWaC sfsuXl9g==; 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 1eLyNi-0001QT-Mx; Mon, 04 Dec 2017 21:34:30 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eLyNg-0001QJ-Ia for linux-arm-kernel@bombadil.infradead.org; Mon, 04 Dec 2017 21:34:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=w7+JCGDxXqRgNaEBotBwTBmOyxryFF6QgFJkBNxEQw0=; b=xIgJef3fo0X5JFJn7VHW2I0fz JDwg1nVBdQs+YERDJMvHKS4S+U6RCZ50Qoe5U+NfCuPR3EJljqUoBNHeSx1H8YBgAqXE1aAApAl31 PUj/6nzRS87kcLDOqu86MWzUtK4say9Kk5LICldTB5FO6YoSVtm8j7Y2e0bManodqNohTbDvIkJXb iWq3K5DUo+KW5C/GNxDtoFD1sKrfBaWDyIkjGBocxlE1sIueiwjJi/HjpwCBx7hFHAD7anqxFvrO/ eBqghfV+ZcL+mC7sRDywDvGVOB7oZ1dAIdVJLB5PNro7+K/1Gprp/0AbP39WIoDg0JzSFRaEyqhXz 4Wd3j48Ew==; Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eLxTg-0006Fy-2V for linux-arm-kernel@lists.infradead.org; Mon, 04 Dec 2017 20:36:37 +0000 Received: by mail-wm0-x243.google.com with SMTP id b76so16708333wmg.1 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=DlanPKKW1OFltZb4nMCCasPxJp/wNwmgu2t8oSkOrBlASKxJkCTADBym5XjA2H0yLu TKpjnrPPbFR5ezvi/P2QcMvdKf/lXvcOyapM7HxKRdi8OBeENr8VGUZrw7oEgNgpBcUb Xk3Q3/KlbvGM7MXUV6eE+Xptdbu0R37voZqFYR9TttJ023Buwc0SkRWKWVyaazHFNp21 mR/HBw4YLMiGrPlt8ZQbwsSTpY9EC92WPbTTkXn5V3HCTdeIyBUtimwIDXhn12bBAIEH 1YUqrvTij7uaygZNw1zjEgfBcrmMSH+TILdZlzJ/QTWPpHgMNjcokQ/Hvev4pztqWoRK 7OcQ== X-Gm-Message-State: AJaThX7p4fVAJKFsmD+ByDbnIJcEk2DlAff5X7Wkd26+96bz+MRipXRY lPvTW/IPSPmf+REObxoYDiaRfQ== 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 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> 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 , kvm-ppc@vger.kernel.org, Paul Mackerras , Christian Borntraeger , 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 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; }