KVM: arm/arm64: vgic-its: Check hopefully the last DISCARD command error
Zenghui Yu
reviewerPATCH 1/1 KVM: arm/arm64: vgic-its: Check hopefully the last DISCARD command error
DISCARD command error occurs if any of the following apply:
- [ ... (those which we have already handled) ]
- The EventID for the device is mapped to a collection that has not been mapped to an RDbase using MAPC.
Let's take the unmapped collection case into account and report a DISCARD command error if it really happens.
--- virt/kvm/arm/vgic/vgic-its.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
virt/kvm/arm/vgic/vgic-its.c +1 -2
@@ -839,9 +839,8 @@ static int vgic_its_cmd_handle_discard(struct kvm *kvm, struct vgic_its *its,u32 event_id =its_cmd_get_id (its_cmd);struct its_ite *ite; - ite =find_ite (its, device_id, event_id); -if (ite && ite->collection) { +if (ite &&its_is_collection_mapped (ite->collection)) {/* * Though the spec talks about removing the pending state, we * don't bother here since we clear the ITTE anyway and the
Signature · 1 line
2.19.1
Hi Zenghui,
Quoted 3 lines · Zenghui Yu
DISCARD command error occurs if any of the following apply:
- [ ... (those which we have already handled) ]
nit: I would remove the above and simply say the discard is supposed to fail if the collection is not mapped to any target redistributor. If an ITE exists then the ite->collection is non NULL. What needs to be checked is its_is_collection_mapped().
By the way update_affinity_collection() also tests ite->collection. I think this is useless or do I miss something?
Thanks
Eric
Quoted 27 lines
- The EventID for the device is mapped to a collection that has not been mapped to an RDbase using MAPC.
Let's take the unmapped collection case into account and report a DISCARD command error if it really happens.
Signed-off-by Zenghui Yu <[email protected]>--- virt/kvm/arm/vgic/vgic-its.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)virt/kvm/arm/vgic/vgic-its.c +1
-2@@ -839,9 +839,8 @@ static int vgic_its_cmd_handle_discard(struct kvm *kvm, struct vgic_its *its,u32 event_id =its_cmd_get_id (its_cmd);struct its_ite *ite; - ite =find_ite (its, device_id, event_id); -if (ite && ite->collection) { +if (ite &&its_is_collection_mapped (ite->collection)) {/* * Though the spec talks about removing the pending state, we * don't bother here since we clear the ITTE anyway and the
Zenghui Yu
reviewerHi Eric,
Quoted 9 lines · Auger Eric
Hi Zenghui,
Quoted 3 lines · Zenghui Yu
DISCARD command error occurs if any of the following apply:
- [ ... (those which we have already handled) ]
nit: I would remove the above and simply say the discard is supposed to fail if the collection is not mapped to any target redistributor. If an ITE exists then the
ite->collectionis non NULL.
I think this is not always true. Let's talk about the following scenario (a bit insane, though):
1. First map a LPI to an unmapped Collection, then ite->collection is non NULL and its target_addr is COLLECTION_NOT_MAPPED.
2. Then issue MAPC and unMAPC(V=0) commands on this Collection, the ite->collection will be NULL, see vgic_its_free_collection().
Discard the LPI mapping after "1" or "2", we will both encounter the unmapped collection command error.
Quoted 4 lines
What needs to be checked is
its_is_collection_mapped().By the way
update_affinity_collection()also testsite->collection. I think this is useless or do I miss something?
Yeah, I agree. We managed to invoke update_affinity_collection(,, coll), ensure that the 'coll' can _not_ be NULL.
So '!ite->collection' is already a subcase of 'coll != ite->collection'. We can safely get rid of it.
Quoted 3 lines
Reviewed-by Eric Auger <[email protected]>
Thanks for that. I'll change the commit message with your suggestion and add your R-b in v2.
Thanks,
Zenghui
Hi Zenghui,
Quoted 13 lines · Zenghui Yu
Hi Eric,
Quoted 9 lines · Auger Eric
Hi Zenghui,
Quoted 3 lines · Zenghui Yu
DISCARD command error occurs if any of the following apply:
- [ ... (those which we have already handled) ]
nit: I would remove the above and simply say the discard is supposed to fail if the collection is not mapped to any target redistributor. If an ITE exists then the
ite->collectionis non NULL.
Quoted 8 lines
I think this is not always true. Let's talk about the following scenario (a bit insane, though):
1. First map a LPI to an unmapped Collection, then
ite->collectionis non NULL and itstarget_addrisCOLLECTION_NOT_MAPPED.2. Then issue MAPC and unMAPC(V=0) commands on this Collection, the
ite->collectionwill be NULL, seevgic_its_free_collection().
You're right I missed that case.
Quoted 6 lines
Discard the LPI mapping after "1" or "2", we will both encounter the unmapped collection command error.
Quoted 2 lines
What needs to be checked is
its_is_collection_mapped().
Quoted 7 lines
Quoted 2 lines
By the way
update_affinity_collection()also testsite->collection. I think this is useless or do I miss something?Yeah, I agree. We managed to invoke
update_affinity_collection(,, coll), ensure that the 'coll' can _not_ be NULL.
So '!ite->collection' is already a subcase of 'coll !=ite->collection'. We can safely get rid of it.
OK. But that's not for the (wrong) reason I mentioned above. So it is a minor cleanup and you may just leave it as is and just focus on this fix.
Thanks
Eric
Quoted 18 lines
Quoted 4 lines
Reviewed-by Eric Auger <[email protected]>Thanks for that. I'll change the commit message with your suggestion and add your R-b in v2.
Thanks,
Zenghui_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel