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: 10244827 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 8F10660208 for ; Tue, 27 Feb 2018 11:34:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83ECC28833 for ; Tue, 27 Feb 2018 11:34:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7858628841; Tue, 27 Feb 2018 11:34: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=-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 D905E28833 for ; Tue, 27 Feb 2018 11:34:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752911AbeB0Leh (ORCPT ); Tue, 27 Feb 2018 06:34:37 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40289 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752012AbeB0Leg (ORCPT ); Tue, 27 Feb 2018 06:34:36 -0500 Received: by mail-wm0-f68.google.com with SMTP id t6so14820306wmt.5 for ; Tue, 27 Feb 2018 03:34:35 -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=ao2aKLAcmfIC5Q2ca7VPgZDZB+w8+KxS8ttZODl65apsglRc+lmZgh2ZKppFmKYwvV VX6TO6t1rP1zQ+cYRzJUBhmuDwBVUJc0iqUY3CmZdqVgwh6SYRWGXEQ62NqNMI7tWl44 VbHNd1zWeUwjeV7Gaw4XcT4QPuv5VvRy8RqZraM7P4PqEX8UY10cTpuOIbfRwDMwC43Y Kwj6eUe2JU90t6r0OMTN68tqUqc27SkvJ9BPR6Up8OBZyqw6wrwBUhKui15S6/mOMvHB 1708wx6U7oP4KsNyT78N9AZAfOEaN+RW4pqa3WkSflg+JCBXIAzTdreP6C4rmu0HwVIQ Xuug== X-Gm-Message-State: APf1xPDV+48yLwaUzA9PAUwW37/XpYzvEC4KidIJBFwxbgc9xGDTfwLn a/E5JH1xdSeUr8roefSSsrL4eA== 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 Cc: kvm@vger.kernel.org, Marc Zyngier , Andrew Jones , Shih-Wei Li , Dave Martin , Julien Grall , Tomasz Nowicki , Yury Norov 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> 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. 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; }