gem5 [DEVELOP-FOR-25.1]
Loading...
Searching...
No Matches
isa.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 RISC-V Foundation
3 * Copyright (c) 2016 The University of Virginia
4 * Copyright (c) 2020 Barkhausen Institut
5 * Copyright (c) 2022 Google LLC
6 * Copyright (c) 2024 University of Rostock
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are
11 * met: redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer;
13 * redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution;
16 * neither the name of the copyright holders nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include "arch/riscv/isa.hh"
34
35#include <ctime>
36#include <set>
37#include <sstream>
38
39#include "arch/riscv/faults.hh"
42#include "arch/riscv/mmu.hh"
44#include "arch/riscv/pcstate.hh"
45#include "arch/riscv/pmp.hh"
50#include "arch/riscv/system.hh"
51#include "base/bitfield.hh"
52#include "base/compiler.hh"
53#include "base/logging.hh"
54#include "base/trace.hh"
55#include "cpu/base.hh"
56#include "debug/Checkpoint.hh"
57#include "debug/LLSC.hh"
58#include "debug/MatRegs.hh"
59#include "debug/RiscvMisc.hh"
60#include "debug/VecRegs.hh"
61#include "dev/riscv/clint.hh"
62#include "mem/packet.hh"
63#include "mem/request.hh"
64#include "params/RiscvISA.hh"
65#include "sim/pseudo_inst.hh"
66
67namespace gem5
68{
69
70namespace RiscvISA
71{
72
73[[maybe_unused]]
74const std::array<const char *, NUM_MISCREGS> MiscRegNames = {{
75 [MISCREG_PRV] = "PRV",
76 [MISCREG_ISA] = "ISA",
77 [MISCREG_VENDORID] = "VENDORID",
78 [MISCREG_ARCHID] = "ARCHID",
79 [MISCREG_IMPID] = "IMPID",
80 [MISCREG_HARTID] = "HARTID",
81 [MISCREG_STATUS] = "STATUS",
82 [MISCREG_IP] = "IP",
83 [MISCREG_IE] = "IE",
84 [MISCREG_CYCLE] = "CYCLE",
85 [MISCREG_TIME] = "TIME",
86 [MISCREG_INSTRET] = "INSTRET",
87 [MISCREG_HPMCOUNTER03] = "HPMCOUNTER03",
88 [MISCREG_HPMCOUNTER04] = "HPMCOUNTER04",
89 [MISCREG_HPMCOUNTER05] = "HPMCOUNTER05",
90 [MISCREG_HPMCOUNTER06] = "HPMCOUNTER06",
91 [MISCREG_HPMCOUNTER07] = "HPMCOUNTER07",
92 [MISCREG_HPMCOUNTER08] = "HPMCOUNTER08",
93 [MISCREG_HPMCOUNTER09] = "HPMCOUNTER09",
94 [MISCREG_HPMCOUNTER10] = "HPMCOUNTER10",
95 [MISCREG_HPMCOUNTER11] = "HPMCOUNTER11",
96 [MISCREG_HPMCOUNTER12] = "HPMCOUNTER12",
97 [MISCREG_HPMCOUNTER13] = "HPMCOUNTER13",
98 [MISCREG_HPMCOUNTER14] = "HPMCOUNTER14",
99 [MISCREG_HPMCOUNTER15] = "HPMCOUNTER15",
100 [MISCREG_HPMCOUNTER16] = "HPMCOUNTER16",
101 [MISCREG_HPMCOUNTER17] = "HPMCOUNTER17",
102 [MISCREG_HPMCOUNTER18] = "HPMCOUNTER18",
103 [MISCREG_HPMCOUNTER19] = "HPMCOUNTER19",
104 [MISCREG_HPMCOUNTER20] = "HPMCOUNTER20",
105 [MISCREG_HPMCOUNTER21] = "HPMCOUNTER21",
106 [MISCREG_HPMCOUNTER22] = "HPMCOUNTER22",
107 [MISCREG_HPMCOUNTER23] = "HPMCOUNTER23",
108 [MISCREG_HPMCOUNTER24] = "HPMCOUNTER24",
109 [MISCREG_HPMCOUNTER25] = "HPMCOUNTER25",
110 [MISCREG_HPMCOUNTER26] = "HPMCOUNTER26",
111 [MISCREG_HPMCOUNTER27] = "HPMCOUNTER27",
112 [MISCREG_HPMCOUNTER28] = "HPMCOUNTER28",
113 [MISCREG_HPMCOUNTER29] = "HPMCOUNTER29",
114 [MISCREG_HPMCOUNTER30] = "HPMCOUNTER30",
115 [MISCREG_HPMCOUNTER31] = "HPMCOUNTER31",
116 [MISCREG_HPMEVENT03] = "HPMEVENT03",
117 [MISCREG_HPMEVENT04] = "HPMEVENT04",
118 [MISCREG_HPMEVENT05] = "HPMEVENT05",
119 [MISCREG_HPMEVENT06] = "HPMEVENT06",
120 [MISCREG_HPMEVENT07] = "HPMEVENT07",
121 [MISCREG_HPMEVENT08] = "HPMEVENT08",
122 [MISCREG_HPMEVENT09] = "HPMEVENT09",
123 [MISCREG_HPMEVENT10] = "HPMEVENT10",
124 [MISCREG_HPMEVENT11] = "HPMEVENT11",
125 [MISCREG_HPMEVENT12] = "HPMEVENT12",
126 [MISCREG_HPMEVENT13] = "HPMEVENT13",
127 [MISCREG_HPMEVENT14] = "HPMEVENT14",
128 [MISCREG_HPMEVENT15] = "HPMEVENT15",
129 [MISCREG_HPMEVENT16] = "HPMEVENT16",
130 [MISCREG_HPMEVENT17] = "HPMEVENT17",
131 [MISCREG_HPMEVENT18] = "HPMEVENT18",
132 [MISCREG_HPMEVENT19] = "HPMEVENT19",
133 [MISCREG_HPMEVENT20] = "HPMEVENT20",
134 [MISCREG_HPMEVENT21] = "HPMEVENT21",
135 [MISCREG_HPMEVENT22] = "HPMEVENT22",
136 [MISCREG_HPMEVENT23] = "HPMEVENT23",
137 [MISCREG_HPMEVENT24] = "HPMEVENT24",
138 [MISCREG_HPMEVENT25] = "HPMEVENT25",
139 [MISCREG_HPMEVENT26] = "HPMEVENT26",
140 [MISCREG_HPMEVENT27] = "HPMEVENT27",
141 [MISCREG_HPMEVENT28] = "HPMEVENT28",
142 [MISCREG_HPMEVENT29] = "HPMEVENT29",
143 [MISCREG_HPMEVENT30] = "HPMEVENT30",
144 [MISCREG_HPMEVENT31] = "HPMEVENT31",
145 [MISCREG_TSELECT] = "TSELECT",
146 [MISCREG_TDATA1] = "TDATA1",
147 [MISCREG_TDATA2] = "TDATA2",
148 [MISCREG_TDATA3] = "TDATA3",
149 [MISCREG_DCSR] = "DCSR",
150 [MISCREG_DPC] = "DPC",
151 [MISCREG_DSCRATCH] = "DSCRATCH",
152
153 [MISCREG_MEDELEG] = "MEDELEG",
154 [MISCREG_MIDELEG] = "MIDELEG",
155 [MISCREG_MTVEC] = "MTVEC",
156 [MISCREG_MCOUNTEREN] = "MCOUNTEREN",
157 [MISCREG_MSCRATCH] = "MSCRATCH",
158 [MISCREG_MEPC] = "MEPC",
159 [MISCREG_MCAUSE] = "MCAUSE",
160 [MISCREG_MTVAL] = "MTVAL",
161 [MISCREG_PMPCFG0] = "PMPCFG0",
162 [MISCREG_PMPCFG1] = "PMPCFG1", // pmpcfg1 is rv32 only
163 [MISCREG_PMPCFG2] = "PMPCFG2",
164 [MISCREG_PMPCFG3] = "PMPCFG3", // pmpcfg3 is rv32 only
165 [MISCREG_PMPADDR00] = "PMPADDR00",
166 [MISCREG_PMPADDR01] = "PMPADDR01",
167 [MISCREG_PMPADDR02] = "PMPADDR02",
168 [MISCREG_PMPADDR03] = "PMPADDR03",
169 [MISCREG_PMPADDR04] = "PMPADDR04",
170 [MISCREG_PMPADDR05] = "PMPADDR05",
171 [MISCREG_PMPADDR06] = "PMPADDR06",
172 [MISCREG_PMPADDR07] = "PMPADDR07",
173 [MISCREG_PMPADDR08] = "PMPADDR08",
174 [MISCREG_PMPADDR09] = "PMPADDR09",
175 [MISCREG_PMPADDR10] = "PMPADDR10",
176 [MISCREG_PMPADDR11] = "PMPADDR11",
177 [MISCREG_PMPADDR12] = "PMPADDR12",
178 [MISCREG_PMPADDR13] = "PMPADDR13",
179 [MISCREG_PMPADDR14] = "PMPADDR14",
180 [MISCREG_PMPADDR15] = "PMPADDR15",
181
182 [MISCREG_RESERVED01] = "",
183 [MISCREG_RESERVED02] = "",
184 [MISCREG_STVEC] = "STVEC",
185 [MISCREG_SCOUNTEREN] = "SCOUNTEREN",
186 [MISCREG_SSCRATCH] = "SSCRATCH",
187 [MISCREG_SEPC] = "SEPC",
188 [MISCREG_SCAUSE] = "SCAUSE",
189 [MISCREG_STVAL] = "STVAL",
190 [MISCREG_SATP] = "SATP",
191 [MISCREG_SENVCFG] = "SENVCFG",
192
193 [MISCREG_RESERVED03] = "",
194 [MISCREG_RESERVED04] = "",
195 [MISCREG_RESERVED05] = "",
196 [MISCREG_RESERVED06] = "",
197 [MISCREG_RESERVED07] = "",
198 [MISCREG_FFLAGS] = "FFLAGS",
199 [MISCREG_FRM] = "FRM",
200
201 [MISCREG_VSTART] = "VSTART",
202 [MISCREG_VXSAT] = "VXSAT",
203 [MISCREG_VXRM] = "VXRM",
204 [MISCREG_VCSR] = "VCSR",
205 [MISCREG_VL] = "VL",
206 [MISCREG_VTYPE] = "VTYPE",
207 [MISCREG_VLENB] = "VLENB",
208
209 // H-extension (RV64) registers
210
211 [MISCREG_HVIP] = "HVIP",
212
213 [MISCREG_MTINST] = "MTINST",
214 [MISCREG_MTVAL2] = "MTVAL2",
215
216 [MISCREG_HSTATUS] = "HSTATUS",
217 [MISCREG_HEDELEG] = "HEDELEG",
218 [MISCREG_HIDELEG] = "HIDELEG",
219 [MISCREG_HCOUNTEREN] = "HCOUNTEREN",
220 [MISCREG_HGEIE] = "HGEIE",
221 [MISCREG_HTVAL] = "HTVAL",
222 [MISCREG_HTINST] = "HTINST",
223 [MISCREG_HGEIP] = "HGEIP",
224
225 [MISCREG_HENVCFG] = "HENVCFG",
226 [MISCREG_HGATP] = "HGATP",
227 [MISCREG_HCONTEXT] = "HCONTEXT",
228 [MISCREG_HTIMEDELTA] = "HTIMEDELTA",
229
230 [MISCREG_VSSTATUS] = "VSSTATUS",
231 [MISCREG_VSTVEC] = "VSTVEC",
232 [MISCREG_VSSCRATCH] = "VSSCRATCH",
233 [MISCREG_VSEPC] = "VSEPC",
234 [MISCREG_VSCAUSE] = "VSCAUSE",
235 [MISCREG_VSTVAL] = "VSTVAL",
236 [MISCREG_VSATP] = "VSATP",
237 [MISCREG_VIRT] = "VIRT",
238
239 // H-extension (RV64) registers end here
240
241 [MISCREG_NMIVEC] = "NMIVEC",
242 [MISCREG_NMIE] = "NMIE",
243 [MISCREG_NMIP] = "NMIP",
244 [MISCREG_MNSCRATCH] = "MNSCRATCH",
245 [MISCREG_MNEPC] = "MNEPC",
246 [MISCREG_MNCAUSE] = "MNCAUSE",
247 [MISCREG_MNSTATUS] = "MNSTATUS",
248
249 // following are rv32 only registers
250 [MISCREG_MSTATUSH] = "MSTATUSH",
251
252 [MISCREG_CYCLEH] = "CYCLEH",
253 [MISCREG_TIMEH] = "TIMEH",
254 [MISCREG_INSTRETH] = "INSTRETH",
255 [MISCREG_HPMCOUNTER03H] = "HPMCOUNTER03H",
256 [MISCREG_HPMCOUNTER04H] = "HPMCOUNTER04H",
257 [MISCREG_HPMCOUNTER05H] = "HPMCOUNTER05H",
258 [MISCREG_HPMCOUNTER06H] = "HPMCOUNTER06H",
259 [MISCREG_HPMCOUNTER07H] = "HPMCOUNTER07H",
260 [MISCREG_HPMCOUNTER08H] = "HPMCOUNTER08H",
261 [MISCREG_HPMCOUNTER09H] = "HPMCOUNTER09H",
262 [MISCREG_HPMCOUNTER10H] = "HPMCOUNTER10H",
263 [MISCREG_HPMCOUNTER11H] = "HPMCOUNTER11H",
264 [MISCREG_HPMCOUNTER12H] = "HPMCOUNTER12H",
265 [MISCREG_HPMCOUNTER13H] = "HPMCOUNTER13H",
266 [MISCREG_HPMCOUNTER14H] = "HPMCOUNTER14H",
267 [MISCREG_HPMCOUNTER15H] = "HPMCOUNTER15H",
268 [MISCREG_HPMCOUNTER16H] = "HPMCOUNTER16H",
269 [MISCREG_HPMCOUNTER17H] = "HPMCOUNTER17H",
270 [MISCREG_HPMCOUNTER18H] = "HPMCOUNTER18H",
271 [MISCREG_HPMCOUNTER19H] = "HPMCOUNTER19H",
272 [MISCREG_HPMCOUNTER20H] = "HPMCOUNTER20H",
273 [MISCREG_HPMCOUNTER21H] = "HPMCOUNTER21H",
274 [MISCREG_HPMCOUNTER22H] = "HPMCOUNTER22H",
275 [MISCREG_HPMCOUNTER23H] = "HPMCOUNTER23H",
276 [MISCREG_HPMCOUNTER24H] = "HPMCOUNTER24H",
277 [MISCREG_HPMCOUNTER25H] = "HPMCOUNTER25H",
278 [MISCREG_HPMCOUNTER26H] = "HPMCOUNTER26H",
279 [MISCREG_HPMCOUNTER27H] = "HPMCOUNTER27H",
280 [MISCREG_HPMCOUNTER28H] = "HPMCOUNTER28H",
281 [MISCREG_HPMCOUNTER29H] = "HPMCOUNTER29H",
282 [MISCREG_HPMCOUNTER30H] = "HPMCOUNTER30H",
283 [MISCREG_HPMCOUNTER31H] = "HPMCOUNTER31H",
284
285 [MISCREG_JVT] = "JVT",
286
287 [MISCREG_FFLAGS_EXE] = "FFLAGS_EXE",
288}};
289
290namespace
291{
292
293/* Not applicable to RISCV */
296 debug::IntRegs);
298RegClass ccRegClass(CCRegClass, CCRegClassName, 0, debug::IntRegs);
299
300} // anonymous namespace
301
302ISA::ISA(const Params &p) : BaseISA(p, "riscv"),
303 _rvType(p.riscv_type), enableRvv(p.enable_rvv), vlen(p.vlen), elen(p.elen),
304 _privilegeModeSet(p.privilege_mode_set),
305 _wfiResumeOnPending(p.wfi_resume_on_pending), _enableZcd(p.enable_Zcd),
306 _enableSmrnmi(p.enable_Smrnmi)
307{
308 _regClasses.push_back(&intRegClass);
309 _regClasses.push_back(&floatRegClass);
310 _regClasses.push_back(&vecRegClass);
311 _regClasses.push_back(&vecElemClass);
312 _regClasses.push_back(&vecPredRegClass);
313 _regClasses.push_back(&matRegClass);
314 _regClasses.push_back(&ccRegClass);
315 _regClasses.push_back(&miscRegClass);
316
317 fatal_if( p.vlen < p.elen,
318 "VLEN should be greater or equal",
319 "than ELEN. Ch. 2RISC-V vector spec.");
320
321 inform("RVV enabled, VLEN = %d bits, ELEN = %d bits",
322 p.vlen, p.elen);
323
325 clear();
326}
327
328bool ISA::inUserMode() const
329{
330 return miscRegFile[MISCREG_PRV] == PRV_U;
331}
332
333void
335{
336 // First loop through the integer registers.
337 for (auto &id: intRegClass)
338 tc->setReg(id, src->getReg(id));
339
340 // Second loop through the float registers.
341 for (auto &id: floatRegClass)
342 tc->setReg(id, src->getReg(id));
343
344 // Third loop through the vector registers.
346 for (auto &id: vecRegClass) {
347 src->getReg(id, &vc);
348 tc->setReg(id, &vc);
349 }
350
351 // Copying Misc Regs
352 for (int i = 0; i < NUM_PHYS_MISCREGS; i++)
353 tc->setMiscRegNoEffect(i, src->readMiscRegNoEffect(i));
354
355 // Lastly copy PC/NPC
356 tc->pcState(src->pcState());
357}
358
360{
361 std::fill(miscRegFile.begin(), miscRegFile.end(), 0);
362
367
368 MISA misa = 0;
369 STATUS status = 0;
370
371 // default config arch isa string is rv64(32)imafdc
372 misa.rvi = misa.rvm = misa.rva = misa.rvf = misa.rvd = misa.rvc = 1;
373
374 switch (getPrivilegeModeSet()) {
375 case enums::M:
376 break;
377 case enums::MU:
378 misa.rvu = 1;
379 break;
380 case enums::MSU:
381 misa.rvs = misa.rvu = 1;
382 break;
383 case enums::MHSU:
384 misa.rvh = misa.rvs = misa.rvu = 1;
385 inform("RVH enabled.");
386 break;
387 default:
388 panic("Privilege mode set config should not reach here");
389 }
390
391 // mark FS is initial
393
394 // _rvType dependent init.
395 switch (_rvType) {
396 case RV32:
397 misa.rv32_mxl = 1;
398 break;
399 case RV64:
400 misa.rv64_mxl = 2;
401 status.uxl = status.sxl = 2;
402 if (misa.rvh) {
403 HSTATUS hstatus = 0;
404 hstatus.vsxl = 2;
405 miscRegFile[MISCREG_HSTATUS] = hstatus;
406
407 STATUS vsstatus = 0;
408 vsstatus.uxl = 2;
409 vsstatus.fs = FPUStatus::INITIAL;
410
411 if (getEnableRvv())
412 vsstatus.vs = VPUStatus::INITIAL;
413
414 miscRegFile[MISCREG_VSSTATUS] = vsstatus;
415 }
416 break;
417 default:
418 panic("%s: Unknown _rvType: %d", name(), (int)_rvType);
419 }
420 if (getEnableRvv()) {
422 misa.rvv = 1;
423 }
424
425 miscRegFile[MISCREG_ISA] = misa;
429 // don't set it to zero; software may try to determine the supported
430 // triggers, starting at zero. simply set a different value here.
433}
434
435Fault
437{
438 int hpmcounter = 0;
439 if (misc_reg >= MISCREG_CYCLEH) {
440 hpmcounter = misc_reg - MISCREG_CYCLEH;
441 } else {
442 hpmcounter = misc_reg - MISCREG_CYCLE;
443 }
444
445 if (hpmcounter < 0 || hpmcounter > 31)
446 panic("Illegal HPM counter %d\n", hpmcounter);
447
449 MISA misa = readMiscRegNoEffect(MISCREG_ISA);
450 RiscvSystem *sys = dynamic_cast<RiscvSystem *>(tc->getSystemPtr());
451 bool is_time_csr = misc_reg == MISCREG_TIME || misc_reg == MISCREG_TIMEH;
452
453 // Check if the clint is exists in system
454 if (is_time_csr && (sys == nullptr || sys->getClint() == nullptr)) {
455 return std::make_shared<IllegalInstFault>("Can't find CLINT in system",
456 machInst);
457 }
458
460 RegVal hcounteren = misa.rvh ? miscRegFile[MISCREG_HCOUNTEREN] : 0;
461 RegVal scounteren = misa.rvs ? miscRegFile[MISCREG_SCOUNTEREN] : 0;
462
463 // Paragraph 3.1.11 RISCV Privileged Spec 20211203
464 // firstly, respect mcounteren disallowing the counter
465 if (prv < PRV_M && (bits(mcounteren, hpmcounter) == 0)) {
466 return std::make_shared<IllegalInstFault>(
467 csprintf("Counter %s is disabled from mcounteren bit %d\n",
468 MiscRegNames[misc_reg], hpmcounter), machInst);
469 }
470
471 // then, if h-extension is on and virtualization
472 // is enabled, respect hcounteren for VS and VU
473 if (misa.rvh && virtualizationEnabled() && prv < PRV_HS &&
474 bits(hcounteren, hpmcounter) == 0)
475 {
476 return std::make_shared<VirtualInstFault>(
477 csprintf("Counter %s is disabled from hcounteren bit %d\n",
478 MiscRegNames[misc_reg], hpmcounter), machInst);
479 }
480
481 // finally, respect scounteren for PRV_U (either with V = 1 or 0)
482 if (prv == PRV_U && bits(scounteren, hpmcounter) == 0) {
483 return std::make_shared<IllegalInstFault>(
484 csprintf("Counter %s is disabled from scounteren bit %d\n",
485 MiscRegNames[misc_reg], hpmcounter), machInst);
486 }
487
488 return NoFault;
489}
490
491RegVal
493{
494 // Illegal CSR
495 panic_if(idx > NUM_PHYS_MISCREGS, "Illegal CSR index %#x\n", idx);
496 DPRINTF(RiscvMisc, "Reading MiscReg %s (%d): %#x.\n",
497 MiscRegNames[idx], idx, miscRegFile[idx]);
498 return miscRegFile[idx];
499}
500
501RegVal
503{
504 switch (idx) {
505 case MISCREG_HARTID:
506 return tc->contextId();
507 case MISCREG_CYCLE:
508 return static_cast<RegVal>(tc->getCpuPtr()->curCycle());
509 case MISCREG_CYCLEH:
510 return bits<RegVal>(tc->getCpuPtr()->curCycle(), 63, 32);
511 case MISCREG_TIME: {
512 RiscvSystem *sys = dynamic_cast<RiscvSystem *>(tc->getSystemPtr());
513 panic_if(!sys, "read MISCREG_TIME not in RiscvSystem");
514 return sys->tryReadMtime();
515 }
516 case MISCREG_TIMEH: {
517 RiscvSystem *sys = dynamic_cast<RiscvSystem *>(tc->getSystemPtr());
518 panic_if(!sys, "read MISCREG_TIME not in RiscvSystem");
519 return bits(sys->tryReadMtime(), 63, 32);
520 }
521 case MISCREG_INSTRET:
522 return static_cast<RegVal>(tc->getCpuPtr()->totalInsts());
523 case MISCREG_INSTRETH:
524 return bits<RegVal>(tc->getCpuPtr()->totalInsts(), 63, 32);
525 case MISCREG_IP:
526 {
527 auto ic = dynamic_cast<RiscvISA::Interrupts *>(
528 tc->getCpuPtr()->getInterruptController(tc->threadId()));
529 return ic->readIP();
530 }
531 case MISCREG_HVIP:
532 {
533 auto ic = dynamic_cast<RiscvISA::Interrupts *>(
534 tc->getCpuPtr()->getInterruptController(tc->threadId()));
535 return ic->readHVIP();
536 }
537 case MISCREG_IE:
538 {
539 auto ic = dynamic_cast<RiscvISA::Interrupts *>(
540 tc->getCpuPtr()->getInterruptController(tc->threadId()));
541 return ic->readIE();
542 }
543 case MISCREG_MIDELEG:
544 {
545 MISA misa = readMiscRegNoEffect(MISCREG_ISA);
546 auto mideleg_val = readMiscRegNoEffect(MISCREG_MIDELEG);
547
548 // Note: old versions of bbl don't like HS_INTERRUPTS on mideleg
549 // In those cases, the bootloader panics.
550 // You can replace with the line below, however H-extension
551 // is incomplete this way.
552 // we only check misa to avoid unused var error
553 // return misa.rvh ? mideleg_val : mideleg_val;
554 return misa.rvh ? mideleg_val | HS_INTERRUPTS : mideleg_val;
555
556 }
557 case MISCREG_SEPC:
558 case MISCREG_MEPC:
559 case MISCREG_MNEPC:
560 {
561 MISA misa = readMiscRegNoEffect(MISCREG_ISA);
562 auto val = readMiscRegNoEffect(idx);
563 // if compressed instructions are disabled, epc[1] is set to 0
564 if (misa.rvc == 0)
565 return mbits(val, 63, 2);
566 // epc[0] is always 0
567 else
568 return mbits(val, 63, 1);
569 }
570 case MISCREG_HSTATUS:
571 {
572 auto val = readMiscRegNoEffect(idx);
573 // hardwire vsxl
574 return val |= (2ULL << VSXL_OFFSET);
575 }
576 case MISCREG_VSSTATUS:
577 case MISCREG_STATUS:
578 {
579 // Updating the SD bit.
580 // . Per RISC-V ISA Manual, vol II, section 3.1.6.6, page 26,
581 // the SD bit is a read-only bit indicating whether any of
582 // FS, VS, and XS fields being in the respective dirty state.
583 // . Per section 3.1.6, page 20, the SD bit is the most
584 // significant bit of the MSTATUS CSR for both RV32 and RV64.
585 // . Per section 3.1.6.6, page 29, the explicit formula for
586 // updating the SD is,
587 // SD = ((FS==DIRTY) | (XS==DIRTY) | (VS==DIRTY))
588 // . Ideally, we want to update the SD after every relevant
589 // instruction, however, lazily updating the Status register
590 // upon its read produces the same effect as well.
591 STATUS status = readMiscRegNoEffect(idx);
592 uint64_t sd_bit = \
593 (status.xs == 3) || (status.fs == 3) || (status.vs == 3);
594 // For RV32, the SD bit is at index 31
595 // For RV64, the SD bit is at index 63.
596 switch (_rvType) {
597 case RV32:
598 status.rv32_sd = sd_bit;
599 break;
600 case RV64:
601 status.rv64_sd = sd_bit;
602 break;
603 default:
604 panic("%s: Unknown _rvType: %d", name(), (int)_rvType);
605 }
606 // Check status.mpp
607 MISA misa = readMiscRegNoEffect(MISCREG_ISA);
608 switch(status.mpp) {
609 case PRV_U:
610 status.mpp = (misa.rvu) ? PRV_U : PRV_M;
611 break;
612 case PRV_S:
613 if (misa.rvs)
614 status.mpp = PRV_S;
615 else
616 status.mpp = (misa.rvu) ? PRV_U : PRV_M;
617 break;
618 case PRV_M:
619 break;
620 default:
621 status.mpp = (misa.rvu) ? PRV_U : PRV_M;
622 }
623
625 return readMiscRegNoEffect(idx);
626 }
627 case MISCREG_VLENB:
628 {
629 return getVecLenInBytes();
630 }
631 case MISCREG_VTYPE:
632 {
633 auto rpc = tc->pcState().as<PCState>();
634 return rpc.vtype();
635 }
636 case MISCREG_VL:
637 {
638 auto rpc = tc->pcState().as<PCState>();
639 return (RegVal)rpc.vl();
640 }
641 case MISCREG_VCSR:
642 {
645 }
646 break;
647
648 case MISCREG_MNSTATUS:
649 {
650 NSTATUS nstatus = readMiscRegNoEffect(idx);
651 nstatus.nmie = readMiscRegNoEffect(MISCREG_NMIE);
652 // Check nstatus.mnpp
653 MISA misa = readMiscRegNoEffect(MISCREG_ISA);
654 switch(nstatus.mnpp) {
655 case PRV_U:
656 nstatus.mnpp = (misa.rvu) ? PRV_U : PRV_M;
657 break;
658 case PRV_S:
659 if (misa.rvs)
660 nstatus.mnpp = PRV_S;
661 else
662 nstatus.mnpp = (misa.rvu) ? PRV_U : PRV_M;
663 break;
664 case PRV_M:
665 break;
666 default:
667 nstatus.mnpp = (misa.rvu) ? PRV_U : PRV_M;
668 }
669 return nstatus;
670 }
671
673 {
675 }
676
677 default:
678 // Try reading HPM counters
679 // As a placeholder, all HPM counters are just cycle counters
680 if (idx >= MISCREG_HPMCOUNTER03 &&
681 idx <= MISCREG_HPMCOUNTER31) {
682 return tc->getCpuPtr()->curCycle();
683
684 } else if (idx >= MISCREG_HPMCOUNTER03H &&
685 idx <= MISCREG_HPMCOUNTER31H) {
686 return bits<RegVal>(tc->getCpuPtr()->curCycle(), 63, 32);
687 }
688 return readMiscRegNoEffect(idx);
689 }
690}
691
692void
694{
695 // Illegal CSR
696 panic_if(idx > NUM_PHYS_MISCREGS, "Illegal CSR index %#x\n", idx);
697 DPRINTF(RiscvMisc, "Setting MiscReg %s (%d) to %#x.\n",
698 MiscRegNames[idx], idx, val);
699 miscRegFile[idx] = val;
700}
701
702void
704{
705 if (idx >= MISCREG_CYCLE && idx <= MISCREG_HPMCOUNTER31) {
706 // Ignore writes to HPM counters for now
707 warn("Ignoring write to miscreg %s.\n", MiscRegNames[idx]);
708 } else {
709 switch (idx) {
710
711 // From section 3.7.1 of RISCV priv. specs
712 // V1.12, the odd-numbered configuration
713 // registers are illegal for RV64 and
714 // each 64 bit CFG register hold configurations
715 // for 8 PMP entries.
716
717 case MISCREG_PMPCFG0:
718 case MISCREG_PMPCFG1:
719 case MISCREG_PMPCFG2:
720 case MISCREG_PMPCFG3:
721 {
722 // PMP registers should only be modified in M mode
724
725 int regSize = 0;
726 switch (_rvType) {
727 case RV32:
728 regSize = 4;
729 break;
730 case RV64:
731 regSize = 8;
732 break;
733 default:
734 panic("%s: Unknown _rvType: %d", name(), (int)_rvType);
735 }
736
737 // Specs do not seem to mention what should be
738 // configured first, cfg or address regs!
739 // qemu seems to update the tables when
740 // pmp addr regs are written (with the assumption
741 // that cfg regs are already written)
742 RegVal res = 0;
743 RegVal old_val = readMiscRegNoEffect(idx);
744
745 for (int i=0; i < regSize; i++) {
746
747 uint8_t cfg_val = (val >> (8*i)) & 0xff;
748 auto mmu = dynamic_cast<RiscvISA::MMU *>
749 (tc->getMMUPtr());
750
751 // Form pmp_index using the index i and
752 // PMPCFG register number
753 uint32_t pmp_index = i+(4*(idx-MISCREG_PMPCFG0));
754 bool result = mmu->getPMP()->pmpUpdateCfg(pmp_index,cfg_val);
755 if (result) {
756 res |= ((RegVal)cfg_val << (8*i));
757 } else {
758 res |= (old_val & (0xFF << (8*i)));
759 }
760 }
761 setMiscRegNoEffect(idx, res);
762 }
763 break;
765 {
766 // PMP registers should only be modified in M mode
768
769 auto mmu = dynamic_cast<RiscvISA::MMU *>
770 (tc->getMMUPtr());
771 uint32_t pmp_index = idx-MISCREG_PMPADDR00;
772 if (mmu->getPMP()->pmpUpdateAddr(pmp_index, val)) {
774 }
775 } break;
776 case MISCREG_IP:
777 {
779 auto ic = dynamic_cast<RiscvISA::Interrupts *>(
780 tc->getCpuPtr()->getInterruptController(tc->threadId()));
781 val = (val & mask) | (ic->readIP() & ~mask);
782 ic->setIP(val);
783 }
784 break;
785 case MISCREG_HVIP:
786 {
787 auto ic = dynamic_cast<RiscvISA::Interrupts *>(
788 tc->getCpuPtr()->getInterruptController(tc->threadId()));
789 ic->setHVIP(val);
790 }
791 break;
792 case MISCREG_IE:
793 {
795 auto ic = dynamic_cast<RiscvISA::Interrupts *>(
796 tc->getCpuPtr()->getInterruptController(tc->threadId()));
797 ic->setIE(val);
798 }
799 break;
800 case MISCREG_SATP:
801 {
802 // we only support bare and Sv39 mode; setting a different mode
803 // shall have no effect (see 4.1.12 in priv ISA manual)
804 SATP cur_val = readMiscRegNoEffect(idx);
805 SATP new_val = val;
806 if (new_val.mode != AddrXlateMode::BARE &&
807 new_val.mode != AddrXlateMode::SV39)
808 new_val.mode = cur_val.mode;
809
810 // TLB flush can be elided here
811 // --- From the RISCV Privileged Spec 20250508, p.129 ---
812 // "Not imposing upon implementations to flush
813 // address-translation caches upon satp writes reduces
814 // the cost of context switches provided a sufficiently
815 // large ASID space."
816
817 setMiscRegNoEffect(idx, new_val);
818 }
819 break;
820
821 case MISCREG_VSATP:
822 {
823 // we only support bare and Sv39 mode; setting a different mode
824 // shall have no effect (see 4.1.12 in priv ISA manual)
825 SATP cur_val = readMiscRegNoEffect(idx);
826 SATP new_val = val;
827 if (new_val.mode != AddrXlateMode::BARE &&
828 new_val.mode != AddrXlateMode::SV39)
829 new_val.mode = cur_val.mode;
830
831 setMiscRegNoEffect(idx, new_val);
832 }
833 break;
834
835 case MISCREG_SENVCFG:
836 {
837 // panic on write to bitfields that aren't implemented in gem5
838 SENVCFG panic_mask = 0;
839 panic_mask.pmm = 3;
840
841 SENVCFG wpri_mask = 0;
842 wpri_mask.wpri_1 = ~wpri_mask.wpri_1;
843 wpri_mask.wpri_2 = ~wpri_mask.wpri_2;
844 wpri_mask.wpri_3 = ~wpri_mask.wpri_3;
845
846 if ((panic_mask & val) != 0) {
847 panic("Tried to write to an unimplemented bitfield in the "
848 "senvcfg CSR!\nThe attempted write was:\n %" PRIu64 "\n",
849 val);
850 }
851
852 setMiscRegNoEffect(idx, val & ~wpri_mask);
853 }
854 break;
855 case MISCREG_HGATP:
856 {
857 // TLB flush can be elided here
858 // --- From the RISCV Privileged Spec 20250508, p.171 ---
859 // Note that writing hgatp does not imply any ordering
860 // constraints between page-table updates and
861 // subsequent G-stage address translations.
862 // If the new virtual machine’s guest physical page tables have
863 // been modified, or if a VMID is reused,
864 // it may be necessary to execute an HFENCE.GVMA instruction
865 // (see Section 21.3.2) before or after writing hgatp.
866
867 SATP cur_val = readMiscRegNoEffect(idx);
868 SATP new_val = val;
869
870 if (new_val.mode != AddrXlateMode::BARE &&
871 new_val.mode != AddrXlateMode::SV39)
872 {
873 new_val.mode = cur_val.mode;
874 }
875
876 setMiscRegNoEffect(idx, new_val);
877
878 }
879 break;
880 case MISCREG_TSELECT:
881 {
882 // we don't support debugging, so always set a different value
883 // than written
884 setMiscRegNoEffect(idx, val + 1);
885 }
886 break;
887 case MISCREG_ISA:
888 {
889 MISA cur_misa = (MISA)readMiscRegNoEffect(MISCREG_ISA);
890 MISA new_misa = (MISA)val;
891 // only allow to disable compressed instructions
892 // if the following instruction is 4-byte aligned
893 if (new_misa.rvc == 0 &&
894 bits(tc->pcState().as<RiscvISA::PCState>().npc(),
895 2, 0) != 0) {
896 new_misa.rvc = new_misa.rvc | cur_misa.rvc;
897 }
898 if (!getEnableRvv()) {
899 new_misa.rvv = 0;
900 }
901 new_misa.rvs = cur_misa.rvs;
902 new_misa.rvu = cur_misa.rvu;
903 setMiscRegNoEffect(idx, new_misa);
904 }
905 break;
906 case MISCREG_STATUS:
907 {
908 if (_rvType != RV32) {
909 // SXL and UXL are hard-wired to 64 bit
910 auto cur = readMiscRegNoEffect(idx);
913 }
914 if (!getEnableRvv()) {
915 // Always OFF is rvv is disabled.
917 }
919 }
920 break;
921 case MISCREG_VSSTATUS:
922 {
923
924 auto cur = readMiscRegNoEffect(idx);
925 auto wmask_map = CSRWriteMasks[RV64][getPrivilegeModeSet()];
926 auto sstatus_wmask = wmask_map.find(CSR_VSSTATUS)->second;
927 val = (cur & ~sstatus_wmask) | val;
929 }
930 break;
931 case MISCREG_VXSAT:
932 {
933 setMiscRegNoEffect(idx, val & 0x1);
934 }
935 break;
936 case MISCREG_VXRM:
937 {
938 setMiscRegNoEffect(idx, val & 0x3);
939 }
940 break;
941 case MISCREG_VCSR:
942 {
944 setMiscRegNoEffect(MISCREG_VXRM, (val & 0x6) >> 1);
945 }
946 break;
947 case MISCREG_PRV:
948 {
950 }
951 break;
952 case MISCREG_VIRT:
953 {
954 tc->getMMUPtr()->flushAll();
956 }
957 break;
958 case MISCREG_MNSTATUS:
959 {
960 NSTATUS nstatus = val;
962 (RegVal)nstatus.nmie | readMiscRegNoEffect(MISCREG_NMIE));
964 }
965 break;
966 case MISCREG_JVT:
967 {
969 }
970 break;
971
973 {
975 new_val |= (val & FFLAGS_MASK);
977 }
978 break;
979 default:
981 }
982 }
983}
984
985void
987{
989
990 DPRINTF(Checkpoint, "Serializing Riscv Misc Registers\n");
992}
993
994void
996{
997 DPRINTF(Checkpoint, "Unserializing Riscv Misc Registers\n");
999}
1000
1001void
1003{
1004 Addr& load_reservation_addr = load_reservation_addrs[tc->contextId()];
1005
1006 if (load_reservation_addr == INVALID_RESERVATION_ADDR)
1007 return;
1008 Addr snoop_addr = pkt->getAddr() & cacheBlockMask;
1009 DPRINTF(LLSC, "Locked snoop on address %x.\n", snoop_addr);
1010 if ((load_reservation_addr & cacheBlockMask) == snoop_addr)
1011 load_reservation_addr = INVALID_RESERVATION_ADDR;
1012}
1013
1014
1015void
1017{
1018 Addr& load_reservation_addr = load_reservation_addrs[tc->contextId()];
1019
1020 load_reservation_addr = req->getPaddr();
1021 DPRINTF(LLSC, "[cid:%d]: Reserved address %x.\n",
1022 req->contextId(), req->getPaddr());
1023}
1024
1025bool
1026ISA::handleLockedWrite(const RequestPtr &req, Addr cacheBlockMask)
1027{
1028 Addr& load_reservation_addr = load_reservation_addrs[tc->contextId()];
1029 bool lr_addr_empty = (load_reservation_addr == INVALID_RESERVATION_ADDR);
1030
1031 // Normally RISC-V uses zero to indicate success and nonzero to indicate
1032 // failure (right now only 1 is reserved), but in gem5 zero indicates
1033 // failure and one indicates success, so here we conform to that (it should
1034 // be switched in the instruction's implementation)
1035
1036 DPRINTF(LLSC, "[cid:%d]: load_reservation_addrs empty? %s.\n",
1037 req->contextId(),
1038 lr_addr_empty ? "yes" : "no");
1039 if (!lr_addr_empty) {
1040 DPRINTF(LLSC, "[cid:%d]: addr = %x.\n", req->contextId(),
1041 req->getPaddr() & cacheBlockMask);
1042 DPRINTF(LLSC, "[cid:%d]: last locked addr = %x.\n", req->contextId(),
1043 load_reservation_addr & cacheBlockMask);
1044 }
1045 if (lr_addr_empty ||
1046 (load_reservation_addr & cacheBlockMask)
1047 != ((req->getPaddr() & cacheBlockMask))) {
1048 req->setExtraData(0);
1049 int stCondFailures = tc->readStCondFailures();
1050 tc->setStCondFailures(++stCondFailures);
1051 if (stCondFailures % WARN_FAILURE == 0) {
1052 warn("%i: context %d: %d consecutive SC failures.\n",
1053 curTick(), tc->contextId(), stCondFailures);
1054 }
1055
1056 // Must clear any reservations
1057 load_reservation_addr = INVALID_RESERVATION_ADDR;
1058
1059 return false;
1060 }
1061 if (req->isUncacheable()) {
1062 req->setExtraData(2);
1063 }
1064
1065 // Must clear any reservations
1066 load_reservation_addr = INVALID_RESERVATION_ADDR;
1067
1068 DPRINTF(LLSC, "[cid:%d]: SC success! Current locked addr = %x.\n",
1069 req->contextId(), load_reservation_addr & cacheBlockMask);
1070 return true;
1071}
1072
1073void
1075{
1076 tc->getCpuPtr()->wakeup(tc->threadId());
1077 Addr& load_reservation_addr = load_reservation_addrs[tc->contextId()];
1078 load_reservation_addr = INVALID_RESERVATION_ADDR;
1079}
1080
1081void
1083{
1084 Reset().invoke(tc);
1085}
1086
1087bool
1089{
1090 // Virtualized when V-bit is 1
1091 return readMiscRegNoEffect(MISCREG_VIRT) == 1;
1092}
1093
1094void
1096 uint64_t& csr, RegIndex& midx, std::string& csrName)
1097{
1098 switch (csr) {
1099 case CSR_SSTATUS: csr = CSR_VSSTATUS; break;
1100 case CSR_STVEC: csr = CSR_VSTVEC; break;
1101 case CSR_SSCRATCH: csr = CSR_VSSCRATCH; break;
1102 case CSR_SEPC: csr = CSR_VSEPC; break;
1103 case CSR_SCAUSE: csr = CSR_VSCAUSE; break;
1104 case CSR_STVAL: csr = CSR_VSTVAL; break;
1105 case CSR_SATP: csr = CSR_VSATP; break;
1106 case CSR_SIP: csr = CSR_VSIP; break;
1107 case CSR_SIE: csr = CSR_VSIE; break;
1108 default: return; break;
1109 }
1110
1111 // Lookup new midx and csrName
1112 auto csr_data_it = getCSRDataMap().find(csr);
1113 if (csr_data_it == getCSRDataMap().end()) {
1114 panic("Bad remapping of virtualized CSR");
1115 }
1116 midx = csr_data_it->second.physIndex;
1117 csrName = csr_data_it->second.name;
1118}
1119
1120Fault
1121ISA::tvmChecks(uint64_t csr, PrivilegeMode pm, ExtMachInst machInst)
1122{
1123 if (csr == CSR_SATP) {
1125 if (pm != PRV_M && status.tvm == 1) {
1126 return std::make_shared<IllegalInstFault>(
1127 "SATP access with TVM enabled\n",
1128 machInst);
1129 }
1130 } else if (csr == CSR_VSATP) {
1131 if (virtualizationEnabled()) {
1132 HSTATUS hstatus = readMiscReg(MISCREG_HSTATUS);
1133 if (hstatus.vtvm == 1)
1134 return std::make_shared<VirtualInstFault>(
1135 "VSATP access with hstatus.vtvm enabled",
1136 machInst);
1137 }
1138 } else if (csr == CSR_HGATP) {
1140 if (pm != PRV_M && status.tvm == 1) {
1141 return std::make_shared<IllegalInstFault>(
1142 "HGATP access with TVM enabled\n",
1143 machInst);
1144 }
1145 }
1146
1147
1148 return NoFault;
1149}
1150
1151RegVal
1153{
1154 auto csr_it = getCSRDataMap().find(csr);
1155
1156 // panic if the method was used with bad csr idx
1157 panic_if(csr_it == getCSRDataMap().end(),
1158 "Illegal CSR passed to backdoorReadCSRAllBits");
1159
1160 auto midx = csr_it->second.physIndex;
1161
1162 RegVal readval = xc->readMiscReg(midx);
1163
1164 // Special handling for FCSR
1165 if (csr == CSR_FCSR) {
1166 readval = (xc->readMiscReg(MISCREG_FFLAGS) |
1168 }
1169
1170 return readval;
1171}
1172
1173RegVal
1174ISA::readCSR(ExecContext *xc, uint64_t csr)
1175{
1176 auto csr_it = getCSRDataMap().find(csr);
1177
1178 // panic if the method was used with bad csr idx
1179 panic_if(csr_it == getCSRDataMap().end(), "Illegal CSR passed to readCSR");
1180
1181
1182 auto mask_it = getCSRMaskMap().find(csr);
1183 RegVal maskVal = (mask_it == getCSRMaskMap().end()) ?
1184 mask(64) : mask_it->second;
1185
1186 RegVal readval = backdoorReadCSRAllBits(xc, csr) & maskVal;
1187
1188
1189 // Some registers need additional masking/shifting
1190 // to read the correct value
1191 switch (csr) {
1192 case CSR_SIP: case CSR_SIE:
1193 case CSR_HIP: case CSR_HIE:
1194 {
1195 RegVal mideleg = xc->readMiscReg(MISCREG_MIDELEG);
1196 readval &= mideleg;
1197 break;
1198 }
1199 // VSIP and VSIE bits are stored one bit to the left
1200 // However reads expect them in SIP and SIE positions!
1201 case CSR_VSIP: case CSR_VSIE:
1202 {
1203 RegVal hideleg = xc->readMiscReg(MISCREG_HIDELEG);
1204 readval &= hideleg;
1205 readval >>= 1;
1206 break;
1207 }
1208
1209 case CSR_HVIP:
1210 {
1211 INTERRUPT mip = xc->readMiscReg(MISCREG_IP);
1212 readval |= (mip.vssi << 2);
1213 break;
1214 }
1215 default: break;
1216 }
1217
1218 return readval;
1219}
1220
1221void
1222ISA::writeCSR(ExecContext *xc, uint64_t csr, RegVal writeData)
1223{
1224 auto csr_it = getCSRDataMap().find(csr);
1225
1226 // panic if the method was used with bad csr idx
1227 panic_if(csr_it == getCSRDataMap().end(),
1228 "Illegal CSR passed to writeCSR");
1229
1230 // find physical register id (MISCREG == physical)
1231 auto midx = csr_it->second.physIndex;
1232
1233 switch (csr) {
1234 case CSR_SIP: case CSR_SIE:
1235 case CSR_HIP: case CSR_HIE:
1236 {
1237 RegVal mideleg = xc->readMiscReg(MISCREG_MIDELEG);
1238 writeData &= mideleg;
1239 break;
1240 }
1241
1242 // Special case for VSIP & VSIE
1243 // We presented the bits in SIP and SIE (one position right)
1244 // But we shift them up one again so that they don't overwrite
1245 // the actual SIP and SIE but instead take their actual places.
1246 // This happens because XIP and XIE are shared registers
1247 // but VS-level should be unaware that its SIP and SIE bits are stored
1248 // elsewhere.
1249 case CSR_VSIP: case CSR_VSIE:
1250 {
1251 RegVal hideleg = xc->readMiscReg(MISCREG_HIDELEG);
1252 writeData <<= 1;
1253 writeData &= hideleg;
1254 break;
1255 }
1256 default:
1257 break;
1258 }
1259
1260 auto& csr_read_masks = getCSRMaskMap();
1261 auto& csr_write_masks = getCSRWriteMaskMap();
1262
1263 // If no read mask or write mask, assume all bits are writable
1264 RegVal write_mask = mask(64);
1265
1266 // To save space, we only specify write masks that differ
1267 // from the respective read masks in misc.hh
1268 // If there is no write mask, use the read mask to write
1269 // all "visible" aka readable bits. Else use mask(64).
1270 auto write_mask_it = csr_write_masks.find(csr);
1271 if (write_mask_it != csr_write_masks.end()) {
1272 write_mask = write_mask_it->second;
1273 } else {
1274 auto read_mask_it = csr_read_masks.find(csr);
1275 if (read_mask_it != csr_read_masks.end()) {
1276 write_mask = read_mask_it->second;
1277 }
1278 }
1279
1280 auto writeDataMasked = writeData & write_mask;
1281
1282 // CSRs are often aliases with different visibility
1283 // on the same physical register (MISCREG).
1284 // We must keep the values of the non-visible bits
1285 // intact for other privileges/contexts where
1286 // they are used.
1287
1288 // Read all the CSR bits
1289 auto reg_data_all = backdoorReadCSRAllBits(xc, csr);
1290
1291 // Only modify those in writeMask
1292 auto new_reg_data_all = (reg_data_all & ~write_mask)
1293 | (writeData & write_mask);
1294
1295
1296 switch (csr) {
1297 case CSR_FCSR: {
1298 xc->setMiscReg(MISCREG_FFLAGS, bits(writeDataMasked, 4, 0));
1299 xc->setMiscReg(MISCREG_FRM, bits(writeDataMasked, 7, 5));
1300 break;
1301 }
1302
1303 case CSR_HVIP: {
1304 // vssi bit is an alias, propagate to mip
1305 INTERRUPT mip = xc->readMiscReg(MISCREG_IP);
1306 mip.vssi = (new_reg_data_all & VSSI_MASK) >> 2;
1307 xc->setMiscReg(MISCREG_IP, mip);
1308
1309 // turn off vssi for write to HVIP
1310 new_reg_data_all &= ~VSSI_MASK;
1311
1312 // finally write hvip
1313 xc->setMiscReg(midx, new_reg_data_all);
1314 break;
1315 }
1316 // case CSR_MIP: case CSR_MIE:
1317 // case CSR_HIP: case CSR_HIE:
1318 // case CSR_SIP: case CSR_SIE:
1319 // case CSR_VSIP: case CSR_VSIE:
1320 // case CSR_MSTATUS: case CSR_SSTATUS:
1321 // xc->setMiscReg(midx, new_reg_data_all);
1322 // break;
1323 default:
1324 xc->setMiscReg(midx, new_reg_data_all);
1325 break;
1326 }
1327}
1328
1329Addr
1330ISA::getFaultHandlerAddr(RegIndex idx, uint64_t cause, bool intr) const
1331{
1332 auto vec = tc->readMiscRegNoEffect(idx);
1333 Addr addr = mbits(vec, 63, 2);
1334 if (intr && bits(vec, 1, 0) == 1)
1335 addr += 4 * cause;
1336 return addr;
1337}
1338
1339// V-bit utilities (H-extension)
1341 return xc->readMiscReg(MISCREG_VIRT);
1342}
1346
1348 assert(!virtualizationEnabled(xc));
1349 xc->setMiscReg(MISCREG_VIRT, 1);
1350}
1352 assert(!virtualizationEnabled(tc));
1353 tc->setMiscReg(MISCREG_VIRT, 1);
1354}
1355
1357 assert(virtualizationEnabled(xc));
1358 xc->setMiscReg(MISCREG_VIRT, 0);
1359}
1361 assert(virtualizationEnabled(tc));
1362 tc->setMiscReg(MISCREG_VIRT, 0);
1363}
1364
1365// FPU status update function
1366Fault
1367updateFPUStatus(ExecContext *xc, ExtMachInst machInst, bool set_dirty)
1368{
1369 MISA misa = xc->readMiscReg(MISCREG_ISA);
1370 STATUS status = xc->readMiscReg(MISCREG_STATUS);
1371 STATUS vsstatus = misa.rvh && virtualizationEnabled(xc) ?
1373
1374 if (status.fs == FPUStatus::OFF ||
1375 (misa.rvh && virtualizationEnabled(xc) &&
1376 vsstatus.fs == FPUStatus::OFF))
1377 return std::make_shared<IllegalInstFault>("FPU is off", machInst);
1378
1379 if (set_dirty) {
1382
1383 if (misa.rvh && virtualizationEnabled(xc)) {
1384 vsstatus.fs = FPUStatus::DIRTY;
1385 xc->setMiscReg(MISCREG_VSSTATUS, vsstatus);
1386 }
1387 }
1388
1389 return NoFault;
1390}
1391
1392// VPU status update function
1393Fault
1395 ExecContext *xc, ExtMachInst machInst, bool set_dirty, bool check_vill)
1396{
1397 MISA misa = xc->readMiscReg(MISCREG_ISA);
1398 STATUS status = xc->readMiscReg(MISCREG_STATUS);
1399 STATUS vsstatus = misa.rvh && virtualizationEnabled(xc) ?
1401
1402 if (!misa.rvv || status.vs == VPUStatus::OFF ||
1403 (misa.rvh && virtualizationEnabled(xc) &&
1404 vsstatus.vs == VPUStatus::OFF)) {
1405 return std::make_shared<IllegalInstFault>(
1406 "RVV is disabled or VPU is off", machInst);
1407 }
1408
1409 if (check_vill && machInst.vill) {
1410 return std::make_shared<IllegalInstFault>("VILL is set", machInst);
1411 }
1412
1413 if (set_dirty) {
1416
1417 if (misa.rvh && virtualizationEnabled(xc)) {
1418 vsstatus.vs = VPUStatus::DIRTY;
1419 xc->setMiscReg(MISCREG_VSSTATUS, vsstatus);
1420 }
1421 }
1422
1423 return NoFault;
1424}
1425
1426
1427} // namespace RiscvISA
1428} // namespace gem5
1429
1430std::ostream &
1431operator<<(std::ostream &os, gem5::RiscvISA::PrivilegeMode pm)
1432{
1433 switch (pm) {
1435 return os << "PRV_U";
1437 return os << "PRV_S";
1439 return os << "PRV_M";
1440 default:
1441 return os << "PRV_<invalid>";
1442 }
1443}
#define DPRINTF(x,...)
Definition trace.hh:209
ThreadContext * tc
Definition isa.hh:68
RegClasses _regClasses
Definition isa.hh:70
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition isa.hh:136
BaseISA(const SimObjectParams &p, const std::string &name)
Definition isa.hh:64
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
virtual RegVal readMiscReg(int misc_reg)=0
Reads a miscellaneous register, handling any architectural side effects due to reading that register.
virtual void setMiscReg(int misc_reg, RegVal val)=0
Sets a miscellaneous register, handling any architectural side effects due to writing that register.
virtual std::string name() const
Definition named.hh:60
Addr getAddr() const
Definition packet.hh:807
const bool _wfiResumeOnPending
The WFI instruction can halt the execution of a hart.
Definition isa.hh:112
virtual const std::unordered_map< int, CSRMetadata > & getCSRDataMap() const
Definition isa.hh:150
void setMiscReg(RegIndex idx, RegVal val) override
Definition isa.cc:703
void handleLockedSnoop(PacketPtr pkt, Addr cacheBlockMask) override
Definition isa.cc:1002
virtual const std::unordered_map< int, RegVal > & getCSRMaskMap() const
Definition isa.hh:155
RegVal readMiscReg(RegIndex idx) override
Definition isa.cc:502
void globalClearExclusive() override
Definition isa.cc:1074
const int WARN_FAILURE
Definition isa.hh:86
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition isa.cc:986
void resetThread() override
Definition isa.cc:1082
PrivilegeModeSet _privilegeModeSet
The combination of privilege modes in Privilege Levels section of RISC-V privileged spec.
Definition isa.hh:103
Fault hpmCounterCheck(int counter, ExtMachInst machInst) const
Definition isa.cc:436
bool enableSmrnmi()
Definition isa.hh:211
Addr rvSext(Addr addr) const
Definition isa.hh:216
void setMiscRegNoEffect(RegIndex idx, RegVal val) override
Definition isa.cc:693
RegVal readMiscRegNoEffect(RegIndex idx) const override
Definition isa.cc:492
unsigned elen
Length of each vector element in bits.
Definition isa.hh:98
Fault tvmChecks(uint64_t csr, PrivilegeMode pm, ExtMachInst machInst)
Definition isa.cc:1121
void copyRegsFrom(ThreadContext *src) override
Definition isa.cc:334
bool handleLockedWrite(const RequestPtr &req, Addr cacheBlockMask) override
Definition isa.cc:1026
unsigned vlen
Length of each vector register in bits.
Definition isa.hh:93
void swapToVirtCSR(uint64_t &csr, RegIndex &midx, std::string &csrName)
Definition isa.cc:1095
void clear() override
Definition isa.cc:359
bool getEnableRvv() const
Definition isa.hh:187
void writeCSR(ExecContext *xc, uint64_t csr, RegVal writeData)
Definition isa.cc:1222
bool _enableSmrnmi
Resumable non-maskable interrupt Set true to make NMI recoverable.
Definition isa.hh:126
RegVal readCSR(ExecContext *xc, uint64_t csr)
Definition isa.cc:1174
std::vector< RegVal > miscRegFile
Definition isa.hh:80
bool inUserMode() const override
Definition isa.cc:328
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition isa.cc:995
const Addr INVALID_RESERVATION_ADDR
Definition isa.hh:87
bool _enableZcd
Enable Zcd extensions.
Definition isa.hh:120
virtual Addr getFaultHandlerAddr(RegIndex idx, uint64_t cause, bool intr) const
Definition isa.cc:1330
bool virtualizationEnabled() const
Definition isa.cc:1088
unsigned getVecLenInBytes()
Definition isa.hh:200
std::unordered_map< int, Addr > load_reservation_addrs
Definition isa.hh:88
RiscvType _rvType
Definition isa.hh:79
PrivilegeModeSet getPrivilegeModeSet()
Definition isa.hh:205
RiscvISAParams Params
Definition isa.hh:129
virtual const std::unordered_map< int, RegVal > & getCSRWriteMaskMap() const
Definition isa.hh:161
ISA(const Params &p)
Definition isa.cc:302
void handleLockedRead(const RequestPtr &req) override
Definition isa.cc:1016
RegVal backdoorReadCSRAllBits(ExecContext *xc, uint64_t csr)
Definition isa.cc:1152
void vtype(VTYPE v)
Definition pcstate.hh:114
void vl(uint32_t v)
Definition pcstate.hh:117
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition faults.cc:260
Clint * getClint() const
Get a pointer to the system's CLINT model.
Definition system.hh:75
uint64_t tryReadMtime() const
Definition system.cc:46
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual RegVal readMiscReg(RegIndex misc_reg)=0
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
virtual RegVal getReg(const RegId &reg) const
virtual const PCStateBase & pcState() const =0
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition bitfield.hh:79
constexpr T mbits(T val, unsigned first, unsigned last)
Mask off the given bits in place like bits() but without shifting.
Definition bitfield.hh:106
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:220
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition logging.hh:268
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition logging.hh:246
#define UNSERIALIZE_CONTAINER(member)
Definition serialize.hh:651
#define SERIALIZE_CONTAINER(member)
Definition serialize.hh:643
#define warn(...)
Definition logging.hh:288
#define inform(...)
Definition logging.hh:289
constexpr RegClass matRegClass
Definition mat.hh:92
constexpr RegClass vecElemClass
Definition vec.hh:104
Bitfield< 5, 0 > status
constexpr RegClass vecPredRegClass
Definition vec.hh:108
constexpr RegClass ccRegClass
Definition cc.hh:87
Bitfield< 25 > vec
Definition misc.hh:113
Bitfield< 0 > p
constexpr enums::RiscvType RV32
Definition pcstate.hh:56
constexpr RegClass floatRegClass(FloatRegClass, FloatRegClassName, float_reg::NumRegs, debug::FloatRegs)
Fault updateVPUStatus(ExecContext *xc, ExtMachInst machInst, bool set_dirty, bool check_vill)
Definition isa.cc:1394
gem5::VecRegContainer< MaxVecLenInBytes > VecRegContainer
Definition vector.hh:50
const RegVal HS_INTERRUPTS
Definition misc.hh:1691
Fault updateFPUStatus(ExecContext *xc, ExtMachInst machInst, bool set_dirty)
Definition isa.cc:1367
Bitfield< 2 > i
const RegVal STATUS_VS_MASK
Definition misc.hh:1514
void resetV(ExecContext *xc)
Definition isa.cc:1356
const RegVal STATUS_SXL_MASK
Definition misc.hh:1503
const RegVal FFLAGS_MASK
Definition misc.hh:1678
const off_t VSXL_OFFSET
Definition misc.hh:1470
const RegVal STATUS_UXL_MASK
Definition misc.hh:1504
const RegVal VSSI_MASK
Definition misc.hh:1640
constexpr RegClass intRegClass(IntRegClass, IntRegClassName, int_reg::NumRegs, debug::IntRegs)
const std::unordered_map< int, RegVal > CSRWriteMasks[enums::Num_RiscvType][enums::Num_PrivilegeModeSet]
Definition misc.hh:1817
const std::array< const char *, NUM_MISCREGS > MiscRegNames
Definition isa.cc:74
constexpr RegClass vecRegClass
Definition vector.hh:71
bool virtualizationEnabled(ExecContext *xc)
Definition isa.cc:1340
constexpr enums::RiscvType RV64
Definition pcstate.hh:57
@ MISCREG_PMPADDR11
Definition misc.hh:173
@ MISCREG_HPMCOUNTER16H
Definition misc.hh:277
@ MISCREG_HSTATUS
Definition misc.hh:213
@ MISCREG_HPMCOUNTER09
Definition misc.hh:90
@ MISCREG_HPMEVENT31
Definition misc.hh:141
@ MISCREG_IMPID
Definition misc.hh:76
@ MISCREG_HPMEVENT07
Definition misc.hh:117
@ MISCREG_RESERVED01
Definition misc.hh:179
@ MISCREG_HPMCOUNTER16
Definition misc.hh:97
@ MISCREG_HPMCOUNTER13H
Definition misc.hh:274
@ MISCREG_SENVCFG
Definition misc.hh:188
@ MISCREG_HPMCOUNTER19
Definition misc.hh:100
@ MISCREG_PMPADDR12
Definition misc.hh:174
@ MISCREG_HPMCOUNTER07
Definition misc.hh:88
@ MISCREG_HPMEVENT29
Definition misc.hh:139
@ MISCREG_HPMCOUNTER26
Definition misc.hh:107
@ MISCREG_PMPADDR05
Definition misc.hh:167
@ MISCREG_RESERVED03
Definition misc.hh:190
@ MISCREG_HPMCOUNTER13
Definition misc.hh:94
@ MISCREG_PMPADDR10
Definition misc.hh:172
@ MISCREG_PMPADDR14
Definition misc.hh:176
@ MISCREG_PMPCFG3
Definition misc.hh:161
@ NUM_PHYS_MISCREGS
Definition misc.hh:295
@ MISCREG_HPMCOUNTER22H
Definition misc.hh:283
@ MISCREG_PMPADDR09
Definition misc.hh:171
@ MISCREG_HPMEVENT06
Definition misc.hh:116
@ MISCREG_TSELECT
Definition misc.hh:142
@ MISCREG_MSCRATCH
Definition misc.hh:154
@ MISCREG_HPMCOUNTER04H
Definition misc.hh:265
@ MISCREG_MNCAUSE
Definition misc.hh:255
@ MISCREG_HPMEVENT21
Definition misc.hh:131
@ MISCREG_HPMCOUNTER12H
Definition misc.hh:273
@ MISCREG_STATUS
Definition misc.hh:78
@ MISCREG_HPMEVENT12
Definition misc.hh:122
@ MISCREG_HPMCOUNTER25
Definition misc.hh:106
@ MISCREG_RESERVED05
Definition misc.hh:192
@ MISCREG_PMPADDR04
Definition misc.hh:166
@ MISCREG_INSTRETH
Definition misc.hh:263
@ MISCREG_MCOUNTEREN
Definition misc.hh:153
@ MISCREG_PMPADDR00
Definition misc.hh:162
@ MISCREG_HPMCOUNTER22
Definition misc.hh:103
@ MISCREG_RESERVED02
Definition misc.hh:180
@ MISCREG_HPMEVENT17
Definition misc.hh:127
@ MISCREG_RESERVED06
Definition misc.hh:193
@ MISCREG_HPMEVENT20
Definition misc.hh:130
@ MISCREG_HPMCOUNTER03H
Definition misc.hh:264
@ MISCREG_HPMCOUNTER15H
Definition misc.hh:276
@ MISCREG_MEDELEG
Definition misc.hh:150
@ MISCREG_HPMEVENT25
Definition misc.hh:135
@ MISCREG_HPMCOUNTER31H
Definition misc.hh:292
@ MISCREG_HPMCOUNTER11
Definition misc.hh:92
@ MISCREG_HPMCOUNTER17H
Definition misc.hh:278
@ MISCREG_HPMEVENT03
Definition misc.hh:113
@ MISCREG_PMPCFG1
Definition misc.hh:159
@ MISCREG_HPMEVENT13
Definition misc.hh:123
@ MISCREG_PMPADDR13
Definition misc.hh:175
@ MISCREG_FFLAGS_EXE
Definition misc.hh:296
@ MISCREG_HPMCOUNTER12
Definition misc.hh:93
@ MISCREG_HPMCOUNTER29H
Definition misc.hh:290
@ MISCREG_HENVCFG
Definition misc.hh:222
@ MISCREG_HPMEVENT04
Definition misc.hh:114
@ MISCREG_HPMEVENT08
Definition misc.hh:118
@ MISCREG_HIDELEG
Definition misc.hh:215
@ MISCREG_HPMEVENT19
Definition misc.hh:129
@ MISCREG_DSCRATCH
Definition misc.hh:148
@ MISCREG_HPMEVENT30
Definition misc.hh:140
@ MISCREG_PMPADDR06
Definition misc.hh:168
@ MISCREG_HPMCOUNTER21
Definition misc.hh:102
@ MISCREG_HPMCOUNTER21H
Definition misc.hh:282
@ MISCREG_PMPADDR03
Definition misc.hh:165
@ MISCREG_SCOUNTEREN
Definition misc.hh:182
@ MISCREG_HPMCOUNTER18H
Definition misc.hh:279
@ MISCREG_HPMCOUNTER06
Definition misc.hh:87
@ MISCREG_HPMCOUNTER20H
Definition misc.hh:281
@ MISCREG_HPMCOUNTER28
Definition misc.hh:109
@ MISCREG_PMPADDR02
Definition misc.hh:164
@ MISCREG_MIDELEG
Definition misc.hh:151
@ MISCREG_HPMCOUNTER30
Definition misc.hh:111
@ MISCREG_VSSCRATCH
Definition misc.hh:229
@ MISCREG_HPMCOUNTER14
Definition misc.hh:95
@ MISCREG_MSTATUSH
Definition misc.hh:259
@ MISCREG_HPMEVENT10
Definition misc.hh:120
@ MISCREG_HPMEVENT26
Definition misc.hh:136
@ MISCREG_HPMEVENT18
Definition misc.hh:128
@ MISCREG_VSSTATUS
Definition misc.hh:227
@ MISCREG_HPMEVENT23
Definition misc.hh:133
@ MISCREG_INSTRET
Definition misc.hh:83
@ MISCREG_HARTID
Definition misc.hh:77
@ MISCREG_MNSTATUS
Definition misc.hh:256
@ MISCREG_HPMCOUNTER05H
Definition misc.hh:266
@ MISCREG_HPMCOUNTER20
Definition misc.hh:101
@ MISCREG_HPMEVENT09
Definition misc.hh:119
@ MISCREG_HPMCOUNTER04
Definition misc.hh:85
@ MISCREG_HPMCOUNTER25H
Definition misc.hh:286
@ MISCREG_HPMCOUNTER27H
Definition misc.hh:288
@ MISCREG_HPMCOUNTER06H
Definition misc.hh:267
@ MISCREG_RESERVED07
Definition misc.hh:194
@ MISCREG_PMPADDR07
Definition misc.hh:169
@ MISCREG_HPMCOUNTER08H
Definition misc.hh:269
@ MISCREG_HPMEVENT16
Definition misc.hh:126
@ MISCREG_HPMCOUNTER18
Definition misc.hh:99
@ MISCREG_SSCRATCH
Definition misc.hh:183
@ MISCREG_HPMCOUNTER19H
Definition misc.hh:280
@ MISCREG_HPMEVENT14
Definition misc.hh:124
@ MISCREG_VSCAUSE
Definition misc.hh:231
@ MISCREG_HPMCOUNTER10H
Definition misc.hh:271
@ MISCREG_HPMCOUNTER05
Definition misc.hh:86
@ MISCREG_HPMCOUNTER30H
Definition misc.hh:291
@ MISCREG_HPMCOUNTER17
Definition misc.hh:98
@ MISCREG_HCONTEXT
Definition misc.hh:224
@ MISCREG_HPMCOUNTER09H
Definition misc.hh:270
@ MISCREG_HPMCOUNTER27
Definition misc.hh:108
@ MISCREG_HPMCOUNTER24
Definition misc.hh:105
@ MISCREG_HPMCOUNTER28H
Definition misc.hh:289
@ MISCREG_HPMCOUNTER14H
Definition misc.hh:275
@ MISCREG_HPMCOUNTER23
Definition misc.hh:104
@ MISCREG_CYCLE
Definition misc.hh:81
@ MISCREG_RESERVED04
Definition misc.hh:191
@ MISCREG_HPMCOUNTER07H
Definition misc.hh:268
@ MISCREG_MNSCRATCH
Definition misc.hh:253
@ MISCREG_HPMCOUNTER15
Definition misc.hh:96
@ MISCREG_HPMEVENT24
Definition misc.hh:134
@ MISCREG_HPMCOUNTER10
Definition misc.hh:91
@ MISCREG_HPMCOUNTER29
Definition misc.hh:110
@ MISCREG_VENDORID
Definition misc.hh:74
@ MISCREG_PMPADDR01
Definition misc.hh:163
@ MISCREG_HEDELEG
Definition misc.hh:214
@ MISCREG_HPMEVENT27
Definition misc.hh:137
@ MISCREG_HPMEVENT15
Definition misc.hh:125
@ MISCREG_HPMEVENT05
Definition misc.hh:115
@ MISCREG_ARCHID
Definition misc.hh:75
@ MISCREG_HPMCOUNTER24H
Definition misc.hh:285
@ MISCREG_HPMEVENT11
Definition misc.hh:121
@ MISCREG_HPMCOUNTER31
Definition misc.hh:112
@ MISCREG_HPMCOUNTER23H
Definition misc.hh:284
@ MISCREG_HTIMEDELTA
Definition misc.hh:225
@ MISCREG_HPMCOUNTER11H
Definition misc.hh:272
@ MISCREG_PMPADDR08
Definition misc.hh:170
@ MISCREG_HPMCOUNTER03
Definition misc.hh:84
@ MISCREG_PMPADDR15
Definition misc.hh:177
@ MISCREG_HPMEVENT28
Definition misc.hh:138
@ MISCREG_HCOUNTEREN
Definition misc.hh:216
@ MISCREG_HPMEVENT22
Definition misc.hh:132
@ MISCREG_PMPCFG0
Definition misc.hh:158
@ MISCREG_HPMCOUNTER08
Definition misc.hh:89
@ MISCREG_HPMCOUNTER26H
Definition misc.hh:287
@ MISCREG_PMPCFG2
Definition misc.hh:160
const off_t FRM_OFFSET
Definition misc.hh:1474
const RegVal MI_MASK[enums::Num_PrivilegeModeSet]
Definition misc.hh:1643
void setV(ExecContext *xc)
Definition isa.cc:1347
constexpr RegClass miscRegClass(MiscRegClass, MiscRegClassName, NUM_MISCREGS, debug::MiscRegs)
Bitfield< 63 > val
Definition misc.hh:804
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
uint16_t RegIndex
Definition types.hh:176
std::shared_ptr< FaultBase > Fault
Definition types.hh:249
std::shared_ptr< Request > RequestPtr
Definition request.hh:94
uint64_t RegVal
Definition types.hh:173
constexpr char CCRegClassName[]
Definition reg_class.hh:81
constexpr char VecPredRegClassName[]
Definition reg_class.hh:79
Tick curTick()
The universal simulation clock.
Definition cur_tick.hh:46
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
Packet * PacketPtr
std::string csprintf(const char *format, const Args &...args)
Definition cprintf.hh:161
constexpr char MatRegClassName[]
Definition reg_class.hh:80
constexpr decltype(nullptr) NoFault
Definition types.hh:253
@ VecPredRegClass
Definition reg_class.hh:67
@ MatRegClass
Matrix Register.
Definition reg_class.hh:68
@ CCRegClass
Condition-code register.
Definition reg_class.hh:69
@ VecElemClass
Vector Register Native Elem lane.
Definition reg_class.hh:66
constexpr char VecElemClassName[]
Definition reg_class.hh:78
Declaration of the Packet class.
PMP header file.
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
std::ostream & operator<<(std::ostream &os, gem5::RiscvISA::PrivilegeMode pm)
Definition isa.cc:1431

Generated on Mon Oct 27 2025 04:12:58 for gem5 by doxygen 1.14.0