Force address masking for prefetch instructions
This commit is contained in:
parent
c56a24e83b
commit
a434b54329
2 changed files with 38 additions and 2 deletions
|
@ -1149,5 +1149,19 @@ namespace Ryujinx.Cpu.LightningJit.Arm64
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsPrefetchMemory(this InstName name)
|
||||||
|
{
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case InstName.PrfmImm:
|
||||||
|
case InstName.PrfmLit:
|
||||||
|
case InstName.PrfmReg:
|
||||||
|
case InstName.Prfum:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,16 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
|
||||||
ulong pc,
|
ulong pc,
|
||||||
uint encoding)
|
uint encoding)
|
||||||
{
|
{
|
||||||
|
if (name.IsPrefetchMemory() && mmType == MemoryManagerType.HostTrackedUnsafe)
|
||||||
|
{
|
||||||
|
// Prefetch to invalid addresses do not cause faults, so for memory manager
|
||||||
|
// types where we need to access the page table before doing the prefetch,
|
||||||
|
// we should make sure we won't try to access an out of bounds page table region.
|
||||||
|
// To do this, we force the masked memory manager variant to be used.
|
||||||
|
|
||||||
|
mmType = MemoryManagerType.HostTracked;
|
||||||
|
}
|
||||||
|
|
||||||
switch (addressForm)
|
switch (addressForm)
|
||||||
{
|
{
|
||||||
case AddressForm.OffsetReg:
|
case AddressForm.OffsetReg:
|
||||||
|
@ -511,14 +521,26 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
|
||||||
WriteAddressTranslation(asBits, mmType, regAlloc, ref asm, destination, guestAddress);
|
WriteAddressTranslation(asBits, mmType, regAlloc, ref asm, destination, guestAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void WriteAddressTranslation(int asBits, MemoryManagerType mmType, RegisterAllocator regAlloc, ref Assembler asm, Operand destination, ulong guestAddress)
|
private static void WriteAddressTranslation(
|
||||||
|
int asBits,
|
||||||
|
MemoryManagerType mmType,
|
||||||
|
RegisterAllocator regAlloc,
|
||||||
|
ref Assembler asm,
|
||||||
|
Operand destination,
|
||||||
|
ulong guestAddress)
|
||||||
{
|
{
|
||||||
asm.Mov(destination, guestAddress);
|
asm.Mov(destination, guestAddress);
|
||||||
|
|
||||||
WriteAddressTranslation(asBits, mmType, regAlloc, ref asm, destination, destination);
|
WriteAddressTranslation(asBits, mmType, regAlloc, ref asm, destination, destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void WriteAddressTranslation(int asBits, MemoryManagerType mmType, RegisterAllocator regAlloc, ref Assembler asm, Operand destination, Operand guestAddress)
|
private static void WriteAddressTranslation(
|
||||||
|
int asBits,
|
||||||
|
MemoryManagerType mmType,
|
||||||
|
RegisterAllocator regAlloc,
|
||||||
|
ref Assembler asm,
|
||||||
|
Operand destination,
|
||||||
|
Operand guestAddress)
|
||||||
{
|
{
|
||||||
Operand basePointer = new(regAlloc.FixedPageTableRegister, RegisterType.Integer, OperandType.I64);
|
Operand basePointer = new(regAlloc.FixedPageTableRegister, RegisterType.Integer, OperandType.I64);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue