From f21e36f43bcb67221a45697fccbdb955e0563fab Mon Sep 17 00:00:00 2001 From: Shiqing Gao Date: Thu, 22 Nov 2018 12:24:53 +0800 Subject: [PATCH] hv: vioapic: clean up HV_DEBUG usage remove the usage of HV_DEBUG in vioapic.c Tracked-On: #861 Signed-off-by: Shiqing Gao Acked-by: Eddie Dong --- hypervisor/debug/shell.c | 56 +++++++++++++++++++ hypervisor/dm/vioapic.c | 59 --------------------- hypervisor/include/arch/x86/guest/vioapic.h | 6 +-- 3 files changed, 58 insertions(+), 63 deletions(-) diff --git a/hypervisor/debug/shell.c b/hypervisor/debug/shell.c index f5293fadf..cb454ebd1 100644 --- a/hypervisor/debug/shell.c +++ b/hypervisor/debug/shell.c @@ -916,6 +916,62 @@ static int shell_show_ptdev_info(__unused int argc, __unused char **argv) return 0; } +static void get_vioapic_info(char *str_arg, size_t str_max, uint16_t vmid) +{ + char *str = str_arg; + size_t len, size = str_max; + union ioapic_rte rte; + uint32_t delmode, vector, dest; + bool level, phys, remote_irr, mask; + struct acrn_vm *vm = get_vm_from_vmid(vmid); + uint32_t pin, pincount; + + if (vm == NULL) { + len = snprintf(str, size, "\r\nvm is not exist for vmid %hu", vmid); + if (len >= size) { + goto overflow; + } + size -= len; + str += len; + goto END; + } + + len = snprintf(str, size, "\r\nPIN\tVEC\tDM\tDEST\tTM\tDELM\tIRR\tMASK"); + if (len >= size) { + goto overflow; + } + size -= len; + str += len; + + pincount = vioapic_pincount(vm); + rte.full = 0UL; + for (pin = 0U; pin < pincount; pin++) { + vioapic_get_rte(vm, pin, &rte); + mask = ((rte.full & IOAPIC_RTE_INTMASK) == IOAPIC_RTE_INTMSET); + remote_irr = ((rte.full & IOAPIC_RTE_REM_IRR) == IOAPIC_RTE_REM_IRR); + phys = ((rte.full & IOAPIC_RTE_DESTMOD) == IOAPIC_RTE_DESTPHY); + delmode = (uint32_t)(rte.full & IOAPIC_RTE_DELMOD); + level = ((rte.full & IOAPIC_RTE_TRGRLVL) != 0UL); + vector = rte.u.lo_32 & IOAPIC_RTE_LOW_INTVEC; + dest = (uint32_t)(rte.full >> IOAPIC_RTE_DEST_SHIFT); + + len = snprintf(str, size, "\r\n%hhu\t0x%X\t%s\t0x%X\t%s\t%u\t%d\t%d", + pin, vector, phys ? "phys" : "logic", dest, level ? "level" : "edge", + delmode >> 8U, remote_irr, mask); + if (len >= size) { + goto overflow; + } + size -= len; + str += len; + } +END: + snprintf(str, size, "\r\n"); + return; + +overflow: + printf("buffer size could not be enough! please check!\n"); +} + static int shell_show_vioapic_info(int argc, char **argv) { uint16_t vmid; diff --git a/hypervisor/dm/vioapic.c b/hypervisor/dm/vioapic.c index f71ed0138..7a5b81067 100644 --- a/hypervisor/dm/vioapic.c +++ b/hypervisor/dm/vioapic.c @@ -40,7 +40,6 @@ #define IOAPIC_ID_MASK 0x0f000000U #define MASK_ALL_INTERRUPTS 0x0001000000010000UL -#define IOAPIC_RTE_LOW_INTVEC ((uint32_t)IOAPIC_RTE_INTVEC) /** * @pre pin < vioapic_pincount(vm) @@ -574,61 +573,3 @@ void vioapic_get_rte(struct acrn_vm *vm, uint32_t pin, union ioapic_rte *rte) vioapic = vm_ioapic(vm); *rte = vioapic->rtbl[pin]; } - -#ifdef HV_DEBUG -void get_vioapic_info(char *str_arg, size_t str_max, uint16_t vmid) -{ - char *str = str_arg; - size_t len, size = str_max; - union ioapic_rte rte; - uint32_t delmode, vector, dest; - bool level, phys, remote_irr, mask; - struct acrn_vm *vm = get_vm_from_vmid(vmid); - uint32_t pin, pincount; - - if (vm == NULL) { - len = snprintf(str, size, "\r\nvm is not exist for vmid %hu", vmid); - if (len >= size) { - goto overflow; - } - size -= len; - str += len; - goto END; - } - - len = snprintf(str, size, "\r\nPIN\tVEC\tDM\tDEST\tTM\tDELM\tIRR\tMASK"); - if (len >= size) { - goto overflow; - } - size -= len; - str += len; - - pincount = vioapic_pincount(vm); - rte.full = 0UL; - for (pin = 0U; pin < pincount; pin++) { - vioapic_get_rte(vm, pin, &rte); - mask = ((rte.full & IOAPIC_RTE_INTMASK) == IOAPIC_RTE_INTMSET); - remote_irr = ((rte.full & IOAPIC_RTE_REM_IRR) == IOAPIC_RTE_REM_IRR); - phys = ((rte.full & IOAPIC_RTE_DESTMOD) == IOAPIC_RTE_DESTPHY); - delmode = (uint32_t)(rte.full & IOAPIC_RTE_DELMOD); - level = ((rte.full & IOAPIC_RTE_TRGRLVL) != 0UL); - vector = rte.u.lo_32 & IOAPIC_RTE_LOW_INTVEC; - dest = (uint32_t)(rte.full >> IOAPIC_RTE_DEST_SHIFT); - - len = snprintf(str, size, "\r\n%hhu\t0x%X\t%s\t0x%X\t%s\t%u\t%d\t%d", - pin, vector, phys ? "phys" : "logic", dest, level ? "level" : "edge", - delmode >> 8U, remote_irr, mask); - if (len >= size) { - goto overflow; - } - size -= len; - str += len; - } -END: - snprintf(str, size, "\r\n"); - return; - -overflow: - printf("buffer size could not be enough! please check!\n"); -} -#endif /* HV_DEBUG */ diff --git a/hypervisor/include/arch/x86/guest/vioapic.h b/hypervisor/include/arch/x86/guest/vioapic.h index a921e8a09..8f30f6473 100644 --- a/hypervisor/include/arch/x86/guest/vioapic.h +++ b/hypervisor/include/arch/x86/guest/vioapic.h @@ -46,6 +46,8 @@ #define REDIR_ENTRIES_HW 120U /* SOS align with native ioapic */ #define STATE_BITMAP_SIZE INT_DIV_ROUNDUP(REDIR_ENTRIES_HW, 64U) +#define IOAPIC_RTE_LOW_INTVEC ((uint32_t)IOAPIC_RTE_INTVEC) + struct acrn_vioapic { struct acrn_vm *vm; spinlock_t mtx; @@ -104,10 +106,6 @@ void vioapic_process_eoi(struct acrn_vm *vm, uint32_t vector); void vioapic_get_rte(struct acrn_vm *vm, uint32_t pin, union ioapic_rte *rte); int vioapic_mmio_access_handler(struct io_request *io_req, void *handler_private_data); -#ifdef HV_DEBUG -void get_vioapic_info(char *str_arg, size_t str_max, uint16_t vmid); -#endif /* HV_DEBUG */ - /** * @} */