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] Remove explicit munging of selector RPLs from Xen Linux

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Remove explicit munging of selector RPLs from Xen Linux x86/64.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 23 Feb 2006 19:42:08 +0000
Delivery-date: Thu, 23 Feb 2006 19:42:27 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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 kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 436c4c83a200cd86e1304e36a1278bdc1ecb490d
# Parent  643940bb3e50ebeac243f422f5af780fea1442da
Remove explicit munging of selector RPLs from Xen Linux x86/64.
Not needed now it's done by Xen.

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r 643940bb3e50 -r 436c4c83a200 
linux-2.6-xen-sparse/arch/x86_64/ia32/syscall32-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/ia32/syscall32-xen.c     Thu Feb 23 
17:14:55 2006
+++ b/linux-2.6-xen-sparse/arch/x86_64/ia32/syscall32-xen.c     Thu Feb 23 
17:27:18 2006
@@ -119,7 +119,7 @@
 
        /* Load these always in case some future AMD CPU supports
           SYSENTER from compat mode too. */
-       checking_wrmsrl(MSR_IA32_SYSENTER_CS, (u64)(__KERNEL_CS | 3));
+       checking_wrmsrl(MSR_IA32_SYSENTER_CS, (u64)__KERNEL_CS);
        checking_wrmsrl(MSR_IA32_SYSENTER_ESP, 0ULL);
        checking_wrmsrl(MSR_IA32_SYSENTER_EIP, (u64)ia32_sysenter_target);
 
diff -r 643940bb3e50 -r 436c4c83a200 
linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S       Thu Feb 23 
17:14:55 2006
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S       Thu Feb 23 
17:27:18 2006
@@ -325,7 +325,7 @@
        testb $3,CS-ARGOFFSET(%rsp)
         jnz 1f
         /* Need to set the proper %ss (not NULL) for ring 3 iretq */
-        movl $__KERNEL_DS,SS-ARGOFFSET(%rsp)
+        movl $__KERNEL_DS|3,SS-ARGOFFSET(%rsp)
         jmp retint_restore_args   # retrun from ring3 kernel
 1:              
        movl $_TIF_ALLWORK_MASK,%edi
diff -r 643940bb3e50 -r 436c4c83a200 
linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S        Thu Feb 23 
17:14:55 2006
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S        Thu Feb 23 
17:27:18 2006
@@ -111,12 +111,12 @@
 ENTRY(cpu_gdt_table)
        .quad   0x0000000000000000      /* NULL descriptor */
        .quad   0x0                     /* unused */
-       .quad   0x00affa000000ffff      /* __KERNEL_CS */
-       .quad   0x00cff2000000ffff      /* __KERNEL_DS */
+       .quad   0x00af9a000000ffff      /* __KERNEL_CS */
+       .quad   0x00cf92000000ffff      /* __KERNEL_DS */
        .quad   0x00cffa000000ffff      /* __USER32_CS */
        .quad   0x00cff2000000ffff      /* __USER_DS, __USER32_DS  */
        .quad   0x00affa000000ffff      /* __USER_CS */
-       .quad   0x00cffa000000ffff      /* __KERNEL32_CS */
+       .quad   0x00cf9a000000ffff      /* __KERNEL32_CS */
        .quad   0,0                     /* TSS */
        .quad   0,0                     /* LDT */
        .quad   0,0,0                   /* three TLS descriptors */
@@ -151,5 +151,6 @@
        .ascii  ",FEATURES=writable_page_tables"
        .ascii           "|writable_descriptor_tables"
        .ascii           "|auto_translated_physmap"
+       .ascii           "|supervisor_mode_kernel"
        .ascii  ",LOADER=generic"
        .byte   0
diff -r 643940bb3e50 -r 436c4c83a200 
linux-2.6-xen-sparse/arch/x86_64/kernel/traps-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/traps-xen.c       Thu Feb 23 
17:14:55 2006
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/traps-xen.c       Thu Feb 23 
17:27:18 2006
@@ -952,28 +952,28 @@
  * specify <dpl>|4 in the second field.
  */
 static trap_info_t trap_table[] = {
-        {  0, 0|4, (__KERNEL_CS|0x3), (unsigned long)divide_error              
 },
-        {  1, 0|4, (__KERNEL_CS|0x3), (unsigned long)debug                     
 },
-        {  3, 3|4, (__KERNEL_CS|0x3), (unsigned long)int3                      
 },
-        {  4, 3|4, (__KERNEL_CS|0x3), (unsigned long)overflow                  
 },
-        {  5, 0|4, (__KERNEL_CS|0x3), (unsigned long)bounds                    
 },
-        {  6, 0|4, (__KERNEL_CS|0x3), (unsigned long)invalid_op                
 },
-        {  7, 0|4, (__KERNEL_CS|0x3), (unsigned long)device_not_available      
 },
-        {  9, 0|4, (__KERNEL_CS|0x3), (unsigned 
long)coprocessor_segment_overrun},
-        { 10, 0|4, (__KERNEL_CS|0x3), (unsigned long)invalid_TSS               
 },
-        { 11, 0|4, (__KERNEL_CS|0x3), (unsigned long)segment_not_present       
 },
-        { 12, 0|4, (__KERNEL_CS|0x3), (unsigned long)stack_segment             
 },
-        { 13, 0|4, (__KERNEL_CS|0x3), (unsigned long)general_protection        
 },
-        { 14, 0|4, (__KERNEL_CS|0x3), (unsigned long)page_fault                
 },
-        { 15, 0|4, (__KERNEL_CS|0x3), (unsigned long)spurious_interrupt_bug    
 },
-        { 16, 0|4, (__KERNEL_CS|0x3), (unsigned long)coprocessor_error         
 },
-        { 17, 0|4, (__KERNEL_CS|0x3), (unsigned long)alignment_check           
 },
+        {  0, 0|4, __KERNEL_CS, (unsigned long)divide_error               },
+        {  1, 0|4, __KERNEL_CS, (unsigned long)debug                      },
+        {  3, 3|4, __KERNEL_CS, (unsigned long)int3                       },
+        {  4, 3|4, __KERNEL_CS, (unsigned long)overflow                   },
+        {  5, 0|4, __KERNEL_CS, (unsigned long)bounds                     },
+        {  6, 0|4, __KERNEL_CS, (unsigned long)invalid_op                 },
+        {  7, 0|4, __KERNEL_CS, (unsigned long)device_not_available       },
+        {  9, 0|4, __KERNEL_CS, (unsigned long)coprocessor_segment_overrun},
+        { 10, 0|4, __KERNEL_CS, (unsigned long)invalid_TSS                },
+        { 11, 0|4, __KERNEL_CS, (unsigned long)segment_not_present        },
+        { 12, 0|4, __KERNEL_CS, (unsigned long)stack_segment              },
+        { 13, 0|4, __KERNEL_CS, (unsigned long)general_protection         },
+        { 14, 0|4, __KERNEL_CS, (unsigned long)page_fault                 },
+        { 15, 0|4, __KERNEL_CS, (unsigned long)spurious_interrupt_bug     },
+        { 16, 0|4, __KERNEL_CS, (unsigned long)coprocessor_error          },
+        { 17, 0|4, __KERNEL_CS, (unsigned long)alignment_check            },
 #ifdef CONFIG_X86_MCE
-        { 18, 0|4, (__KERNEL_CS|0x3), (unsigned long)machine_check             
 },
-#endif
-        { 19, 0|4, (__KERNEL_CS|0x3), (unsigned long)simd_coprocessor_error    
 },
+        { 18, 0|4, __KERNEL_CS, (unsigned long)machine_check              },
+#endif
+        { 19, 0|4, __KERNEL_CS, (unsigned long)simd_coprocessor_error     },
 #ifdef CONFIG_IA32_EMULATION
-       { IA32_SYSCALL_VECTOR, 3|4, (__KERNEL_CS|0x3), (unsigned 
long)ia32_syscall},
+       { IA32_SYSCALL_VECTOR, 3|4, __KERNEL_CS, (unsigned long)ia32_syscall},
 #endif
         {  0, 0,           0, 0                                              }
 };
diff -r 643940bb3e50 -r 436c4c83a200 
linux-2.6-xen-sparse/drivers/xen/core/smpboot.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c   Thu Feb 23 17:14:55 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c   Thu Feb 23 17:27:18 2006
@@ -188,7 +188,7 @@
 
        ctxt.ctrlreg[3] = virt_to_mfn(swapper_pg_dir) << PAGE_SHIFT;
 #else /* __x86_64__ */
-       ctxt.user_regs.cs = __KERNEL_CS | 3;
+       ctxt.user_regs.cs = __KERNEL_CS;
        ctxt.user_regs.esp = idle->thread.rsp0 - sizeof(struct pt_regs);
 
        ctxt.kernel_ss = __KERNEL_DS;
diff -r 643940bb3e50 -r 436c4c83a200 xen/arch/x86/x86_32/mm.c
--- a/xen/arch/x86/x86_32/mm.c  Thu Feb 23 17:14:55 2006
+++ b/xen/arch/x86/x86_32/mm.c  Thu Feb 23 17:27:18 2006
@@ -250,8 +250,8 @@
      * gates (consider a call gate pointing at another kernel descriptor with 
      * DPL 0 -- this would get the OS ring-0 privileges).
      */
-    if ( (b & _SEGMENT_DPL) == 0 )
-        d->b = b = b | (0x01<<13); /* Force DPL == 1 */
+    if ( (b & _SEGMENT_DPL) < (GUEST_KERNEL_RPL << 13) )
+        d->b = b = (b & ~_SEGMENT_DPL) | (GUEST_KERNEL_RPL << 13);
 
     if ( !(b & _SEGMENT_S) )
     {
diff -r 643940bb3e50 -r 436c4c83a200 xen/arch/x86/x86_64/mm.c
--- a/xen/arch/x86/x86_64/mm.c  Thu Feb 23 17:14:55 2006
+++ b/xen/arch/x86/x86_64/mm.c  Thu Feb 23 17:27:18 2006
@@ -228,8 +228,7 @@
 
 long do_stack_switch(unsigned long ss, unsigned long esp)
 {
-    if ( (ss & 3) != 3 )
-        return -EPERM;
+    fixup_guest_selector(ss);
     current->arch.guest_context.kernel_ss = ss;
     current->arch.guest_context.kernel_sp = esp;
     return 0;
@@ -298,9 +297,9 @@
     if ( !(b & _SEGMENT_P) ) 
         goto good;
 
-    /* The guest can only safely be executed in ring 3. */
-    if ( (b & _SEGMENT_DPL) != _SEGMENT_DPL )
-        goto bad;
+    /* Check and fix up the DPL. */
+    if ( (b & _SEGMENT_DPL) < (GUEST_KERNEL_RPL << 13) )
+        d->b = b = (b & ~_SEGMENT_DPL) | (GUEST_KERNEL_RPL << 13);
 
     /* All code and data segments are okay. No base/limit checking. */
     if ( (b & _SEGMENT_S) )
diff -r 643940bb3e50 -r 436c4c83a200 
linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/segment.h
--- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/segment.h    Thu Feb 
23 17:14:55 2006
+++ /dev/null   Thu Feb 23 17:27:18 2006
@@ -1,44 +0,0 @@
-#ifndef _ASM_SEGMENT_H
-#define _ASM_SEGMENT_H
-
-#include <asm/cache.h>
-
-#define __KERNEL_CS    0x10
-#define __KERNEL_DS    0x1b
-
-#define __KERNEL32_CS   0x3b
-
-/* 
- * we cannot use the same code segment descriptor for user and kernel
- * -- not even in the long flat mode, because of different DPL /kkeil 
- * The segment offset needs to contain a RPL. Grr. -AK
- * GDT layout to get 64bit syscall right (sysret hardcodes gdt offsets) 
- */
-
-#define __USER32_CS   0x23   /* 4*8+3 */ 
-#define __USER_DS     0x2b   /* 5*8+3 */ 
-#define __USER_CS     0x33   /* 6*8+3 */ 
-#define __USER32_DS    __USER_DS 
-
-#define GDT_ENTRY_TLS 1
-#define GDT_ENTRY_TSS 8        /* needs two entries */
-#define GDT_ENTRY_LDT 10 /* needs two entries */
-#define GDT_ENTRY_TLS_MIN 12
-#define GDT_ENTRY_TLS_MAX 14
-/* 15 free */
-
-#define GDT_ENTRY_TLS_ENTRIES 3
-
-/* TLS indexes for 64bit - hardcoded in arch_prctl */
-#define FS_TLS 0       
-#define GS_TLS 1       
-
-#define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
-#define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
-
-#define IDT_ENTRIES 256
-#define GDT_ENTRIES 16
-#define GDT_SIZE (GDT_ENTRIES * 8)
-#define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8) 
-
-#endif

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Remove explicit munging of selector RPLs from Xen Linux x86/64., Xen patchbot -unstable <=