arch-riscv: Check CSR before executing VMem instructions (#187)
Any instructions require vector register should check if vector is enabled. Any instructions need vtype CSR to execute them should check vill bit beforehead.
This commit is contained in:
@@ -137,6 +137,8 @@ Fault
|
||||
return std::make_shared<IllegalInstFault>(
|
||||
"RVV is disabled or VPU is off", machInst);
|
||||
}
|
||||
if (machInst.vill)
|
||||
return std::make_shared<IllegalInstFault>("VILL is set", machInst);
|
||||
if(!machInst.vm) {
|
||||
xc->getRegOperand(this, _numSrcRegs - 1, &tmp_v0);
|
||||
v0 = tmp_v0.as<uint8_t>();
|
||||
@@ -175,6 +177,15 @@ Fault
|
||||
%(op_rd)s;
|
||||
%(ea_code)s;
|
||||
|
||||
MISA misa = xc->readMiscReg(MISCREG_ISA);
|
||||
STATUS status = xc->readMiscReg(MISCREG_STATUS);
|
||||
if (!misa.rvv || status.vs == VPUStatus::OFF) {
|
||||
return std::make_shared<IllegalInstFault>(
|
||||
"RVV is disabled or VPU is off", machInst);
|
||||
}
|
||||
if (machInst.vill)
|
||||
return std::make_shared<IllegalInstFault>("VILL is set", machInst);
|
||||
|
||||
uint32_t mem_size = width_EEW(this->machInst.width) / 8 * this->microVl;
|
||||
const std::vector<bool> byte_enable(mem_size, true);
|
||||
Fault fault = initiateMemRead(xc, EA, mem_size, memAccessFlags,
|
||||
@@ -297,6 +308,8 @@ Fault
|
||||
return std::make_shared<IllegalInstFault>(
|
||||
"RVV is disabled or VPU is off", machInst);
|
||||
}
|
||||
if (machInst.vill)
|
||||
return std::make_shared<IllegalInstFault>("VILL is set", machInst);
|
||||
if(!machInst.vm) {
|
||||
xc->getRegOperand(this, _numSrcRegs - 1, &tmp_v0);
|
||||
v0 = tmp_v0.as<uint8_t>();
|
||||
@@ -338,6 +351,14 @@ Fault
|
||||
|
||||
RiscvISA::vreg_t tmp_v0;
|
||||
uint8_t *v0;
|
||||
MISA misa = xc->readMiscReg(MISCREG_ISA);
|
||||
STATUS status = xc->readMiscReg(MISCREG_STATUS);
|
||||
if (!misa.rvv || status.vs == VPUStatus::OFF) {
|
||||
return std::make_shared<IllegalInstFault>(
|
||||
"RVV is disabled or VPU is off", machInst);
|
||||
}
|
||||
if (machInst.vill)
|
||||
return std::make_shared<IllegalInstFault>("VILL is set", machInst);
|
||||
if(!machInst.vm) {
|
||||
xc->getRegOperand(this, _numSrcRegs - 1, &tmp_v0);
|
||||
v0 = tmp_v0.as<uint8_t>();
|
||||
@@ -522,6 +543,12 @@ Fault
|
||||
trace::InstRecord* traceData) const
|
||||
{
|
||||
Addr EA;
|
||||
MISA misa = xc->readMiscReg(MISCREG_ISA);
|
||||
STATUS status = xc->readMiscReg(MISCREG_STATUS);
|
||||
if (!misa.rvv || status.vs == VPUStatus::OFF) {
|
||||
return std::make_shared<IllegalInstFault>(
|
||||
"RVV is disabled or VPU is off", machInst);
|
||||
}
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
%(ea_code)s;
|
||||
@@ -642,6 +669,12 @@ Fault
|
||||
trace::InstRecord* traceData) const
|
||||
{
|
||||
Addr EA;
|
||||
MISA misa = xc->readMiscReg(MISCREG_ISA);
|
||||
STATUS status = xc->readMiscReg(MISCREG_STATUS);
|
||||
if (!misa.rvv || status.vs == VPUStatus::OFF) {
|
||||
return std::make_shared<IllegalInstFault>(
|
||||
"RVV is disabled or VPU is off", machInst);
|
||||
}
|
||||
%(op_src_decl)s;
|
||||
%(op_rd)s;
|
||||
%(ea_code)s;
|
||||
@@ -761,6 +794,8 @@ Fault
|
||||
return std::make_shared<IllegalInstFault>(
|
||||
"RVV is disabled or VPU is off", machInst);
|
||||
}
|
||||
if (machInst.vill)
|
||||
return std::make_shared<IllegalInstFault>("VILL is set", machInst);
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
constexpr uint8_t elem_size = sizeof(Vd[0]);
|
||||
@@ -799,7 +834,14 @@ Fault
|
||||
{
|
||||
Fault fault = NoFault;
|
||||
Addr EA;
|
||||
|
||||
MISA misa = xc->readMiscReg(MISCREG_ISA);
|
||||
STATUS status = xc->readMiscReg(MISCREG_STATUS);
|
||||
if (!misa.rvv || status.vs == VPUStatus::OFF) {
|
||||
return std::make_shared<IllegalInstFault>(
|
||||
"RVV is disabled or VPU is off", machInst);
|
||||
}
|
||||
if (machInst.vill)
|
||||
return std::make_shared<IllegalInstFault>("VILL is set", machInst);
|
||||
%(op_src_decl)s;
|
||||
%(op_rd)s;
|
||||
constexpr uint8_t elem_size = sizeof(Vd[0]);
|
||||
@@ -953,6 +995,8 @@ Fault
|
||||
return std::make_shared<IllegalInstFault>(
|
||||
"RVV is disabled or VPU is off", machInst);
|
||||
}
|
||||
if (machInst.vill)
|
||||
return std::make_shared<IllegalInstFault>("VILL is set", machInst);
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
constexpr uint8_t elem_size = sizeof(Vs3[0]);
|
||||
@@ -987,7 +1031,14 @@ Fault
|
||||
{
|
||||
Fault fault = NoFault;
|
||||
Addr EA;
|
||||
|
||||
MISA misa = xc->readMiscReg(MISCREG_ISA);
|
||||
STATUS status = xc->readMiscReg(MISCREG_STATUS);
|
||||
if (!misa.rvv || status.vs == VPUStatus::OFF) {
|
||||
return std::make_shared<IllegalInstFault>(
|
||||
"RVV is disabled or VPU is off", machInst);
|
||||
}
|
||||
if (machInst.vill)
|
||||
return std::make_shared<IllegalInstFault>("VILL is set", machInst);
|
||||
RiscvISA::vreg_t tmp_v0;
|
||||
uint8_t *v0;
|
||||
if(!machInst.vm) {
|
||||
@@ -1126,6 +1177,8 @@ Fault
|
||||
return std::make_shared<IllegalInstFault>(
|
||||
"RVV is disabled or VPU is off", machInst);
|
||||
}
|
||||
if (machInst.vill)
|
||||
return std::make_shared<IllegalInstFault>("VILL is set", machInst);
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
%(ea_code)s;
|
||||
@@ -1165,7 +1218,14 @@ Fault
|
||||
using vu = std::make_unsigned_t<ElemType>;
|
||||
Fault fault = NoFault;
|
||||
Addr EA;
|
||||
|
||||
MISA misa = xc->readMiscReg(MISCREG_ISA);
|
||||
STATUS status = xc->readMiscReg(MISCREG_STATUS);
|
||||
if (!misa.rvv || status.vs == VPUStatus::OFF) {
|
||||
return std::make_shared<IllegalInstFault>(
|
||||
"RVV is disabled or VPU is off", machInst);
|
||||
}
|
||||
if (machInst.vill)
|
||||
return std::make_shared<IllegalInstFault>("VILL is set", machInst);
|
||||
%(op_src_decl)s;
|
||||
%(op_rd)s;
|
||||
constexpr uint8_t elem_size = sizeof(Vd[0]);
|
||||
@@ -1327,6 +1387,8 @@ Fault
|
||||
return std::make_shared<IllegalInstFault>(
|
||||
"RVV is disabled or VPU is off", machInst);
|
||||
}
|
||||
if (machInst.vill)
|
||||
return std::make_shared<IllegalInstFault>("VILL is set", machInst);
|
||||
%(op_decl)s;
|
||||
%(op_rd)s;
|
||||
%(ea_code)s;
|
||||
@@ -1362,7 +1424,14 @@ Fault
|
||||
using vu = std::make_unsigned_t<ElemType>;
|
||||
Fault fault = NoFault;
|
||||
Addr EA;
|
||||
|
||||
MISA misa = xc->readMiscReg(MISCREG_ISA);
|
||||
STATUS status = xc->readMiscReg(MISCREG_STATUS);
|
||||
if (!misa.rvv || status.vs == VPUStatus::OFF) {
|
||||
return std::make_shared<IllegalInstFault>(
|
||||
"RVV is disabled or VPU is off", machInst);
|
||||
}
|
||||
if (machInst.vill)
|
||||
return std::make_shared<IllegalInstFault>("VILL is set", machInst);
|
||||
%(op_src_decl)s;
|
||||
%(op_rd)s;
|
||||
%(ea_code)s;
|
||||
|
||||
Reference in New Issue
Block a user