Page MenuHomeFreeBSD

Implement ifunc support for x86, use it to enable SMAP on amd64.
ClosedPublic

Authored by kib on Jan 10 2018, 9:25 PM.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jhb added a subscriber: jhb.

In general this looks ok to me. As we discussed on IRC I think it would be useful to split up into multiple commits. (e.g. ifunc, fpu/npx usage, pmap usage, fast_syscall changes that don't use SMAP (remove cld and shared function), and then SMAP itself).

sys/amd64/amd64/support.S
299 ↗(On Diff #37756)

I wonder if this comment is a bit stale? It doesn't seem like any pre-486 CPUs will ever support SMAP. OTOH, I'm not quite sure what is even meant by "486 write protection".

377 ↗(On Diff #37756)

(I know this is old code, but I wonder if this 'cld' is even needed anymore since 'cld' is now part of the ABI?)

sys/amd64/ia32/ia32_exception.S
70 ↗(On Diff #37756)

Picking one at random. Is there a reason to think that pushf/andl/popf is better than 'cld/clac'?

Ah to answer my own question (and for future readers): clac may not be supported on all processors but this pattern is.

sys/amd64/include/asmacros.h
182 ↗(On Diff #37756)

Perhaps go ahead and break these out on separate lines since all the other instructions are on separate lines?

sys/amd64/include/cpufunc.h
840 ↗(On Diff #37756)

s/slac/stac/? (I don't think this is used in any C code though as it wouldn't compile if so?)

This revision is now accepted and ready to land.Jan 10 2018, 9:48 PM
sys/amd64/amd64/support.S
299 ↗(On Diff #37756)

As discussed, 'the protection' means CR0.WP=1.

In fact this comment is wrong in more fundamental way. The lack of CoW when user tricked copyout to copy into KVA is the least of the problems. I rewrote it there and for i386.

If CR0,WP=0, CoW would not work anyway, checked or not.

This revision was automatically updated to reflect the committed changes.

Fix typo slac->stac.

Noted by: jhb

Fix one more merge conflict.

This revision was not accepted when it landed; it landed in state Needs Review.Jan 11 2018, 1:57 PM
This revision was automatically updated to reflect the committed changes.
kib updated this revision to Diff 37799.

re-merge

This revision was not accepted when it landed; it landed in state Needs Review.Jan 14 2018, 12:40 PM
This revision was automatically updated to reflect the committed changes.
kib updated this revision to Diff 37934.

Re-merge.

This revision was not accepted when it landed; it landed in state Needs Review.May 3 2018, 10:17 AM
Closed by commit rS333208: Style. (authored by kib). · Explain Why
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state Needs Review.May 3 2018, 9:38 PM
This revision was automatically updated to reflect the committed changes.

Rebase after commits.

Now the patch only contains the actual uses of ifuncs.

This revision was not accepted when it landed; it landed in state Needs Review.May 10 2018, 3:02 PM
This revision was automatically updated to reflect the committed changes.

Update after amd64/fpu.c commit.

This revision was not accepted when it landed; it landed in state Needs Review.Jul 29 2018, 8:47 PM
Closed by commit rS336876: Use SMAP on amd64. (authored by kib). · Explain Why
This revision was automatically updated to reflect the committed changes.