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

Re: [PATCH v2] arm/gicv3: Decode cacheability fields before comparing


  • To: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • From: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • Date: Thu, 23 Apr 2026 09:02:14 +0300
  • 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-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=nl7cIH8Ft8KrXNepYu/GHtaIZIBfWGZDLBrbsxutfCw=; fh=lnG/EjedhIb/IfplijZjNTuDmIWktIpSdwgeAb6fZ6k=; b=jbpoR02C0gU/a8MID/XbWgmKf2vUNWApjWe5n/BomRt6QsEOWWRxjCRGlkFPLk3xE+ OEhaliE0CWOzHKB6U4qXlB7zMbN6X9bTnVzK9aYj7dEC4kX09o/o41hnhKg4ZhPoJG9m quYEtYWm7Vk7Q0otzCeipcvLCOCYRIYyE94+YI7QZAWrCEsr+9s3hQ+g7f9KN7l7fDXv mYELhnIRIpFnjGOqJi5zfYFy1YHK7KTnxIOc2pceLhfPsBZ/uLxV7rEVEHTw9azYK49V r50FIdzdpSMo+BUHnvGOMM8K1C1IBJM8MMwVQ3LLfLA0Cc1end7ezNz0+6DzMEE1Q5ZZ Vi2w==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1776924146; cv=none; d=google.com; s=arc-20240605; b=hMjEb9weXROHPQM+rmOR0GGi+G+PlD/iR4jEFGYoStG39xChCalN0g7aSzGnGex836 Bvi9Mf7gVK1MKh/pwPBu71pTHj1x0ISWQWptMi89Wabt+JIk7bBNiQ/qOoaOVcFi/vYc janWTv+nTRLGCxJnh7M1tEw+yWnou/FItNG4dVPQFy6C932mS2sl0S0ANZVkjF6YHncq ySDgiIprtf/O4wAJ0NWTnO1zNI5Y2Bs8y3vvLfXjs/k3xDw3E+RQvxhvwkFf0Md2We4C OgzmQzzPT7DR2qRu2aP0Bbe8ks2rgkGpOX5s6ZIbOOYv1XRAl5EpepEar0kmLkRhPDnT D9lw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Mykola Kvach <mykola_kvach@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Mykyta Poturai <mykyta_poturai@xxxxxxxx>
  • Delivery-date: Thu, 23 Apr 2026 06:02:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Michal,

Thank you for the review.

On Mon, Apr 13, 2026 at 12:28 PM Orzel, Michal <michal.orzel@xxxxxxx> wrote:
>
>
>
> On 10/04/2026 19:34, Mykola Kvach wrote:
> > From: Mykola Kvach <mykola_kvach@xxxxxxxx>
> >
> > GITS_BASER_INNER_CACHEABILITY_MASK and
> > GICR_PROPBASER_INNER_CACHEABILITY_MASK are shifted masks. Comparing the
> > masked but unshifted values against GIC_BASER_CACHE_nC, which is an
> > unshifted enum value, leads to incorrect detection of non-cacheable
> > GITS_CBASER command queue, GITS_BASER tables, and GICR_PROPBASER
> > mappings.
> >
> > Use MASK_EXTR() to decode these cacheability fields before comparing
> > against GIC_BASER_CACHE_nC, so the backing memory is flushed when
> > required.
> >
> > Fixes: 8ed8d21373be ("ARM: GICv3 ITS: map ITS command buffer")
> > Fixes: 05238012b86d ("ARM: GICv3 ITS: allocate device and collection table")
> > Fixes: c9b939863c89 ("ARM: GICv3: allocate LPI pending and property table")
> > Signed-off-by: Mykyta Poturai <mykyta_poturai@xxxxxxxx>
> > Signed-off-by: Mykola Kvach <mykola_kvach@xxxxxxxx>
> > ---
> > Changes in v2:
> > - use MASK_EXTR() instead of open-coding the BASER field shift
> > - fix the analogous PROPBASER cacheability comparison in
> >   gicv3_lpi_set_proptable()
> > - fix the CBASER command queue cacheability check as well
> > ---
> >  xen/arch/arm/gic-v3-its.c | 6 ++++--
> >  xen/arch/arm/gic-v3-lpi.c | 3 ++-
> >  2 files changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c
> > index 9ba068c46f..e87465d2ff 100644
> > --- a/xen/arch/arm/gic-v3-its.c
> > +++ b/xen/arch/arm/gic-v3-its.c
> > @@ -424,7 +424,8 @@ static void *its_map_cbaser(struct host_its *its)
> >       * If the command queue memory is mapped as uncached, we need to flush
> >       * it on every access.
> >       */
> > -    if ( !(reg & GITS_BASER_INNER_CACHEABILITY_MASK) )
> You don't seem to mention this change. This one does not compare to
> GIC_BASER_CACHE_nC and checks against 0, which means we are on the safe side. 
> If
> you still want to change it, then you should also look few lines above where 
> we
> have:
> if ( (reg & GITS_BASER_SHAREABILITY_MASK) == 0 )
>
> > +    if ( MASK_EXTR(reg, GITS_BASER_INNER_CACHEABILITY_MASK) <=
> > +         GIC_BASER_CACHE_nC )
> This is a functional change. Previously we where comparing against 0 and now 
> you
> compare against <= 1

You are right, the CBASER hunk is not fixing the same shifted-mask
comparison bug as the BASER/PROPBASER hunks.

My intention was to also handle InnerCache == 0b001, which is Normal
Inner Non-cacheable, so the command queue should need flushing in that
case as well. I agree this is a separate functional change.

I will drop the CBASER hunk from this patch to keep it focused on the
BASER/PROPBASER shifted-mask fix. I will send the CBASER change
separately with a dedicated explanation.

Best regards,
Mykola

>
> ~Michal
>
> >      {
> >          its->flags |= HOST_ITS_FLUSH_CMD_QUEUE;
> >          printk(XENLOG_WARNING "using non-cacheable ITS command queue\n");
> > @@ -496,7 +497,8 @@ retry:
> >          }
> >          attr = regc & BASER_ATTR_MASK;
> >      }
> > -    if ( (regc & GITS_BASER_INNER_CACHEABILITY_MASK) <= GIC_BASER_CACHE_nC 
> > )
> > +    if ( MASK_EXTR(regc, GITS_BASER_INNER_CACHEABILITY_MASK) <=
> > +         GIC_BASER_CACHE_nC )
> >          clean_and_invalidate_dcache_va_range(buffer, table_size);
> >
> >      /* If the host accepted our page size, we are done. */
> > diff --git a/xen/arch/arm/gic-v3-lpi.c b/xen/arch/arm/gic-v3-lpi.c
> > index de5052e5cf..9ee338edc2 100644
> > --- a/xen/arch/arm/gic-v3-lpi.c
> > +++ b/xen/arch/arm/gic-v3-lpi.c
> > @@ -351,7 +351,8 @@ static int gicv3_lpi_set_proptable(void __iomem * 
> > rdist_base)
> >      }
> >
> >      /* Remember that we have to flush the property table if non-cacheable. 
> > */
> > -    if ( (reg & GICR_PROPBASER_INNER_CACHEABILITY_MASK) <= 
> > GIC_BASER_CACHE_nC )
> > +    if ( MASK_EXTR(reg, GICR_PROPBASER_INNER_CACHEABILITY_MASK) <=
> > +         GIC_BASER_CACHE_nC )
> >      {
> >          lpi_data.flags |= LPI_PROPTABLE_NEEDS_FLUSHING;
> >          /* Update the redistributors knowledge about the attributes. */
>



 


Rackspace

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