gem5 v24.1.0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
415 SecurityState::Secure : SecurityState::NonSecure;
416 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
417 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
418 hcr.fb && !hcr.tge;
419
420 TLBIALL tlbiOp(TranslationRegime::EL10, ss);
421 if (shareable) {
422 tlbiOp.broadcast(tc);
423 } else {
424 tlbiOp(tc);
425 }
426 return;
427 }
428 // TLB Invalidate All, Inner Shareable
430 {
431 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
432
433 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
434 SecurityState::Secure : SecurityState::NonSecure;
435 TLBIALL tlbiOp(TranslationRegime::EL10, ss);
436 tlbiOp.broadcast(tc);
437 return;
438 }
439 // Instruction TLB Invalidate All
440 case MISCREG_ITLBIALL:
441 {
442 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
443 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
444
445 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
446 SecurityState::Secure : SecurityState::NonSecure;
447 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
448 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
449 hcr.fb && !hcr.tge;
450
451 ITLBIALL tlbiOp(TranslationRegime::EL10, ss);
452 if (shareable) {
453 tlbiOp.broadcast(tc);
454 } else {
455 tlbiOp(tc);
456 }
457 return;
458 }
459 // Data TLB Invalidate All
460 case MISCREG_DTLBIALL:
461 {
462 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
463 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
464
465 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
466 SecurityState::Secure : SecurityState::NonSecure;
467 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
468 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
469 hcr.fb && !hcr.tge;
470
471 DTLBIALL tlbiOp(TranslationRegime::EL10, ss);
472 if (shareable) {
473 tlbiOp.broadcast(tc);
474 } else {
475 tlbiOp(tc);
476 }
477 return;
478 }
479 // TLB Invalidate by VA
480 case MISCREG_TLBIMVA:
481 {
482 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
483 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
484
485 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
486 SecurityState::Secure : SecurityState::NonSecure;
487 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
488 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
489 hcr.fb && !hcr.tge;
490
491 TLBIMVA tlbiOp(TranslationRegime::EL10,
492 ss,
493 mbits(value, 31, 12),
494 bits(value, 7, 0),
495 false);
496
497 if (shareable) {
498 tlbiOp.broadcast(tc);
499 } else {
500 tlbiOp(tc);
501 }
502 return;
503 }
504 // TLB Invalidate by VA, Last Level
505 case MISCREG_TLBIMVAL:
506 {
507 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
508 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
509
510 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
511 SecurityState::Secure : SecurityState::NonSecure;
512 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
513 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
514 hcr.fb && !hcr.tge;
515
516 TLBIMVA tlbiOp(TranslationRegime::EL10,
517 ss,
518 mbits(value, 31, 12),
519 bits(value, 7, 0),
520 true);
521
522 if (shareable) {
523 tlbiOp.broadcast(tc);
524 } else {
525 tlbiOp(tc);
526 }
527 return;
528 }
529 // TLB Invalidate by VA, Inner Shareable
531 {
532 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
533
534 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
535 SecurityState::Secure : SecurityState::NonSecure;
536 TLBIMVA tlbiOp(TranslationRegime::EL10,
537 ss,
538 mbits(value, 31, 12),
539 bits(value, 7, 0),
540 false);
541
542 tlbiOp.broadcast(tc);
543 return;
544 }
545 // TLB Invalidate by VA, Last Level, Inner Shareable
547 {
548 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
549
550 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
551 SecurityState::Secure : SecurityState::NonSecure;
552 TLBIMVA tlbiOp(TranslationRegime::EL10,
553 ss,
554 mbits(value, 31, 12),
555 bits(value, 7, 0),
556 true);
557
558 tlbiOp.broadcast(tc);
559 return;
560 }
561 // TLB Invalidate by ASID match
562 case MISCREG_TLBIASID:
563 {
564 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
565 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
566
567 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
568 SecurityState::Secure : SecurityState::NonSecure;
569 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
570 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
571 hcr.fb && !hcr.tge;
572
573 TLBIASID tlbiOp(TranslationRegime::EL10,
574 ss,
575 bits(value, 7, 0));
576
577 if (shareable) {
578 tlbiOp.broadcast(tc);
579 } else {
580 tlbiOp(tc);
581 }
582 return;
583 }
584 // TLB Invalidate by ASID match, Inner Shareable
586 {
587 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
588
589 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
590 SecurityState::Secure : SecurityState::NonSecure;
591 TLBIASID tlbiOp(TranslationRegime::EL10,
592 ss,
593 bits(value, 7, 0));
594
595 tlbiOp.broadcast(tc);
596 return;
597 }
598 // TLB Invalidate by VA, All ASID
599 case MISCREG_TLBIMVAA:
600 {
601 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
602 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
603
604 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
605 SecurityState::Secure : SecurityState::NonSecure;
606 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
607 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
608 hcr.fb && !hcr.tge;
609 TLBIMVAA tlbiOp(TranslationRegime::EL10, ss,
610 mbits(value, 31, 12), false);
611
612 if (shareable) {
613 tlbiOp.broadcast(tc);
614 } else {
615 tlbiOp(tc);
616 }
617 return;
618 }
619 // TLB Invalidate by VA, Last Level, All ASID
621 {
622 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
623 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
624
625 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
626 SecurityState::Secure : SecurityState::NonSecure;
627 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
628 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
629 hcr.fb && !hcr.tge;
630
631 TLBIMVAA tlbiOp(TranslationRegime::EL10, ss,
632 mbits(value, 31, 12), true);
633
634 if (shareable) {
635 tlbiOp.broadcast(tc);
636 } else {
637 tlbiOp(tc);
638 }
639 return;
640 }
641 // TLB Invalidate by VA, All ASID, Inner Shareable
643 {
644 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
645
646 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
647 SecurityState::Secure : SecurityState::NonSecure;
648 TLBIMVAA tlbiOp(TranslationRegime::EL10, ss,
649 mbits(value, 31, 12), false);
650
651 tlbiOp.broadcast(tc);
652 return;
653 }
654 // TLB Invalidate by VA, All ASID, Last Level, Inner Shareable
656 {
657 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
658
659 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
660 SecurityState::Secure : SecurityState::NonSecure;
661 TLBIMVAA tlbiOp(TranslationRegime::EL10, ss,
662 mbits(value, 31, 12), true);
663
664 tlbiOp.broadcast(tc);
665 return;
666 }
667 // TLB Invalidate by VA, Hyp mode
668 case MISCREG_TLBIMVAH:
669 {
670 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
671
672 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
673 SecurityState::Secure : SecurityState::NonSecure;
674 TLBIMVAA tlbiOp(TranslationRegime::EL2, ss,
675 mbits(value, 31, 12), false);
676
677 tlbiOp(tc);
678 return;
679 }
680 // TLB Invalidate by VA, Last Level, Hyp mode
682 {
683 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
684
685 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
686 SecurityState::Secure : SecurityState::NonSecure;
687 TLBIMVAA tlbiOp(TranslationRegime::EL2, ss,
688 mbits(value, 31, 12), true);
689
690 tlbiOp(tc);
691 return;
692 }
693 // TLB Invalidate by VA, Hyp mode, Inner Shareable
695 {
696 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
697
698 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
699 SecurityState::Secure : SecurityState::NonSecure;
700 TLBIMVAA tlbiOp(TranslationRegime::EL2, ss,
701 mbits(value, 31, 12), false);
702
703 tlbiOp.broadcast(tc);
704 return;
705 }
706 // TLB Invalidate by VA, Hyp mode, Last Level, Inner Shareable
708 {
709 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
710
711 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
712 SecurityState::Secure : SecurityState::NonSecure;
713 TLBIMVAA tlbiOp(TranslationRegime::EL2, ss,
714 mbits(value, 31, 12), true);
715
716 tlbiOp.broadcast(tc);
717 return;
718 }
719 // TLB Invalidate by Intermediate Physical Address, Stage 2
721 {
722 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
723
724 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
725 SecurityState::Secure : SecurityState::NonSecure;
726 TLBIIPA tlbiOp(TranslationRegime::EL10,
727 ss,
728 static_cast<Addr>(bits(value, 35, 0)) << 12,
729 false);
730
731 tlbiOp(tc);
732 return;
733 }
734 // TLB Invalidate by Intermediate Physical Address, Stage 2,
735 // Last Level
737 {
738 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
739
740 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
741 SecurityState::Secure : SecurityState::NonSecure;
742 TLBIIPA tlbiOp(TranslationRegime::EL10,
743 ss,
744 static_cast<Addr>(bits(value, 35, 0)) << 12,
745 true);
746
747 tlbiOp(tc);
748 return;
749 }
750 // TLB Invalidate by Intermediate Physical Address, Stage 2,
751 // Inner Shareable
753 {
754 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
755
756 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
757 SecurityState::Secure : SecurityState::NonSecure;
758 TLBIIPA tlbiOp(TranslationRegime::EL10,
759 ss,
760 static_cast<Addr>(bits(value, 35, 0)) << 12,
761 false);
762
763 tlbiOp.broadcast(tc);
764 return;
765 }
766 // TLB Invalidate by Intermediate Physical Address, Stage 2,
767 // Last Level, Inner Shareable
769 {
770 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
771
772 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
773 SecurityState::Secure : SecurityState::NonSecure;
774 TLBIIPA tlbiOp(TranslationRegime::EL10,
775 ss,
776 static_cast<Addr>(bits(value, 35, 0)) << 12,
777 true);
778
779 tlbiOp.broadcast(tc);
780 return;
781 }
782 // Instruction TLB Invalidate by VA
783 case MISCREG_ITLBIMVA:
784 {
785 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
786 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
787
788 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
789 SecurityState::Secure : SecurityState::NonSecure;
790 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
791 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
792 hcr.fb && !hcr.tge;
793
794 ITLBIMVA tlbiOp(TranslationRegime::EL10,
795 ss,
796 mbits(value, 31, 12),
797 bits(value, 7, 0));
798
799 if (shareable) {
800 tlbiOp.broadcast(tc);
801 } else {
802 tlbiOp(tc);
803 }
804 return;
805 }
806 // Data TLB Invalidate by VA
807 case MISCREG_DTLBIMVA:
808 {
809 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
810 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
811
812 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
813 SecurityState::Secure : SecurityState::NonSecure;
814 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
815 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
816 hcr.fb && !hcr.tge;
817
818 DTLBIMVA tlbiOp(TranslationRegime::EL10,
819 ss,
820 mbits(value, 31, 12),
821 bits(value, 7, 0));
822
823 if (shareable) {
824 tlbiOp.broadcast(tc);
825 } else {
826 tlbiOp(tc);
827 }
828 return;
829 }
830 // Instruction TLB Invalidate by ASID match
832 {
833 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
834 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
835
836 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
837 SecurityState::Secure : SecurityState::NonSecure;
838 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
839 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
840 hcr.fb && !hcr.tge;
841
842 ITLBIASID tlbiOp(TranslationRegime::EL10,
843 ss,
844 bits(value, 7, 0));
845
846 if (shareable) {
847 tlbiOp.broadcast(tc);
848 } else {
849 tlbiOp(tc);
850 }
851 return;
852 }
853 // Data TLB Invalidate by ASID match
855 {
856 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
857 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
858
859 auto ss = release->has(ArmExtension::SECURITY) && !scr.ns ?
860 SecurityState::Secure : SecurityState::NonSecure;
861 // Check for Force Broadcast. Ignored if HCR_EL2.TGE == 1
862 bool shareable = currEL(tc) == EL1 && EL2Enabled(tc) &&
863 hcr.fb && !hcr.tge;
864
865 DTLBIASID tlbiOp(TranslationRegime::EL10,
866 ss,
867 bits(value, 7, 0));
868
869 if (shareable) {
870 tlbiOp.broadcast(tc);
871 } else {
872 tlbiOp(tc);
873 }
874 return;
875 }
876 // TLB Invalidate All, Non-Secure Non-Hyp
878 {
879 TLBIALLN tlbiOp(TranslationRegime::EL10);
880 tlbiOp(tc);
881 return;
882 }
883 // TLB Invalidate All, Non-Secure Non-Hyp, Inner Shareable
885 {
886 TLBIALLN tlbiOp(TranslationRegime::EL10);
887 tlbiOp.broadcast(tc);
888 return;
889 }
890 // TLB Invalidate All, Hyp mode
891 case MISCREG_TLBIALLH:
892 {
893 TLBIALLN tlbiOp(TranslationRegime::EL2);
894 tlbiOp(tc);
895 return;
896 }
897 // TLB Invalidate All, Hyp mode, Inner Shareable
899 {
900 TLBIALLN tlbiOp(TranslationRegime::EL2);
901 tlbiOp.broadcast(tc);
902 return;
903 }
904 default:
905 panic("Unrecognized TLBIOp\n");
906 }
907}
908
909} // 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:157
Data TLB Invalidate by ASID match.
Definition tlbi_op.hh:247
Data TLB Invalidate by VA.
Definition tlbi_op.hh:337
const ArmRelease * getRelease() const
Definition isa.hh:194
Instruction TLB Invalidate All.
Definition tlbi_op.hh:144
Instruction TLB Invalidate by ASID match.
Definition tlbi_op.hh:233
Instruction TLB Invalidate by VA.
Definition tlbi_op.hh:323
TLB Invalidate All, Non-Secure.
Definition tlbi_op.hh:261
TLB Invalidate All.
Definition tlbi_op.hh:118
TLB Invalidate by ASID match.
Definition tlbi_op.hh:215
TLB Invalidate by Intermediate Physical Address.
Definition tlbi_op.hh:406
TLB Invalidate by VA, All ASID.
Definition tlbi_op.hh:280
TLB Invalidate by VA.
Definition tlbi_op.hh:300
void broadcast(ThreadContext *tc)
Broadcast the TLB Invalidate operation to all TLBs in the Arm system.
Definition tlbi_op.hh:79
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:134
Fault mcrMrc15Trap(const MiscRegIndex misc_reg, ExtMachInst mach_inst, ThreadContext *tc, uint32_t imm)
Definition utility.cc:505
Bitfield< 7 > i
Definition misc_types.hh:67
bool EL2Enabled(ThreadContext *tc)
Definition utility.cc:268
@ MISCREG_TLBIMVALIS
Definition misc.hh:343
@ MISCREG_TLBIMVAALIS
Definition misc.hh:344
@ MISCREG_TLBIMVAAL
Definition misc.hh:356
@ MISCREG_TLBIIPAS2
Definition misc.hh:363
@ MISCREG_TLBIIPAS2L
Definition misc.hh:364
@ MISCREG_SCR_EL3
Definition misc.hh:628
@ MISCREG_TLBIALLHIS
Definition misc.hh:359
@ MISCREG_TLBIIPAS2LIS
Definition misc.hh:358
@ MISCREG_TLBIASIDIS
Definition misc.hh:341
@ MISCREG_DTLBIMVA
Definition misc.hh:349
@ MISCREG_TLBIMVALH
Definition misc.hh:368
@ MISCREG_TLBIMVA
Definition misc.hh:352
@ MISCREG_TLBIMVAL
Definition misc.hh:355
@ MISCREG_ITLBIALL
Definition misc.hh:345
@ MISCREG_TLBIALLNSNH
Definition misc.hh:367
@ MISCREG_CPSR
Definition misc.hh:79
@ MISCREG_TLBIIPAS2IS
Definition misc.hh:357
@ MISCREG_TLBIMVAAIS
Definition misc.hh:342
@ MISCREG_TLBIMVAHIS
Definition misc.hh:360
@ MISCREG_DTLBIALL
Definition misc.hh:348
@ MISCREG_TLBIALLIS
Definition misc.hh:339
@ MISCREG_TLBIASID
Definition misc.hh:353
@ MISCREG_ITLBIMVA
Definition misc.hh:346
@ MISCREG_TLBIALLNSNHIS
Definition misc.hh:361
@ MISCREG_HCR_EL2
Definition misc.hh:619
@ MISCREG_TLBIMVALHIS
Definition misc.hh:362
@ MISCREG_ITLBIASID
Definition misc.hh:347
@ MISCREG_TLBIMVAIS
Definition misc.hh:340
@ MISCREG_TLBIALLH
Definition misc.hh:365
@ MISCREG_TLBIMVAH
Definition misc.hh:366
@ MISCREG_DTLBIASID
Definition misc.hh:350
@ MISCREG_TLBIALL
Definition misc.hh:351
@ MISCREG_TLBIMVAA
Definition misc.hh:354
@ MISCREG_SPSR
Definition misc.hh:80
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 Arm Limited All rights reserved.
Definition binary32.hh:36
std::shared_ptr< FaultBase > Fault
Definition types.hh:249
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t RegVal
Definition types.hh:173
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 Mon Jan 13 2025 04:28:21 for gem5 by doxygen 1.9.8