Page MenuHomeFreeBSD

amd64: Reload cpu ext features after resume or cr4 changes
ClosedPublic

Authored by dchagin on Jun 22 2022, 11:42 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Oct 21, 4:45 AM
Unknown Object (File)
Mon, Oct 21, 4:44 AM
Unknown Object (File)
Mon, Oct 21, 4:44 AM
Unknown Object (File)
Mon, Oct 21, 4:44 AM
Unknown Object (File)
Mon, Oct 21, 4:44 AM
Unknown Object (File)
Mon, Oct 21, 4:44 AM
Unknown Object (File)
Mon, Oct 21, 4:44 AM
Unknown Object (File)
Mon, Oct 21, 4:21 AM
Subscribers

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 46069
Build 42958: arc lint + arc unit

Event Timeline

dchagin retitled this revision from linprocfs: Save some cpu features to avoid overwriting by the kernel to linprocfs: Save ext cpu feature3 as it is zeroed by the kernel.Jun 22 2022, 11:50 PM
dchagin added reviewers: Linux Emulation, kib.
dchagin changed the repository for this revision from rS FreeBSD src repository - subversion to rG FreeBSD src repository.

read and local feature2 to reflect cr4 changes

If these are indeed the problems, they should be fixed in the kernel proper, not worked around in linprocfs.

sys/compat/linprocfs/linprocfs.c
149

If you are about OSPKE, then I believe that the right fix is to re-read feature2 after setting the bit in CR4.

150

Can you explain more, where feature3 is zeroed?

In D35555#807163, @kib wrote:

If these are indeed the problems, they should be fixed in the kernel proper, not worked around in linprocfs.

sure, I wrote a reply to the 986c4ca3 a few days ago about this

sys/compat/linprocfs/linprocfs.c
149

agree, I commented on it above

150

https://cgit.freebsd.org/src/tree/sys/amd64/acpica/acpi_wakeup.c#n219

seems on wakeup we should reload ext features before initializecpu(), at first look

So why not write a proper patch instead?

In D35555#807315, @kib wrote:

So why not write a proper patch instead?

Target fixation, ok, I just got home, I'm on it.

Replace linprocfs workaround by kernel fix

dchagin retitled this revision from linprocfs: Save ext cpu feature3 as it is zeroed by the kernel to amd64: Reload cpu ext features after resume or cr4 changes.Jun 27 2022, 11:49 AM
sys/amd64/amd64/initcpu.c
296 ↗(On Diff #107430)

I suggest only do this once, see the IS_BSP() check above. Otherwise you introduce the unpleasant race where all APs are writing to the variables.

I believe that resume occurs on BSP, please recheck.

done, about resume on BSP, AFAIR, according to the ACPI Spec (16.3), it should,
and it works

This revision is now accepted and ready to land.Jun 28 2022, 5:18 PM