ia64/xen-unstable

changeset 8987:436c4c83a200

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@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Feb 23 18:27:18 2006 +0100 (2006-02-23)
parents 643940bb3e50
children 49c02a7a92dd
files linux-2.6-xen-sparse/arch/x86_64/ia32/syscall32-xen.c linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S linux-2.6-xen-sparse/arch/x86_64/kernel/traps-xen.c linux-2.6-xen-sparse/drivers/xen/core/smpboot.c xen/arch/x86/x86_32/mm.c xen/arch/x86/x86_64/mm.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/x86_64/ia32/syscall32-xen.c	Thu Feb 23 17:14:55 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/ia32/syscall32-xen.c	Thu Feb 23 18:27:18 2006 +0100
     1.3 @@ -119,7 +119,7 @@ void syscall32_cpu_init(void)
     1.4  
     1.5  	/* Load these always in case some future AMD CPU supports
     1.6  	   SYSENTER from compat mode too. */
     1.7 -	checking_wrmsrl(MSR_IA32_SYSENTER_CS, (u64)(__KERNEL_CS | 3));
     1.8 +	checking_wrmsrl(MSR_IA32_SYSENTER_CS, (u64)__KERNEL_CS);
     1.9  	checking_wrmsrl(MSR_IA32_SYSENTER_ESP, 0ULL);
    1.10  	checking_wrmsrl(MSR_IA32_SYSENTER_EIP, (u64)ia32_sysenter_target);
    1.11  
     2.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S	Thu Feb 23 17:14:55 2006 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S	Thu Feb 23 18:27:18 2006 +0100
     2.3 @@ -325,7 +325,7 @@ ENTRY(int_ret_from_sys_call)
     2.4  	testb $3,CS-ARGOFFSET(%rsp)
     2.5          jnz 1f
     2.6          /* Need to set the proper %ss (not NULL) for ring 3 iretq */
     2.7 -        movl $__KERNEL_DS,SS-ARGOFFSET(%rsp)
     2.8 +        movl $__KERNEL_DS|3,SS-ARGOFFSET(%rsp)
     2.9          jmp retint_restore_args   # retrun from ring3 kernel
    2.10  1:              
    2.11  	movl $_TIF_ALLWORK_MASK,%edi
     3.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S	Thu Feb 23 17:14:55 2006 +0000
     3.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S	Thu Feb 23 18:27:18 2006 +0100
     3.3 @@ -111,12 +111,12 @@ gdt:
     3.4  ENTRY(cpu_gdt_table)
     3.5  	.quad	0x0000000000000000	/* NULL descriptor */
     3.6  	.quad	0x0			/* unused */
     3.7 -	.quad	0x00affa000000ffff	/* __KERNEL_CS */
     3.8 -	.quad	0x00cff2000000ffff	/* __KERNEL_DS */
     3.9 +	.quad	0x00af9a000000ffff	/* __KERNEL_CS */
    3.10 +	.quad	0x00cf92000000ffff	/* __KERNEL_DS */
    3.11  	.quad	0x00cffa000000ffff	/* __USER32_CS */
    3.12  	.quad	0x00cff2000000ffff	/* __USER_DS, __USER32_DS  */
    3.13  	.quad	0x00affa000000ffff	/* __USER_CS */
    3.14 -	.quad	0x00cffa000000ffff	/* __KERNEL32_CS */
    3.15 +	.quad	0x00cf9a000000ffff	/* __KERNEL32_CS */
    3.16  	.quad	0,0			/* TSS */
    3.17  	.quad	0,0			/* LDT */
    3.18  	.quad   0,0,0			/* three TLS descriptors */
    3.19 @@ -151,5 +151,6 @@ gdt_end:
    3.20  	.ascii  ",FEATURES=writable_page_tables"
    3.21  	.ascii		 "|writable_descriptor_tables"
    3.22  	.ascii		 "|auto_translated_physmap"
    3.23 +	.ascii	         "|supervisor_mode_kernel"
    3.24  	.ascii	",LOADER=generic"
    3.25  	.byte	0
     4.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/traps-xen.c	Thu Feb 23 17:14:55 2006 +0000
     4.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/traps-xen.c	Thu Feb 23 18:27:18 2006 +0100
     4.3 @@ -952,28 +952,28 @@ asmlinkage void math_state_restore(void)
     4.4   * specify <dpl>|4 in the second field.
     4.5   */
     4.6  static trap_info_t trap_table[] = {
     4.7 -        {  0, 0|4, (__KERNEL_CS|0x3), (unsigned long)divide_error               },
     4.8 -        {  1, 0|4, (__KERNEL_CS|0x3), (unsigned long)debug                      },
     4.9 -        {  3, 3|4, (__KERNEL_CS|0x3), (unsigned long)int3                       },
    4.10 -        {  4, 3|4, (__KERNEL_CS|0x3), (unsigned long)overflow                   },
    4.11 -        {  5, 0|4, (__KERNEL_CS|0x3), (unsigned long)bounds                     },
    4.12 -        {  6, 0|4, (__KERNEL_CS|0x3), (unsigned long)invalid_op                 },
    4.13 -        {  7, 0|4, (__KERNEL_CS|0x3), (unsigned long)device_not_available       },
    4.14 -        {  9, 0|4, (__KERNEL_CS|0x3), (unsigned long)coprocessor_segment_overrun},
    4.15 -        { 10, 0|4, (__KERNEL_CS|0x3), (unsigned long)invalid_TSS                },
    4.16 -        { 11, 0|4, (__KERNEL_CS|0x3), (unsigned long)segment_not_present        },
    4.17 -        { 12, 0|4, (__KERNEL_CS|0x3), (unsigned long)stack_segment              },
    4.18 -        { 13, 0|4, (__KERNEL_CS|0x3), (unsigned long)general_protection         },
    4.19 -        { 14, 0|4, (__KERNEL_CS|0x3), (unsigned long)page_fault                 },
    4.20 -        { 15, 0|4, (__KERNEL_CS|0x3), (unsigned long)spurious_interrupt_bug     },
    4.21 -        { 16, 0|4, (__KERNEL_CS|0x3), (unsigned long)coprocessor_error          },
    4.22 -        { 17, 0|4, (__KERNEL_CS|0x3), (unsigned long)alignment_check            },
    4.23 +        {  0, 0|4, __KERNEL_CS, (unsigned long)divide_error               },
    4.24 +        {  1, 0|4, __KERNEL_CS, (unsigned long)debug                      },
    4.25 +        {  3, 3|4, __KERNEL_CS, (unsigned long)int3                       },
    4.26 +        {  4, 3|4, __KERNEL_CS, (unsigned long)overflow                   },
    4.27 +        {  5, 0|4, __KERNEL_CS, (unsigned long)bounds                     },
    4.28 +        {  6, 0|4, __KERNEL_CS, (unsigned long)invalid_op                 },
    4.29 +        {  7, 0|4, __KERNEL_CS, (unsigned long)device_not_available       },
    4.30 +        {  9, 0|4, __KERNEL_CS, (unsigned long)coprocessor_segment_overrun},
    4.31 +        { 10, 0|4, __KERNEL_CS, (unsigned long)invalid_TSS                },
    4.32 +        { 11, 0|4, __KERNEL_CS, (unsigned long)segment_not_present        },
    4.33 +        { 12, 0|4, __KERNEL_CS, (unsigned long)stack_segment              },
    4.34 +        { 13, 0|4, __KERNEL_CS, (unsigned long)general_protection         },
    4.35 +        { 14, 0|4, __KERNEL_CS, (unsigned long)page_fault                 },
    4.36 +        { 15, 0|4, __KERNEL_CS, (unsigned long)spurious_interrupt_bug     },
    4.37 +        { 16, 0|4, __KERNEL_CS, (unsigned long)coprocessor_error          },
    4.38 +        { 17, 0|4, __KERNEL_CS, (unsigned long)alignment_check            },
    4.39  #ifdef CONFIG_X86_MCE
    4.40 -        { 18, 0|4, (__KERNEL_CS|0x3), (unsigned long)machine_check              },
    4.41 +        { 18, 0|4, __KERNEL_CS, (unsigned long)machine_check              },
    4.42  #endif
    4.43 -        { 19, 0|4, (__KERNEL_CS|0x3), (unsigned long)simd_coprocessor_error     },
    4.44 +        { 19, 0|4, __KERNEL_CS, (unsigned long)simd_coprocessor_error     },
    4.45  #ifdef CONFIG_IA32_EMULATION
    4.46 -	{ IA32_SYSCALL_VECTOR, 3|4, (__KERNEL_CS|0x3), (unsigned long)ia32_syscall},
    4.47 +	{ IA32_SYSCALL_VECTOR, 3|4, __KERNEL_CS, (unsigned long)ia32_syscall},
    4.48  #endif
    4.49          {  0, 0,           0, 0                                              }
    4.50  };
     5.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c	Thu Feb 23 17:14:55 2006 +0000
     5.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c	Thu Feb 23 18:27:18 2006 +0100
     5.3 @@ -188,7 +188,7 @@ void vcpu_prepare(int vcpu)
     5.4  
     5.5  	ctxt.ctrlreg[3] = virt_to_mfn(swapper_pg_dir) << PAGE_SHIFT;
     5.6  #else /* __x86_64__ */
     5.7 -	ctxt.user_regs.cs = __KERNEL_CS | 3;
     5.8 +	ctxt.user_regs.cs = __KERNEL_CS;
     5.9  	ctxt.user_regs.esp = idle->thread.rsp0 - sizeof(struct pt_regs);
    5.10  
    5.11  	ctxt.kernel_ss = __KERNEL_DS;
     6.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/segment.h	Thu Feb 23 17:14:55 2006 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,44 +0,0 @@
     6.4 -#ifndef _ASM_SEGMENT_H
     6.5 -#define _ASM_SEGMENT_H
     6.6 -
     6.7 -#include <asm/cache.h>
     6.8 -
     6.9 -#define __KERNEL_CS	0x10
    6.10 -#define __KERNEL_DS	0x1b
    6.11 -
    6.12 -#define __KERNEL32_CS   0x3b
    6.13 -
    6.14 -/* 
    6.15 - * we cannot use the same code segment descriptor for user and kernel
    6.16 - * -- not even in the long flat mode, because of different DPL /kkeil 
    6.17 - * The segment offset needs to contain a RPL. Grr. -AK
    6.18 - * GDT layout to get 64bit syscall right (sysret hardcodes gdt offsets) 
    6.19 - */
    6.20 -
    6.21 -#define __USER32_CS   0x23   /* 4*8+3 */ 
    6.22 -#define __USER_DS     0x2b   /* 5*8+3 */ 
    6.23 -#define __USER_CS     0x33   /* 6*8+3 */ 
    6.24 -#define __USER32_DS	__USER_DS 
    6.25 -
    6.26 -#define GDT_ENTRY_TLS 1
    6.27 -#define GDT_ENTRY_TSS 8	/* needs two entries */
    6.28 -#define GDT_ENTRY_LDT 10 /* needs two entries */
    6.29 -#define GDT_ENTRY_TLS_MIN 12
    6.30 -#define GDT_ENTRY_TLS_MAX 14
    6.31 -/* 15 free */
    6.32 -
    6.33 -#define GDT_ENTRY_TLS_ENTRIES 3
    6.34 -
    6.35 -/* TLS indexes for 64bit - hardcoded in arch_prctl */
    6.36 -#define FS_TLS 0	
    6.37 -#define GS_TLS 1	
    6.38 -
    6.39 -#define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
    6.40 -#define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
    6.41 -
    6.42 -#define IDT_ENTRIES 256
    6.43 -#define GDT_ENTRIES 16
    6.44 -#define GDT_SIZE (GDT_ENTRIES * 8)
    6.45 -#define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8) 
    6.46 -
    6.47 -#endif
     7.1 --- a/xen/arch/x86/x86_32/mm.c	Thu Feb 23 17:14:55 2006 +0000
     7.2 +++ b/xen/arch/x86/x86_32/mm.c	Thu Feb 23 18:27:18 2006 +0100
     7.3 @@ -250,8 +250,8 @@ int check_descriptor(struct desc_struct 
     7.4       * gates (consider a call gate pointing at another kernel descriptor with 
     7.5       * DPL 0 -- this would get the OS ring-0 privileges).
     7.6       */
     7.7 -    if ( (b & _SEGMENT_DPL) == 0 )
     7.8 -        d->b = b = b | (0x01<<13); /* Force DPL == 1 */
     7.9 +    if ( (b & _SEGMENT_DPL) < (GUEST_KERNEL_RPL << 13) )
    7.10 +        d->b = b = (b & ~_SEGMENT_DPL) | (GUEST_KERNEL_RPL << 13);
    7.11  
    7.12      if ( !(b & _SEGMENT_S) )
    7.13      {
     8.1 --- a/xen/arch/x86/x86_64/mm.c	Thu Feb 23 17:14:55 2006 +0000
     8.2 +++ b/xen/arch/x86/x86_64/mm.c	Thu Feb 23 18:27:18 2006 +0100
     8.3 @@ -228,8 +228,7 @@ long subarch_memory_op(int op, void *arg
     8.4  
     8.5  long do_stack_switch(unsigned long ss, unsigned long esp)
     8.6  {
     8.7 -    if ( (ss & 3) != 3 )
     8.8 -        return -EPERM;
     8.9 +    fixup_guest_selector(ss);
    8.10      current->arch.guest_context.kernel_ss = ss;
    8.11      current->arch.guest_context.kernel_sp = esp;
    8.12      return 0;
    8.13 @@ -298,9 +297,9 @@ int check_descriptor(struct desc_struct 
    8.14      if ( !(b & _SEGMENT_P) ) 
    8.15          goto good;
    8.16  
    8.17 -    /* The guest can only safely be executed in ring 3. */
    8.18 -    if ( (b & _SEGMENT_DPL) != _SEGMENT_DPL )
    8.19 -        goto bad;
    8.20 +    /* Check and fix up the DPL. */
    8.21 +    if ( (b & _SEGMENT_DPL) < (GUEST_KERNEL_RPL << 13) )
    8.22 +        d->b = b = (b & ~_SEGMENT_DPL) | (GUEST_KERNEL_RPL << 13);
    8.23  
    8.24      /* All code and data segments are okay. No base/limit checking. */
    8.25      if ( (b & _SEGMENT_S) )