Page MenuHomeFreeBSD

Use ifunc to resolve context switching mode on amd4.
ClosedPublic

Authored by kib on Sep 16 2018, 2:33 PM.
Tags
None
Referenced Files
F106161181: D17181.id48121.diff
Thu, Dec 26, 9:46 AM
F106127016: D17181.id48082.diff
Wed, Dec 25, 8:31 PM
Unknown Object (File)
Mon, Dec 9, 7:26 PM
Unknown Object (File)
Fri, Dec 6, 9:26 AM
Unknown Object (File)
Nov 17 2024, 12:33 AM
Unknown Object (File)
Oct 24 2024, 1:29 PM
Unknown Object (File)
Oct 24 2024, 1:29 PM
Unknown Object (File)
Oct 24 2024, 1:29 PM
Subscribers

Details

Summary

Patch removes all checks for pti/pcid/invpcid from the context switch path. I verified this by looking at the generated code. The invpcid_works1 trick required inline attribute for pmap_activate_sw_pcid_pti() to work.

The change requires moving of the pti and pcid_enabled initialization before ifunc resolution.

Trap.c change is mostly unrelated and just puts the PTI trap check into the same style as the SMAP trap check, also removing excessive new line from the panic message.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj added inline comments.
sys/amd64/amd64/machdep.c
1583 ↗(On Diff #48081)

I'd add a comment explaining why we do this here.

sys/amd64/amd64/pmap.c
7466 ↗(On Diff #48081)

Perhaps make invpcid_works1 const as a further hint?

sys/amd64/amd64/trap.c
711 ↗(On Diff #48081)

Missing newline.

This revision is now accepted and ready to land.Sep 16 2018, 3:28 PM
kib marked 3 inline comments as done.

Handle Mark' notes.

This revision now requires review to proceed.Sep 16 2018, 3:39 PM
This revision is now accepted and ready to land.Sep 16 2018, 4:05 PM
alc added inline comments.
sys/amd64/amd64/machdep.c
1585 ↗(On Diff #48082)

Rather than the also's and and's below, I would say it all up front: "Check for pti, pcid, and invpcid before ..."

1586 ↗(On Diff #48082)

"... select the implementation ..."

sys/amd64/amd64/pmap.c
7482 ↗(On Diff #48082)

I would say, "Explicitly", instead of "Manually". Then, add the word "automatically" to the next sentence, i.e., "... flushed automatically by ..."

This comment and the ones in the later functions have been deindented by a tab, so you might try reflowing the text.

7522 ↗(On Diff #48082)

"... used to handle an invalidate_all ..."

7524 ↗(On Diff #48082)

"The below sequence of operations has ..."

7526 ↗(On Diff #48082)

"... but the curpmap value has not yet been updated."

7527 ↗(On Diff #48082)

"... causes the invltlb ... handler, which is called between ..."

7528 ↗(On Diff #48082)

"... as a NOP ..."

7534 ↗(On Diff #48082)

"... and the IPI ..."

sys/amd64/amd64/trap.c
715 ↗(On Diff #48082)

Please insert a space into )==.

Do you plan to apply similar changes to the TLB invalidation code?

In D17181#366407, @alc wrote:

Do you plan to apply similar changes to the TLB invalidation code?

I will look at it certainly. We only need this for pmap_invalidate_XXX() functions, since IPI handlers already split.

Also I want to note D16736 which does the ifunc-ation for cache invalidation.

This revision was automatically updated to reflect the committed changes.
kib marked 10 inline comments as done.

Updated diff after processing Alan' comments.

This revision is now accepted and ready to land.Sep 16 2018, 7:56 PM
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state Needs Review.Sep 17 2018, 3:34 PM
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state Needs Review.Sep 17 2018, 3:52 PM
This revision was automatically updated to reflect the committed changes.