From: eric.auger@redhat.com (Auger Eric)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/8] KVM: arm/arm64: Make vgic_v3_check_base more broadly usable
Date: Mon, 8 May 2017 19:39:24 +0200 [thread overview]
Message-ID: <7e67fe6c-0956-ec03-d18c-d6e3c59b334a@redhat.com> (raw)
In-Reply-To: <20170508171849.GI28342@cbox>
Hi,
On 08/05/2017 19:18, Christoffer Dall wrote:
> On Mon, May 08, 2017 at 06:13:01PM +0200, Auger Eric wrote:
>> Hi Christoffer,
>>
>> On 08/05/2017 13:54, Christoffer Dall wrote:
>>> As we are about to fiddle with the io device registration mechanism
>>> let's be a little more careful in verifying the addresses we can ealier
>>> on to provide error messages to the user at time related to him/her
>>> setting overlapping addresses.
>> Above sentence would need some rewording.
>> We still want to check a consistent
>
> indeed :)
>
>>> system before actually running the VM for the first time, so we make
>>> vgic_v3_check_base available in the core vgic-v3 code as well as in the
>>> other parts of the GICv3 code, namely the MMIO config code.
>>>
>>> We also return true for undefined base addresses so that the function
>>> can be used before all base addresses are set; all callers already check
>>> for uninitialized addresses before calling this function.
>>>
>>> Signed-off-by: Christoffer Dall <cdall@linaro.org>
>>> ---
>>> virt/kvm/arm/vgic/vgic-v3.c | 18 ++++++++++++++----
>>> virt/kvm/arm/vgic/vgic.h | 1 +
>>> 2 files changed, 15 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
>>> index 12e52a0..b934e78 100644
>>> --- a/virt/kvm/arm/vgic/vgic-v3.c
>>> +++ b/virt/kvm/arm/vgic/vgic-v3.c
>>> @@ -329,19 +329,29 @@ int vgic_v3_save_pending_tables(struct kvm *kvm)
>>> return 0;
>>> }
>>>
>>> -/* check for overlapping regions and for regions crossing the end of memory */
>>> -static bool vgic_v3_check_base(struct kvm *kvm)
>>> +/*
>>> + * Check for overlapping regions and for regions crossing the end of memory
>>> + * for base addresses which have already been set.
>>> + */
>>> +bool vgic_v3_check_base(struct kvm *kvm)
>>> {
>>> struct vgic_dist *d = &kvm->arch.vgic;
>>> gpa_t redist_size = KVM_VGIC_V3_REDIST_SIZE;
>>>
>>> redist_size *= atomic_read(&kvm->online_vcpus);
>>>
>>> - if (d->vgic_dist_base + KVM_VGIC_V3_DIST_SIZE < d->vgic_dist_base)
>>> + if (!IS_VGIC_ADDR_UNDEF(d->vgic_dist_base) &&
>>> + d->vgic_dist_base + KVM_VGIC_V3_DIST_SIZE < d->vgic_dist_base)
>>> return false;
>>> - if (d->vgic_redist_base + redist_size < d->vgic_redist_base)
>>> +
>>> + if (!IS_VGIC_ADDR_UNDEF(d->vgic_redist_base) &&
>>> + d->vgic_redist_base + redist_size < d->vgic_redist_base)
>>> return false;
>>>
>>> + if (IS_VGIC_ADDR_UNDEF(d->vgic_dist_base) &&
>>> + IS_VGIC_ADDR_UNDEF(d->vgic_redist_base))
>>> + return true;
>>> +
>>> if (d->vgic_dist_base + KVM_VGIC_V3_DIST_SIZE <= d->vgic_redist_base)
>>> return true;
>> It is unclear to me if the dunction can be called if either of the
>> address is unset?
>
> Yes, it can be called if both addreses are unset, in which case you'll
> get a positive result. If a single address is set, we cannot check
> interaction between the two addresses, but we can check the requirements
> for the single address, and the interaction must be checked later.
Although unlikely can't you have the redist_base set at 0x0 and
dist_base unset. Wouldn't this return false?
Thanks
Eric
>
> Thanks,
> -Christoffer
>
>>> if (d->vgic_redist_base + redist_size <= d->vgic_dist_base)
>>> diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h
>>> index a2aeaa8..89eb935 100644
>>> --- a/virt/kvm/arm/vgic/vgic.h
>>> +++ b/virt/kvm/arm/vgic/vgic.h
>>> @@ -175,6 +175,7 @@ int vgic_v3_map_resources(struct kvm *kvm);
>>> int vgic_v3_lpi_sync_pending_status(struct kvm *kvm, struct vgic_irq *irq);
>>> int vgic_v3_save_pending_tables(struct kvm *kvm);
>>> int vgic_register_redist_iodevs(struct kvm *kvm);
>>> +bool vgic_v3_check_base(struct kvm *kvm);
>>>
>>> void vgic_v3_load(struct kvm_vcpu *vcpu);
>>> void vgic_v3_put(struct kvm_vcpu *vcpu);
>>>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
next prev parent reply other threads:[~2017-05-08 17:39 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 [this message]
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 ` [PATCH 8/8] KVM: arm/arm64: vgic-its: Cleanup after failed ITT restore Christoffer Dall
2017-05-08 17:20 ` 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=7e67fe6c-0956-ec03-d18c-d6e3c59b334a@redhat.com \
--to=eric.auger@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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).