[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen/arm: vgic: fix INTID calculation in GICv2 SGIPENDR handlers


  • To: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>
  • From: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • Date: Fri, 4 Dec 2026 11:04:44 +0200
  • Arc-authentication-results: i=1; mx.google.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ZG0EUgIkin7YkeHfc5+Bl4Yvgs3CmIbUj396QQsLduw=; fh=GldZTi0KZp1II6NZj18WzQVesZ+tJW4FCIWi3p8dyT8=; b=gf/wbsqZ3Ms4jen5S92yALJl/gF+khzV6Wltaxw7qOokZjbDwrB7sXoMWdDE325GI0 My40KnF8WWXmKjYNTplod2zqAEog8XY9pp+5BWBw0UqDF6HWsgKisXvUzNcBHY6nuBPK 7Ir0blIgJ3BkNpkg4NQ25l5LZKKkwhV+jZIkqb+SFsFJpUo0sA2J3g5Y0ZTF2lXQ6ItN Rko0OV439N7KCZZw3jaopkBGTU22FB6ARj7676sBzKsCXHhK24w/X0sofRMw7+6cTu1f re0d9/Cv8ZyzAhLkBlBNERVtyVTmMLUkQxIqLzK4GRklS0bY47UsXPuFaTCetNmmyqJN 3N0g==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1796375096; cv=none; d=google.com; s=arc-20260327; b=d1Ds9bajgWBN1+GWo6CgV3IIxCoAU1vyIK14GBWJ5L2PXYc/VVP3chYSEwLAZ6LLD0 LoVL/5Vv9LcxA94O3DymUXrQURQ0n6amzZxDasjtvCqClJtRgOdlZsO/vLRFikhV6D/x khgPsWAxcDKlUbBbumIlU3eLm8WzqXEVG7v/Ou0Ezs0kaFpTI4CSQaGt/Hyex07MuTKz u01+UG/gd9MuSL+xChcRM0QJTptyzziV58b7SdebP7ml5u5j+zRAjBqPIEJerMId5XFB ccT4ksUe50/6PL/DH7XwkMPEXU+3fZegy3xAjw3JBT2+c/PYJj+UNggX/DgNP088E6ty 1U2w==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
  • Cc: Mykola Kvach <Mykola_Kvach@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Xen-devel <xen-devel-bounces@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 04 Dec 2026 09:05:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Mykyta,

Thank you for the reviiew.

On Fri, Dec 4, 2026 at 10:57 AM Mykyta Poturai <Mykyta_Poturai@xxxxxxxx> wrote:
>
> 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?

I see no reason for a new macro here: this matches Linux KVM, which
makes comparing the two implementations easier, and the same file
already open-codes addr & 0x0c in vgic_mmio_{read,write}_v2_misc().

Best regards,
Mykola

>
> >      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++ )
> >      {
>



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.