xref: /openbmc/linux/Documentation/arch/arm64/booting.rst (revision 2612e3bbc0386368a850140a6c9b990cd496a5ec)
1e4624435SJonathan Corbet=====================
2e4624435SJonathan CorbetBooting AArch64 Linux
3e4624435SJonathan Corbet=====================
4e4624435SJonathan Corbet
5e4624435SJonathan CorbetAuthor: Will Deacon <will.deacon@arm.com>
6e4624435SJonathan Corbet
7e4624435SJonathan CorbetDate  : 07 September 2012
8e4624435SJonathan Corbet
9e4624435SJonathan CorbetThis document is based on the ARM booting document by Russell King and
10e4624435SJonathan Corbetis relevant to all public releases of the AArch64 Linux kernel.
11e4624435SJonathan Corbet
12e4624435SJonathan CorbetThe AArch64 exception model is made up of a number of exception levels
13e4624435SJonathan Corbet(EL0 - EL3), with EL0, EL1 and EL2 having a secure and a non-secure
14e4624435SJonathan Corbetcounterpart.  EL2 is the hypervisor level, EL3 is the highest priority
15e4624435SJonathan Corbetlevel and exists only in secure mode. Both are architecturally optional.
16e4624435SJonathan Corbet
17e4624435SJonathan CorbetFor the purposes of this document, we will use the term `boot loader`
18e4624435SJonathan Corbetsimply to define all software that executes on the CPU(s) before control
19e4624435SJonathan Corbetis passed to the Linux kernel.  This may include secure monitor and
20e4624435SJonathan Corbethypervisor code, or it may just be a handful of instructions for
21e4624435SJonathan Corbetpreparing a minimal boot environment.
22e4624435SJonathan Corbet
23e4624435SJonathan CorbetEssentially, the boot loader should provide (as a minimum) the
24e4624435SJonathan Corbetfollowing:
25e4624435SJonathan Corbet
26e4624435SJonathan Corbet1. Setup and initialise the RAM
27e4624435SJonathan Corbet2. Setup the device tree
28e4624435SJonathan Corbet3. Decompress the kernel image
29e4624435SJonathan Corbet4. Call the kernel image
30e4624435SJonathan Corbet
31e4624435SJonathan Corbet
32e4624435SJonathan Corbet1. Setup and initialise RAM
33e4624435SJonathan Corbet---------------------------
34e4624435SJonathan Corbet
35e4624435SJonathan CorbetRequirement: MANDATORY
36e4624435SJonathan Corbet
37e4624435SJonathan CorbetThe boot loader is expected to find and initialise all RAM that the
38e4624435SJonathan Corbetkernel will use for volatile data storage in the system.  It performs
39e4624435SJonathan Corbetthis in a machine dependent manner.  (It may use internal algorithms
40e4624435SJonathan Corbetto automatically locate and size all RAM, or it may use knowledge of
41e4624435SJonathan Corbetthe RAM in the machine, or any other method the boot loader designer
42e4624435SJonathan Corbetsees fit.)
43e4624435SJonathan Corbet
44e4624435SJonathan Corbet
45e4624435SJonathan Corbet2. Setup the device tree
46e4624435SJonathan Corbet-------------------------
47e4624435SJonathan Corbet
48e4624435SJonathan CorbetRequirement: MANDATORY
49e4624435SJonathan Corbet
50e4624435SJonathan CorbetThe device tree blob (dtb) must be placed on an 8-byte boundary and must
51e4624435SJonathan Corbetnot exceed 2 megabytes in size. Since the dtb will be mapped cacheable
52e4624435SJonathan Corbetusing blocks of up to 2 megabytes in size, it must not be placed within
53e4624435SJonathan Corbetany 2M region which must be mapped with any specific attributes.
54e4624435SJonathan Corbet
55e4624435SJonathan CorbetNOTE: versions prior to v4.2 also require that the DTB be placed within
56e4624435SJonathan Corbetthe 512 MB region starting at text_offset bytes below the kernel Image.
57e4624435SJonathan Corbet
58e4624435SJonathan Corbet3. Decompress the kernel image
59e4624435SJonathan Corbet------------------------------
60e4624435SJonathan Corbet
61e4624435SJonathan CorbetRequirement: OPTIONAL
62e4624435SJonathan Corbet
63e4624435SJonathan CorbetThe AArch64 kernel does not currently provide a decompressor and
64e4624435SJonathan Corbettherefore requires decompression (gzip etc.) to be performed by the boot
65e4624435SJonathan Corbetloader if a compressed Image target (e.g. Image.gz) is used.  For
66e4624435SJonathan Corbetbootloaders that do not implement this requirement, the uncompressed
67e4624435SJonathan CorbetImage target is available instead.
68e4624435SJonathan Corbet
69e4624435SJonathan Corbet
70e4624435SJonathan Corbet4. Call the kernel image
71e4624435SJonathan Corbet------------------------
72e4624435SJonathan Corbet
73e4624435SJonathan CorbetRequirement: MANDATORY
74e4624435SJonathan Corbet
75e4624435SJonathan CorbetThe decompressed kernel image contains a 64-byte header as follows::
76e4624435SJonathan Corbet
77e4624435SJonathan Corbet  u32 code0;			/* Executable code */
78e4624435SJonathan Corbet  u32 code1;			/* Executable code */
79e4624435SJonathan Corbet  u64 text_offset;		/* Image load offset, little endian */
80e4624435SJonathan Corbet  u64 image_size;		/* Effective Image size, little endian */
81e4624435SJonathan Corbet  u64 flags;			/* kernel flags, little endian */
82e4624435SJonathan Corbet  u64 res2	= 0;		/* reserved */
83e4624435SJonathan Corbet  u64 res3	= 0;		/* reserved */
84e4624435SJonathan Corbet  u64 res4	= 0;		/* reserved */
85e4624435SJonathan Corbet  u32 magic	= 0x644d5241;	/* Magic number, little endian, "ARM\x64" */
86e4624435SJonathan Corbet  u32 res5;			/* reserved (used for PE COFF offset) */
87e4624435SJonathan Corbet
88e4624435SJonathan Corbet
89e4624435SJonathan CorbetHeader notes:
90e4624435SJonathan Corbet
91e4624435SJonathan Corbet- As of v3.17, all fields are little endian unless stated otherwise.
92e4624435SJonathan Corbet
93e4624435SJonathan Corbet- code0/code1 are responsible for branching to stext.
94e4624435SJonathan Corbet
95e4624435SJonathan Corbet- when booting through EFI, code0/code1 are initially skipped.
96e4624435SJonathan Corbet  res5 is an offset to the PE header and the PE header has the EFI
97e4624435SJonathan Corbet  entry point (efi_stub_entry).  When the stub has done its work, it
98e4624435SJonathan Corbet  jumps to code0 to resume the normal boot process.
99e4624435SJonathan Corbet
100e4624435SJonathan Corbet- Prior to v3.17, the endianness of text_offset was not specified.  In
101e4624435SJonathan Corbet  these cases image_size is zero and text_offset is 0x80000 in the
102e4624435SJonathan Corbet  endianness of the kernel.  Where image_size is non-zero image_size is
103e4624435SJonathan Corbet  little-endian and must be respected.  Where image_size is zero,
104e4624435SJonathan Corbet  text_offset can be assumed to be 0x80000.
105e4624435SJonathan Corbet
106e4624435SJonathan Corbet- The flags field (introduced in v3.17) is a little-endian 64-bit field
107e4624435SJonathan Corbet  composed as follows:
108e4624435SJonathan Corbet
109e4624435SJonathan Corbet  ============= ===============================================================
110e4624435SJonathan Corbet  Bit 0		Kernel endianness.  1 if BE, 0 if LE.
111e4624435SJonathan Corbet  Bit 1-2	Kernel Page size.
112e4624435SJonathan Corbet
113e4624435SJonathan Corbet			* 0 - Unspecified.
114e4624435SJonathan Corbet			* 1 - 4K
115e4624435SJonathan Corbet			* 2 - 16K
116e4624435SJonathan Corbet			* 3 - 64K
117e4624435SJonathan Corbet  Bit 3		Kernel physical placement
118e4624435SJonathan Corbet
119e4624435SJonathan Corbet			0
120e4624435SJonathan Corbet			  2MB aligned base should be as close as possible
121e4624435SJonathan Corbet			  to the base of DRAM, since memory below it is not
122e4624435SJonathan Corbet			  accessible via the linear mapping
123e4624435SJonathan Corbet			1
124e4624435SJonathan Corbet			  2MB aligned base such that all image_size bytes
125e4624435SJonathan Corbet			  counted from the start of the image are within
126e4624435SJonathan Corbet			  the 48-bit addressable range of physical memory
127e4624435SJonathan Corbet  Bits 4-63	Reserved.
128e4624435SJonathan Corbet  ============= ===============================================================
129e4624435SJonathan Corbet
130e4624435SJonathan Corbet- When image_size is zero, a bootloader should attempt to keep as much
131e4624435SJonathan Corbet  memory as possible free for use by the kernel immediately after the
132e4624435SJonathan Corbet  end of the kernel image. The amount of space required will vary
133e4624435SJonathan Corbet  depending on selected features, and is effectively unbound.
134e4624435SJonathan Corbet
135e4624435SJonathan CorbetThe Image must be placed text_offset bytes from a 2MB aligned base
136e4624435SJonathan Corbetaddress anywhere in usable system RAM and called there. The region
137e4624435SJonathan Corbetbetween the 2 MB aligned base address and the start of the image has no
138e4624435SJonathan Corbetspecial significance to the kernel, and may be used for other purposes.
139e4624435SJonathan CorbetAt least image_size bytes from the start of the image must be free for
140e4624435SJonathan Corbetuse by the kernel.
141e4624435SJonathan CorbetNOTE: versions prior to v4.6 cannot make use of memory below the
142e4624435SJonathan Corbetphysical offset of the Image so it is recommended that the Image be
143e4624435SJonathan Corbetplaced as close as possible to the start of system RAM.
144e4624435SJonathan Corbet
145e4624435SJonathan CorbetIf an initrd/initramfs is passed to the kernel at boot, it must reside
146e4624435SJonathan Corbetentirely within a 1 GB aligned physical memory window of up to 32 GB in
147e4624435SJonathan Corbetsize that fully covers the kernel Image as well.
148e4624435SJonathan Corbet
149e4624435SJonathan CorbetAny memory described to the kernel (even that below the start of the
150e4624435SJonathan Corbetimage) which is not marked as reserved from the kernel (e.g., with a
151e4624435SJonathan Corbetmemreserve region in the device tree) will be considered as available to
152e4624435SJonathan Corbetthe kernel.
153e4624435SJonathan Corbet
154e4624435SJonathan CorbetBefore jumping into the kernel, the following conditions must be met:
155e4624435SJonathan Corbet
156e4624435SJonathan Corbet- Quiesce all DMA capable devices so that memory does not get
157e4624435SJonathan Corbet  corrupted by bogus network packets or disk data.  This will save
158e4624435SJonathan Corbet  you many hours of debug.
159e4624435SJonathan Corbet
160e4624435SJonathan Corbet- Primary CPU general-purpose register settings:
161e4624435SJonathan Corbet
162e4624435SJonathan Corbet    - x0 = physical address of device tree blob (dtb) in system RAM.
163e4624435SJonathan Corbet    - x1 = 0 (reserved for future use)
164e4624435SJonathan Corbet    - x2 = 0 (reserved for future use)
165e4624435SJonathan Corbet    - x3 = 0 (reserved for future use)
166e4624435SJonathan Corbet
167e4624435SJonathan Corbet- CPU mode
168e4624435SJonathan Corbet
169e4624435SJonathan Corbet  All forms of interrupts must be masked in PSTATE.DAIF (Debug, SError,
170e4624435SJonathan Corbet  IRQ and FIQ).
171e4624435SJonathan Corbet  The CPU must be in non-secure state, either in EL2 (RECOMMENDED in order
172e4624435SJonathan Corbet  to have access to the virtualisation extensions), or in EL1.
173e4624435SJonathan Corbet
174e4624435SJonathan Corbet- Caches, MMUs
175e4624435SJonathan Corbet
176e4624435SJonathan Corbet  The MMU must be off.
177e4624435SJonathan Corbet
178e4624435SJonathan Corbet  The instruction cache may be on or off, and must not hold any stale
179e4624435SJonathan Corbet  entries corresponding to the loaded kernel image.
180e4624435SJonathan Corbet
181e4624435SJonathan Corbet  The address range corresponding to the loaded kernel image must be
182e4624435SJonathan Corbet  cleaned to the PoC. In the presence of a system cache or other
183e4624435SJonathan Corbet  coherent masters with caches enabled, this will typically require
184e4624435SJonathan Corbet  cache maintenance by VA rather than set/way operations.
185e4624435SJonathan Corbet  System caches which respect the architected cache maintenance by VA
186e4624435SJonathan Corbet  operations must be configured and may be enabled.
187e4624435SJonathan Corbet  System caches which do not respect architected cache maintenance by VA
188e4624435SJonathan Corbet  operations (not recommended) must be configured and disabled.
189e4624435SJonathan Corbet
190e4624435SJonathan Corbet- Architected timers
191e4624435SJonathan Corbet
192e4624435SJonathan Corbet  CNTFRQ must be programmed with the timer frequency and CNTVOFF must
193e4624435SJonathan Corbet  be programmed with a consistent value on all CPUs.  If entering the
194e4624435SJonathan Corbet  kernel at EL1, CNTHCTL_EL2 must have EL1PCTEN (bit 0) set where
195e4624435SJonathan Corbet  available.
196e4624435SJonathan Corbet
197e4624435SJonathan Corbet- Coherency
198e4624435SJonathan Corbet
199e4624435SJonathan Corbet  All CPUs to be booted by the kernel must be part of the same coherency
200e4624435SJonathan Corbet  domain on entry to the kernel.  This may require IMPLEMENTATION DEFINED
201e4624435SJonathan Corbet  initialisation to enable the receiving of maintenance operations on
202e4624435SJonathan Corbet  each CPU.
203e4624435SJonathan Corbet
204e4624435SJonathan Corbet- System registers
205e4624435SJonathan Corbet
206e4624435SJonathan Corbet  All writable architected system registers at or below the exception
207e4624435SJonathan Corbet  level where the kernel image will be entered must be initialised by
208e4624435SJonathan Corbet  software at a higher exception level to prevent execution in an UNKNOWN
209e4624435SJonathan Corbet  state.
210e4624435SJonathan Corbet
211e4624435SJonathan Corbet  For all systems:
212e4624435SJonathan Corbet  - If EL3 is present:
213e4624435SJonathan Corbet
214e4624435SJonathan Corbet    - SCR_EL3.FIQ must have the same value across all CPUs the kernel is
215e4624435SJonathan Corbet      executing on.
216e4624435SJonathan Corbet    - The value of SCR_EL3.FIQ must be the same as the one present at boot
217e4624435SJonathan Corbet      time whenever the kernel is executing.
218e4624435SJonathan Corbet
219e4624435SJonathan Corbet  - If EL3 is present and the kernel is entered at EL2:
220e4624435SJonathan Corbet
221e4624435SJonathan Corbet    - SCR_EL3.HCE (bit 8) must be initialised to 0b1.
222e4624435SJonathan Corbet
223e4624435SJonathan Corbet  For systems with a GICv3 interrupt controller to be used in v3 mode:
224e4624435SJonathan Corbet  - If EL3 is present:
225e4624435SJonathan Corbet
226e4624435SJonathan Corbet      - ICC_SRE_EL3.Enable (bit 3) must be initialised to 0b1.
227e4624435SJonathan Corbet      - ICC_SRE_EL3.SRE (bit 0) must be initialised to 0b1.
228e4624435SJonathan Corbet      - ICC_CTLR_EL3.PMHE (bit 6) must be set to the same value across
229e4624435SJonathan Corbet        all CPUs the kernel is executing on, and must stay constant
230e4624435SJonathan Corbet        for the lifetime of the kernel.
231e4624435SJonathan Corbet
232e4624435SJonathan Corbet  - If the kernel is entered at EL1:
233e4624435SJonathan Corbet
234e4624435SJonathan Corbet      - ICC.SRE_EL2.Enable (bit 3) must be initialised to 0b1
235e4624435SJonathan Corbet      - ICC_SRE_EL2.SRE (bit 0) must be initialised to 0b1.
236e4624435SJonathan Corbet
237e4624435SJonathan Corbet  - The DT or ACPI tables must describe a GICv3 interrupt controller.
238e4624435SJonathan Corbet
239e4624435SJonathan Corbet  For systems with a GICv3 interrupt controller to be used in
240e4624435SJonathan Corbet  compatibility (v2) mode:
241e4624435SJonathan Corbet
242e4624435SJonathan Corbet  - If EL3 is present:
243e4624435SJonathan Corbet
244e4624435SJonathan Corbet      ICC_SRE_EL3.SRE (bit 0) must be initialised to 0b0.
245e4624435SJonathan Corbet
246e4624435SJonathan Corbet  - If the kernel is entered at EL1:
247e4624435SJonathan Corbet
248e4624435SJonathan Corbet      ICC_SRE_EL2.SRE (bit 0) must be initialised to 0b0.
249e4624435SJonathan Corbet
250e4624435SJonathan Corbet  - The DT or ACPI tables must describe a GICv2 interrupt controller.
251e4624435SJonathan Corbet
252e4624435SJonathan Corbet  For CPUs with pointer authentication functionality:
253e4624435SJonathan Corbet
254e4624435SJonathan Corbet  - If EL3 is present:
255e4624435SJonathan Corbet
256e4624435SJonathan Corbet    - SCR_EL3.APK (bit 16) must be initialised to 0b1
257e4624435SJonathan Corbet    - SCR_EL3.API (bit 17) must be initialised to 0b1
258e4624435SJonathan Corbet
259e4624435SJonathan Corbet  - If the kernel is entered at EL1:
260e4624435SJonathan Corbet
261e4624435SJonathan Corbet    - HCR_EL2.APK (bit 40) must be initialised to 0b1
262e4624435SJonathan Corbet    - HCR_EL2.API (bit 41) must be initialised to 0b1
263e4624435SJonathan Corbet
264e4624435SJonathan Corbet  For CPUs with Activity Monitors Unit v1 (AMUv1) extension present:
265e4624435SJonathan Corbet
266e4624435SJonathan Corbet  - If EL3 is present:
267e4624435SJonathan Corbet
268e4624435SJonathan Corbet    - CPTR_EL3.TAM (bit 30) must be initialised to 0b0
269e4624435SJonathan Corbet    - CPTR_EL2.TAM (bit 30) must be initialised to 0b0
270e4624435SJonathan Corbet    - AMCNTENSET0_EL0 must be initialised to 0b1111
271e4624435SJonathan Corbet    - AMCNTENSET1_EL0 must be initialised to a platform specific value
272e4624435SJonathan Corbet      having 0b1 set for the corresponding bit for each of the auxiliary
273e4624435SJonathan Corbet      counters present.
274e4624435SJonathan Corbet
275e4624435SJonathan Corbet  - If the kernel is entered at EL1:
276e4624435SJonathan Corbet
277e4624435SJonathan Corbet    - AMCNTENSET0_EL0 must be initialised to 0b1111
278e4624435SJonathan Corbet    - AMCNTENSET1_EL0 must be initialised to a platform specific value
279e4624435SJonathan Corbet      having 0b1 set for the corresponding bit for each of the auxiliary
280e4624435SJonathan Corbet      counters present.
281e4624435SJonathan Corbet
282e4624435SJonathan Corbet  For CPUs with the Fine Grained Traps (FEAT_FGT) extension present:
283e4624435SJonathan Corbet
284e4624435SJonathan Corbet  - If EL3 is present and the kernel is entered at EL2:
285e4624435SJonathan Corbet
286e4624435SJonathan Corbet    - SCR_EL3.FGTEn (bit 27) must be initialised to 0b1.
287e4624435SJonathan Corbet
288e4624435SJonathan Corbet  For CPUs with support for HCRX_EL2 (FEAT_HCX) present:
289e4624435SJonathan Corbet
290e4624435SJonathan Corbet  - If EL3 is present and the kernel is entered at EL2:
291e4624435SJonathan Corbet
292e4624435SJonathan Corbet    - SCR_EL3.HXEn (bit 38) must be initialised to 0b1.
293e4624435SJonathan Corbet
294e4624435SJonathan Corbet  For CPUs with Advanced SIMD and floating point support:
295e4624435SJonathan Corbet
296e4624435SJonathan Corbet  - If EL3 is present:
297e4624435SJonathan Corbet
298e4624435SJonathan Corbet    - CPTR_EL3.TFP (bit 10) must be initialised to 0b0.
299e4624435SJonathan Corbet
300e4624435SJonathan Corbet  - If EL2 is present and the kernel is entered at EL1:
301e4624435SJonathan Corbet
302e4624435SJonathan Corbet    - CPTR_EL2.TFP (bit 10) must be initialised to 0b0.
303e4624435SJonathan Corbet
304e4624435SJonathan Corbet  For CPUs with the Scalable Vector Extension (FEAT_SVE) present:
305e4624435SJonathan Corbet
306e4624435SJonathan Corbet  - if EL3 is present:
307e4624435SJonathan Corbet
308e4624435SJonathan Corbet    - CPTR_EL3.EZ (bit 8) must be initialised to 0b1.
309e4624435SJonathan Corbet
310e4624435SJonathan Corbet    - ZCR_EL3.LEN must be initialised to the same value for all CPUs the
311e4624435SJonathan Corbet      kernel is executed on.
312e4624435SJonathan Corbet
313e4624435SJonathan Corbet  - If the kernel is entered at EL1 and EL2 is present:
314e4624435SJonathan Corbet
315e4624435SJonathan Corbet    - CPTR_EL2.TZ (bit 8) must be initialised to 0b0.
316e4624435SJonathan Corbet
317e4624435SJonathan Corbet    - CPTR_EL2.ZEN (bits 17:16) must be initialised to 0b11.
318e4624435SJonathan Corbet
319e4624435SJonathan Corbet    - ZCR_EL2.LEN must be initialised to the same value for all CPUs the
320e4624435SJonathan Corbet      kernel will execute on.
321e4624435SJonathan Corbet
322e4624435SJonathan Corbet  For CPUs with the Scalable Matrix Extension (FEAT_SME):
323e4624435SJonathan Corbet
324e4624435SJonathan Corbet  - If EL3 is present:
325e4624435SJonathan Corbet
326e4624435SJonathan Corbet    - CPTR_EL3.ESM (bit 12) must be initialised to 0b1.
327e4624435SJonathan Corbet
328e4624435SJonathan Corbet    - SCR_EL3.EnTP2 (bit 41) must be initialised to 0b1.
329e4624435SJonathan Corbet
330e4624435SJonathan Corbet    - SMCR_EL3.LEN must be initialised to the same value for all CPUs the
331e4624435SJonathan Corbet      kernel will execute on.
332e4624435SJonathan Corbet
333e4624435SJonathan Corbet - If the kernel is entered at EL1 and EL2 is present:
334e4624435SJonathan Corbet
335e4624435SJonathan Corbet    - CPTR_EL2.TSM (bit 12) must be initialised to 0b0.
336e4624435SJonathan Corbet
337e4624435SJonathan Corbet    - CPTR_EL2.SMEN (bits 25:24) must be initialised to 0b11.
338e4624435SJonathan Corbet
339e4624435SJonathan Corbet    - SCTLR_EL2.EnTP2 (bit 60) must be initialised to 0b1.
340e4624435SJonathan Corbet
341e4624435SJonathan Corbet    - SMCR_EL2.LEN must be initialised to the same value for all CPUs the
342e4624435SJonathan Corbet      kernel will execute on.
343e4624435SJonathan Corbet
344e4624435SJonathan Corbet    - HWFGRTR_EL2.nTPIDR2_EL0 (bit 55) must be initialised to 0b01.
345e4624435SJonathan Corbet
346e4624435SJonathan Corbet    - HWFGWTR_EL2.nTPIDR2_EL0 (bit 55) must be initialised to 0b01.
347e4624435SJonathan Corbet
348e4624435SJonathan Corbet    - HWFGRTR_EL2.nSMPRI_EL1 (bit 54) must be initialised to 0b01.
349e4624435SJonathan Corbet
350e4624435SJonathan Corbet    - HWFGWTR_EL2.nSMPRI_EL1 (bit 54) must be initialised to 0b01.
351e4624435SJonathan Corbet
352e4624435SJonathan Corbet  For CPUs with the Scalable Matrix Extension FA64 feature (FEAT_SME_FA64):
353e4624435SJonathan Corbet
354e4624435SJonathan Corbet  - If EL3 is present:
355e4624435SJonathan Corbet
356e4624435SJonathan Corbet    - SMCR_EL3.FA64 (bit 31) must be initialised to 0b1.
357e4624435SJonathan Corbet
358e4624435SJonathan Corbet - If the kernel is entered at EL1 and EL2 is present:
359e4624435SJonathan Corbet
360e4624435SJonathan Corbet    - SMCR_EL2.FA64 (bit 31) must be initialised to 0b1.
361e4624435SJonathan Corbet
362e4624435SJonathan Corbet  For CPUs with the Memory Tagging Extension feature (FEAT_MTE2):
363e4624435SJonathan Corbet
364e4624435SJonathan Corbet  - If EL3 is present:
365e4624435SJonathan Corbet
366e4624435SJonathan Corbet    - SCR_EL3.ATA (bit 26) must be initialised to 0b1.
367e4624435SJonathan Corbet
368e4624435SJonathan Corbet  - If the kernel is entered at EL1 and EL2 is present:
369e4624435SJonathan Corbet
370e4624435SJonathan Corbet    - HCR_EL2.ATA (bit 56) must be initialised to 0b1.
371e4624435SJonathan Corbet
372e4624435SJonathan Corbet  For CPUs with the Scalable Matrix Extension version 2 (FEAT_SME2):
373e4624435SJonathan Corbet
374e4624435SJonathan Corbet  - If EL3 is present:
375e4624435SJonathan Corbet
376e4624435SJonathan Corbet    - SMCR_EL3.EZT0 (bit 30) must be initialised to 0b1.
377e4624435SJonathan Corbet
378e4624435SJonathan Corbet - If the kernel is entered at EL1 and EL2 is present:
379e4624435SJonathan Corbet
380e4624435SJonathan Corbet    - SMCR_EL2.EZT0 (bit 30) must be initialised to 0b1.
381e4624435SJonathan Corbet
382*6aeadf78SLinus Torvalds  For CPUs with Memory Copy and Memory Set instructions (FEAT_MOPS):
383*6aeadf78SLinus Torvalds
384*6aeadf78SLinus Torvalds  - If the kernel is entered at EL1 and EL2 is present:
385*6aeadf78SLinus Torvalds
386*6aeadf78SLinus Torvalds    - HCRX_EL2.MSCEn (bit 11) must be initialised to 0b1.
387*6aeadf78SLinus Torvalds
388*6aeadf78SLinus Torvalds  For CPUs with the Extended Translation Control Register feature (FEAT_TCR2):
389*6aeadf78SLinus Torvalds
390*6aeadf78SLinus Torvalds  - If EL3 is present:
391*6aeadf78SLinus Torvalds
392*6aeadf78SLinus Torvalds    - SCR_EL3.TCR2En (bit 43) must be initialised to 0b1.
393*6aeadf78SLinus Torvalds
394*6aeadf78SLinus Torvalds - If the kernel is entered at EL1 and EL2 is present:
395*6aeadf78SLinus Torvalds
396*6aeadf78SLinus Torvalds    - HCRX_EL2.TCR2En (bit 14) must be initialised to 0b1.
397*6aeadf78SLinus Torvalds
398*6aeadf78SLinus Torvalds  For CPUs with the Stage 1 Permission Indirection Extension feature (FEAT_S1PIE):
399*6aeadf78SLinus Torvalds
400*6aeadf78SLinus Torvalds  - If EL3 is present:
401*6aeadf78SLinus Torvalds
402*6aeadf78SLinus Torvalds    - SCR_EL3.PIEn (bit 45) must be initialised to 0b1.
403*6aeadf78SLinus Torvalds
404*6aeadf78SLinus Torvalds  - If the kernel is entered at EL1 and EL2 is present:
405*6aeadf78SLinus Torvalds
406*6aeadf78SLinus Torvalds    - HFGRTR_EL2.nPIR_EL1 (bit 58) must be initialised to 0b1.
407*6aeadf78SLinus Torvalds
408*6aeadf78SLinus Torvalds    - HFGWTR_EL2.nPIR_EL1 (bit 58) must be initialised to 0b1.
409*6aeadf78SLinus Torvalds
410*6aeadf78SLinus Torvalds    - HFGRTR_EL2.nPIRE0_EL1 (bit 57) must be initialised to 0b1.
411*6aeadf78SLinus Torvalds
412*6aeadf78SLinus Torvalds    - HFGRWR_EL2.nPIRE0_EL1 (bit 57) must be initialised to 0b1.
413*6aeadf78SLinus Torvalds
414e4624435SJonathan CorbetThe requirements described above for CPU mode, caches, MMUs, architected
415e4624435SJonathan Corbettimers, coherency and system registers apply to all CPUs.  All CPUs must
416e4624435SJonathan Corbetenter the kernel in the same exception level.  Where the values documented
417e4624435SJonathan Corbetdisable traps it is permissible for these traps to be enabled so long as
418e4624435SJonathan Corbetthose traps are handled transparently by higher exception levels as though
419e4624435SJonathan Corbetthe values documented were set.
420e4624435SJonathan Corbet
421e4624435SJonathan CorbetThe boot loader is expected to enter the kernel on each CPU in the
422e4624435SJonathan Corbetfollowing manner:
423e4624435SJonathan Corbet
424e4624435SJonathan Corbet- The primary CPU must jump directly to the first instruction of the
425e4624435SJonathan Corbet  kernel image.  The device tree blob passed by this CPU must contain
426e4624435SJonathan Corbet  an 'enable-method' property for each cpu node.  The supported
427e4624435SJonathan Corbet  enable-methods are described below.
428e4624435SJonathan Corbet
429e4624435SJonathan Corbet  It is expected that the bootloader will generate these device tree
430e4624435SJonathan Corbet  properties and insert them into the blob prior to kernel entry.
431e4624435SJonathan Corbet
432e4624435SJonathan Corbet- CPUs with a "spin-table" enable-method must have a 'cpu-release-addr'
433e4624435SJonathan Corbet  property in their cpu node.  This property identifies a
434e4624435SJonathan Corbet  naturally-aligned 64-bit zero-initalised memory location.
435e4624435SJonathan Corbet
436e4624435SJonathan Corbet  These CPUs should spin outside of the kernel in a reserved area of
437e4624435SJonathan Corbet  memory (communicated to the kernel by a /memreserve/ region in the
438e4624435SJonathan Corbet  device tree) polling their cpu-release-addr location, which must be
439e4624435SJonathan Corbet  contained in the reserved region.  A wfe instruction may be inserted
440e4624435SJonathan Corbet  to reduce the overhead of the busy-loop and a sev will be issued by
441e4624435SJonathan Corbet  the primary CPU.  When a read of the location pointed to by the
442e4624435SJonathan Corbet  cpu-release-addr returns a non-zero value, the CPU must jump to this
443e4624435SJonathan Corbet  value.  The value will be written as a single 64-bit little-endian
444e4624435SJonathan Corbet  value, so CPUs must convert the read value to their native endianness
445e4624435SJonathan Corbet  before jumping to it.
446e4624435SJonathan Corbet
447e4624435SJonathan Corbet- CPUs with a "psci" enable method should remain outside of
448e4624435SJonathan Corbet  the kernel (i.e. outside of the regions of memory described to the
449e4624435SJonathan Corbet  kernel in the memory node, or in a reserved area of memory described
450e4624435SJonathan Corbet  to the kernel by a /memreserve/ region in the device tree).  The
451e4624435SJonathan Corbet  kernel will issue CPU_ON calls as described in ARM document number ARM
452e4624435SJonathan Corbet  DEN 0022A ("Power State Coordination Interface System Software on ARM
453e4624435SJonathan Corbet  processors") to bring CPUs into the kernel.
454e4624435SJonathan Corbet
455e4624435SJonathan Corbet  The device tree should contain a 'psci' node, as described in
456e4624435SJonathan Corbet  Documentation/devicetree/bindings/arm/psci.yaml.
457e4624435SJonathan Corbet
458e4624435SJonathan Corbet- Secondary CPU general-purpose register settings
459e4624435SJonathan Corbet
460e4624435SJonathan Corbet  - x0 = 0 (reserved for future use)
461e4624435SJonathan Corbet  - x1 = 0 (reserved for future use)
462e4624435SJonathan Corbet  - x2 = 0 (reserved for future use)
463e4624435SJonathan Corbet  - x3 = 0 (reserved for future use)
464