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: 10193715 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 C728A603EE for ; Wed, 31 Jan 2018 09:41:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8D6028606 for ; Wed, 31 Jan 2018 09:41:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DA5C28609; Wed, 31 Jan 2018 09:41:33 +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=ham 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 3336B28606 for ; Wed, 31 Jan 2018 09:41:33 +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=yrJe0pyUVJfXl2k/WHZkPC0l9ZJV3btD9/IdKlFQxfs=; b=glyFeO1+BRYgC5vBe8i4R2RRIk iDPaOwCh/Adju+vmQUfI7m32PuU3TX0fDUooaHfW1NS2uMgRme3PT5nmsFnmpo9O00mBKxL0DOz5n SUbnb4a88gGlOjVOpvT9P5eN9OtGHUpdrYKbwy5yah0/jaxlf5nQ1f4HJNgP3j3mIq7TEo3iouSeP zw6IXknY+Ld0NRMMQYFRWiHOX6U9amsU2E+I68VyWNVhtD54O0ALqaMrUj7XJXD9JJ3Yn5QCorUPQ 0tjdzUxGDpHg8m1gfVQDbsek5Bcq4wykHfz2J5ZW1Qs4VuMQQdcGcp3eE+miUDlKHBfG7g07YcG25 Dt4kPiuQ==; 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 1egotV-00044a-9e; Wed, 31 Jan 2018 09:41:29 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1egoo8-0005tt-3Q for linux-arm-kernel@lists.infradead.org; Wed, 31 Jan 2018 09:36:09 +0000 Received: by mail-wm0-x242.google.com with SMTP id 143so6647059wma.5 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=gt+Hp/Wm21JJ/18MBW0gGbhp/7OPeY6ItwsYk1kIl/CCugXjRQRyN1KytRt+u5plNN lUkP+Rsqg+/Dqw9wN8jHQs7V2UTmUO1RUj3is2jOXEQ4GxJ7ltm8/xI34sROwx+N9seh r2hyzzyQy5813rZstkqFiYOodB3OULoVkQTTDq8EDgwCNTM5qrtocplDo9rrattpSERC WKF7D7daUVvwlSCqQ9LIkSlgUcJffhlZAPV73c4hnvzQw/lxzsCKLpwrdTu19a1C0p7K wQ8Gc5fsllImYGyqWKZ3da5CYIIn3oCDKS8sTMfdN4PSyHfpSkjQSbFIq5/WwcNjzbTF q2Zg== X-Gm-Message-State: AKwxytcnOxxU8beZ1fATuaN7QeR3V5zwEtdEi0qiG8kYjPa5ijlXszxF m/aKNaSlCGIS/V2sQ/jUp51JrQ== 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?= 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> 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 , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, 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 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); }