|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v1 13/27] xen/riscv: add basic VGEIN management for AIA guests
On 13.04.2026 16:42, Oleksii Kurochko wrote:
> On 4/2/26 12:03 PM, Jan Beulich wrote:
>> On 10.03.2026 18:08, Oleksii Kurochko wrote:
>>> AIA provides a hardware-accelerated mechanism for delivering external
>>> interrupts to domains via "guest interrupt files" located in IMSIC.
>>> A single physical hart can implement multiple such files (up to GEILEN),
>>> allowing several virtual harts to receive interrupts directly from hardware
>>
>> Isn't use of such an optimization coming prematurely? Shouldn't this series
>> focus on getting basic functionality in place?
>
> At the moment, we don't support only APLIC for guest interrupts as it
> will require trap-and-emulation approach, so just from the start it was
> decided to go with APLIC+IMSIC (IMSIC here as it only one interrupt
> controller which exist and support VGEIN stuff at the momemnt) approach
> and then when it will be needed back to only the case when APLIC is
> supported.
>
> Maybe, it was better to introduce in patch series where a lauching of
> domain actually happens.
>
> Considering that you've already made a review, I prefer then to have
> this patch part of this patch series.
That's okay, but then please take my remark as an indication that once
again the patch description makes implications on what the reader knows
(without it being written down anywhere I'm aware of).
>>> @@ -14,12 +27,109 @@ bool aia_available(void)
>>> return is_aia_available;
>>> }
>>>
>>> +int __init vgein_init(unsigned int cpu)
>>
>> If this needs invoking once per CPU being brought up, it can't be __init.
>
> Yes, it is going to be called inside the secondary CPU bring-up function.
>
> __init sections are removed much later, after all CPUs are brought up,
> so it looks like that at the moment when secondary CPUs are being
> brought up, __init still exists and can be called.
No. And I said so before. See XEN_SYSCTL_cpu_hotplug (and ignore it having
"hotplug" in the name, but merely consider that you can take CPUs offline
at runtime, and later bring them online again).
>> Also - static?
>
> It isn't static because it will be called inside the secondary CPU
> bring-up function.
As it doesn't need calling from the outside for the boot CPU, it's not
obvious why it would need calling from the outside for secondary ones.
>>> +{
>>> + struct vgein_bmp *vgein = &per_cpu(vgein_bmp, cpu);
>>> +
>>> + csr_write(CSR_HGEIE, -1UL);
>>> + vgein->geilen = flsl(csr_read(CSR_HGEIE));
>>> + csr_write(CSR_HGEIE, 0);
>>> + if ( vgein->geilen )
>>> + vgein->geilen--;
>>
>> I don't understand this. The "len" in "geilen" stands for "length", I
>> suppose,
>> i.e. the number of bits. Hmm, the spec itself is inconsistent: "The number of
>> bits implemented in hgeip and hgeie for guest external interrupts is
>> UNSPECIFIED
>> and may be zero. This number is known as GEILEN." This may or may not include
>> bit 0 (which is implemented, but r/o zero). Then saying "Hence, if GEILEN is
>> nonzero, bits GEILEN:1 shall be writable in ..." suggests 0 isn't included,
>> but
>> that's not unambiguous.
>
> But they explicitly wrote that: The least-significant bits are
> implemented first, apart from bit 0. So bit 0 is explicitly excluded.
Fine, but not including it in anything named *LEN feels - as said - ambiguous.
>>> + /*
>>> + * All vCPU guest interrupt files are used and we don't support a case
>>> + * when number of vCPU on 1 pCPU is bigger then geilen.
>>> + */
>>
>> This wants checking in vgein_init() then. CPUs (beyond the boot one)
>> violating this should not be brought online.
>
> It'll be nice. But we can't know how many vCPUs will be ran on pCPU when
> vgein_init() is executed.
I don't understand: How does it matter how many vCPU-s will exist later on
(and will run wherever)?
>>> + ASSERT(vgein_id < vgein_bmp->geilen);
>>
>> What if not bit is available? By asserting, you assume the caller will not
>> call here when no ID is available.
>
> It is just a temporary ASSERT() (as we don't support software guest
> interrupt files) because in general it is fine if there is no bit
> available, it will just mean that that no physical hardware guest
> interrupt file is assigned to the virtual hart, and software-based
> emulation (a "software file") must be used to handle guest external
> interrupts.
>
> Will it be better to return 0 now here and just don't create a vCPU
> on ...
>
> Yet there is no caller of this function,
>> so how can one verify whether this assertion is appropriate?
>
> ... the caller side when an assignment is expected to be happen?
Yes, you want to return errors for cases you can't handle. You wan to
assert on internal state only, not on anything controlled by a caller
outside of the hypervisor.
>>> + bitmap_set(bmp, vgein_id, 1);
>>
>> __set_bit()?
>
> I thought that it will be fine to use for bmp, bitmap_* functions().
> __set_bit is what is called inside bitmap_set().
Sure, but why make things look complicated? We use __set_bit() and
friends all over the place on bitmaps. bitmap_*() exist for the less
trivial cases.
>>> + spin_unlock_irqrestore(&vgein_bmp->lock, flags);
>>> +
>>> +#ifdef VGEIN_DEBUG
>>> + printk("%s: vgein_id(%u), xen_cpu%d_bmp=%#lx\n",
>>> + __func__, vgen_id, v->processor, *vgein_bmp->bmp);
>>
>> I can't spot a difference from the message in vgein_assign(). How is one
>> to distinguish the two in a log?
>
> By function name which is the first argument (__func__).
My general take is that in gprintk() use of __func__ may be okay, but
hardly anywhere else.
Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |