From patchwork Tue Jan 30 12:42:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10191783 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 C9EA860375 for ; Tue, 30 Jan 2018 12:42:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8B7B20174 for ; Tue, 30 Jan 2018 12:42:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD57A28903; Tue, 30 Jan 2018 12:42: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 3DE1320174 for ; Tue, 30 Jan 2018 12:42: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=XrRWo4kFWRF68C48wLrA9Uk92UZobEmXj+2TA34gwgU=; b=pQQ9nzXIypFCIgDFnUcFAB403r 4aYLJ6OK86Xw6WV+AQcydO9aEp/iLMM1yxJoocGEj9Ec5DXo1GO/SZwb/mHlAtkOmklmXW0Jy2uKd Io9aftOfFZqAvO8SF9CqpaXWwvnTNrH32fUDAXA1IgYQUOlhQf6KytvFHo4KjQnos3bZI/yKCf7T5 2wjihmMyX5RBixXt1AymMdV/OdxU4Lu6CoPWbWLfymei/jTF4QGHWIq4o5eJRQqkH0eDmhcCNY9nI fdax0dZ1tXy18/Jrus5bYvBEmuKM0AvCsDZzB4zl3liqdUP17CciLIbI11i+cZvu97afV62lYSC7g NCV0rdkg==; 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 1egVF7-0007Hv-Mc; Tue, 30 Jan 2018 12:42:29 +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 1egVF2-0007GS-MS for linux-arm-kernel@lists.infradead.org; Tue, 30 Jan 2018 12:42:27 +0000 Received: by mail-wm0-x243.google.com with SMTP id i186so825189wmi.4 for ; Tue, 30 Jan 2018 04:42:16 -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=evDfwGtuCdlYdDKFl+Jbg4TaY1YezQWd2eUKImHi4M4=; b=JaKY7jK9qVuV5VsVCRWpsae1TRCMrklxhfQs9y55uvXPsoA5UHMvREomhL12K132sj AiUIqQg5idlznmB6ZChCNycoHy2XGUZ0dU79P6nQJ0MyBJwLKCW6+beZfm8Pu3xHqD+U rXVy/5U1uWH/9AIHaEPlL1vnaDLD6Hh9jEbmM= 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=evDfwGtuCdlYdDKFl+Jbg4TaY1YezQWd2eUKImHi4M4=; b=jQ+nnlRFSFzo50lAxc+6OyFI+RHoRa9dRpLyrzxGC3E4VwQsjVoZ6mBDzhG2TNVOoY 6OalMgSi+lmufNfnZFJolgyFjUKiGL1GHNdotga6/jwUVaWAmZktWfu9xElOSMPWRq3x Rev1YSOs5eBeG/JE6ZMbfmjU4Jwsmxg9NFxBZ44F2ecu5dmap0qFBHmrpatD59wPeKhp Qe3wyBcC1WYU+wcCHyAzetUqTb7jJVwJfQIjydn+GdpHMNPj4GZPar9byM3p0HqfxzT2 2EI27JA0+UKXnP8YWN5TblrU9kt3DuMucnPQyP1fNnxP9BjgOFnLqVklWKS34852Lbn9 3igA== X-Gm-Message-State: AKwxytcLv1RTqlo64/EfppdiRmTu2+fN3U2BCsGoOj7pAiJ/+dGzm+9y JHSv0qfQcTthKfWx/Fj/olrVEtuPLBU= X-Google-Smtp-Source: AH8x2271uY2Y9ugTwu6xhfxJOLrro1s7Rk2vQ1g/rb4frflUuHSfnw0h7msLeUUA3DFT4vnW+e3Hjw== X-Received: by 10.80.152.68 with SMTP id h4mr51276285edb.23.1517316134858; Tue, 30 Jan 2018 04:42:14 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id z7sm7990225edb.45.2018.01.30.04.42.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Jan 2018 04:42:13 -0800 (PST) From: Christoffer Dall To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Subject: [PATCH 2/3] KVM: arm/arm64: Fix userspace_irqchip_in_use counting Date: Tue, 30 Jan 2018 13:42:05 +0100 Message-Id: <20180130124206.12262-3-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180130124206.12262-1-christoffer.dall@linaro.org> References: <20180130124206.12262-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 , 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(). Signed-off-by: Christoffer Dall Acked-by: Marc Zyngier --- 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); }