From patchwork Mon May 8 11:54:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9716151 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 AB36F6035D for ; Mon, 8 May 2017 11:57:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92E6320410 for ; Mon, 8 May 2017 11:57:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86BAC223B3; Mon, 8 May 2017 11:57:11 +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 19C8C20410 for ; Mon, 8 May 2017 11:57:11 +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=lXM/KY2qb4cPxj5SmXaGJuW9jRIN5KquF4gHpdL2x1M=; b=Lm7x75db9jrgBNEIV7ErVOneL8 EAbrbZkchtTiQ4GwP7s1YIGlUSRYZwvg/ml/m9xn6isLsVc9reaP4GhJtONYFHlxR2k9k9m2blJTs Hp3bzfuLvZswDU5SX2AThjsm8e89KVaV1WNXOHxaQOctZ15fo2uoof2I87EnJD6UIoKy3qbKQfn8d KZWcSnvFPVJfnxNO4SsTnJ5mJLoJAvKf5PwhByPkTnjShIGcGO079QS5sIpbKBmcxEgYHzZgljmN2 KQYuxivn7SawpfgOUwHUl9orrVzUxtsqwJBID9tc0NA0cKbxs1FJxyO28BwUp8O1EvtFc0Hl3SC8T l2Qg3SlA==; 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 1d7hHq-0000DD-0o; Mon, 08 May 2017 11:57:10 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d7hGC-0006Nx-UJ for linux-arm-kernel@lists.infradead.org; Mon, 08 May 2017 11:55:33 +0000 Received: by mail-wm0-x230.google.com with SMTP id m123so61992954wma.0 for ; Mon, 08 May 2017 04:55:09 -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=CX8ykkjX8HjecRRvv6/XbiOcxMNjPv2PrV7AqrWu548=; b=W1Owd0IwcNvhMX60kmdR18loFB+FWNo5Ni1fAgiE10SGDZAzdd3KgFfpJM4u1M5I7p 8QSFIYHPSnOg1knwwm6JkwP9H/YD+oOwz9/VnXPMNxz7jHZpqhQmO/gkcOzQwzh90vpK niijv8BiRCxX19zSFKrEmGL87td/3ey4L5vjQ= 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=CX8ykkjX8HjecRRvv6/XbiOcxMNjPv2PrV7AqrWu548=; b=dhGo5Ukf0ArPCLbVSvZrFvq941ZeIN8t0/u71vYOvY+LgsPFabmD/FnTUSW/jn3Shx L1tWPQfU0qS6yhEMit1km+AwKZKoqib/2aGMFoEGuHnOA6jzuAPpgnsW4BIA/w1y193d hFCJdtP6RMJuxL56WxxNRc6Tq1VeyznlmgZg75oVPY145yrPHFva00f2TulOYTb88VTG PvkBcoYqKXiZ8ja0/oeeGqeVt+KCqFaPzbm1EnlGeqHlLehDaMzv4TCFQhfXAu3PKoz4 MNR6H+tfYEWXxN+sx657CY5XoFWCgwHWYpQSeuYRN1BwIkRJQkbFxK0mwfwU4w7kR1gn mJQA== X-Gm-Message-State: AN3rC/7HCih1I8oa2ZJZ2oFDAs2mogUAWXa5257jL7Tnw0fSTRnycbyp RfKSFmT+FFXIlRm4 X-Received: by 10.80.140.164 with SMTP id q33mr37736401edq.77.1494244507757; Mon, 08 May 2017 04:55:07 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id k43sm3483411ede.1.2017.05.08.04.55.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 May 2017 04:55:07 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH 8/8] KVM: arm/arm64: vgic-its: Cleanup after failed ITT restore Date: Mon, 8 May 2017 13:54:54 +0200 Message-Id: <20170508115454.5075-9-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170508115454.5075-1-cdall@linaro.org> References: <20170508115454.5075-1-cdall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170508_045529_398427_9B61E5FD X-CRM114-Status: GOOD ( 13.59 ) 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 , Eric Auger , kvm@vger.kernel.org, Christoffer Dall 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 When failing to restore the ITT for a DTE, we should remove the failed device entry from the list and free the object. We slightly refactor vgic_its_destroy to be able to reuse the now separate vgic_its_free_dte() function. Signed-off-by: Christoffer Dall Reviewed-by: Eric Auger --- virt/kvm/arm/vgic/vgic-its.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index 375c503..00f2990 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c @@ -1612,13 +1612,20 @@ static int vgic_its_create(struct kvm_device *dev, u32 type) return vgic_its_set_abi(its, NR_ITS_ABIS - 1); } +static void vgic_its_free_dte(struct kvm *kvm, struct its_device *dev) +{ + struct its_ite *ite, *tmp; + + list_for_each_entry_safe(ite, tmp, &dev->itt_head, ite_list) + its_free_ite(kvm, ite); + list_del(&dev->dev_list); + kfree(dev); +} + static void vgic_its_destroy(struct kvm_device *kvm_dev) { struct kvm *kvm = kvm_dev->kvm; struct vgic_its *its = kvm_dev->private; - struct its_device *dev; - struct its_ite *ite; - struct list_head *dev_cur, *dev_temp; struct list_head *cur, *temp; /* @@ -1629,19 +1636,19 @@ static void vgic_its_destroy(struct kvm_device *kvm_dev) return; mutex_lock(&its->its_lock); - list_for_each_safe(dev_cur, dev_temp, &its->device_list) { - dev = container_of(dev_cur, struct its_device, dev_list); - list_for_each_safe(cur, temp, &dev->itt_head) { - ite = (container_of(cur, struct its_ite, ite_list)); - its_free_ite(kvm, ite); - } - list_del(dev_cur); - kfree(dev); + list_for_each_safe(cur, temp, &its->device_list) { + struct its_device *dev; + + dev = list_entry(cur, struct its_device, dev_list); + vgic_its_free_dte(kvm, dev); } list_for_each_safe(cur, temp, &its->collection_list) { + struct its_collection *coll; + + coll = list_entry(cur, struct its_collection, coll_list); list_del(cur); - kfree(container_of(cur, struct its_collection, coll_list)); + kfree(coll); } mutex_unlock(&its->its_lock); @@ -2011,8 +2018,10 @@ static int vgic_its_restore_dte(struct vgic_its *its, u32 id, return PTR_ERR(dev); ret = vgic_its_restore_itt(its, dev); - if (ret) + if (ret) { + vgic_its_free_dte(its->dev->kvm, dev); return ret; + } return offset; }