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

Re: [RFC PATCH v2] xen/arm: select GIC interrupt priorities at boot


  • To: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>
  • From: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • Date: Tue, 1 Dec 2026 23:50:40 +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=o8CeMvvI9MySjiWZRTBp69DmBlHVCsTzbOPilx5/Qf0=; fh=NF592IdqE4/KKY6mLHrjnxDP5rSh0BSXn/Arec+Id+o=; b=EkJfLnc9W3gU4Hi/deqj6QXJsFU8CwkngdiNy0LHBpOngbieJ5wmoPaV4bBIxnBsmh KLGoeJxb4kzrViuaG7InMBgM4Cshn1YwT+MqgLSMN06WdRq7r3tGSLzUhJxMq8yDvlYq PCFJpDWZfO/jqcEhp6kwPEZDWPPYSQ+C/8xZP2Lmu5GUrBgEJj/k0O8kbcqXg9FOFqfT omojvTo88xMjsx/KWO7tDCREx/VrFM75wX6eh4+oZ1gIj4ikLEBULFBlFoniF3DYfb9P h6Q8RWENQyCOBxR0jcrZ0HsZv7hK7EAxCzu2iQX+XtYOJUsa/fEN2cZ11ohGT3VhflyP +13Q==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1796161852; cv=none; d=google.com; s=arc-20260327; b=pDH2jKv631cqWl2GrxZf+PT9WWuou1pPLRnzHYFPd3OqSqklJXtUS2Z5Rmpz8Beq9N UPc3O52YO9x+aHQ75ZA5bITBH+dlrbe3Sb7sZFL9SdVCeASKpOUqaUwCNv506pjOrUWi 9iP2CZPICAlaq9VkhtwjTI0iC0X4+YAY2J5Pq1MuwwNJ/L0FRMsGFTmJyxQ1MRwSVMDJ 74aziQ6fucfUhv3iay+1yQMMBmCpb+I5cL1qcYBGsu9YesRkNH5PQ83Kzt5QaxoP8hzx hF63ysWjvYVukoxLBgWgi8yrSG+hRYuCjowX1ZlFq7/ek5PRZjAosAwICEUsYEcpOpfw 9oeg==
  • 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>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, "ayan.kumar.halder | Guest" <ayan.kumar.halder@xxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Xen-devel <xen-devel-bounces@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 01 Dec 2026 21:51:08 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Mykyta,

Thank you for the review.

On Tue, Dec 1, 2026 at 11:02 AM Mykyta Poturai <Mykyta_Poturai@xxxxxxxx> wrote:
>
> On Fri Nov 20, 2026 at 3:10 PM EET, Mykola Kvach wrote:
> > Add boot parameters for ordinary IRQs, dynamic SGIs and Xen IPIs so
> > platforms can give an FF-A notification SGI higher priority than device
> > IRQs. Keep the defaults of 0xa0 for IRQs and dynamic SGIs and 0x90 for
> > IPIs.
> >
> > An IRQ handler can wait for an IPI in on_selected_cpus(), so internal
> > IPIs must be able to preempt ordinary IRQs. Warn when a dynamic SGI is
> > registered at IPI priority or higher.
> >
> > Signed-off-by: Mykola Kvach <mykola_kvach@xxxxxxxx>
> > ---
> > Changes in v2:
> > - Keep dynamic SGIs at 0xa0 by default. v1 used 0x90.
> > - Add boot parameters for all three classes, as Bertrand suggested.
> > - Warn once for a dynamic SGI at IPI priority or higher.
> >
> > Original patch and review:
> > https://lore.kernel.org/xen-devel/f7475c0083bf4995f2ec4afa3aaf44b9676fd1ab.1756867760.git.mykola_kvach@xxxxxxxx/
> >
> > Would these three priority classes cover the real-time use case, or does
> > an individual interrupt need its own priority?
> >
> > Level 0 programs 0xf0. With four effective priority bits, this can mask
> > the whole class, including timer PPIs for gic-pri-irq=0. Should Xen
> > expose level 0 on these systems?
> >
> > If EL3 selects a common binary point, different IRQ and IPI levels can
> > share a preemption group. Should Xen check the effective groups?
> > ---
> >  docs/misc/xen-command-line.pandoc | 16 +++++++++++++
> >  xen/arch/arm/gic.c                | 38 +++++++++++++++++++++++++++++++
> >  xen/arch/arm/include/asm/gic.h    | 23 +++++++++++++------
> >  xen/arch/arm/irq.c                | 14 +++++++++++-
> >  4 files changed, 83 insertions(+), 8 deletions(-)
> >
> > diff --git a/docs/misc/xen-command-line.pandoc 
> > b/docs/misc/xen-command-line.pandoc
> > index 
> > a6f08463d177686cddd718437b29013273bf0468..0d2fb5ef6379a3d5d6f7814c7c3b72863e2c4803
> >  100644
> > --- a/docs/misc/xen-command-line.pandoc
> > +++ b/docs/misc/xen-command-line.pandoc
> > @@ -1283,6 +1283,22 @@ available on Intel Panther Lake and Diamond Rapids 
> > CPUs, and AMD Zen6 CPUs.
> >  FRED is fully supported on AMD hardware.  On Intel hardware it is still 
> > tech
> >  preview, and in particular not security supported.
> >
> > +### gic-pri-irq, gic-pri-sgi, gic-pri-ipi (arm)
> > +> `= <integer>`
> > +
> > +> Default: `gic-pri-irq=5 gic-pri-sgi=5 gic-pri-ipi=6`
> > +
> > +Set the physical GIC priority for ordinary IRQs, dynamically requested SGIs
> > +and Xen's internal IPIs, respectively. Ordinary IRQs include Xen's timer
> > +PPIs, physical SPIs routed to guests and physical LPIs. Choose levels
> > +that let internal IPIs preempt ordinary IRQs.
> > +
> > +Levels 0 (lowest) through 7 (highest) program GIC priorities from `0xf0`
> > +to `0x80`, in steps of `0x10`. The GIC delivers an interrupt only
> > +if its priority is higher than the effective priority mask. Depending on
> > +the implemented priority bits, the mask can block level 0. This can stop
> > +Xen's timer interrupts when `gic-pri-irq=0`.
> > +
> >  ### gic-test (arm)
> >  > `= <boolean>`
> >
> > diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
> > index 
> > c4bda435bd61f696ff3170ed1d9e5ec3b4a0f5de..99dc5eb8254d13452a4aca717cf787e0c078bfa4
> >  100644
> > --- a/xen/arch/arm/gic.c
> > +++ b/xen/arch/arm/gic.c
> > @@ -14,6 +14,7 @@
> >  #include <xen/irq.h>
> >  #include <xen/sched.h>
> >  #include <xen/errno.h>
> > +#include <xen/param.h>
> >  #include <xen/softirq.h>
> >  #include <xen/list.h>
> >  #include <xen/device_tree.h>
> > @@ -35,6 +36,43 @@ DEFINE_PER_CPU(uint64_t, lr_mask);
> >
> >  const struct gic_hw_operations *gic_hw_ops;
> >
> > +#define GIC_PRI_LEVEL(level) (GIC_PRI_LOWEST - ((level) * 0x10U))
> > +
> > +unsigned int __ro_after_init gic_pri_irq = GIC_PRI_LEVEL(5U);
> > +unsigned int __ro_after_init gic_pri_sgi = GIC_PRI_LEVEL(5U);
> > +unsigned int __ro_after_init gic_pri_ipi = GIC_PRI_LEVEL(6U);
> > +
> > +static int __init parse_gic_pri(const char *s, unsigned int *priority)
> > +{
> > +    const char *end;
> > +    unsigned long level = simple_strtoul(s, &end, 0);
> > +
> > +    if ( end == s || *end || level > 7 )
> > +        return -EINVAL;
> > +
> > +    *priority = GIC_PRI_LEVEL((unsigned int)level);
> > +
> > +    return 0;
> > +}
> > +
> > +static int __init cf_check parse_gic_pri_irq(const char *s)
> > +{
> > +    return parse_gic_pri(s, &gic_pri_irq);
> > +}
> > +custom_param("gic-pri-irq", parse_gic_pri_irq);
> > +
> > +static int __init cf_check parse_gic_pri_sgi(const char *s)
> > +{
> > +    return parse_gic_pri(s, &gic_pri_sgi);
> > +}
> > +custom_param("gic-pri-sgi", parse_gic_pri_sgi);
> > +
> > +static int __init cf_check parse_gic_pri_ipi(const char *s)
> > +{
> > +    return parse_gic_pri(s, &gic_pri_ipi);
> > +}
> > +custom_param("gic-pri-ipi", parse_gic_pri_ipi);
> > +
> >  static void __init __maybe_unused build_assertions(void)
> >  {
> >      /* Check our enum gic_sgi only covers SGIs */
> > diff --git a/xen/arch/arm/include/asm/gic.h b/xen/arch/arm/include/asm/gic.h
> > index 
> > 7ceae49774bf29e1dedc6c223c30a16265b53275..0883d5c66133cd198f6281dc6bb4968698f642ff
> >  100644
> > --- a/xen/arch/arm/include/asm/gic.h
> > +++ b/xen/arch/arm/include/asm/gic.h
> > @@ -153,7 +153,8 @@
> >   * GICC_BPR to 0 but we must expect that it might be 3. This means we
> >   * can rely on preemption between the following ranges:
> >   * 0xf0..0xff
> > - * 0xe0..0xdf
> > + * 0xe0..0xef
> > + * 0xd0..0xdf
> >   * 0xc0..0xcf
> >   * 0xb0..0xbf
> >   * 0xa0..0xaf
> > @@ -165,13 +166,7 @@
> >   * A GIC must support a minimum of 16 priority levels.
> >   */
> >  #define GIC_PRI_LOWEST     0xf0U
> > -#define GIC_PRI_IRQ        0xa0U
> > -#define GIC_PRI_IPI        0x90U /* IPIs must preempt normal interrupts */
>
> according to this...
>
> >  #define GIC_PRI_HIGHEST    0x80U /* Higher priorities belong to 
> > Secure-World */
> > -#define GIC_PRI_IRQ_ALL    ((GIC_PRI_IRQ << 24) | (GIC_PRI_IRQ << 16) |\
> > -                            (GIC_PRI_IRQ << 8) | GIC_PRI_IRQ)
> > -#define GIC_PRI_IPI_ALL    ((GIC_PRI_IPI << 24) | (GIC_PRI_IPI << 16) |\
> > -                            (GIC_PRI_IPI << 8) | GIC_PRI_IPI)
> >
> >  #define GIC_PRI_TO_GUEST(pri) ((pri) >> 3) /* GICH_LR and GICH_VMCR only 
> > support
> >                                                5 bits for guest irq 
> > priority */
> > @@ -180,6 +175,20 @@
> >  #define GICH_LR_ACTIVE          2
> >
> >  #ifndef __ASSEMBLER__
> > +
> > +extern unsigned int gic_pri_irq;
> > +extern unsigned int gic_pri_sgi;
> > +extern unsigned int gic_pri_ipi;
> > +
> > +#define GIC_PRI_IRQ        gic_pri_irq
> > +#define GIC_PRI_SGI        gic_pri_sgi
> > +#define GIC_PRI_IPI        gic_pri_ipi
> > +
> > +#define GIC_PRI_IRQ_ALL    ((GIC_PRI_IRQ << 24) | (GIC_PRI_IRQ << 16) |\
> > +                            (GIC_PRI_IRQ << 8) | GIC_PRI_IRQ)
> > +#define GIC_PRI_IPI_ALL    ((GIC_PRI_IPI << 24) | (GIC_PRI_IPI << 16) |\
> > +                            (GIC_PRI_IPI << 8) | GIC_PRI_IPI)
> > +
> >  #include <xen/device_tree.h>
> >  #include <xen/irq.h>
> >
> > diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
> > index 
> > 8d3517e761621c4930c9440ebd060762b8369e4e..29f21224ffdde620307e4f58fd7dd247d975ba82
> >  100644
> > --- a/xen/arch/arm/irq.c
> > +++ b/xen/arch/arm/irq.c
> > @@ -453,7 +453,19 @@ int setup_irq(unsigned int irq, unsigned int irqflags, 
> > struct irqaction *new)
> >      /* First time the IRQ is setup */
> >      if ( disabled )
> >      {
> > -        gic_route_irq_to_xen(desc, GIC_PRI_IRQ);
> > +        unsigned int prio = GIC_PRI_IRQ;
> > +
> > +        if ( desc->irq >= GIC_SGI_STATIC_MAX && desc->irq < NR_GIC_SGI )
> > +        {
> > +            prio = GIC_PRI_SGI;
> > +
> > +            if ( prio <= GIC_PRI_IPI )
> > +                printk_once(XENLOG_WARNING
> > +                            "SGI %u priority %#x at or above IPI %#x\n",
> > +                            desc->irq, prio, GIC_PRI_IPI);
> > +        }
>
> ... should we also check ordinary IRQs in the same way? Why only SGIs?
> Maybe remove this warning from here and do all checks once somewhere
> during init?

The original patch only changed dynamic SGIs. In the earlier review,
Bertrand asked for a warning naming the SGI when it was requested.
That is why I put the warning in setup_irq().

I agree that the ordinary IRQ level should be checked too. Since all
three levels are set at boot, I can check both the IRQ and SGI levels
against the IPI level once in gic_init(). I would warn and keep the
configured values.

Best regards,
Mykola



 


Rackspace

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