From 706bc79c356283f3bcaee817b3dab2f0e4a59ef2 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Thu, 30 Nov 2023 23:27:48 -0800 Subject: [PATCH] caller.py: implement exit_group syscall --- src/openpower/decoder/isa/caller.py | 8 ++++++++ src/openpower/test/runner.py | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/openpower/decoder/isa/caller.py b/src/openpower/decoder/isa/caller.py index c0b08b86..ae6ade01 100644 --- a/src/openpower/decoder/isa/caller.py +++ b/src/openpower/decoder/isa/caller.py @@ -1144,6 +1144,10 @@ class StepLoop: log(" new dststep", dststep) +class ExitSyscallCalled(Exception): + pass + + class SyscallEmulator(openpower.syscalls.Dispatcher): def __init__(self, isacaller): self.__isacaller = isacaller @@ -1158,6 +1162,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 diff --git a/src/openpower/test/runner.py b/src/openpower/test/runner.py index ea6edb6f..47010a44 100644 --- a/src/openpower/test/runner.py +++ b/src/openpower/test/runner.py @@ -28,6 +28,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 @@ -107,7 +108,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 @@ -274,7 +278,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 -- 2.30.2