Page MenuHomeFreeBSD

riscv: correctly set kernel_pmap hart mask
ClosedPublic

Authored by mhorne on Nov 3 2020, 7:21 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 10, 2:40 AM
Unknown Object (File)
Fri, Nov 1, 2:09 AM
Unknown Object (File)
Thu, Oct 24, 11:57 AM
Unknown Object (File)
Oct 1 2024, 1:55 PM
Unknown Object (File)
Sep 28 2024, 1:30 PM
Unknown Object (File)
Sep 24 2024, 12:54 AM
Unknown Object (File)
Sep 22 2024, 11:03 PM
Unknown Object (File)
Sep 15 2024, 7:27 PM
Subscribers

Details

Summary

In pmap_bootstrap(), we fill kernel_pmap->pm_active since it is
invariably active on all harts. However, this marks it as active even
for harts that don't exist in the system, which can cause issue when the
mask is passed to the SBI firmware via sbi_remote_sfence_vma().
Specifically, the SBI spec allows SBI_ERR_INVALID_PARAM to be returned
when an invalid hart is set in the mask.

The latest version of OpenSBI does not have this issue, but v0.6 does,
and this is triggering a recently added KASSERT in CI. Change to only setting
bits in pm_active for harts that enter the system.

Test Plan

Boot succeeds with OpenSBI v0.6.

Diff Detail

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

Event Timeline

mhorne requested review of this revision.Nov 3 2020, 7:21 PM
mhorne created this revision.

Change to only setting bits in pm_active for harts that enter the system.

I don't see where secondary harts set pm_active bits in kernel_pmap. Note that vmspace_pmap(&vmspace0) is not the same thing as kernel_pmap. That is, the pmap_activate_boot() call in init_secondary() doesn't modify kernel_pmap.

Change to only setting bits in pm_active for harts that enter the system.

I don't see where secondary harts set pm_active bits in kernel_pmap. Note that vmspace_pmap(&vmspace0) is not the same thing as kernel_pmap. That is, the pmap_activate_boot() call in init_secondary() doesn't modify kernel_pmap.

You're right, I did not read it closely enough. It should be enough to set the active bit directly in init_secondary(), perhaps right before we call pmap_activate_boot() ?

Activate for secondary cores as well.

markj added inline comments.
sys/riscv/riscv/pmap.c
578 ↗(On Diff #79163)

You might add a sentence or two explaining why we don't use CPU_FILL.

This revision is now accepted and ready to land.Nov 4 2020, 4:58 PM
This revision was automatically updated to reflect the committed changes.