From: Gabe Black Date: Wed, 18 Mar 2020 06:00:51 +0000 (-0700) Subject: sparc: Hook up but not implement the get/set context traps. X-Git-Tag: v20.0.0.0~278 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=059fa7079dab8a2cd3cffb6a0837d5145f5c7b1f;p=gem5.git 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 Maintainer: Gabe Black Tested-by: kokoro --- diff --git a/src/arch/sparc/linux/process.cc b/src/arch/sparc/linux/process.cc index 028000410..a9b3a0b7d 100644 --- a/src/arch/sparc/linux/process.cc +++ b/src/arch/sparc/linux/process.cc @@ -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); } diff --git a/src/arch/sparc/linux/process.hh b/src/arch/sparc/linux/process.hh index 963056ceb..45fcbd5d3 100644 --- a/src/arch/sparc/linux/process.hh +++ b/src/arch/sparc/linux/process.hh @@ -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; };