Hi Penny,
On 23/09/2021 08:11, Penny Zheng wrote:
> From: Stefano Stabellini <stefano.stabellini@xilinx.com>
>
> Add a field in struct vgic_dist to store the cpu interface base address,
> similar to the existing dbase field.
>
> Use the field in vgic_v2_domain_init, instead of original local variable.
Please explain in the commit message why this is necessary.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
> Signed-off-by: Penny Zheng <penny.zheng@arm.com>
> ---
> xen/arch/arm/vgic-v2.c | 10 +++++-----
> xen/include/asm-arm/vgic.h | 1 +
> 2 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c
> index b2da886adc..b34ec88106 100644
> --- a/xen/arch/arm/vgic-v2.c
> +++ b/xen/arch/arm/vgic-v2.c
> @@ -652,7 +652,7 @@ static int vgic_v2_vcpu_init(struct vcpu *v)
> static int vgic_v2_domain_init(struct domain *d)
> {
> int ret;
> - paddr_t cbase, csize;
> + paddr_t csize;
> paddr_t vbase;
>
> /*
> @@ -669,7 +669,7 @@ static int vgic_v2_domain_init(struct domain *d)
> * Note that we assume the size of the CPU interface is always
> * aligned to PAGE_SIZE.
> */
> - cbase = vgic_v2_hw.cbase;
> + d->arch.vgic.cbase = vgic_v2_hw.cbase;
> csize = vgic_v2_hw.csize;
> vbase = vgic_v2_hw.vbase;
> }
> @@ -683,7 +683,7 @@ static int vgic_v2_domain_init(struct domain *d)
> * region.
> */
> BUILD_BUG_ON(GUEST_GICC_SIZE != SZ_8K);
> - cbase = GUEST_GICC_BASE;
> + d->arch.vgic.cbase = GUEST_GICC_BASE;
> csize = GUEST_GICC_SIZE;
Shouldn't we also stash d->arch.vgic.csize?
> vbase = vgic_v2_hw.vbase + vgic_v2_hw.aliased_offset;
> }
> @@ -692,8 +692,8 @@ static int vgic_v2_domain_init(struct domain *d)
> * Map the gic virtual cpu interface in the gic cpu interface
> * region of the guest.
> */
> - ret = map_mmio_regions(d, gaddr_to_gfn(cbase), csize / PAGE_SIZE,
> - maddr_to_mfn(vbase));
> + ret = map_mmio_regions(d, gaddr_to_gfn(d->arch.vgic.cbase),
> + csize / PAGE_SIZE, maddr_to_mfn(vbase));
> if ( ret )
> return ret;
>
> diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h
> index e1bc5113da..d5ad1f387b 100644
> --- a/xen/include/asm-arm/vgic.h
> +++ b/xen/include/asm-arm/vgic.h
> @@ -152,6 +152,7 @@ struct vgic_dist {
> struct pending_irq *pending_irqs;
> /* Base address for guest GIC */
> paddr_t dbase; /* Distributor base address */
> + paddr_t cbase; /* CPU interface base address */
> #ifdef CONFIG_GICV3
> /* GIC V3 addressing */
> /* List of contiguous occupied by the redistributors */
>
Cheers,
--
Julien Grall