This is the mail archive of the glibc-bugs@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]

[Bug libc/1468] AMD64 {get,set,swap,make}context use wrong offsets into ucontext_t


------- Additional Comments From nmiell at comcast dot net  2005-10-15 03:27 -------
Sorry, I should have marked my patch as obsolete when I added comment #2.

Fortunately, I was wrong and the MXCSR register isn't actually corrupted --
STMXCSR occurs after FNSTENV, so the saved %ds and padding are overwritten by
the saved %mxcsr, but they're purely informational and don't effect execution
when they're loaded by FLDENV (afaik). (Meaning no new bugs were introduced, I
think.)

I was just going to submit a patch to setcontext, getcontext and swapcontext
that makes them use FXSAVE and FXRSTOR instead of FNSTENV/STMXCSR and
FLDENV/LDMXCSR --  it turns out that saving and restoring the entire FPU state
with these intructions is faster than just saving/restoring the x87 environment
and MXCSR register and FXSAVE/FXRSTOR would naturally put things in the right
place in struct _libc_fpstate.

However, I ran into a problem that I don't know how to solve:

The FXSAVE area needs to be 16-byte aligned, however the natural alignment of
struct _libc_fpstate is 8. As such, the __fpregs_mem member of struct ucontext
isn't aligned sufficiently for use with the FXSAVE and FXRSTOR instructions.

_libc_fpstate should probably get an __attribute__((aligned(16))), but this
would change the layout of struct ucontext and definately break the ABI.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


http://sourceware.org/bugzilla/show_bug.cgi?id=1468

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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