diff options
| author | JMC47 <JMC4789@gmail.com> | 2021-04-06 20:23:13 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-06 20:23:13 -0400 |
| commit | 53222560650e4a99eceafcd537d4e04d1c50b3a6 (patch) | |
| tree | e4c47ed5390688532ebd5ce04bd6581eac167322 /Source | |
| parent | 3b6fdb74f6510cf5ccc6b9f62829c1086dc6a134 (diff) | |
| parent | 49edd5f482036dec2fa0778366e2c4ea118d89a5 (diff) | |
Merge pull request #9625 from leoetlino/mmu-sdr-update
MMU: Fix SDR updates being silently dropped in some cases
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/Core/PowerPC/MMU.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/Source/Core/Core/PowerPC/MMU.cpp b/Source/Core/Core/PowerPC/MMU.cpp index 9714af5bc7..3adf10a294 100644 --- a/Source/Core/Core/PowerPC/MMU.cpp +++ b/Source/Core/Core/PowerPC/MMU.cpp @@ -980,14 +980,16 @@ void SDRUpdated() { u32 htabmask = SDR1_HTABMASK(PowerPC::ppcState.spr[SPR_SDR]); if (!Common::IsValidLowMask(htabmask)) - { - return; - } + WARN_LOG_FMT(POWERPC, "Invalid HTABMASK: 0b{:032b}", htabmask); + + // While 6xx_pem.pdf ยง7.6.1.1 mentions that the number of trailing zeros in HTABORG + // must be equal to the number of trailing ones in the mask (i.e. HTABORG must be + // properly aligned), this is actually not a hard requirement. Real hardware will just OR + // the base address anyway. Ignoring SDR changes would lead to incorrect emulation. u32 htaborg = SDR1_HTABORG(PowerPC::ppcState.spr[SPR_SDR]); if (htaborg & htabmask) - { - return; - } + WARN_LOG_FMT(POWERPC, "Invalid HTABORG: htaborg=0x{:08x} htabmask=0x{:08x}", htaborg, htabmask); + PowerPC::ppcState.pagetable_base = htaborg << 16; PowerPC::ppcState.pagetable_hashmask = ((htabmask << 10) | 0x3ff); } @@ -1111,7 +1113,7 @@ static TranslateAddressResult TranslatePageAddress(const u32 address, const XChe // hash function no 1 "xor" .360 u32 hash = (VSID ^ page_index); - u32 pte1 = Common::swap32((VSID << 7) | api | PTE1_V); + u32 pte1 = (VSID << 7) | api | PTE1_V; for (int hash_func = 0; hash_func < 2; hash_func++) { @@ -1119,7 +1121,7 @@ static TranslateAddressResult TranslatePageAddress(const u32 address, const XChe if (hash_func == 1) { hash = ~hash; - pte1 |= PTE1_H << 24; + pte1 |= PTE1_H; } u32 pteg_addr = @@ -1127,7 +1129,7 @@ static TranslateAddressResult TranslatePageAddress(const u32 address, const XChe for (int i = 0; i < 8; i++, pteg_addr += 8) { - u32 pteg = Common::swap32(Memory::Read_U32(pteg_addr)); + const u32 pteg = Memory::Read_U32(pteg_addr); if (pte1 == pteg) { |
