From a0038f7aec488887cb2db5aad4bf4a5142a3572b Mon Sep 17 00:00:00 2001 From: Giacomo Travaglini Date: Fri, 24 Apr 2020 14:12:54 +0100 Subject: [PATCH] sim, arch-arm: Restore capability of running without a kernel The following patch: https://gem5-review.googlesource.com/c/public/gem5/+/24283 Removed the capability of starting a gem5 simulation without a kernel object. This patch is restoring it Change-Id: I6d751bac386cbb250b3593bb12463140dc964ab3 Signed-off-by: Giacomo Travaglini Reviewed-by: Nikos Nikoleris Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/28147 Reviewed-by: Gabe Black Tested-by: kokoro --- src/arch/arm/fs_workload.cc | 8 ++++-- src/sim/kernel_workload.cc | 53 ++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/arch/arm/fs_workload.cc b/src/arch/arm/fs_workload.cc index 550d8ded0..09c7bb2e7 100644 --- a/src/arch/arm/fs_workload.cc +++ b/src/arch/arm/fs_workload.cc @@ -69,9 +69,13 @@ SkipFunc::returnFromFuncIn(ThreadContext *tc) } } -FsWorkload::FsWorkload(Params *p) : KernelWorkload(*p), - kernelEntry((kernelObj->entryPoint() & loadAddrMask()) + loadAddrOffset()) +FsWorkload::FsWorkload(Params *p) : KernelWorkload(*p) { + if (kernelObj) { + kernelEntry = (kernelObj->entryPoint() & loadAddrMask()) + + loadAddrOffset(); + } + bootLoaders.reserve(p->boot_loader.size()); for (const auto &bl : p->boot_loader) { std::unique_ptr bl_obj; diff --git a/src/sim/kernel_workload.cc b/src/sim/kernel_workload.cc index f107d696e..415ff9630 100644 --- a/src/sim/kernel_workload.cc +++ b/src/sim/kernel_workload.cc @@ -38,39 +38,44 @@ KernelWorkload::KernelWorkload(const Params &p) : Workload(&p), _params(p), if (!Loader::debugSymbolTable) Loader::debugSymbolTable = new Loader::SymbolTable; - kernelObj = Loader::createObjectFile(params().object_file); - inform("kernel located at: %s", params().object_file); + if (params().object_file == "") { + inform("No kernel set for full system simulation. " + "Assuming you know what you're doing."); + } else { + kernelObj = Loader::createObjectFile(params().object_file); + inform("kernel located at: %s", params().object_file); - fatal_if(!kernelObj, - "Could not load kernel file %s", params().object_file); + fatal_if(!kernelObj, + "Could not load kernel file %s", params().object_file); - image = kernelObj->buildImage(); + image = kernelObj->buildImage(); - _start = image.minAddr(); - _end = image.maxAddr(); + _start = image.minAddr(); + _end = image.maxAddr(); - // If load_addr_mask is set to 0x0, then calculate the smallest mask to - // cover all kernel addresses so gem5 can relocate the kernel to a new - // offset. - if (_loadAddrMask == 0) - _loadAddrMask = mask(findMsbSet(_end - _start) + 1); + // If load_addr_mask is set to 0x0, then calculate the smallest mask to + // cover all kernel addresses so gem5 can relocate the kernel to a new + // offset. + if (_loadAddrMask == 0) + _loadAddrMask = mask(findMsbSet(_end - _start) + 1); - image.move([this](Addr a) { - return (a & _loadAddrMask) + _loadAddrOffset; - }); + image.move([this](Addr a) { + return (a & _loadAddrMask) + _loadAddrOffset; + }); - // load symbols - fatal_if(!kernelObj->loadGlobalSymbols(kernelSymtab), - "Could not load kernel symbols."); + // load symbols + fatal_if(!kernelObj->loadGlobalSymbols(kernelSymtab), + "Could not load kernel symbols."); - fatal_if(!kernelObj->loadLocalSymbols(kernelSymtab), - "Could not load kernel local symbols."); + fatal_if(!kernelObj->loadLocalSymbols(kernelSymtab), + "Could not load kernel local symbols."); - fatal_if(!kernelObj->loadGlobalSymbols(Loader::debugSymbolTable), - "Could not load kernel symbols."); + fatal_if(!kernelObj->loadGlobalSymbols(Loader::debugSymbolTable), + "Could not load kernel symbols."); - fatal_if(!kernelObj->loadLocalSymbols(Loader::debugSymbolTable), - "Could not load kernel local symbols."); + fatal_if(!kernelObj->loadLocalSymbols(Loader::debugSymbolTable), + "Could not load kernel local symbols."); + } // Loading only needs to happen once and after memory system is // connected so it will happen in initState() -- 2.30.2