gem5 v24.0.0.0
Loading...
Searching...
No Matches
misc.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010, 2012-2013, 2017-2018, 2021, 2023-2024 Arm Limited
3 * Copyright (c) 2013 Advanced Micro Devices, Inc.
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating
9 * to a hardware implementation of the functionality of the software
10 * licensed hereunder. You may use the software subject to the license
11 * terms below provided that you ensure that this notice is replicated
12 * unmodified and in its entirety in all distributions of the software,
13 * modified or unmodified, in source code or in binary form.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions are
17 * met: redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer;
19 * redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution;
22 * neither the name of the copyright holders nor the names of its
23 * contributors may be used to endorse or promote products derived from
24 * this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 */
38
40#include "arch/arm/tlbi_op.hh"
41
42#include "cpu/reg_class.hh"
43
44namespace gem5
45{
46
47using namespace ArmISA;
48
49std::string
51{
52 std::stringstream ss;
55 ss << ", ";
56 bool foundPsr = false;
57 for (unsigned i = 0; i < numSrcRegs(); i++) {
58 const RegId& reg = srcRegIdx(i);
59 if (!reg.is(MiscRegClass)) {
60 continue;
61 }
62 if (reg.index() == MISCREG_CPSR) {
63 ss << "cpsr";
64 foundPsr = true;
65 break;
66 }
67 if (reg.index() == MISCREG_SPSR) {
68 ss << "spsr";
69 foundPsr = true;
70 break;
71 }
72 }
73 if (!foundPsr) {
74 ss << "????";
75 }
76 return ss.str();
77}
78
79void
80MsrBase::printMsrBase(std::ostream &os) const
81{
83 bool apsr = false;
84 bool foundPsr = false;
85 for (unsigned i = 0; i < numDestRegs(); i++) {
86 const RegId& reg = destRegIdx(i);
87 if (!reg.is(MiscRegClass)) {
88 continue;
89 }
90 if (reg.index() == MISCREG_CPSR) {
91 os << "cpsr_";
92 foundPsr = true;
93 break;
94 }
95 if (reg.index() == MISCREG_SPSR) {
96 if (bits(byteMask, 1, 0)) {
97 os << "spsr_";
98 } else {
99 os << "apsr_";
100 apsr = true;
101 }
102 foundPsr = true;
103 break;
104 }
105 }
106 if (!foundPsr) {
107 os << "????";
108 return;
109 }
110 if (bits(byteMask, 3)) {
111 if (apsr) {
112 os << "nzcvq";
113 } else {
114 os << "f";
115 }
116 }
117 if (bits(byteMask, 2)) {
118 if (apsr) {
119 os << "g";
120 } else {
121 os << "s";
122 }
123 }
124 if (bits(byteMask, 1)) {
125 os << "x";
126 }
127 if (bits(byteMask, 0)) {
128 os << "c";
129 }
130}
131
132std::string
134{
135 std::stringstream ss;
137 ccprintf(ss, ", #%#x", imm);
138 return ss.str();
139}
140
141std::string
143{
144 std::stringstream ss;
146 ss << ", ";
148 return ss.str();
149}
150
151std::string
153{
154 std::stringstream ss;
157 ss << ", ";
159 ss << ", ";
161 return ss.str();
162}
163
164std::string
166{
167 std::stringstream ss;
170 ss << ", ";
172 ss << ", ";
174 return ss.str();
175}
176
177std::string
179{
180 std::stringstream ss;
182 ccprintf(ss, "#%d", imm);
183 return ss.str();
184}
185
186std::string
188{
189 std::stringstream ss;
192 ccprintf(ss, ", #%d", imm);
193 return ss.str();
194}
195
196std::string
198{
199 std::stringstream ss;
202 ss << ", ";
204 return ss.str();
205}
206
207std::string
209{
210 std::stringstream ss;
213 return ss.str();
214}
215
216std::string
218 Addr pc, const loader::SymbolTable *symtab) const
219{
220 std::stringstream ss;
223 ss << ", ";
225 ss << ", ";
227 ccprintf(ss, ", #%d", imm);
228 return ss.str();
229}
230
231std::string
233 Addr pc, const loader::SymbolTable *symtab) const
234{
235 std::stringstream ss;
238 ss << ", ";
240 ss << ", ";
242 ss << ", ";
244 return ss.str();
245}
246
247std::string
249 Addr pc, const loader::SymbolTable *symtab) const
250{
251 std::stringstream ss;
254 ss << ", ";
256 ss << ", ";
258 return ss.str();
259}
260
261std::string
263 Addr pc, const loader::SymbolTable *symtab) const
264{
265 std::stringstream ss;
268 ss << ", ";
270 ccprintf(ss, ", #%d", imm);
271 return ss.str();
272}
273
274std::string
276 Addr pc, const loader::SymbolTable *symtab) const
277{
278 std::stringstream ss;
281 ss << ", ";
283 return ss.str();
284}
285
286std::string
288 Addr pc, const loader::SymbolTable *symtab) const
289{
290 std::stringstream ss;
293 ss << ", ";
295 return ss.str();
296}
297
298std::string
300 Addr pc, const loader::SymbolTable *symtab) const
301{
302 std::stringstream ss;
305 ccprintf(ss, ", #%d, #%d", imm1, imm2);
306 return ss.str();
307}
308
309std::string
311 Addr pc, const loader::SymbolTable *symtab) const
312{
313 std::stringstream ss;
316 ss << ", ";
318 ccprintf(ss, ", #%d, #%d", imm1, imm2);
319 return ss.str();
320}
321
322std::string
324 Addr pc, const loader::SymbolTable *symtab) const
325{
326 std::stringstream ss;
329 ccprintf(ss, ", #%d, ", imm);
331 return ss.str();
332}
333
334std::string
336 Addr pc, const loader::SymbolTable *symtab) const
337{
338 std::stringstream ss;
341 ccprintf(ss, ", #%d, ", imm);
344 return ss.str();
345}
346
347std::string
349 Addr pc, const loader::SymbolTable *symtab) const
350{
351 return csprintf("%-10s (inst %#08x)", "unknown", encoding());
352}
353
354McrMrcMiscInst::McrMrcMiscInst(const char *_mnemonic, ExtMachInst _machInst,
355 uint64_t _iss, MiscRegIndex _miscReg)
356 : ArmStaticInst(_mnemonic, _machInst, No_OpClass)
357{
358 flags[IsNonSpeculative] = true;
359 iss = _iss;
360 miscReg = _miscReg;
361}
362
363Fault
365{
366 return mcrMrc15Trap(miscReg, machInst, xc->tcBase(), iss);
367}
368
369std::string
371 Addr pc, const loader::SymbolTable *symtab) const
372{
373 return csprintf("%-10s (pipe flush)", mnemonic);
374}
375
377 ExtMachInst _machInst, uint64_t _iss,
378 MiscRegIndex _miscReg)
379 : McrMrcMiscInst(_mnemonic, _machInst, _iss, _miscReg)
380{}
381
382Fault
384{
385 Fault fault = mcrMrc15Trap(miscReg, machInst, xc->tcBase(), iss);
386 if (fault != NoFault) {
387 return fault;
388 } else {
389 return std::make_shared<UndefinedInstruction>(machInst, false,
390 mnemonic);
391 }
392}
393
394std::string
396 Addr pc, const loader::SymbolTable *symtab) const
397{
398 return csprintf("%-10s (implementation defined)", mnemonic);
399}
400
401void
403{
404 ThreadContext* tc = xc->tcBase();
405 auto isa = static_cast<ArmISA::ISA *>(tc->getIsaPtr());
406 auto release = isa->getRelease();
407
408 switch (dest_idx) {
409 case MISCREG_TLBIALL: // TLBI all entries, EL0&1,
410 {
411 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
412 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
413
414 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
415 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
416 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
417 hcr.fb && !hcr.tge;
418
419 TLBIALL tlbiOp(TranslationRegime::EL10, secure);
420 if (shareable) {
421 tlbiOp.broadcast(tc);
422 } else {
423 tlbiOp(tc);
424 }
425 return;
426 }
427 // TLB Invalidate All, Inner Shareable
429 {
430 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
431
432 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
433 TLBIALL tlbiOp(TranslationRegime::EL10, secure);
434 tlbiOp.broadcast(tc);
435 return;
436 }
437 // Instruction TLB Invalidate All
438 case MISCREG_ITLBIALL:
439 {
440 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
441 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
442
443 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
444 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
445 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
446 hcr.fb && !hcr.tge;
447
448 ITLBIALL tlbiOp(TranslationRegime::EL10, secure);
449 if (shareable) {
450 tlbiOp.broadcast(tc);
451 } else {
452 tlbiOp(tc);
453 }
454 return;
455 }
456 // Data TLB Invalidate All
457 case MISCREG_DTLBIALL:
458 {
459 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
460 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
461
462 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
463 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
464 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
465 hcr.fb && !hcr.tge;
466
467 DTLBIALL tlbiOp(TranslationRegime::EL10, secure);
468 if (shareable) {
469 tlbiOp.broadcast(tc);
470 } else {
471 tlbiOp(tc);
472 }
473 return;
474 }
475 // TLB Invalidate by VA
476 case MISCREG_TLBIMVA:
477 {
478 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
479 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
480
481 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
482 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
483 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
484 hcr.fb && !hcr.tge;
485
486 TLBIMVA tlbiOp(TranslationRegime::EL10,
487 secure,
488 mbits(value, 31, 12),
489 bits(value, 7, 0),
490 false);
491
492 if (shareable) {
493 tlbiOp.broadcast(tc);
494 } else {
495 tlbiOp(tc);
496 }
497 return;
498 }
499 // TLB Invalidate by VA, Last Level
500 case MISCREG_TLBIMVAL:
501 {
502 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
503 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
504
505 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
506 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
507 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
508 hcr.fb && !hcr.tge;
509
510 TLBIMVA tlbiOp(TranslationRegime::EL10,
511 secure,
512 mbits(value, 31, 12),
513 bits(value, 7, 0),
514 true);
515
516 if (shareable) {
517 tlbiOp.broadcast(tc);
518 } else {
519 tlbiOp(tc);
520 }
521 return;
522 }
523 // TLB Invalidate by VA, Inner Shareable
525 {
526 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
527
528 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
529 TLBIMVA tlbiOp(TranslationRegime::EL10,
530 secure,
531 mbits(value, 31, 12),
532 bits(value, 7, 0),
533 false);
534
535 tlbiOp.broadcast(tc);
536 return;
537 }
538 // TLB Invalidate by VA, Last Level, Inner Shareable
540 {
541 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
542
543 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
544 TLBIMVA tlbiOp(TranslationRegime::EL10,
545 secure,
546 mbits(value, 31, 12),
547 bits(value, 7, 0),
548 true);
549
550 tlbiOp.broadcast(tc);
551 return;
552 }
553 // TLB Invalidate by ASID match
554 case MISCREG_TLBIASID:
555 {
556 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
557 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
558
559 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
560 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
561 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
562 hcr.fb && !hcr.tge;
563
564 TLBIASID tlbiOp(TranslationRegime::EL10,
565 secure,
566 bits(value, 7, 0));
567
568 if (shareable) {
569 tlbiOp.broadcast(tc);
570 } else {
571 tlbiOp(tc);
572 }
573 return;
574 }
575 // TLB Invalidate by ASID match, Inner Shareable
577 {
578 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
579
580 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
581 TLBIASID tlbiOp(TranslationRegime::EL10,
582 secure,
583 bits(value, 7, 0));
584
585 tlbiOp.broadcast(tc);
586 return;
587 }
588 // TLB Invalidate by VA, All ASID
589 case MISCREG_TLBIMVAA:
590 {
591 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
592 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
593
594 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
595 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
596 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
597 hcr.fb && !hcr.tge;
598 TLBIMVAA tlbiOp(TranslationRegime::EL10, secure,
599 mbits(value, 31, 12), false);
600
601 if (shareable) {
602 tlbiOp.broadcast(tc);
603 } else {
604 tlbiOp(tc);
605 }
606 return;
607 }
608 // TLB Invalidate by VA, Last Level, All ASID
610 {
611 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
612 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
613
614 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
615 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
616 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
617 hcr.fb && !hcr.tge;
618
619 TLBIMVAA tlbiOp(TranslationRegime::EL10, secure,
620 mbits(value, 31, 12), true);
621
622 if (shareable) {
623 tlbiOp.broadcast(tc);
624 } else {
625 tlbiOp(tc);
626 }
627 return;
628 }
629 // TLB Invalidate by VA, All ASID, Inner Shareable
631 {
632 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
633
634 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
635 TLBIMVAA tlbiOp(TranslationRegime::EL10, secure,
636 mbits(value, 31, 12), false);
637
638 tlbiOp.broadcast(tc);
639 return;
640 }
641 // TLB Invalidate by VA, All ASID, Last Level, Inner Shareable
643 {
644 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
645
646 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
647 TLBIMVAA tlbiOp(TranslationRegime::EL10, secure,
648 mbits(value, 31, 12), true);
649
650 tlbiOp.broadcast(tc);
651 return;
652 }
653 // TLB Invalidate by VA, Hyp mode
654 case MISCREG_TLBIMVAH:
655 {
656 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
657
658 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
659 TLBIMVAA tlbiOp(TranslationRegime::EL2, secure,
660 mbits(value, 31, 12), false);
661
662 tlbiOp(tc);
663 return;
664 }
665 // TLB Invalidate by VA, Last Level, Hyp mode
667 {
668 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
669
670 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
671 TLBIMVAA tlbiOp(TranslationRegime::EL2, secure,
672 mbits(value, 31, 12), true);
673
674 tlbiOp(tc);
675 return;
676 }
677 // TLB Invalidate by VA, Hyp mode, Inner Shareable
679 {
680 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
681
682 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
683 TLBIMVAA tlbiOp(TranslationRegime::EL2, secure,
684 mbits(value, 31, 12), false);
685
686 tlbiOp.broadcast(tc);
687 return;
688 }
689 // TLB Invalidate by VA, Hyp mode, Last Level, Inner Shareable
691 {
692 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
693
694 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
695 TLBIMVAA tlbiOp(TranslationRegime::EL2, secure,
696 mbits(value, 31, 12), true);
697
698 tlbiOp.broadcast(tc);
699 return;
700 }
701 // TLB Invalidate by Intermediate Physical Address, Stage 2
703 {
704 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
705
706 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
707 TLBIIPA tlbiOp(TranslationRegime::EL10,
708 secure,
709 static_cast<Addr>(bits(value, 35, 0)) << 12,
710 false);
711
712 tlbiOp(tc);
713 return;
714 }
715 // TLB Invalidate by Intermediate Physical Address, Stage 2,
716 // Last Level
718 {
719 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
720
721 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
722 TLBIIPA tlbiOp(TranslationRegime::EL10,
723 secure,
724 static_cast<Addr>(bits(value, 35, 0)) << 12,
725 true);
726
727 tlbiOp(tc);
728 return;
729 }
730 // TLB Invalidate by Intermediate Physical Address, Stage 2,
731 // Inner Shareable
733 {
734 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
735
736 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
737 TLBIIPA tlbiOp(TranslationRegime::EL10,
738 secure,
739 static_cast<Addr>(bits(value, 35, 0)) << 12,
740 false);
741
742 tlbiOp.broadcast(tc);
743 return;
744 }
745 // TLB Invalidate by Intermediate Physical Address, Stage 2,
746 // Last Level, Inner Shareable
748 {
749 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
750
751 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
752 TLBIIPA tlbiOp(TranslationRegime::EL10,
753 secure,
754 static_cast<Addr>(bits(value, 35, 0)) << 12,
755 true);
756
757 tlbiOp.broadcast(tc);
758 return;
759 }
760 // Instruction TLB Invalidate by VA
761 case MISCREG_ITLBIMVA:
762 {
763 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
764 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
765
766 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
767 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
768 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
769 hcr.fb && !hcr.tge;
770 ITLBIMVA tlbiOp(TranslationRegime::EL10,
771 secure,
772 mbits(value, 31, 12),
773 bits(value, 7, 0));
774
775 if (shareable) {
776 tlbiOp.broadcast(tc);
777 } else {
778 tlbiOp(tc);
779 }
780 return;
781 }
782 // Data TLB Invalidate by VA
783 case MISCREG_DTLBIMVA:
784 {
785 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
786 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
787
788 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
789 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
790 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
791 hcr.fb && !hcr.tge;
792
793 DTLBIMVA tlbiOp(TranslationRegime::EL10,
794 secure,
795 mbits(value, 31, 12),
796 bits(value, 7, 0));
797
798 if (shareable) {
799 tlbiOp.broadcast(tc);
800 } else {
801 tlbiOp(tc);
802 }
803 return;
804 }
805 // Instruction TLB Invalidate by ASID match
807 {
808 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
809 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
810
811 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
812 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
813 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
814 hcr.fb && !hcr.tge;
815
816 ITLBIASID tlbiOp(TranslationRegime::EL10,
817 secure,
818 bits(value, 7, 0));
819
820 if (shareable) {
821 tlbiOp.broadcast(tc);
822 } else {
823 tlbiOp(tc);
824 }
825 return;
826 }
827 // Data TLB Invalidate by ASID match
829 {
830 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
831 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
832
833 bool secure = release->has(ArmExtension::SECURITY) && !scr.ns;
834 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
835 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
836 hcr.fb && !hcr.tge;
837
838 DTLBIASID tlbiOp(TranslationRegime::EL10,
839 secure,
840 bits(value, 7, 0));
841
842 if (shareable) {
843 tlbiOp.broadcast(tc);
844 } else {
845 tlbiOp(tc);
846 }
847 return;
848 }
849 // TLB Invalidate All, Non-Secure Non-Hyp
851 {
852 TLBIALLN tlbiOp(TranslationRegime::EL10);
853 tlbiOp(tc);
854 return;
855 }
856 // TLB Invalidate All, Non-Secure Non-Hyp, Inner Shareable
858 {
859 TLBIALLN tlbiOp(TranslationRegime::EL10);
860 tlbiOp.broadcast(tc);
861 return;
862 }
863 // TLB Invalidate All, Hyp mode
864 case MISCREG_TLBIALLH:
865 {
866 TLBIALLN tlbiOp(TranslationRegime::EL2);
867 tlbiOp(tc);
868 return;
869 }
870 // TLB Invalidate All, Hyp mode, Inner Shareable
872 {
873 TLBIALLN tlbiOp(TranslationRegime::EL2);
874 tlbiOp.broadcast(tc);
875 return;
876 }
877 default:
878 panic("Unrecognized TLBIOp\n");
879 }
880}
881
882} // namespace gem5
void printMiscReg(std::ostream &os, RegIndex reg_idx) const
void printMnemonic(std::ostream &os, const std::string &suffix="", bool withPred=true, bool withCond64=false, ConditionCode cond64=COND_UC) const
void printIntReg(std::ostream &os, RegIndex reg_idx, uint8_t opWidth=0) const
Print a register name for disassembly given the unique dependence tag number (FP or int).
void printShiftOperand(std::ostream &os, RegIndex rm, bool immShift, uint32_t shiftAmt, RegIndex rs, ArmShiftType type) const
Data TLB Invalidate All.
Definition tlbi_op.hh:153
Data TLB Invalidate by ASID match.
Definition tlbi_op.hh:253
Data TLB Invalidate by VA.
Definition tlbi_op.hh:347
const ArmRelease * getRelease() const
Definition isa.hh:193
Instruction TLB Invalidate All.
Definition tlbi_op.hh:140
Instruction TLB Invalidate by ASID match.
Definition tlbi_op.hh:240
Instruction TLB Invalidate by VA.
Definition tlbi_op.hh:333
TLB Invalidate All, Non-Secure.
Definition tlbi_op.hh:266
TLB Invalidate All.
Definition tlbi_op.hh:109
TLB Invalidate by ASID match.
Definition tlbi_op.hh:223
TLB Invalidate by Intermediate Physical Address.
Definition tlbi_op.hh:416
TLB Invalidate by VA, All ASID.
Definition tlbi_op.hh:291
TLB Invalidate by VA.
Definition tlbi_op.hh:311
void broadcast(ThreadContext *tc)
Broadcast the TLB Invalidate operation to all TLBs in the Arm system.
Definition tlbi_op.hh:73
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
virtual ThreadContext * tcBase() const =0
Returns a pointer to the ThreadContext.
uint64_t imm
Definition misc.hh:142
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:178
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:395
McrMrcImplDefined(const char *_mnemonic, ArmISA::ExtMachInst _machInst, uint64_t _iss, ArmISA::MiscRegIndex _miscReg)
Definition misc.cc:376
Fault execute(ExecContext *xc, trace::InstRecord *traceData) const override
Definition misc.cc:383
Certain mrc/mcr instructions act as nops or flush the pipe based on what register the instruction is ...
Definition misc.hh:407
Fault execute(ExecContext *xc, trace::InstRecord *traceData) const override
Definition misc.cc:364
McrMrcMiscInst(const char *_mnemonic, ArmISA::ExtMachInst _machInst, uint64_t _iss, ArmISA::MiscRegIndex _miscReg)
Definition misc.cc:354
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:370
ArmISA::MiscRegIndex miscReg
Definition misc.hh:410
RegIndex op2
Definition misc.hh:124
RegIndex op1
Definition misc.hh:123
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:165
ArmISA::MiscRegIndex dest
Definition misc.hh:125
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:275
ArmISA::MiscRegIndex dest
Definition misc.hh:295
RegIndex dest2
Definition misc.hh:106
RegIndex dest
Definition misc.hh:105
ArmISA::MiscRegIndex op1
Definition misc.hh:104
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:152
RegIndex dest
Definition misc.hh:49
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:50
uint8_t byteMask
Definition misc.hh:63
void printMsrBase(std::ostream &os) const
Definition misc.cc:80
uint32_t imm
Definition misc.hh:76
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:133
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:142
RegIndex op1
Definition misc.hh:90
Register ID: describe an architectural register with its class and index.
Definition reg_class.hh:94
uint64_t imm2
Definition misc.hh:333
uint64_t imm1
Definition misc.hh:332
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:299
RegIndex dest
Definition misc.hh:331
uint64_t imm
Definition misc.hh:157
RegIndex dest
Definition misc.hh:156
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:187
RegIndex dest
Definition misc.hh:201
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:323
uint64_t imm
Definition misc.hh:202
RegIndex op1
Definition misc.hh:203
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:335
ArmISA::ArmShiftType shiftType
Definition misc.hh:372
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:287
ArmISA::MiscRegIndex op1
Definition misc.hh:314
RegIndex dest
Definition misc.hh:187
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:208
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:310
RegIndex op1
Definition misc.hh:278
uint64_t imm
Definition misc.hh:279
RegIndex dest
Definition misc.hh:277
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:262
RegIndex op1
Definition misc.hh:172
RegIndex dest
Definition misc.hh:171
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:197
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:217
RegIndex op1
Definition misc.hh:260
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:248
RegIndex dest
Definition misc.hh:259
RegIndex op2
Definition misc.hh:261
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:232
uint8_t numSrcRegs() const
Number of source registers.
uint8_t numDestRegs() const
Number of destination registers.
const RegId & destRegIdx(int i) const
Return logical index (architectural reg num) of i'th destination reg.
const char * mnemonic
Base mnemonic (e.g., "add").
std::bitset< Num_Flags > flags
Flag values for this instruction.
const RegId & srcRegIdx(int i) const
Return logical index (architectural reg num) of i'th source reg.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual RegVal readMiscReg(RegIndex misc_reg)=0
virtual BaseISA * getIsaPtr() const =0
void performTlbi(ExecContext *xc, ArmISA::MiscRegIndex dest_idx, RegVal value) const
Definition misc.cc:402
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition misc.cc:348
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:188
constexpr RegId Zero
Definition int.hh:228
ExceptionLevel currEL(const ThreadContext *tc)
Returns the current Exception Level (EL) of the provided ThreadContext.
Definition utility.cc:133
Fault mcrMrc15Trap(const MiscRegIndex misc_reg, ExtMachInst mach_inst, ThreadContext *tc, uint32_t imm)
Definition utility.cc:504
Bitfield< 7 > i
Definition misc_types.hh:67
bool EL2Enabled(ThreadContext *tc)
Definition utility.cc:267
@ MISCREG_TLBIMVALIS
Definition misc.hh:331
@ MISCREG_TLBIMVAALIS
Definition misc.hh:332
@ MISCREG_TLBIMVAAL
Definition misc.hh:344
@ MISCREG_TLBIIPAS2
Definition misc.hh:351
@ MISCREG_TLBIIPAS2L
Definition misc.hh:352
@ MISCREG_SCR_EL3
Definition misc.hh:604
@ MISCREG_TLBIALLHIS
Definition misc.hh:347
@ MISCREG_TLBIIPAS2LIS
Definition misc.hh:346
@ MISCREG_TLBIASIDIS
Definition misc.hh:329
@ MISCREG_DTLBIMVA
Definition misc.hh:337
@ MISCREG_TLBIMVALH
Definition misc.hh:356
@ MISCREG_TLBIMVA
Definition misc.hh:340
@ MISCREG_TLBIMVAL
Definition misc.hh:343
@ MISCREG_ITLBIALL
Definition misc.hh:333
@ MISCREG_TLBIALLNSNH
Definition misc.hh:355
@ MISCREG_CPSR
Definition misc.hh:67
@ MISCREG_TLBIIPAS2IS
Definition misc.hh:345
@ MISCREG_TLBIMVAAIS
Definition misc.hh:330
@ MISCREG_TLBIMVAHIS
Definition misc.hh:348
@ MISCREG_DTLBIALL
Definition misc.hh:336
@ MISCREG_TLBIALLIS
Definition misc.hh:327
@ MISCREG_TLBIASID
Definition misc.hh:341
@ MISCREG_ITLBIMVA
Definition misc.hh:334
@ MISCREG_TLBIALLNSNHIS
Definition misc.hh:349
@ MISCREG_HCR_EL2
Definition misc.hh:595
@ MISCREG_TLBIMVALHIS
Definition misc.hh:350
@ MISCREG_ITLBIASID
Definition misc.hh:335
@ MISCREG_TLBIMVAIS
Definition misc.hh:328
@ MISCREG_TLBIALLH
Definition misc.hh:353
@ MISCREG_TLBIMVAH
Definition misc.hh:354
@ MISCREG_DTLBIASID
Definition misc.hh:338
@ MISCREG_TLBIALL
Definition misc.hh:339
@ MISCREG_TLBIMVAA
Definition misc.hh:342
@ MISCREG_SPSR
Definition misc.hh:68
Bitfield< 27, 25 > encoding
Definition types.hh:90
Bitfield< 21 > ss
Definition misc_types.hh:60
Bitfield< 4 > pc
Bitfield< 5, 3 > reg
Definition types.hh:92
Bitfield< 17 > os
Definition misc.hh:838
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::shared_ptr< FaultBase > Fault
Definition types.hh:249
uint64_t RegVal
Definition types.hh:173
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
std::string csprintf(const char *format, const Args &...args)
Definition cprintf.hh:161
constexpr decltype(nullptr) NoFault
Definition types.hh:253
@ MiscRegClass
Control (misc) register.
Definition reg_class.hh:70
void ccprintf(cp::Print &print)
Definition cprintf.hh:130
The file contains the definition of a set of TLB Invalidate Instructions.

Generated on Tue Jun 18 2024 16:23:57 for gem5 by doxygen 1.11.0