diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index 48f26ec298..bd647b0acf 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -16,6 +16,7 @@ #include #include #include +#include typedef void (*SceKernelExceptionHandler)(int32_t, void*); extern "C" int32_t sceKernelInstallExceptionHandler(int32_t signum, SceKernelExceptionHandler handler); #endif @@ -143,8 +144,13 @@ void* AllocateMemoryPages(std::size_t size) noexcept { #elif defined(__OPENORBIS__) void* addr; if (size <= 8192 * 4096) { - addr = malloc(size); - LOG_WARNING(HW_Memory, "Using DMem for {} bytes area @ {}", size, addr); + size_t align = 16384; + size_t len = (size + align - 1) / align * align; + off_t offset = 0; + ASSERT(sceKernelAllocateDirectMemory(0, ORBIS_KERNEL_MAIN_DMEM_SIZE, len, align, ORBIS_KERNEL_WB_ONION, &offset) == 0); + ASSERT(sceKernelMapDirectMemory(&addr, len, ORBIS_KERNEL_PROT_CPU_RW, 0, offset, len) == 0); + ASSERT(sceKernelMprotect(addr, len, VM_PROT_ALL) == 0); + LOG_WARNING(HW_Memory, "Using DMem for {} bytes area @ {}", len, addr); ASSERT(addr != nullptr); } else { addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_VOID | MAP_PRIVATE, -1, 0); @@ -166,7 +172,7 @@ void FreeMemoryPages(void* addr, [[maybe_unused]] std::size_t size) noexcept { VirtualFree(addr, 0, MEM_RELEASE); #elif defined(__OPENORBIS__) if (size <= 8192 * 4096) { - free(addr); + sceKernelCheckedReleaseDirectMemory(off_t(addr), size_t(size)); } else { int rc = munmap(addr, size); ASSERT(rc == 0); diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index c207335d71..8ef8cafae1 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp @@ -204,7 +204,7 @@ void ArmDynarmic32::MakeJit(Common::PageTable* page_table) { // Code cache size #if defined(__OPENORBIS__) - config.code_cache_size = std::uint32_t(32_MiB); + config.code_cache_size = std::uint32_t(128_MiB); #elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) config.code_cache_size = std::uint32_t(128_MiB); #else diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index 8a5c0c1649..256ab6ce22 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp @@ -255,7 +255,7 @@ void ArmDynarmic64::MakeJit(Common::PageTable* page_table, std::size_t address_s // Code cache size #if defined(__OPENORBIS__) - config.code_cache_size = std::uint32_t(32_MiB); + config.code_cache_size = std::uint32_t(128_MiB); #elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) config.code_cache_size = std::uint32_t(128_MiB); #else diff --git a/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp b/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp index 39e39577e9..9b0e44b19f 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp @@ -58,13 +58,8 @@ const std::array BlockOfCode::ABI_PARAMS = {Block namespace { -#ifdef __OPENORBIS__ -constexpr size_t CONSTANT_POOL_SIZE = 8 * 4096; -constexpr size_t PRELUDE_COMMIT_SIZE = 8 * 4096; -#else constexpr size_t CONSTANT_POOL_SIZE = 2 * 1024 * 1024; constexpr size_t PRELUDE_COMMIT_SIZE = 16 * 1024 * 1024; -#endif class CustomXbyakAllocator : public Xbyak::Allocator { public: @@ -247,9 +242,7 @@ bool IsUnderRosetta() { } // anonymous namespace BlockOfCode::BlockOfCode(RunCodeCallbacks cb, JitStateInfo jsi, size_t total_code_size, std::function rcp) noexcept -#ifdef __OPENORBIS__ - : Xbyak::CodeGenerator(total_code_size, Xbyak::AutoGrow, &s_allocator) -#elif defined(DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT) +#if defined(DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT) : Xbyak::CodeGenerator(total_code_size, Xbyak::DontSetProtectRWE, &s_allocator) #else : Xbyak::CodeGenerator(total_code_size, nullptr, &s_allocator)