arch,mem: Move page table construction into the arch classes.
This gets rid of an awkward NoArchPageTable class, and also gives the arch a place to inject ISA specific parameters (specifically page size) without having to have TheISA:: in the generic version of these types. Change-Id: I1412f303460d5c43dafdb9b3cd07af81c908a441 Reviewed-on: https://gem5-review.googlesource.com/6981 Reviewed-by: Alexandru Duțu <alexandru.dutu@amd.com> Maintainer: Gabe Black <gabeblack@google.com>
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "debug/Loader.hh"
|
||||
#include "mem/page_table.hh"
|
||||
#include "params/Process.hh"
|
||||
#include "sim/aux_vector.hh"
|
||||
#include "sim/byteswap.hh"
|
||||
#include "sim/process_impl.hh"
|
||||
@@ -48,8 +49,9 @@ using namespace AlphaISA;
|
||||
using namespace std;
|
||||
|
||||
AlphaProcess::AlphaProcess(ProcessParams *params, ObjectFile *objFile)
|
||||
: Process(params, objFile)
|
||||
: Process(params, new FuncPageTable(params->name, params->pid), objFile)
|
||||
{
|
||||
fatal_if(!params->useArchPT, "Arch page tables not implemented.");
|
||||
Addr brk_point = objFile->dataBase() + objFile->dataSize() +
|
||||
objFile->bssSize();
|
||||
brk_point = roundUp(brk_point, PageBytes);
|
||||
|
||||
@@ -61,7 +61,4 @@ class AlphaProcess : public Process
|
||||
virtual bool mmapGrowsDown() const override { return false; }
|
||||
};
|
||||
|
||||
/* No architectural page table defined for this ISA */
|
||||
typedef NoArchPageTable ArchPageTable;
|
||||
|
||||
#endif // __ARCH_ALPHA_PROCESS_HH__
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "debug/Stack.hh"
|
||||
#include "mem/page_table.hh"
|
||||
#include "params/Process.hh"
|
||||
#include "sim/aux_vector.hh"
|
||||
#include "sim/byteswap.hh"
|
||||
#include "sim/process_impl.hh"
|
||||
@@ -62,8 +63,10 @@ using namespace ArmISA;
|
||||
|
||||
ArmProcess::ArmProcess(ProcessParams *params, ObjectFile *objFile,
|
||||
ObjectFile::Arch _arch)
|
||||
: Process(params, objFile), arch(_arch)
|
||||
: Process(params, new FuncPageTable(params->name, params->pid), objFile),
|
||||
arch(_arch)
|
||||
{
|
||||
fatal_if(!params->useArchPT, "Arch page tables not implemented.");
|
||||
}
|
||||
|
||||
ArmProcess32::ArmProcess32(ProcessParams *params, ObjectFile *objFile,
|
||||
|
||||
@@ -95,8 +95,5 @@ class ArmProcess64 : public ArmProcess
|
||||
void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
|
||||
};
|
||||
|
||||
/* No architectural page table defined for this ISA */
|
||||
typedef NoArchPageTable ArchPageTable;
|
||||
|
||||
#endif // __ARM_PROCESS_HH__
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "debug/Loader.hh"
|
||||
#include "mem/page_table.hh"
|
||||
#include "params/Process.hh"
|
||||
#include "sim/aux_vector.hh"
|
||||
#include "sim/process.hh"
|
||||
#include "sim/process_impl.hh"
|
||||
@@ -48,9 +49,10 @@
|
||||
using namespace std;
|
||||
using namespace MipsISA;
|
||||
|
||||
MipsProcess::MipsProcess(ProcessParams * params, ObjectFile *objFile)
|
||||
: Process(params, objFile)
|
||||
MipsProcess::MipsProcess(ProcessParams *params, ObjectFile *objFile)
|
||||
: Process(params, new FuncPageTable(params->name, params->pid), objFile)
|
||||
{
|
||||
fatal_if(!params->useArchPT, "Arch page tables not implemented.");
|
||||
// Set up stack. On MIPS, stack starts at the top of kuseg
|
||||
// user address space. MIPS stack grows down from here
|
||||
Addr stack_base = 0x7FFFFFFF;
|
||||
|
||||
@@ -58,8 +58,4 @@ class MipsProcess : public Process
|
||||
void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
|
||||
};
|
||||
|
||||
/* No architectural page table defined for this ISA */
|
||||
typedef NoArchPageTable ArchPageTable;
|
||||
|
||||
|
||||
#endif // __MIPS_PROCESS_HH__
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "debug/Stack.hh"
|
||||
#include "mem/page_table.hh"
|
||||
#include "params/Process.hh"
|
||||
#include "sim/aux_vector.hh"
|
||||
#include "sim/process_impl.hh"
|
||||
#include "sim/syscall_return.hh"
|
||||
@@ -49,8 +50,9 @@ using namespace std;
|
||||
using namespace PowerISA;
|
||||
|
||||
PowerProcess::PowerProcess(ProcessParams *params, ObjectFile *objFile)
|
||||
: Process(params, objFile)
|
||||
: Process(params, new FuncPageTable(params->name, params->pid), objFile)
|
||||
{
|
||||
fatal_if(!params->useArchPT, "Arch page tables not implemented.");
|
||||
// Set up break point (Top of Heap)
|
||||
Addr brk_point = objFile->dataBase() + objFile->dataSize() +
|
||||
objFile->bssSize();
|
||||
|
||||
@@ -57,8 +57,5 @@ class PowerProcess : public Process
|
||||
void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
|
||||
};
|
||||
|
||||
/* No architectural page table defined for this ISA */
|
||||
typedef NoArchPageTable ArchPageTable;
|
||||
|
||||
#endif // __POWER_PROCESS_HH__
|
||||
|
||||
|
||||
@@ -59,9 +59,10 @@
|
||||
using namespace std;
|
||||
using namespace RiscvISA;
|
||||
|
||||
RiscvProcess::RiscvProcess(ProcessParams * params,
|
||||
ObjectFile *objFile) : Process(params, objFile)
|
||||
RiscvProcess::RiscvProcess(ProcessParams *params, ObjectFile *objFile) :
|
||||
Process(params, new FuncPageTable(params->name, params->pid), objFile)
|
||||
{
|
||||
fatal_if(!params->useArchPT, "Arch page tables not implemented.");
|
||||
const Addr stack_base = 0x7FFFFFFFFFFFFFFFL;
|
||||
const Addr max_stack_size = 8 * 1024 * 1024;
|
||||
const Addr next_thread_stack_base = stack_base - max_stack_size;
|
||||
|
||||
@@ -65,8 +65,4 @@ class RiscvProcess : public Process
|
||||
virtual bool mmapGrowsDown() const override { return false; }
|
||||
};
|
||||
|
||||
/* No architectural page table defined for this ISA */
|
||||
typedef NoArchPageTable ArchPageTable;
|
||||
|
||||
|
||||
#endif // __RISCV_PROCESS_HH__
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "debug/Stack.hh"
|
||||
#include "mem/page_table.hh"
|
||||
#include "params/Process.hh"
|
||||
#include "sim/aux_vector.hh"
|
||||
#include "sim/process_impl.hh"
|
||||
#include "sim/syscall_return.hh"
|
||||
@@ -53,10 +54,12 @@ using namespace SparcISA;
|
||||
static const int FirstArgumentReg = 8;
|
||||
|
||||
|
||||
SparcProcess::SparcProcess(ProcessParams * params, ObjectFile *objFile,
|
||||
SparcProcess::SparcProcess(ProcessParams *params, ObjectFile *objFile,
|
||||
Addr _StackBias)
|
||||
: Process(params, objFile), StackBias(_StackBias)
|
||||
: Process(params, new FuncPageTable(params->name, params->pid), objFile),
|
||||
StackBias(_StackBias)
|
||||
{
|
||||
fatal_if(!params->useArchPT, "Arch page tables not implemented.");
|
||||
// Initialize these to 0s
|
||||
fillStart = 0;
|
||||
spillStart = 0;
|
||||
|
||||
@@ -160,7 +160,4 @@ class Sparc64Process : public SparcProcess
|
||||
void setSyscallArg(ThreadContext *tc, int i, SparcISA::IntReg val);
|
||||
};
|
||||
|
||||
/* No architectural page table defined for this ISA */
|
||||
typedef NoArchPageTable ArchPageTable;
|
||||
|
||||
#endif // __SPARC_PROCESS_HH__
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
#include "debug/Stack.hh"
|
||||
#include "mem/multi_level_page_table.hh"
|
||||
#include "mem/page_table.hh"
|
||||
#include "params/Process.hh"
|
||||
#include "sim/aux_vector.hh"
|
||||
#include "sim/process_impl.hh"
|
||||
#include "sim/syscall_desc.hh"
|
||||
@@ -95,10 +96,16 @@ static const int ArgumentReg32[] = {
|
||||
static const int NumArgumentRegs32 M5_VAR_USED =
|
||||
sizeof(ArgumentReg) / sizeof(const int);
|
||||
|
||||
X86Process::X86Process(ProcessParams * params, ObjectFile *objFile,
|
||||
X86Process::X86Process(ProcessParams *params, ObjectFile *objFile,
|
||||
SyscallDesc *_syscallDescs, int _numSyscallDescs)
|
||||
: Process(params, objFile), syscallDescs(_syscallDescs),
|
||||
numSyscallDescs(_numSyscallDescs)
|
||||
: Process(params, params->useArchPT ?
|
||||
static_cast<PageTableBase *>(
|
||||
new ArchPageTable(params->name, params->pid,
|
||||
params->system)) :
|
||||
static_cast<PageTableBase *>(
|
||||
new FuncPageTable(params->name, params->pid)),
|
||||
objFile),
|
||||
syscallDescs(_syscallDescs), numSyscallDescs(_numSyscallDescs)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,14 @@ namespace X86ISA
|
||||
class X86Process : public Process
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
* Declaration of architectural page table for x86.
|
||||
*
|
||||
* These page tables are stored in system memory and respect x86
|
||||
* specification.
|
||||
*/
|
||||
typedef MultiLevelPageTable<PageTableOps> ArchPageTable;
|
||||
|
||||
Addr _gdtStart;
|
||||
Addr _gdtSize;
|
||||
|
||||
@@ -189,14 +197,6 @@ namespace X86ISA
|
||||
Process *process, TheISA::IntReg flags) override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Declaration of architectural page table for x86.
|
||||
*
|
||||
* These page tables are stored in system memory and respect x86
|
||||
* specification.
|
||||
*/
|
||||
typedef MultiLevelPageTable<PageTableOps> ArchPageTable;
|
||||
|
||||
}
|
||||
|
||||
#endif // __ARCH_X86_PROCESS_HH__
|
||||
|
||||
@@ -246,19 +246,4 @@ class FuncPageTable : public PageTableBase
|
||||
void getMappings(std::vector<std::pair<Addr, Addr>> *addr_maps) override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Faux page table class indended to stop the usage of
|
||||
* an architectural page table, when there is none defined
|
||||
* for a particular ISA.
|
||||
*/
|
||||
class NoArchPageTable : public FuncPageTable
|
||||
{
|
||||
public:
|
||||
NoArchPageTable(const std::string &__name, uint64_t _pid, System *_sys,
|
||||
Addr _pageSize = TheISA::PageBytes) : FuncPageTable(__name, _pid)
|
||||
{
|
||||
fatal("No architectural page table defined for this ISA.\n");
|
||||
}
|
||||
};
|
||||
|
||||
#endif // __MEM_PAGE_TABLE_HH__
|
||||
|
||||
@@ -101,14 +101,12 @@
|
||||
using namespace std;
|
||||
using namespace TheISA;
|
||||
|
||||
Process::Process(ProcessParams * params, ObjectFile * obj_file)
|
||||
Process::Process(ProcessParams *params, PageTableBase *pTable,
|
||||
ObjectFile *obj_file)
|
||||
: SimObject(params), system(params->system),
|
||||
useArchPT(params->useArchPT),
|
||||
kvmInSE(params->kvmInSE),
|
||||
pTable(useArchPT ?
|
||||
static_cast<PageTableBase *>(new ArchPageTable(name(), params->pid,
|
||||
system)) :
|
||||
static_cast<PageTableBase *>(new FuncPageTable(name(), params->pid))),
|
||||
pTable(pTable),
|
||||
initVirtMem(system->getSystemPort(), this,
|
||||
SETranslatingPortProxy::Always),
|
||||
objFile(obj_file),
|
||||
|
||||
@@ -63,7 +63,8 @@ class ThreadContext;
|
||||
class Process : public SimObject
|
||||
{
|
||||
public:
|
||||
Process(ProcessParams *params, ObjectFile *obj_file);
|
||||
Process(ProcessParams *params, PageTableBase *pTable,
|
||||
ObjectFile *obj_file);
|
||||
|
||||
void serialize(CheckpointOut &cp) const override;
|
||||
void unserialize(CheckpointIn &cp) override;
|
||||
|
||||
Reference in New Issue
Block a user