cpu,sim-se: move error checks in syscall methods

There is a check on a global flag denoting that the simulator
has been configured to run in fullsystem mode. The check is
conducted at runtime during calls to syscall methods.

The high-level models are checking the flag when the check
could be conducted further down the call chain (nearer to the
actual Process invocation). Moving the checks should result
in less copy-pasta as new models are developed. It might be
argued that the checks should stay in place since an error
would detected earlier; that may be true, but the error
would be the same and the simulation should fail in either
case. This arrangement requires fewer lines of code.

The changeset also changes the check into a fatal error
instead of a panic since usage (in fs mode) should result
in immediate corruption.

Change-Id: If387e27f166ac1374f3fe8b7befe3546e69adba7
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23240
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Tested-by: kokoro <noreply+kokoro@google.com>
diff --git a/src/cpu/minor/exec_context.hh b/src/cpu/minor/exec_context.hh
index 87787f0..66e313e 100644
--- a/src/cpu/minor/exec_context.hh
+++ b/src/cpu/minor/exec_context.hh
@@ -389,9 +389,6 @@
     void
     syscall(int64_t callnum, Fault *fault) override
     {
-        if (FullSystem)
-            panic("Syscall emulation isn't available in FS mode.\n");
-
         thread.syscall(callnum, fault);
     }
 
diff --git a/src/cpu/o3/dyn_inst_impl.hh b/src/cpu/o3/dyn_inst_impl.hh
index fbeb3c2..22d89ec 100644
--- a/src/cpu/o3/dyn_inst_impl.hh
+++ b/src/cpu/o3/dyn_inst_impl.hh
@@ -45,7 +45,6 @@
 
 #include "base/cp_annotate.hh"
 #include "cpu/o3/dyn_inst.hh"
-#include "sim/full_system.hh"
 #include "debug/O3PipeView.hh"
 
 template <class Impl>
@@ -195,9 +194,6 @@
 void
 BaseO3DynInst<Impl>::syscall(int64_t callnum, Fault *fault)
 {
-    if (FullSystem)
-        panic("Syscall emulation isn't available in FS mode.\n");
-
     // HACK: check CPU's nextPC before and after syscall. If it
     // changes, update this instruction's nextPC because the syscall
     // must have changed the nextPC.
diff --git a/src/cpu/o3/thread_state.hh b/src/cpu/o3/thread_state.hh
index a4a1233..a0c3a81 100644
--- a/src/cpu/o3/thread_state.hh
+++ b/src/cpu/o3/thread_state.hh
@@ -150,6 +150,7 @@
     /** Handles the syscall. */
     void syscall(int64_t callnum, Fault *fault)
     {
+        fatal_if(FullSystem, "System call emulation is unavailable!");
         process->syscall(callnum, tc, fault);
     }
 
diff --git a/src/cpu/simple/exec_context.hh b/src/cpu/simple/exec_context.hh
index 91f7ec5..4d26dfe 100644
--- a/src/cpu/simple/exec_context.hh
+++ b/src/cpu/simple/exec_context.hh
@@ -499,9 +499,6 @@
     void
     syscall(int64_t callnum, Fault *fault) override
     {
-        if (FullSystem)
-            panic("Syscall emulation isn't available in FS mode.");
-
         thread->syscall(callnum, fault);
     }
 
diff --git a/src/cpu/simple_thread.hh b/src/cpu/simple_thread.hh
index f25e622..387e745 100644
--- a/src/cpu/simple_thread.hh
+++ b/src/cpu/simple_thread.hh
@@ -66,6 +66,7 @@
 #include "mem/request.hh"
 #include "sim/byteswap.hh"
 #include "sim/eventq.hh"
+#include "sim/full_system.hh"
 #include "sim/process.hh"
 #include "sim/serialize.hh"
 #include "sim/system.hh"
@@ -610,6 +611,7 @@
     void
     syscall(int64_t callnum, Fault *fault) override
     {
+        fatal_if(FullSystem, "System call emulation is unavailable!");
         process->syscall(callnum, this, fault);
     }