This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: i386: Lazy binding trampoline and vector register usage


On Wed, Dec 18, 2019 at 2:22 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> We have this in sysdeps/i386/Makefile:
>
> # Make sure no code in ld.so uses mm/xmm/ymm/zmm registers on i386 since
> # the first 3 mm/xmm/ymm/zmm registers are used to pass vector parameters
> # which must be preserved.
> # With SSE disabled, ensure -fpmath is not set to use sse either.
> rtld-CFLAGS += -mno-sse -mno-mmx -mfpmath=387
> ifeq ($(subdir),elf)
> CFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\
>                    $(rtld-CFLAGS))
>
> tests-special += $(objpfx)tst-ld-sse-use.out
> $(objpfx)tst-ld-sse-use.out: ../sysdeps/i386/tst-ld-sse-use.sh $(objpfx)ld.so
>         @echo "Checking ld.so for SSE register use.  This will take a few seconds..."
>         $(BASH) $< $(objpfx) '$(NM)' '$(OBJDUMP)' '$(READELF)' > $@; \
>         $(evaluate-test)
> else
> CFLAGS-.os += $(if $(filter rtld-%.os,$(@F)), $(rtld-CFLAGS))
> endif
>
> The idea is that we do not need to save and restore vector registers in
> the trampoline (or align the stack) if we compile ld.so in such a way
> that only general registers are used.  But that does not actually work
> in all cases because lazy binding can call malloc, which lives in
> libc.so or might even be interposed, and is thus free to use vector
> registers.
>
> What should we do about this?  Calling malloc from _dl_fixup is unsafe
> for other reasons because lazy binding can happen in signal handlers, so
> maybe this would be fixed if we switched to a non-interposable
> async-signal-safe allocator?

Yes, we can do it for i386.

> (I found this by code inspection.  I have not seen actual crashes/wrong
> results at run time.)

Thanks.

-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]