From fc57ae640130c2d7610f4ff20a3d8816b88042bf Mon Sep 17 00:00:00 2001 From: Nilay Vaish Date: Tue, 22 Jan 2013 00:10:10 -0600 Subject: [PATCH] x86, cpu: corrects 270c9a75e91f, take over decoder on cpu switch The changes made by the changeset 270c9a75e91f do not work well with switching of cpus. The problem is that decoder for the old thread context holds state that is not taken over by the new decoder. This patch adds a takeOverFrom() function to Decoder class in each ISA. Except for x86, functions in other ISAs are blank. For x86, the function copies state from the old decoder to the new decoder. --- src/arch/alpha/decoder.hh | 2 ++ src/arch/arm/decoder.hh | 2 ++ src/arch/mips/decoder.hh | 2 ++ src/arch/power/decoder.hh | 3 +++ src/arch/sparc/decoder.hh | 2 ++ src/arch/x86/decoder.hh | 13 +++++++++++++ src/cpu/o3/thread_context_impl.hh | 3 +++ src/cpu/simple_thread.cc | 1 + 8 files changed, 28 insertions(+) diff --git a/src/arch/alpha/decoder.hh b/src/arch/alpha/decoder.hh index 45e737e529..d337228677 100644 --- a/src/arch/alpha/decoder.hh +++ b/src/arch/alpha/decoder.hh @@ -83,6 +83,8 @@ class Decoder return instDone; } + void takeOverFrom(Decoder * old) {} + protected: /// A cache of decoded instruction objects. static GenericISA::BasicDecodeCache defaultCache; diff --git a/src/arch/arm/decoder.hh b/src/arch/arm/decoder.hh index 83a16da4c3..72776bcfd7 100644 --- a/src/arch/arm/decoder.hh +++ b/src/arch/arm/decoder.hh @@ -116,6 +116,8 @@ class Decoder fpscrStride = fpscr.stride; } + void takeOverFrom(Decoder *old) {} + protected: /// A cache of decoded instruction objects. static GenericISA::BasicDecodeCache defaultCache; diff --git a/src/arch/mips/decoder.hh b/src/arch/mips/decoder.hh index 080614dee9..a3a68ad074 100644 --- a/src/arch/mips/decoder.hh +++ b/src/arch/mips/decoder.hh @@ -83,6 +83,8 @@ class Decoder return instDone; } + void takeOverFrom(Decoder *old) {} + protected: /// A cache of decoded instruction objects. static GenericISA::BasicDecodeCache defaultCache; diff --git a/src/arch/power/decoder.hh b/src/arch/power/decoder.hh index 830636aed1..a70802cedc 100644 --- a/src/arch/power/decoder.hh +++ b/src/arch/power/decoder.hh @@ -89,6 +89,9 @@ class Decoder { return instDone; } + + void takeOverFrom(Decoder *old) {} + protected: /// A cache of decoded instruction objects. static GenericISA::BasicDecodeCache defaultCache; diff --git a/src/arch/sparc/decoder.hh b/src/arch/sparc/decoder.hh index e7a806d81b..b87ee682e4 100644 --- a/src/arch/sparc/decoder.hh +++ b/src/arch/sparc/decoder.hh @@ -97,6 +97,8 @@ class Decoder asi = _asi; } + void takeOverFrom(Decoder *old) {} + protected: /// A cache of decoded instruction objects. static GenericISA::BasicDecodeCache defaultCache; diff --git a/src/arch/x86/decoder.hh b/src/arch/x86/decoder.hh index 6f55ab26f8..ca7ef96fe0 100644 --- a/src/arch/x86/decoder.hh +++ b/src/arch/x86/decoder.hh @@ -250,6 +250,19 @@ class Decoder } } + void takeOverFrom(Decoder *old) + { + mode = old->mode; + submode = old->submode; + emi.mode.mode = mode; + emi.mode.submode = submode; + altOp = old->altOp; + defOp = old->defOp; + altAddr = old->altAddr; + defAddr = old->defAddr; + stack = old->stack; + } + void reset() { state = ResetState; diff --git a/src/cpu/o3/thread_context_impl.hh b/src/cpu/o3/thread_context_impl.hh index 6de5c57317..f818cc3dc7 100755 --- a/src/cpu/o3/thread_context_impl.hh +++ b/src/cpu/o3/thread_context_impl.hh @@ -67,6 +67,9 @@ void O3ThreadContext::takeOverFrom(ThreadContext *old_context) { ::takeOverFrom(*this, *old_context); + TheISA::Decoder *newDecoder = getDecoderPtr(); + TheISA::Decoder *oldDecoder = old_context->getDecoderPtr(); + newDecoder->takeOverFrom(oldDecoder); thread->kernelStats = old_context->getKernelStats(); thread->funcExeInst = old_context->readFuncExeInst(); diff --git a/src/cpu/simple_thread.cc b/src/cpu/simple_thread.cc index 77569aa68d..de01124e03 100644 --- a/src/cpu/simple_thread.cc +++ b/src/cpu/simple_thread.cc @@ -108,6 +108,7 @@ void SimpleThread::takeOverFrom(ThreadContext *oldContext) { ::takeOverFrom(*tc, *oldContext); + decoder.takeOverFrom(oldContext->getDecoderPtr()); kernelStats = oldContext->getKernelStats(); funcExeInst = oldContext->readFuncExeInst();