From patchwork Fri Jan 12 12:07:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10160421 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 565CF602D8 for ; Fri, 12 Jan 2018 12:08:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38C5D28870 for ; Fri, 12 Jan 2018 12:08:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D84B289CD; Fri, 12 Jan 2018 12:08: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=-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 CBDED289C6 for ; Fri, 12 Jan 2018 12:08: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=DBj3MnqvUJpx6VIiJSZv98JqXL60FcCoseeMvBBrcJU=; b=nAJRiwY00ch5j4Zszk00JOAbMz 63sLVf+u9DAYxGrqrUr5vYjTHhy7iigYkK+U6CnoNPlQ+G+NiVjR3CVuR7bFhkmAUEz4EsspEOMNc uehv1/sLUc/fyXq5/vcJxRvLR2zlKJBUtwWO5vRhLcxF5EnR0tIYVk0iihyqTupyFiTWbH7EaQZgU 64QkysJTfJJta4vjxLgoCx9LrFkEALDVsmLCNtBW4nrm3+v4IAl1liBn31On/GYY6hCvDsZB2FsKX /k+nnbqEV656BB0aKUlmK8CHXGdr87ii6EDR/YRFfGAkOSpjIA6Q6K/Ds6WNuPxpklw2aPa/dk75a 9vHVURPA==; 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 1eZy8U-0000pR-5n; Fri, 12 Jan 2018 12:08:38 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZy7y-0008GT-CB for linux-arm-kernel@lists.infradead.org; Fri, 12 Jan 2018 12:08:08 +0000 Received: by mail-wm0-x244.google.com with SMTP id 141so11311611wme.3 for ; Fri, 12 Jan 2018 04:07:55 -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=S9+p/CvzAotTSBv3RfhdGtWSEYEtzEXarDZnBAfS0e4=; b=ZgfTGKDhp8sN0ENAMqZGedHv99FSWpAgHSmsQkj32BssgADOMITTzLtmeh4TPmLqqb dHvTAvZpgJ/Dan1WkyE+kA2Czv4rMEN2YnGz6NYZQaJ9yDr2vdWpVpETunfeFBrus/uV vGOoYUPSUIVTmB005sqTJczhTu9WbfsJwdoJg= 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=S9+p/CvzAotTSBv3RfhdGtWSEYEtzEXarDZnBAfS0e4=; b=l6dRyX9aJGvRzQJh1k0nUTA2DDk+pF0AHmhAfwVpQybxfFbEI1doGQ3IkqRzYFA3PC YHp+i5MTb500zcpyMUL06caTJxCHi4QBadjgFUu6j3vb6Xt/oV2kjl5V8fC5kuH244xr 0YWsvwuxwjPd9dLLsJ8V5UqcGFzVoJPYuzwRmPaJ8DIWnH8wm4GLCcexshC6JqkdvIXS R+CzV1sAMEwdGHItGadVzfxpNbJv/vyPjqYVMfbI7neQYJTIs5MpLUQiJ8GXMii+gIrH OK/UFhnBnaP8uWCHXP52hkhT+L18WXlytkUzXXipCkLYM84/kr0UakjcMh46xHPA4kW4 yKfg== X-Gm-Message-State: AKwxytcGxth6ECPPOIykT0NQO08Vf5ghaz/OBK28hWdrTn0qBlLf+0A+ 9mJcBQtsADA24HwJA7gwuR9r9Q== X-Google-Smtp-Source: ACJfBovMaTBff6CPloSFDP6flG2lmTk8PtcbBUa8PMj+WXKfyUq7VEJcJly7YNDohnNTppOiTmITew== X-Received: by 10.80.137.178 with SMTP id g47mr2425095edg.100.1515758873862; Fri, 12 Jan 2018 04:07:53 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id f16sm13489705edj.65.2018.01.12.04.07.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Jan 2018 04:07:52 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 02/41] KVM: arm/arm64: Move vcpu_load call after kvm_vcpu_first_run_init Date: Fri, 12 Jan 2018 13:07:08 +0100 Message-Id: <20180112120747.27999-3-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180112120747.27999-1-christoffer.dall@linaro.org> References: <20180112120747.27999-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180112_040806_425051_D6AF3472 X-CRM114-Status: GOOD ( 13.82 ) 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: Marc Zyngier , Andrew Jones , Christoffer Dall , Shih-Wei Li , kvm@vger.kernel.org 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 Reviewed-by: Julien Grall --- virt/kvm/arm/arch_timer.c | 7 ------- virt/kvm/arm/arm.c | 22 ++++++++-------------- virt/kvm/arm/vgic/vgic-init.c | 11 ----------- 3 files changed, 8 insertions(+), 32 deletions(-) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index cfcd0323deab..c09c701fd68e 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -834,14 +834,7 @@ int kvm_timer_enable(struct kvm_vcpu *vcpu) return ret; no_vgic: - preempt_disable(); timer->enabled = 1; - if (!irqchip_in_kernel(vcpu->kvm)) - kvm_timer_vcpu_load_user(vcpu); - else - 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 5e3c149a6e28..360df72692ee 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -631,27 +631,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); @@ -803,7 +798,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 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; }