|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] xen/arm: vgic: fix INTID calculation in GICv2 SGIPENDR handlers
On Fri Dec 4, 2026 at 2:51 AM EET, Mykola Kvach wrote:
> GICD_CPENDSGIR (0xf10) and GICD_SPENDSGIR (0xf20) are 16-byte aligned
> regions for SGIs 0..15. However, vgic_mmio_read_sgipend(),
> vgic_mmio_write_sgipendc(), and vgic_mmio_write_sgipends() use
> VGIC_ADDR_TO_INTID(addr, 8), which masks addr with 0x3ff. Because addr
> is a full guest physical address, this gives INTIDs 784..815 instead
> of 0..15.
>
> As a result, any guest access hits ASSERT(intid < VGIC_NR_SGIS) in
> debug builds, or accesses wrong or out-of-bounds entries in
> d->arch.vgic.spis[] in release builds.
>
> Mask addr with 0x0fU instead (as in Linux KVM) and check
> intid + len <= VGIC_NR_SGIS in the assertions.
>
> Fixes: a11452f2d330 ("ARM: new VGIC: Add SGIPENDR register handlers")
> Assisted-by: Antigravity:gemini-4-neon
> Signed-off-by: Mykola Kvach <mykola_kvach@xxxxxxxx>
> ---
> xen/arch/arm/vgic/vgic-mmio-v2.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/xen/arch/arm/vgic/vgic-mmio-v2.c
> b/xen/arch/arm/vgic/vgic-mmio-v2.c
> index fc04741ca1..c1bf7da04d 100644
> --- a/xen/arch/arm/vgic/vgic-mmio-v2.c
> +++ b/xen/arch/arm/vgic/vgic-mmio-v2.c
> @@ -183,11 +183,11 @@ static void vgic_mmio_write_target(struct vcpu *vcpu,
> static unsigned long vgic_mmio_read_sgipend(struct vcpu *vcpu,
> paddr_t addr, unsigned int len)
> {
> - uint32_t intid = VGIC_ADDR_TO_INTID(addr, 8);
> + uint32_t intid = addr & 0x0fU;
Maybe it would be better to add a new macro for this instead of
open-coding a constant 3 times?
> uint32_t val = 0;
> unsigned int i;
>
> - ASSERT(intid < VGIC_NR_SGIS);
> + ASSERT(intid + len <= VGIC_NR_SGIS);
>
> for ( i = 0; i < len; i++ )
> {
> @@ -205,11 +205,11 @@ static void vgic_mmio_write_sgipendc(struct vcpu *vcpu,
> paddr_t addr, unsigned int len,
> unsigned long val)
> {
> - uint32_t intid = VGIC_ADDR_TO_INTID(addr, 8);
> + uint32_t intid = addr & 0x0fU;
> unsigned int i;
> unsigned long flags;
>
> - ASSERT(intid < VGIC_NR_SGIS);
> + ASSERT(intid + len <= VGIC_NR_SGIS);
>
> for ( i = 0; i < len; i++ )
> {
> @@ -230,11 +230,11 @@ static void vgic_mmio_write_sgipends(struct vcpu *vcpu,
> paddr_t addr, unsigned int len,
> unsigned long val)
> {
> - uint32_t intid = VGIC_ADDR_TO_INTID(addr, 8);
> + uint32_t intid = addr & 0x0fU;
> unsigned int i;
> unsigned long flags;
>
> - ASSERT(intid < VGIC_NR_SGIS);
> + ASSERT(intid + len <= VGIC_NR_SGIS);
>
> for ( i = 0; i < len; i++ )
> {
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |