From patchwork Tue Feb 27 11:33:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10244909 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 54DBA60208 for ; Tue, 27 Feb 2018 11:36:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 476AB28833 for ; Tue, 27 Feb 2018 11:36:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B70C28845; Tue, 27 Feb 2018 11:36:41 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 91AD628833 for ; Tue, 27 Feb 2018 11:36:40 +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=AGtEh668qmJgUWBmhY4q7HfegvERetmNncLt90Q8BKI=; b=Ry6ORxxYpsEV/awxs3TjqmDkzT lw9erLMuAOW3wL5Vyr/EzvdZZ4n6f8V/bPFviAGdGxiXXIWBuTzKa/QYlNgIOSt1nfRzkFsdj7a2C RjjBSXzd8A0wecAj6xj8ri0dORocLbHhO6qNmHqB0yWinQxVGMw5Y8AYDclXSUmHP6XNfNUd1Vt1+ 0gp0e6VMojamNtlxt6Y5xaQEVrtg9Rw0tXJguOUEL+7qC54j1EVGnqTOxByZBKPVwnh9Z7GSPYA1I qJlEjc3HBXkY15CNsvFGP96Ioymxpr/7m0Xxu1/B0uine9HSrRBR+FUDhq6e6oLAR6ehsAktwe+VU HQyEhjkg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eqdYY-0000F2-Gb; Tue, 27 Feb 2018 11:36:26 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqdWv-0006Vi-JC for linux-arm-kernel@lists.infradead.org; Tue, 27 Feb 2018 11:34:51 +0000 Received: by mail-wm0-x243.google.com with SMTP id 188so22533818wme.1 for ; Tue, 27 Feb 2018 03:34:36 -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=N15gI1HiMvw/zI9ea12N3+LJKMPjAEmCg5rYvo0/nlU=; b=p8lHblneW/nKA3pN2tsDddgVVyRcFGeKO3WFcessuuil5D08LRXb8Tdw0Kg/XNgKJ9 C5xG4Tr5QPNlSwFyxp/KteZJC1jmBGXbGhXpmjUXEKh1WGWTqpG13hLrYjjq0Fl5b3dT 5r+ph75HGoKtYhLV1yQbbhZ8y19RJO1/duqT2OV60hsWx8/vaRkeFFFDgc6xsQRXE3SU hLIBybDjw+OtHoqJhBZaJl6C2Y2U2wEZD8rsKQ2MJ/KH5FaWrXRbk3Psjpaxc8aDaDJG 5nB3nkzF8H/nt4cbbZ1iOR8hPNYPlc2RdJbxBw272b9Ipa8VbJbC33rGrXi+nZacWY36 jm9Q== 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=N15gI1HiMvw/zI9ea12N3+LJKMPjAEmCg5rYvo0/nlU=; b=Fa55Yatpf/vroJPqx4gIzKqH0yBt08N5CjZH6AyY7DuVSZ4LL9un+eIUTx54Fw9o0A oGPWsrNR1+9ZeuGnqKimYefoiK0yYzjZbeNXU7M59alTJyLLhxlIAAithvwOXpV0vbJ7 fvK+WETwatdrgtkH8eo7ZIlevG4MJukFEVEWco7cZ4GDKOWXP5BprXqLdoPExgHjK/6y /wmFOTexcg0U3ZlplBrCZ5EFd6m+C4hr4FO+tL68WjFM/vS9BUuceiYN2QiZIRCmIwWT uPsbDlWWoYhwylEvoLK8tF6NeCO0QTi6Rz2uFYvd2/1nxE0eVs3aiFyoRv+Eq+iJ/usb n11A== X-Gm-Message-State: APf1xPDJPLVyFQ8QdWQXsRxOVIHPVNKjCD9LH3bCQ04OvW6EMi1WrOum +O9YfEIo/X63NIgRqLf9c9t8jg== X-Google-Smtp-Source: AH8x225rgpN3QY/AVOPkf+FSiXOe8SNH0vPtgD06SC9iWo+h1Wrp7MblFLFpR+S0AHuggI1T8P2sNw== X-Received: by 10.80.153.221 with SMTP id n29mr18839827edb.303.1519731274973; Tue, 27 Feb 2018 03:34:34 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id m1sm9176786ede.39.2018.02.27.03.34.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Feb 2018 03:34:33 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 02/40] KVM: arm/arm64: Move vcpu_load call after kvm_vcpu_first_run_init Date: Tue, 27 Feb 2018 12:33:51 +0100 Message-Id: <20180227113429.637-3-cdall@kernel.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180227113429.637-1-cdall@kernel.org> References: <20180227113429.637-1-cdall@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180227_033445_834795_2D123EB2 X-CRM114-Status: GOOD ( 15.54 ) 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: Andrew Jones , kvm@vger.kernel.org, Marc Zyngier , Tomasz Nowicki , Julien Grall , Yury Norov , Dave Martin , Shih-Wei Li 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. Reviewed-by: Julien Grall Reviewed-by: Marc Zyngier Signed-off-by: Christoffer Dall --- virt/kvm/arm/arch_timer.c | 4 ---- virt/kvm/arm/arm.c | 22 ++++++++-------------- virt/kvm/arm/vgic/vgic-init.c | 11 ----------- 3 files changed, 8 insertions(+), 29 deletions(-) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index f7278358f133..872e1fbd94dc 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -854,11 +854,7 @@ int kvm_timer_enable(struct kvm_vcpu *vcpu) return ret; no_vgic: - preempt_disable(); timer->enabled = 1; - kvm_timer_vcpu_load(vcpu); - preempt_enable(); - return 0; } diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index 53572304843b..932e61858c55 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -632,27 +632,22 @@ 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; + return ret; if (run->exit_reason == KVM_EXIT_MMIO) { ret = kvm_handle_mmio_return(vcpu, vcpu->run); if (ret) - goto out; - if (kvm_arm_handle_step_debug(vcpu, vcpu->run)) { - ret = 0; - goto out; - } - + return ret; + if (kvm_arm_handle_step_debug(vcpu, vcpu->run)) + return 0; } - if (run->immediate_exit) { - ret = -EINTR; - goto out; - } + if (run->immediate_exit) + return -EINTR; + + vcpu_load(vcpu); kvm_sigset_activate(vcpu); @@ -811,7 +806,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) kvm_sigset_deactivate(vcpu); -out: vcpu_put(vcpu); return ret; } diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c index 743ca5cb05ef..3e8209a07585 100644 --- a/virt/kvm/arm/vgic/vgic-init.c +++ b/virt/kvm/arm/vgic/vgic-init.c @@ -302,17 +302,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; }