acrn-hypervisor/hypervisor/arch/x86
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
..
boot hv: a few fixes for multiboot2 boot 2020-03-24 08:44:20 +08:00
configs hv: Add HI_MMIO_START and HI_MMIO_END macros to board files 2020-04-13 16:52:18 +08:00
guest hv: maintain a per-pCPU array of vCPUs and handle posted interrupt IRQs 2020-04-15 13:47:22 +08:00
lib hv: refine retpoline speculation barriers 2020-02-26 09:24:54 +08:00
seed HV: init and sanitize acrn multiboot info 2020-02-26 09:24:16 +08:00
cpu_caps.c hv: cpuid: remove cpuid() 2020-03-25 13:26:58 +08:00
cpu_state_tbl.c HV: add board specific cpu state table to support Px Cx 2019-07-29 20:25:16 +08:00
cpu.c hv: define posted interrupt IRQs/vectors 2020-04-15 13:47:22 +08:00
e820.c hv: Reserve space for VMs' EPT 4k pages after boot 2020-04-01 21:13:37 +08:00
gdt.c
idt.S HV: Install a NMI handler in acrn IDT 2019-12-13 10:13:09 +08:00
init.c HV: init and sanitize acrn multiboot info 2020-02-26 09:24:16 +08:00
ioapic.c hv: vioapic init for SOS VM on platforms with multiple IO-APICs 2020-03-25 09:36:18 +08:00
irq.c hv: define posted interrupt IRQs/vectors 2020-04-15 13:47:22 +08:00
Kconfig hv: Server platforms can have more than 8 IO-APICs 2020-03-25 09:36:18 +08:00
lapic.c HV: clean up redundant macro in lapic.h 2019-12-27 12:27:08 +08:00
mmu.c hv: Hypervisor access to PCI devices with 64-bit MMIO BARs 2020-04-13 16:52:18 +08:00
notify.c hv: maintain a per-pCPU array of vCPUs and handle posted interrupt IRQs 2020-04-15 13:47:22 +08:00
page.c hv: Hypervisor access to PCI devices with 64-bit MMIO BARs 2020-04-13 16:52:18 +08:00
pagetable.c hv: mmu: minor fix about add_pte 2020-03-09 10:03:01 +08:00
platform_caps.c hv: add function to check if using posted interrupt is possible for vm 2020-04-15 13:47:22 +08:00
pm.c pm: S5: update the system shutdown logical in ACRN 2019-12-23 15:15:09 +08:00
rdt.c HV: Add MBA support in ACRN 2020-03-04 17:33:50 +08:00
sched.S hv: sched: rename schedule related structs and vars 2019-10-16 10:25:53 +08:00
security.c hv: config: add an option to disable mce on psc workaround 2019-12-03 09:17:04 +08:00
sgx.c hv: sgx: add basic support to init sgx resource for vm 2019-05-29 11:24:13 +08:00
timer.c hv: list: rename list_entry to container_of 2020-03-31 10:57:47 +08:00
trampoline.c hv: refine 'uint64_t' string print format in x86 moudle 2019-11-09 11:42:38 +08:00
vmx.c hv:fix "no prototype for non-static function" 2019-07-09 10:36:03 +08:00
vtd.c hv: enable VT-d PI for ptdev if intr_src->pid_addr is non-zero 2020-04-15 13:47:22 +08:00
wakeup.S hv: pm: correct the function name 2019-09-11 17:30:24 +08:00