caller.py: implement exit_group syscall
authorJacob Lifshay <programmerjake@gmail.com>
Fri, 1 Dec 2023 07:27:48 +0000 (23:27 -0800)
committerJacob Lifshay <programmerjake@gmail.com>
Fri, 1 Dec 2023 09:29:58 +0000 (01:29 -0800)
src/openpower/decoder/isa/caller.py
src/openpower/test/runner.py

index 409fedfb21740407a885b1397182f3ebc8838a36..53412e99802b256538a424419d118be7816eacf6 100644 (file)
@@ -1141,6 +1141,10 @@ class StepLoop:
         log("    new dststep", dststep)
 
 
+class ExitSyscallCalled(Exception):
+    pass
+
+
 class SyscallEmulator(openpower.syscalls.Dispatcher):
     def __init__(self, isacaller):
         self.__isacaller = isacaller
@@ -1155,6 +1159,10 @@ class SyscallEmulator(openpower.syscalls.Dispatcher):
         (identifier, *arguments) = map(int, (identifier, *arguments))
         return super().__call__(identifier, *arguments)
 
+    def sys_exit_group(self, status, *rest):
+        self.__isacaller.halted = True
+        raise ExitSyscallCalled(status)
+
 
 class ISACaller(ISACallerHelper, ISAFPHelpers, StepLoop):
     # decoder2 - an instance of power_decoder2
index 6c6163b0a0613dd20aeedb5dd00312a3bfb84508..a2aac7f0819619943cbdad680a547d7c3e5c1fc9 100644 (file)
@@ -27,6 +27,7 @@ from nmutil.sim_tmp_alternative import Simulator, Settle
 from nmutil.formaltest import FHDLTestCase
 from nmutil.gtkw import write_gtkw
 from openpower.decoder.isa.all import ISA
+from openpower.decoder.isa.caller import ExitSyscallCalled
 from openpower.endian import bigendian
 
 from openpower.decoder.power_decoder2 import PowerDecode2
@@ -106,7 +107,10 @@ class SimRunner(StateRunner):
 
             # call simulated operation
             log("sim", code)
-            yield from sim.execute_one()
+            try:
+                yield from sim.execute_one()
+            except ExitSyscallCalled:
+                break
             yield Settle()
             index = sim.pc.CIA.value//4
 
@@ -273,7 +277,10 @@ class TestRunnerBase(FHDLTestCase):
                     log("sprs", test.sprs, kind=LogType.InstrInOuts)
                     log("cr", test.cr, kind=LogType.InstrInOuts)
                     log("mem", test.mem)
-                    log("msr", test.msr, kind=LogType.InstrInOuts)
+                    if test.msr is None:
+                        log("msr", "None", kind=LogType.InstrInOuts)
+                    else:
+                        log("msr", hex(test.msr), kind=LogType.InstrInOuts)
 
                     def format_assembly(assembly):
                         # type: (str) -> str