All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3] mesa: Disable asm on musl
@ 2018-10-03  0:44 Khem Raj
  2018-10-03  1:40 ` Paul Eggleton
  2018-10-03  9:12 ` Burton, Ross
  0 siblings, 2 replies; 4+ messages in thread
From: Khem Raj @ 2018-10-03  0:44 UTC (permalink / raw)
  To: openembedded-core

Musl started blocking dlopen of libs with initial-exec references into
dynamic TLS area, via

https://github.com/kraj/musl/commit/5c2f46a214fceeee3c3e41700c51415e0a4f1acd

prior to that commit, musl was loading it and silently letting
subsequent TLS accesses via the miscompiled code clobber memory that
didn't belong to them

This was wrong behavior and it relied on additional space reserved by
libc in TLS space to adjust fo such broken libs, but it also fails
with glibc if the reserved space was already used up

Right fix is that  mesa should be patched to remove all the
initial-exec hacks and use real TLS, and -mtls-dialect=gnu2 (TLSDESC)
should be used on archs it's supported on (i386, x86_64, and aarch64)
to make up for the lost performance, but mesa hardcodes the initial-exec,
so there must be a reason that probably is better known to mesa devs.

but we 'fixed' it for musl by adding --disable-glx-tls for mesa in OE,
which uses pthread_getspecific instead and makes is lot slower.

this caused additional problems with security flags on, it get textrels
in .text segment. Therefore this is 'second fix' to get us through this
warning.

Cause is some unknown part of mesa's x86 assembly code is broken by
readonly text segments

[ YOCTO #12918 ]

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
V3: Disable asm just on x86, since it works well elsewhere

 meta/recipes-graphics/mesa/mesa.inc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
index 8d0e2cb67c..0dfdfbd5b4 100644
--- a/meta/recipes-graphics/mesa/mesa.inc
+++ b/meta/recipes-graphics/mesa/mesa.inc
@@ -108,6 +108,8 @@ PACKAGECONFIG[unwind] = "--enable-libunwind,--disable-libunwind,libunwind"
 
 EXTRA_OECONF_remove_libc-musl = "--enable-glx-tls"
 EXTRA_OECONF_append_libc-musl = " --disable-glx-tls"
+EXTRA_OECONF_append_libc-musl_x86 = " --disable-asm"
+
 # llvmpipe is slow if compiled with -fomit-frame-pointer (e.g. -O2)
 FULL_OPTIMIZATION_append = " -fno-omit-frame-pointer"
 
-- 
2.19.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH V3] mesa: Disable asm on musl
  2018-10-03  0:44 [PATCH V3] mesa: Disable asm on musl Khem Raj
@ 2018-10-03  1:40 ` Paul Eggleton
  2018-10-03  9:12 ` Burton, Ross
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Eggleton @ 2018-10-03  1:40 UTC (permalink / raw)
  To: Khem Raj; +Cc: openembedded-core

On Wednesday, 3 October 2018 1:44:05 PM NZDT Khem Raj wrote:
> Musl started blocking dlopen of libs with initial-exec references into
> dynamic TLS area, via
> 
> https://github.com/kraj/musl/commit/5c2f46a214fceeee3c3e41700c51415e0a4f1acd
> 
> prior to that commit, musl was loading it and silently letting
> subsequent TLS accesses via the miscompiled code clobber memory that
> didn't belong to them
> 
> This was wrong behavior and it relied on additional space reserved by
> libc in TLS space to adjust fo such broken libs, but it also fails
> with glibc if the reserved space was already used up
> 
> Right fix is that  mesa should be patched to remove all the
> initial-exec hacks and use real TLS, and -mtls-dialect=gnu2 (TLSDESC)
> should be used on archs it's supported on (i386, x86_64, and aarch64)
> to make up for the lost performance, but mesa hardcodes the initial-exec,
> so there must be a reason that probably is better known to mesa devs.
> 
> but we 'fixed' it for musl by adding --disable-glx-tls for mesa in OE,
> which uses pthread_getspecific instead and makes is lot slower.
> 
> this caused additional problems with security flags on, it get textrels
> in .text segment. Therefore this is 'second fix' to get us through this
> warning.
> 
> Cause is some unknown part of mesa's x86 assembly code is broken by
> readonly text segments

That's excellent, thanks!

Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V3] mesa: Disable asm on musl
  2018-10-03  0:44 [PATCH V3] mesa: Disable asm on musl Khem Raj
  2018-10-03  1:40 ` Paul Eggleton
@ 2018-10-03  9:12 ` Burton, Ross
  2018-10-03 13:32   ` Khem Raj
  1 sibling, 1 reply; 4+ messages in thread
From: Burton, Ross @ 2018-10-03  9:12 UTC (permalink / raw)
  To: Khem Raj; +Cc: OE-core

Perfect. :)  Did you file a bug upstream, or shall I copy/paste that
into a bug now?

Ross
On Wed, 3 Oct 2018 at 01:49, Khem Raj <raj.khem@gmail.com> wrote:
>
> Musl started blocking dlopen of libs with initial-exec references into
> dynamic TLS area, via
>
> https://github.com/kraj/musl/commit/5c2f46a214fceeee3c3e41700c51415e0a4f1acd
>
> prior to that commit, musl was loading it and silently letting
> subsequent TLS accesses via the miscompiled code clobber memory that
> didn't belong to them
>
> This was wrong behavior and it relied on additional space reserved by
> libc in TLS space to adjust fo such broken libs, but it also fails
> with glibc if the reserved space was already used up
>
> Right fix is that  mesa should be patched to remove all the
> initial-exec hacks and use real TLS, and -mtls-dialect=gnu2 (TLSDESC)
> should be used on archs it's supported on (i386, x86_64, and aarch64)
> to make up for the lost performance, but mesa hardcodes the initial-exec,
> so there must be a reason that probably is better known to mesa devs.
>
> but we 'fixed' it for musl by adding --disable-glx-tls for mesa in OE,
> which uses pthread_getspecific instead and makes is lot slower.
>
> this caused additional problems with security flags on, it get textrels
> in .text segment. Therefore this is 'second fix' to get us through this
> warning.
>
> Cause is some unknown part of mesa's x86 assembly code is broken by
> readonly text segments
>
> [ YOCTO #12918 ]
>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
> V3: Disable asm just on x86, since it works well elsewhere
>
>  meta/recipes-graphics/mesa/mesa.inc | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
> index 8d0e2cb67c..0dfdfbd5b4 100644
> --- a/meta/recipes-graphics/mesa/mesa.inc
> +++ b/meta/recipes-graphics/mesa/mesa.inc
> @@ -108,6 +108,8 @@ PACKAGECONFIG[unwind] = "--enable-libunwind,--disable-libunwind,libunwind"
>
>  EXTRA_OECONF_remove_libc-musl = "--enable-glx-tls"
>  EXTRA_OECONF_append_libc-musl = " --disable-glx-tls"
> +EXTRA_OECONF_append_libc-musl_x86 = " --disable-asm"
> +
>  # llvmpipe is slow if compiled with -fomit-frame-pointer (e.g. -O2)
>  FULL_OPTIMIZATION_append = " -fno-omit-frame-pointer"
>
> --
> 2.19.0
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V3] mesa: Disable asm on musl
  2018-10-03  9:12 ` Burton, Ross
@ 2018-10-03 13:32   ` Khem Raj
  0 siblings, 0 replies; 4+ messages in thread
From: Khem Raj @ 2018-10-03 13:32 UTC (permalink / raw)
  To: Burton, Ross; +Cc: Patches and discussions about the oe-core layer

On Wed, Oct 3, 2018 at 2:12 AM Burton, Ross <ross.burton@intel.com> wrote:
>
> Perfect. :)  Did you file a bug upstream, or shall I copy/paste that
> into a bug now?

i did not. thanks in advance if you can
>
> Ross
> On Wed, 3 Oct 2018 at 01:49, Khem Raj <raj.khem@gmail.com> wrote:
> >
> > Musl started blocking dlopen of libs with initial-exec references into
> > dynamic TLS area, via
> >
> > https://github.com/kraj/musl/commit/5c2f46a214fceeee3c3e41700c51415e0a4f1acd
> >
> > prior to that commit, musl was loading it and silently letting
> > subsequent TLS accesses via the miscompiled code clobber memory that
> > didn't belong to them
> >
> > This was wrong behavior and it relied on additional space reserved by
> > libc in TLS space to adjust fo such broken libs, but it also fails
> > with glibc if the reserved space was already used up
> >
> > Right fix is that  mesa should be patched to remove all the
> > initial-exec hacks and use real TLS, and -mtls-dialect=gnu2 (TLSDESC)
> > should be used on archs it's supported on (i386, x86_64, and aarch64)
> > to make up for the lost performance, but mesa hardcodes the initial-exec,
> > so there must be a reason that probably is better known to mesa devs.
> >
> > but we 'fixed' it for musl by adding --disable-glx-tls for mesa in OE,
> > which uses pthread_getspecific instead and makes is lot slower.
> >
> > this caused additional problems with security flags on, it get textrels
> > in .text segment. Therefore this is 'second fix' to get us through this
> > warning.
> >
> > Cause is some unknown part of mesa's x86 assembly code is broken by
> > readonly text segments
> >
> > [ YOCTO #12918 ]
> >
> > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > ---
> > V3: Disable asm just on x86, since it works well elsewhere
> >
> >  meta/recipes-graphics/mesa/mesa.inc | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
> > index 8d0e2cb67c..0dfdfbd5b4 100644
> > --- a/meta/recipes-graphics/mesa/mesa.inc
> > +++ b/meta/recipes-graphics/mesa/mesa.inc
> > @@ -108,6 +108,8 @@ PACKAGECONFIG[unwind] = "--enable-libunwind,--disable-libunwind,libunwind"
> >
> >  EXTRA_OECONF_remove_libc-musl = "--enable-glx-tls"
> >  EXTRA_OECONF_append_libc-musl = " --disable-glx-tls"
> > +EXTRA_OECONF_append_libc-musl_x86 = " --disable-asm"
> > +
> >  # llvmpipe is slow if compiled with -fomit-frame-pointer (e.g. -O2)
> >  FULL_OPTIMIZATION_append = " -fno-omit-frame-pointer"
> >
> > --
> > 2.19.0
> >
> > --
> > _______________________________________________
> > Openembedded-core mailing list
> > Openembedded-core@lists.openembedded.org
> > http://lists.openembedded.org/mailman/listinfo/openembedded-core


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-10-03 13:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-03  0:44 [PATCH V3] mesa: Disable asm on musl Khem Raj
2018-10-03  1:40 ` Paul Eggleton
2018-10-03  9:12 ` Burton, Ross
2018-10-03 13:32   ` Khem Raj

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.