Merge pull request #9978 from JosJuice/jit-ibat-table

Jit: Use ibat_table for dcbf/dcbi/dcbst address check
This commit is contained in:
Léo Lam 2021-07-31 18:59:17 +02:00 committed by GitHub
commit 3b88ffbe60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 8 deletions

View File

@ -20,6 +20,7 @@
#include "Core/PowerPC/Jit64/RegCache/JitRegCache.h"
#include "Core/PowerPC/Jit64Common/Jit64PowerPCState.h"
#include "Core/PowerPC/JitInterface.h"
#include "Core/PowerPC/MMU.h"
#include "Core/PowerPC/PowerPC.h"
using namespace Gen;
@ -246,7 +247,7 @@ void Jit64::dcbx(UGeckoInstruction inst)
if (MSR.IR)
{
MOV(32, R(addr), R(value));
bat_lookup_failed = BATAddressLookup(value, tmp);
bat_lookup_failed = BATAddressLookup(value, tmp, PowerPC::ibat_table.data());
AND(32, R(addr), Imm32(0x0001ffff));
AND(32, R(value), Imm32(0xfffe0000));
OR(32, R(value), R(addr));

View File

@ -91,9 +91,9 @@ void EmuCodeBlock::SwitchToNearCode()
SetCodePtr(m_near_code, m_near_code_end, m_near_code_write_failed);
}
FixupBranch EmuCodeBlock::BATAddressLookup(X64Reg addr, X64Reg tmp)
FixupBranch EmuCodeBlock::BATAddressLookup(X64Reg addr, X64Reg tmp, const void* bat_table)
{
MOV(64, R(tmp), ImmPtr(&PowerPC::dbat_table[0]));
MOV(64, R(tmp), ImmPtr(bat_table));
SHR(32, R(addr), Imm8(PowerPC::BAT_INDEX_SHIFT));
MOV(32, R(addr), MComplex(tmp, addr, SCALE_4, 0));
BT(32, R(addr), Imm8(IntLog2(PowerPC::BAT_MAPPED_BIT)));

View File

@ -51,7 +51,7 @@ public:
// Writes upper 15 bits of physical address to addr and clobbers the lower 17 bits of addr.
// Jumps to the returned FixupBranch if lookup fails.
Gen::FixupBranch BATAddressLookup(Gen::X64Reg addr, Gen::X64Reg tmp);
Gen::FixupBranch BATAddressLookup(Gen::X64Reg addr, Gen::X64Reg tmp, const void* bat_table);
Gen::FixupBranch CheckIfSafeAddress(const Gen::OpArg& reg_value, Gen::X64Reg reg_addr,
BitSet32 registers_in_use);

View File

@ -234,7 +234,7 @@ protected:
// If lookup succeeds, writes upper 15 bits of physical address to addr_out. If not,
// jumps to the returned FixupBranch. Clobbers tmp and the 17 lower bits of addr_out.
Arm64Gen::FixupBranch BATAddressLookup(Arm64Gen::ARM64Reg addr_out, Arm64Gen::ARM64Reg addr_in,
Arm64Gen::ARM64Reg tmp);
Arm64Gen::ARM64Reg tmp, const void* bat_table);
void DoJit(u32 em_address, JitBlock* b, u32 nextPC);

View File

@ -274,11 +274,12 @@ void JitArm64::SafeStoreFromReg(s32 dest, u32 value, s32 regOffset, u32 flags, s
gpr.Unlock(ARM64Reg::W0, ARM64Reg::W1, ARM64Reg::W30);
}
FixupBranch JitArm64::BATAddressLookup(ARM64Reg addr_out, ARM64Reg addr_in, ARM64Reg tmp)
FixupBranch JitArm64::BATAddressLookup(ARM64Reg addr_out, ARM64Reg addr_in, ARM64Reg tmp,
const void* bat_table)
{
tmp = EncodeRegTo64(tmp);
MOVP2R(tmp, PowerPC::dbat_table.data());
MOVP2R(tmp, bat_table);
LSR(addr_out, addr_in, PowerPC::BAT_INDEX_SHIFT);
LDR(addr_out, tmp, ArithOption(addr_out, true));
FixupBranch pass = TBNZ(addr_out, IntLog2(PowerPC::BAT_MAPPED_BIT));
@ -570,7 +571,8 @@ void JitArm64::dcbx(UGeckoInstruction inst)
FixupBranch bat_lookup_failed;
if (MSR.IR)
{
bat_lookup_failed = BATAddressLookup(physical_addr, effective_addr, WA);
bat_lookup_failed =
BATAddressLookup(physical_addr, effective_addr, WA, PowerPC::ibat_table.data());
BFI(physical_addr, effective_addr, 0, PowerPC::BAT_INDEX_SHIFT);
}