Page MenuHomeFreeBSD

linux(4): Preserve fpu fxsave state across signal delivery on amd64.
ClosedPublic

Authored by dchagin on Jan 31 2023, 7:50 PM.
Tags
None
Referenced Files
F82333796: D38302.id116344.diff
Sat, Apr 27, 5:58 PM
Unknown Object (File)
Thu, Apr 25, 9:32 PM
Unknown Object (File)
Feb 19 2024, 5:38 AM
Unknown Object (File)
Feb 19 2024, 5:37 AM
Unknown Object (File)
Feb 19 2024, 5:37 AM
Unknown Object (File)
Feb 18 2024, 11:41 PM
Unknown Object (File)
Feb 18 2024, 11:41 PM
Unknown Object (File)
Feb 18 2024, 11:41 PM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 49367
Build 46257: arc lint + arc unit

Event Timeline

dchagin added a reviewer: kib.
dchagin added a reviewer: Linux Emulation.

blank line removed, on phab it looks better..

drop fpstate like native sendsig()

sys/amd64/linux/linux_sysvec.c
511
523

Could 10 be replaced by some symbolic expression like sizeof()?

Same question for 8 and 16, above and below.

sys/x86/linux/linux_x86_sigframe.h
150

So what would we do when Linux starts using that space?

In fact I believe that you do not need to save any of these fields. When restroring context, set owned to _MC_FPOWNED_FPU, mc_fpformat to _MC_FPFMT_XMM, and flags to _MX_HASFPXSTATE,

bad idea to put mc_ field at the end of the reserved area in the struct fpstate,
as here potential extended state is encoded.
put it at the start

fixed, thanks! a bit ugly for() loops...

sys/amd64/linux/linux_sysvec.c
401
417

nitems

422

nitems

504

I believe the ps_mtx and proc lock can be dropped after this line, there is no point of copying all the stuff under the locks. Even more, the code be re-arranged to do all accesses to lock-protected members earlier.

But this is perhaps is not too important.

522

sizeof(svfp->sv_fp) / sizeof(svfp->sv_fp[0]) is better spelled as nitems(sizeof(svfp->sv_fp))

527

Same

ah, nitems() done, proc lock moved above, thank you

sys/amd64/linux/linux_sysvec.c
406

I mis-remembered my own code. _MX_HASFPXSTATE is wrong there, initialze mc_flags with 0.

538

This condition should be always true. Perhaps assert it and unindent the 'then' block.

done,

perhaps make sense to fix xxx_fpregs_xmm()? use nitems, etc?

done,

perhaps make sense to fix xxx_fpregs_xmm()? use nitems, etc?

Perhaps yes

This revision is now accepted and ready to land.Feb 1 2023, 5:12 PM