lguest: fix kvm-style hypercall handling on modern Intel

Impact: fix guest crash '

If the host has VT support, then the guest doing a VMCALL will cause a
General Protection Fault, not an Invalid Opcode fault.  You won't notice
this on AMD boxes, nor under kvm (these are my two normal testing
environments).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: lguest@ozlabs.org
Cc: Matias Zabaljauregui <zabaljauregui at gmail.com>
---
 drivers/lguest/x86/core.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
--- a/drivers/lguest/x86/core.c
+++ b/drivers/lguest/x86/core.c
@@ -345,15 +346,6 @@ static bool is_hypercall(struct lg_cpu *
 void lguest_arch_handle_trap(struct lg_cpu *cpu)
 {
 	switch (cpu->regs->trapnum) {
-	case 13: /* We've intercepted a General Protection Fault. */
-		/* Check if this was one of those annoying IN or OUT
-		 * instructions which we need to emulate.  If so, we just go
-		 * back into the Guest after we've done it. */
-		if (cpu->regs->errcode == 0) {
-			if (emulate_insn(cpu))
-				return;
-		}
-		break;
 	case 14: /* We've intercepted a Page Fault. */
 		/* The Guest accessed a virtual address that wasn't mapped.
 		 * This happens a lot: we don't actually set up most of the page
@@ -398,6 +390,15 @@ void lguest_arch_handle_trap(struct lg_c
 		 * up the pointer now to indicate a hypercall is pending. */
 		cpu->hcall = (struct hcall_args *)cpu->regs;
 		return;
+	case 13: /* We've intercepted a General Protection Fault. */
+		/* Check if this was one of those annoying IN or OUT
+		 * instructions which we need to emulate.  If so, we just go
+		 * back into the Guest after we've done it. */
+		if (cpu->regs->errcode == 0) {
+			if (emulate_insn(cpu))
+				return;
+		}
+		/* It can also be a hypercall: if cpu has VT support. */
 	case 6:
 		/* kvm hypercalls trigger an invalid opcode fault (6).
 		 * We need to check if ring == GUEST_PL and
