Skip to content

Build lightweight virtual memory manager (vm_map/vm_unmap/vm_clone) #57

Description

@pbalduino

Goal

Create a lightweight virtual memory manager that provides high-level VM operations and wraps low-level page table manipulation.

Context

Currently, virtual memory operations are open-coded throughout the kernel. We need a clean abstraction layer that manages virtual memory regions and handles cleanup properly.

Definition of Done

  • vm_map(): Map virtual memory regions with specified permissions
  • vm_unmap(): Unmap and free virtual memory regions
  • vm_clone(): Clone virtual memory spaces for process creation
  • Region management: Update vm_region table during all operations
  • Cleanup integration: Proper cleanup on process exit without page leaks
  • 16 MiB support: Handle large footprints efficiently (for Doom requirements)

API Design

Implementation Details

  • Wrap pmm_map_page_in_root() calls with higher-level interface
  • Maintain vm_region metadata during all operations
  • Implement proper reference counting for shared pages
  • Add memory leak detection and prevention
  • Support efficient mapping/unmapping of large regions
  • Handle page table allocation and cleanup

Benefits

  • Eliminates open-coded page table loops
  • Prevents memory leaks through proper tracking
  • Makes 16 MiB footprints manageable
  • Provides clean interface for other kernel subsystems
  • Enables easier debugging and validation

Files to Create

  • vm_manager.h - Virtual memory manager interface
  • vm_manager.c - Implementation of VM operations
  • Integration with existing memory management
  • Helper functions for common VM operations

Dependencies

  • Formal VM layout system
  • vm_region table implementation
  • Existing page table management

Related Issues

This is part of the per-process virtual memory management overhaul (issue #28).

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions