lguest: workaround cmpxchg8b_emu by ignoring cli in the guest.
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 15 Apr 2010 03:43:53 +0000 (21:43 -0600)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 14 Apr 2010 12:13:54 +0000 (21:43 +0930)
It's only used by cmpxchg8b_emu (see db677ffa5f5a for the gory
details), and fixing that to be paravirt aware would be more work than
simply ignoring it (and AFAICT only help lguest).  This makes lguest
work on machines which have cmpxchg8b, for kernels compiled for older
processors.

(We can't emulate it properly: the popf which expects to restore interrupts
does not trap).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: virtualization@lists.osdl.org
drivers/lguest/x86/core.c

index fb2b7ef..b4eb675 100644 (file)
@@ -288,6 +288,18 @@ static int emulate_insn(struct lg_cpu *cpu)
        insn = lgread(cpu, physaddr, u8);
 
        /*
+        * Around 2.6.33, the kernel started using an emulation for the
+        * cmpxchg8b instruction in early boot on many configurations.  This
+        * code isn't paravirtualized, and it tries to disable interrupts.
+        * Ignore it, which will Mostly Work.
+        */
+       if (insn == 0xfa) {
+               /* "cli", or Clear Interrupt Enable instruction.  Skip it. */
+               cpu->regs->eip++;
+               return 1;
+       }
+
+       /*
         * 0x66 is an "operand prefix".  It means it's using the upper 16 bits
         * of the eax register.
         */