WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xen x86/64: Fix int80 direct trap. It mus

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xen x86/64: Fix int80 direct trap. It must check for events and also
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 09 Apr 2007 12:30:17 -0700
Delivery-date: Mon, 09 Apr 2007 12:29:22 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1175868454 -3600
# Node ID f80a97d262769710f9e1612bebc3c1308f947e4e
# Parent  bd73cb523111dd022d6d1e7de01d1930ed85b307
xen x86/64: Fix int80 direct trap. It must check for events and also
disable interrupts before exiting to guest context.

Also sprinkle about some assertions about interrupt-enable status.

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/arch/x86/x86_32/entry.S            |    1 +
 xen/arch/x86/x86_64/compat/entry.S     |    4 +++-
 xen/arch/x86/x86_64/entry.S            |    6 ++++--
 xen/arch/x86/x86_64/traps.c            |   12 ++++++++----
 xen/include/asm-x86/desc.h             |    2 +-
 xen/include/asm-x86/x86_32/asm_defns.h |   10 ++++++++++
 xen/include/asm-x86/x86_64/asm_defns.h |   10 ++++++++++
 7 files changed, 37 insertions(+), 8 deletions(-)

diff -r bd73cb523111 -r f80a97d26276 xen/arch/x86/x86_32/entry.S
--- a/xen/arch/x86/x86_32/entry.S       Fri Apr 06 14:35:25 2007 +0100
+++ b/xen/arch/x86/x86_32/entry.S       Fri Apr 06 15:07:34 2007 +0100
@@ -283,6 +283,7 @@ bad_hypercall:
 /* %edx == trap_bounce, %ebx == struct vcpu                       */
 /* %eax,%ecx are clobbered. %gs:%esi contain new UREGS_ss/UREGS_esp. */
 create_bounce_frame:
+        ASSERT_INTERRUPTS_ENABLED
         movl UREGS_eflags+4(%esp),%ecx
         movb UREGS_cs+4(%esp),%cl
         testl $(2|X86_EFLAGS_VM),%ecx
diff -r bd73cb523111 -r f80a97d26276 xen/arch/x86/x86_64/compat/entry.S
--- a/xen/arch/x86/x86_64/compat/entry.S        Fri Apr 06 14:35:25 2007 +0100
+++ b/xen/arch/x86/x86_64/compat/entry.S        Fri Apr 06 15:07:34 2007 +0100
@@ -137,6 +137,7 @@ compat_bad_hypercall:
 
 /* %rbx: struct vcpu, interrupts disabled */
 compat_restore_all_guest:
+        ASSERT_INTERRUPTS_DISABLED
         RESTORE_ALL
         addq  $8,%rsp
 .Lft0:  iretq
@@ -188,13 +189,14 @@ ENTRY(compat_post_handle_exception)
 
 ENTRY(compat_int80_direct_trap)
         call  compat_create_bounce_frame
-        jmp   compat_restore_all_guest
+        jmp   compat_test_all_events
 
 /* CREATE A BASIC EXCEPTION FRAME ON GUEST OS (RING-1) STACK:            */
 /*   {[ERRCODE,] EIP, CS, EFLAGS, [ESP, SS]}                             */
 /* %rdx: trap_bounce, %rbx: struct vcpu                                  */
 /* On return only %rbx is guaranteed non-clobbered.                      */
 compat_create_bounce_frame:
+        ASSERT_INTERRUPTS_ENABLED
         mov   %fs,%edi
         testb $2,UREGS_cs+8(%rsp)
         jz    1f
diff -r bd73cb523111 -r f80a97d26276 xen/arch/x86/x86_64/entry.S
--- a/xen/arch/x86/x86_64/entry.S       Fri Apr 06 14:35:25 2007 +0100
+++ b/xen/arch/x86/x86_64/entry.S       Fri Apr 06 15:07:34 2007 +0100
@@ -38,6 +38,7 @@ 1:      call  create_bounce_frame
 
 /* %rbx: struct vcpu, interrupts disabled */
 restore_all_guest:
+        ASSERT_INTERRUPTS_DISABLED
         RESTORE_ALL
         testw $TRAP_syscall,4(%rsp)
         jz    iret_exit_to_guest
@@ -230,7 +231,7 @@ ENTRY(int80_direct_trap)
 
         /* Check that the callback is non-null. */
         leaq  VCPU_int80_bounce(%rbx),%rdx
-        cmp   $0, TRAPBOUNCE_flags(%rdx)
+        cmp   $0,TRAPBOUNCE_flags(%rdx)
         jz    int80_slow_path
 
         movq  VCPU_domain(%rbx),%rax
@@ -238,7 +239,7 @@ ENTRY(int80_direct_trap)
         jnz   compat_int80_direct_trap
 
         call  create_bounce_frame
-        jmp   restore_all_guest
+        jmp   test_all_events
 
 int80_slow_path:
         /* 
@@ -256,6 +257,7 @@ int80_slow_path:
 /* %rdx: trap_bounce, %rbx: struct vcpu                           */
 /* On return only %rbx is guaranteed non-clobbered.                      */
 create_bounce_frame:
+        ASSERT_INTERRUPTS_ENABLED
         testb $TF_kernel_mode,VCPU_thread_flags(%rbx)
         jnz   1f
         /* Push new frame at registered guest-OS stack base. */
diff -r bd73cb523111 -r f80a97d26276 xen/arch/x86/x86_64/traps.c
--- a/xen/arch/x86/x86_64/traps.c       Fri Apr 06 14:35:25 2007 +0100
+++ b/xen/arch/x86/x86_64/traps.c       Fri Apr 06 15:07:34 2007 +0100
@@ -170,7 +170,8 @@ asmlinkage void do_double_fault(struct c
            regs->r9,  regs->r10, regs->r11);
     printk("r12: %016lx   r13: %016lx   r14: %016lx\n",
            regs->r12, regs->r13, regs->r14);
-    printk("r15: %016lx\n", regs->r15);
+    printk("r15: %016lx    cs: %016lx    ss: %016lx\n",
+           regs->r15, (long)regs->cs, (long)regs->ss);
     show_stack_overflow(cpu, regs->rsp);
 
     panic("DOUBLE FAULT -- system shutdown\n");
@@ -260,11 +261,14 @@ void __init percpu_traps_init(void)
         idt_table[TRAP_double_fault].a |= 1UL << 32; /* IST1 */
         idt_table[TRAP_nmi].a          |= 2UL << 32; /* IST2 */
 
-#ifdef CONFIG_COMPAT
-        /* The hypercall entry vector is only accessible from ring 1. */
+        /*
+         * The 32-on-64 hypercall entry vector is only accessible from ring 1.
+         * Also note that this is a trap gate, not an interrupt gate.
+         */
         _set_gate(idt_table+HYPERCALL_VECTOR, 15, 1, &compat_hypercall);
+
+        /* Fast trap for int80 (faster than taking the #GP-fixup path). */
         _set_gate(idt_table+0x80, 15, 3, &int80_direct_trap);
-#endif
     }
 
     stack_bottom = (char *)get_stack_bottom();
diff -r bd73cb523111 -r f80a97d26276 xen/include/asm-x86/desc.h
--- a/xen/include/asm-x86/desc.h        Fri Apr 06 14:35:25 2007 +0100
+++ b/xen/include/asm-x86/desc.h        Fri Apr 06 15:07:34 2007 +0100
@@ -106,7 +106,7 @@
     ((((sel)>>3) < FIRST_RESERVED_GDT_ENTRY) || /* Guest seg? */        \
      ((sel) == (!IS_COMPAT(d) ?                                         \
                 FLAT_KERNEL_CS :                /* Xen default seg? */  \
-                FLAT_COMPAT_KERNEL_CS)) ||      /* Xen default compat seg? */  
\
+                FLAT_COMPAT_KERNEL_CS)) ||                              \
      ((sel) & 4))                               /* LDT seg? */
 
 #endif /* __ASSEMBLY__ */
diff -r bd73cb523111 -r f80a97d26276 xen/include/asm-x86/x86_32/asm_defns.h
--- a/xen/include/asm-x86/x86_32/asm_defns.h    Fri Apr 06 14:35:25 2007 +0100
+++ b/xen/include/asm-x86/x86_32/asm_defns.h    Fri Apr 06 15:07:34 2007 +0100
@@ -8,9 +8,19 @@
 #define SETUP_EXCEPTION_FRAME_POINTER           \
         movl  %esp,%ebp;                        \
         notl  %ebp
+#define ASSERT_INTERRUPT_STATUS(x)              \
+        pushf;                                  \
+        testb $X86_EFLAGS_IF>>8,1(%esp);        \
+        j##x  1f;                               \
+        ud2a;                                   \
+1:      addl  $4,%esp;
 #else
 #define SETUP_EXCEPTION_FRAME_POINTER
+#define ASSERT_INTERRUPT_STATUS(x)
 #endif
+
+#define ASSERT_INTERRUPTS_ENABLED  ASSERT_INTERRUPT_STATUS(nz)
+#define ASSERT_INTERRUPTS_DISABLED ASSERT_INTERRUPT_STATUS(z)
 
 #define __SAVE_ALL_PRE                                  \
         cld;                                            \
diff -r bd73cb523111 -r f80a97d26276 xen/include/asm-x86/x86_64/asm_defns.h
--- a/xen/include/asm-x86/x86_64/asm_defns.h    Fri Apr 06 14:35:25 2007 +0100
+++ b/xen/include/asm-x86/x86_64/asm_defns.h    Fri Apr 06 15:07:34 2007 +0100
@@ -8,9 +8,19 @@
 #define SETUP_EXCEPTION_FRAME_POINTER           \
         movq  %rsp,%rbp;                        \
         notq  %rbp
+#define ASSERT_INTERRUPT_STATUS(x)              \
+        pushf;                                  \
+        testb $X86_EFLAGS_IF>>8,1(%rsp);        \
+        j##x  1f;                               \
+        ud2a;                                   \
+1:      addq  $8,%rsp;
 #else
 #define SETUP_EXCEPTION_FRAME_POINTER
+#define ASSERT_INTERRUPT_STATUS(x)
 #endif
+
+#define ASSERT_INTERRUPTS_ENABLED  ASSERT_INTERRUPT_STATUS(nz)
+#define ASSERT_INTERRUPTS_DISABLED ASSERT_INTERRUPT_STATUS(z)
 
 #define SAVE_ALL                                \
         cld;                                    \

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xen x86/64: Fix int80 direct trap. It must check for events and also, Xen patchbot-unstable <=