summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2018-05-20 23:08:59 +0200
committerGitHub <noreply@github.com>2018-05-20 23:08:59 +0200
commit79edd57b96efa7a246671646bcf2d9c41e057d7c (patch)
tree7c7f9f06a6cdcc859e36903eb8ff40e28c368292 /Source/Core
parent73fde6d84d3192f9c1dfe93e1ab32f954350f635 (diff)
parent0337ca116abe9b9b9877e6071ad0697188198885 (diff)
Merge pull request #6920 from lioncash/priv
Interpreter_SystemRegisters: Check processor privilege level in mfspr and mtspr
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp
index 2c060f42bb..1bdee2fbf7 100644
--- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp
+++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp
@@ -194,9 +194,13 @@ void Interpreter::mfspr(UGeckoInstruction inst)
{
const u32 index = ((inst.SPR & 0x1F) << 5) + ((inst.SPR >> 5) & 0x1F);
- // TODO - check processor privilege level - many of these require privilege
- // XER LR CTR are the only ones available in user mode, time base can be read too.
- // GameCube games always run in superuser mode, but hey....
+ // XER, LR, CTR, and timebase halves are the only ones available in user mode.
+ if (MSR.PR && index != SPR_XER && index != SPR_LR && index != SPR_CTR && index != SPR_TL &&
+ index != SPR_TU)
+ {
+ PowerPC::ppcState.Exceptions |= EXCEPTION_PROGRAM;
+ return;
+ }
switch (index)
{
@@ -237,13 +241,17 @@ void Interpreter::mfspr(UGeckoInstruction inst)
void Interpreter::mtspr(UGeckoInstruction inst)
{
const u32 index = (inst.SPRU << 5) | (inst.SPRL & 0x1F);
+
+ // XER, LR, and CTR are the only ones available to be written to in user mode
+ if (MSR.PR && index != SPR_XER && index != SPR_LR && index != SPR_CTR)
+ {
+ PowerPC::ppcState.Exceptions |= EXCEPTION_PROGRAM;
+ return;
+ }
+
const u32 old_value = rSPR(index);
rSPR(index) = rGPR[inst.RD];
- // TODO - check processor privilege level - many of these require privilege
- // XER LR CTR are the only ones available in user mode, time base can be read too.
- // GameCube games always run in superuser mode, but hey....
-
// Our DMA emulation is highly inaccurate - instead of properly emulating the queue
// and so on, we simply make all DMA:s complete instantaneously.