All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mykyta Poturai <Mykyta_Poturai@epam.com>
To: Mykola Kvach <Mykola_Kvach@epam.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Anthony PERARD" <anthony.perard@vates.tech>,
	"Michal Orzel" <michal.orzel@amd.com>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Julien Grall" <julien@xen.org>,
	"Roger Pau Monné" <roger@xenproject.org>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Bertrand Marquis" <bertrand.marquis@arm.com>,
	"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
	"ayan.kumar.halder | Guest" <ayan.kumar.halder@amd.com>,
	"Oleksandr Tyshchenko" <Oleksandr_Tyshchenko@epam.com>,
	Xen-devel <xen-devel-bounces@lists.xenproject.org>
Subject: Re: [RFC PATCH v2] xen/arm: select GIC interrupt priorities at boot
Date: Tue, 1 Dec 2026 09:01:41 +0000	[thread overview]
Message-ID: <DN99TEJ4AV8K.2FXS5PE1KAVYK@epam.com> (raw)
In-Reply-To: <20261120130933.102952-1-mykola_kvach@epam.com>

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@epam.com>
> ---
> 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@epam.com/
>
> 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?

> +
> +        gic_route_irq_to_xen(desc, prio);
>          /* It's fine to use smp_processor_id() because:
>           * For SGI and PPI: irq_desc is banked
>           * For SPI: we don't care for now which CPU will receive the


  reply	other threads:[~2026-12-01  9:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 13:10 [RFC PATCH v2] xen/arm: select GIC interrupt priorities at boot Mykola Kvach
2026-12-01  9:01 ` Mykyta Poturai [this message]
2026-12-01 21:50   ` Mykola Kvach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DN99TEJ4AV8K.2FXS5PE1KAVYK@epam.com \
    --to=mykyta_poturai@epam.com \
    --cc=Mykola_Kvach@epam.com \
    --cc=Oleksandr_Tyshchenko@epam.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=ayan.kumar.halder@amd.com \
    --cc=bertrand.marquis@arm.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger@xenproject.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel-bounces@lists.xenproject.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.