gem5 v24.0.0.0
|
This class helps to implement RISCV's physical memory protection (pmp) primitive. More...
#include <pmp.hh>
Classes | |
struct | PmpEntry |
single pmp entry struct More... | |
Public Member Functions | |
PARAMS (PMP) | |
PMP (const Params ¶ms) | |
Fault | pmpCheck (const RequestPtr &req, BaseMMU::Mode mode, PrivilegeMode pmode, ThreadContext *tc, Addr vaddr=0) |
pmpCheck checks if a particular memory access is allowed based on the pmp rules. | |
bool | pmpUpdateCfg (uint32_t pmp_index, uint8_t this_cfg) |
pmpUpdateCfg updates the pmpcfg for a pmp entry and calls pmpUpdateRule to update the rule of corresponding pmp entry. | |
bool | pmpUpdateAddr (uint32_t pmp_index, Addr this_addr) |
pmpUpdateAddr updates the pmpaddr for a pmp entry and calls pmpUpdateRule to update the rule of corresponding pmp entry. | |
void | pmpReset () |
pmpReset reset when reset signal in trigger from CPU. | |
Public Member Functions inherited from gem5::SimObject | |
const Params & | params () const |
SimObject (const Params &p) | |
virtual | ~SimObject () |
virtual void | init () |
init() is called after all C++ SimObjects have been created and all ports are connected. | |
virtual void | loadState (CheckpointIn &cp) |
loadState() is called on each SimObject when restoring from a checkpoint. | |
virtual void | initState () |
initState() is called on each SimObject when not restoring from a checkpoint. | |
virtual void | regProbePoints () |
Register probe points for this object. | |
virtual void | regProbeListeners () |
Register probe listeners for this object. | |
ProbeManager * | getProbeManager () |
Get the probe manager for this object. | |
virtual Port & | getPort (const std::string &if_name, PortID idx=InvalidPortID) |
Get a port with a given name and index. | |
virtual void | startup () |
startup() is the final initialization call before simulation. | |
DrainState | drain () override |
Provide a default implementation of the drain interface for objects that don't need draining. | |
virtual void | memWriteback () |
Write back dirty buffers to memory using functional writes. | |
virtual void | memInvalidate () |
Invalidate the contents of memory buffers. | |
void | serialize (CheckpointOut &cp) const override |
Serialize an object. | |
void | unserialize (CheckpointIn &cp) override |
Unserialize an object. | |
Public Member Functions inherited from gem5::EventManager | |
EventQueue * | eventQueue () const |
void | schedule (Event &event, Tick when) |
void | deschedule (Event &event) |
void | reschedule (Event &event, Tick when, bool always=false) |
void | schedule (Event *event, Tick when) |
void | deschedule (Event *event) |
void | reschedule (Event *event, Tick when, bool always=false) |
void | wakeupEventQueue (Tick when=(Tick) -1) |
This function is not needed by the usual gem5 event loop but may be necessary in derived EventQueues which host gem5 on other schedulers. | |
void | setCurTick (Tick newVal) |
EventManager (EventManager &em) | |
Event manger manages events in the event queue. | |
EventManager (EventManager *em) | |
EventManager (EventQueue *eq) | |
Public Member Functions inherited from gem5::Serializable | |
Serializable () | |
virtual | ~Serializable () |
void | serializeSection (CheckpointOut &cp, const char *name) const |
Serialize an object into a new section. | |
void | serializeSection (CheckpointOut &cp, const std::string &name) const |
void | unserializeSection (CheckpointIn &cp, const char *name) |
Unserialize an a child object. | |
void | unserializeSection (CheckpointIn &cp, const std::string &name) |
Public Member Functions inherited from gem5::Drainable | |
DrainState | drainState () const |
Return the current drain state of an object. | |
virtual void | notifyFork () |
Notify a child process of a fork. | |
Public Member Functions inherited from gem5::statistics::Group | |
Group (Group *parent, const char *name=nullptr) | |
Construct a new statistics group. | |
virtual | ~Group () |
virtual void | regStats () |
Callback to set stat parameters. | |
virtual void | resetStats () |
Callback to reset stats. | |
virtual void | preDumpStats () |
Callback before stats are dumped. | |
void | addStat (statistics::Info *info) |
Register a stat with this group. | |
const std::map< std::string, Group * > & | getStatGroups () const |
Get all child groups associated with this object. | |
const std::vector< Info * > & | getStats () const |
Get all stats associated with this object. | |
void | addStatGroup (const char *name, Group *block) |
Add a stat block as a child of this block. | |
const Info * | resolveStat (std::string name) const |
Resolve a stat by its name within this group. | |
void | mergeStatGroup (Group *block) |
Merge the contents (stats & children) of a block to this block. | |
Group ()=delete | |
Group (const Group &)=delete | |
Group & | operator= (const Group &)=delete |
Public Member Functions inherited from gem5::Named | |
Named (const std::string &name_) | |
virtual | ~Named ()=default |
virtual std::string | name () const |
Private Types | |
enum | pmpAmatch { PMP_OFF , PMP_TOR , PMP_NA4 , PMP_NAPOT } |
This enum is used for encoding of address matching mode of pmp address register, which is present in bits 3-4 (A) of pmpcfg register for a pmp entry. More... | |
Private Member Functions | |
bool | shouldCheckPMP (PrivilegeMode pmode, ThreadContext *tc) |
This function is called during a memory access to determine if the pmp table should be consulted for this access. | |
Fault | createAddrfault (Addr vaddr, BaseMMU::Mode mode) |
createAddrfault creates an address fault if the pmp checks fail to pass for a given access. | |
void | pmpUpdateRule (uint32_t pmp_index) |
pmpUpdateRule updates the pmp rule for a given pmp entry depending on the value of pmpaddr and pmpcfg for that entry. | |
uint8_t | pmpGetAField (uint8_t cfg) |
pmpGetAField extracts the A field (address matching mode) from an input pmpcfg register | |
AddrRange | pmpDecodeNapot (Addr pmpaddr) |
This function decodes a pmpaddr register value into an address range when A field of pmpcfg register is set to NAPOT mode (naturally aligned power of two region). | |
Private Attributes | |
int | pmpEntries |
maximum number of entries in the pmp table | |
const uint8_t | PMP_READ = 1 << 0 |
pmpcfg address range read permission mask | |
const uint8_t | PMP_WRITE = 1 << 1 |
pmpcfg address range write permission mask | |
const uint8_t | PMP_EXEC = 1 << 2 |
pmpcfg address range execute permission mask | |
const uint8_t | PMP_A_MASK = 3 << 3 |
pmpcfg A field mask | |
const uint8_t | PMP_LOCK = 1 << 7 |
pmpcfg address range locked mask | |
int | numRules |
variable to keep track of active number of rules any time | |
bool | hasLockEntry |
variable to keep track of any lock of entry | |
std::vector< PmpEntry > | pmpTable |
a table of pmp entries | |
Additional Inherited Members | |
Public Types inherited from gem5::SimObject | |
typedef SimObjectParams | Params |
Static Public Member Functions inherited from gem5::SimObject | |
static void | serializeAll (const std::string &cpt_dir) |
Create a checkpoint by serializing all SimObjects in the system. | |
static SimObject * | find (const char *name) |
Find the SimObject with the given name and return a pointer to it. | |
static void | setSimObjectResolver (SimObjectResolver *resolver) |
There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. | |
static SimObjectResolver * | getSimObjectResolver () |
There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. | |
Static Public Member Functions inherited from gem5::Serializable | |
static const std::string & | currentSection () |
Gets the fully-qualified name of the active section. | |
static void | generateCheckpointOut (const std::string &cpt_dir, std::ofstream &outstream) |
Generate a checkpoint file so that the serialization can be routed to it. | |
Protected Member Functions inherited from gem5::Drainable | |
Drainable () | |
virtual | ~Drainable () |
virtual void | drainResume () |
Resume execution after a successful drain. | |
void | signalDrainDone () const |
Signal that an object is drained. | |
Protected Attributes inherited from gem5::SimObject | |
const SimObjectParams & | _params |
Cached copy of the object parameters. | |
Protected Attributes inherited from gem5::EventManager | |
EventQueue * | eventq |
A pointer to this object's event queue. | |
This class helps to implement RISCV's physical memory protection (pmp) primitive.
|
private |
This enum is used for encoding of address matching mode of pmp address register, which is present in bits 3-4 (A) of pmpcfg register for a pmp entry.
PMP_OFF = null region (pmp disabled) MP_TOR = top of range mode PMP_NA4 = naturally aligned four byte region PMP_NAPOT = naturally aligned power of two region, >= 8 bytes
Enumerator | |
---|---|
PMP_OFF | |
PMP_TOR | |
PMP_NA4 | |
PMP_NAPOT |
gem5::RiscvISA::PMP::PMP | ( | const Params & | params | ) |
Definition at line 50 of file pmp.cc.
References pmpEntries, and pmpTable.
|
private |
createAddrfault creates an address fault if the pmp checks fail to pass for a given access.
This function is used by pmpCheck(). given pmp entry depending on the value of pmpaddr and pmpcfg for that entry.
vaddr | virtual address of the access. |
mode | mode of access(read, write, execute). |
Definition at line 128 of file pmp.cc.
References gem5::RiscvISA::INST_ACCESS, gem5::RiscvISA::LOAD_ACCESS, gem5::RiscvISA::mode, gem5::BaseMMU::Read, gem5::RiscvISA::STORE_ACCESS, gem5::RiscvISA::vaddr, warn, and gem5::BaseMMU::Write.
Referenced by pmpCheck().
gem5::RiscvISA::PMP::PARAMS | ( | PMP | ) |
Fault gem5::RiscvISA::PMP::pmpCheck | ( | const RequestPtr & | req, |
BaseMMU::Mode | mode, | ||
PrivilegeMode | pmode, | ||
ThreadContext * | tc, | ||
Addr | vaddr = 0 ) |
pmpCheck checks if a particular memory access is allowed based on the pmp rules.
req | memory request. |
mode | mode of request (read, write, execute). |
pmode | current privilege mode of memory (U, S, M). |
tc | thread context. |
vaddr | optional parameter to pass vaddr of original request for which a page table walk is consulted by pmp unit |
Definition at line 60 of file pmp.cc.
References gem5::AddrRange::contains(), createAddrfault(), DPRINTF, gem5::BaseMMU::Execute, gem5::RiscvISA::i, gem5::RiscvISA::mode, gem5::NoFault, PMP_EXEC, PMP_LOCK, PMP_OFF, PMP_READ, PMP_WRITE, pmpGetAField(), pmpTable, gem5::RiscvISA::PRV_M, gem5::BaseMMU::Read, shouldCheckPMP(), gem5::RiscvISA::vaddr, and gem5::BaseMMU::Write.
This function decodes a pmpaddr register value into an address range when A field of pmpcfg register is set to NAPOT mode (naturally aligned power of two region).
pmpaddr | input address from a pmp entry. |
Definition at line 285 of file pmp.cc.
References gem5::X86ISA::base, gem5::ctz64(), gem5::mbits(), and gem5::ArmISA::t1.
Referenced by pmpUpdateRule().
|
inlineprivate |
pmpGetAField extracts the A field (address matching mode) from an input pmpcfg register
cfg | pmpcfg register value. |
Definition at line 143 of file pmp.cc.
References gem5::RiscvISA::a.
Referenced by pmpCheck(), pmpUpdateAddr(), and pmpUpdateRule().
void gem5::RiscvISA::PMP::pmpReset | ( | ) |
pmpReset reset when reset signal in trigger from CPU.
Definition at line 229 of file pmp.cc.
References gem5::RiscvISA::i, PMP_A_MASK, PMP_LOCK, pmpTable, and pmpUpdateRule().
bool gem5::RiscvISA::PMP::pmpUpdateAddr | ( | uint32_t | pmp_index, |
Addr | this_addr ) |
pmpUpdateAddr updates the pmpaddr for a pmp entry and calls pmpUpdateRule to update the rule of corresponding pmp entry.
pmp_index | pmp entry index. |
this_addr | value to be written to pmpaddr. |
Definition at line 238 of file pmp.cc.
References DPRINTF, gem5::RiscvISA::index, PMP_LOCK, PMP_TOR, pmpEntries, pmpGetAField(), pmpTable, and pmpUpdateRule().
bool gem5::RiscvISA::PMP::pmpUpdateCfg | ( | uint32_t | pmp_index, |
uint8_t | this_cfg ) |
pmpUpdateCfg updates the pmpcfg for a pmp entry and calls pmpUpdateRule to update the rule of corresponding pmp entry.
pmp_index | pmp entry index. |
this_cfg | value to be written to pmpcfg. |
Definition at line 152 of file pmp.cc.
References DPRINTF, PMP_LOCK, pmpEntries, pmpTable, and pmpUpdateRule().
|
private |
pmpUpdateRule updates the pmp rule for a given pmp entry depending on the value of pmpaddr and pmpcfg for that entry.
pmp_index | pmp entry index. |
Definition at line 174 of file pmp.cc.
References DPRINTF, hasLockEntry, gem5::RiscvISA::i, numRules, PMP_LOCK, PMP_NA4, PMP_NAPOT, PMP_OFF, PMP_TOR, pmpDecodeNapot(), pmpEntries, pmpGetAField(), and pmpTable.
Referenced by pmpReset(), pmpUpdateAddr(), and pmpUpdateCfg().
|
private |
This function is called during a memory access to determine if the pmp table should be consulted for this access.
pmode | current privilege mode of memory (U, S, M). |
tc | thread context. |
Definition at line 275 of file pmp.cc.
References hasLockEntry, numRules, and gem5::RiscvISA::PRV_M.
Referenced by pmpCheck().
|
private |
variable to keep track of any lock of entry
Definition at line 102 of file pmp.hh.
Referenced by pmpUpdateRule(), and shouldCheckPMP().
|
private |
variable to keep track of active number of rules any time
Definition at line 99 of file pmp.hh.
Referenced by pmpUpdateRule(), and shouldCheckPMP().
|
private |
|
private |
pmpcfg address range execute permission mask
Definition at line 90 of file pmp.hh.
Referenced by pmpCheck().
|
private |
pmpcfg address range locked mask
Definition at line 96 of file pmp.hh.
Referenced by pmpCheck(), pmpReset(), pmpUpdateAddr(), pmpUpdateCfg(), and pmpUpdateRule().
|
private |
pmpcfg address range read permission mask
Definition at line 84 of file pmp.hh.
Referenced by pmpCheck().
|
private |
pmpcfg address range write permission mask
Definition at line 87 of file pmp.hh.
Referenced by pmpCheck().
|
private |
maximum number of entries in the pmp table
Definition at line 65 of file pmp.hh.
Referenced by PMP(), pmpUpdateAddr(), pmpUpdateCfg(), and pmpUpdateRule().
|
private |
a table of pmp entries
Definition at line 116 of file pmp.hh.
Referenced by PMP(), pmpCheck(), pmpReset(), pmpUpdateAddr(), pmpUpdateCfg(), and pmpUpdateRule().