Apparently ERET will throw a COP unusable exception when non-kernel mode.

This commit is contained in:
irisz64
2025-09-01 12:06:01 +02:00
parent bd4a692899
commit a636f4dc60

View File

@@ -25,6 +25,10 @@ void Cop0::dmfc0(const Instruction instr) const {
void Cop0::eret() { void Cop0::eret() {
Registers& regs = Core::GetRegs(); Registers& regs = Core::GetRegs();
if (!regs.cop0.kernelMode) {
FireException(ExceptionCode::CoprocessorUnusable, 0, regs.oldPC);
return;
}
if (status.erl) { if (status.erl) {
regs.SetPC64(ErrorEPC); regs.SetPC64(ErrorEPC);
status.erl = false; status.erl = false;
@@ -76,12 +80,14 @@ void Cop0::tlbw(const int index_) {
void Cop0::tlbp() { void Cop0::tlbp() {
int match = -1; int match = -1;
if (const TLBEntry *entry = TLBTryMatch(entryHi.raw, match); match >= 0) { const TLBEntry *entry = TLBTryMatch(entryHi.raw, match);
if (match >= 0) {
index.raw = match; index.raw = match;
} else { return;
}
index.raw = 0; index.raw = 0;
index.p = 1; index.p = 1;
} }
}
} // namespace n64 } // namespace n64