Page MenuHomeFreeBSD

amd64: add pcb_tlsbase
ClosedPublic

Authored by kib on May 23 2025, 3:32 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Sep 16, 7:02 AM
Unknown Object (File)
Sep 12 2025, 10:49 AM
Unknown Object (File)
Sep 2 2025, 9:24 AM
Unknown Object (File)
Sep 1 2025, 10:14 AM
Unknown Object (File)
Sep 1 2025, 10:14 AM
Unknown Object (File)
Aug 30 2025, 12:39 AM
Unknown Object (File)
Aug 29 2025, 11:17 PM
Unknown Object (File)
Aug 29 2025, 9:12 PM

Details

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.May 23 2025, 3:32 AM

Seems fine, except for one thing, please see inline comment.

sys/amd64/amd64/exec_machdep.c
212–213

Shouldn't we set pcb_gsbase on SV_ILP32 instead?

sys/amd64/amd64/exec_machdep.c
212–213

There is no problem with 32bit apps at all in this regard. Simple reload of %gs on the signal handler entry gives the right base, because 32bit GDT/LDT already must have correct base.

Problem with fsbase in long mode is that the reload of the segment is not enough, and we do not know what is the right fsbase, without userspace explicitly telling us. This is the difference between AMD64_SET_FSBASE and AMD64_SET_TLSBASE.

That said, sendsig() does not delvier signals to i386 processes, this is done by ia32_sendsig(), so SV_ILP32 must not be set there anyway.

olce added inline comments.
sys/amd64/amd64/exec_machdep.c
212–213

Ah yes, forgot that there's no base problem for 32-bit apps. (I appreciate the difference between AMD64_SET_FSBASE and AMD64_SET_TLSBASE.)

I was not aware there was as sv_sendsig field in struct sysentvec. Indeed, ia32_sendsig(). So, setting PCB_TLSBASE even for a 32-bit process in cpu_set_user_tls() is not needed, but doesn't hurt either.

This revision is now accepted and ready to land.May 23 2025, 11:26 AM

There seems to be no more interest to the review.
Peter, could you, please run the stress2 set, all amd64 and threading tests are relevant?

In D50482#1153552, @kib wrote:

There seems to be no more interest to the review.
Peter, could you, please run the stress2 set, all amd64 and threading tests are relevant?

Sure, happy to.