sparc: Hook up but not implement the get/set context traps.

gem5 will panic if it encounters a trap it doesn't know what to do with.
Newer versions of glibc, gcc, etc., use the getcontext trap in setjmp
during startup.

This change hooks up a function for both the getcontext and setcontext
traps. The getcontext one just warns that it isn't implemented. If the
context it creates is never used (likely) then that should be fine for
now. If we ever try to actually use a context with setcontext, then
something bad will almost certainly happen if it's not implemented, and
we panic.

Change-Id: Id6797ac6955249d299e975c9c30360920d380e60
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26825
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2020-03-17 23:00:51 -07:00
parent ed5c610611
commit 059fa7079d
2 changed files with 21 additions and 0 deletions

View File

@@ -111,6 +111,18 @@ Sparc64LinuxProcess::syscall(ThreadContext *tc, Fault *fault)
syscallDescs.get(tc->readIntReg(1))->doSyscall(tc, fault);
}
void
Sparc64LinuxProcess::getContext(ThreadContext *tc)
{
warn("The getcontext trap is not implemented on SPARC");
}
void
Sparc64LinuxProcess::setContext(ThreadContext *tc)
{
panic("The setcontext trap is not implemented on SPARC");
}
void
Sparc64LinuxProcess::handleTrap(int trapNum, ThreadContext *tc, Fault *fault)
{
@@ -119,6 +131,12 @@ Sparc64LinuxProcess::handleTrap(int trapNum, ThreadContext *tc, Fault *fault)
case 0x6d: // Linux 64 bit syscall trap
tc->syscall(fault);
break;
case 0x6e: // Linux 64 bit getcontext trap
getContext(tc);
break;
case 0x6f: // Linux 64 bit setcontext trap
setContext(tc);
break;
default:
SparcProcess::handleTrap(trapNum, tc, fault);
}

View File

@@ -70,6 +70,9 @@ class Sparc64LinuxProcess : public SparcLinuxProcess, public Sparc64Process
void syscall(ThreadContext *tc, Fault *fault) override;
void getContext(ThreadContext *tc);
void setContext(ThreadContext *tc);
void handleTrap(int trapNum, ThreadContext *tc, Fault *fault) override;
};