|
gem5
v22.0.0.2
|
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, RiscvISA::PrivilegeMode pmode, ThreadContext *tc, Addr vaddr=0) |
| pmpCheck checks if a particular memory access is allowed based on the pmp rules. More... | |
| void | 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. More... | |
| void | 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. More... | |
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. More... | |
| virtual void | loadState (CheckpointIn &cp) |
| loadState() is called on each SimObject when restoring from a checkpoint. More... | |
| virtual void | initState () |
| initState() is called on each SimObject when not restoring from a checkpoint. More... | |
| virtual void | regProbePoints () |
| Register probe points for this object. More... | |
| virtual void | regProbeListeners () |
| Register probe listeners for this object. More... | |
| ProbeManager * | getProbeManager () |
| Get the probe manager for this object. More... | |
| virtual Port & | getPort (const std::string &if_name, PortID idx=InvalidPortID) |
| Get a port with a given name and index. More... | |
| virtual void | startup () |
| startup() is the final initialization call before simulation. More... | |
| DrainState | drain () override |
| Provide a default implementation of the drain interface for objects that don't need draining. More... | |
| virtual void | memWriteback () |
| Write back dirty buffers to memory using functional writes. More... | |
| virtual void | memInvalidate () |
| Invalidate the contents of memory buffers. More... | |
| void | serialize (CheckpointOut &cp) const override |
| Serialize an object. More... | |
| void | unserialize (CheckpointIn &cp) override |
| Unserialize an object. More... | |
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. More... | |
| void | setCurTick (Tick newVal) |
| EventManager (EventManager &em) | |
| Event manger manages events in the event queue. More... | |
| 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. More... | |
| void | serializeSection (CheckpointOut &cp, const std::string &name) const |
| void | unserializeSection (CheckpointIn &cp, const char *name) |
| Unserialize an a child object. More... | |
| 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. More... | |
| virtual void | notifyFork () |
| Notify a child process of a fork. More... | |
Public Member Functions inherited from gem5::statistics::Group | |
| Group (Group *parent, const char *name=nullptr) | |
| Construct a new statistics group. More... | |
| virtual | ~Group () |
| virtual void | regStats () |
| Callback to set stat parameters. More... | |
| virtual void | resetStats () |
| Callback to reset stats. More... | |
| virtual void | preDumpStats () |
| Callback before stats are dumped. More... | |
| void | addStat (statistics::Info *info) |
| Register a stat with this group. More... | |
| const std::map< std::string, Group * > & | getStatGroups () const |
| Get all child groups associated with this object. More... | |
| const std::vector< Info * > & | getStats () const |
| Get all stats associated with this object. More... | |
| void | addStatGroup (const char *name, Group *block) |
| Add a stat block as a child of this block. More... | |
| const Info * | resolveStat (std::string name) const |
| Resolve a stat by its name within this group. More... | |
| void | mergeStatGroup (Group *block) |
| Merge the contents (stats & children) of a block to this block. More... | |
| 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 (RiscvISA::PrivilegeMode pmode, BaseMMU::Mode mode, ThreadContext *tc) |
| This function is called during a memory access to determine if the pmp table should be consulted for this access. More... | |
| Fault | createAddrfault (Addr vaddr, BaseMMU::Mode mode) |
| createAddrfault creates an address fault if the pmp checks fail to pass for a given access. More... | |
| 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. More... | |
| uint8_t | pmpGetAField (uint8_t cfg) |
| pmpGetAField extracts the A field (address matching mode) from an input pmpcfg register More... | |
| 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). More... | |
Private Attributes | |
| int | pmpEntries |
| maximum number of entries in the pmp table More... | |
| const uint8_t | PMP_READ = 1 << 0 |
| pmpcfg address range read permission mask More... | |
| const uint8_t | PMP_WRITE = 1 << 1 |
| pmpcfg address range write permission mask More... | |
| const uint8_t | PMP_EXEC = 1 << 2 |
| pmpcfg address range execute permission mask More... | |
| const uint8_t | PMP_LOCK = 1 << 7 |
| pmpcfg address range locked mask More... | |
| int | numRules |
| variable to keep track of active number of rules any time More... | |
| std::vector< PmpEntry > | pmpTable |
| a table of pmp entries More... | |
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. More... | |
| static SimObject * | find (const char *name) |
| Find the SimObject with the given name and return a pointer to it. More... | |
| static void | setSimObjectResolver (SimObjectResolver *resolver) |
| There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. More... | |
| static SimObjectResolver * | getSimObjectResolver () |
| There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. More... | |
Static Public Member Functions inherited from gem5::Serializable | |
| static const std::string & | currentSection () |
| Gets the fully-qualified name of the active section. More... | |
| static void | generateCheckpointOut (const std::string &cpt_dir, std::ofstream &outstream) |
| Generate a checkpoint file so that the serialization can be routed to it. More... | |
Protected Member Functions inherited from gem5::Drainable | |
| Drainable () | |
| virtual | ~Drainable () |
| virtual void | drainResume () |
| Resume execution after a successful drain. More... | |
| void | signalDrainDone () const |
| Signal that an object is drained. More... | |
Protected Attributes inherited from gem5::SimObject | |
| const SimObjectParams & | _params |
| Cached copy of the object parameters. More... | |
Protected Attributes inherited from gem5::EventManager | |
| EventQueue * | eventq |
| A pointer to this object's event queue. More... | |
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::PMP::PMP | ( | const Params & | params | ) |
Definition at line 47 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 130 of file pmp.cc.
References gem5::RiscvISA::INST_ACCESS, gem5::RiscvISA::LOAD_ACCESS, gem5::ArmISA::mode, gem5::BaseMMU::Read, gem5::RiscvISA::STORE_ACCESS, gem5::MipsISA::vaddr, warn, and gem5::BaseMMU::Write.
Referenced by pmpCheck().
| gem5::PMP::PARAMS | ( | PMP | ) |
| Fault gem5::PMP::pmpCheck | ( | const RequestPtr & | req, |
| BaseMMU::Mode | mode, | ||
| RiscvISA::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 execution (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 56 of file pmp.cc.
References gem5::AddrRange::contains(), createAddrfault(), DPRINTF, gem5::ArmISA::i, gem5::ArmISA::mode, gem5::NoFault, numRules, PMP_EXEC, PMP_OFF, PMP_READ, PMP_WRITE, pmpGetAField(), pmpTable, gem5::RiscvISA::PRV_M, shouldCheckPMP(), and gem5::MipsISA::vaddr.
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 254 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 145 of file pmp.cc.
References gem5::ArmISA::a.
Referenced by pmpCheck(), and pmpUpdateRule().
| void gem5::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 216 of file pmp.cc.
References DPRINTF, gem5::MipsISA::index, pmpEntries, pmpTable, and pmpUpdateRule().
| void gem5::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 154 of file pmp.cc.
References DPRINTF, PMP_LOCK, pmpTable, pmpUpdateRule(), and warn_if.
|
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 167 of file pmp.cc.
References gem5::ArmISA::i, numRules, PMP_NA4, PMP_NAPOT, PMP_OFF, PMP_TOR, pmpDecodeNapot(), pmpEntries, pmpGetAField(), and pmpTable.
Referenced by 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 execution (U, S, M). |
| mode | mode of request (read, write, execute). |
| tc | thread context. |
Definition at line 231 of file pmp.cc.
References gem5::BaseMMU::Execute, gem5::RiscvISA::MISCREG_STATUS, gem5::ArmISA::mode, gem5::RiscvISA::PRV_M, gem5::ThreadContext::readMiscRegNoEffect(), and gem5::ArmISA::status.
Referenced by pmpCheck().
|
private |
variable to keep track of active number of rules any time
Definition at line 92 of file pmp.hh.
Referenced by pmpCheck(), and pmpUpdateRule().
|
private |
pmpcfg address range execute permission mask
Definition at line 86 of file pmp.hh.
Referenced by pmpCheck().
|
private |
pmpcfg address range locked mask
Definition at line 89 of file pmp.hh.
Referenced by pmpUpdateCfg().
|
private |
pmpcfg address range read permission mask
Definition at line 80 of file pmp.hh.
Referenced by pmpCheck().
|
private |
pmpcfg address range write permission mask
Definition at line 83 of file pmp.hh.
Referenced by pmpCheck().
|
private |
maximum number of entries in the pmp table
Definition at line 61 of file pmp.hh.
Referenced by PMP(), pmpUpdateAddr(), and pmpUpdateRule().
|
private |
a table of pmp entries
Definition at line 106 of file pmp.hh.
Referenced by PMP(), pmpCheck(), pmpUpdateAddr(), pmpUpdateCfg(), and pmpUpdateRule().