From 57e792b858f4f78bf3fd49989ec9e58aa8085fd7 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 9 Dec 2019 16:55:36 -0800 Subject: [PATCH] sim: Add a returnInto function to the SyscallDesc class. This method lets system call implementations return values into ThreadContexts other than the one they were called from. That's useful for, for instance, clone() which creates new ThreadContexts. By making it a virtual function in the SyscallDesc, we can delegate the actual implementation to the SyscallDescABI subclass which knows the ABI and how to use it to set the return value. Change-Id: I61c6e60e4c2a8863c885cd818e4ff053fc3312ee Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23503 Tested-by: kokoro Reviewed-by: Bobby R. Bruce Maintainer: Gabe Black --- src/sim/syscall_desc.hh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/sim/syscall_desc.hh b/src/sim/syscall_desc.hh index 4f1aa1877..b8d993b33 100644 --- a/src/sim/syscall_desc.hh +++ b/src/sim/syscall_desc.hh @@ -76,6 +76,12 @@ class SyscallDesc { std::string name() { return _name; } + /** + * For use within the system call executor if new threads are created and + * need something returned into them. + */ + virtual void returnInto(ThreadContext *tc, const SyscallReturn &ret) = 0; + protected: using Executor = std::function; @@ -162,6 +168,12 @@ class SyscallDescABI : public SyscallDesc SyscallDescABI(const char *name) : SyscallDescABI(name, ABIExecutor<>(unimplementedFunc)) {} + + void + returnInto(ThreadContext *tc, const SyscallReturn &ret) override + { + GuestABI::Result::store(tc, ret); + } }; #endif // __SIM_SYSCALL_DESC_HH__ -- 2.30.2