Signed-off-by: Andrea Bastoni <[email protected]>
[Jan: fix APIC register loop after making n unsigned]
Signed-off-by: Jan Kiszka <[email protected]>
---
 hypervisor/arch/x86/apic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hypervisor/arch/x86/apic.c b/hypervisor/arch/x86/apic.c
index d36c2033..e861ec2f 100644
--- a/hypervisor/arch/x86/apic.c
+++ b/hypervisor/arch/x86/apic.c
@@ -315,7 +315,7 @@ void apic_clear(void)
 {
        unsigned int maxlvt = (apic_ops.read(APIC_REG_LVR) >> 16) & 0xff;
        unsigned int xlc = (apic_ext_features() >> 16) & 0xff;
-       int n;
+       unsigned int n;
 
        /* Enable the APIC - the cell may have turned it off */
        apic_ops.write(APIC_REG_SVR, APIC_SVR_ENABLE_APIC | 0xff);
@@ -336,8 +336,8 @@ void apic_clear(void)
 
        /* Clear ISR. This is done in reverse direction as EOI
         * clears highest-priority interrupt ISR bit. */
-       for (n = APIC_NUM_INT_REGS-1; n >= 0; n--)
-               while (apic_ops.read(APIC_REG_ISR0 + n) != 0)
+       for (n = APIC_NUM_INT_REGS; n > 0; n--)
+               while (apic_ops.read(APIC_REG_ISR0 + n - 1) != 0)
                        apic_ops.write(APIC_REG_EOI, APIC_EOI_ACK);
 
        /* Consume pending interrupts to clear IRR.
-- 
2.26.2

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/ec57e348-7525-c8a2-027f-5ac4cf61badb%40siemens.com.

Reply via email to