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

Description

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 by axeld, 8 years ago

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 by dacha, 8 years ago

Yes, Windows makes heavy use of the FS register to store the TEB: http://en.wikipedia.org/wiki/Win32_Thread_Information_Block

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

comment:3 by dacha, 8 years ago

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 by axeld, 8 years ago

%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).

by dacha, 8 years ago

proposed patch

comment:5 by dacha, 8 years ago

Has a Patch: set

comment:6 by bonefish, 8 years ago

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 by kaliber, 8 years ago

Cc: grzegorz.dabrowski@… added

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

Obsoleting patch: see comment:6

comment:9 by nielx, 7 years ago

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