arch-riscv: Initial the privilege modes configuration
1. Declare the new enum type PrivilegeModes 2. Disallow setting the MISA register RVU and RVS. Change-Id: I932d714bc70c9720a706353c557a5be76c950f81
This commit is contained in:
@@ -74,6 +74,16 @@ class RiscvType(Enum):
|
||||
vals = ["RV32", "RV64"]
|
||||
|
||||
|
||||
class PrivilegeModeSet(Enum):
|
||||
vals = [
|
||||
"M", # Machine privilege mode only
|
||||
"MU", # Machine and user privlege modes implemented
|
||||
"MNU", # MU privilege modes with user-mode trap
|
||||
"MSU", # Machine, supervisor and user modes implemented
|
||||
"MNSU", # MSU privilege modes with user-mode trap
|
||||
]
|
||||
|
||||
|
||||
class RiscvISA(BaseISA):
|
||||
type = "RiscvISA"
|
||||
cxx_class = "gem5::RiscvISA::ISA"
|
||||
@@ -95,6 +105,11 @@ class RiscvISA(BaseISA):
|
||||
"Length of each vector element in bits. \
|
||||
ELEN in Ch. 2 of RISC-V vector spec",
|
||||
)
|
||||
privilege_mode_set = Param.PrivilegeModeSet(
|
||||
"MSU",
|
||||
"The combination of privilege modes \
|
||||
in Privilege Levels section of RISC-V privileged spec",
|
||||
)
|
||||
|
||||
enable_Zicbom_fs = Param.Bool(True, "Enable Zicbom extension in FS mode")
|
||||
enable_Zicboz_fs = Param.Bool(True, "Enable Zicboz extension in FS mode")
|
||||
|
||||
@@ -73,7 +73,7 @@ SimObject('RiscvFsWorkload.py',
|
||||
SimObject('RiscvInterrupts.py', sim_objects=['RiscvInterrupts'],
|
||||
tags='riscv isa')
|
||||
SimObject('RiscvISA.py', sim_objects=['RiscvISA'],
|
||||
enums=['RiscvType'], tags='riscv isa')
|
||||
enums=['RiscvType', 'PrivilegeModeSet'], tags='riscv isa')
|
||||
SimObject('RiscvMMU.py', sim_objects=['RiscvMMU'], tags='riscv isa')
|
||||
SimObject('RiscvSeWorkload.py', sim_objects=[
|
||||
'RiscvSEWorkload', 'RiscvEmuLinux'], tags='riscv isa')
|
||||
|
||||
@@ -254,9 +254,10 @@ RegClass ccRegClass(CCRegClass, CCRegClassName, 0, debug::IntRegs);
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
ISA::ISA(const Params &p) :BaseISA(p),
|
||||
ISA::ISA(const Params &p) : BaseISA(p),
|
||||
_rvType(p.riscv_type), checkAlignment(p.check_alignment),
|
||||
enableRvv(p.enable_rvv),vlen(p.vlen),elen(p.elen)
|
||||
enableRvv(p.enable_rvv), vlen(p.vlen), elen(p.elen),
|
||||
_privilegeModeSet(p.privilege_mode_set)
|
||||
{
|
||||
_regClasses.push_back(&intRegClass);
|
||||
_regClasses.push_back(&floatRegClass);
|
||||
@@ -324,8 +325,25 @@ void ISA::clear()
|
||||
|
||||
// default config arch isa string is rv64(32)imafdc
|
||||
misa.rvi = misa.rvm = misa.rva = misa.rvf = misa.rvd = misa.rvc = 1;
|
||||
// default privlege modes if MSU
|
||||
misa.rvs = misa.rvu = 1;
|
||||
|
||||
switch (getPrivilegeModeSet()) {
|
||||
case enums::M:
|
||||
break;
|
||||
case enums::MU:
|
||||
misa.rvu = 1;
|
||||
break;
|
||||
case enums::MNU:
|
||||
misa.rvu = misa.rvn = 1;
|
||||
break;
|
||||
case enums::MSU:
|
||||
misa.rvs = misa.rvu = 1;
|
||||
break;
|
||||
case enums::MNSU:
|
||||
misa.rvs = misa.rvu = misa.rvn = 1;
|
||||
break;
|
||||
default:
|
||||
panic("Privilege mode set config should not reach here");
|
||||
}
|
||||
|
||||
// mark FS is initial
|
||||
status.fs = INITIAL;
|
||||
@@ -697,6 +715,9 @@ ISA::setMiscReg(RegIndex idx, RegVal val)
|
||||
if (!getEnableRvv()) {
|
||||
new_misa.rvv = 0;
|
||||
}
|
||||
new_misa.rvn = cur_misa.rvn;
|
||||
new_misa.rvs = cur_misa.rvs;
|
||||
new_misa.rvu = cur_misa.rvu;
|
||||
setMiscRegNoEffect(idx, new_misa);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -94,6 +94,11 @@ class ISA : public BaseISA
|
||||
*/
|
||||
unsigned elen;
|
||||
|
||||
/** The combination of privilege modes
|
||||
* in Privilege Levels section of RISC-V privileged spec
|
||||
*/
|
||||
PrivilegeModeSet _privilegeModeSet;
|
||||
|
||||
public:
|
||||
using Params = RiscvISAParams;
|
||||
|
||||
@@ -164,6 +169,8 @@ class ISA : public BaseISA
|
||||
unsigned getVecLenInBytes() { return vlen >> 3; }
|
||||
unsigned getVecElemLenInBits() { return elen; }
|
||||
|
||||
PrivilegeModeSet getPrivilegeModeSet() { return _privilegeModeSet; }
|
||||
|
||||
virtual Addr getFaultHandlerAddr(
|
||||
RegIndex idx, uint64_t cause, bool intr) const;
|
||||
};
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
#include "arch/generic/pcstate.hh"
|
||||
#include "arch/riscv/regs/vector.hh"
|
||||
#include "enums/PrivilegeModeSet.hh"
|
||||
#include "enums/RiscvType.hh"
|
||||
|
||||
namespace gem5
|
||||
@@ -55,6 +56,8 @@ using RiscvType = enums::RiscvType;
|
||||
constexpr enums::RiscvType RV32 = enums::RV32;
|
||||
constexpr enums::RiscvType RV64 = enums::RV64;
|
||||
|
||||
using PrivilegeModeSet = enums::PrivilegeModeSet;
|
||||
|
||||
class PCState : public GenericISA::UPCState<4>
|
||||
{
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user