kvmarm.lists.cs.columbia.edu archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Eric Auger <eric.auger@redhat.com>
Cc: kvm@vger.kernel.org, shuah@kernel.org,
	linux-kernel@vger.kernel.org, pbonzini@redhat.com,
	kvmarm@lists.cs.columbia.edu, eric.auger.pro@gmail.com
Subject: Re: [PATCH v5 7/8] KVM: arm64: vgic-v3: Expose GICR_TYPER.Last for userspace
Date: Mon, 05 Apr 2021 11:10:18 +0100	[thread overview]
Message-ID: <878s5xf3ed.wl-maz@kernel.org> (raw)
In-Reply-To: <20210404172243.504309-8-eric.auger@redhat.com>

On Sun, 04 Apr 2021 18:22:42 +0100,
Eric Auger <eric.auger@redhat.com> wrote:
> 
> Commit 23bde34771f1 ("KVM: arm64: vgic-v3: Drop the
> reporting of GICR_TYPER.Last for userspace") temporarily fixed
> a bug identified when attempting to access the GICR_TYPER
> register before the redistributor region setting, but dropped
> the support of the LAST bit.
> 
> Emulating the GICR_TYPER.Last bit still makes sense for
> architecture compliance though. This patch restores its support
> (if the redistributor region was set) while keeping the code safe.
> 
> We introduce a new helper, vgic_mmio_vcpu_rdist_is_last() which
> computes whether a redistributor is the highest one of a series
> of redistributor contributor pages.
> 
> With this new implementation we do not need to have a uaccess
> read accessor anymore.
> 
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> 
> ---
> 
> v4 -> v5:
> - redist region list now is sorted by @base
> - change the implementation according to Marc's understanding of
>   the spec
> ---
>  arch/arm64/kvm/vgic/vgic-mmio-v3.c | 58 +++++++++++++++++-------------
>  include/kvm/arm_vgic.h             |  1 +
>  2 files changed, 34 insertions(+), 25 deletions(-)
> 
> diff --git a/arch/arm64/kvm/vgic/vgic-mmio-v3.c b/arch/arm64/kvm/vgic/vgic-mmio-v3.c
> index e1ed0c5a8eaa..03a253785700 100644
> --- a/arch/arm64/kvm/vgic/vgic-mmio-v3.c
> +++ b/arch/arm64/kvm/vgic/vgic-mmio-v3.c
> @@ -251,45 +251,52 @@ static void vgic_mmio_write_v3r_ctlr(struct kvm_vcpu *vcpu,
>  		vgic_enable_lpis(vcpu);
>  }
>  
> +static bool vgic_mmio_vcpu_rdist_is_last(struct kvm_vcpu *vcpu)
> +{
> +	struct vgic_dist *vgic = &vcpu->kvm->arch.vgic;
> +	struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
> +	struct vgic_redist_region *iter, *rdreg = vgic_cpu->rdreg;
> +
> +	if (!rdreg)
> +		return false;
> +
> +	if (vgic_cpu->rdreg_index < rdreg->free_index - 1) {
> +		return false;
> +	} else if (rdreg->count && vgic_cpu->rdreg_index == (rdreg->count - 1)) {
> +		struct list_head *rd_regions = &vgic->rd_regions;
> +		gpa_t end = rdreg->base + rdreg->count * KVM_VGIC_V3_REDIST_SIZE;
> +
> +		/*
> +		 * the rdist is the last one of the redist region,
> +		 * check whether there is no other contiguous rdist region
> +		 */
> +		list_for_each_entry(iter, rd_regions, list) {
> +			if (iter->base == end && iter->free_index > 0)
> +				return false;
> +		}

In the above notes, you state that the region list is now sorted by
base address, but I really can't see what sorts that list. And the
lines above indicate that you are still iterating over the whole RD
regions.

It's not a big deal (the code is now simple enough), but that's just
to confirm that I understand what is going on here.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-04 17:22 [PATCH v5 0/8] KVM/ARM: Some vgic fixes and init sequence KVM selftests Eric Auger
2021-04-04 17:22 ` [PATCH v5 1/8] KVM: arm64: Fix KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION read Eric Auger
2021-04-04 17:22 ` [PATCH v5 2/8] KVM: arm64: vgic-v3: Fix error handling in vgic_v3_set_redist_base() Eric Auger
2021-04-04 17:22 ` [PATCH v5 3/8] KVM: arm/arm64: vgic: Reset base address on kvm_vgic_dist_destroy() Eric Auger
2021-04-04 17:22 ` [PATCH v5 4/8] docs: kvm: devices/arm-vgic-v3: enhance KVM_DEV_ARM_VGIC_CTRL_INIT doc Eric Auger
2021-04-04 17:22 ` [PATCH v5 5/8] KVM: arm64: Simplify argument passing to vgic_uaccess_[read|write] Eric Auger
2021-04-04 17:22 ` [PATCH v5 6/8] kvm: arm64: vgic-v3: Introduce vgic_v3_free_redist_region() Eric Auger
2021-04-04 17:22 ` [PATCH v5 7/8] KVM: arm64: vgic-v3: Expose GICR_TYPER.Last for userspace Eric Auger
2021-04-05 10:10   ` Marc Zyngier [this message]
2021-04-05 16:27     ` Auger Eric
2021-04-04 17:22 ` [PATCH v5 8/8] KVM: selftests: aarch64/vgic-v3 init sequence tests Eric Auger
2021-04-05 10:12 ` [PATCH v5 0/8] KVM/ARM: Some vgic fixes and init sequence KVM selftests Marc Zyngier
2021-04-05 16:30   ` 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=878s5xf3ed.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=eric.auger.pro@gmail.com \
    --cc=eric.auger@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=shuah@kernel.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).