|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v1 14/27] xen/riscv: introduce per-vCPU IMSIC state
On 4/2/26 1:31 PM, Jan Beulich wrote: On 10.03.2026 18:08, Oleksii Kurochko wrote:Each vCPU interacting with the IMSIC requires state to track the associated guest interrupt file and its backing context. Introduce a per-vCPU structure to hold IMSIC-related state, including the guest interrupt file identifier and the CPU providing the backing VS-file. Access to the guest file identifier is protected by a lock. Initialize this structure during vCPU setup and store it in arch_vcpu. The initial state marks the VS-file as software-backed until it becomes associated with a physical CPU. Add helpers to retrieve and update the guest interrupt file identifier.Yet again a functions with no callers. They will be called in follow-up patches.
ACCESS_ONCE() isn't guarantee only compiler re-ordering (as basically it is just volatile-related stuff inisde the macros)? Generally, I think that that guest_file_id is needed to be updated only during migration of vCPU from one pCPU to another and I expect that during this migration vCPU isn't active, so no one will want to read imsic_state->guest_file_id. But on the other hand, there is:
bool imsic_has_interrupt(const struct vcpu *vcpu)
{
...
/*
* The IMSIC SW-file directly injects interrupt via hvip so
* only check for interrupt when IMSIC VS-file is being used.
*/
read_lock_irqsave(&imsic_state->vsfile_lock, flags);
if ( imsic_state->vsfile_pcpu != NR_CPUS )
ret = !!(csr_read(CSR_HGEIP) & BIT(imsic_state->guest_file_id,
UL));
read_unlock_irqrestore(&imsic_state->vsfile_lock, flags);
...
}
which I think could be called in parallel with with migration, so then
still lock are needed.
Yes, it will be used during creationg of a vCPU.
Makes sense. Lets rename this field and tag.
Originally, IIRC mhartid register is unsigned long, so potentially we could have amount of pCPU up to what fit into unsigned long. But know I see that AIA limits amount of pCPUs to 16,384 harts. So we could really use unsigned int here. As to the comment - as per vcpu_imsic_init() NR_CPUS also has some special meaning for guest_file_id, yet there's no comment there. How do file ID and NR_CPUS fit together anyway? Agree, it looks incorrect. I tried to avoid introduction of "#define GIELEN_MAX 64". As an option I can use UINT_MAX as init value for guest_file_id or even better just use 0 as it basically means that SW-file should be used. The idea is that if s/w IMSIC SW-file is used that it doesn't sit on any pCPU, so we should have some marker to show that and NR_CPUS should be fine. As a result guest_file_id should be init-ed with 0 (and it will be by default as xvzalloc() is used for allocation) and ->vsfile_pcpu inits with NR_CPUS. Also, I will add a comment above guest_file_id. Thanks. ~ Oleksii
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |