This document describes how the paging system is now integrated into the CoreJS JavaScript code generator and Reactor types.
The paging system can now be configured at runtime through the generated Reactor type. The paging configuration is automatically used when generating JavaScript code for memory access.
The Flags struct in vane-arch/src/template.rs now includes paging configuration:
pub struct Flags {
pub test_mode: bool,
pub paging_mode: Option<PagingMode>,
pub shared_page_table_vaddr: Option<u64>,
pub use_32bit_paging: bool,
pub use_multilevel_paging: bool,
}New constructor:
Flags::with_paging(
test_mode: bool,
paging_mode: PagingMode,
shared_page_table_vaddr: Option<u64>,
use_32bit_paging: bool,
use_multilevel_paging: bool,
)The CoreJS struct now generates different JavaScript data functions based on the paging mode:
-
Legacy Mode (default): Uses
$.get_page()directlydata = (p => { p = $.get_page(p); return new DataView($._sys('memory').buffer, p); })
-
Shared/Both Mode with Single-Level Paging:
- 64-bit physical addresses: Inline page table lookup with 8-byte entries
- 32-bit physical addresses: Inline page table lookup with 4-byte entries
-
Shared/Both Mode with Multi-Level Paging:
- 64-bit physical addresses: 3-level page table with 8-byte entries
- 32-bit physical addresses: 3-level page table with 4-byte entries
New JavaScript methods added to generated Reactor types:
reactor.get_paging_mode() // Returns: "legacy", "shared", or "both"
reactor.set_paging_mode("shared") // Sets the paging modereactor.get_shared_page_table_vaddr() // Returns: u64 or null
reactor.set_shared_page_table_vaddr(0x1000000n) // Sets the virtual address of the page tablelet reactor = new Reactor();
// Default mode is "legacy" - no configuration needed
// Memory access goes through $.get_page() directlylet reactor = new Reactor();
// Configure shared paging
reactor.set_paging_mode("shared");
reactor.set_shared_page_table_vaddr(0x1000000n);
// Now generated JavaScript will use inline page table translation
// The page table must be set up at virtual address 0x1000000let reactor = new Reactor();
// Configure nested paging (page table stored in legacy virtual memory)
reactor.set_paging_mode("both");
reactor.set_shared_page_table_vaddr(0x1000000n);
// The shared page table at 0x1000000 will be accessed through legacy get_page()
// This provides two-level translation:
// 1. Shared page table lookup (in legacy virtual space)
// 2. Legacy page allocation for physical memory-
Configuration: When you set the paging mode and page table address on the Reactor, these values are stored in the
Memstructure. -
Code Generation: When
jit_code()is called, it reads the current paging configuration fromMemand createsFlagswith these settings. -
JavaScript Output: The
CoreJSstruct generates JavaScript with the appropriatedatafunction based on the flags:- Reads
paging_mode,shared_page_table_vaddr,use_32bit_paging, anduse_multilevel_paging - Generates inline page table lookup code for Shared/Both modes
- Falls back to legacy mode if page table address is not configured
- Reads
-
Runtime: The generated JavaScript code performs address translation according to the configured paging mode.
Currently, use_32bit_paging and use_multilevel_paging are hardcoded to false in the macro. To use these features, you can modify the macro or expose additional configuration methods:
// In vane-meta-gen/src/lib.rs, modify the jit_code function:
let flags = Flags::with_paging(
test_mode,
paging_mode,
shared_page_table_vaddr,
true, // Enable 32-bit paging
false, // Disable multi-level paging
);Or add additional setter methods to the Reactor type for these options.
PAGING.md- Complete paging system specificationcrates/vane-arch/src/lib.rs- Paging implementation with translation functionscrates/vane-arch/src/template.rs- CoreJS and Flags structurescrates/vane-meta-gen/src/lib.rs- Reactor type generation macro