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 <noreply+kokoro@google.com> Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu> Maintainer: Gabe Black <gabeblack@google.com>
This commit is contained in:
@@ -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<SyscallReturn(SyscallDesc *, int num, ThreadContext *)>;
|
||||
@@ -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<ABI, SyscallReturn>::store(tc, ret);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // __SIM_SYSCALL_DESC_HH__
|
||||
|
||||
Reference in New Issue
Block a user