This is an archive of the discontinued LLVM Phabricator instance.

Fix floating point register write on new x86 linux kernels
ClosedPublic

Authored by labath on Nov 24 2017, 6:04 AM.

Details

Summary

New linux kernels (on systems that support the XSAVES instruction) will
not update the inferior registers unless the corresponding flag in the
XSAVE header is set. Normally this flag will be set in our image of the
XSAVE area (since we obtained it from the kernel), but if the inferior
has never used the corresponding register set, the respective flag can
be clear.

This fixes the issue by making sure we explicitly set the flags
corresponding to the registers we modify. I don't try to precisely match
the flags to set on each write, as the rules could get quite complicated

  • I use a simpler over-approximation instead.

This was already caught by test_fp_register_write, but that was only
because the code that ran before main() did not use some of the register
sets. Since nothing in this test relies on being stopped in main(), I
modify the test to stop at the entry point instead, so we can be sure
the inferior did not have a chance to access these registers. If you
think that stopping in main brings something useful to the test, I can
make an extra test that stops at entry point instead.

Diff Detail

Repository
rL LLVM

Event Timeline

labath created this revision.Nov 24 2017, 6:04 AM
clayborg accepted this revision.Nov 27 2017, 9:49 AM
This revision is now accepted and ready to land.Nov 27 2017, 9:49 AM
This revision was automatically updated to reflect the committed changes.