diff options
author | Gabe Black <gabeblack@google.com> | 2019-11-25 01:07:41 -0800 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2019-12-10 23:58:14 +0000 |
commit | cb3457ccd17a89a4df3e70d35e0254c77a0b5782 (patch) | |
tree | 6693c6acb869246269906c5227f1331a78a6262d /src/arch/mips | |
parent | d142a1547cfc7e06964e2cb34905f3e4304c93fd (diff) | |
download | gem5-cb3457ccd17a89a4df3e70d35e0254c77a0b5782.tar.xz |
arch,cpu,sim: Push syscall number determination up to processes.
The logic that determines which syscall to call was built into the
implementation of faults/exceptions or even into the instruction
decoder, but that logic can depend on what OS is being used, and
sometimes even what version, for example 32bit vs. 64bit.
This change pushes that logic up into the Process objects since those
already handle a lot of the aspects of emulating the guest OS. Instead,
the ISA or fault implementations just notify the rest of the system
that a nebulous syscall has happened, and that gets propogated upward
until the process does something with it. That's very analogous to how
a system call would work on a real machine.
When a system call happens, the low level component which detects that
should call tc->syscall(&fault), where tc is the relevant thread (or
execution) context, and fault is a Fault which can ultimately be set
by the system call implementation.
The TC implementor (probably a CPU) will then have a chance to do
whatever it needs to to handle a system call. Currently only O3 does
anything special here. That implementor will end up calling the
Process's syscall() method.
Once in Process::syscall, the process object will use it's contextual
knowledge to determine what system call is being requested. It then
calls Process::doSyscall with the right syscall number, where doSyscall
centralizes the common mechanism for actually retrieving and calling
into the system call implementation.
Jira Issue: https://gem5.atlassian.net/browse/GEM5-187
Change-Id: I937ec1ef0576142c2a182ff33ca508d77ad0e7a1
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23176
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Brandon Potter <Brandon.Potter@amd.com>
Diffstat (limited to 'src/arch/mips')
-rw-r--r-- | src/arch/mips/isa/decoder.isa | 2 | ||||
-rw-r--r-- | src/arch/mips/isa/operands.isa | 3 | ||||
-rw-r--r-- | src/arch/mips/linux/process.cc | 9 | ||||
-rw-r--r-- | src/arch/mips/linux/process.hh | 2 |
4 files changed, 9 insertions, 7 deletions
diff --git a/src/arch/mips/isa/decoder.isa b/src/arch/mips/isa/decoder.isa index 3406ed5d2..856a34083 100644 --- a/src/arch/mips/isa/decoder.isa +++ b/src/arch/mips/isa/decoder.isa @@ -163,7 +163,7 @@ decode OPCODE_HI default Unknown::unknown() { 0x2: movz({{ Rd = (Rt == 0) ? Rs : Rd; }}); 0x3: movn({{ Rd = (Rt != 0) ? Rs : Rd; }}); 0x4: decode FullSystemInt { - 0: syscall_se({{ xc->syscall(R2, &fault); }}, + 0: syscall_se({{ xc->syscall(&fault); }}, IsSerializeAfter, IsNonSpeculative); default: syscall({{ fault = std::make_shared<SystemCallFault>(); }}); } diff --git a/src/arch/mips/isa/operands.isa b/src/arch/mips/isa/operands.isa index 2d44bb30e..f81df73fd 100644 --- a/src/arch/mips/isa/operands.isa +++ b/src/arch/mips/isa/operands.isa @@ -51,9 +51,8 @@ def operands {{ #Immediate Value operand 'IntImm': ('IntReg', 'uw', 'INTIMM', 'IsInteger', 3), - #Operands used for Link or Syscall Insts + #Operands used for Link Insts 'R31': ('IntReg', 'uw','31','IsInteger', 4), - 'R2': ('IntReg', 'uw','2', 'IsInteger', 5), #Special Integer Reg operands 'LO0': ('IntReg', 'uw','INTREG_LO', 'IsInteger', 6), diff --git a/src/arch/mips/linux/process.cc b/src/arch/mips/linux/process.cc index adfbfd3f6..2dc1bcdaf 100644 --- a/src/arch/mips/linux/process.cc +++ b/src/arch/mips/linux/process.cc @@ -509,7 +509,8 @@ MipsLinuxProcess::getDesc(int callnum) return &syscallDescs[m5_sys_idx]; } - - - - +void +MipsLinuxProcess::syscall(ThreadContext *tc, Fault *fault) +{ + doSyscall(tc->readIntReg(2), tc, fault); +} diff --git a/src/arch/mips/linux/process.hh b/src/arch/mips/linux/process.hh index cbf0d78ea..7fcb6f014 100644 --- a/src/arch/mips/linux/process.hh +++ b/src/arch/mips/linux/process.hh @@ -51,6 +51,8 @@ class MipsLinuxProcess : public MipsProcess /// ID of the thread group leader for the process uint64_t __tgid; + void syscall(ThreadContext *tc, Fault *fault) override; + /// Array of syscall descriptors, indexed by call number. static SyscallDesc syscallDescs[]; const int Num_Syscall_Descs; |