Page MenuHomeFreeBSD

riscv stage2 pmap support
ClosedPublic

Authored by br on Jun 4 2024, 1:33 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 19, 9:31 AM
Unknown Object (File)
Nov 18 2024, 8:13 PM
Unknown Object (File)
Nov 18 2024, 6:26 PM
Unknown Object (File)
Nov 14 2024, 2:41 PM
Unknown Object (File)
Nov 10 2024, 2:59 PM
Unknown Object (File)
Nov 7 2024, 10:30 AM
Unknown Object (File)
Nov 7 2024, 8:51 AM
Unknown Object (File)
Nov 4 2024, 9:51 AM
Subscribers

Details

Summary

Add basic Stage2 support (guest physical to host physical)

RISC-V hypervisor spec[1] extends top page table directory from 4K page to 16K page making total addressable memory 1petabyte (4x256TB).
The rest of page table system (including PTE format) is identical.

I am not sure if that makes any sense to us to support all of that space since our VM layout limits user VA space to 128TB.

(If some one want I can try to support all that space, but that could add a mess into pmap.c since NUL2E, NUL1E, NUL0E defines have to be converted into macroses, i.e. NUL2E(pmap) depending on stage could give different bounds)

  1. https://five-embeddev.com/riscv-priv-isa-manual/Priv-v1.12/hypervisor.html
Test Plan

Tested on unmodified Spike running Bhyve with 2.5gb of memory

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

br requested review of this revision.Jun 4 2024, 1:33 PM

No objection if you want to commit this now. I agree it is unimportant to support the full address space, at present.

sys/riscv/riscv/pmap.c
1353
This revision is now accepted and ready to land.Jun 4 2024, 11:26 PM

The rest of page table system (including PTE format) is identical.

That's not entirely true; the G bit exists but is reserved. Having said that I don't think we currently set it? (Though there is code to inspect and preserve it in places)

The rest of page table system (including PTE format) is identical.

That's not entirely true; the G bit exists but is reserved. Having said that I don't think we currently set it? (Though there is code to inspect and preserve it in places)

right, we will need to support hypervisor memory-management fence instructions (and manage address space/VM IDs etc). I will put this into TODO list.

sys/riscv/riscv/pmap.c
1353

that is intentional to fit into 80 characters line

rename variable mtop to m

This revision now requires review to proceed.Jun 5 2024, 10:06 AM
In D45481#1037849, @br wrote:

The rest of page table system (including PTE format) is identical.

That's not entirely true; the G bit exists but is reserved. Having said that I don't think we currently set it? (Though there is code to inspect and preserve it in places)

right, we will need to support hypervisor memory-management fence instructions (and manage address space/VM IDs etc). I will put this into TODO list.

FYI I have some old patches for the G bit, but it needs rebasing. This will come after Svpbmt.

This revision is now accepted and ready to land.Jun 5 2024, 12:50 PM
This revision was automatically updated to reflect the committed changes.