pass the mode (LOAD,EXECUTE,STORE) through ISACaller RADIX MMU
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 19 Dec 2021 21:27:09 +0000 (21:27 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 19 Dec 2021 23:20:32 +0000 (23:20 +0000)
so that the right exception type can be raised (0x300 rather than 0x400)

src/openpower/decoder/isa/caller.py
src/openpower/decoder/isa/radixmmu.py

index f2a5aded8621e6805c69dfa7dbabb5616d51140d..d3fb0ad4f9d33a256aedd178f81ecbe89014e2c5 100644 (file)
@@ -1026,7 +1026,7 @@ class ISACaller(ISACallerHelper, ISAFPHelpers):
                 return
             elif e.args[0] == 'invalid':         # invalid
                # run a Trap but set DAR first
-                log ("RADIX MMU memory invalid error")
+                log ("RADIX MMU memory invalid error, mode %s" % e.mode)
                 self.call_trap(0x300, PIb.PRIV)    # 0x300, privileged
                 return
             # not supported yet:
index 9fe724d972b93aa8ddb58009da8aa735d39a4751..afd84ea571337d6486ef19eb5865f30ba910ad91 100644 (file)
@@ -293,13 +293,14 @@ class RADIX:
 
     def ld(self, address, width=8, swap=True, check_in_mem=False,
                  instr_fetch=False):
-        print("RADIX: ld from addr 0x%x width %d" % (address, width))
-
-        priv = ~(self.msr[MSRb.PR].value) # problem-state ==> privileged
         if instr_fetch:
             mode = 'EXECUTE'
         else:
             mode = 'LOAD'
+        print("RADIX: ld from addr 0x%x width %d mode %s" % \
+               (address, width, mode))
+
+        priv = ~(self.msr[MSRb.PR].value) # problem-state ==> privileged
         addr = SelectableInt(address, 64)
         pte = self._walk_tree(addr, mode, priv)
 
@@ -444,7 +445,9 @@ class RADIX:
 
         # WIP
         if mbits == 0:
-            raise MemException("invalid")
+            exc = MemException("invalid")
+            exc.mode = mode
+            raise exc
 
         # mask_size := mbits(4 downto 0);
         mask_size = mbits[0:5]
@@ -487,7 +490,9 @@ class RADIX:
 
             print("    valid, leaf", valid, leaf)
             if not valid:
-                raise MemException("invalid")
+                exc = MemException("invalid")
+                exc.mode = mode
+                raise exc
             if leaf:
                 print ("is leaf, checking perms")
                 ok = self._check_perms(data, priv, mode)