hv:Add vpin to ptdev entry mapping for vpic/vioapic

Now if the vmexit reason is virtulized EOI for level triggered
interrupts, HV will loop all the ptdev entries, it is time-consuming,
this patch add vpin to ptdev entry mapping for vpic and vioapic
when add intx entry for a vm,it can use the ptdev entry directly
according to the mapping for vpin and ptdev entry when EOI vmexit.

v3-->v4:
  -- add check vpin in remove_intx_remapping
  -- move check vpin from ptdev_add_intx_remapping to add_intx_remapping

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Mingqiang Chi
2018-11-19 11:35:22 +08:00
committed by lijinxia
parent 297a264a74
commit 538ba08c2b
5 changed files with 58 additions and 33 deletions

View File

@@ -119,7 +119,7 @@ int ptdev_add_intx_remapping(struct acrn_vm *vm, uint8_t virt_pin, uint8_t phys_
* @pre vm != NULL
*
*/
void ptdev_remove_intx_remapping(const struct acrn_vm *vm, uint8_t virt_pin, bool pic_pin);
void ptdev_remove_intx_remapping(struct acrn_vm *vm, uint8_t virt_pin, bool pic_pin);
/**
* @brief Add interrupt remapping entry/entries for MSI/MSI-x as pre-hold mapping.

View File

@@ -41,6 +41,7 @@
#define VIOAPIC_BASE 0xFEC00000UL
#define VIOAPIC_SIZE 4096UL
#define VIOAPIC_MAX_PIN 256U
#define REDIR_ENTRIES_HW 120U /* SOS align with native ioapic */
#define STATE_BITMAP_SIZE INT_DIV_ROUNDUP(REDIR_ENTRIES_HW, 64U)
@@ -53,6 +54,7 @@ struct acrn_vioapic {
union ioapic_rte rtbl[REDIR_ENTRIES_HW];
/* pin_state status bitmap: 1 - high, 0 - low */
uint64_t pin_state[STATE_BITMAP_SIZE];
struct ptdev_remapping_info *vpin_to_pt_entry[VIOAPIC_MAX_PIN];
};
void vioapic_init(struct acrn_vm *vm);

View File

@@ -92,6 +92,10 @@
#define IO_ELCR1 0x4d0U
#define IO_ELCR2 0x4d1U
#define NR_VPIC_PINS_PER_CHIP 8U
#define NR_VPIC_PINS_TOTAL 16U
#define VPIC_INVALID_PIN 0xffU
enum vpic_trigger {
EDGE_TRIGGER,
LEVEL_TRIGGER
@@ -124,6 +128,7 @@ struct acrn_vpic {
struct acrn_vm *vm;
spinlock_t lock;
struct i8259_reg_state i8259[2];
struct ptdev_remapping_info *vpin_to_pt_entry[NR_VPIC_PINS_TOTAL];
};
void vpic_init(struct acrn_vm *vm);