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: 10160385 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 E23AC602D8 for ; Fri, 12 Jan 2018 12:08:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C65A128870 for ; Fri, 12 Jan 2018 12:08:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAF62289CD; Fri, 12 Jan 2018 12:08:00 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI 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 8B93F289C6 for ; Fri, 12 Jan 2018 12:07:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933396AbeALMH4 (ORCPT ); Fri, 12 Jan 2018 07:07:56 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36435 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932797AbeALMHz (ORCPT ); Fri, 12 Jan 2018 07:07:55 -0500 Received: by mail-wm0-f65.google.com with SMTP id b76so11447074wmg.1 for ; Fri, 12 Jan 2018 04:07:54 -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=dJL2J5eK9A1CGIRp6NYPTAtv6eOwpssfrcAtZb9gpbpvAMFsH8qANG48YOa6YQ5lh6 rLW+YRQgl3o+EvewjBKgNHG9HTqlJvajOpH+DJPExzlQIZj6lADBvjkVL9XEuM3k7IOx 8ifGCgRqZXx+wmNjpI5IaL+ep6Sys2tYsyvwS35VjN+XZMjFeGOFsp+PDaMnTuxtg4OF 2VHKcEa8fMR7ZiFXln8ot0ilCTEzCSFCj8DkpRAZ3QS3qEZcKUvKjvKPIWPAtC1g9H3h yo+GTRC+M8N+XrqsGfycTy3lYG1Kg51odu5USXyxqHBxDEvtaV3nkGsoK3d6WYDFq3Yi l6rQ== X-Gm-Message-State: AKwxytckIuEJVJeFrsIS6UowROzkQh+KEYYP75r8kKNRPWc9TKGWwpMM TI4Vs9lS9vTnDPsGLmBKsROHyQ== 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 Cc: kvm@vger.kernel.org, Marc Zyngier , Shih-Wei Li , Andrew Jones , Christoffer Dall 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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; }