Opened 8 years ago

Last modified 7 years ago

#7867 new enhancement

Need to provide all CPU registers to signal handler

Reported by: dacha Owned by: nobody
Priority: normal Milestone: R1
Component: - General Version: R1/Development
Keywords: Cc: grzegorz.dabrowski@…
Blocked By: Blocking:
Has a Patch: no Platform: x86


Wine needs to read and write all the (user-space modifiable?) CPU registers from ucontext_t. Haiku lacks the following:

  • All the segment registers (CS, DS, ES, FS, GS, SS)
  • Trap (sc_trapno on FreeBSD)
  • Error (sc_err on FreeBSD)

Apart from adding these to /boot/develop/headers/posix/arch/x86/signal.h, the kernel needs to read and write the registers to and from ucontext_t as necessary.

Attachments (1)

ucontext-more-registers.patch (2.2 KB) - added by dacha 8 years ago.
proposed patch

Download all attachments as: .zip

Change History (10)

comment:1 Changed 8 years ago by axeld

Most of these never change, but IIRC FS is a per thread register on Haiku and is used to provide TLS (that's a BeOS legacy). Wine might want to use it by other means which could give you some headaches.

comment:2 Changed 8 years ago by dacha

Yes, Windows makes heavy use of the FS register to store the TEB:

Linux gets lucky by using GS for TLS instead. Where is TLS used by BeOS? Kernel? libroot? All GCC generated code? Everywhere?

comment:3 Changed 8 years ago by dacha

Looks like:

  • libroot uses %fs a lot, especially for pthreads functions, but also for errno
  • libnetwork only references %fs in an errno related function
  • wine .o files only use %fs for the Win32 TEB
  • wine DLLs also use %fs for things like errno
  • haven't had a chance to examine the kernel yet

If the kernel ignores %fs, it looks like a matter of saving and restoring %fs across each function call out of Wine (and signal into Wine?). But if the kernel also uses %fs for something, then it's game over.

comment:4 Changed 8 years ago by axeld

%fs is set in the kernel upon every thread context switch per CPU. Therefore, you cannot just reset it in Wine, as that won't get you very far.

For this particular problem, I guess there are two choices: 1) Try to make the use of %fs compatible, if possible in any way. 2) Provide a kernel level solution that allows Wine to work (by setting some thread flag, or whatever).

Changed 8 years ago by dacha

proposed patch

comment:5 Changed 8 years ago by dacha

Has a Patch: set

comment:6 Changed 8 years ago by bonefish

Just extending the vregs structure will break binary compatibility (there's the _reserved_1 which can and should be used, but obviously that isn't enough). You'll also have to introduce a binary compatible version of the structure (vregs_beos) and adjust the x86_signal_frame_function_beos() function (cf. src/system/kernel/arch/x86/x86_signals_asm.S, and src/system/kernel/arch/x86/asm_offsets.cpp for the assembly offset/size macros).

comment:7 Changed 8 years ago by kaliber

Cc: grzegorz.dabrowski@… added

comment:8 in reply to:  6 Changed 7 years ago by nielx

Obsoleting patch: see comment:6

comment:9 Changed 7 years ago by nielx

Has a Patch: unset
Note: See TracTickets for help on using tickets.