Date: Tue, 2 Sep 2003 22:38:36 -0400 (EDT) From: Daniel Eischen <eischen@vigrid.com> To: ports@freebsd.org Subject: ports using i386_set_ldt (was: mplayer won't work with libkse/libthr) Message-ID: <Pine.GSO.4.10.10309022234250.25430-100000@pcnet5.pcnet.com>
next in thread | raw e-mail | index | archive | help
FYI, any port that uses ldt's in -current won't work with our new thread libraries (libkse, libthr) unless they use auto LDT creation. Below is a patch to make mplayer work with libkse. I assume there will be other ports that need similar patches. -- Dan Eischen ---------- Forwarded message ---------- Date: Tue, 2 Sep 2003 22:15:55 -0400 (EDT) From: Daniel Eischen <eischen@vigrid.com> Reply-To: deischen@freebsd.org To: kde@freebsd.org Cc: Andy Fawcett <andy@athame.co.uk> Subject: Re: mplayer won't work with libkse/libthr (was Re: [kde-freebsd] Showing off KDE on TechTV) On Tue, 2 Sep 2003, Daniel Eischen wrote: > On Tue, 2 Sep 2003, Daniel Eischen wrote: > > > On Tue, 2 Sep 2003, Andy Fawcett wrote: > > > > > Untested fix (no -current here at the moment) > > > > > > pre-configure: > > > ${REINPLACE_CMD} "s,-pedantic ,," ${WRKSRC}/configure > > > > Though there were still a lot of warnings, this got it to > > build (USE_REINPLACE was already true). Should this be > > committed as a fix for 5.x? > > mplayer can't work with libkse or libthr because it uses > static ldt assigments and it clashes with our threads > libraries. > > Under -current, applications should use dynamic ldts by > using LDT_AUTO_ALLOC as the first argument to i386_set_ldt(). Here's a patch that makes it work for me with libkse. It was a quick and dirty patch, so you guys might want to do it another way... Should I send-pr it? -- Dan Eischen --- loader/ldt_keeper.c.orig Sun Nov 17 12:41:19 2002 +++ loader/ldt_keeper.c Tue Sep 2 17:55:21 2003 @@ -88,11 +88,16 @@ #define LDT_SEL(idx) ((idx) << 3 | 1 << 2 | 3) /* i got this value from wine sources, it's the first free LDT entry */ +#if defined(__FreeBSD__) && defined(LDT_AUTO_ALLOC) +#define TEB_SEL_IDX LDT_AUTO_ALLOC +#endif + #ifndef TEB_SEL_IDX #define TEB_SEL_IDX 17 #endif -#define TEB_SEL LDT_SEL(TEB_SEL_IDX) +static unsigned int fs_ldt = TEB_SEL_IDX; + /** * here is a small logical problem with Restore for multithreaded programs - @@ -104,8 +109,10 @@ #endif void Setup_FS_Segment(void) { + unsigned int ldt_desc = LDT_SEL(fs_ldt); + __asm__ __volatile__( - "movl %0,%%eax; movw %%ax, %%fs" : : "i" (TEB_SEL) + "movl %0,%%eax; movw %%ax, %%fs" : : "r" (ldt_desc) ); } @@ -211,7 +218,13 @@ unsigned long d[2]; LDT_EntryToBytes( d, &array ); +#if defined(__FreeBSD__) && defined(LDT_AUTO_ALLOC) + ret = i386_set_ldt(LDT_AUTO_ALLOC, (union descriptor *)d, 1); + array.entry_number = ret; + fs_ldt = ret; +#else ret = i386_set_ldt(array.entry_number, (union descriptor *)d, 1); +#endif if (ret < 0) { perror("install_fs"); @@ -224,7 +237,7 @@ #if defined(__svr4__) { struct ssd ssd; - ssd.sel = TEB_SEL; + ssd.sel = LDT_SEL(TEB_SEL_IDX); ssd.bo = array.base_addr; ssd.ls = array.limit - array.base_addr; ssd.acc1 = ((array.read_exec_only == 0) << 1) |
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.10.10309022234250.25430-100000>