Re: [PATCH] KVM: arm/arm64: vgic-its: Fix restoration of unmapped collections

From: Auger Eric
Date: Fri Dec 13 2019 - 06:06:54 EST


Hi Zenghui,

On 12/13/19 11:53 AM, Zenghui Yu wrote:
> Hi Eric,
>
> On 2019/12/13 17:42, Eric Auger wrote:
>> Saving/restoring an unmapped collection is a valid scenario. For
>> example this happens if a MAPTI command was sent, featuring an
>> unmapped collection. At the moment the CTE fails to be restored.
>> Only compare against the number of online vcpus if the rdist
>> base is set.
>
> Have you actually seen a problem and this patch fixed it?

It is not with a linux guest but with kvm-unit-test.

To be honest,
> I'm surprised to find that we can map a LPI to an unmapped collection ;)
> (and prevent it to be delivered to vcpu with an INT_UNMAPPED_INTERRUPT
> error, until someone had actually mapped the collection).
> After a quick glance of spec (MAPTI), just as you said, this is valid.
>
> If Marc has no objection to this fix, please add
>
> Reviewed-by: Zenghui Yu <yuzenghui@xxxxxxxxxx>
Thank you for the review.

Eric
>
>
> Thanks,
> Zenghui
>
>>
>> Cc: stable@xxxxxxxxxxxxxxx # v4.11+
>> Fixes: ea1ad53e1e31a ("KVM: arm64: vgic-its: Collection table
>> save/restore")
>> Signed-off-by: Eric Auger <eric.auger@xxxxxxxxxx>
>> ---
>> Â virt/kvm/arm/vgic/vgic-its.c | 3 ++-
>> Â 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
>> index 98c7360d9fb7..17920d1b350a 100644
>> --- a/virt/kvm/arm/vgic/vgic-its.c
>> +++ b/virt/kvm/arm/vgic/vgic-its.c
>> @@ -2475,7 +2475,8 @@ static int vgic_its_restore_cte(struct vgic_its
>> *its, gpa_t gpa, int esz)
>> ÂÂÂÂÂ target_addr = (u32)(val >> KVM_ITS_CTE_RDBASE_SHIFT);
>> ÂÂÂÂÂ coll_id = val & KVM_ITS_CTE_ICID_MASK;
>> Â -ÂÂÂ if (target_addr >= atomic_read(&kvm->online_vcpus))
>> +ÂÂÂ if (target_addr != COLLECTION_NOT_MAPPED &&
>> +ÂÂÂÂÂÂÂ target_addr >= atomic_read(&kvm->online_vcpus))
>> ÂÂÂÂÂÂÂÂÂ return -EINVAL;
>> Â ÂÂÂÂÂ collection = find_collection(its, coll_id);
>>
>