mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* lguest: bug in lg_irq_enable?
@ 2015-02-26 15:39 Denys Vlasenko
  2015-03-02  0:14 ` Rusty Russell
  0 siblings, 1 reply; 2+ messages in thread
From: Denys Vlasenko @ 2015-02-26 15:39 UTC (permalink / raw)
  To: Rusty Russell, Linux Kernel Mailing List

ENTRY(lg_irq_enable)
        /*
         * The reverse of irq_disable, this sets lguest_data.irq_enabled to
         * X86_EFLAGS_IF (ie. "Interrupts enabled").
         */
        movl $X86_EFLAGS_IF, lguest_data+LGUEST_DATA_irq_enabled
        /*
         * But now we need to check if the Host wants to know: there might have
         * been interrupts waiting to be delivered, in which case it will have
         * set lguest_data.irq_pending to X86_EFLAGS_IF.  If it's not zero, we
         * jump to send_interrupts, otherwise we're done.
         */
        testl $0, lguest_data+LGUEST_DATA_irq_pending
^^^^^^^^^^^^^^^^^??????????
        jnz send_interrupts
        /*
         * One cool thing about x86 is that you can do many things without using
         * a register.  In this case, the normal path hasn't needed to save or
         * restore any registers at all!
         */
        ret
send_interrupts:


TEST with zero will always set ZF. Thus, "jnz send_interrupts" never jumps.

-- 
vda

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: lguest: bug in lg_irq_enable?
  2015-02-26 15:39 lguest: bug in lg_irq_enable? Denys Vlasenko
@ 2015-03-02  0:14 ` Rusty Russell
  0 siblings, 0 replies; 2+ messages in thread
From: Rusty Russell @ 2015-03-02  0:14 UTC (permalink / raw)
  To: Denys Vlasenko, Linux Kernel Mailing List

Denys Vlasenko <vda.linux@googlemail.com> writes:
> ENTRY(lg_irq_enable)
>         /*
>          * The reverse of irq_disable, this sets lguest_data.irq_enabled to
>          * X86_EFLAGS_IF (ie. "Interrupts enabled").
>          */
>         movl $X86_EFLAGS_IF, lguest_data+LGUEST_DATA_irq_enabled
>         /*
>          * But now we need to check if the Host wants to know: there might have
>          * been interrupts waiting to be delivered, in which case it will have
>          * set lguest_data.irq_pending to X86_EFLAGS_IF.  If it's not zero, we
>          * jump to send_interrupts, otherwise we're done.
>          */
>         testl $0, lguest_data+LGUEST_DATA_irq_pending
> ^^^^^^^^^^^^^^^^^??????????

Heh, that should be cmpl!  Nice catch!

Cheers,
Rusty.

Subject: lguest: fix pending interrupt test.

Denys says:
  TEST with zero will always set ZF. Thus, "jnz send_interrupts" never jumps.

We get interrupts regularly enough that this didn't cause immediate problems.

Reported-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

diff --git a/arch/x86/lguest/head_32.S b/arch/x86/lguest/head_32.S
index 6ddfe4fc23c3..05b0a85507ce 100644
--- a/arch/x86/lguest/head_32.S
+++ b/arch/x86/lguest/head_32.S
@@ -84,7 +84,7 @@ ENTRY(lg_irq_enable)
 	 * set lguest_data.irq_pending to X86_EFLAGS_IF.  If it's not zero, we
 	 * jump to send_interrupts, otherwise we're done.
 	 */
-	testl $0, lguest_data+LGUEST_DATA_irq_pending
+	cmpl $0, lguest_data+LGUEST_DATA_irq_pending
 	jnz send_interrupts
 	/*
 	 * One cool thing about x86 is that you can do many things without using


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-02 10:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-26 15:39 lguest: bug in lg_irq_enable? Denys Vlasenko
2015-03-02  0:14 ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome