2 * Copyright (c) 2010-2020 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.
41 #ifndef __ARCH_ARM_MISCREGS_HH__
42 #define __ARCH_ARM_MISCREGS_HH__
47 #include "arch/arm/miscregs_types.hh"
48 #include "base/compiler.hh"
49 #include "dev/arm/generic_timer_miscregs_types.hh"
81 MISCREG_PRRR_MAIR0_NS,
84 MISCREG_NMRR_MAIR1_NS,
86 MISCREG_PMXEVTYPER_PMCCFILTR,
90 // AArch32 CP14 registers (debug/trace/ThumbEE/Jazelle control)
132 MISCREG_DBGAUTHSTATUS,
136 MISCREG_TEECR, // not in ARM DDI 0487A.b+
138 MISCREG_TEEHBR, // not in ARM DDI 0487A.b+
142 // AArch32 CP15 registers (system control)
275 MISCREG_TLBIIPAS2LIS,
278 MISCREG_TLBIALLNSNHIS,
335 MISCREG_CONTEXTIDR_NS,
336 MISCREG_CONTEXTIDR_S,
347 // BEGIN Generic Timer (AArch32)
355 MISCREG_CNTP_CVAL_NS,
358 MISCREG_CNTP_TVAL_NS,
369 // END Generic Timer (AArch32)
387 // AArch64 registers (Op0=2)
417 MISCREG_DBGVCR32_EL2,
423 MISCREG_DBGCLAIMSET_EL1,
424 MISCREG_DBGCLAIMCLR_EL1,
425 MISCREG_DBGAUTHSTATUS_EL1,
426 MISCREG_TEECR32_EL1, // not in ARM DDI 0487A.b+
427 MISCREG_TEEHBR32_EL1, // not in ARM DDI 0487A.b+
429 // AArch64 registers (Op0=1,3)
437 MISCREG_ID_MMFR0_EL1,
438 MISCREG_ID_MMFR1_EL1,
439 MISCREG_ID_MMFR2_EL1,
440 MISCREG_ID_MMFR3_EL1,
441 MISCREG_ID_ISAR0_EL1,
442 MISCREG_ID_ISAR1_EL1,
443 MISCREG_ID_ISAR2_EL1,
444 MISCREG_ID_ISAR3_EL1,
445 MISCREG_ID_ISAR4_EL1,
446 MISCREG_ID_ISAR5_EL1,
450 MISCREG_ID_AA64PFR0_EL1,
451 MISCREG_ID_AA64PFR1_EL1,
452 MISCREG_ID_AA64DFR0_EL1,
453 MISCREG_ID_AA64DFR1_EL1,
454 MISCREG_ID_AA64AFR0_EL1,
455 MISCREG_ID_AA64AFR1_EL1,
456 MISCREG_ID_AA64ISAR0_EL1,
457 MISCREG_ID_AA64ISAR1_EL1,
458 MISCREG_ID_AA64MMFR0_EL1,
459 MISCREG_ID_AA64MMFR1_EL1,
508 MISCREG_SPSR_IRQ_AA64,
509 MISCREG_SPSR_ABT_AA64,
510 MISCREG_SPSR_UND_AA64,
511 MISCREG_SPSR_FIQ_AA64,
548 MISCREG_AT_S12E1R_Xt,
549 MISCREG_AT_S12E1W_Xt,
550 MISCREG_AT_S12E0R_Xt,
551 MISCREG_AT_S12E0W_Xt,
554 MISCREG_TLBI_VMALLE1IS,
555 MISCREG_TLBI_VAE1IS_Xt,
556 MISCREG_TLBI_ASIDE1IS_Xt,
557 MISCREG_TLBI_VAAE1IS_Xt,
558 MISCREG_TLBI_VALE1IS_Xt,
559 MISCREG_TLBI_VAALE1IS_Xt,
560 MISCREG_TLBI_VMALLE1,
561 MISCREG_TLBI_VAE1_Xt,
562 MISCREG_TLBI_ASIDE1_Xt,
563 MISCREG_TLBI_VAAE1_Xt,
564 MISCREG_TLBI_VALE1_Xt,
565 MISCREG_TLBI_VAALE1_Xt,
566 MISCREG_TLBI_IPAS2E1IS_Xt,
567 MISCREG_TLBI_IPAS2LE1IS_Xt,
568 MISCREG_TLBI_ALLE2IS,
569 MISCREG_TLBI_VAE2IS_Xt,
570 MISCREG_TLBI_ALLE1IS,
571 MISCREG_TLBI_VALE2IS_Xt,
572 MISCREG_TLBI_VMALLS12E1IS,
573 MISCREG_TLBI_IPAS2E1_Xt,
574 MISCREG_TLBI_IPAS2LE1_Xt,
576 MISCREG_TLBI_VAE2_Xt,
578 MISCREG_TLBI_VALE2_Xt,
579 MISCREG_TLBI_VMALLS12E1,
580 MISCREG_TLBI_ALLE3IS,
581 MISCREG_TLBI_VAE3IS_Xt,
582 MISCREG_TLBI_VALE3IS_Xt,
584 MISCREG_TLBI_VAE3_Xt,
585 MISCREG_TLBI_VALE3_Xt,
586 MISCREG_PMINTENSET_EL1,
587 MISCREG_PMINTENCLR_EL1,
589 MISCREG_PMCNTENSET_EL0,
590 MISCREG_PMCNTENCLR_EL0,
591 MISCREG_PMOVSCLR_EL0,
597 MISCREG_PMXEVTYPER_EL0,
598 MISCREG_PMCCFILTR_EL0,
599 MISCREG_PMXEVCNTR_EL0,
600 MISCREG_PMUSERENR_EL0,
601 MISCREG_PMOVSSET_EL0,
618 MISCREG_CONTEXTIDR_EL1,
624 // BEGIN Generic Timer (AArch64)
628 MISCREG_CNTP_CTL_EL0,
629 MISCREG_CNTP_CVAL_EL0,
630 MISCREG_CNTP_TVAL_EL0,
631 MISCREG_CNTV_CTL_EL0,
632 MISCREG_CNTV_CVAL_EL0,
633 MISCREG_CNTV_TVAL_EL0,
634 MISCREG_CNTP_CTL_EL02,
635 MISCREG_CNTP_CVAL_EL02,
636 MISCREG_CNTP_TVAL_EL02,
637 MISCREG_CNTV_CTL_EL02,
638 MISCREG_CNTV_CVAL_EL02,
639 MISCREG_CNTV_TVAL_EL02,
641 MISCREG_CNTKCTL_EL12,
642 MISCREG_CNTPS_CTL_EL1,
643 MISCREG_CNTPS_CVAL_EL1,
644 MISCREG_CNTPS_TVAL_EL1,
646 MISCREG_CNTHP_CTL_EL2,
647 MISCREG_CNTHP_CVAL_EL2,
648 MISCREG_CNTHP_TVAL_EL2,
650 MISCREG_CNTHV_CTL_EL2,
651 MISCREG_CNTHV_CVAL_EL2,
652 MISCREG_CNTHV_TVAL_EL2,
655 // END Generic Timer (AArch64)
656 MISCREG_PMEVCNTR0_EL0,
657 MISCREG_PMEVCNTR1_EL0,
658 MISCREG_PMEVCNTR2_EL0,
659 MISCREG_PMEVCNTR3_EL0,
660 MISCREG_PMEVCNTR4_EL0,
661 MISCREG_PMEVCNTR5_EL0,
662 MISCREG_PMEVTYPER0_EL0,
663 MISCREG_PMEVTYPER1_EL0,
664 MISCREG_PMEVTYPER2_EL0,
665 MISCREG_PMEVTYPER3_EL0,
666 MISCREG_PMEVTYPER4_EL0,
667 MISCREG_PMEVTYPER5_EL0,
668 MISCREG_IL1DATA0_EL1,
669 MISCREG_IL1DATA1_EL1,
670 MISCREG_IL1DATA2_EL1,
671 MISCREG_IL1DATA3_EL1,
672 MISCREG_DL1DATA0_EL1,
673 MISCREG_DL1DATA1_EL1,
674 MISCREG_DL1DATA2_EL1,
675 MISCREG_DL1DATA3_EL1,
676 MISCREG_DL1DATA4_EL1,
678 MISCREG_CPUACTLR_EL1,
679 MISCREG_CPUECTLR_EL1,
680 MISCREG_CPUMERRSR_EL1,
681 MISCREG_L2MERRSR_EL1,
683 MISCREG_CONTEXTIDR_EL2,
685 // Introduced in ARMv8.1
688 MISCREG_ID_AA64MMFR2_EL1,
690 //PAuth Key Regsiters
691 MISCREG_APDAKeyHi_EL1,
692 MISCREG_APDAKeyLo_EL1,
693 MISCREG_APDBKeyHi_EL1,
694 MISCREG_APDBKeyLo_EL1,
695 MISCREG_APGAKeyHi_EL1,
696 MISCREG_APGAKeyLo_EL1,
697 MISCREG_APIAKeyHi_EL1,
698 MISCREG_APIAKeyLo_EL1,
699 MISCREG_APIBKeyHi_EL1,
700 MISCREG_APIBKeyLo_EL1,
702 // GICv3, CPU interface
704 MISCREG_ICC_IAR0_EL1,
705 MISCREG_ICC_EOIR0_EL1,
706 MISCREG_ICC_HPPIR0_EL1,
707 MISCREG_ICC_BPR0_EL1,
708 MISCREG_ICC_AP0R0_EL1,
709 MISCREG_ICC_AP0R1_EL1,
710 MISCREG_ICC_AP0R2_EL1,
711 MISCREG_ICC_AP0R3_EL1,
712 MISCREG_ICC_AP1R0_EL1,
713 MISCREG_ICC_AP1R0_EL1_NS,
714 MISCREG_ICC_AP1R0_EL1_S,
715 MISCREG_ICC_AP1R1_EL1,
716 MISCREG_ICC_AP1R1_EL1_NS,
717 MISCREG_ICC_AP1R1_EL1_S,
718 MISCREG_ICC_AP1R2_EL1,
719 MISCREG_ICC_AP1R2_EL1_NS,
720 MISCREG_ICC_AP1R2_EL1_S,
721 MISCREG_ICC_AP1R3_EL1,
722 MISCREG_ICC_AP1R3_EL1_NS,
723 MISCREG_ICC_AP1R3_EL1_S,
726 MISCREG_ICC_SGI1R_EL1,
727 MISCREG_ICC_ASGI1R_EL1,
728 MISCREG_ICC_SGI0R_EL1,
729 MISCREG_ICC_IAR1_EL1,
730 MISCREG_ICC_EOIR1_EL1,
731 MISCREG_ICC_HPPIR1_EL1,
732 MISCREG_ICC_BPR1_EL1,
733 MISCREG_ICC_BPR1_EL1_NS,
734 MISCREG_ICC_BPR1_EL1_S,
735 MISCREG_ICC_CTLR_EL1,
736 MISCREG_ICC_CTLR_EL1_NS,
737 MISCREG_ICC_CTLR_EL1_S,
739 MISCREG_ICC_SRE_EL1_NS,
740 MISCREG_ICC_SRE_EL1_S,
741 MISCREG_ICC_IGRPEN0_EL1,
742 MISCREG_ICC_IGRPEN1_EL1,
743 MISCREG_ICC_IGRPEN1_EL1_NS,
744 MISCREG_ICC_IGRPEN1_EL1_S,
746 MISCREG_ICC_CTLR_EL3,
748 MISCREG_ICC_IGRPEN1_EL3,
750 // GICv3, CPU interface, virtualization
751 MISCREG_ICH_AP0R0_EL2,
752 MISCREG_ICH_AP0R1_EL2,
753 MISCREG_ICH_AP0R2_EL2,
754 MISCREG_ICH_AP0R3_EL2,
755 MISCREG_ICH_AP1R0_EL2,
756 MISCREG_ICH_AP1R1_EL2,
757 MISCREG_ICH_AP1R2_EL2,
758 MISCREG_ICH_AP1R3_EL2,
761 MISCREG_ICH_MISR_EL2,
762 MISCREG_ICH_EISR_EL2,
763 MISCREG_ICH_ELRSR_EL2,
764 MISCREG_ICH_VMCR_EL2,
775 MISCREG_ICH_LR10_EL2,
776 MISCREG_ICH_LR11_EL2,
777 MISCREG_ICH_LR12_EL2,
778 MISCREG_ICH_LR13_EL2,
779 MISCREG_ICH_LR14_EL2,
780 MISCREG_ICH_LR15_EL2,
783 MISCREG_ICV_IAR0_EL1,
784 MISCREG_ICV_EOIR0_EL1,
785 MISCREG_ICV_HPPIR0_EL1,
786 MISCREG_ICV_BPR0_EL1,
787 MISCREG_ICV_AP0R0_EL1,
788 MISCREG_ICV_AP0R1_EL1,
789 MISCREG_ICV_AP0R2_EL1,
790 MISCREG_ICV_AP0R3_EL1,
791 MISCREG_ICV_AP1R0_EL1,
792 MISCREG_ICV_AP1R0_EL1_NS,
793 MISCREG_ICV_AP1R0_EL1_S,
794 MISCREG_ICV_AP1R1_EL1,
795 MISCREG_ICV_AP1R1_EL1_NS,
796 MISCREG_ICV_AP1R1_EL1_S,
797 MISCREG_ICV_AP1R2_EL1,
798 MISCREG_ICV_AP1R2_EL1_NS,
799 MISCREG_ICV_AP1R2_EL1_S,
800 MISCREG_ICV_AP1R3_EL1,
801 MISCREG_ICV_AP1R3_EL1_NS,
802 MISCREG_ICV_AP1R3_EL1_S,
805 MISCREG_ICV_SGI1R_EL1,
806 MISCREG_ICV_ASGI1R_EL1,
807 MISCREG_ICV_SGI0R_EL1,
808 MISCREG_ICV_IAR1_EL1,
809 MISCREG_ICV_EOIR1_EL1,
810 MISCREG_ICV_HPPIR1_EL1,
811 MISCREG_ICV_BPR1_EL1,
812 MISCREG_ICV_BPR1_EL1_NS,
813 MISCREG_ICV_BPR1_EL1_S,
814 MISCREG_ICV_CTLR_EL1,
815 MISCREG_ICV_CTLR_EL1_NS,
816 MISCREG_ICV_CTLR_EL1_S,
818 MISCREG_ICV_SRE_EL1_NS,
819 MISCREG_ICV_SRE_EL1_S,
820 MISCREG_ICV_IGRPEN0_EL1,
821 MISCREG_ICV_IGRPEN1_EL1,
822 MISCREG_ICV_IGRPEN1_EL1_NS,
823 MISCREG_ICV_IGRPEN1_EL1_S,
830 MISCREG_ICC_AP1R0_NS,
833 MISCREG_ICC_AP1R1_NS,
836 MISCREG_ICC_AP1R2_NS,
839 MISCREG_ICC_AP1R3_NS,
859 MISCREG_ICC_IGRPEN1_NS,
860 MISCREG_ICC_IGRPEN1_S,
920 MISCREG_ID_AA64ZFR0_EL1,
926 // NUM_PHYS_MISCREGS specifies the number of actual physical
927 // registers, not considering the following pseudo-registers
928 // (dummy registers), like UNKNOWN, CP15_UNIMPL, MISCREG_IMPDEF_UNIMPL.
929 // Checkpointing should use this physical index when
930 // saving/restoring register values.
940 // Implementation defined register: this represent
941 // a pool of unimplemented registers whose access can throw
942 // either UNDEFINED or hypervisor trap exception.
943 MISCREG_IMPDEF_UNIMPL,
945 // RAS extension (unimplemented)
950 MISCREG_ERXSTATUS_EL1,
952 MISCREG_ERXMISC0_EL1,
953 MISCREG_ERXMISC1_EL1,
961 // Total number of Misc Registers: Physical + Dummy
967 MISCREG_UNVERIFIABLE, // Does the value change on every read (e.g. a
968 // arch generic counter)
969 MISCREG_WARN_NOT_FAIL, // If MISCREG_IMPLEMENTED is deasserted, it
970 // tells whether the instruction should raise a
972 MISCREG_MUTEX, // True if the register corresponds to a pair of
973 // mutually exclusive registers
974 MISCREG_BANKED, // True if the register is banked between the two
975 // security states, and this is the parent node of the
976 // two banked registers
977 MISCREG_BANKED64, // True if the register is banked between the two
978 // security states, and this is the parent node of
979 // the two banked registers. Used in AA64 only.
980 MISCREG_BANKED_CHILD, // The entry is one of the child registers that
981 // forms a banked set of regs (along with the
984 // Access permissions
990 // Privileged modes other than hypervisor or monitor
998 // Hypervisor mode, HCR_EL2.E2H == 1
1001 // Monitor mode, SCR.NS == 0
1004 // Monitor mode, SCR.NS == 1
1007 // Monitor mode, HCR_EL2.E2H == 1
1014 extern std::bitset<NUM_MISCREG_INFOS> miscRegInfo[NUM_MISCREGS];
1016 // Decodes 32-bit CP14 registers accessible through MCR/MRC instructions
1017 MiscRegIndex decodeCP14Reg(unsigned crn, unsigned opc1,
1018 unsigned crm, unsigned opc2);
1019 MiscRegIndex decodeAArch64SysReg(unsigned op0, unsigned op1,
1020 unsigned crn, unsigned crm,
1022 // Whether a particular AArch64 system register is -always- read only.
1023 bool aarch64SysRegReadOnly(MiscRegIndex miscReg);
1025 // Decodes 32-bit CP15 registers accessible through MCR/MRC instructions
1026 MiscRegIndex decodeCP15Reg(unsigned crn, unsigned opc1,
1027 unsigned crm, unsigned opc2);
1029 // Decodes 64-bit CP15 registers accessible through MCRR/MRRC instructions
1030 MiscRegIndex decodeCP15Reg64(unsigned crm, unsigned opc1);
1033 const char * const miscRegName[] = {
1063 "pmxevtyper_pmccfiltr",
1067 // AArch32 CP14 registers
1119 // AArch32 CP15 registers
1362 // AArch64 registers (Op0=2)
1400 "dbgauthstatus_el1",
1404 // AArch64 registers (Op0=1,3)
1541 "tlbi_ipas2e1is_xt",
1542 "tlbi_ipas2le1is_xt",
1547 "tlbi_vmalls12e1is",
1669 // GICv3, CPU interface
1710 "icc_igrpen1_el1_ns",
1711 "icc_igrpen1_el1_s",
1717 // GICv3, CPU interface, virtualization
1789 "icv_igrpen1_el1_ns",
1790 "icv_igrpen1_el1_s",
1917 static_assert(sizeof(miscRegName) / sizeof(*miscRegName) == NUM_MISCREGS,
1918 "The miscRegName array and NUM_MISCREGS are inconsistent.");
1920 // This mask selects bits of the CPSR that actually go in the CondCodes
1921 // integer register to allow renaming.
1922 static const uint32_t CondCodesMask = 0xF00F0000;
1923 static const uint32_t CpsrMaskQ = 0x08000000;
1925 // APSR (Application Program Status Register Mask). It is the user level
1926 // alias for the CPSR. The APSR is a subset of the CPSR. Although
1927 // bits[15:0] are UNKNOWN on reads, it is permitted that, on a read of
1929 // Bit[9] returns the value of CPSR.E.
1930 // Bits[8:6] return the value of CPSR.{A,I, F}, the mask bits.
1931 static const uint32_t ApsrMask = CpsrMaskQ | CondCodesMask | 0x000001D0;
1933 // CPSR (Current Program Status Register Mask).
1934 static const uint32_t CpsrMask = ApsrMask | 0x00F003DF;
1936 // This mask selects bits of the FPSCR that actually go in the FpCondCodes
1937 // integer register to allow renaming.
1938 static const uint32_t FpCondCodesMask = 0xF0000000;
1939 // This mask selects the cumulative FP exception flags of the FPSCR.
1940 static const uint32_t FpscrExcMask = 0x0000009F;
1941 // This mask selects the cumulative saturation flag of the FPSCR.
1942 static const uint32_t FpscrQcMask = 0x08000000;
1945 * Check for permission to read coprocessor registers.
1947 * Checks whether an instruction at the current program mode has
1948 * permissions to read the coprocessor registers. This function
1949 * returns whether the check is undefined and if not whether the
1950 * read access is permitted.
1952 * @param the misc reg indicating the coprocessor
1955 * @param the thread context on the core
1956 * @return a tuple of booleans: can_read, undefined
1958 std::tuple<bool, bool> canReadCoprocReg(MiscRegIndex reg, SCR scr,
1959 CPSR cpsr, ThreadContext *tc);
1962 * Check for permission to write coprocessor registers.
1964 * Checks whether an instruction at the current program mode has
1965 * permissions to write the coprocessor registers. This function
1966 * returns whether the check is undefined and if not whether the
1967 * write access is permitted.
1969 * @param the misc reg indicating the coprocessor
1972 * @param the thread context on the core
1973 * @return a tuple of booleans: can_write, undefined
1975 std::tuple<bool, bool> canWriteCoprocReg(MiscRegIndex reg, SCR scr,
1976 CPSR cpsr, ThreadContext *tc);
1978 // Checks for UNDEFINED behaviours when accessing AArch32
1979 // Generic Timer system registers
1980 bool AArch32isUndefinedGenericTimer(MiscRegIndex reg, ThreadContext *tc);
1982 // Checks read access permissions to AArch64 system registers
1983 bool canReadAArch64SysReg(MiscRegIndex reg, HCR hcr, SCR scr, CPSR cpsr,
1986 // Checks write access permissions to AArch64 system registers
1987 bool canWriteAArch64SysReg(MiscRegIndex reg, HCR hcr, SCR scr, CPSR cpsr,
1990 // Uses just the scr.ns bit to pre flatten the misc regs. This is useful
1991 // for MCR/MRC instructions
1993 snsBankedIndex(MiscRegIndex reg, ThreadContext *tc);
1995 // Flattens a misc reg index using the specified security state. This is
1996 // used for opperations (eg address translations) where the security
1997 // state of the register access may differ from the current state of the
2000 snsBankedIndex(MiscRegIndex reg, ThreadContext *tc, bool ns);
2003 snsBankedIndex64(MiscRegIndex reg, ThreadContext *tc);
2005 // Takes a misc reg index and returns the root reg if its one of a set of
2008 preUnflattenMiscReg();
2011 unflattenMiscReg(int reg);
2015 #endif // __ARCH_ARM_MISCREGS_HH__