From patchwork Mon Jul 17 14:27:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9845301 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 DB7186037F for ; Mon, 17 Jul 2017 14:30:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAE1928509 for ; Mon, 17 Jul 2017 14:30:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF80928540; Mon, 17 Jul 2017 14:30:39 +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 [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 53A0D28509 for ; Mon, 17 Jul 2017 14:30:39 +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=uuwV4YG54Ivs59W2OYja+551OrGtmptEtZCO9xnmchM=; b=Vdh+9bY/FZNyZtEbNTgADhNo8a bRdsdnzLTXxgagCeiQ+AVmbH84o8q/ChbT09aMm45rojA056qcMqyPuH4I2vCwQ6N0bTHstQLW0K8 vnwI5ZbKnowEq/VACgaqc0q+jettRNOXxW91ec7vgXBDBzj2qfhRhWVJZYAx4nEzYj4RJysTvQbwj 84wj79H7IbqCpM1XtM1t33SLlvBqysw+NzAlLPW+oQgd7CASYdIVaf8w3AikRtPbHeRQPLJac9lEc ba/5i5N6ZogHzg6FN383MlHf8xAsF7a1vQlxO8gOgIm9GwR+kaoQKssn5IAg8sVsgcqE236wS7kfh rmA8g0Cg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dX72j-0005NU-7s; Mon, 17 Jul 2017 14:30:37 +0000 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dX704-0001MK-Pu for linux-arm-kernel@lists.infradead.org; Mon, 17 Jul 2017 14:28:07 +0000 Received: by mail-wm0-x235.google.com with SMTP id b134so49977552wma.0 for ; Mon, 17 Jul 2017 07:27:35 -0700 (PDT) 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=L7yRpNurBA/QaRaoo3v+XL/vD7V8ESnwd+r2lEr5+zw=; b=Y1dUsoS/rJB9vh8/gIygb7zCqKb8wutea0/BQhCBVUIlFeCVq/9zEcMrrUD9T4otfw Xf3cWA6AEzBGSrIWINvQQDq8xcQuYmh8rxL8gk27vvftj6WfUARkhq1nDXzh8tPuJIXB hypgB6kcZ4/6Gcdia72shqYt8pX1MT2TLlgGU= 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=L7yRpNurBA/QaRaoo3v+XL/vD7V8ESnwd+r2lEr5+zw=; b=cO0wGsu3SeOFdeno7YH/QunFF4GSMZW3LMtFeaIzkSc2Vh2K6UtFS37AeBfNjr5RxK W+rS48Lr7SjZgJw0A9bwx7gfyv2xrM+BycnqeMZ+9Wy/HlsushsLW0y9++PcRZh773jx MDM5V8VAMwXiJ6abprcxsB1s2A82tEOR8j4JEhrQdlWzi30qpzV1bdl2h31+qOSQCaQ6 WzPwf+nc3B8ENTuA9dpQnF9AXGLW945d6iyCmyFR9vMPFYxJVRe65YlQNP54qEddGCXh zV/ll5ogW/TtmwHUkrYaqPhFVxby8ZE0sqbKVn8RruoaisooZGUuz+TL+vd8+c6+bSag BqcQ== X-Gm-Message-State: AIVw113B5sZYE4Hkx9PrvOPgrgY9gV7LDC1Cf8cVOcqP2U9ZbULLwU0L K+oAof0TgDm/g8sT X-Received: by 10.80.164.72 with SMTP id v8mr17401601edb.49.1500301653882; Mon, 17 Jul 2017 07:27:33 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id b30sm9428952edd.6.2017.07.17.07.27.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 07:27:33 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH v2 09/19] KVM: arm/arm64: Move timer/vgic flush/sync under disabled irq Date: Mon, 17 Jul 2017 16:27:08 +0200 Message-Id: <20170717142718.13853-10-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170717142718.13853-1-cdall@linaro.org> References: <20170717142718.13853-1-cdall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170717_072753_704616_CD528ABF X-CRM114-Status: GOOD ( 11.77 ) 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 , Christoffer Dall , 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 As we are about to play tricks with the timer to be more lazy in saving and restoring state, we need to move the timer sync and flush functions under a disabled irq section and since we have to flush the vgic state after the timer and PMU state, we do the whole flush/sync sequence with disabled irqs. The only downside is a slightly longer delay before being able to process hardware interrupts and run softirqs. Signed-off-by: Christoffer Dall --- virt/kvm/arm/arm.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index a39a1e1..a49b19e 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -649,11 +649,11 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) kvm_pmu_flush_hwstate(vcpu); + local_irq_disable(); + kvm_timer_flush_hwstate(vcpu); kvm_vgic_flush_hwstate(vcpu); - local_irq_disable(); - /* * If we have a singal pending, or need to notify a userspace * irqchip about timer or PMU level changes, then we exit (and @@ -678,10 +678,10 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) if (ret <= 0 || need_new_vmid_gen(vcpu->kvm) || kvm_request_pending(vcpu)) { vcpu->mode = OUTSIDE_GUEST_MODE; - local_irq_enable(); kvm_pmu_sync_hwstate(vcpu); kvm_timer_sync_hwstate(vcpu); kvm_vgic_sync_hwstate(vcpu); + local_irq_enable(); preempt_enable(); continue; } @@ -705,6 +705,16 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) kvm_arm_clear_debug(vcpu); /* + * We must sync the PMU and timer state before the vgic state so + * that the vgic can properly sample the updated state of the + * interrupt line. + */ + kvm_pmu_sync_hwstate(vcpu); + kvm_timer_sync_hwstate(vcpu); + + kvm_vgic_sync_hwstate(vcpu); + + /* * We may have taken a host interrupt in HYP mode (ie * while executing the guest). This interrupt is still * pending, as we haven't serviced it yet! @@ -727,16 +737,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) guest_exit(); trace_kvm_exit(ret, kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu)); - /* - * We must sync the PMU and timer state before the vgic state so - * that the vgic can properly sample the updated state of the - * interrupt line. - */ - kvm_pmu_sync_hwstate(vcpu); - kvm_timer_sync_hwstate(vcpu); - - kvm_vgic_sync_hwstate(vcpu); - preempt_enable(); ret = handle_exit(vcpu, run, ret);