xref: /aosp_15_r20/external/cpuinfo/src/arm/tlb.c (revision 2b54f0db79fd8303838913b20ff3780cddaa909f)
1*2b54f0dbSXin Li 
2*2b54f0dbSXin Li 
3*2b54f0dbSXin Li switch (uarch) {
4*2b54f0dbSXin Li 	case cpuinfo_uarch_cortex_a5:
5*2b54f0dbSXin Li 		/*
6*2b54f0dbSXin Li 		 * Cortex-A5 Technical Reference Manual:
7*2b54f0dbSXin Li 		 * 6.3.1. Micro TLB
8*2b54f0dbSXin Li 		 *   The first level of caching for the page table information is a micro TLB of
9*2b54f0dbSXin Li 		 *   10 entries that is implemented on each of the instruction and data sides.
10*2b54f0dbSXin Li 		 * 6.3.2. Main TLB
11*2b54f0dbSXin Li 		 *   Misses from the instruction and data micro TLBs are handled by a unified main TLB.
12*2b54f0dbSXin Li 		 *   The main TLB is 128-entry two-way set-associative.
13*2b54f0dbSXin Li 		 */
14*2b54f0dbSXin Li 		break;
15*2b54f0dbSXin Li 	case cpuinfo_uarch_cortex_a7:
16*2b54f0dbSXin Li 		/*
17*2b54f0dbSXin Li 		 * Cortex-A7 MPCore Technical Reference Manual:
18*2b54f0dbSXin Li 		 * 5.3.1. Micro TLB
19*2b54f0dbSXin Li 		 *   The first level of caching for the page table information is a micro TLB of
20*2b54f0dbSXin Li 		 *   10 entries that is implemented on each of the instruction and data sides.
21*2b54f0dbSXin Li 		 * 5.3.2. Main TLB
22*2b54f0dbSXin Li 		 *   Misses from the micro TLBs are handled by a unified main TLB. This is a 256-entry 2-way
23*2b54f0dbSXin Li 		 *   set-associative structure. The main TLB supports all the VMSAv7 page sizes of
24*2b54f0dbSXin Li 		 *   4KB, 64KB, 1MB and 16MB in addition to the LPAE page sizes of 2MB and 1G.
25*2b54f0dbSXin Li 		 */
26*2b54f0dbSXin Li 		break;
27*2b54f0dbSXin Li 	case cpuinfo_uarch_cortex_a8:
28*2b54f0dbSXin Li 		/*
29*2b54f0dbSXin Li 		 * Cortex-A8 Technical Reference Manual:
30*2b54f0dbSXin Li 		 * 6.1. About the MMU
31*2b54f0dbSXin Li 		 *    The MMU features include the following:
32*2b54f0dbSXin Li 		 *     - separate, fully-associative, 32-entry data and instruction TLBs
33*2b54f0dbSXin Li 		 *     - TLB entries that support 4KB, 64KB, 1MB, and 16MB pages
34*2b54f0dbSXin Li 		 */
35*2b54f0dbSXin Li 		break;
36*2b54f0dbSXin Li 	case cpuinfo_uarch_cortex_a9:
37*2b54f0dbSXin Li 		/*
38*2b54f0dbSXin Li 		 * ARM Cortex‑A9 Technical Reference Manual:
39*2b54f0dbSXin Li 		 * 6.2.1 Micro TLB
40*2b54f0dbSXin Li 		 *    The first level of caching for the page table information is a micro TLB of 32 entries on the data side,
41*2b54f0dbSXin Li 		 *    and configurable 32 or 64 entries on the instruction side.
42*2b54f0dbSXin Li 		 * 6.2.2 Main TLB
43*2b54f0dbSXin Li 		 *    The main TLB is implemented as a combination of:
44*2b54f0dbSXin Li 		 *     - A fully-associative, lockable array of four elements.
45*2b54f0dbSXin Li 		 *     - A 2-way associative structure of 2x32, 2x64, 2x128 or 2x256 entries.
46*2b54f0dbSXin Li 		 */
47*2b54f0dbSXin Li 		break;
48*2b54f0dbSXin Li 	case cpuinfo_uarch_cortex_a15:
49*2b54f0dbSXin Li 		/*
50*2b54f0dbSXin Li 		 * ARM Cortex-A15 MPCore Processor Technical Reference Manual:
51*2b54f0dbSXin Li 		 * 5.2.1. L1 instruction TLB
52*2b54f0dbSXin Li 		 *    The L1 instruction TLB is a 32-entry fully-associative structure. This TLB caches entries at the 4KB
53*2b54f0dbSXin Li 		 *    granularity of Virtual Address (VA) to Physical Address (PA) mapping only. If the page tables map the
54*2b54f0dbSXin Li 		 *    memory region to a larger granularity than 4K, it only allocates one mapping for the particular 4K region
55*2b54f0dbSXin Li 		 *    to which the current access corresponds.
56*2b54f0dbSXin Li 		 * 5.2.2. L1 data TLB
57*2b54f0dbSXin Li 		 *    There are two separate 32-entry fully-associative TLBs that are used for data loads and stores,
58*2b54f0dbSXin Li 		 *    respectively. Similar to the L1 instruction TLB, both of these cache entries at the 4KB granularity of
59*2b54f0dbSXin Li 		 *    VA to PA mappings only. At implementation time, the Cortex-A15 MPCore processor can be configured with
60*2b54f0dbSXin Li 		 *    the -l1tlb_1m option, to have the L1 data TLB cache entries at both the 4KB and 1MB granularity.
61*2b54f0dbSXin Li 		 *    With this configuration, any translation that results in a 1MB or larger page is cached in the L1 data
62*2b54f0dbSXin Li 		 *    TLB as a 1MB entry. Any translation that results in a page smaller than 1MB is cached in the L1 data TLB
63*2b54f0dbSXin Li 		 *    as a 4KB entry. By default, all translations are cached in the L1 data TLB as a 4KB entry.
64*2b54f0dbSXin Li 		 * 5.2.3. L2 TLB
65*2b54f0dbSXin Li 		 *    Misses from the L1 instruction and data TLBs are handled by a unified L2 TLB. This is a 512-entry 4-way
66*2b54f0dbSXin Li 		 *    set-associative structure. The L2 TLB supports all the VMSAv7 page sizes of 4K, 64K, 1MB and 16MB in
67*2b54f0dbSXin Li 		 *    addition to the LPAE page sizes of 2MB and 1GB.
68*2b54f0dbSXin Li 		 */
69*2b54f0dbSXin Li 		break;
70*2b54f0dbSXin Li 	case cpuinfo_uarch_cortex_a17:
71*2b54f0dbSXin Li 		/*
72*2b54f0dbSXin Li 		 * ARM Cortex-A17 MPCore Processor Technical Reference Manual:
73*2b54f0dbSXin Li 		 * 5.2.1. Instruction micro TLB
74*2b54f0dbSXin Li 		 *    The instruction micro TLB is implemented as a 32, 48 or 64 entry, fully-associative structure. This TLB
75*2b54f0dbSXin Li 		 *    caches entries at the 4KB and 1MB granularity of Virtual Address (VA) to Physical Address (PA) mapping
76*2b54f0dbSXin Li 		 *    only. If the translation tables map the memory region to a larger granularity than 4KB or 1MB, it only
77*2b54f0dbSXin Li 		 *    allocates one mapping for the particular 4KB region to which the current access corresponds.
78*2b54f0dbSXin Li 		 * 5.2.2. Data micro TLB
79*2b54f0dbSXin Li 		 *    The data micro TLB is a 32 entry fully-associative TLB that is used for data loads and stores. The cache
80*2b54f0dbSXin Li 		 *    entries have a 4KB and 1MB granularity of VA to PA mappings only.
81*2b54f0dbSXin Li 		 * 5.2.3. Unified main TLB
82*2b54f0dbSXin Li 		 *    Misses from the instruction and data micro TLBs are handled by a unified main TLB. This is a 1024 entry
83*2b54f0dbSXin Li 		 *    4-way set-associative structure. The main TLB supports all the VMSAv7 page sizes of 4K, 64K, 1MB and 16MB
84*2b54f0dbSXin Li 		 *    in addition to the LPAE page sizes of 2MB and 1GB.
85*2b54f0dbSXin Li 		 */
86*2b54f0dbSXin Li 		break;
87*2b54f0dbSXin Li 	case cpuinfo_uarch_cortex_a35:
88*2b54f0dbSXin Li 		/*
89*2b54f0dbSXin Li 		 * ARM Cortex‑A35 Processor Technical Reference Manual:
90*2b54f0dbSXin Li 		 * A6.2 TLB Organization
91*2b54f0dbSXin Li 		 *   Micro TLB
92*2b54f0dbSXin Li 		 *     The first level of caching for the translation table information is a micro TLB of ten entries that
93*2b54f0dbSXin Li 		 *     is implemented on each of the instruction and data sides.
94*2b54f0dbSXin Li 		 *   Main TLB
95*2b54f0dbSXin Li 		 *     A unified main TLB handles misses from the micro TLBs. It has a 512-entry, 2-way, set-associative
96*2b54f0dbSXin Li 		 *     structure and supports all VMSAv8 block sizes, except 1GB. If it fetches a 1GB block, the TLB splits
97*2b54f0dbSXin Li 		 *     it into 512MB blocks and stores the appropriate block for the lookup.
98*2b54f0dbSXin Li 		 */
99*2b54f0dbSXin Li 		break;
100*2b54f0dbSXin Li 	case cpuinfo_uarch_cortex_a53:
101*2b54f0dbSXin Li 		/*
102*2b54f0dbSXin Li 		 * ARM Cortex-A53 MPCore Processor Technical Reference Manual:
103*2b54f0dbSXin Li 		 * 5.2.1. Micro TLB
104*2b54f0dbSXin Li 		 *    The first level of caching for the translation table information is a micro TLB of ten entries that is
105*2b54f0dbSXin Li 		 *    implemented on each of the instruction and data sides.
106*2b54f0dbSXin Li 		 * 5.2.2. Main TLB
107*2b54f0dbSXin Li 		 *    A unified main TLB handles misses from the micro TLBs. This is a 512-entry, 4-way, set-associative
108*2b54f0dbSXin Li 		 *    structure. The main TLB supports all VMSAv8 block sizes, except 1GB. If a 1GB block is fetched, it is
109*2b54f0dbSXin Li 		 *    split into 512MB blocks and the appropriate block for the lookup stored.
110*2b54f0dbSXin Li 		 */
111*2b54f0dbSXin Li 		break;
112*2b54f0dbSXin Li 	case cpuinfo_uarch_cortex_a57:
113*2b54f0dbSXin Li 		/*
114*2b54f0dbSXin Li 		 * ARM® Cortex-A57 MPCore Processor Technical Reference Manual:
115*2b54f0dbSXin Li 		 * 5.2.1 L1 instruction TLB
116*2b54f0dbSXin Li 		 *    The L1 instruction TLB is a 48-entry fully-associative structure. This TLB caches entries of three
117*2b54f0dbSXin Li 		 *    different page sizes, natively 4KB, 64KB, and 1MB, of VA to PA mappings. If the page tables map the memory
118*2b54f0dbSXin Li 		 *    region to a larger granularity than 1MB, it only allocates one mapping for the particular 1MB region to
119*2b54f0dbSXin Li 		 *    which the current access corresponds.
120*2b54f0dbSXin Li 		 * 5.2.2 L1 data TLB
121*2b54f0dbSXin Li 		 *    The L1 data TLB is a 32-entry fully-associative TLB that is used for data loads and stores. This TLB
122*2b54f0dbSXin Li 		 *    caches entries of three different page sizes, natively 4KB, 64KB, and 1MB, of VA to PA mappings.
123*2b54f0dbSXin Li 		 * 5.2.3 L2 TLB
124*2b54f0dbSXin Li 		 *    Misses from the L1 instruction and data TLBs are handled by a unified L2 TLB. This is a 1024-entry 4-way
125*2b54f0dbSXin Li 		 *    set-associative structure. The L2 TLB supports the page sizes of 4K, 64K, 1MB and 16MB. It also supports
126*2b54f0dbSXin Li 		 *    page sizes of 2MB and 1GB for the long descriptor format translation in AArch32 state and in AArch64 state
127*2b54f0dbSXin Li 		 *    when using the 4KB translation granule. In addition, the L2 TLB supports the 512MB page map size defined
128*2b54f0dbSXin Li 		 *    for the AArch64 translations that use a 64KB translation granule.
129*2b54f0dbSXin Li 		 */
130*2b54f0dbSXin Li 		break;
131*2b54f0dbSXin Li }
132*2b54f0dbSXin Li 
133*2b54f0dbSXin Li 
134