ia64/xen-unstable

changeset 4498:3f2415a328b7

bitkeeper revision 1.1282 (4254e8d92URVK0d-Uc-p1l7ymBS-HA)

A few x86/64 cleanups.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Apr 07 08:01:29 2005 +0000 (2005-04-07)
parents 6a9598f401d9
children f301b12bedde
files xen/arch/x86/domain.c xen/arch/x86/x86_64/mm.c xen/include/asm-x86/config.h xen/include/asm-x86/x86_64/asm_defns.h xen/include/asm-x86/x86_64/page.h xen/include/xen/shadow.h
line diff
     1.1 --- a/xen/arch/x86/domain.c	Thu Apr 07 07:56:34 2005 +0000
     1.2 +++ b/xen/arch/x86/domain.c	Thu Apr 07 08:01:29 2005 +0000
     1.3 @@ -516,7 +516,7 @@ void new_thread(struct exec_domain *d,
     1.4  void toggle_guest_mode(struct exec_domain *ed)
     1.5  {
     1.6      ed->arch.flags ^= TF_kernel_mode;
     1.7 -    __asm__ __volatile__ ( "mfence; swapgs" ); /* AMD erratum #88 */
     1.8 +    __asm__ __volatile__ ( "swapgs" );
     1.9      update_pagetables(ed);
    1.10      write_ptbase(ed);
    1.11  }
    1.12 @@ -600,7 +600,7 @@ static void load_segments(struct exec_do
    1.13  
    1.14      /* If in kernel mode then switch the GS bases around. */
    1.15      if ( n->arch.flags & TF_kernel_mode )
    1.16 -        __asm__ __volatile__ ( "mfence; swapgs" ); /* AMD erratum #88 */
    1.17 +        __asm__ __volatile__ ( safe_swapgs );
    1.18  
    1.19      if ( unlikely(!all_segs_okay) )
    1.20      {
    1.21 @@ -651,12 +651,12 @@ static void save_segments(struct exec_do
    1.22  static void clear_segments(void)
    1.23  {
    1.24      __asm__ __volatile__ (
    1.25 -        "movl %0,%%ds; "
    1.26 -        "movl %0,%%es; "
    1.27 -        "movl %0,%%fs; "
    1.28 -        "movl %0,%%gs; "
    1.29 -        "mfence; swapgs; " /* AMD erratum #88 */
    1.30 -        "movl %0,%%gs"
    1.31 +        " movl %0,%%ds; "
    1.32 +        " movl %0,%%es; "
    1.33 +        " movl %0,%%fs; "
    1.34 +        " movl %0,%%gs; "
    1.35 +        ""safe_swapgs"  "
    1.36 +        " movl %0,%%gs"
    1.37          : : "r" (0) );
    1.38  }
    1.39  
     2.1 --- a/xen/arch/x86/x86_64/mm.c	Thu Apr 07 07:56:34 2005 +0000
     2.2 +++ b/xen/arch/x86/x86_64/mm.c	Thu Apr 07 08:01:29 2005 +0000
     2.3 @@ -23,6 +23,7 @@
     2.4  #include <xen/init.h>
     2.5  #include <xen/mm.h>
     2.6  #include <xen/sched.h>
     2.7 +#include <asm/asm_defns.h>
     2.8  #include <asm/page.h>
     2.9  #include <asm/flushtlb.h>
    2.10  #include <asm/fixmap.h>
    2.11 @@ -248,31 +249,33 @@ long do_stack_switch(unsigned long ss, u
    2.12  long do_set_segment_base(unsigned int which, unsigned long base)
    2.13  {
    2.14      struct exec_domain *ed = current;
    2.15 -
    2.16 -    base = canonicalise_virt_address(base);
    2.17 +    long ret = 0;
    2.18  
    2.19      switch ( which )
    2.20      {
    2.21      case SEGBASE_FS:
    2.22          ed->arch.user_ctxt.fs_base = base;
    2.23 -        wrmsr(MSR_FS_BASE, base, base>>32);
    2.24 +        if ( wrmsr_user(MSR_FS_BASE, base, base>>32) )
    2.25 +            ret = -EFAULT;
    2.26          break;
    2.27  
    2.28      case SEGBASE_GS_USER:
    2.29          ed->arch.user_ctxt.gs_base_user = base;
    2.30 -        wrmsr(MSR_SHADOW_GS_BASE, base, base>>32);
    2.31 +        if ( wrmsr_user(MSR_SHADOW_GS_BASE, base, base>>32) )
    2.32 +            ret = -EFAULT;
    2.33          break;
    2.34  
    2.35      case SEGBASE_GS_KERNEL:
    2.36          ed->arch.user_ctxt.gs_base_kernel = base;
    2.37 -        wrmsr(MSR_GS_BASE, base, base>>32);
    2.38 +        if ( wrmsr_user(MSR_GS_BASE, base, base>>32) )
    2.39 +            ret = -EFAULT;
    2.40          break;
    2.41  
    2.42      case SEGBASE_GS_USER_SEL:
    2.43          __asm__ __volatile__ (
    2.44              "     swapgs              \n"
    2.45              "1:   movl %k0,%%gs       \n"
    2.46 -            "     mfence; swapgs      \n" /* AMD erratum #88 */
    2.47 +            "    "safe_swapgs"        \n"
    2.48              ".section .fixup,\"ax\"   \n"
    2.49              "2:   xorl %k0,%k0        \n"
    2.50              "     jmp  1b             \n"
    2.51 @@ -285,10 +288,11 @@ long do_set_segment_base(unsigned int wh
    2.52          break;
    2.53  
    2.54      default:
    2.55 -        return -EINVAL;
    2.56 +        ret = -EINVAL;
    2.57 +        break;
    2.58      }
    2.59  
    2.60 -    return 0;
    2.61 +    return ret;
    2.62  }
    2.63  
    2.64  
     3.1 --- a/xen/include/asm-x86/config.h	Thu Apr 07 07:56:34 2005 +0000
     3.2 +++ b/xen/include/asm-x86/config.h	Thu Apr 07 08:01:29 2005 +0000
     3.3 @@ -12,6 +12,7 @@
     3.4  #endif
     3.5  
     3.6  #define CONFIG_X86 1
     3.7 +#define CONFIG_SHADOW 1
     3.8  
     3.9  #define CONFIG_SMP 1
    3.10  #define CONFIG_X86_LOCAL_APIC 1
     4.1 --- a/xen/include/asm-x86/x86_64/asm_defns.h	Thu Apr 07 07:56:34 2005 +0000
     4.2 +++ b/xen/include/asm-x86/x86_64/asm_defns.h	Thu Apr 07 08:01:29 2005 +0000
     4.3 @@ -39,6 +39,10 @@
     4.4          "popq  %rsi;" \
     4.5          "popq  %rdi;"
     4.6  
     4.7 +/* Work around AMD erratum #88 */
     4.8 +#define safe_swapgs \
     4.9 +        "mfence; swapgs;"
    4.10 +
    4.11  #else
    4.12  
    4.13  #define SAVE_ALL \
     5.1 --- a/xen/include/asm-x86/x86_64/page.h	Thu Apr 07 07:56:34 2005 +0000
     5.2 +++ b/xen/include/asm-x86/x86_64/page.h	Thu Apr 07 08:01:29 2005 +0000
     5.3 @@ -98,15 +98,6 @@ typedef l4_pgentry_t root_pgentry_t;
     5.4  #define L3_DISALLOW_MASK ((cpu_has_nx?0:(1UL<<63)) | (7UL << 7))
     5.5  #define L4_DISALLOW_MASK ((cpu_has_nx?0:(1UL<<63)) | (7UL << 7))
     5.6  
     5.7 -#ifndef __ASSEMBLY__
     5.8 -static inline unsigned long canonicalise_virt_address(unsigned long v)
     5.9 -{
    5.10 -    v &= VADDR_MASK;
    5.11 -    if ( v & (1UL << (VADDR_BITS - 1)) )
    5.12 -        v |= ~VADDR_MASK;
    5.13 -}
    5.14 -#endif /* !__ASSEMBLY__ */
    5.15 -
    5.16  #endif /* __X86_64_PAGE_H__ */
    5.17  
    5.18  /*
     6.1 --- a/xen/include/xen/shadow.h	Thu Apr 07 07:56:34 2005 +0000
     6.2 +++ b/xen/include/xen/shadow.h	Thu Apr 07 08:01:29 2005 +0000
     6.3 @@ -4,7 +4,7 @@
     6.4  
     6.5  #include <xen/config.h>
     6.6  
     6.7 -#ifdef CONFIG_X86
     6.8 +#ifdef CONFIG_SHADOW
     6.9  
    6.10  #include <asm/shadow.h>
    6.11