The Pedigree Project 0.1
memory-region-regressions.cc
1/*
2 * Copyright (c) 2026, Pedigree Developers
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted.
6 */
7
8#include "pedigree/kernel/Log.h"
9#include "pedigree/kernel/processor/MemoryRegion.h"
10#include "pedigree/kernel/processor/PhysicalMemoryManager.h"
11#include "pedigree/kernel/processor/VirtualAddressSpace.h"
12
13bool runAnonymousMemoryRegionRegression() {
14 NOTICE("QEMU-CONCURRENCY-TEST: BEGIN anonymous-memory-region-release");
15
17 const physical_uintptr_t page = memory.allocatePage();
18 if (!page) {
19 ERROR("QEMU anonymous MemoryRegion regression could not allocate a page");
20 return false;
21 }
22
23 MemoryRegion region("QEMU anonymous MemoryRegion regression");
24 if (!memory.allocateRegion(region, 1,
28 memory.freePage(page);
29 ERROR("QEMU anonymous MemoryRegion regression could not map its page");
30 return false;
31 }
32
33 void* address = region.virtualAddress();
35 if (!addressSpace.isMapped(address)) {
36 region.free();
37 memory.freePage(page);
38 ERROR("QEMU anonymous MemoryRegion regression was not mapped");
39 return false;
40 }
41
42 region.free();
43 if (addressSpace.isMapped(address)) {
44 addressSpace.unmap(address);
45 memory.freePage(page);
46 ERROR("QEMU anonymous MemoryRegion release left a stale mapping");
47 return false;
48 }
49
50 memory.freePage(page);
51 NOTICE("QEMU-CONCURRENCY-TEST: PASS anonymous-memory-region-release");
52 return true;
53}
Special memory entity in the kernel's virtual address space.
virtual physical_uintptr_t allocatePage(size_t pageConstraints=0)=0
static PhysicalMemoryManager & instance()
virtual void freePage(physical_uintptr_t page)=0
virtual bool allocateRegion(MemoryRegion &Region, size_t cPages, size_t pageConstraints, size_t Flags, physical_uintptr_t start=-1)=0
virtual bool isMapped(void *virtualAddress)=0
static EXPORTED_PUBLIC VirtualAddressSpace & getKernelAddressSpace()
virtual void unmap(void *virtualAddress)=0