linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: arm/arm64: vgic-its: Check hopefully the last DISCARD command error
@ 2019-12-25 13:30 Zenghui Yu
  2020-01-10  8:37 ` Auger Eric
  0 siblings, 1 reply; 4+ messages in thread
From: Zenghui Yu @ 2019-12-25 13:30 UTC (permalink / raw)
  To: maz
  Cc: andre.przywara, eric.auger, linux-arm-kernel, kvmarm,
	linux-kernel, wanghaibin.wang, Zenghui Yu

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.

Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
---
 virt/kvm/arm/vgic/vgic-its.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
index 17920d1b350a..d53d34a33e35 100644
--- a/virt/kvm/arm/vgic/vgic-its.c
+++ b/virt/kvm/arm/vgic/vgic-its.c
@@ -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
-- 
2.19.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: arm/arm64: vgic-its: Check hopefully the last DISCARD command error
  2019-12-25 13:30 [PATCH] KVM: arm/arm64: vgic-its: Check hopefully the last DISCARD command error Zenghui Yu
@ 2020-01-10  8:37 ` Auger Eric
  2020-01-14  7:10   ` Zenghui Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Auger Eric @ 2020-01-10  8:37 UTC (permalink / raw)
  To: Zenghui Yu, maz
  Cc: andre.przywara, linux-arm-kernel, kvmarm, linux-kernel, wanghaibin.wang

Hi Zenghui,

On 12/25/19 2:30 PM, Zenghui Yu wrote:
> 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?

Reviewed-by: Eric Auger <eric.auger@redhat.com>

Thanks

Eric

>  - 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 <yuzenghui@huawei.com>
> ---
>  virt/kvm/arm/vgic/vgic-its.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
> index 17920d1b350a..d53d34a33e35 100644
> --- a/virt/kvm/arm/vgic/vgic-its.c
> +++ b/virt/kvm/arm/vgic/vgic-its.c
> @@ -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
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: arm/arm64: vgic-its: Check hopefully the last DISCARD command error
  2020-01-10  8:37 ` Auger Eric
@ 2020-01-14  7:10   ` Zenghui Yu
  2020-01-14  8:20     ` Auger Eric
  0 siblings, 1 reply; 4+ messages in thread
From: Zenghui Yu @ 2020-01-14  7:10 UTC (permalink / raw)
  To: Auger Eric, maz
  Cc: andre.przywara, linux-arm-kernel, kvmarm, linux-kernel, wanghaibin.wang

Hi Eric,

On 2020/1/10 16:37, Auger Eric wrote:
> Hi Zenghui,
> 
> On 12/25/19 2:30 PM, Zenghui Yu wrote:
>> 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.

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.

> 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?

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.

> 
> Reviewed-by: Eric Auger <eric.auger@redhat.com>
> 

Thanks for that. I'll change the commit message with your suggestion and
add your R-b in v2.


Thanks,
Zenghui


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: arm/arm64: vgic-its: Check hopefully the last DISCARD command error
  2020-01-14  7:10   ` Zenghui Yu
@ 2020-01-14  8:20     ` Auger Eric
  0 siblings, 0 replies; 4+ messages in thread
From: Auger Eric @ 2020-01-14  8:20 UTC (permalink / raw)
  To: Zenghui Yu, maz
  Cc: andre.przywara, wanghaibin.wang, kvmarm, linux-arm-kernel, linux-kernel

Hi Zenghui,

On 1/14/20 8:10 AM, Zenghui Yu wrote:
> Hi Eric,
> 
> On 2020/1/10 16:37, Auger Eric wrote:
>> Hi Zenghui,
>>
>> On 12/25/19 2:30 PM, Zenghui Yu wrote:
>>> 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.
> 
> 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().
You're right I missed that case.
> 
> Discard the LPI mapping after "1" or "2", we will both encounter the
> unmapped collection command error.
> 
>> 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?
> 
> 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
> 
>>
>> Reviewed-by: Eric Auger <eric.auger@redhat.com>
>>
> 
> 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
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-14  8:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-25 13:30 [PATCH] KVM: arm/arm64: vgic-its: Check hopefully the last DISCARD command error Zenghui Yu
2020-01-10  8:37 ` Auger Eric
2020-01-14  7:10   ` Zenghui Yu
2020-01-14  8:20     ` Auger Eric

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).