On Mon, Aug 07, 2017 at 05:04:46PM +0200, Mark Kettenis wrote:
> > Date: Mon, 7 Aug 2017 16:46:42 +0200 (CEST)
> > From: Mark Kettenis <[email protected]>
> > 
> > > Date: Sun, 6 Aug 2017 19:44:49 -0700
> > > From: Max Parmer <[email protected]>
> > > 
> > > >Synopsis:        X server segfaults in VESA driver as Linux KVM guest
> > > >Category:        system
> > > >Environment:
> > >   System      : OpenBSD 6.1
> > >   Details     : OpenBSD 6.1-current (GENERIC.MP) #45: Sat Aug  5 16:22:04 
> > > MDT 2017
> > >                    
> > > [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> > > 
> > >   Architecture: OpenBSD.amd64
> > >   Machine     : amd64
> > > >Description:
> > >   startx crashes with an illegal instruction leaving a jumble of
> > >   colors on screen.
> > > 
> > >   After enabling suid coredumps I retrieved this backtrace:
> > >   (gdb) bt
> > >   #0  0x0000169016f7e620 in xf86SlowBcopy () from /usr/X11R6/bin/Xorg
> > >   #1  0x00001692b393238a in VESASaveRestore () from
> > >   /usr/X11R6/lib/modules/drivers/vesa_drv.so
> > >   #2  0x00001692b39314ea in VESAScreenInit () from
> > >   /usr/X11R6/lib/modules/drivers/vesa_drv.so
> > >   #3  0x0000169016f147d3 in AddScreen () from /usr/X11R6/bin/Xorg
> > >   #4  0x0000169016f5dcb2 in InitOutput () from /usr/X11R6/bin/Xorg
> > >   #5  0x0000169016f18774 in dix_main () from /usr/X11R6/bin/Xorg
> > >   #6  0x0000169016f01914 in _start () from /usr/X11R6/bin/Xorg
> > >   #7  0x0000169016f018c0 in ?? () from /usr/X11R6/bin/Xorg
> > >   #8  0x0000000000000000 in ?? ()
> > 
> > Looks like clang is uptimizing xf86SlowBcopy() to use SSE
> > instructions.  I wouldn't be surprised that those are indeed
> > unsupported on memory mapped device memory.  Since the whole purpose
> > of xf86SlowBcopy to do a bytewise unoptimized copy, we need to tell
> > the compiler not to optimize this code.
> 
> FreeBSD fixed this:
> 
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=202643

Here's an adaptation of Dimitry's patch for xenocara (tested here).


Index: hw/xfree86/common/xf86Init.c
===================================================================
RCS file: /cvs/OpenBSD/xenocara/xserver/hw/xfree86/common/xf86Init.c,v
retrieving revision 1.25
diff -u -p -u -r1.25 xf86Init.c
--- hw/xfree86/common/xf86Init.c        9 Aug 2016 18:59:52 -0000       1.25
+++ hw/xfree86/common/xf86Init.c        6 Mar 2017 22:20:33 -0000
@@ -945,6 +945,10 @@ InitOutput(ScreenInfo * pScreenInfo, int
 
     RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr) NoopDDA, xf86Wakeup,
                                    NULL);
+#ifdef X_PRIVSEP
+    ErrorF("enabling local access\n");
+    LocalAccessScopeUser();
+#endif
 }
 
 /**
Index: hw/xfree86/os-support/misc/Makefile.am
===================================================================
RCS file: /cvs/OpenBSD/xenocara/xserver/hw/xfree86/os-support/misc/Makefile.am,v
retrieving revision 1.4
diff -u -p -u -r1.4 Makefile.am
--- hw/xfree86/os-support/misc/Makefile.am      2 May 2014 19:27:49 -0000       
1.4
+++ hw/xfree86/os-support/misc/Makefile.am      7 Aug 2017 18:31:57 -0000
@@ -7,6 +7,11 @@ libmisc_la_SOURCES = SlowBcopy.c
 
 AM_CPPFLAGS = $(XORG_INCS)
 
-AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS)
+if I386_VIDEO
+NOSSE_CFLAGS = -mno-sse
+endif
+
+AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS) $(NOSSE_CFLAGS)
+
 
 EXTRA_DIST = $(I386_SRCS) $(PORTIO_SRCS)
Index: hw/xfree86/os-support/misc/Makefile.in
===================================================================
RCS file: /cvs/OpenBSD/xenocara/xserver/hw/xfree86/os-support/misc/Makefile.in,v
retrieving revision 1.33
diff -u -p -u -r1.33 Makefile.in
--- hw/xfree86/os-support/misc/Makefile.in      11 Oct 2016 22:15:56 -0000      
1.33
+++ hw/xfree86/os-support/misc/Makefile.in      7 Aug 2017 18:37:58 -0000
@@ -475,7 +475,8 @@ libmisc_la_SOURCES = SlowBcopy.c
 
 #AM_LDFLAGS = -r
 AM_CPPFLAGS = $(XORG_INCS)
-AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS)
+@I386_VIDEO_TRUE@NOSSE_CFLAGS = -mno-sse
+AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS) $(NOSSE_CFLAGS)
 EXTRA_DIST = $(I386_SRCS) $(PORTIO_SRCS)
 all: all-am
 

-- 
Matthieu Herrb

Reply via email to