diff --git a/rpcsx-gpu/main.cpp b/rpcsx-gpu/main.cpp index be83a8c4d..a6f943bc3 100644 --- a/rpcsx-gpu/main.cpp +++ b/rpcsx-gpu/main.cpp @@ -1032,8 +1032,8 @@ int main(int argc, const char *argv[]) { auto memory = amdgpu::RemoteMemory{process.vmId}; rx::mem::protect(memory.getPointer(cmd.memoryProt.address), cmd.memoryProt.size, cmd.memoryProt.prot >> 4); - device.handleProtectMemory(memory, cmd.mapMemory.address, - cmd.mapMemory.size, cmd.mapMemory.prot); + device.handleProtectMemory(memory, cmd.memoryProt.address, + cmd.memoryProt.size, cmd.memoryProt.prot); } break; } diff --git a/rpcsx-os/main.cpp b/rpcsx-os/main.cpp index 5f8f1510e..21ada2ff1 100644 --- a/rpcsx-os/main.cpp +++ b/rpcsx-os/main.cpp @@ -1747,7 +1747,7 @@ int main(int argc, const char *argv[]) { auto initProcess = orbis::g_context.createProcess(asRoot ? 1 : 10); // pthread_setname_np(pthread_self(), "10.MAINTHREAD"); - rx::vm::initialize(); + rx::vm::initialize(initProcess->pid); runRpsxGpu(); if (enableAudio) { diff --git a/rpcsx-os/vm.cpp b/rpcsx-os/vm.cpp index 24bd3f885..78e4d1623 100644 --- a/rpcsx-os/vm.cpp +++ b/rpcsx-os/vm.cpp @@ -724,11 +724,11 @@ void rx::vm::reset() { kMaxAddress - kMinAddress); } -void rx::vm::initialize() { +void rx::vm::initialize(std::uint64_t pid) { std::printf("Memory: initialization\n"); - gMemoryShm = - ::shm_open("/rpcsx-os-memory", O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); + gMemoryShm = ::shm_open(("/rpcsx-os-memory-" + std::to_string(pid)).c_str(), + O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); if (gMemoryShm == -1) { std::fprintf(stderr, "Memory: failed to open /rpcsx-os-memory\n"); @@ -938,6 +938,16 @@ void *rx::vm::map(void *addr, std::uint64_t len, std::int32_t prot, gMapInfo.map(address, address + len, info); } + // if (device == nullptr) { + if (auto thr = orbis::g_currentThread) { + rx::bridge.sendMapMemory(thr->tproc->pid, -1, -1, address, len, prot, + address - kMinAddress); + } else { + std::fprintf(stderr, "ignoring mapping %lx-%lx\n", address, + address + len); + } + // } + if (internalFlags & kMapInternalReserveOnly) { return reinterpret_cast(address); } @@ -957,12 +967,6 @@ void *rx::vm::map(void *addr, std::uint64_t len, std::int32_t prot, } } - if (auto thr = orbis::g_currentThread) { - rx::bridge.sendMapMemory(thr->tproc->pid, -1, -1, address, len, prot, - address - kMinAddress); - } else { - std::fprintf(stderr, "ignoring mapping %lx-%lx\n", address, address + len); - } return result; } @@ -1032,6 +1036,7 @@ bool rx::vm::protect(void *addr, std::uint64_t size, std::int32_t prot) { kAllocated | (prot & (kMapProtCpuAll | kMapProtGpuAll)), false); if (auto thr = orbis::g_currentThread) { + std::printf("memory prot: %x\n", prot); rx::bridge.sendMemoryProtect( thr->tproc->pid, reinterpret_cast(addr), size, prot); } else { diff --git a/rpcsx-os/vm.hpp b/rpcsx-os/vm.hpp index ca49921ba..2b1f6c0bc 100644 --- a/rpcsx-os/vm.hpp +++ b/rpcsx-os/vm.hpp @@ -69,7 +69,7 @@ std::string mapProtToString(std::int32_t prot); void printHostStats(); void fork(std::uint64_t pid); void reset(); -void initialize(); +void initialize(std::uint64_t pid); void deinitialize(); void *map(void *addr, std::uint64_t len, std::int32_t prot, std::int32_t flags, std::int32_t internalFlags = 0, IoDevice *device = nullptr,