Replace it with a new virtual function.
Change-Id: I9d516d21ab3b1d1d70ea1297f984f868d3e7c3fb
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24111
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
"oops_exit", "Kernel oops in guest");
}
- uDelaySkipEvent = addKernelFuncEvent<UDelayEvent>(
+ uDelaySkipEvent = addKernelFuncEvent<UDelayEvent<ArmISA::SkipFunc>>(
"DELAY", "DELAY", 1000, 0);
}
* processor for the appropriate amount of time. This is not functionally
* required but does speed up simulation.
*/
- FreeBSD::UDelayEvent *uDelaySkipEvent = nullptr;
+ FreeBSD::UDelayEvent<SkipFunc> *uDelaySkipEvent = nullptr;
/** These variables store addresses of important data structures
* that are normaly kept coherent at boot with cache mainetence operations.
namespace ArmISA
{
+void
+SkipFunc::returnFromFuncIn(ThreadContext *tc)
+{
+ PCState newPC = tc->pcState();
+ if (inAArch64(tc)) {
+ newPC.set(tc->readIntReg(INTREG_X30));
+ } else {
+ newPC.set(tc->readIntReg(ReturnAddressReg) & ~ULL(1));
+ }
+
+ CheckerCPU *checker = tc->getCheckerCpuPtr();
+ if (checker) {
+ tc->pcStateNoRecord(newPC);
+ } else {
+ tc->pcState(newPC);
+ }
+}
+
FsWorkload::FsWorkload(Params *p) : OsKernel(*p)
{
bootLoaders.reserve(p->boot_loader.size());
namespace ArmISA
{
+class SkipFunc : public SkipFuncBase
+{
+ public:
+ using SkipFuncBase::SkipFuncBase;
+ void returnFromFuncIn(ThreadContext *tc) override;
+};
+
class FsWorkload : public OsKernel
{
protected:
// With ARM udelay() is #defined to __udelay
// newer kernels use __loop_udelay and __loop_const_udelay symbols
- uDelaySkipEvent = addKernelFuncEvent<UDelayEvent>(
+ uDelaySkipEvent = addKernelFuncEvent<UDelayEvent<SkipFunc>>(
"__loop_udelay", "__udelay", 1000, 0);
if (!uDelaySkipEvent)
- uDelaySkipEvent = addKernelFuncEventOrPanic<UDelayEvent>(
+ uDelaySkipEvent = addKernelFuncEventOrPanic<UDelayEvent<SkipFunc>>(
"__udelay", "__udelay", 1000, 0);
// constant arguments to udelay() have some precomputation done ahead of
// time. Constant comes from code.
- constUDelaySkipEvent = addKernelFuncEvent<UDelayEvent>(
+ constUDelaySkipEvent = addKernelFuncEvent<UDelayEvent<SkipFunc>>(
"__loop_const_udelay", "__const_udelay", 1000, 107374);
if (!constUDelaySkipEvent)
- constUDelaySkipEvent = addKernelFuncEventOrPanic<UDelayEvent>(
+ constUDelaySkipEvent =
+ addKernelFuncEventOrPanic<UDelayEvent<SkipFunc>>(
"__const_udelay", "__const_udelay", 1000, 107374);
- debugPrintkEvent = addKernelFuncEvent<DebugPrintkEvent>("dprintk");
+ debugPrintkEvent =
+ addKernelFuncEvent<DebugPrintkEvent<SkipFunc>>("dprintk");
}
void
* PC based event to skip the dprink() call and emulate its
* functionality
*/
- Linux::DebugPrintkEvent *debugPrintkEvent = nullptr;
+ Linux::DebugPrintkEvent<SkipFunc> *debugPrintkEvent = nullptr;
DumpStatsPCEvent *dumpStatsPCEvent = nullptr;
* processor for the appropriate amount of time. This is not functionally
* required but does speed up simulation.
*/
- Linux::UDelayEvent *uDelaySkipEvent;
+ Linux::UDelayEvent<SkipFunc> *uDelaySkipEvent = nullptr;
/** Another PC based skip event for const_udelay(). Similar to the udelay
* skip, but this function precomputes the first multiply that is done
* in the generic case since the parameter is known at compile time.
* Thus we need to do some division to get back to us.
*/
- Linux::UDelayEvent *constUDelaySkipEvent;
+ Linux::UDelayEvent<SkipFunc> *constUDelaySkipEvent = nullptr;
};
panic("getArgument() should always return\n");
}
-void
-skipFunction(ThreadContext *tc)
-{
- PCState newPC = tc->pcState();
- if (inAArch64(tc)) {
- newPC.set(tc->readIntReg(INTREG_X30));
- } else {
- newPC.set(tc->readIntReg(ReturnAddressReg) & ~ULL(1));
- }
-
- CheckerCPU *checker = tc->getCheckerCpuPtr();
- if (checker) {
- tc->pcStateNoRecord(newPC);
- } else {
- tc->pcState(newPC);
- }
-}
-
static void
copyVecRegs(ThreadContext *src, ThreadContext *dest)
{
uint64_t getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp);
-void skipFunction(ThreadContext *tc);
-
inline void
advancePC(PCState &pc, const StaticInstPtr &inst)
{
void
LinuxMipsSystem::SkipDelayLoopEvent::process(ThreadContext *tc)
{
- SkipFuncEvent::process(tc);
+ MipsISA::SkipFunc::process(tc);
// calculate and set loops_per_jiffy
((LinuxMipsSystem *)tc->getSystemPtr())->setDelayLoop(tc);
}
class LinuxMipsSystem : public MipsSystem
{
private:
- class SkipDelayLoopEvent : public SkipFuncEvent
+ using SkipFunc = MipsISA::SkipFunc;
+
+ class SkipDelayLoopEvent : public SkipFunc
{
public:
SkipDelayLoopEvent(PCEventScope *s, const std::string &desc, Addr addr)
- : SkipFuncEvent(s, desc, addr) {}
+ : SkipFunc(s, desc, addr) {}
virtual void process(ThreadContext *tc);
};
#include "arch/mips/system.hh"
-#include "arch/vtophys.hh"
+#include "arch/mips/registers.hh"
+#include "arch/mips/vtophys.hh"
#include "base/loader/object_file.hh"
#include "base/loader/symtab.hh"
#include "base/trace.hh"
#include "params/MipsSystem.hh"
#include "sim/byteswap.hh"
+void
+MipsISA::SkipFunc::returnFromFuncIn(ThreadContext *tc)
+{
+ MipsISA::PCState newPC = tc->pcState();
+ newPC.set(tc->readIntReg(MipsISA::ReturnAddressReg));
+ tc->pcState(newPC);
+}
+
MipsSystem::MipsSystem(Params *p) : System(p)
{
}
#include "sim/sim_object.hh"
#include "sim/system.hh"
+
+namespace MipsISA
+{
+
+class SkipFunc : public SkipFuncBase
+{
+ public:
+ using SkipFuncBase::SkipFuncBase;
+
+ void returnFromFuncIn(ThreadContext *tc) override;
+};
+
+} // namespace MipsaISA
+
class MipsSystem : public System
{
public:
{
panic("Copy Misc. Regs Not Implemented Yet\n");
}
-void
-skipFunction(ThreadContext *tc)
-{
- PCState newPC = tc->pcState();
- newPC.set(tc->readIntReg(ReturnAddressReg));
- tc->pcState(newPC);
-}
-
} // namespace MipsISA
void copyRegs(ThreadContext *src, ThreadContext *dest);
void copyMiscRegs(ThreadContext *src, ThreadContext *dest);
-void skipFunction(ThreadContext *tc);
-
inline void
advancePC(PCState &pc, const StaticInstPtr &inst)
{
return 0;
}
-void
-skipFunction(ThreadContext *tc)
-{
- panic("Not Implemented for POWER");
-}
-
} // namespace PowerISA
{
}
-void skipFunction(ThreadContext *tc);
-
inline void
advancePC(PCState &pc, const StaticInstPtr &inst)
{
}
}
-inline void
-skipFunction(ThreadContext *tc)
-{
- panic("Not Implemented for Riscv");
-}
-
inline void
advancePC(PCState &pc, const StaticInstPtr &inst)
{
dest->pcState(src->pcState());
}
-void
-skipFunction(ThreadContext *tc)
-{
- PCState newPC = tc->pcState();
- newPC.set(tc->readIntReg(ReturnAddressReg));
- tc->pcState(newPC);
-}
-
} // namespace SPARC_ISA
void copyMiscRegs(ThreadContext *src, ThreadContext *dest);
-void skipFunction(ThreadContext *tc);
-
inline void
advancePC(PCState &pc, const StaticInstPtr &inst)
{
dest->pcState(src->pcState());
}
-void
-skipFunction(ThreadContext *tc)
-{
- panic("Not implemented for x86\n");
-}
-
uint64_t
getRFlags(ThreadContext *tc)
{
void copyMiscRegs(ThreadContext *src, ThreadContext *dest);
- void skipFunction(ThreadContext *tc);
-
inline void
advancePC(PCState &pc, const StaticInstPtr &inst)
{
namespace FreeBSD {
void
-UDelayEvent::process(ThreadContext *tc)
+onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul)
{
int arg_num;
//DPRINTFN("DELAY(%d)\n", time);
// convert parameter to ns
- if (argDivToNs)
- time /= argDivToNs;
+ if (div)
+ time /= div;
- time *= argMultToNs;
-
- SkipFuncEvent::process(tc);
+ time *= mul;
// Currently, only ARM full-system simulation uses UDelayEvents to skip
// __delay and __loop_delay functions. One form involves setting quiesce
namespace FreeBSD {
+void onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul);
+
/** A class to skip udelay() and related calls in the kernel.
* This class has two additional parameters that take the argument to udelay and
* manipulated it to come up with ns and eventually ticks to quiesce for.
* See descriptions of argDivToNs and argMultToNs below.
*/
-class UDelayEvent : public SkipFuncEvent
+template <typename Base>
+class UDelayEvent : public Base
{
private:
/** value to divide arg by to create ns. This is present beacues the linux
public:
UDelayEvent(PCEventScope *s, const std::string &desc, Addr addr,
uint64_t mult, uint64_t div)
- : SkipFuncEvent(s, desc, addr), argDivToNs(div), argMultToNs(mult) {}
- virtual void process(ThreadContext *xc);
+ : Base(s, desc, addr), argDivToNs(div), argMultToNs(mult) {}
+
+ void
+ process(ThreadContext *tc) override
+ {
+ onUDelay(tc, argDivToNs, argMultToNs);
+ Base::process(tc);
+ }
};
}
namespace Linux {
void
-DebugPrintkEvent::process(ThreadContext *tc)
+onDebugPrintk(ThreadContext *tc)
{
if (DTRACE(DebugPrintf)) {
std::stringstream ss;
StringWrap name(tc->getSystemPtr()->name() + ".dprintk");
DPRINTFN("%s", ss.str());
}
- SkipFuncEvent::process(tc);
-}
-
-void
-UDelayEvent::process(ThreadContext *tc)
-{
- int arg_num = 0;
-
- // Get the time in native size
- uint64_t time = TheISA::getArgument(tc, arg_num, (uint16_t)-1, false);
-
- // convert parameter to ns
- if (argDivToNs)
- time /= argDivToNs;
-
- time *= argMultToNs;
-
- SkipFuncEvent::process(tc);
-
- // Currently, only ARM full-system simulation uses UDelayEvents to skip
- // __delay and __loop_delay functions. One form involves setting quiesce
- // time to 0 with the assumption that quiesce will not happen. To avoid
- // the quiesce handling in this case, only execute the quiesce if time > 0.
- if (time > 0)
- tc->quiesceTick(curTick() + SimClock::Int::ns * time);
}
void
DmesgDumpEvent::process(ThreadContext *tc)
{
- StringWrap name(tc->getCpuPtr()->name() + ".dmesg_dump_event");
-
inform("Dumping kernel dmesg buffer to %s...\n", fname);
OutputStream *os = simout.create(fname);
dumpDmesg(tc, *os->stream());
void
KernelPanicEvent::process(ThreadContext *tc)
{
- StringWrap name(tc->getCpuPtr()->name() + ".dmesg_dump_event");
-
inform("Dumping kernel dmesg buffer to %s...\n", fname);
OutputStream *os = simout.create(fname);
dumpDmesg(tc, *os->stream());
panic(descr());
}
+void
+onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul)
+{
+ int arg_num = 0;
+
+ // Get the time in native size
+ uint64_t time = TheISA::getArgument(tc, arg_num, (uint16_t)-1, false);
+
+ // convert parameter to ns
+ if (div)
+ time /= div;
+
+ time *= mul;
+
+ // Currently, only ARM full-system simulation uses UDelayEvents to skip
+ // __delay and __loop_delay functions. One form involves setting quiesce
+ // time to 0 with the assumption that quiesce will not happen. To avoid
+ // the quiesce handling in this case, only execute the quiesce if time > 0.
+ if (time > 0)
+ tc->quiesceTick(curTick() + SimClock::Int::ns * time);
+}
+
} // namespace linux
namespace Linux {
-class DebugPrintkEvent : public SkipFuncEvent
+void onDebugPrintk(ThreadContext *tc);
+
+template <typename Base>
+class DebugPrintkEvent : public Base
{
public:
DebugPrintkEvent(PCEventScope *s, const std::string &desc, Addr addr)
- : SkipFuncEvent(s, desc, addr) {}
- virtual void process(ThreadContext *xc);
+ : Base(s, desc, addr) {}
+ virtual void
+ process(ThreadContext *tc)
+ {
+ onDebugPrintk(tc);
+ Base::process(tc);
+ }
};
/**
DmesgDumpEvent(PCEventScope *s, const std::string &desc, Addr addr,
const std::string &_fname)
: PCEvent(s, desc, addr), fname(_fname) {}
- virtual void process(ThreadContext *xc);
+ virtual void process(ThreadContext *tc);
};
/**
KernelPanicEvent(PCEventScope *s, const std::string &desc, Addr addr,
const std::string &_fname)
: PCEvent(s, desc, addr), fname(_fname) {}
- virtual void process(ThreadContext *xc);
+ virtual void process(ThreadContext *tc);
};
-/** A class to skip udelay() and related calls in the kernel.
- * This class has two additional parameters that take the argument to udelay and
- * manipulated it to come up with ns and eventually ticks to quiesce for.
+void onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul);
+
+/**
+ * A class to skip udelay() and related calls in the kernel.
+ * This class has two additional parameters that take the argument to udelay
+ * and manipulated it to come up with ns and eventually ticks to quiesce for.
* See descriptions of argDivToNs and argMultToNs below.
*/
-class UDelayEvent : public SkipFuncEvent
+template <typename Base>
+class UDelayEvent : public Base
{
private:
/** value to divide arg by to create ns. This is present beacues the linux
public:
UDelayEvent(PCEventScope *s, const std::string &desc, Addr addr,
uint64_t mult, uint64_t div)
- : SkipFuncEvent(s, desc, addr), argDivToNs(div), argMultToNs(mult) {}
- virtual void process(ThreadContext *xc);
-};
+ : Base(s, desc, addr), argDivToNs(div), argMultToNs(mult) {}
+ virtual void
+ process(ThreadContext *tc)
+ {
+ onUDelay(tc, argDivToNs, argMultToNs);
+ Base::process(tc);
+ }
+};
}
#include "kern/system_events.hh"
-#include "arch/utility.hh"
#include "base/trace.hh"
-#include "config/the_isa.hh"
#include "cpu/thread_context.hh"
#include "debug/PCEvent.hh"
void
-SkipFuncEvent::process(ThreadContext *tc)
+SkipFuncBase::process(ThreadContext *tc)
{
TheISA::PCState oldPC M5_VAR_USED = tc->pcState();
- // Call ISA specific code to do the skipping
- TheISA::skipFunction(tc);
+ returnFromFuncIn(tc);
+
DPRINTF(PCEvent, "skipping %s: pc = %s, newpc = %s\n", description,
oldPC, tc->pcState());
}
#include "cpu/pc_event.hh"
-class SkipFuncEvent : public PCEvent
+class SkipFuncBase : public PCEvent
{
+ protected:
+ virtual void returnFromFuncIn(ThreadContext *tc) = 0;
+
public:
- SkipFuncEvent(PCEventScope *s, const std::string &desc, Addr addr)
+ SkipFuncBase(PCEventScope *s, const std::string &desc, Addr addr)
: PCEvent(s, desc, addr)
{}
+
void process(ThreadContext *tc) override;
};