acrn-hypervisor/hypervisor/include/arch/x86/guest
dongshen 00ad3863a1 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>
2020-04-15 13:47:22 +08:00
..
assign.h hv: Introduce Global System Interrupt (GSI) into INTx Remapping 2020-03-25 09:36:18 +08:00
ept.h hv: vpci: add PCI BAR re-program address check 2019-10-29 14:49:55 +08:00
guest_memory.h xHV: remove unused function is_dbg_uart_enabled 2019-05-22 16:36:03 +08:00
guest_pm.h hv:Wrap some APIs related with guest pm 2019-10-21 10:13:02 +08:00
hyperv.h hv: support reference time enlightenment 2019-10-22 10:09:16 +08:00
instr_emul.h HV: remove instr_emul.c dead code 2019-07-09 09:22:53 +08:00
trusty.h hv: seed: refine header file 2019-03-15 14:09:56 +08:00
ucode.h HV:treewide:rename vcpu data structure 2018-11-05 15:35:49 +08:00
vcpu.h hv: maintain a per-pCPU array of vCPUs and handle posted interrupt IRQs 2020-04-15 13:47:22 +08:00
vcpuid.h HV: return extended info in vCPUID leaf 0x40000001 2019-07-31 14:13:39 +08:00
virtual_cr.h hv:move some files to guest folder 2019-01-30 20:43:04 +08:00
vlapic.h hv: virq: refine pending event inject sequence 2020-04-09 09:40:00 +08:00
vm_reset.h hv:move some APIs related host reset to pm.c 2019-08-22 14:09:18 +08:00
vm.h hv: add function to check if using posted interrupt is possible for vm 2020-04-15 13:47:22 +08:00
vmcs.h hv: bugfix for debug commands with smp_call 2019-12-05 11:19:35 +08:00
vmexit.h hv: refine guest.h 2019-02-03 13:00:42 +08:00
vmtrr.h hv: vmtrr: remove vcpu structure pointer from vmtrr 2020-03-31 10:57:47 +08:00
vmx_io.h hv: emulate ACPI reset register for Service OS guest 2019-05-15 11:20:12 +08:00