[Memory] Preallocate whole physical range for GPU.

Seems like GPU has direct access to whole RAM and can request anything.

Removed check for page access as all pages are now available for gpu
This commit is contained in:
Gliniak
2024-09-01 22:21:28 +02:00
parent ed843f35f8
commit 5f5be06680
3 changed files with 24 additions and 29 deletions

View File

@@ -84,6 +84,17 @@ void CrashDump() {
--in_crash_dump;
}
xe::memory::PageAccess ToPageAccess(uint32_t protect) {
if ((protect & kMemoryProtectRead) && !(protect & kMemoryProtectWrite)) {
return xe::memory::PageAccess::kReadOnly;
} else if ((protect & kMemoryProtectRead) &&
(protect & kMemoryProtectWrite)) {
return xe::memory::PageAccess::kReadWrite;
} else {
return xe::memory::PageAccess::kNoAccess;
}
}
Memory::Memory() {
system_page_size_ = uint32_t(xe::memory::page_size());
system_allocation_granularity_ =
@@ -196,6 +207,17 @@ bool Memory::Initialize() {
kMemoryAllocationReserve | kMemoryAllocationCommit,
kMemoryProtectRead | kMemoryProtectWrite);
// TODO(Gliniak): Seems like GPU has access to whole physical memory range
// without any restriction. This however needs some form of validation.
// That's why we're commiting whole physical memory range and deal with
// allocations issues on custom page protection level.
for (size_t i = 1; i <= 16; i++) {
xe::memory::AllocFixed(heaps_.physical.TranslateRelative(i << 24),
heaps_.physical.page_size() * 0x10000,
xe::memory::AllocationType::kCommit,
xe::memory::PageAccess::kReadWrite);
}
// Add handlers for MMIO.
mmio_handler_ = cpu::MMIOHandler::Install(
virtual_membase_, physical_membase_, physical_membase_ + 0x1FFFFFFF,
@@ -670,17 +692,6 @@ bool Memory::Restore(ByteStream* stream) {
return true;
}
xe::memory::PageAccess ToPageAccess(uint32_t protect) {
if ((protect & kMemoryProtectRead) && !(protect & kMemoryProtectWrite)) {
return xe::memory::PageAccess::kReadOnly;
} else if ((protect & kMemoryProtectRead) &&
(protect & kMemoryProtectWrite)) {
return xe::memory::PageAccess::kReadWrite;
} else {
return xe::memory::PageAccess::kNoAccess;
}
}
uint32_t FromPageAccess(xe::memory::PageAccess protect) {
switch (protect) {
case memory::PageAccess::kNoAccess: