From patchwork Thu Feb 15 21:02:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10223553 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 AD9FA60467 for ; Thu, 15 Feb 2018 21:04:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DD8929512 for ; Thu, 15 Feb 2018 21:04:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91FB029513; Thu, 15 Feb 2018 21:04:24 +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=ham 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 863EE29516 for ; Thu, 15 Feb 2018 21:04:23 +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=WCaqYEjj+/6kGGhiD5BURjZ72Ho4iWlVA+VDe4Jm/NE=; b=iNAwrFmcjMIenIBvIzf5IM4/93 j4pG+SHbGmEk5jIG0WbPYwbcMi99I69nKkK1bWopFKY2In/7yU8JXofMydkwtfqe8azM88p/pM8TG 6ujp0qR2wz76cYWVUFmYJlaJ6FD4JO/wYCWJcbvoNpA9aTES9vABZ0Qvkvx6140AQAmr00nC4heZg BjLJhxXahaR3QJiZsDXcQD10NKHLLxbFi9J05uEXP81MZ04Q7DOs6dmParWGNUybeVdKB8cISmG9K Z9MwCAZCpp/qt6pAJuetT107ZwcdwQMUPCd+HMQNCi3aun4+4cQQr6wP7J56u2X0tDntrUQlKPFbW SKZpfjiQ==; 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 1emQhI-0008G2-E3; Thu, 15 Feb 2018 21:04:04 +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 1emQhB-0008BN-Vh for linux-arm-kernel@lists.infradead.org; Thu, 15 Feb 2018 21:03:59 +0000 Received: by mail-wm0-x243.google.com with SMTP id z81so3259602wmb.4 for ; Thu, 15 Feb 2018 13:03:49 -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=BVeIYbeKrgGaLSpFVTOEqNZXTaKZRysjha49Of6aKK0=; b=AFkdcTG6CEyfW2HcIHKUELCxuQlwUQiRY9+pQgfGWxSAbLJDVNHDS/RqtrCjb+47l3 EwhIfBQmHtB4MS8Iu1KtwqJeTaSihCXvqccZi5vIICO9MgKEHbA5yKBjXlJGk75YvYRF cG1nfSYcRRnwN/VeDiebvxyrvatXuEH2BAFJ8= 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=BVeIYbeKrgGaLSpFVTOEqNZXTaKZRysjha49Of6aKK0=; b=raPXSptPS7MVgrDpbM1vBfIJ4mitNug+xrwx74eGjSyvuHdpGE04bWWoOW9yaWrLmx 48DYidetBV29Na71FDCR/yZHis+r2iMQRnCpfgp91u13U9q1z8U9q/pKEqexuDW0l8Mb a/DVKkSyfjaHdbZtNQ4FdAyZd/Yi0nxy9QtlsI7gLv89+GYNpft90o8x/gwr5oCFpKb5 2sPiSkRubmeDzs0MQKGMk8PKcxaON4ZtXL+/sPA6j9hdHnFap9dsE1pIz+VQ/gOYcm7+ fHwk5J29Q0eRXX5je1Z45t9/8pwTByRc8JeS8wl9RSKpwLm3QR5tiJ0BC4soi5aukFiN GYQw== X-Gm-Message-State: APf1xPADHEp2QcTsW5X/mKSMdovBqUbDKqrwW2IDSX5GxOAtbVa5NKXA AXPy5GmzxZkEr0TvJx7cMa/n/A== X-Google-Smtp-Source: AH8x226EPz/wH3Kf4I0smYHJBCutD5r0AKsOHyKrbgPl8JDozJPrpDACNJVQzRL8FnsNyT6CKBJsZw== X-Received: by 10.80.135.205 with SMTP id 13mr5164586edz.253.1518728628696; Thu, 15 Feb 2018 13:03:48 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id p55sm8220030edc.15.2018.02.15.13.03.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Feb 2018 13:03:47 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 02/40] KVM: arm/arm64: Move vcpu_load call after kvm_vcpu_first_run_init Date: Thu, 15 Feb 2018 22:02:54 +0100 Message-Id: <20180215210332.8648-3-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180215210332.8648-1-christoffer.dall@linaro.org> References: <20180215210332.8648-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180215_130358_116674_3E58AC0E X-CRM114-Status: GOOD ( 14.93 ) 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 , Christoffer Dall , 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 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 Signed-off-by: Christoffer Dall Reviewed-by: Marc Zyngier --- 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 70f4c30918eb..b744e6935a3f 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -852,11 +852,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; }