Merge pull request #11375 from JosJuice/mmu-inf-write

PowerPC: Fix theoretically possible infinite loop in WriteToHardware
This commit is contained in:
Mai 2022-12-31 18:55:11 +00:00 committed by GitHub
commit 20ac2cf781
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -8,6 +8,7 @@
#include <cstring> #include <cstring>
#include <string> #include <string>
#include "Common/Align.h"
#include "Common/Assert.h" #include "Common/Assert.h"
#include "Common/BitUtils.h" #include "Common/BitUtils.h"
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
@ -379,7 +380,9 @@ static void WriteToHardware(Memory::MemoryManager& memory, u32 em_address, const
const u32 rotated_data = std::rotr(data, ((em_address & 0x3) + size) * 8); const u32 rotated_data = std::rotr(data, ((em_address & 0x3) + size) * 8);
for (u32 addr = em_address & ~0x7; addr < em_address + size; addr += 8) const u32 start_addr = Common::AlignDown(em_address, 8);
const u32 end_addr = Common::AlignUp(em_address + size, 8);
for (u32 addr = start_addr; addr != end_addr; addr += 8)
{ {
WriteToHardware<flag, true>(memory, addr, rotated_data, 4); WriteToHardware<flag, true>(memory, addr, rotated_data, 4);
WriteToHardware<flag, true>(memory, addr + 4, rotated_data, 4); WriteToHardware<flag, true>(memory, addr + 4, rotated_data, 4);