power: Use a power specific GuestABI for power system calls.
authorGabe Black <gabeblack@google.com>
Sun, 8 Dec 2019 04:13:50 +0000 (20:13 -0800)
committerGabe Black <gabeblack@google.com>
Thu, 12 Mar 2020 01:35:34 +0000 (01:35 +0000)
Change-Id: I39cf64c025c284b63980f3c2e48fbd8b6c355d2b
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23452
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/power/linux/process.cc
src/arch/power/linux/process.hh
src/arch/power/process.cc
src/arch/power/process.hh

index 9f16e85c791f46b8f1cafe08efc6c8ed2360c942..0653c3123a3c91786ff4fc167e08bbd4d09faa7a 100644 (file)
@@ -91,7 +91,7 @@ unameFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr utsname)
     return 0;
 }
 
-SyscallDescABI<DefaultSyscallABI> PowerLinuxProcess::syscallDescs[] = {
+SyscallDescABI<PowerProcess::SyscallABI> PowerLinuxProcess::syscallDescs[] = {
     /*  0 */ { "syscall" },
     /*  1 */ { "exit", exitFunc },
     /*  2 */ { "fork" },
index 0db151778578106bc76be00250b8183364a79b9e..5ff462fc60cd10e201b17e96e9fe6daee86a5e3e 100644 (file)
@@ -51,7 +51,7 @@ class PowerLinuxProcess : public PowerProcess
     using Process::getSyscallArg;
 
     /// Array of syscall descriptors, indexed by call number.
-    static SyscallDescABI<DefaultSyscallABI> syscallDescs[];
+    static SyscallDescABI<SyscallABI> syscallDescs[];
 
     const int Num_Syscall_Descs;
 };
index 7d8dd34e47516e41ebc552ef4423fdb3d9088b1d..d74563b92e043255a10c82a0c1e5c850d8658ed0 100644 (file)
@@ -288,3 +288,7 @@ PowerProcess::setSyscallReturn(ThreadContext *tc, SyscallReturn sysret)
     tc->setIntReg(INTREG_CR, cr);
     tc->setIntReg(ReturnValueReg, sysret.encodedValue());
 }
+
+const std::vector<int> PowerProcess::SyscallABI::ArgumentRegs = {
+    3, 4, 5, 6, 7, 8
+};
index 0df6333505940b11a4489bb5668fe24f99d787d9..7f6eede192e806432a2f4ad263265d8e0ba64c32 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "mem/page_table.hh"
 #include "sim/process.hh"
+#include "sim/syscall_abi.hh"
 
 class ObjectFile;
 
@@ -52,7 +53,37 @@ class PowerProcess : public Process
     using Process::getSyscallArg;
     void setSyscallReturn(ThreadContext *tc,
             SyscallReturn return_value) override;
+
+    struct SyscallABI : public GenericSyscallABI64
+    {
+        static const std::vector<int> ArgumentRegs;
+    };
+};
+
+namespace GuestABI
+{
+
+template <>
+struct Result<PowerProcess::SyscallABI, SyscallReturn>
+{
+    static void
+    store(ThreadContext *tc, const SyscallReturn &ret)
+    {
+        if (ret.suppressed() || ret.needsRetry())
+            return;
+
+        PowerISA::Cr cr = tc->readIntReg(PowerISA::INTREG_CR);
+        if (ret.successful()) {
+            cr.cr0.so = 0;
+        } else {
+            cr.cr0.so = 1;
+        }
+        tc->setIntReg(PowerISA::INTREG_CR, cr);
+        tc->setIntReg(PowerISA::ReturnValueReg, ret.encodedValue());
+    }
 };
 
+} // namespace GuestABI
+
 #endif // __POWER_PROCESS_HH__