System Call Interrupts do *not* set SRR1[TRAP]
authorJacob Lifshay <programmerjake@gmail.com>
Tue, 7 Nov 2023 04:38:18 +0000 (20:38 -0800)
committerJacob Lifshay <programmerjake@gmail.com>
Tue, 14 Nov 2023 23:06:49 +0000 (15:06 -0800)
See PowerISA v3.1B Book III 7.5.14

openpower/isa/system.mdwn
src/openpower/decoder/isa/test_syscall.py
src/openpower/test/trap/trap_cases.py

index 958502d3b606e98648f03882fb925930676797bf..0c41078e35aaf7379e7f95a40196985bb83b3bf0 100644 (file)
@@ -18,7 +18,7 @@ Pseudo-code:
     SRR1[0:32]  <- MSR[0:32]
     SRR1[37:41] <- MSR[37:41]
     SRR1[48:63] <- MSR[48:63]
-    TRAP(0xC00)
+    TRAP(0xC00, None)
 
 Special Registers Altered:
 
index a1f42ba24b8af1f66023dcb95a8e05619ce2907d..2bbd27da74222248b45b23946c1b27756e12e9ee 100644 (file)
@@ -42,7 +42,8 @@ class SyscallTestCase(FHDLTestCase):
         SRR1[0:33] = MSR[0:33]
         SRR1[37:42] = MSR[37:42]
         SRR1[48:64] = MSR[48:64]
-        SRR1[PIb.TRAP] = 1
+        # PowerISA v3.1B Book III 7.5.14 specifies TRAP is set to zero
+        SRR1[PIb.TRAP] = 0
 
         # rfid instruction
         MSR[51] = MSR[3] & SRR1[51] | ~MSR[3] & MSR[51]
index b90bf6939fff94c027f99cc219517d89eec4748a..13d9b09437e2fbd6944831776e11c934c0266423 100644 (file)
@@ -2,7 +2,7 @@ from openpower.simulator.program import Program
 from openpower.endian import bigendian
 from openpower.consts import MSR
 from openpower.test.state import ExpectedState
-
+from openpower.decoder.selectable_int import SelectableInt
 from openpower.test.common import TestAccumulatorBase
 import random
 
@@ -62,7 +62,7 @@ class TrapTestCase(TestAccumulatorBase):
         e = ExpectedState(pc=0xc00)
         e.intregs[1] = 1
         e.sprs['SRR0'] = 4                  # PC to return to: CIA+4
-        e.sprs['SRR1'] = 0x9000000000022903  # MSR to restore after sc return
+        e.sprs['SRR1'] = 0x9000000000002903  # MSR to restore after sc return
         e.msr = 0x9000000000000001          # MSR changed to this by sc/trap
         self.add_case(Program(lst, bigendian),
                       initial_regs, initial_sprs,
@@ -86,9 +86,12 @@ class TrapTestCase(TestAccumulatorBase):
         e.intregs[1] = 1 # should be unaltered
         e.intregs[0] = 2 # due to instruction at 0xc0c
         e.sprs['SRR0'] = 0xc0c              # PC to return to: CIA+4 (0xc0c)
-        e.sprs['SRR1'] = 0xffff_ffff_ffff_ffff # MSR after rfid return
-        e.msr = 0xffffffffffffffff          # MSR is restored (by rfid)
-        e.pc = 0xc10                        # should stop after addi 0,0,2
+        SRR1 = SelectableInt(-1, 64)
+        SRR1[33:37] = 0 # sc clears bits 33:36
+        SRR1[42:48] = 0 # sc clears bits 42:47
+        e.sprs['SRR1'] = int(SRR1)         # MSR after rfid return
+        e.msr = 0xffff_ffff_ffff_ffff      # MSR is restored (by rfid)
+        e.pc = 0xc10                       # should stop after addi 0,0,2
         self.add_case(Program(lst, bigendian),
                       initial_regs, initial_sprs,
                       initial_msr=0xffff_ffff_ffff_ffff,