vm: fix initial process memory name

This commit is contained in:
DH 2024-09-01 18:52:32 +03:00
parent b17bf677e5
commit df3a2d36d2
4 changed files with 18 additions and 13 deletions

View file

@ -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;
}

View file

@ -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) {

View file

@ -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<void *>(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<std::uint64_t>(addr), size, prot);
} else {

View file

@ -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,