This is a big one, because it turns out that memory management is a pretty core aspect of the kernel. Sorry in advance, it's hard to break up something like this and still have things boot.
Highlights
The new context code has the following highlights:
A trait, UserContext, that defines the interface for the rest of the kernel to interact with user-facing aspects of memory management (mapping objects, etc).
A trait, KernelMemoryContext, that provides the kernel allocator with a consistent interface for managing kernel memory. Currently this is largely to support the global allocator.
An implementation of both traits, VirtContext. This type implements UserContext and KernelMemoryContext for virtual memory systems (x86, aarch64, etc).
A concrete type alias, Context, that selects an implementation at compile time (e.g. x86 will have type Context = VirtContext;.
A major refactoring throughout the kernel to clean things up and use the new Context interfaces.
The new page table code has the following highlights:
A new system for managing page tables that is generic over the actual structures, making the majority of the page table code not arch-specific.
A better interface for operating on page tables.
TLB coherence and cache coherence for structures is tracked automatically and invalidations are queued into batches for other CPUs.
What's missing?
These will come in future patches:
Support for PCIDs on x86 to reduce TLB shootdowns and invalidations.
Support for tracking which CPUs a set of page tables are active on, to reduce invalidation traffic.
This is a big one, because it turns out that memory management is a pretty core aspect of the kernel. Sorry in advance, it's hard to break up something like this and still have things boot.
Highlights
The new context code has the following highlights:
type Context = VirtContext;
.The new page table code has the following highlights:
What's missing?
These will come in future patches: