Allocator: Still need to return memory regions to frontend

This commit is contained in:
Ryan Houdek committed 2025-01-28 16:07:51 -08:00
1 parent dc866538d4
commit 11ce97655b
3 files changed
+8 -4

No files matched your search

+4 -2
View File
@@ -304,10 +304,10 @@ fextl::vector<MemoryRegion> StealMemoryRegion(uintptr_t Begin, uintptr_t End) {
return Regions;
}
void Setup48BitAllocatorIfExists() {
fextl::vector<MemoryRegion> Setup48BitAllocatorIfExists() {
size_t Bits = FEXCore::Allocator::DetermineVASize();
if (Bits < 48) {
return;
return {};
}
uintptr_t Begin48BitVA = 0x0'8000'0000'0000ULL;
@@ -316,6 +316,8 @@ void Setup48BitAllocatorIfExists() {
Alloc64 = Alloc::OSAllocator::Create64BitAllocatorWithRegions(Regions);
AssignHookOverrides();
return Regions;
}
void ReclaimMemoryRegion(const fextl::vector<MemoryRegion>& Regions) {
+1 -1
View File
@@ -86,7 +86,7 @@ FEX_DEFAULT_VISIBILITY void ReclaimMemoryRegion(const fextl::vector<MemoryRegion
// AArch64 canonical addresses are only up to bits 48/52 with the remainder being other things
// Use this to reserve the top 128TB of VA so the guest never see it
// Returns nullptr on host VA < 48bits
FEX_DEFAULT_VISIBILITY void Setup48BitAllocatorIfExists();
FEX_DEFAULT_VISIBILITY fextl::vector<MemoryRegion> Setup48BitAllocatorIfExists();
#ifndef _WIN32
FEX_DEFAULT_VISIBILITY void RegisterTLSData(FEXCore::Core::InternalThreadState* Thread);
+3 -1
View File
@@ -491,11 +491,12 @@ int main(int argc, char** argv, char** const envp) {
FEXCore::Config::EraseSet(FEXCore::Config::CONFIG_IS64BIT_MODE, Loader.Is64BitMode() ? "1" : "0");
fextl::unique_ptr<FEX::HLE::MemAllocator> Allocator;
fextl::vector<FEXCore::Allocator::MemoryRegion> Base48Bit;
fextl::vector<FEXCore::Allocator::MemoryRegion> Low4GB;
if (Loader.Is64BitMode()) {
// Destroy the 48th bit if it exists
FEXCore::Allocator::Setup48BitAllocatorIfExists();
Base48Bit = FEXCore::Allocator::Setup48BitAllocatorIfExists();
} else {
// Reserve [0x1_0000_0000, 0x2_0000_0000).
// Safety net if 32-bit address calculation overflows in to 64-bit range.
@@ -684,6 +685,7 @@ int main(int argc, char** argv, char** const envp) {
LogMan::Msg::UnInstallHandler();
FEXCore::Allocator::ClearHooks();
FEXCore::Allocator::ReclaimMemoryRegion(Base48Bit);
FEXCore::Allocator::ReclaimMemoryRegion(Low4GB);
// Allocator is now original system allocator