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

Generated on Sat Oct 18 2025 08:06:40 for gem5 by doxygen 1.14.0