Skip to main content

aarch64_cpu/registers/
hcr_el2.rs

1// SPDX-License-Identifier: Apache-2.0 OR MIT
2//
3// Copyright (c) 2018-2025 by the author(s)
4//
5// Author(s):
6//   - Andre Richter <andre.o.richter@gmail.com>
7//   - Bradley Landherr <landhb@users.noreply.github.com>
8//   - Javier Alvarez <javier.alvarez@allthingsembedded.com>
9//   - Yan Tan <tanyan@kylinos.cn>
10//   - Callum Thomson <callumthom11@gmail.com>
11
12//! Hypervisor Configuration Register - EL2
13//!
14//! Provides configuration controls for virtualization, including defining
15//! whether various Non-secure operations are trapped to EL2.
16
17use tock_registers::{
18    interfaces::{Readable, Writeable},
19    register_bitfields,
20};
21
22register_bitfields! {u64,
23    pub HCR_EL2 [
24        /// TWE Delay.
25        ///
26        /// Requires FEAT_TWED
27        TWEDEL   OFFSET(60) NUMBITS(4) [],
28
29        /// TWE Delay Enable.
30        ///
31        /// Requires FEAT_TWED
32        TWEDEn   OFFSET(59) NUMBITS(1) [],
33
34        /// Trap ID group 5.
35        ///
36        /// Requires FEAT_MTE2
37        TID5   OFFSET(58) NUMBITS(1) [],
38
39        /// Default Cacheability Tagging.
40        ///
41        /// Requires FEAT_MTE2
42        DCT   OFFSET(57) NUMBITS(1) [],
43
44        /// Allocation Tag Access
45        ///
46        /// Requires FEAT_MTE2
47        ATA   OFFSET(56) NUMBITS(1) [],
48
49        /// Trap TLB Maintenance (Outer Shareable)
50        ///
51        /// Requires FEAT_EVT
52        TTLBOS   OFFSET(55) NUMBITS(1) [],
53
54        /// Trap TBL Maintenance (Inner Shareable).
55        ///
56        /// Requires FEAT_EVT
57        TTLBIS  OFFSET(54) NUMBITS(1) [],
58
59        /// Enable `SCXTNUM_EL1` and `SCXTNUM_EL0` registers.
60        ///
61        /// Requires FEAT_CSV2_2 or FEAT_CSV2_1p2
62        EnSCXT   OFFSET(53) NUMBITS(1) [],
63
64        /// Trap Cache Maintenance to Unification
65        ///
66        /// Requires FEAT_EVT
67        TOCU   OFFSET(52) NUMBITS(1) [],
68
69        /// Activity Monitors Virtual Offset Enable.
70        ///
71        /// Requires FEAT_AMUv1p1
72        AMVOFFEN   OFFSET(51) NUMBITS(1) [],
73
74        /// Trap `ICIALLUIS` and `IC IALLUIS`
75        ///
76        /// Requires FEAT_EVT
77        TICAB   OFFSET(50) NUMBITS(1) [],
78
79        /// Trap ID group 4
80        ///
81        /// Requires FEAT_EVT
82        TID4   OFFSET(49) NUMBITS(1) [],
83
84        /// Granule Protection Fault routing control.
85        ///
86        /// Requires FEAT_RME
87        GPF   OFFSET(48) NUMBITS(1) [],
88
89        /// Fault Injection Enable.
90        ///
91        /// Requires FEAT_RASv1p1
92        FIEN   OFFSET(47) NUMBITS(1) [],
93
94        /// When FEAT_S2FWB is implemented Forced Write-back changes the combined cachability of stage1
95        /// and stage2 attributes.
96        FWB OFFSET(46) NUMBITS(1) [
97           /// Stage2 memory type and cacheability attributes are in bits[5:2] of the stage2 PTE
98           Disabled = 0,
99           /// Stage1 memory type can be overridden by Stage2 descriptor
100           Enabled = 1,
101        ],
102
103        /// Nested Virtualization.
104        ///
105        /// Requires FEAT_NV2
106        NV2   OFFSET(45) NUMBITS(1) [],
107
108        /// Address Translation.
109        ///
110        /// Requires FEAT_NV
111        ///
112        /// Traps use of `AT S1E0R`, `AT S1E0W`, `AT S1E1R`, `AT S1E1W`, `AT S1E1RP` and `AT S1E1WP`
113        /// Traps use of `AT S1E1A` if FEAT_ATS1A is present
114        AT    OFFSET(44) NUMBITS(1) [],
115
116        /// Nested Virtualization.
117        ///
118        /// Changes meaning depending on if FEAT_NV2 or FEAT_NV is implemented.
119        NV1   OFFSET(43) NUMBITS(1) [],
120
121        /// Nested Virtualization.
122        ///
123        /// Changes meaning depending on if FEAT_NV2 or FEAT_NV is implemented.
124        NV   OFFSET(42) NUMBITS(1) [],
125
126        /// Controls the use of instructions related to Pointer Authentication.
127        ///
128        ///   - In EL0, when HCR_EL2.TGE==0 or HCR_EL2.E2H==0, and the associated SCTLR_EL1.En<N><M>==1.
129        ///   - In EL1, the associated SCTLR_EL1.En<N><M>==1.
130        ///
131        /// Traps are reported using EC syndrome value 0x09. The Pointer Authentication instructions
132        /// trapped are:
133        ///
134        /// `AUTDA`, `AUTDB`, `AUTDZA`, `AUTDZB`, `AUTIA`, `AUTIA1716`, `AUTIASP`, `AUTIAZ`, `AUTIB`, `AUTIB1716`,
135        /// `AUTIBSP`, `AUTIBZ`, `AUTIZA`, `AUTIZB`, `PACGA`, `PACDA`, `PACDB`, `PACDZA`, `PACDZB`, `PACIA`,
136        /// `PACIA1716`, `PACIASP`, `PACIAZ`, `PACIB`, `PACIB1716`, `PACIBSP`, `PACIBZ`, `PACIZA`, `PACIZB`,
137        /// `RETAA`, `RETAB`, `BRAA`, `BRAB`, `BLRAA`, `BLRAB`, `BRAAZ`, `BRABZ`, `BLRAAZ`, `BLRABZ`,
138        /// `ERETAA`, `ERETAB`, `LDRAA`, and `LDRAB`.
139        API   OFFSET(41) NUMBITS(1) [
140            EnableTrapPointerAuthInstToEl2 = 0,
141            DisableTrapPointerAuthInstToEl2 = 1
142        ],
143
144        /// Trap registers holding "key" values for Pointer Authentication.
145        ///
146        /// Traps accesses to the following registers from EL1 to EL2,
147        /// when EL2 is enabled in the current Security state, reported using EC syndrome value 0x18:
148        ///
149        /// `APIAKeyLo_EL1`, `APIAKeyHi_EL1`, `APIBKeyLo_EL1`, `APIBKeyHi_EL1`, `APDAKeyLo_EL1`,
150        /// `APDAKeyHi_EL1`, `APDBKeyLo_EL1`, `APDBKeyHi_EL1`, `APGAKeyLo_EL1`, and `APGAKeyHi_EL1`.
151        APK   OFFSET(40) NUMBITS(1) [
152            EnableTrapPointerAuthKeyRegsToEl2 = 0,
153            DisableTrapPointerAuthKeyRegsToEl2 = 1,
154        ],
155
156        /// TME.
157        ///
158        /// Requires FEAT_TME.
159        ///
160        /// Enables access to the TSTART, TCOMMIT, TTEST, and TCANCEL instructions at EL0 and EL1.
161        TME   OFFSET(39) NUMBITS(1) [],
162
163        /// Route synchronous External abort exceptions to EL2.
164        ///
165        ///   - if 0: This control does not cause exceptions to be routed from EL0 and EL1 to EL2.
166        ///   - if 1: Route synchronous External abort exceptions from EL0 and EL1 to EL2, when EL2 is
167        ///         enabled in the current Security state, if not routed to EL3.
168        TEA   OFFSET(37) NUMBITS(1) [
169            DisableTrapSyncExtAbortsToEl2 = 0,
170            EnableTrapSyncExtAbortsToEl2 = 1,
171        ],
172
173        /// Trap accesses of Error Record registers. Enables a trap to EL2 on accesses of
174        /// Error Record registers.
175        ///
176        /// - 0 Accesses of the specified Error Record registers are not trapped by this mechanism.
177        /// - 1 Accesses of the specified Error Record registers at EL1 are trapped to EL2,
178        ///   unless the instruction generates a higher priority exception.
179        TERR  OFFSET(36) NUMBITS(1) [],
180
181        /// Trap LOR registers. Traps Non-secure EL1 accesses to LORSA_EL1, LOREA_EL1, LORN_EL1,
182        /// LORC_EL1, and LORID_EL1 registers to EL2.
183        ///
184        /// - 0: This control does not cause any instructions to be trapped.
185        /// - 1: Non-secure EL1 accesses to the LOR registers are trapped to EL2.
186        TLOR  OFFSET(35) NUMBITS(1) [],
187
188        /// EL2 Host. Enables a configuration where a Host Operating System is running in EL2, and
189        /// the Host Operating System's applications are running in EL0.
190        E2H   OFFSET(34) NUMBITS(1) [
191            DisableOsAtEl2 = 0,
192            EnableOsAtEl2 = 1
193        ],
194
195        /// Instruction Cache Disable (Stage 2).
196        ID   OFFSET(33) NUMBITS(1) [],
197
198        /// Data Cache Disable (Stage 2).
199        CD   OFFSET(32) NUMBITS(1) [],
200
201        /// Execution state control for lower Exception levels.
202        ///
203        /// - 0 Lower levels are all AArch32.
204        /// - 1 The Execution state for EL1 is AArch64. The Execution state for EL0 is determined by
205        ///   the current value of PSTATE.nRW when executing at EL0.
206        ///
207        /// If all lower Exception levels cannot use AArch32 then this bit is RAO/WI.
208        ///
209        /// In an implementation that includes EL3, when SCR_EL3.NS==0, the PE behaves as if this
210        /// bit has the same value as the SCR_EL3.RW bit for all purposes other than a direct read
211        /// or write access of HCR_EL2.
212        ///
213        /// The RW bit is permitted to be cached in a TLB.
214        ///
215        /// When ARMv8.1-VHE is implemented, and the value of HCR_EL2.{E2H, TGE} is {1, 1}, this
216        /// field behaves as 1 for all purposes other than a direct read of the value of this bit.
217        RW   OFFSET(31) NUMBITS(1) [
218            AllLowerELsAreAarch32 = 0,
219            EL1IsAarch64 = 1
220        ],
221
222        /// Trap Read of Virtual Memory control registers.
223        TRVM OFFSET(30) NUMBITS(1) [],
224
225        /// HVC instruction Disable.
226        ///
227        /// Requires EL3 _not_ implemented
228        HCD  OFFSET(29) NUMBITS(1) [],
229
230        /// Trap DC ZVA.
231        TDZ  OFFSET(28) NUMBITS(1) [],
232
233        /// Trap General Exceptions, from EL0.
234        ///
235        /// If enabled:
236        ///   - When EL2 is not enabled in the current Security state, this control has no effect on
237        ///     execution at EL0.
238        ///
239        ///   - When EL2 is enabled in the current Security state, in all cases:
240        ///
241        ///       - All exceptions that would be routed to EL1 are routed to EL2.
242        ///       - If EL1 is using AArch64, the SCTLR_EL1.M field is treated as being 0 for all
243        ///         purposes other than returning the result of a direct read of SCTLR_EL1.
244        ///       - If EL1 is using AArch32, the SCTLR.M field is treated as being 0 for all
245        ///         purposes other than returning the result of a direct read of SCTLR.
246        ///       - All virtual interrupts are disabled.
247        ///       - Any IMPLEMENTATION DEFINED mechanisms for signaling virtual interrupts are
248        ///         disabled.
249        ///       - An exception return to EL1 is treated as an illegal exception return.
250        ///       - The MDCR_EL2.{TDRA, TDOSA, TDA, TDE} fields are treated as being 1 for all
251        ///         purposes other than returning the result of a direct read of MDCR_EL2.
252        ///
253        ///   - In addition, when EL2 is enabled in the current Security state, if:
254        ///
255        ///       - HCR_EL2.E2H is 0, the Effective values of the HCR_EL2.{FMO, IMO, AMO} fields
256        ///         are 1.
257        ///       - HCR_EL2.E2H is 1, the Effective values of the HCR_EL2.{FMO, IMO, AMO} fields
258        ///         are 0.
259        ///
260        ///   - For further information on the behavior of this bit when E2H is 1, see 'Behavior of
261        ///     HCR_EL2.E2H'.
262        TGE   OFFSET(27) NUMBITS(1) [
263            DisableTrapGeneralExceptionsToEl2 = 0,
264            EnableTrapGeneralExceptionsToEl2 = 1,
265        ],
266
267        /// Trap Virtual Memory controls.
268        ///
269        /// Traps writes to the virtual memory control registers to EL2,
270        /// when EL2 is enabled in the current Security state, as follows:
271        ///
272        /// If EL1 is using AArch64, the following registers are trapped to EL2 and reported using EC
273        /// syndrome value 0x18 for MSR and 0x14 for MSRR:
274        ///   - `SCTLR_EL1`, `TTBR0_EL1`, `TTBR1_EL1`, `TCR_EL1`, `ESR_EL1`, `FAR_EL1`, `AFSR0_EL1`,
275        ///     `AFSR1_EL1`, `MAIR_EL1`, `AMAIR_EL1`, and `CONTEXTIDR_EL1`.
276        ///   - If FEAT_AIE is implemented, `MAIR2_EL1` and `AMAIR2_EL1`.
277        ///   - If FEAT_S1PIE is implemented, `PIRE0_EL1` and `PIR_EL1`.
278        ///   - If FEAT_S1POE is implemented, `POR_EL0` and `POR_EL1`.
279        ///   - If FEAT_S2POE is implemented, `S2POR_EL1`.
280        ///   - If FEAT_TCR2 is implemented, `TCR2_EL1`.
281        ///   - If FEAT_SCTLR2 is implemented, `SCTLR2_EL1`.
282        ///
283        /// If the Effective value of HCR_EL2.{E2H, TGE} is not {1, 1}, and EL0 is using AArch64, EL0
284        /// accesses to the following registers are trapped to EL2 and reported using EC syndrome value
285        /// 0x18 for MSR:
286        ///   - If FEAT_S1POE is implemented, `POR_EL0`.
287        ///
288        /// If EL1 is using AArch32, EL1 accesses using MCR to the following registers are trapped to
289        /// EL2 and reported using EC syndrome value 0x03, accesses using MCRR are trapped to EL2 and
290        /// reported using EC syndrome value 0x04:
291        ///   - `SCTLR`, `TTBR0`, `TTBR1`, `TTBCR`, `TTBCR2`, `DACR`, `DFSR`, `IFSR`, `DFAR`, `IFAR`,
292        ///     `ADFSR`, `AIFSR`, `PRRR`, `NMRR`, `MAIR0`, `MAIR1`, `AMAIR0`, `AMAIR1`, and `CONTEXTIDR`.
293        ///
294        /// Meaning:
295        /// - 0: This control does not cause any instructions to be trapped.
296        /// - 1: Write accesses to the specified Virtual Memory control registers are trapped to EL2,
297        ///      when EL2 is enabled in the current Security state.
298        ///
299        /// When the Effective value of HCR_EL2.{E2H, TGE} is {1, 1}, the PE ignores the value of this
300        /// field for all purposes other than a direct read of this field.
301        ///
302        /// The reset behavior of this field is:
303        ///   - On a Warm reset, this field resets to an architecturally UNKNOWN value.
304        TVM OFFSET(26) NUMBITS(1) [
305            DisableTrapTVM = 0,
306            EnableTrapTVM = 1,
307        ],
308
309        /// Trap TLB Maintenance instructions.
310        TTLB OFFSET(25) NUMBITS(1) [],
311
312        /// Trap Cache Maintenance to Unification.
313        TPU  OFFSET(24) NUMBITS(1) [],
314
315        /// Trap Cache Maintenance to Coherency.
316        TPCP OFFSET(23) NUMBITS(1) [],
317
318        /// Trap data or unified cache maintenance instructions that operate by Set/Way.
319        ///
320        /// Traps execution of those cache maintenance instructions at EL1 to EL2, when
321        /// EL2 is enabled in the current Security state.
322        ///
323        /// - 0: This control does not cause any instructions to be trapped.
324        /// - 1: Execution of the specified instructions is trapped to EL2, when EL2 is enabled
325        /// in the current Security state.
326        TSW   OFFSET(22) NUMBITS(1) [],
327
328        /// Trap Auxiliary Control Registers.
329        ///
330        /// Traps EL1 accesses to the Auxiliary Control Registers
331        /// to EL2, when EL2 is enabled in the current Security state
332        ///
333        /// - 0: This control does not cause any instructions to be trapped.
334        /// - 1: EL1 accesses to the specified registers are trapped to EL2, when EL2 is enabled in the
335        ///   current Security state.
336        TACR  OFFSET(21) NUMBITS(1) [],
337
338        /// Trap IMPLEMENTATION DEFINED functionality.
339        ///
340        /// Traps EL1 accesses to the encodings reserved
341        /// for IMPLEMENTATION DEFINED functionality to EL2, when EL2 is enabled in the current
342        /// Security state
343        ///
344        /// - 0: This control does not cause any instructions to be trapped.
345        /// - 1: EL1 accesses to or execution of the specified encodings reserved for IMPLEMENTATION
346        ///     DEFINED functionality are trapped to EL2, when EL2 is enabled in the current Security
347        ///     state.
348        TIDCP OFFSET(20) NUMBITS(1) [],
349
350        /// Trap SMC instructions.
351        ///
352        /// Traps EL1 execution of SMC instructions to EL2, when EL2 is
353        /// enabled in the current Security state.
354        ///
355        /// If execution is in AArch64 state, the trap is reported using EC syndrome value 0x17.
356        ///
357        /// HCR_EL2.TSC traps execution of the SMC instruction. It is not a routing control for
358        /// the SMC exception. Trap exceptions and SMC exceptions have different preferred return
359        /// addresses.
360        ///
361        /// If disabled, this control does not cause any instructions to be trapped.
362        ///
363        /// If enabled:
364        ///   - If EL3 is implemented, then any attempt to execute an SMC instruction at EL1 is
365        ///     trapped to EL2, when EL2 is enabled in the current Security state, regardless of
366        ///     the value of SCR_EL3.SMD.
367        ///   - If EL3 is not implemented, FEAT_NV is implemented, and HCR_EL2.NV is 1, then any
368        ///     attempt to execute an SMC instruction at EL1 using AArch64 is trapped to EL2,
369        ///     when EL2 is enabled in the current Security state.
370        ///   - If EL3 is not implemented, and either FEAT_NV is not implemented or HCR_EL2.NV is 0,
371        ///     then it is IMPLEMENTATION DEFINED whether:
372        ///       - Any attempt to execute an SMC instruction at EL1 is trapped to EL2, when EL2 is
373        ///         enabled in the current Security state.
374        ///       - Any attempt to execute an SMC instruction is UNDEFINED.
375        ///
376        /// SMC instructions are UNDEFINED at EL0.
377        ///
378        /// If EL3 is not implemented, and either FEAT_NV is not implemented or HCR_EL2.NV is 0,
379        /// then it is IMPLEMENTATION DEFINED whether this bit is:
380        ///   - RES0.
381        ///   - Implemented with the functionality as described in HCR_EL2.TSC.
382        ///
383        /// When HCR_EL2.TGE is 1, the PE ignores the value of this field for all purposes other
384        /// than a direct read of this field.
385        TSC   OFFSET(19) NUMBITS(1) [
386            DisableTrapEl1SmcToEl2 = 0,
387            EnableTrapEl1SmcToEl2 = 1,
388        ],
389
390        /// Trap ID group 3.
391        ///
392        /// Traps EL1 reads of group 3 ID registers to EL2, when EL2 is enabled
393        /// in the current Security state.
394        ///
395        /// - 0 This control does not cause any instructions to be trapped.
396        /// - 1 The specified EL1 read accesses to ID group 3 registers are trapped to EL2, when EL2
397        /// is enabled in the current Security state.
398        TID3  OFFSET(18) NUMBITS(1) [],
399
400        /// Trap ID group 2.
401        TID2  OFFSET(17) NUMBITS(1) [],
402
403        /// Trap ID group 1.
404        TID1  OFFSET(16) NUMBITS(1) [],
405
406        /// Trap ID group 0.
407        ///
408        /// Requires FEAT_AA32
409        TID0  OFFSET(15) NUMBITS(1) [],
410
411        /// Trap WFE Instructions.
412        ///
413        /// Additionally applies to WFET when FEAT_WFxT is implemented.
414        TWE  OFFSET(14) NUMBITS(1) [],
415
416        /// Trap WFI Instructions.
417        ///
418        /// Additionally applies to WFIT when FEAT_WFxT is implemented.
419        TWI  OFFSET(13) NUMBITS(1) [],
420
421        /// Default Cacheability.
422        ///
423        /// - 0 This control has no effect on the Non-secure EL1&0 translation regime.
424        ///
425        /// - 1 In Non-secure state:
426        ///   - When EL1 is using AArch64, the PE behaves as if the value of the SCTLR_EL1.M field
427        ///     is 0 for all purposes other than returning the value of a direct read of SCTLR_EL1.
428        ///
429        ///   - When EL1 is using AArch32, the PE behaves as if the value of the SCTLR.M field is 0
430        ///     for all purposes other than returning the value of a direct read of SCTLR.
431        ///
432        ///   - The PE behaves as if the value of the HCR_EL2.VM field is 1 for all purposes other
433        ///     than returning the value of a direct read of HCR_EL2.
434        ///
435        ///   - The memory type produced by stage 1 of the EL1&0 translation regime is Normal
436        ///     Non-Shareable, Inner Write-Back Read-Allocate Write-Allocate, Outer Write-Back
437        ///     Read-Allocate Write-Allocate.
438        ///
439        /// This field has no effect on the EL2, EL2&0, and EL3 translation regimes.
440        ///
441        /// This field is permitted to be cached in a TLB.
442        ///
443        /// In an implementation that includes EL3, when the value of SCR_EL3.NS is 0 the PE behaves
444        /// as if this field is 0 for all purposes other than a direct read or write access of
445        /// HCR_EL2.
446        ///
447        /// When ARMv8.1-VHE is implemented, and the value of HCR_EL2.{E2H, TGE} is {1, 1}, this
448        /// field behaves as 0 for all purposes other than a direct read of the value of this field.
449        DC   OFFSET(12) NUMBITS(1) [],
450
451        /// Barrier Shareability upgrade.
452        ///
453        /// This field determines the minimum shareability domain that
454        /// is applied to any barrier instruction executed from EL1 or EL0.
455        BSU  OFFSET(10) NUMBITS(2) [
456            NoEffect = 0b00,
457            InnerShareable = 0b01,
458            OuterShareable = 0b10,
459            FullSystem = 0b11
460        ],
461
462        /// Force broadcast.
463        ///
464        /// Causes the following instructions to be broadcast within the Inner
465        /// Shareable domain when executed from EL1.
466        ///
467        /// - 0 This field has no effect on the operation of the specified instructions.
468        /// - 1 When one of the specified instruction is executed at EL1, the instruction is broadcast
469        /// within the Inner Shareable shareability domain.
470        FB    OFFSET(9) NUMBITS(1) [],
471
472        /// Virtual SError exception.
473        ///
474        /// Meaning:
475        /// - 0: This mechanism is not making a virtual SError exception pending.
476        /// - 1: A virtual SError exception is pending because of this mechanism.
477        ///
478        /// The virtual SError exception is enabled only when HCR_EL2.TGE is 0 and either HCR_EL2.AMO
479        /// is 1 or FEAT_DoubleFault2 is implemented and the Effective value of HCRX_EL2.TMEA is 1.
480        ///
481        /// When FEAT_E3DSE is implemented, virtual SError exceptions pended by this field have
482        /// priority over delegated SError exceptions pended by SCR_EL3.DSE.
483        ///
484        /// The reset behavior of this field is:
485        ///   - On a Warm reset, this field resets to an architecturally UNKNOWN value.
486        VSE   OFFSET(8) NUMBITS(1) [],
487
488        /// Virtual IRQ Interrupt.
489        VI    OFFSET(7) NUMBITS(1) [],
490
491        /// Virtual FIQ Interrupt.
492        VF    OFFSET(6) NUMBITS(1) [],
493
494        /// Physical SError interrupt routing.
495        ///   - If bit is 1 when executing at any Exception level, and EL2 is enabled in the current
496        ///     Security state:
497        ///     - Physical SError interrupts are taken to EL2, unless they are routed to EL3.
498        ///     - When the value of HCR_EL2.TGE is 0, then virtual SError interrupts are enabled.
499        AMO   OFFSET(5) NUMBITS(1) [],
500
501        /// Physical IRQ Routing.
502        ///
503        /// If this bit is 0:
504        ///   - When executing at Exception levels below EL2, and EL2 is enabled in the current
505        ///     Security state:
506        ///     - When the value of HCR_EL2.TGE is 0, Physical IRQ interrupts are not taken to EL2.
507        ///     - When the value of HCR_EL2.TGE is 1, Physical IRQ interrupts are taken to EL2
508        ///       unless they are routed to EL3.
509        ///     - Virtual IRQ interrupts are disabled.
510        ///
511        /// If this bit is 1:
512        ///   - When executing at any Exception level, and EL2 is enabled in the current Security
513        ///     state:
514        ///     - Physical IRQ interrupts are taken to EL2, unless they are routed to EL3.
515        ///     - When the value of HCR_EL2.TGE is 0, then Virtual IRQ interrupts are enabled.
516        ///
517        /// If EL2 is enabled in the current Security state, and the value of HCR_EL2.TGE is 1:
518        ///   - Regardless of the value of the IMO bit, physical IRQ Interrupts target EL2 unless
519        ///     they are routed to EL3.
520        ///   - When FEAT_VHE is not implemented, or if HCR_EL2.E2H is 0, this field behaves as 1
521        ///     for all purposes other than a direct read of the value of this bit.
522        ///   - When FEAT_VHE is implemented and HCR_EL2.E2H is 1, this field behaves as 0 for all
523        ///     purposes other than a direct read of the value of this bit.
524        ///
525        /// For more information, see 'Asynchronous exception routing'.
526        IMO   OFFSET(4) NUMBITS(1) [
527            DisableVirtualIRQ = 0,
528            EnableVirtualIRQ = 1,
529        ],
530
531        /// Physical FIQ Routing.
532        ///
533        /// If this bit is 0:
534        ///   - When executing at Exception levels below EL2, and EL2 is enabled in the current
535        ///     Security state:
536        ///     - When the value of HCR_EL2.TGE is 0, Physical FIQ interrupts are not taken to EL2.
537        ///     - When the value of HCR_EL2.TGE is 1, Physical FIQ interrupts are taken to EL2
538        ///       unless they are routed to EL3.
539        ///     - Virtual FIQ interrupts are disabled.
540        ///
541        /// If this bit is 1:
542        ///   - When executing at any Exception level, and EL2 is enabled in the current Security
543        ///     state:
544        ///     - Physical FIQ interrupts are taken to EL2, unless they are routed to EL3.
545        ///     - When HCR_EL2.TGE is 0, then Virtual FIQ interrupts are enabled.
546        ///
547        /// If EL2 is enabled in the current Security state and the value of HCR_EL2.TGE is 1:
548        ///   - Regardless of the value of the FMO bit, physical FIQ Interrupts target EL2 unless
549        ///     they are routed to EL3.
550        ///   - When FEAT_VHE is not implemented, or if HCR_EL2.E2H is 0, this field behaves as 1
551        ///     for all purposes other than a direct read of the value of this bit.
552        ///   - When FEAT_VHE is implemented and HCR_EL2.E2H is 1, this field behaves as 0 for all
553        ///     purposes other than a direct read of the value of this bit.
554        ///
555        /// For more information, see 'Asynchronous exception routing'.
556        FMO   OFFSET(3) NUMBITS(1) [
557            DisableVirtualFIQ = 0,
558            EnableVirtualFIQ = 1,
559        ],
560
561        /// Protected Table Walk.
562        PTW   OFFSET(2) NUMBITS(1) [],
563
564        /// Set/Way Invalidation Override.
565        ///
566        /// Causes Non-secure EL1 execution of the data cache
567        /// invalidate by set/way instructions to perform a data cache clean and invalidate by
568        /// set/way:
569        ///
570        /// - 0: This control has no effect on the operation of data cache invalidate by set/way
571        ///   instructions.
572        ///
573        /// - 1: Data cache invalidate by set/way instructions perform a data cache clean and
574        ///   invalidate by set/way.
575        ///
576        /// When the value of this bit is 1:
577        ///
578        /// - AArch32: DCISW performs the same invalidation as a DCCISW instruction.
579        ///
580        /// - AArch64: DC ISW performs the same invalidation as a DC CISW instruction.
581        ///
582        /// This bit can be implemented as RES 1.
583        ///
584        /// In an implementation that includes EL3, when the value of SCR_EL3.NS is 0 the PE behaves
585        /// as if this field is 0 for all purposes other than a direct read or write access of
586        /// HCR_EL2.
587        ///
588        /// When HCR_EL2.TGE is 1, the PE ignores the value of this field for all purposes other
589        /// than a direct read of this field.
590        SWIO OFFSET(1) NUMBITS(1) [],
591
592        /// Virtualization enable.
593        ///
594        /// Enables stage 2 address translation for the EL1&0 translation regime,
595        /// when EL2 is enabled in the current Security state. The possible values are:
596        ///
597        /// - 0: EL1&0 stage 2 address translation disabled.
598        /// - 1: EL1&0 stage 2 address translation enabled.
599        ///
600        /// When the value of this bit is 1, data cache invalidate instructions executed at EL1 perform
601        /// a data cache clean and invalidate. For the invalidate by set/way instruction this behavior
602        /// applies regardless of the value of the HCR_EL2.SWIO bit.
603        ///
604        /// This bit is permitted to be cached in a TLB.
605        ///
606        /// When ARMv8.1-VHE is implemented, and the value of HCR_EL2.{E2H, TGE} is {1, 1}, this
607        /// field behaves as 0 for all purposes other than a direct read of the value of this field.
608        VM OFFSET(0) NUMBITS(1) [
609            Disable = 0,
610            Enable = 1
611        ]
612    ]
613}
614
615pub struct Reg;
616
617impl Readable for Reg {
618    type T = u64;
619    type R = HCR_EL2::Register;
620
621    sys_coproc_read_raw!(u64, "HCR_EL2", "x");
622}
623
624impl Writeable for Reg {
625    type T = u64;
626    type R = HCR_EL2::Register;
627
628    sys_coproc_write_raw!(u64, "HCR_EL2", "x");
629}
630
631pub const HCR_EL2: Reg = Reg {};