2 * Copyright (c) 2010-2019 ARM Limited
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
14 * Copyright (c) 2009 The Regents of The University of Michigan
15 * All rights reserved.
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 #ifndef __ARCH_ARM_MISCREGS_HH__
44 #define __ARCH_ARM_MISCREGS_HH__
49 #include "arch/arm/miscregs_types.hh"
50 #include "base/compiler.hh"
82 MISCREG_PRRR_MAIR0_NS,
85 MISCREG_NMRR_MAIR1_NS,
87 MISCREG_PMXEVTYPER_PMCCFILTR,
91 // AArch32 CP14 registers (debug/trace/ThumbEE/Jazelle control)
133 MISCREG_DBGAUTHSTATUS,
137 MISCREG_TEECR, // not in ARM DDI 0487A.b+
139 MISCREG_TEEHBR, // not in ARM DDI 0487A.b+
143 // AArch32 CP15 registers (system control)
276 MISCREG_TLBIIPAS2LIS,
279 MISCREG_TLBIALLNSNHIS,
336 MISCREG_CONTEXTIDR_NS,
337 MISCREG_CONTEXTIDR_S,
351 MISCREG_CNTP_TVAL_NS,
378 MISCREG_CNTP_CVAL_NS,
386 // AArch64 registers (Op0=2)
416 MISCREG_DBGVCR32_EL2,
422 MISCREG_DBGCLAIMSET_EL1,
423 MISCREG_DBGCLAIMCLR_EL1,
424 MISCREG_DBGAUTHSTATUS_EL1,
425 MISCREG_TEECR32_EL1, // not in ARM DDI 0487A.b+
426 MISCREG_TEEHBR32_EL1, // not in ARM DDI 0487A.b+
428 // AArch64 registers (Op0=1,3)
436 MISCREG_ID_MMFR0_EL1,
437 MISCREG_ID_MMFR1_EL1,
438 MISCREG_ID_MMFR2_EL1,
439 MISCREG_ID_MMFR3_EL1,
440 MISCREG_ID_ISAR0_EL1,
441 MISCREG_ID_ISAR1_EL1,
442 MISCREG_ID_ISAR2_EL1,
443 MISCREG_ID_ISAR3_EL1,
444 MISCREG_ID_ISAR4_EL1,
445 MISCREG_ID_ISAR5_EL1,
449 MISCREG_ID_AA64PFR0_EL1,
450 MISCREG_ID_AA64PFR1_EL1,
451 MISCREG_ID_AA64DFR0_EL1,
452 MISCREG_ID_AA64DFR1_EL1,
453 MISCREG_ID_AA64AFR0_EL1,
454 MISCREG_ID_AA64AFR1_EL1,
455 MISCREG_ID_AA64ISAR0_EL1,
456 MISCREG_ID_AA64ISAR1_EL1,
457 MISCREG_ID_AA64MMFR0_EL1,
458 MISCREG_ID_AA64MMFR1_EL1,
507 MISCREG_SPSR_IRQ_AA64,
508 MISCREG_SPSR_ABT_AA64,
509 MISCREG_SPSR_UND_AA64,
510 MISCREG_SPSR_FIQ_AA64,
547 MISCREG_AT_S12E1R_Xt,
548 MISCREG_AT_S12E1W_Xt,
549 MISCREG_AT_S12E0R_Xt,
550 MISCREG_AT_S12E0W_Xt,
553 MISCREG_TLBI_VMALLE1IS,
554 MISCREG_TLBI_VAE1IS_Xt,
555 MISCREG_TLBI_ASIDE1IS_Xt,
556 MISCREG_TLBI_VAAE1IS_Xt,
557 MISCREG_TLBI_VALE1IS_Xt,
558 MISCREG_TLBI_VAALE1IS_Xt,
559 MISCREG_TLBI_VMALLE1,
560 MISCREG_TLBI_VAE1_Xt,
561 MISCREG_TLBI_ASIDE1_Xt,
562 MISCREG_TLBI_VAAE1_Xt,
563 MISCREG_TLBI_VALE1_Xt,
564 MISCREG_TLBI_VAALE1_Xt,
565 MISCREG_TLBI_IPAS2E1IS_Xt,
566 MISCREG_TLBI_IPAS2LE1IS_Xt,
567 MISCREG_TLBI_ALLE2IS,
568 MISCREG_TLBI_VAE2IS_Xt,
569 MISCREG_TLBI_ALLE1IS,
570 MISCREG_TLBI_VALE2IS_Xt,
571 MISCREG_TLBI_VMALLS12E1IS,
572 MISCREG_TLBI_IPAS2E1_Xt,
573 MISCREG_TLBI_IPAS2LE1_Xt,
575 MISCREG_TLBI_VAE2_Xt,
577 MISCREG_TLBI_VALE2_Xt,
578 MISCREG_TLBI_VMALLS12E1,
579 MISCREG_TLBI_ALLE3IS,
580 MISCREG_TLBI_VAE3IS_Xt,
581 MISCREG_TLBI_VALE3IS_Xt,
583 MISCREG_TLBI_VAE3_Xt,
584 MISCREG_TLBI_VALE3_Xt,
585 MISCREG_PMINTENSET_EL1,
586 MISCREG_PMINTENCLR_EL1,
588 MISCREG_PMCNTENSET_EL0,
589 MISCREG_PMCNTENCLR_EL0,
590 MISCREG_PMOVSCLR_EL0,
596 MISCREG_PMXEVTYPER_EL0,
597 MISCREG_PMCCFILTR_EL0,
598 MISCREG_PMXEVCNTR_EL0,
599 MISCREG_PMUSERENR_EL0,
600 MISCREG_PMOVSSET_EL0,
617 MISCREG_CONTEXTIDR_EL1,
627 MISCREG_CNTP_TVAL_EL0,
628 MISCREG_CNTP_CTL_EL0,
629 MISCREG_CNTP_CVAL_EL0,
630 MISCREG_CNTV_TVAL_EL0,
631 MISCREG_CNTV_CTL_EL0,
632 MISCREG_CNTV_CVAL_EL0,
633 MISCREG_PMEVCNTR0_EL0,
634 MISCREG_PMEVCNTR1_EL0,
635 MISCREG_PMEVCNTR2_EL0,
636 MISCREG_PMEVCNTR3_EL0,
637 MISCREG_PMEVCNTR4_EL0,
638 MISCREG_PMEVCNTR5_EL0,
639 MISCREG_PMEVTYPER0_EL0,
640 MISCREG_PMEVTYPER1_EL0,
641 MISCREG_PMEVTYPER2_EL0,
642 MISCREG_PMEVTYPER3_EL0,
643 MISCREG_PMEVTYPER4_EL0,
644 MISCREG_PMEVTYPER5_EL0,
647 MISCREG_CNTHP_TVAL_EL2,
648 MISCREG_CNTHP_CTL_EL2,
649 MISCREG_CNTHP_CVAL_EL2,
650 MISCREG_CNTPS_TVAL_EL1,
651 MISCREG_CNTPS_CTL_EL1,
652 MISCREG_CNTPS_CVAL_EL1,
653 MISCREG_IL1DATA0_EL1,
654 MISCREG_IL1DATA1_EL1,
655 MISCREG_IL1DATA2_EL1,
656 MISCREG_IL1DATA3_EL1,
657 MISCREG_DL1DATA0_EL1,
658 MISCREG_DL1DATA1_EL1,
659 MISCREG_DL1DATA2_EL1,
660 MISCREG_DL1DATA3_EL1,
661 MISCREG_DL1DATA4_EL1,
663 MISCREG_CPUACTLR_EL1,
664 MISCREG_CPUECTLR_EL1,
665 MISCREG_CPUMERRSR_EL1,
666 MISCREG_L2MERRSR_EL1,
668 MISCREG_CONTEXTIDR_EL2,
670 // Introduced in ARMv8.1
672 MISCREG_CNTHV_CTL_EL2,
673 MISCREG_CNTHV_CVAL_EL2,
674 MISCREG_CNTHV_TVAL_EL2,
676 MISCREG_ID_AA64MMFR2_EL1,
678 // GICv3, CPU interface
680 MISCREG_ICC_IAR0_EL1,
681 MISCREG_ICC_EOIR0_EL1,
682 MISCREG_ICC_HPPIR0_EL1,
683 MISCREG_ICC_BPR0_EL1,
684 MISCREG_ICC_AP0R0_EL1,
685 MISCREG_ICC_AP0R1_EL1,
686 MISCREG_ICC_AP0R2_EL1,
687 MISCREG_ICC_AP0R3_EL1,
688 MISCREG_ICC_AP1R0_EL1,
689 MISCREG_ICC_AP1R0_EL1_NS,
690 MISCREG_ICC_AP1R0_EL1_S,
691 MISCREG_ICC_AP1R1_EL1,
692 MISCREG_ICC_AP1R1_EL1_NS,
693 MISCREG_ICC_AP1R1_EL1_S,
694 MISCREG_ICC_AP1R2_EL1,
695 MISCREG_ICC_AP1R2_EL1_NS,
696 MISCREG_ICC_AP1R2_EL1_S,
697 MISCREG_ICC_AP1R3_EL1,
698 MISCREG_ICC_AP1R3_EL1_NS,
699 MISCREG_ICC_AP1R3_EL1_S,
702 MISCREG_ICC_SGI1R_EL1,
703 MISCREG_ICC_ASGI1R_EL1,
704 MISCREG_ICC_SGI0R_EL1,
705 MISCREG_ICC_IAR1_EL1,
706 MISCREG_ICC_EOIR1_EL1,
707 MISCREG_ICC_HPPIR1_EL1,
708 MISCREG_ICC_BPR1_EL1,
709 MISCREG_ICC_BPR1_EL1_NS,
710 MISCREG_ICC_BPR1_EL1_S,
711 MISCREG_ICC_CTLR_EL1,
712 MISCREG_ICC_CTLR_EL1_NS,
713 MISCREG_ICC_CTLR_EL1_S,
715 MISCREG_ICC_SRE_EL1_NS,
716 MISCREG_ICC_SRE_EL1_S,
717 MISCREG_ICC_IGRPEN0_EL1,
718 MISCREG_ICC_IGRPEN1_EL1,
719 MISCREG_ICC_IGRPEN1_EL1_NS,
720 MISCREG_ICC_IGRPEN1_EL1_S,
722 MISCREG_ICC_CTLR_EL3,
724 MISCREG_ICC_IGRPEN1_EL3,
726 // GICv3, CPU interface, virtualization
727 MISCREG_ICH_AP0R0_EL2,
728 MISCREG_ICH_AP0R1_EL2,
729 MISCREG_ICH_AP0R2_EL2,
730 MISCREG_ICH_AP0R3_EL2,
731 MISCREG_ICH_AP1R0_EL2,
732 MISCREG_ICH_AP1R1_EL2,
733 MISCREG_ICH_AP1R2_EL2,
734 MISCREG_ICH_AP1R3_EL2,
737 MISCREG_ICH_MISR_EL2,
738 MISCREG_ICH_EISR_EL2,
739 MISCREG_ICH_ELRSR_EL2,
740 MISCREG_ICH_VMCR_EL2,
751 MISCREG_ICH_LR10_EL2,
752 MISCREG_ICH_LR11_EL2,
753 MISCREG_ICH_LR12_EL2,
754 MISCREG_ICH_LR13_EL2,
755 MISCREG_ICH_LR14_EL2,
756 MISCREG_ICH_LR15_EL2,
759 MISCREG_ICV_IAR0_EL1,
760 MISCREG_ICV_EOIR0_EL1,
761 MISCREG_ICV_HPPIR0_EL1,
762 MISCREG_ICV_BPR0_EL1,
763 MISCREG_ICV_AP0R0_EL1,
764 MISCREG_ICV_AP0R1_EL1,
765 MISCREG_ICV_AP0R2_EL1,
766 MISCREG_ICV_AP0R3_EL1,
767 MISCREG_ICV_AP1R0_EL1,
768 MISCREG_ICV_AP1R0_EL1_NS,
769 MISCREG_ICV_AP1R0_EL1_S,
770 MISCREG_ICV_AP1R1_EL1,
771 MISCREG_ICV_AP1R1_EL1_NS,
772 MISCREG_ICV_AP1R1_EL1_S,
773 MISCREG_ICV_AP1R2_EL1,
774 MISCREG_ICV_AP1R2_EL1_NS,
775 MISCREG_ICV_AP1R2_EL1_S,
776 MISCREG_ICV_AP1R3_EL1,
777 MISCREG_ICV_AP1R3_EL1_NS,
778 MISCREG_ICV_AP1R3_EL1_S,
781 MISCREG_ICV_SGI1R_EL1,
782 MISCREG_ICV_ASGI1R_EL1,
783 MISCREG_ICV_SGI0R_EL1,
784 MISCREG_ICV_IAR1_EL1,
785 MISCREG_ICV_EOIR1_EL1,
786 MISCREG_ICV_HPPIR1_EL1,
787 MISCREG_ICV_BPR1_EL1,
788 MISCREG_ICV_BPR1_EL1_NS,
789 MISCREG_ICV_BPR1_EL1_S,
790 MISCREG_ICV_CTLR_EL1,
791 MISCREG_ICV_CTLR_EL1_NS,
792 MISCREG_ICV_CTLR_EL1_S,
794 MISCREG_ICV_SRE_EL1_NS,
795 MISCREG_ICV_SRE_EL1_S,
796 MISCREG_ICV_IGRPEN0_EL1,
797 MISCREG_ICV_IGRPEN1_EL1,
798 MISCREG_ICV_IGRPEN1_EL1_NS,
799 MISCREG_ICV_IGRPEN1_EL1_S,
806 MISCREG_ICC_AP1R0_NS,
809 MISCREG_ICC_AP1R1_NS,
812 MISCREG_ICC_AP1R2_NS,
815 MISCREG_ICC_AP1R3_NS,
835 MISCREG_ICC_IGRPEN1_NS,
836 MISCREG_ICC_IGRPEN1_S,
896 MISCREG_ID_AA64ZFR0_EL1,
902 // NUM_PHYS_MISCREGS specifies the number of actual physical
903 // registers, not considering the following pseudo-registers
904 // (dummy registers), like UNKNOWN, CP15_UNIMPL, MISCREG_IMPDEF_UNIMPL.
905 // Checkpointing should use this physical index when
906 // saving/restoring register values.
916 // Implementation defined register: this represent
917 // a pool of unimplemented registers whose access can throw
918 // either UNDEFINED or hypervisor trap exception.
919 MISCREG_IMPDEF_UNIMPL,
921 // RAS extension (unimplemented)
926 MISCREG_ERXSTATUS_EL1,
928 MISCREG_ERXMISC0_EL1,
929 MISCREG_ERXMISC1_EL1,
937 // Total number of Misc Registers: Physical + Dummy
943 MISCREG_UNVERIFIABLE, // Does the value change on every read (e.g. a
944 // arch generic counter)
945 MISCREG_WARN_NOT_FAIL, // If MISCREG_IMPLEMENTED is deasserted, it
946 // tells whether the instruction should raise a
948 MISCREG_MUTEX, // True if the register corresponds to a pair of
949 // mutually exclusive registers
950 MISCREG_BANKED, // True if the register is banked between the two
951 // security states, and this is the parent node of the
952 // two banked registers
953 MISCREG_BANKED64, // True if the register is banked between the two
954 // security states, and this is the parent node of
955 // the two banked registers. Used in AA64 only.
956 MISCREG_BANKED_CHILD, // The entry is one of the child registers that
957 // forms a banked set of regs (along with the
960 // Access permissions
966 // Privileged modes other than hypervisor or monitor
974 // Monitor mode, SCR.NS == 0
977 // Monitor mode, SCR.NS == 1
984 extern std::bitset<NUM_MISCREG_INFOS> miscRegInfo[NUM_MISCREGS];
986 // Decodes 32-bit CP14 registers accessible through MCR/MRC instructions
987 MiscRegIndex decodeCP14Reg(unsigned crn, unsigned opc1,
988 unsigned crm, unsigned opc2);
989 MiscRegIndex decodeAArch64SysReg(unsigned op0, unsigned op1,
990 unsigned crn, unsigned crm,
992 // Whether a particular AArch64 system register is -always- read only.
993 bool aarch64SysRegReadOnly(MiscRegIndex miscReg);
995 // Decodes 32-bit CP15 registers accessible through MCR/MRC instructions
996 MiscRegIndex decodeCP15Reg(unsigned crn, unsigned opc1,
997 unsigned crm, unsigned opc2);
999 // Decodes 64-bit CP15 registers accessible through MCRR/MRRC instructions
1000 MiscRegIndex decodeCP15Reg64(unsigned crm, unsigned opc1);
1003 const char * const miscRegName[] = {
1033 "pmxevtyper_pmccfiltr",
1037 // AArch32 CP14 registers
1089 // AArch32 CP15 registers
1332 // AArch64 registers (Op0=2)
1370 "dbgauthstatus_el1",
1374 // AArch64 registers (Op0=1,3)
1511 "tlbi_ipas2e1is_xt",
1512 "tlbi_ipas2le1is_xt",
1517 "tlbi_vmalls12e1is",
1622 // GICv3, CPU interface
1663 "icc_igrpen1_el1_ns",
1664 "icc_igrpen1_el1_s",
1670 // GICv3, CPU interface, virtualization
1742 "icv_igrpen1_el1_ns",
1743 "icv_igrpen1_el1_s",
1870 static_assert(sizeof(miscRegName) / sizeof(*miscRegName) == NUM_MISCREGS,
1871 "The miscRegName array and NUM_MISCREGS are inconsistent.");
1873 // This mask selects bits of the CPSR that actually go in the CondCodes
1874 // integer register to allow renaming.
1875 static const uint32_t CondCodesMask = 0xF00F0000;
1876 static const uint32_t CpsrMaskQ = 0x08000000;
1878 // APSR (Application Program Status Register Mask). It is the user level
1879 // alias for the CPSR. The APSR is a subset of the CPSR. Although
1880 // bits[15:0] are UNKNOWN on reads, it is permitted that, on a read of
1882 // Bit[9] returns the value of CPSR.E.
1883 // Bits[8:6] return the value of CPSR.{A,I, F}, the mask bits.
1884 static const uint32_t ApsrMask = CpsrMaskQ | CondCodesMask | 0x000001D0;
1886 // CPSR (Current Program Status Register Mask).
1887 static const uint32_t CpsrMask = ApsrMask | 0x00F003DF;
1889 // This mask selects bits of the FPSCR that actually go in the FpCondCodes
1890 // integer register to allow renaming.
1891 static const uint32_t FpCondCodesMask = 0xF0000000;
1892 // This mask selects the cumulative FP exception flags of the FPSCR.
1893 static const uint32_t FpscrExcMask = 0x0000009F;
1894 // This mask selects the cumulative saturation flag of the FPSCR.
1895 static const uint32_t FpscrQcMask = 0x08000000;
1898 * Check for permission to read coprocessor registers.
1900 * Checks whether an instruction at the current program mode has
1901 * permissions to read the coprocessor registers. This function
1902 * returns whether the check is undefined and if not whether the
1903 * read access is permitted.
1905 * @param the misc reg indicating the coprocessor
1908 * @return a tuple of booleans: can_read, undefined
1910 std::tuple<bool, bool> canReadCoprocReg(MiscRegIndex reg, SCR scr,
1914 * Check for permission to write coprocessor registers.
1916 * Checks whether an instruction at the current program mode has
1917 * permissions to write the coprocessor registers. This function
1918 * returns whether the check is undefined and if not whether the
1919 * write access is permitted.
1921 * @param the misc reg indicating the coprocessor
1924 * @return a tuple of booleans: can_write, undefined
1926 std::tuple<bool, bool> canWriteCoprocReg(MiscRegIndex reg, SCR scr,
1929 // Checks read access permissions to AArch64 system registers
1930 bool canReadAArch64SysReg(MiscRegIndex reg, SCR scr, CPSR cpsr,
1933 // Checks write access permissions to AArch64 system registers
1934 bool canWriteAArch64SysReg(MiscRegIndex reg, SCR scr, CPSR cpsr,
1937 // Uses just the scr.ns bit to pre flatten the misc regs. This is useful
1938 // for MCR/MRC instructions
1940 snsBankedIndex(MiscRegIndex reg, ThreadContext *tc);
1942 // Flattens a misc reg index using the specified security state. This is
1943 // used for opperations (eg address translations) where the security
1944 // state of the register access may differ from the current state of the
1947 snsBankedIndex(MiscRegIndex reg, ThreadContext *tc, bool ns);
1950 snsBankedIndex64(MiscRegIndex reg, ThreadContext *tc);
1952 // Takes a misc reg index and returns the root reg if its one of a set of
1955 preUnflattenMiscReg();
1958 unflattenMiscReg(int reg);
1962 #endif // __ARCH_ARM_MISCREGS_HH__