mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-23 17:58:30 +00:00
hv: define posted interrupt IRQs/vectors
This is a preparation patch for adding support for VT-d PI related vCPU scheduling. ACRN does not support vCPU migration, one vCPU always runs on the same pCPU, so PI's ndst is never changed after startup. VCPUs of a VM won’t share same pCPU. So the maximum possible number of VCPUs that can run on a pCPU is CONFIG_MAX_VM_NUM. Allocate unique Activation Notification Vectors (ANV) for each vCPU that belongs to the same pCPU, the ANVs need only be unique within each pCPU, not across all vCPUs. This reduces # of pre-allocated ANVs for posted interrupts to CONFIG_MAX_VM_NUM, and enables ACRN to avoid switching between active and wake-up vector values in the posted interrupt descriptor on vCPU scheduling state changes. A total of CONFIG_MAX_VM_NUM consecutive IRQs/vectors are reserved for posted interrupts use. The code first initializes vcpu->arch.pid.control.bits.nv dynamically (will be added in subsequent patch), the other code shall use vcpu->arch.pid.control.bits.nv instead of the hard-coded notification vectors. Rename some functions: apicv_post_intr --> apicv_trigger_pi_anv posted_intr_notification --> handle_pi_notification setup_posted_intr_notification --> setup_pi_notification Tracked-On: #4506 Signed-off-by: dongshen <dongsheng.x.zhang@intel.com> Reviewed-by: Eddie Dong <eddie.dong@Intel.com>
This commit is contained in:
@@ -25,7 +25,24 @@
|
||||
#define NR_IRQS 256U
|
||||
#define IRQ_INVALID 0xffffffffU
|
||||
|
||||
#define NR_STATIC_MAPPINGS (4U)
|
||||
/* # of NR_STATIC_MAPPINGS_1 entries for timer, vcpu notify, and PMI */
|
||||
#define NR_STATIC_MAPPINGS_1 3U
|
||||
|
||||
/*
|
||||
* The static IRQ/Vector mapping table in irq.c consists of the following entries:
|
||||
* # of NR_STATIC_MAPPINGS_1 entries for timer, vcpu notify, and PMI
|
||||
*
|
||||
* # of CONFIG_MAX_VM_NUM entries for posted interrupt notification, platform
|
||||
* specific but known at build time:
|
||||
* Allocate unique Activation Notification Vectors (ANV) for each vCPU that belongs
|
||||
* to the same pCPU, the ANVs need only be unique within each pCPU, not across all
|
||||
* vCPUs. The max numbers of vCPUs may be running on top of a pCPU is CONFIG_MAX_VM_NUM,
|
||||
* since ACRN does not support 2 vCPUs of same VM running on top of same pCPU.
|
||||
* This reduces # of pre-allocated ANVs for posted interrupts to CONFIG_MAX_VM_NUM,
|
||||
* and enables ACRN to avoid switching between active and wake-up vector values
|
||||
* in the posted interrupt descriptor on vCPU scheduling state changes.
|
||||
*/
|
||||
#define NR_STATIC_MAPPINGS (NR_STATIC_MAPPINGS_1 + CONFIG_MAX_VM_NUM)
|
||||
|
||||
#define HYPERVISOR_CALLBACK_VHM_VECTOR 0xF3U
|
||||
|
||||
@@ -39,13 +56,23 @@
|
||||
|
||||
#define TIMER_VECTOR (VECTOR_FIXED_START)
|
||||
#define NOTIFY_VCPU_VECTOR (VECTOR_FIXED_START + 1U)
|
||||
#define POSTED_INTR_VECTOR (VECTOR_FIXED_START + 2U)
|
||||
#define PMI_VECTOR (VECTOR_FIXED_START + 3U)
|
||||
#define PMI_VECTOR (VECTOR_FIXED_START + 2U)
|
||||
/*
|
||||
* Starting vector for posted interrupts
|
||||
* # of CONFIG_MAX_VM_NUM (POSTED_INTR_VECTOR ~ (POSTED_INTR_VECTOR + CONFIG_MAX_VM_NUM - 1U))
|
||||
* consecutive vectors reserved for posted interrupts
|
||||
*/
|
||||
#define POSTED_INTR_VECTOR (VECTOR_FIXED_START + NR_STATIC_MAPPINGS_1)
|
||||
|
||||
#define TIMER_IRQ (NR_IRQS - 1U)
|
||||
#define NOTIFY_VCPU_IRQ (NR_IRQS - 2U)
|
||||
#define POSTED_INTR_IRQ (NR_IRQS - 3U)
|
||||
#define PMI_IRQ (NR_IRQS - 4U)
|
||||
#define PMI_IRQ (NR_IRQS - 3U)
|
||||
/*
|
||||
* Starting IRQ for posted interrupts
|
||||
* # of CONFIG_MAX_VM_NUM (POSTED_INTR_IRQ ~ (POSTED_INTR_IRQ + CONFIG_MAX_VM_NUM - 1U))
|
||||
* consecutive IRQs reserved for posted interrupts
|
||||
*/
|
||||
#define POSTED_INTR_IRQ (NR_IRQS - NR_STATIC_MAPPINGS_1 - CONFIG_MAX_VM_NUM)
|
||||
|
||||
/* the maximum number of msi entry is 2048 according to PCI
|
||||
* local bus specification
|
||||
@@ -95,7 +122,7 @@ void init_default_irqs(uint16_t cpu_id);
|
||||
void dispatch_exception(struct intr_excp_ctx *ctx);
|
||||
|
||||
void setup_notification(void);
|
||||
void setup_posted_intr_notification(void);
|
||||
void setup_pi_notification(void);
|
||||
|
||||
typedef void (*spurious_handler_t)(uint32_t vector);
|
||||
extern spurious_handler_t spurious_handler;
|
||||
|
Reference in New Issue
Block a user