arm,kern: Stop using the getArgument function for kernel events.

This change plumbs through an ABI to use with the GuestABI mechanism so
that the ISA switched getArgument function is no longer used.

Change-Id: I0d394dcfd7ad6fa745b6ef2aa62973167108f0c3
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/39320
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2021-01-17 22:46:36 -08:00
parent 8633802c3e
commit 9d04b1b4e6
7 changed files with 64 additions and 37 deletions

View File

@@ -68,8 +68,7 @@ FsFreebsd::FsFreebsd(const Params &p) : ArmISA::FsWorkload(p),
"oops_exit", "Kernel oops in guest");
}
skipUDelay = addKernelFuncEvent<SkipUDelay<ArmISA::SkipFunc>>(
"DELAY", "DELAY", 1000, 0);
skipUDelay = addSkipFunc<SkipUDelay>("DELAY", "DELAY", 1000, 0);
}
void

View File

@@ -44,6 +44,8 @@
#include <memory>
#include <vector>
#include "arch/arm/aapcs32.hh"
#include "arch/arm/aapcs64.hh"
#include "kern/linux/events.hh"
#include "params/ArmFsWorkload.hh"
#include "sim/kernel_workload.hh"
@@ -86,6 +88,34 @@ class FsWorkload : public KernelWorkload
*/
Loader::ObjectFile *getBootLoader(Loader::ObjectFile *const obj);
template <template <class ABI, class Base> class FuncEvent,
typename... Args>
PCEvent *
addSkipFunc(Args... args)
{
if (getArch() == Loader::Arm64) {
return addKernelFuncEvent<FuncEvent<Aapcs64, SkipFunc>>(
std::forward<Args>(args)...);
} else {
return addKernelFuncEvent<FuncEvent<Aapcs32, SkipFunc>>(
std::forward<Args>(args)...);
}
}
template <template <class ABI, class Base> class FuncEvent,
typename... Args>
PCEvent *
addSkipFuncOrPanic(Args... args)
{
if (getArch() == Loader::Arm64) {
return addKernelFuncEventOrPanic<FuncEvent<Aapcs64, SkipFunc>>(
std::forward<Args>(args)...);
} else {
return addKernelFuncEventOrPanic<FuncEvent<Aapcs32, SkipFunc>>(
std::forward<Args>(args)...);
}
}
public:
typedef ArmFsWorkloadParams Params;
const Params &

View File

@@ -230,28 +230,23 @@ FsLinux::startup()
// With ARM udelay() is #defined to __udelay
// newer kernels use __loop_udelay and __loop_const_udelay symbols
skipUDelay = addKernelFuncEvent<SkipUDelay<SkipFunc>>(
skipUDelay = addSkipFunc<SkipUDelay>(
"__loop_udelay", "__udelay", 1000, 0);
if (!skipUDelay)
skipUDelay = addKernelFuncEventOrPanic<SkipUDelay<SkipFunc>>(
"__udelay", "__udelay", 1000, 0);
if (!skipUDelay) {
skipUDelay = addSkipFuncOrPanic<SkipUDelay>(
"__udelay", "__udelay", 1000, 0);
}
// constant arguments to udelay() have some precomputation done ahead of
// time. Constant comes from code.
skipConstUDelay = addKernelFuncEvent<SkipUDelay<SkipFunc>>(
skipConstUDelay = addSkipFunc<SkipUDelay>(
"__loop_const_udelay", "__const_udelay", 1000, 107374);
if (!skipConstUDelay) {
skipConstUDelay = addKernelFuncEventOrPanic<SkipUDelay<SkipFunc>>(
skipConstUDelay = addSkipFuncOrPanic<SkipUDelay>(
"__const_udelay", "__const_udelay", 1000, 107374);
}
if (getArch() == Loader::Arm64) {
debugPrintk = addKernelFuncEvent<
DebugPrintk<SkipFuncLinux64>>("dprintk");
} else {
debugPrintk = addKernelFuncEvent<
DebugPrintk<SkipFuncLinux32>>("dprintk");
}
debugPrintk = addSkipFunc<DebugPrintk>("dprintk");
}
void

View File

@@ -45,13 +45,8 @@ namespace FreeBSD
{
void
onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul)
onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul, uint64_t time)
{
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;

View File

@@ -34,18 +34,19 @@
#define __KERN_FREEBSD_EVENTS_HH__
#include "kern/system_events.hh"
#include "sim/guest_abi.hh"
namespace FreeBSD
{
void onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul);
void onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul, uint64_t time);
/** 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.
* 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.
*/
template <typename Base>
template <typename ABI, typename Base>
class SkipUDelay : public Base
{
private:
@@ -69,7 +70,13 @@ class SkipUDelay : public Base
void
process(ThreadContext *tc) override
{
onUDelay(tc, argDivToNs, argMultToNs);
// Use Addr since it's handled specially and will act as a natively
// sized data type.
std::function<void(ThreadContext *, Addr)> call_udelay =
[this](ThreadContext *tc, Addr time) {
onUDelay(tc, argDivToNs, argMultToNs, time);
};
invokeSimcall<ABI>(tc, call_udelay);
Base::process(tc);
}
};

View File

@@ -78,13 +78,8 @@ KernelPanic::process(ThreadContext *tc)
}
void
onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul)
onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul, uint64_t time)
{
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;

View File

@@ -56,7 +56,7 @@ class ThreadContext;
namespace Linux
{
template <typename Base>
template <typename ABI, typename Base>
class DebugPrintk : public Base
{
public:
@@ -71,7 +71,7 @@ class DebugPrintk : public Base
PrintkVarArgs args) -> int {
return printk(str, tc, format_ptr, args);
};
invokeSimcall<typename Base::ABI>(tc, func);
invokeSimcall<ABI>(tc, func);
DPRINTFN("%s", str);
}
Base::process(tc);
@@ -120,7 +120,7 @@ class KernelPanic : public PCEvent
void process(ThreadContext *tc) override;
};
void onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul);
void onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul, uint64_t time);
/**
* A class to skip udelay() and related calls in the kernel.
@@ -128,7 +128,7 @@ void onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul);
* and manipulated it to come up with ns and eventually ticks to quiesce for.
* See descriptions of argDivToNs and argMultToNs below.
*/
template <typename Base>
template <typename ABI, typename Base>
class SkipUDelay : public Base
{
private:
@@ -156,7 +156,13 @@ class SkipUDelay : public Base
void
process(ThreadContext *tc) override
{
onUDelay(tc, argDivToNs, argMultToNs);
// Use Addr since it's handled specially and will act as a natively
// sized data type.
std::function<void(ThreadContext *, Addr)> call_udelay =
[this](ThreadContext *tc, Addr time) {
onUDelay(tc, argDivToNs, argMultToNs, time);
};
invokeSimcall<ABI>(tc, call_udelay);
Base::process(tc);
}
};