From patchwork Fri Oct 27 08:34:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10029495 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 319F66034B for ; Fri, 27 Oct 2017 09:50:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25E1828F7D for ; Fri, 27 Oct 2017 09:50:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1AEDC28F81; Fri, 27 Oct 2017 09:50:06 +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 24C2D28F7D for ; Fri, 27 Oct 2017 09:50:05 +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=SRQw+CleZyCOlqb2UtlRcog8n5mUnSWqXoMHH5QlSMA=; b=SUCig0xiOPlSqG1381Psh7Xjz6 T9tUl4X51esFBeoL+9bnrUcHTWg70TJJOrFI11ihH8dn6R9HvQwfCf6gSOTSyjeOcqnRghoyfmVlV UPo86XC6Hy4Pcwvwfm6HjwMibL4dwK2KNWnNl/7fayWGDLBif/jIJnkGoHeZCR2xI9RlB6cPnagyY /kE5yQSsxlXHWrfr02kdBhEJH+wYcMoTjAbCvg3UPdBSItDMMahy+JR1H0AisI7PnR+MeZlm7s1d/ r/GIlx0O1BMxsCa6CB2nrBsrTgwSJt4CYtAFGt7IKelqZr6Y86ukJg+u2VCSfD0u5pR0TndkHoS/F IVpoFIzA==; 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 1e81H6-0005c0-UO; Fri, 27 Oct 2017 09:50:00 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e81GQ-0004zZ-0W for linux-arm-kernel@bombadil.infradead.org; Fri, 27 Oct 2017 09:49:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=qoGJLIFiYdPiDH97GQXIILsSXPyFfuICDJMCMp1zV0c=; b=ETVtyFvwNvt+6UpsG6A5AAqy0 31n5ch4+mBevKSbZCpKKpJ2Yq3Se2MobFfDELA1rhBZ1A7hzxqfo9k9rYYe7l47dL5R9YhhdUCUN6 P+X0bOIx3jJMhiaabn6e1fv2D4uohDx5ysdgXatkQ2rhP2ndh89gWCQRLmbMuEAr9t41a9FCPM0lZ ZtcAGTAGmmGzExdHWr2ijttdvT4JV/c1abYcpNF8c7w3JlGUARIqgqxp0sHc3n8gsD89PQeCk0iNn kBSNHMucaEK7xzD5/ghER6JLBbOfiob2cUgD6wPGdTOTQr1kr5/q9xsYwr5jj7stOqO2ZyHzWh9fk 5PR12dVLg==; Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e807h-0003lR-UO for linux-arm-kernel@lists.infradead.org; Fri, 27 Oct 2017 08:36:15 +0000 Received: by mail-lf0-x242.google.com with SMTP id a132so6537946lfa.7 for ; Fri, 27 Oct 2017 01:35:51 -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=qoGJLIFiYdPiDH97GQXIILsSXPyFfuICDJMCMp1zV0c=; b=GHd3npqT90VthjWJgx16jJT89nW2h3AKxIgeaHxf++19j8JlaMg5gOrAUQ79E84iDP xy9C81z3Oeq5sJthAIGNYqhWyjIniiqo3bc70Y9LzoZBrhsY+neJQPq7UZhNuGu40owI QLdogVJ/Hvd4Naq637Xk+8nW5/UgxwJTsQ4Io= 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=qoGJLIFiYdPiDH97GQXIILsSXPyFfuICDJMCMp1zV0c=; b=KMp1UNGofWKRhLHKj0zl9erS+up+3HimmHAVt8NvdQNRGNnANXpXSm8MhaB/O4uago eF9rzmiQahSUCvweoUwelBqPc6qYy3sW0i7YJpiu/dwHYuucNtkWHSAwE+kGSn12bvFC oI/4Wz96gagzsJupKC6jS7KN1YnX9k7f9hDGNV2LkN/1b50Feaofb4WxPbHqgp6e41O9 Nn6lwLQ9bvczdmF9K27R6emVx8i9di2utqIlF0vyDXocux2fsxvatz/KTuXBL/pZvluH huFwt1E/msANcsIQ31E65EkxdVBC555QytLUvLa7Nixz3s+4777gWG+71+I+QbnF+IWG N38w== X-Gm-Message-State: AMCzsaXCYhwNZ3+nxSZKN81A3yQAAmo459B04Aiqygcp3J7RAAag1pJp NvfhhaQ7Jft6ViNBwfjL4fnD9Q== X-Google-Smtp-Source: ABhQp+Shcg/o52xAbooWDPTo5gdyf5tUYhlxpsma0g6It8VFfGeTwK5iRM0tdpJoMeL7JZ+q5HrFKw== X-Received: by 10.46.117.24 with SMTP id q24mr10288943ljc.14.1509093348686; Fri, 27 Oct 2017 01:35:48 -0700 (PDT) Received: from localhost.localdomain (212.27.17.163.bredband.3.dk. [212.27.17.163]) by smtp.gmail.com with ESMTPSA id d204sm1471957lfe.73.2017.10.27.01.35.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Oct 2017 01:35:47 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 09/20] KVM: arm/arm64: Move timer/vgic flush/sync under disabled irq Date: Fri, 27 Oct 2017 10:34:30 +0200 Message-Id: <1509093281-15225-10-git-send-email-cdall@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509093281-15225-1-git-send-email-cdall@linaro.org> References: <1509093281-15225-1-git-send-email-cdall@linaro.org> 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: Christoffer Dall , kvm@vger.kernel.org, Marc Zyngier , Catalin Marinas , Will Deacon , Eric Auger 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 Reviewed-by: Marc Zyngier --- 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 b9f68e4..27db222 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -654,11 +654,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 @@ -683,10 +683,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; } @@ -710,6 +710,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! @@ -732,16 +742,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);