From: "Jürgen Groß" <jgross@suse.com>
To: Baptiste Le Duc <baptiste.leduc@etik.com>,
Anup Patel <anup@brainfault.org>
Cc: linux-riscv@lists.infradead.org, tglx@linutronix.de,
pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu,
alex@ghiti.fr, linux-kernel@vger.kernel.org,
oleksii.kurochko@gmail.com, xen-devel-owner@lists.xenproject.org
Subject: Re: [RFC] xen/riscv: per-CPU devid setup for Xen event channel IRQ on IMSIC
Date: Tue, 28 Apr 2026 20:47:07 +0200 [thread overview]
Message-ID: <62bb9013-bec1-4e69-91fa-c28b39771470@suse.com> (raw)
In-Reply-To: <d1ddacc1-83be-4e3a-97a0-74ca45429584@etik.com>
[-- Attachment #1.1.1: Type: text/plain, Size: 3344 bytes --]
On 28.04.26 18:40, Baptiste Le Duc wrote:
> Hi,
>
> Thanks for your quick response.
>
> I've implemented Xen event channels as a local interrupt, which works correctly
> for Xen <-> dom0 communication.
>
> However, this approach hits a limitation when dom0 needs to notify another guest
> domain: running in VS-mode, dom0 has no access to the hvip CSR and therefore
> cannot inject an IRQ_S_SOFTWARE interrupt into another guest directly as it can
> only be done by the hypervisor from HS-mode.
>
> Do you have any ideas to handle this ?
You need to issue an evtchn hypercall to the Xen hypervisor for sending an event
to another guest.
Juergen
>
> Thanks in advance.
>
> Regards,
> Baptiste
>
> On 4/24/26 6:55 PM, Anup Patel wrote:
>
>> On Fri, Apr 24, 2026 at 10:09 PM Baptiste Le Duc
>> <baptiste.leduc@etik.com> wrote:
>>> Hi,
>>>
>>> While adding Xen/RISC-V support, the guest event channel interrupt is
>>> allocated via irq_of_parse_and_map() against the IMSIC domain and, if
>>> we refer to the ARM implementation, it must
>>> be enabled/disabled per vCPU through enable_percpu_irq() /
>>> disable_percpu_irq() in the CPU hotplug callbacks.
>>>
>>> With IMSIC using handle_edge_irq (the upstream default),
>>> enable_percpu_irq() never clears IRQD_IRQ_DISABLED. That flag is set at
>>> irq_desc allocation time (irqdesc.c) and is only cleared by
>>> irq_startup(), which is called from __setup_irq() only when
>>> irq_settings_can_autoenable() returns true.
>>>
>>> irq_set_percpu_devid() sets IRQ_NOAUTOEN (via irq_set_percpu_devid_flags),
>>> so irq_startup() is intentionally skipped for percpu-devid IRQs.
>>> enable_percpu_irq() calls irq_percpu_enable() which does irq_enable/unmask
>>> on the chip but never touches IRQD_IRQ_DISABLED.
>>>
>>> Result: handle_edge_irq() hits irq_can_handle_actions() → checks
>>> irqd_irq_disabled() → returns false → IRQ silently dropped.
>>>
>>> This was confirmed by logs:
>>>
>>> XEN_TRACE irq=12 percpu_enable cpu=0 IRQD_DISABLED=1
>>> XEN_TRACE irq=12 handle_edge DROP IRQD_DISABLED=1 action=...
>>>
>>> What we tried
>>> -------------
>>> - request_irq() correctly works with upstream IMSIC which uses
>>> handle_edge_irq with no
>>> irq_set_percpu_devid() but it means we only can have one vCPU which will
>>> always handle the irq,
>>> and we don't want that.
>>>
>>> - Adding irq_set_percpu_devid() + switching to handle_percpu_devid_irq in
>>> imsic_irq_domain_alloc() fixes the Xen case but breaks all other IMSIC
>>> users (PCI MSI, platform devices) that call request_irq(), since
>>> request_threaded_irq() rejects IRQs marked _IRQ_PER_CPU_DEVID:
>>>
>>> WARNING: CPU: 0 PID: 1 at kernel/irq/manage.c:2101
>>> request_threaded_irq+0x80/0x12c
>>>
>>> Therefore, do you have any recommendations on how should I handle this
>>> case ?
>>>
>> The RISC-V IMSIC driver does not register per-CPU interrupts
>> rather it treats IDs across all CPUs as independent vectors and
>> picks the right vector for a device MSI based on availability + affinity.
>>
>> Only the RISC-V intc driver manages per-CPU interrupts so the
>> Xen guest event channel interrupt should be a local interrupt
>> managed by RISC-V intc driver.
>>
>> Regards,
>> Anup
>
>
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
next prev parent reply other threads:[~2026-04-28 18:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-24 16:39 [RFC] xen/riscv: per-CPU devid setup for Xen event channel IRQ on IMSIC Baptiste Le Duc
2026-04-24 16:55 ` Anup Patel
2026-04-28 16:40 ` Baptiste Le Duc
2026-04-28 18:47 ` Jürgen Groß [this message]
2026-04-30 13:03 ` Baptiste Le Duc
2026-04-30 13:58 ` Baptiste Le Duc
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=62bb9013-bec1-4e69-91fa-c28b39771470@suse.com \
--to=jgross@suse.com \
--cc=alex@ghiti.fr \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=baptiste.leduc@etik.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=oleksii.kurochko@gmail.com \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=tglx@linutronix.de \
--cc=xen-devel-owner@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox