arch,sim: Merge Process::syscall and Process::getDesc.
When handling a system call, external code would call Process::syscall which would extract the syscall number, that would call the base class' doSyscall method, that would call into the subclass' getDesc to get the appropriate descriptor, and then doSyscall would check that a syscall was found and call into it. Instead, we can just make the SyscallDescTable optionally check for missing syscalls (in case we want to check multiple tables), and make syscall look up the appropriate descriptor and call it. The base implementation of syscall would then do the only bit of doSyscall that is no longer being handled, incrementing the numSyscalls stat. Change-Id: If102c156830ed2997d177dc6937cc85dddadf3f9 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24119 Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Gem5 Cloud Project GCB service account <345032938727@cloudbuild.gserviceaccount.com> Maintainer: Gabe Black <gabeblack@google.com> Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
This commit is contained in:
@@ -419,18 +419,6 @@ Process::map(Addr vaddr, Addr paddr, int size, bool cacheable)
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Process::doSyscall(int64_t callnum, ThreadContext *tc, Fault *fault)
|
||||
{
|
||||
numSyscalls++;
|
||||
|
||||
SyscallDesc *desc = getDesc(callnum);
|
||||
if (desc == nullptr)
|
||||
fatal("Syscall %d out of range", callnum);
|
||||
|
||||
desc->doSyscall(tc, fault);
|
||||
}
|
||||
|
||||
EmulatedDriver *
|
||||
Process::findDriver(std::string filename)
|
||||
{
|
||||
|
||||
@@ -60,9 +60,6 @@ class ThreadContext;
|
||||
|
||||
class Process : public SimObject
|
||||
{
|
||||
protected:
|
||||
void doSyscall(int64_t callnum, ThreadContext *tc, Fault *fault);
|
||||
|
||||
public:
|
||||
Process(ProcessParams *params, EmulationPageTable *pTable,
|
||||
ObjectFile *obj_file);
|
||||
@@ -74,8 +71,7 @@ class Process : public SimObject
|
||||
void initState() override;
|
||||
DrainState drain() override;
|
||||
|
||||
virtual void syscall(ThreadContext *tc, Fault *fault) = 0;
|
||||
virtual SyscallDesc *getDesc(int callnum) = 0;
|
||||
virtual void syscall(ThreadContext *tc, Fault *fault) { numSyscalls++; }
|
||||
|
||||
inline uint64_t uid() { return _uid; }
|
||||
inline uint64_t euid() { return _euid; }
|
||||
|
||||
@@ -192,11 +192,15 @@ class SyscallDescTable
|
||||
}
|
||||
|
||||
SyscallDesc
|
||||
*get(int num)
|
||||
*get(int num, bool fatal_if_missing=true)
|
||||
{
|
||||
auto it = _descs.find(num);
|
||||
if (it == _descs.end())
|
||||
return nullptr;
|
||||
if (it == _descs.end()) {
|
||||
if (fatal_if_missing)
|
||||
fatal("Syscall %d out of range", num);
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
return &it->second;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user