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

Re: [PATCH v2 3/4] xen/arm: its: refactor ITS quirk matching


  • To: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • From: Mykola Kvach <mykola_kvach@xxxxxxxx>
  • Date: Tue, 22 Sep 2026 17:05:47 +0300
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=b4BqyLrUmx+6dUteUQy3vicJ8GpvQFplSI25NlSF2sQ=; b=g5W846Q1lUGS3KuM6mBTqZuurzTyUPVzvibrWzQDtec0Ds7i0gRDo1054xJiLazadWq6f0EuwJyhlKSNJfGlOgeFCO1dhPCN2L+IUhyIuy9YUKCQoJudo+ytb9NkleGvAspTZTOVwL7iCPYApifD+KzpNS+X8rDrFrDqjzaMGKsT7Ndt5Oy66rCZWFdDpB3k4kiYjAY2yoGcyCykzK5clmhkV+nvlIJm8qcgB/AeVYCJ8UlueMvxylcGlILFF+ifhlJYXtZBtt1Aa/7y0IRkaYAJ2RfVbA5vw3yaWWTIhvdvgMrpeYChIwEPY1FpjJycCI8ZaiRtNtCbfb0j5mgNzQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Twa+XyxvDhk2wKCB+4leGMjDQrFWELofrhxeJyx1+pkFFfQUvnsOHUDYEvKmV0xsL7Xz6im6sZYwGwM/hqk3ghjiQso5RVUiWPM3jfxO9b8n2mw/D0yLnbJnlemYBZwYCqYZUyRDAmqtECAkYsjkN7YrAG8nI1lnh/gybHJcOqxQrCNqV2NcVeXN3dy2Jw8qOZv0iGGXyjfVz7jVUruBrIqtmkBM1eOU1h8+SDQwDPSnDiWAv1tqhMHodHb6O4khZA7vpnz82p+wZrk0nCOZSbrzNuCkjT6NCgjaCEZn5vTFw/1BPIeuMCi5Mgo5Ov5r7D/rvoFqS+VpZb+3EJD61g==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Mykola Kvach <xakep.amatop@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Luca Fancellu <luca.fancellu@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 22 Sep 2026 14:06:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Mail-followup-to: "Orzel, Michal" <michal.orzel@xxxxxxx>, Mykola Kvach <xakep.amatop@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Luca Fancellu <luca.fancellu@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>

On Fri, Jul 31, 2026 at 10:34:11AM +0200, Orzel, Michal wrote:
> 
> 
> On 28-May-26 02:25, Mykola Kvach wrote:
> > From: Mykola Kvach <mykola_kvach@xxxxxxxx>
> > 
> > ITS quirks are currently matched only by IIDR and mask fields stored in
> > each table entry. That is too coarse for integrations where the same GIC
> > IP block can appear in several platforms but the workaround is only valid
> > for a subset of boards.
> > 
> > Replace the fixed IIDR fields with a generic match(hw_its, data) callback
> > and an opaque data pointer. Add an IIDR matcher as a reusable building
> > block and use it from the R-Car Gen4 matcher after checking the Renesas
> > machine compatibles. The R-Car Gen4 platform refinement is DT-only;
> > ACPI-discovered ITSes do not match it.
> > 
> > Keep first-match semantics explicit. Assert that non-sentinel entries
> > provide a matcher and that IIDR matching receives match data, but keep
> > runtime guards so a malformed table entry does not become a NULL function
> > call or NULL data dereference in non-debug builds. The matched entry still
> > supplies separate ITS and LPI flags; this patch only changes how the entry
> > is selected.
> > 
> > Signed-off-by: Mykola Kvach <mykola_kvach@xxxxxxxx>
> > ---
> > Changes in v2:
> > - Replace v1's optional platform callback plus fixed IIDR/mask fields with
> >   a single generic match(hw_its, data) selector.
> > - Add a reusable IIDR matcher and use it after the R-Car Gen4
> >   machine-compatible checks.
> > - Document that the R-Car Gen4 quirk remains DT-only.
> > - Keep the split ITS and host LPI quirk scopes when applying the matched
> >   entry.
> > - Document first-match ordering in the lookup path and guard against
> >   entries without a match callback or IIDR match data.
> > ---
> >  xen/arch/arm/gic-v3-its.c | 67 +++++++++++++++++++++++++++++++--------
> >  1 file changed, 53 insertions(+), 14 deletions(-)
> > 
> > diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c
> > index dc48a84789..e055914763 100644
> > --- a/xen/arch/arm/gic-v3-its.c
> > +++ b/xen/arch/arm/gic-v3-its.c
> > @@ -53,8 +53,8 @@ struct its_device {
> >  
> >  struct its_quirk {
> >      const char *desc;
> > -    uint32_t iidr;
> > -    uint32_t mask;
> > +    bool (*match)(const struct host_its *hw_its, const void *data);
> > +    const void *data;
> >      uint32_t its_flags;
> >      /*
> >       * lpi_flags are ORed into the global host LPI policy and must only
> > @@ -64,11 +64,48 @@ struct its_quirk {
> >      uint32_t lpi_flags;
> >  };
> >  
> > +struct its_quirk_match_iidr {
> > +    uint32_t iidr;
> > +    uint32_t mask;
> > +};
> > +
> > +static bool __init gicv3_its_match_iidr(const struct host_its *hw_its,
> > +                                        const void *data)
> > +{
> > +    const struct its_quirk_match_iidr *match;
> > +    uint32_t iidr;
> > +
> > +    ASSERT(data);
> > +
> > +    match = data;
> > +    iidr = readl_relaxed(hw_its->its_base + GITS_IIDR);
> > +
> > +    return (iidr & match->mask) == match->iidr;
> The commit message says you keep a runtime guard so malformed table data
> does not become a NULL data dereference in non-debug builds, but there is
> no such guard - ASSERT() compiles out and match->mask is then read from
> NULL.

You're right: ASSERT() alone does not provide the guard described in
the commit message. I'll add an explicit NULL check before the IIDR
match data is dereferenced, so it also works in non-debug builds.

> 
> > +}
> > +
> > +static bool __init gicv3_its_match_quirk_gen4(const struct host_its 
> > *hw_its,
> > +                                              const void *data)
> > +{
> > +    if ( !hw_its->dt_node )
> > +        return false;
> > +
> > +    if ( !dt_machine_is_compatible("renesas,r8a779f0") &&
> > +         !dt_machine_is_compatible("renesas,r8a779g0") )
> Given that IIDR 0x0201743b is not Renesas-specific as you mention in the cover
> letter, this is a behavior changed and should be mentioned in the commit msg
> (cover letter is not in git).

I'll document the change from IIDR-only matching to platform-restricted
matching in the commit message, including its effect on ACPI and other
platforms.

> 
> > +        return false;
> > +
> > +    return gicv3_its_match_iidr(hw_its, data);
> > +}
> > +
> > +static const struct its_quirk_match_iidr rcar_gen4_iidr = {
> __initconst
> 
> > +    .iidr = 0x0201743b,
> > +    .mask = 0xffffffffU,
> > +};
> > +
> >  static const struct its_quirk its_quirks[] = {
> __initconstrel

I'll also mark the IIDR match data __initconst and the pointer-containing
quirk table __initconstrel.

Best regards,
Mykola



 


Rackspace

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