orbis: remove incomplete check from dmem & add debug log for blockpool

This commit is contained in:
DH 2025-12-02 04:43:00 +03:00
parent 989925b764
commit c10d82f73a
2 changed files with 14 additions and 9 deletions

View file

@ -6,6 +6,7 @@
#include "rx/AddressRange.hpp" #include "rx/AddressRange.hpp"
#include "rx/MemoryTable.hpp" #include "rx/MemoryTable.hpp"
#include "rx/die.hpp" #include "rx/die.hpp"
#include "rx/format.hpp"
#include "thread/Process.hpp" #include "thread/Process.hpp"
#include "vmem.hpp" #include "vmem.hpp"
#include <algorithm> #include <algorithm>
@ -187,14 +188,16 @@ struct PooledMemoryResource {
auto mapVirtualRange = rx::AddressRange::fromBeginSize( auto mapVirtualRange = rx::AddressRange::fromBeginSize(
virtualRange.beginAddress(), block.size()); virtualRange.beginAddress(), block.size());
virtualRange = rx::AddressRange::fromBeginEnd(
mapVirtualRange.endAddress(), virtualRange.endAddress());
auto errc = orbis::pmem::map(mapVirtualRange.beginAddress(), block, auto errc = orbis::pmem::map(mapVirtualRange.beginAddress(), block,
orbis::vmem::toCpuProtection(protection)); orbis::vmem::toCpuProtection(protection));
rx::dieIf(errc != orbis::ErrorCode{}, rx::dieIf(errc != orbis::ErrorCode{},
"blockpool: failed to map physical memory"); "blockpool: failed to map physical memory, vmem {:x}-{:x}, "
"pmem {:x}-{:x}, commit vmem {:x}-{:x}, error {}",
mapVirtualRange.beginAddress(), mapVirtualRange.endAddress(),
block.beginAddress(), block.endAddress(),
virtualRange.beginAddress(), virtualRange.endAddress(), errc);
amdgpu::mapMemory(process->pid, mapVirtualRange, type, protection, amdgpu::mapMemory(process->pid, mapVirtualRange, type, protection,
block.beginAddress()); block.beginAddress());
@ -202,6 +205,9 @@ struct PooledMemoryResource {
{.pmemAddress = block.beginAddress(), .type = type}, {.pmemAddress = block.beginAddress(), .type = type},
false); false);
freeBlocks.pop_back(); freeBlocks.pop_back();
virtualRange = rx::AddressRange::fromBeginEnd(
mapVirtualRange.endAddress(), virtualRange.endAddress());
} }
} }
@ -309,8 +315,7 @@ orbis::ErrorCode
orbis::blockpool::commit(Process *process, rx::AddressRange vmemRange, orbis::blockpool::commit(Process *process, rx::AddressRange vmemRange,
MemoryType type, MemoryType type,
rx::EnumBitSet<orbis::vmem::Protection> protection) { rx::EnumBitSet<orbis::vmem::Protection> protection) {
auto pool = auto pool = type == MemoryType::WbOnion ? g_cachedBlockpool : g_blockpool;
type == MemoryType::WbOnion ? g_cachedBlockpool : g_blockpool;
auto otherPool = auto otherPool =
type == MemoryType::WbOnion ? g_blockpool : g_cachedBlockpool; type == MemoryType::WbOnion ? g_blockpool : g_cachedBlockpool;

View file

@ -673,9 +673,9 @@ orbis::ErrorCode orbis::dmem::map(orbis::Process *process, unsigned dmemIndex,
return ErrorCode::ACCES; return ErrorCode::ACCES;
} }
if (!allocationInfoIt->mappings.empty() && !process->allowDmemAliasing) { // if (!allocationInfoIt->mappings.empty() && !process->allowDmemAliasing) {
return ErrorCode::INVAL; // return ErrorCode::INVAL;
} // }
auto directRange = rx::AddressRange::fromBeginSize(offset, range.size()) auto directRange = rx::AddressRange::fromBeginSize(offset, range.size())
.intersection(allocationInfoIt.range()); .intersection(allocationInfoIt.range());