Subject: xsrc/25170: X server fixes to use loadable modules on amd64 (xsrc part)
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <njoly@pasteur.fr>
List: netbsd-bugs
Date: 04/13/2004 22:49:06
>Number: 25170
>Category: xsrc
>Synopsis: X server fixes to use loadable modules on amd64 (xsrc part)
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: xsrc-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Apr 13 20:50:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: Nicolas Joly
>Release: NetBSD 2.0C (-current 20040413)
>Organization:
Institut Pasteur
>Environment:
System: NetBSD lanfeust.sis.pasteur.fr 2.0C NetBSD 2.0C (LANFEUST) #0: Fri Apr 9 10:21:40 CEST 2004 njoly@lanfeust.sis.pasteur.fr:/local/src/NetBSD/obj/amd64/sys/arch/amd64/compile/LANFEUST amd64
Architecture: x86_64
Machine: amd64
>Description:
Dynamic X server, built from xsrc, crash on amd64 while trying to load modules.
>How-To-Repeat:
X -configure
>Fix:
Patch based on ideas of Matthias Scheler and Frank van der Linden.
All mmap() addresses need be under the 2GB limit.
Index: xfree/xc/config/cf/NetBSD.cf
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/config/cf/NetBSD.cf,v
retrieving revision 1.67
diff -u -r1.67 NetBSD.cf
--- xfree/xc/config/cf/NetBSD.cf 11 Apr 2004 09:09:30 -0000 1.67
+++ xfree/xc/config/cf/NetBSD.cf 13 Apr 2004 20:20:20 -0000
@@ -204,7 +204,7 @@
* Disabled for NetBSD/vax until I figure out the scheme. --CS
*/
#if ((OSMajorVersion > 0) && defined(i386Architecture)) || \
- defined(PpcArchitecture)
+ defined(PpcArchitecture) || defined(AMD64Architecture)
# ifndef DoLoadableServer
# define DoLoadableServer YES
# endif
Index: xfree/xc/programs/Xserver/hw/xfree86/loader/Imakefile
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/xfree86/loader/Imakefile,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 Imakefile
--- xfree/xc/programs/Xserver/hw/xfree86/loader/Imakefile 5 Mar 2004 14:29:15 -0000 1.1.1.7
+++ xfree/xc/programs/Xserver/hw/xfree86/loader/Imakefile 13 Apr 2004 20:20:24 -0000
@@ -36,6 +36,8 @@
#if defined (AMD64Architecture) && defined(linux)
ARCHDEFINES = -DDoMMAPedMerge -DMmapPageAlign
+#elif defined (AMD64Architecture) && defined(NetBSDArchitecture)
+ARCHDEFINES = -DUseMMAP
#endif
DEFINES = $(DBMALLOCDEFINE) $(DLOPENDEFINES) $(OS_DEFINES) $(COMPAT_DEFINES) \
Index: xfree/xc/programs/Xserver/hw/xfree86/loader/loader.c
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/xfree86/loader/loader.c,v
retrieving revision 1.5
diff -u -r1.5 loader.c
--- xfree/xc/programs/Xserver/hw/xfree86/loader/loader.c 28 Mar 2004 15:24:25 -0000 1.5
+++ xfree/xc/programs/Xserver/hw/xfree86/loader/loader.c 13 Apr 2004 20:20:24 -0000
@@ -485,6 +485,12 @@
#ifdef UseMMAP
unsigned long ret;
+# if defined(__NetBSD__) && (__AMD64__)
+ static char *mm_addr = (char *)(1L << 30);
+# else
+ char *mm_addr = NULL;
+# endif
+
# ifdef MmapPageAlign
unsigned long pagesize;
A
unsigned long new_size;
@@ -506,22 +512,28 @@
new_off_bias = (offset + offsetbias) - new_off;
if ((new_off_bias + size) > new_size)
new_size += pagesize;
- ret = (unsigned long)mmap(0, new_size, MMAP_PROT, MAP_PRIVATE
-# ifdef __AMD64__
+ ret = (unsigned long)mmap(mm_addr, new_size, MMAP_PROT, MAP_PRIVATE
+# if !defined(__NetBSD__) && defined(__AMD64__)
| MAP_32BIT
# endif
, fd, new_off);
if (ret == -1)
FatalError("mmap() failed: %s\n", strerror(errno));
+#if defined(__NetBSD__) && (__AMD64__)
+ mm_addr += new_size;
+#endif
return (void *)(ret + new_off_bias);
# else
- ret = (unsigned long)mmap(0, size, MMAP_PROT, MAP_PRIVATE
-# ifdef __AMD64__
+ ret = (unsigned long)mmap(mm_addr, size, MMAP_PROT, MAP_PRIVATE
+# if !defined(__NetBSD__) && defined(__AMD64__)
| MAP_32BIT
# endif
, fd, offset + offsetbias);
if (ret == -1)
FatalError("mmap() failed: %s\n", strerror(errno));
+#if defined(__NetBSD__) && (__AMD64__)
+ mm_addr += size;
+#endif
return (void *)ret;
# endif
#else
>Release-Note:
>Audit-Trail:
>Unformatted: