All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksii Kurochko <oleksii.kurochko@gmail.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Romain Caritey" <Romain.Caritey@microchip.com>,
	"Baptiste Le Duc" <baptiste.le-duc@vates.tech>,
	"Alistair Francis" <alistair.francis@wdc.com>,
	"Connor Davis" <connojdavis@gmail.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Anthony PERARD" <anthony.perard@vates.tech>,
	"Michal Orzel" <michal.orzel@amd.com>,
	"Julien Grall" <julien@xen.org>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v5 17/26] xen/riscv: introduce minimal virtual APLIC (vAPLIC) infrastructure
Date: Mon, 13 Jul 2026 11:57:36 +0200	[thread overview]
Message-ID: <2d0877f5-2fc1-4f53-b662-c377788e02ca@gmail.com> (raw)
In-Reply-To: <d38333f3-0dd0-43ad-ab3d-c6366ae8c74f@suse.com>



On 7/13/26 8:41 AM, Jan Beulich wrote:
> On 10.07.2026 17:52, Oleksii Kurochko wrote:
>> On 7/9/26 5:39 PM, Jan Beulich wrote:
>>> On 06.07.2026 17:57, Oleksii Kurochko wrote:
>>>> At the current development stage, only domain vINTC init and deinit
>>>> operations are required, so implement those first.
>>>>
>>>> Initialize vAPLIC's domaincfg to with the interrupt-enable bit set and
>>>> MSI delivery mode selected as the current solution is exepcted to have
>>>> always IMSIC, and initialize vintc->ops.
>>>
>>> How would domaincfg be initialized on real hardware?
>>
>> Xen will initialize that in aplic_init_hw_interrupts():
>> writel(APLIC_DOMAINCFG_IE | APLIC_DOMAINCFG_DM, &aplic.regs->domaincfg);
> 
> I.e. it is very much something the OS should do.
> 
>> I can see that maybe
>>> firmware would have to set DM suitably (and you may mean to take firmware's
>>> role here).
>>
>> I don't think that firmware will do that (and OpenSBI for example
>> doesn't do that). If firmware can do that we for sure want to control in
>> Xen what is written to ->domaincfg.
>>
>>> But isn't setting at least IE entirely the OSes responsibility?
>>
>> At least, Linux setups ->domaincfg once at the boot time:
>>
>> 	/* Setup APLIC domaincfg register */
>> 	val = readl(priv->regs + APLIC_DOMAINCFG);
>> 	val |= APLIC_DOMAINCFG_IE;
>> 	if (msi_mode)
>> 		val |= APLIC_DOMAINCFG_DM;
>> 	writel(val, priv->regs + APLIC_DOMAINCFG);
>> 	if (readl(priv->regs + APLIC_DOMAINCFG) != val)
>> 		dev_warn(priv->dev, "unable to write 0x%x in domaincfg\n", val);
>>
>> And don't touch this register anymore, even for interrupt disablement it
>> isn't used.
>>
>> So Xen can just does once:
>> writel(APLIC_DOMAINCFG_IE | APLIC_DOMAINCFG_DM, &aplic.regs->domaincfg);
>>
>> and then just properly handle access of a guest to domaincfg.
> 
> Xen can do this for itself, sure. But shouldn't domaincfg as seen by guests
> start out 0 then?

Now I think I understand your point.

I agree that it should start from 0 (or from 0x80000000, since bits 
31:24 are read-only and fixed to 0x80). All other bits should be set or 
cleared by the guest and written to vaplic->regs.domaincfg when the 
guest accesses the vAPLIC domaincfg register.

In that case, domain_vaplic_init() should initialize ->domaincfg as:
   vaplic->regs.domaincfg = APLIC_DOMAINCFG_RO;

instead of:
   vaplic->regs.domaincfg = APLIC_DOMAINCFG_IE | APLIC_DOMAINCFG_DM |
                          APLIC_DOMAINCFG_RO;

> 
>>>> --- a/xen/arch/riscv/include/asm/aplic.h
>>>> +++ b/xen/arch/riscv/include/asm/aplic.h
>>>> @@ -15,6 +15,8 @@
>>>>    
>>>>    #include <asm/imsic.h>
>>>>    
>>>> +/* domaincfg bits 31:24 are read-only 0x80 */
>>>> +#define APLIC_DOMAINCFG_RO      (0x80U << 24)
>>>
>>> Bit 7 is also documented as read-only 0. Wouldn't the comment better reflect
>>> that as well?
>>
>> Not sure, bits 31:24 are read-only *0x80* but bit 7 is read-only *0*.
> 
> And would it hurt if the comment said so, to avoid any ambiguity?

Of course, it won't I will update the comment.

> 
>>>>    #define APLIC_DOMAINCFG_IE      BIT(8, U)
>>>>    #define APLIC_DOMAINCFG_DM      BIT(2, U)
>>>
>>> Wouldn't you better spell out BE as well?
>>
>> I can add:
>>     #define APLIC_DOMAINCFG_BE       BIT(0, U)
>>
>> But it isn't used at the moment (Linux also defines it but never
>> actually using it). Do you want still to add that now?
> 
> Imo it would be better to have a complete set of definitions. If you
> don't allow guests to set this bit, perhaps to emit a sufficiently
> informative debug log messages you may want to use the #define?

Agree, it make sense.

Thanks.

~ Oleksii


  reply	other threads:[~2026-07-13  9:58 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06 15:57 [PATCH v5 00/26] Introduce enablemenant of dom0less Oleksii Kurochko
2026-07-06 15:57 ` [PATCH v5 01/26] xen/dom0less: turn max_init_domid into a common variable Oleksii Kurochko
2026-07-06 15:57 ` [PATCH v5 02/26] xen: arm: move declaration of map_device_irqs_to_domain() to common header Oleksii Kurochko
2026-07-06 15:57 ` [PATCH v5 03/26] xen: arm: update p2m_set_allocation() prototype Oleksii Kurochko
2026-07-06 15:57 ` [PATCH v5 04/26] xen/Kconfig: introduce HAS_STATIC_MEMORY Oleksii Kurochko
2026-07-07  9:52   ` Jan Beulich
2026-07-08 11:50     ` Oleksii Kurochko
2026-07-06 15:57 ` [PATCH v5 05/26] xen/riscv: rename enum intc_version to intc_variant Oleksii Kurochko
2026-07-06 16:05   ` Jan Beulich
2026-07-07  7:34     ` Oleksii Kurochko
2026-07-06 15:57 ` [PATCH v5 06/26] xen/riscv: Implement ARCH_PAGING_MEMPOOL Oleksii Kurochko
2026-07-06 15:57 ` [PATCH v5 07/26] xen/riscv: Implement construct_domain() Oleksii Kurochko
2026-07-06 15:57 ` [PATCH v5 08/26] xen/riscv: implement prerequisites for domain_create() Oleksii Kurochko
2026-07-06 15:57 ` [PATCH v5 09/26] xen/riscv: introduce guest riscv,isa string Oleksii Kurochko
2026-07-09 13:05   ` Jan Beulich
2026-07-10 15:00     ` Oleksii Kurochko
2026-07-13  6:37       ` Jan Beulich
2026-07-06 15:57 ` [PATCH v5 10/26] xen/riscv: implement make_cpus_node() Oleksii Kurochko
2026-07-09 13:20   ` Jan Beulich
2026-07-10 16:00     ` Oleksii Kurochko
2026-07-06 15:57 ` [PATCH v5 11/26] xen/riscv: implement make_timer_node() Oleksii Kurochko
2026-07-06 15:57 ` [PATCH v5 12/26] xen/riscv: implement make_arch_nodes() Oleksii Kurochko
2026-07-06 15:57 ` [PATCH v5 13/26] xen/riscv: introduce init interrupt controller operations Oleksii Kurochko
2026-07-06 15:57 ` [PATCH v5 14/26] xen/riscv: implement make_intc_domU_node() Oleksii Kurochko
2026-07-06 15:57 ` [PATCH v5 15/26] xen/riscv: introduce aia_init() and aia_usable() Oleksii Kurochko
2026-07-06 15:57 ` [PATCH v5 16/26] xen/riscv: introduce per-vCPU IMSIC state Oleksii Kurochko
2026-07-06 15:57 ` [PATCH v5 17/26] xen/riscv: introduce minimal virtual APLIC (vAPLIC) infrastructure Oleksii Kurochko
2026-07-09 15:39   ` Jan Beulich
2026-07-10 15:52     ` Oleksii Kurochko
2026-07-13  6:41       ` Jan Beulich
2026-07-13  9:57         ` Oleksii Kurochko [this message]
2026-07-13 15:44           ` Jan Beulich
2026-07-06 15:57 ` [PATCH v5 18/26] xen/riscv: introduce (de)initialization helpers for vINTC Oleksii Kurochko
2026-07-06 15:58 ` [PATCH v5 19/26] xen/riscv: generate IMSIC DT node for guest domains Oleksii Kurochko
2026-07-09 15:49   ` Jan Beulich
2026-07-13 10:41     ` Oleksii Kurochko
2026-07-06 15:58 ` [PATCH v5 20/26] xen/riscv: create APLIC " Oleksii Kurochko
2026-07-09 15:55   ` Jan Beulich
2026-07-06 15:58 ` [PATCH v5 21/26] xen/riscv: implement IRQ routing for device passthrough Oleksii Kurochko
2026-07-06 15:58 ` [PATCH v5 22/26] xen/riscv: implement init_intc_phandle() Oleksii Kurochko
2026-07-06 15:58 ` [PATCH v5 23/26] xen/riscv: initialize RCU, scheduler, and system domains in start_xen() Oleksii Kurochko
2026-07-06 15:58 ` [PATCH v5 24/26] xen/riscv: provide init_vuart() Oleksii Kurochko
2026-07-06 15:58 ` [PATCH v5 25/26] xen/riscv: add initial dom0less infrastructure support Oleksii Kurochko
2026-07-06 15:58 ` [PATCH v5 26/26] xen/riscv: do a 4th linking pass if necessary Oleksii Kurochko
2026-07-06 16:13   ` Jan Beulich
2026-07-07  8:19     ` Oleksii Kurochko
2026-07-07  8:37       ` Jan Beulich

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=2d0877f5-2fc1-4f53-b662-c377788e02ca@gmail.com \
    --to=oleksii.kurochko@gmail.com \
    --cc=Romain.Caritey@microchip.com \
    --cc=alistair.francis@wdc.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=baptiste.le-duc@vates.tech \
    --cc=connojdavis@gmail.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.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.