From 165c5792cc331a9030019ba666d6d5fe4bb256f4 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Tue, 1 Mar 2022 03:16:42 +0100 Subject: [PATCH] early-access version 2524 --- README.md | 2 +- .../backend/x64/a32_emit_x64_memory.cpp | 3 +++ .../src/dynarmic/backend/x64/a64_emit_x64.cpp | 1 + .../backend/x64/a64_emit_x64_memory.cpp | 7 +++++-- .../src/dynarmic/backend/x64/block_of_code.h | 18 ++++++++++++++++++ .../src/dynarmic/backend/x64/emit_x64_sm4.cpp | 1 + externals/dynarmic/tests/A32/fuzz_arm.cpp | 3 ++- externals/ffmpeg/CMakeLists.txt | 2 +- src/core/hle/service/ldr/ldr.cpp | 15 ++++++++++++++- .../renderer_opengl/gl_fence_manager.cpp | 3 +-- 10 files changed, 47 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7db8a6d08..3a5a831ea 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2522. +This is the source code for early-access 2524. ## Legal Notice diff --git a/externals/dynarmic/src/dynarmic/backend/x64/a32_emit_x64_memory.cpp b/externals/dynarmic/src/dynarmic/backend/x64/a32_emit_x64_memory.cpp index 171db013c..33f1ddfc7 100755 --- a/externals/dynarmic/src/dynarmic/backend/x64/a32_emit_x64_memory.cpp +++ b/externals/dynarmic/src/dynarmic/backend/x64/a32_emit_x64_memory.cpp @@ -61,6 +61,7 @@ void A32EmitX64::GenFastmemFallbacks() { code.mov(Xbyak::Reg64{value_idx}, code.ABI_RETURN); } ABI_PopCallerSaveRegistersAndAdjustStackExcept(code, HostLocRegIdx(value_idx)); + code.ZeroExtendFrom(bitsize, Xbyak::Reg64{value_idx}); code.ret(); PerfMapRegister(read_fallbacks[std::make_tuple(bitsize, vaddr_idx, value_idx)], code.getCurr(), fmt::format("a32_read_fallback_{}", bitsize)); } @@ -277,6 +278,7 @@ void A32EmitX64::EmitMemoryRead(A32EmitContext& ctx, IR::Inst* inst) { // Neither fastmem nor page table: Use callbacks ctx.reg_alloc.HostCall(inst, {}, args[0]); Devirtualize(conf.callbacks).EmitCall(code); + code.ZeroExtendFrom(bitsize, code.ABI_RETURN); return; } @@ -422,6 +424,7 @@ void A32EmitX64::ExclusiveReadMemory(A32EmitContext& ctx, IR::Inst* inst) { return (conf.callbacks->*callback)(vaddr); }); }); + code.ZeroExtendFrom(bitsize, code.ABI_RETURN); } template diff --git a/externals/dynarmic/src/dynarmic/backend/x64/a64_emit_x64.cpp b/externals/dynarmic/src/dynarmic/backend/x64/a64_emit_x64.cpp index a4d36aa9f..8a82fc4eb 100755 --- a/externals/dynarmic/src/dynarmic/backend/x64/a64_emit_x64.cpp +++ b/externals/dynarmic/src/dynarmic/backend/x64/a64_emit_x64.cpp @@ -140,6 +140,7 @@ void A64EmitX64::ClearCache() { EmitX64::ClearCache(); block_ranges.ClearCache(); ClearFastDispatchTable(); + fastmem_patch_info.clear(); } void A64EmitX64::InvalidateCacheRanges(const boost::icl::interval_set& ranges) { diff --git a/externals/dynarmic/src/dynarmic/backend/x64/a64_emit_x64_memory.cpp b/externals/dynarmic/src/dynarmic/backend/x64/a64_emit_x64_memory.cpp index 7c1aff7bc..2c0e50a5d 100755 --- a/externals/dynarmic/src/dynarmic/backend/x64/a64_emit_x64_memory.cpp +++ b/externals/dynarmic/src/dynarmic/backend/x64/a64_emit_x64_memory.cpp @@ -167,7 +167,7 @@ void A64EmitX64::GenFastmemFallbacks() { code.align(); exclusive_write_fallbacks[std::make_tuple(128, vaddr_idx, value_idx)] = code.getCurr(); - ABI_PushCallerSaveRegistersAndAdjustStack(code); + ABI_PushCallerSaveRegistersAndAdjustStackExcept(code, HostLoc::RAX); if (value_idx != 1) { code.movaps(xmm1, Xbyak::Xmm{value_idx}); } @@ -183,7 +183,7 @@ void A64EmitX64::GenFastmemFallbacks() { code.mov(code.ABI_PARAM2, Xbyak::Reg64{vaddr_idx}); } code.call(memory_exclusive_write_128); - ABI_PopCallerSaveRegistersAndAdjustStack(code); + ABI_PopCallerSaveRegistersAndAdjustStackExcept(code, HostLoc::RAX); code.ret(); PerfMapRegister(exclusive_write_fallbacks[std::make_tuple(128, vaddr_idx, value_idx)], code.getCurr(), "a64_write_fallback_128"); @@ -203,6 +203,7 @@ void A64EmitX64::GenFastmemFallbacks() { code.mov(Xbyak::Reg64{value_idx}, code.ABI_RETURN); } ABI_PopCallerSaveRegistersAndAdjustStackExcept(code, HostLocRegIdx(value_idx)); + code.ZeroExtendFrom(bitsize, Xbyak::Reg64{value_idx}); code.ret(); PerfMapRegister(read_fallbacks[std::make_tuple(bitsize, vaddr_idx, value_idx)], code.getCurr(), fmt::format("a64_read_fallback_{}", bitsize)); } @@ -498,6 +499,7 @@ void A64EmitX64::EmitMemoryRead(A64EmitContext& ctx, IR::Inst* inst) { } else { ctx.reg_alloc.HostCall(inst, {}, args[0]); Devirtualize(conf.callbacks).EmitCall(code); + code.ZeroExtendFrom(bitsize, code.ABI_RETURN); } return; } @@ -668,6 +670,7 @@ void A64EmitX64::EmitExclusiveReadMemory(A64EmitContext& ctx, IR::Inst* inst) { return (conf.callbacks->*callback)(vaddr); }); }); + code.ZeroExtendFrom(bitsize, code.ABI_RETURN); } else { const Xbyak::Xmm result = ctx.reg_alloc.ScratchXmm(); ctx.reg_alloc.Use(args[0], ABI_PARAM2); diff --git a/externals/dynarmic/src/dynarmic/backend/x64/block_of_code.h b/externals/dynarmic/src/dynarmic/backend/x64/block_of_code.h index 97b8930af..17aa9cd75 100755 --- a/externals/dynarmic/src/dynarmic/backend/x64/block_of_code.h +++ b/externals/dynarmic/src/dynarmic/backend/x64/block_of_code.h @@ -96,6 +96,24 @@ public: CallFunction(Common::FptrCast(l)); } + void ZeroExtendFrom(size_t bitsize, Xbyak::Reg64 reg) { + switch (bitsize) { + case 8: + movzx(reg.cvt32(), reg.cvt8()); + return; + case 16: + movzx(reg.cvt32(), reg.cvt16()); + return; + case 32: + mov(reg.cvt32(), reg.cvt32()); + return; + case 64: + return; + default: + UNREACHABLE(); + } + } + Xbyak::Address MConst(const Xbyak::AddressFrame& frame, u64 lower, u64 upper = 0); /// Far code sits far away from the near code. Execution remains primarily in near code. diff --git a/externals/dynarmic/src/dynarmic/backend/x64/emit_x64_sm4.cpp b/externals/dynarmic/src/dynarmic/backend/x64/emit_x64_sm4.cpp index bee51a80f..b084a92f9 100755 --- a/externals/dynarmic/src/dynarmic/backend/x64/emit_x64_sm4.cpp +++ b/externals/dynarmic/src/dynarmic/backend/x64/emit_x64_sm4.cpp @@ -15,6 +15,7 @@ void EmitX64::EmitSM4AccessSubstitutionBox(EmitContext& ctx, IR::Inst* inst) { ctx.reg_alloc.HostCall(inst, args[0]); code.CallFunction(&Common::Crypto::SM4::AccessSubstitutionBox); + code.movzx(code.ABI_RETURN.cvt32(), code.ABI_RETURN.cvt8()); } } // namespace Dynarmic::Backend::X64 diff --git a/externals/dynarmic/tests/A32/fuzz_arm.cpp b/externals/dynarmic/tests/A32/fuzz_arm.cpp index dcbc5b138..c36e99c9a 100755 --- a/externals/dynarmic/tests/A32/fuzz_arm.cpp +++ b/externals/dynarmic/tests/A32/fuzz_arm.cpp @@ -397,7 +397,8 @@ static void RunTestInstance(Dynarmic::A32::Jit& jit, if (uni.GetRegisters()[15] > jit.Regs()[15]) { const u32 final_pc = jit.Regs()[15]; - if (final_pc >= initial_pc && final_pc < expected_end_pc) { + int trials = 0; + while (final_pc >= initial_pc && final_pc < expected_end_pc && trials++ < 100) { fmt::print("Warning: Possible unicorn overrrun, attempt recovery\n"); jit.Step(); } diff --git a/externals/ffmpeg/CMakeLists.txt b/externals/ffmpeg/CMakeLists.txt index be8325b47..dcc978827 100755 --- a/externals/ffmpeg/CMakeLists.txt +++ b/externals/ffmpeg/CMakeLists.txt @@ -214,6 +214,6 @@ else(WIN32) set(FFmpeg_LDFLAGS "${FFmpeg_LDFLAGS}" PARENT_SCOPE) set(FFmpeg_LIBRARIES "${FFmpeg_LIBRARIES}" PARENT_SCOPE) set(FFmpeg_INCLUDE_DIR "${FFmpeg_INCLUDE_DIR}" PARENT_SCOPE) -endif(WIN32) +endif() unset(FFmpeg_COMPONENTS) diff --git a/src/core/hle/service/ldr/ldr.cpp b/src/core/hle/service/ldr/ldr.cpp index c65f37ee6..4f7b93236 100755 --- a/src/core/hle/service/ldr/ldr.cpp +++ b/src/core/hle/service/ldr/ldr.cpp @@ -310,7 +310,7 @@ public: ResultCode GetAvailableMapRegion(Kernel::KPageTable& page_table, u64 size, VAddr& out_addr) { size = Common::AlignUp(size, Kernel::PageSize); - size += page_table.GetNumGuardPages() * Kernel::PageSize * 2; + size += page_table.GetNumGuardPages() * Kernel::PageSize * 4; auto is_region_available = [&](VAddr addr) { const auto end_addr = addr + size; @@ -318,6 +318,19 @@ public: if (system.Memory().IsValidVirtualAddress(addr)) { return false; } + + if (!page_table.IsInsideAddressSpace(out_addr, size)) { + return false; + } + + if (page_table.IsInsideHeapRegion(out_addr, size)) { + return false; + } + + if (page_table.IsInsideAliasRegion(out_addr, size)) { + return false; + } + addr += Kernel::PageSize; } return true; diff --git a/src/video_core/renderer_opengl/gl_fence_manager.cpp b/src/video_core/renderer_opengl/gl_fence_manager.cpp index 151290101..293ad7d59 100755 --- a/src/video_core/renderer_opengl/gl_fence_manager.cpp +++ b/src/video_core/renderer_opengl/gl_fence_manager.cpp @@ -31,9 +31,8 @@ bool GLInnerFence::IsSignaled() const { return true; } ASSERT(sync_object.handle != 0); - GLsizei length; GLint sync_status; - glGetSynciv(sync_object.handle, GL_SYNC_STATUS, sizeof(GLint), &length, &sync_status); + glGetSynciv(sync_object.handle, GL_SYNC_STATUS, 1, nullptr, &sync_status); return sync_status == GL_SIGNALED; }