isa/caller: refactor sc logic
authorDmitry Selyutin <ghostmansd@gmail.com>
Fri, 20 Oct 2023 17:15:12 +0000 (20:15 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sun, 22 Oct 2023 06:08:13 +0000 (09:08 +0300)
src/openpower/decoder/isa/caller.py

index 0c9b0e601a876facee89f912658efc1f63de3532..84456c2680a504a5f71b5ed1c1d6ba8d01a03ab6 100644 (file)
@@ -1957,18 +1957,6 @@ class ISACaller(ISACallerHelper, ISAFPHelpers, StepLoop):
         log("call", ins_name, asmop,
             kind=LogKind.InstrInOuts)
 
-        if asmop in ("sc", "scv"):
-            if self.syscall is not None:
-                identifier = self.gpr(0)
-                arguments = map(self.gpr, range(3, 9))
-                result = self.syscall(identifier, *arguments)
-                self.gpr.write(3, result, False, self.namespace["XLEN"])
-                self.update_pc_next()
-                return
-            else:
-                self.call_trap(0x700, PIb.ILLEG)
-                return
-
         # sv.setvl is *not* a loop-function. sigh
         log("is_svp64_mode", self.is_svp64_mode, asmop)
 
@@ -2065,6 +2053,13 @@ class ISACaller(ISACallerHelper, ISAFPHelpers, StepLoop):
             self.update_pc_next()
             return
 
+        # Usermode system call emulation
+        if asmop in ("sc", "scv") and self.syscall is not None:
+            identifier = self.gpr(0)
+            arguments = map(self.gpr, range(3, 9))
+            result = self.syscall(identifier, *arguments)
+            self.gpr.write(3, result, False, self.namespace["XLEN"])
+
         # get elwidths, defaults to 64
         xlen = 64
         ew_src = 64