kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Auger Eric <eric.auger@redhat.com>
To: Alexandru Elisei <alexandru.elisei@arm.com>,
	eric.auger.pro@gmail.com, linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
	maz@kernel.org, drjones@redhat.com
Cc: james.morse@arm.com, julien.thierry.kdev@gmail.com,
	suzuki.poulose@arm.com, shuah@kernel.org, pbonzini@redhat.com
Subject: Re: [PATCH 1/9] KVM: arm64: vgic-v3: Fix some error codes when setting RDIST base
Date: Thu, 14 Jan 2021 11:02:55 +0100	[thread overview]
Message-ID: <e37f1942-dcb7-3579-0aba-e131e4bd9217@redhat.com> (raw)
In-Reply-To: <fa73780d-b72b-6810-460e-5ed1057df093@arm.com>

Hi Alexandru,

On 1/6/21 5:32 PM, Alexandru Elisei wrote:
> Hi Eric,
> 
> On 12/12/20 6:50 PM, Eric Auger wrote:
>> KVM_DEV_ARM_VGIC_GRP_ADDR group doc says we should return
>> -EEXIST in case the base address of the redist is already set.
>> We currently return -EINVAL.
>>
>> However we need to return -EINVAL in case a legacy REDIST address
>> is attempted to be set while REDIST_REGIONS were set. This case
>> is discriminated by looking at the count field.
>>
>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>> ---
>>  arch/arm64/kvm/vgic/vgic-mmio-v3.c | 9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm64/kvm/vgic/vgic-mmio-v3.c b/arch/arm64/kvm/vgic/vgic-mmio-v3.c
>> index 15a6c98ee92f..8e8a862def76 100644
>> --- a/arch/arm64/kvm/vgic/vgic-mmio-v3.c
>> +++ b/arch/arm64/kvm/vgic/vgic-mmio-v3.c
>> @@ -792,8 +792,13 @@ static int vgic_v3_insert_redist_region(struct kvm *kvm, uint32_t index,
>>  	int ret;
>>  
>>  	/* single rdist region already set ?*/
>> -	if (!count && !list_empty(rd_regions))
>> -		return -EINVAL;
>> +	if (!count && !list_empty(rd_regions)) {
>> +		rdreg = list_last_entry(rd_regions,
>> +				       struct vgic_redist_region, list);
>> +		if (rdreg->count)
>> +			return -EINVAL; /* Mixing REDIST and REDIST_REGION API */
>> +		return -EEXIST;
>> +	}
> 
> A few instructions below:
> 
>     if (list_empty(rd_regions)) {
>         [..]
>     } else {
>         rdreg = list_last_entry(rd_regions,
>                     struct vgic_redist_region, list);
>         [..]
> 
>         /* Cannot add an explicitly sized regions after legacy region */
>         if (!rdreg->count)
>             return -EINVAL;
>     }
> 
> Isn't this testing for the same thing, but using the opposite condition? Or am I
> misunderstanding the code (quite likely)?
the 1st test sequence handles the case where the legacy
KVM_VGIC_V3_ADDR_TYPE_REDIST is used (!count) while the second handles
the case where the REDIST_REGION is used. Nevertheless I think this can
be simplified into:

        if (list_empty(rd_regions)) {
                if (index != 0)
                        return -EINVAL;
        } else {
                rdreg = list_last_entry(rd_regions,
                                        struct vgic_redist_region, list);

                if ((!count) != (!rdreg->count))
                        return -EINVAL; /* Mix REDIST and REDIST_REGION */

                if (!count)
                        return -EEXIST;

                if (index != rdreg->index + 1)
                        return -EINVAL;
        }






> 
> Looks to me like KVM_DEV_ARM_VGIC_GRP_ADDR(KVM_VGIC_V3_ADDR_TYPE_REDIST{,_REGION})
> used to return -EEXIST (from vgic_check_ioaddr()) before commit ccc27bf5be7b7
> ("KVM: arm/arm64: Helper to register a new redistributor region") which added the
> vgic_v3_insert_redist_region() function, so bringing back the -EEXIST return code
> looks the right thing to me.

OK thank you for the detailed study.

Eric
> 
> Thanks,
> Alex
>>  
>>  	/* cross the end of memory ? */
>>  	if (base + size < base)
> 


  reply	other threads:[~2021-01-14 10:04 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-12 18:50 [PATCH 0/9] KVM/ARM: Some vgic fixes and init sequence KVM selftests Eric Auger
2020-12-12 18:50 ` [PATCH 1/9] KVM: arm64: vgic-v3: Fix some error codes when setting RDIST base Eric Auger
2021-01-06 16:32   ` Alexandru Elisei
2021-01-14 10:02     ` Auger Eric [this message]
2020-12-12 18:50 ` [PATCH 2/9] KVM: arm64: Fix KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION read Eric Auger
2021-01-06 17:12   ` Alexandru Elisei
2021-01-13 17:18     ` Auger Eric
2020-12-12 18:50 ` [PATCH 3/9] KVM: arm64: vgic-v3: Fix error handling in vgic_v3_set_redist_base() Eric Auger
2020-12-28 15:35   ` Marc Zyngier
2021-01-13 17:18     ` Auger Eric
2020-12-12 18:50 ` [PATCH 4/9] KVM: arm/arm64: vgic: Reset base address on kvm_vgic_dist_destroy() Eric Auger
2020-12-28 15:41   ` Marc Zyngier
2021-01-13 17:18     ` Auger Eric
2020-12-12 18:50 ` [PATCH 5/9] KVM: arm: move has_run_once after the map_resources Eric Auger
2021-01-12 14:55   ` Alexandru Elisei
2021-01-14 10:02     ` Auger Eric
2021-01-20 15:56       ` Alexandru Elisei
2021-03-12 17:27         ` Auger Eric
2020-12-12 18:50 ` [PATCH 6/9] docs: kvm: devices/arm-vgic-v3: enhance KVM_DEV_ARM_VGIC_CTRL_INIT doc Eric Auger
2021-01-12 15:39   ` Alexandru Elisei
2021-01-13 17:18     ` Auger Eric
2020-12-12 18:50 ` [PATCH 7/9] KVM: arm64: Simplify argument passing to vgic_uaccess_[read|write] Eric Auger
2021-01-12 16:04   ` Alexandru Elisei
2021-01-12 16:16     ` Alexandru Elisei
2021-01-13 17:18       ` Auger Eric
2020-12-12 18:50 ` [PATCH 8/9] KVM: arm64: vgic-v3: Expose GICR_TYPER.Last for userspace Eric Auger
2021-01-12 17:02   ` Alexandru Elisei
2021-01-14 10:16     ` Auger Eric
2021-01-20 16:13       ` Alexandru Elisei
2021-03-12 17:26         ` Auger Eric
2021-01-12 17:28   ` Alexandru Elisei
2021-01-12 17:48     ` Marc Zyngier
2020-12-12 18:50 ` [PATCH 9/9] KVM: selftests: aarch64/vgic-v3 init sequence tests Eric Auger

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=e37f1942-dcb7-3579-0aba-e131e4bd9217@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=alexandru.elisei@arm.com \
    --cc=drjones@redhat.com \
    --cc=eric.auger.pro@gmail.com \
    --cc=james.morse@arm.com \
    --cc=julien.thierry.kdev@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=shuah@kernel.org \
    --cc=suzuki.poulose@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;
as well as URLs for NNTP newsgroup(s).