From: Christoffer Dall <cdall@linaro.org>
To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org
Cc: Marc Zyngier <marc.zyngier@arm.com>,
kvm@vger.kernel.org, Christoffer Dall <cdall@linaro.org>
Subject: [PATCH 8/8] KVM: arm/arm64: vgic-its: Cleanup after failed ITT restore
Date: Mon, 8 May 2017 13:54:54 +0200 [thread overview]
Message-ID: <20170508115454.5075-9-cdall@linaro.org> (raw)
In-Reply-To: <20170508115454.5075-1-cdall@linaro.org>
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 <cdall@linaro.org>
---
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;
}
--
2.9.0
next prev parent reply other threads:[~2017-05-08 11:54 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-08 11:54 [PATCH 0/8] Fixes to v7 of the vITS save/restore series Christoffer Dall
2017-05-08 11:54 ` [PATCH 1/8] KVM: arm/arm64: Clarification and relaxation to ITS save/restore ABI Christoffer Dall
2017-05-08 16:03 ` Auger Eric
2017-05-08 11:54 ` [PATCH 2/8] KVM: arm/arm64: vgic: Rename kvm_vgic_vcpu_init to kvm_vgic_vcpu_enable Christoffer Dall
2017-05-08 16:03 ` Auger Eric
2017-05-08 11:54 ` [PATCH 3/8] KVM: arm/arm64: Refactor vgic_register_redist_iodevs Christoffer Dall
2017-05-08 16:03 ` Auger Eric
2017-05-08 18:38 ` Christoffer Dall
2017-05-08 11:54 ` [PATCH 4/8] KVM: arm/arm64: Make vgic_v3_check_base more broadly usable Christoffer Dall
2017-05-08 16:13 ` Auger Eric
2017-05-08 17:18 ` Christoffer Dall
2017-05-08 17:39 ` Auger Eric
2017-05-08 19:10 ` Christoffer Dall
2017-05-08 11:54 ` [PATCH 5/8] KVM: arm/arm64: Slightly rework kvm_vgic_addr Christoffer Dall
2017-05-08 16:19 ` Auger Eric
2017-05-08 11:54 ` [PATCH 6/8] KVM: arm/arm64: Register iodevs when setting redist base and creating VCPUs Christoffer Dall
2017-05-08 17:09 ` Auger Eric
2017-05-08 17:20 ` Christoffer Dall
2017-05-08 11:54 ` [PATCH 7/8] KVM: arm/arm64: Register ITS iodev when setting base address Christoffer Dall
2017-05-08 17:12 ` Auger Eric
2017-05-08 17:41 ` Marc Zyngier
2017-05-08 19:21 ` Christoffer Dall
2017-05-08 11:54 ` Christoffer Dall [this message]
2017-05-08 17:20 ` [PATCH 8/8] KVM: arm/arm64: vgic-its: Cleanup after failed ITT restore Auger Eric
2017-05-08 12:49 ` [PATCH 9/8] KVM: arm/arm64: Don't call map_resources when restoring ITS tables Christoffer Dall
2017-05-08 17:22 ` Auger Eric
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170508115454.5075-9-cdall@linaro.org \
--to=cdall@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=marc.zyngier@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox