From c12725c916caac69d33e1d5c040930eed9e9cb70 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Thu, 30 Nov 2023 22:17:26 +0100 Subject: [PATCH] MMU: Assert that the given XCheckTLBFlag is valid for the operation. --- Source/Core/Core/PowerPC/MMU.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/Core/Core/PowerPC/MMU.cpp b/Source/Core/Core/PowerPC/MMU.cpp index 6c85fc54ee..a069d14073 100644 --- a/Source/Core/Core/PowerPC/MMU.cpp +++ b/Source/Core/Core/PowerPC/MMU.cpp @@ -148,6 +148,12 @@ static void EFB_Write(u32 data, u32 addr) template T MMU::ReadFromHardware(u32 em_address) { + // ReadFromHardware is currently used with XCheckTLBFlag::OpcodeNoException by host instruction + // functions. Actual instruction decoding (which can raise exceptions and uses icache) is handled + // by TryReadInstruction. + static_assert(flag == XCheckTLBFlag::NoException || flag == XCheckTLBFlag::Read || + flag == XCheckTLBFlag::OpcodeNoException); + const u32 em_address_start_page = em_address & ~HW_PAGE_MASK; const u32 em_address_end_page = (em_address + sizeof(T) - 1) & ~HW_PAGE_MASK; if (em_address_start_page != em_address_end_page) @@ -258,6 +264,8 @@ T MMU::ReadFromHardware(u32 em_address) template void MMU::WriteToHardware(u32 em_address, const u32 data, const u32 size) { + static_assert(flag == XCheckTLBFlag::NoException || flag == XCheckTLBFlag::Write); + DEBUG_ASSERT(size <= 4); const u32 em_address_start_page = em_address & ~HW_PAGE_MASK;