Commit e5faff45b381e053c31214713ed783d97f49177b

Authored by Rusty Russell
Committed by Linus Torvalds
1 parent bd6dc742a4

lguest: fix sense if IF flag on interrupt injection

The sense of the IF bit is backwards in the host interrupt handling.

This means we always save "IF=1" on the stack when injecting an
interrupt.  It turns out this is almost always correct (unless the
guest is taking a page fault in an interrupt due to an unpopulated
vmalloc mapping), so went unnoticed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 5 additions and 5 deletions Side-by-side Diff

drivers/lguest/interrupts_and_traps.c
... ... @@ -38,12 +38,12 @@
38 38 ss = lg->regs->ss;
39 39 }
40 40  
41   - /* We use IF bit in eflags to indicate whether irqs were disabled
42   - (it's always 0, since irqs are enabled when guest is running). */
  41 + /* We use IF bit in eflags to indicate whether irqs were enabled
  42 + (it's always 1, since irqs are enabled when guest is running). */
43 43 eflags = lg->regs->eflags;
44   - if (get_user(irq_enable, &lg->lguest_data->irq_enabled))
45   - irq_enable = 0;
46   - eflags |= (irq_enable & X86_EFLAGS_IF);
  44 + if (get_user(irq_enable, &lg->lguest_data->irq_enabled) == 0
  45 + && !(irq_enable & X86_EFLAGS_IF))
  46 + eflags &= ~X86_EFLAGS_IF;
47 47  
48 48 push_guest_stack(lg, &gstack, eflags);
49 49 push_guest_stack(lg, &gstack, lg->regs->cs);