x86: In X86 linux, system calls simply return their result in a register.
authorGabe Black <gabeblack@google.com>
Sat, 7 Dec 2019 01:41:13 +0000 (17:41 -0800)
committerGabe Black <gabeblack@google.com>
Thu, 12 Mar 2020 01:35:34 +0000 (01:35 +0000)
We can partially define an x86 linux system call ABI which handles the
return value. Argument gathering would be handled elsewhere.

Change-Id: Id2841dea39aa2ea3fc42e1a0fb70ff4e477b3671
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23442
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/x86/linux/linux.hh

index 11979cebc6773d29f9abed98f7c2424dd5bbbd6e..7fb362784f40e8b034e5c0274c38a698b904e9ba 100644 (file)
@@ -40,6 +40,8 @@
 
 #include "arch/x86/utility.hh"
 #include "kern/linux/linux.hh"
+#include "sim/guest_abi.hh"
+#include "sim/syscall_return.hh"
 
 class X86Linux : public Linux
 {
@@ -62,6 +64,27 @@ class X86Linux : public Linux
         if (stack)
             ctc->setIntReg(X86ISA::StackPointerReg, stack);
     }
+
+    class SyscallABI
+    {
+    };
+};
+
+namespace GuestABI
+{
+
+template <typename ABI>
+struct Result<ABI, SyscallReturn,
+    typename std::enable_if<std::is_base_of<
+        X86Linux::SyscallABI, ABI>::value>::type>
+{
+    static void
+    store(ThreadContext *tc, const SyscallReturn &ret)
+    {
+        tc->setIntReg(ABI::ReturnValueReg, ret.encodedValue());
+    }
+};
+
 };
 
 class X86Linux64 : public X86Linux