Page MenuHomeFreeBSD

riscv: mark kernel page table entries as global
AcceptedPublic

Authored by mhorne on Aug 20 2026, 3:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Sep 19, 8:10 PM
Unknown Object (File)
Fri, Sep 18, 4:13 PM
Unknown Object (File)
Fri, Sep 18, 12:16 AM
Unknown Object (File)
Thu, Sep 17, 9:25 AM
Unknown Object (File)
Thu, Sep 17, 8:08 AM
Unknown Object (File)
Mon, Sep 14, 6:23 PM
Unknown Object (File)
Sat, Sep 12, 5:24 AM
Unknown Object (File)
Fri, Sep 11, 3:32 PM
Subscribers

Details

Reviewers
markj
bnovkov
jrtc27
br
Group Reviewers
riscv
Summary

The G bit in a RISC-V PTE designates a "global" mapping; i.e. a virtual
address mapping that is valid across all contexts. Applying this bit to
kernel mappings offers a small performance benefit as it allows these
translations to be preserved during a normal TLB flush, for example
during a context switch.

This bit is applied to all L1 kernel PTEs, and only these. The spec
declares that the global bit can be set at any level, and is inherited
by all children. Applying it at this level yields the smallest and
simplest diff.

Use of the feature is toggleable via hw.pmap.global_bit_enable tunable.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 75879
Build 72762: arc lint + arc unit

Event Timeline

sys/riscv/riscv/pmap.c
1947

Should this also be marked with pte_g if pmap == kernel_pmap ?

sys/riscv/riscv/pmap.c
1947

Yes, it looks like it! kmem_alloc_contig() and others can reach here.

Thanks, will update.

mhorne marked an inline comment as done.

Apply pte_g in _pmap_alloc_l3() as well.

Thanks, LGTM now. I won't be able to test the patch series on a non- SiFive FU74 board until EuroBSDCon finishes, I'll let you know if anything comes up during testing.

This revision is now accepted and ready to land.Wed, Sep 9, 11:39 AM