Xen 
 
Home Products Support Community News
 
   

On 32-bit x86 platforms, Xen uses segmentation to provide protection of the memory used for the hypervisor. This results in some performance issues since wrap-around segments as used by glibc need expensive extra handling. For more information on how Xen uses segmentation, see XenSegments.

It is possible to rebuild glibc so that it only uses segments such that there is no performance penalty. To do this, you need to apply the patch below to the glibc sources and then rebuild glibc with the -mno-tls-direct-seg-refs option.

This patch is not needed for glibc-2.4. It automatically accesses the segments correctly when it detects that it is compiled with the -mno-tls-direct-seg-refs option.

RPMs are available for:

For Debian, see DebianSarge for discussion etc. and DebianTlsLibcDiversion for a quick workaround.

--- glibc-2.3.2/sysdeps/unix/i386/sysdep.S      2005/01/24 21:01:14     1.1
+++ glibc-2.3.2/sysdeps/unix/i386/sysdep.S      2005/01/24 21:02:17
@@ -47,7 +47,8 @@
 #endif
 #ifndef        PIC
 # if USE___THREAD
-       movl %eax, %gs:C_SYMBOL_NAME(errno@NTPOFF)
+       movl %gs:0, %ecx
+       movl %eax, C_SYMBOL_NAME(errno@NTPOFF)(%ecx)
 # elif !defined _LIBC_REENTRANT
        movl %eax, C_SYMBOL_NAME(errno)
 # else
@@ -62,11 +63,12 @@
        /* The caller has pushed %ebx and then set it up to
           point to the GOT before calling us through the PLT.  */
 # if USE___THREAD
-       movl C_SYMBOL_NAME(errno@GOTNTPOFF)(%ebx), %ecx
+       movl %gs:0, %ecx
+       addl C_SYMBOL_NAME(errno@GOTNTPOFF)(%ebx), %ecx
 
        /* Pop %ebx value saved before jumping here.  */
        popl %ebx
-       movl %eax, %gs:0(%ecx)
+       movl %eax, (%ecx)
 # elif RTLD_PRIVATE_ERRNO
        movl %eax, C_SYMBOL_NAME(errno@GOTOFF)(%ebx)
 
--- glibc-2.3.2/sysdeps/unix/sysv/linux/i386/sysdep.h   2005/01/24 21:16:54     1.1
+++ glibc-2.3.2/sysdeps/unix/sysv/linux/i386/sysdep.h   2005/01/24 23:41:56
@@ -148,12 +148,13 @@
 #    define SYSCALL_ERROR_ERRNO errno
 #   endif
 #   define SYSCALL_ERROR_HANDLER                                             \
-0:SETUP_PIC_REG (cx);                                                        \
-  addl $_GLOBAL_OFFSET_TABLE_, %ecx;                                         \
-  movl SYSCALL_ERROR_ERRNO@GOTNTPOFF(%ecx), %ecx;                            \
+0:SETUP_PIC_REG (dx);                                                        \
+  addl $_GLOBAL_OFFSET_TABLE_, %edx;                                         \
+  movl %gs:0, %ecx;                                                          \
+  addl SYSCALL_ERROR_ERRNO@GOTNTPOFF(%edx), %ecx;                            \
   xorl %edx, %edx;                                                           \
   subl %eax, %edx;                                                           \
-  movl %edx, %gs:0(%ecx);                                                    \
+  movl %edx, (%ecx);                                                         \
   orl $-1, %eax;                                                             \
   jmp L(pseudo_end);
 #  else

XenSpecificGlibc (last edited 2006-05-11 18:43:57 by Molle)