From 2a819366ae9d9e1f924f2472b9807afc6fe8b617 Mon Sep 17 00:00:00 2001 From: Yin Fengwei Date: Thu, 28 Jun 2018 17:37:40 +0800 Subject: [PATCH] hv: add ioapic reset function ioapic reset function will be called when doing guest reset. Signed-off-by: Yin Fengwei Acked-by: Eddie Dong --- hypervisor/arch/x86/guest/vioapic.c | 14 +++++++++++--- hypervisor/include/arch/x86/guest/vioapic.h | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hypervisor/arch/x86/guest/vioapic.c b/hypervisor/arch/x86/guest/vioapic.c index 84f9f94ba..febdc69e6 100644 --- a/hypervisor/arch/x86/guest/vioapic.c +++ b/hypervisor/arch/x86/guest/vioapic.c @@ -523,6 +523,16 @@ vioapic_process_eoi(struct vm *vm, uint32_t vector) VIOAPIC_UNLOCK(vioapic); } +void +vioapic_reset(struct vioapic *vioapic) +{ + int i; + + /* Initialize all redirection entries to mask all interrupts */ + for (i = 0; i < vioapic_pincount(vioapic->vm); i++) + vioapic->rtbl[i].reg = 0x0001000000010000UL; +} + struct vioapic * vioapic_init(struct vm *vm) { @@ -535,9 +545,7 @@ vioapic_init(struct vm *vm) vioapic->vm = vm; spinlock_init(&vioapic->mtx); - /* Initialize all redirection entries to mask all interrupts */ - for (i = 0; i < vioapic_pincount(vioapic->vm); i++) - vioapic->rtbl[i].reg = 0x0001000000010000UL; + vioapic_reset(vioapic); register_mmio_emulation_handler(vm, vioapic_mmio_access_handler, diff --git a/hypervisor/include/arch/x86/guest/vioapic.h b/hypervisor/include/arch/x86/guest/vioapic.h index 77d64af85..1aaf27ff5 100644 --- a/hypervisor/include/arch/x86/guest/vioapic.h +++ b/hypervisor/include/arch/x86/guest/vioapic.h @@ -36,6 +36,7 @@ struct vioapic *vioapic_init(struct vm *vm); void vioapic_cleanup(struct vioapic *vioapic); +void vioapic_reset(struct vioapic *vioapic); int vioapic_assert_irq(struct vm *vm, uint32_t irq); int vioapic_deassert_irq(struct vm *vm, uint32_t irq);