From patchwork Wed Jan 31 09:35:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10193673 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 C110D603EE for ; Wed, 31 Jan 2018 09:39:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A42F6201BC for ; Wed, 31 Jan 2018 09:39:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98C5D285FC; Wed, 31 Jan 2018 09:39:59 +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 26D0B201BC for ; Wed, 31 Jan 2018 09:39:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753806AbeAaJjJ (ORCPT ); Wed, 31 Jan 2018 04:39:09 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:53720 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753767AbeAaJfw (ORCPT ); Wed, 31 Jan 2018 04:35:52 -0500 Received: by mail-wm0-f67.google.com with SMTP id t74so6695192wme.3 for ; Wed, 31 Jan 2018 01:35:52 -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=uNKugnF1pQMZab9v9SKoWT+wBl/8XFNNaBOr5fJeWuY=; b=PBNGjYq1HqrBPZxzcMoeCk2dqyIU+Uio4jVhArS1MIyu534hXsXVdxGNIJ9xmeZRDb aZGBOIGEk58B79drc8Xdg/izwoAexnRXUdM6misY0bSyRzLHzi5BWDRZyds4/8zsxrEU 9vLFAq4HB8MMXlljLRr11V5vONo9X7aNBbwF0= 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=uNKugnF1pQMZab9v9SKoWT+wBl/8XFNNaBOr5fJeWuY=; b=HKnpzOQNo6ToAwZK8akyq+NVydOVnfP19zVAnNKVVBj/5jDnBdXB8uIychw9t1kY+N BXtsiS4htC3nQHs+hW97tLF3T/8u6IfDxPt1O48y4Mw5ElvFwMQ/rYFTSXe/hcphygKH K7aQ7zWQ9524zeMBqHykOtk8i75/6SYuBryLfTXSUlvTrtOs4wJgnOmx69ZBsqNtV1zz xrbgRqn45LlQPGPCgJm1HNfY3tuYTJ3sTYOhKer+ZUI8GJG1aJvj/UxoZpql5DaJF/6R z5Ze9x6dfjNpBNDTeUawHF8MjP0ki2gOIVvg8Y1yi/Srb61JuFiwEosVP6UzZiB3QdF6 IRNA== X-Gm-Message-State: AKwxyte5WXA6cjLvNiIyankl5V6rw/oK1D2+sQVwUNKm12UugIXvJeUU FgJ+qiOmoug5oWfKYodaf4tbpg== X-Google-Smtp-Source: AH8x226Os6qgDlSJiQHzjy6YE+n7ZeeZaxDZNtVVbAU8w2rRWmxzE6ztpD2rafGMWFfGDNWhYazb+w== X-Received: by 10.80.245.52 with SMTP id t49mr57634747edm.47.1517391351597; Wed, 31 Jan 2018 01:35:51 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id z2sm10247837edc.50.2018.01.31.01.35.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 Jan 2018 01:35:50 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Marc Zyngier , Christoffer Dall Subject: [PULL 27/28] KVM: arm/arm64: Fix userspace_irqchip_in_use counting Date: Wed, 31 Jan 2018 10:35:06 +0100 Message-Id: <20180131093507.22219-28-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180131093507.22219-1-christoffer.dall@linaro.org> References: <20180131093507.22219-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 We were not decrementing the static key count in the right location. kvm_arch_vcpu_destroy() is only called to clean up after a failed VCPU create attempt, whereas kvm_arch_vcpu_free() is called on teardown of the VM as well. Move the static key decrement call to kvm_arch_vcpu_free(). Acked-by: Marc Zyngier Signed-off-by: Christoffer Dall --- virt/kvm/arm/arm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index 639dca0c0560..04ee7a327870 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -295,6 +295,9 @@ void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu) void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu) { + if (vcpu->arch.has_run_once && unlikely(!irqchip_in_kernel(vcpu->kvm))) + static_branch_dec(&userspace_irqchip_in_use); + kvm_mmu_free_memory_caches(vcpu); kvm_timer_vcpu_terminate(vcpu); kvm_pmu_vcpu_destroy(vcpu); @@ -304,8 +307,6 @@ void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu) void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu) { - if (vcpu->arch.has_run_once && unlikely(!irqchip_in_kernel(vcpu->kvm))) - static_branch_dec(&userspace_irqchip_in_use); kvm_arch_vcpu_free(vcpu); }