mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-01-05 15:45:05 +00:00
hv: maintain a per-pCPU array of vCPUs and handle posted interrupt IRQs
Maintain a per-pCPU array of vCPUs (struct acrn_vcpu *vcpu_array[CONFIG_MAX_VM_NUM]), one VM cannot have multiple vCPUs share one pcpu, so we can utilize this property and use the containing VM's vm_id as the index to the vCPU array: In create_vcpu(), we simply do: per_cpu(vcpu_array, pcpu_id)[vm->vm_id] = vcpu; In offline_vcpu(): per_cpu(vcpu_array, pcpuid_from_vcpu(vcpu))[vcpu->vm->vm_id] = NULL; so basically we use the containing VM's vm_id as the index to the vCPU array, as well as the index of posted interrupt IRQ/vector pair that are assigned to this vCPU: 0: first vCPU and first posted interrupt IRQs/vector pair (POSTED_INTR_IRQ/POSTED_INTR_VECTOR) ... CONFIG_MAX_VM_NUM-1: last vCPU and last posted interrupt IRQs/vector pair ((POSTED_INTR_IRQ + CONFIG_MAX_VM_NUM - 1U)/(POSTED_INTR_VECTOR + CONFIG_MAX_VM_NUM - 1U) In the posted interrupt handler, it will do the following: Translate the IRQ into a zero based index of where the vCPU is located in the vCPU list for current pCPU. Once the vCPU is found, we wake up the waiting thread and record this request as ACRN_REQUEST_EVENT Tracked-On: #4506 Signed-off-by: dongshen <dongsheng.x.zhang@intel.com> Reviewed-by: Eddie Dong <eddie.dong@Intel.com> Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
This commit is contained in:
@@ -98,11 +98,19 @@ void setup_notification(void)
|
||||
notification_irq, irq_to_vector(notification_irq));
|
||||
}
|
||||
|
||||
static void handle_pi_notification(__unused uint32_t irq, __unused void *data)
|
||||
/*
|
||||
* posted interrupt handler
|
||||
* @pre (irq - POSTED_INTR_IRQ) < CONFIG_MAX_VM_NUM
|
||||
*/
|
||||
static void handle_pi_notification(uint32_t irq, __unused void *data)
|
||||
{
|
||||
uint32_t vcpu_index = irq - POSTED_INTR_IRQ;
|
||||
|
||||
ASSERT(vcpu_index < CONFIG_MAX_VM_NUM, "");
|
||||
vcpu_handle_pi_notification(vcpu_index);
|
||||
}
|
||||
|
||||
/*pre-conditon: be called only by BSP initialization proccess*/
|
||||
/*pre-condition: be called only by BSP initialization proccess*/
|
||||
void setup_pi_notification(void)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
Reference in New Issue
Block a user