Skip to content
This repository was archived by the owner on Nov 7, 2022. It is now read-only.

Commit 2f0ba8b

Browse files
authored
El2: Adding TTBR0_EL2, ESR_EL2, SCTLR_EL2, MAIR_EL2, TCR_EL2, and VM field to HCR_EL2 (#28)
* Adding the VM field to HCR_EL2, which enables a second stage of translation. As documented here: https://developer.arm.com/documentation/ddi0500/d/system-control/aarch64-register-descriptions/hypervisor-configuration-register * adding TTBR0_EL2 * Adding ESR_EL2 * Adding SCTLR_EL2 * Adding MAIR_EL2 * More descriptive explanation for the VM field in HCR_EL2 * Adding TCR_EL2 Co-authored-by: landhb <landhb@users.noreply.github.com>
1 parent 8384597 commit 2f0ba8b

File tree

7 files changed

+906
-1
lines changed

7 files changed

+906
-1
lines changed

src/regs/esr_el2.rs

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// SPDX-License-Identifier: Apache-2.0 OR MIT
2+
//
3+
// Copyright (c) 2018-2021 by the author(s)
4+
//
5+
// Author(s):
6+
// - Andre Richter <andre.o.richter@gmail.com>
7+
// - Berkus Decker <berkus+github@metta.systems>
8+
// - Bradley Landherr <landhb@users.noreply.github.com>
9+
10+
//! Exception Syndrome Register - EL2
11+
//!
12+
//! Holds syndrome information for an exception taken to EL2.
13+
14+
use register::{cpu::RegisterReadOnly, register_bitfields};
15+
16+
register_bitfields! {u64,
17+
pub ESR_EL2 [
18+
19+
/// Reserved
20+
RES0 OFFSET(37) NUMBITS(27) [],
21+
22+
/// Instruction Specific Syndrome 2. If a memory access generated by an ST64BV or ST64BV0
23+
/// instruction generates a Data Abort for a Translation fault, Access flag fault, or
24+
/// Permission fault, then this field holds register specifier, Xs.
25+
///
26+
/// For any other Data Abort, this field is RES0.
27+
ISS2 OFFSET(32) NUMBITS(5) [],
28+
29+
/// Exception Class. Indicates the reason for the exception that this register holds
30+
/// information about.
31+
///
32+
/// For each EC value, the table references a subsection that gives information about:
33+
/// - The cause of the exception, for example the configuration required to enable the
34+
/// trap.
35+
/// - The encoding of the associated ISS.
36+
///
37+
/// Incomplete listing - to be done.
38+
EC OFFSET(26) NUMBITS(6) [
39+
Unknown = 0b00_0000,
40+
TrappedWFIorWFE = 0b00_0001,
41+
TrappedMCRorMRC = 0b00_0011, // A32
42+
TrappedMCRRorMRRC = 0b00_0100, // A32
43+
TrappedMCRorMRC2 = 0b00_0101, // A32
44+
TrappedLDCorSTC = 0b00_0110, // A32
45+
TrappedFP = 0b00_0111,
46+
TrappedMRRC = 0b00_1100, // A32
47+
BranchTarget = 0b00_1101,
48+
IllegalExecutionState = 0b00_1110,
49+
SVC32 = 0b01_0001, // A32
50+
SVC64 = 0b01_0101,
51+
HVC64 = 0b01_0110,
52+
SMC64 = 0b01_0111,
53+
TrappedMsrMrs = 0b01_1000,
54+
TrappedSve = 0b01_1001,
55+
PointerAuth = 0b01_1100,
56+
InstrAbortLowerEL = 0b10_0000,
57+
InstrAbortCurrentEL = 0b10_0001,
58+
PCAlignmentFault = 0b10_0010,
59+
DataAbortLowerEL = 0b10_0100,
60+
DataAbortCurrentEL = 0b10_0101,
61+
SPAlignmentFault = 0b10_0110,
62+
TrappedFP32 = 0b10_1000, // A32
63+
TrappedFP64 = 0b10_1100,
64+
SError = 0b10_1111,
65+
BreakpointLowerEL = 0b11_0000,
66+
BreakpointCurrentEL = 0b11_0001,
67+
SoftwareStepLowerEL = 0b11_0010,
68+
SoftwareStepCurrentEL = 0b11_0011,
69+
WatchpointLowerEL = 0b11_0100,
70+
WatchpointCurrentEL = 0b11_0101,
71+
Bkpt32 = 0b11_1000, // A32 BKTP instruction
72+
Brk64 = 0b11_1100 // A64 BRK instruction
73+
],
74+
75+
/// Instruction Length for synchronous exceptions.
76+
IL OFFSET(25) NUMBITS(1) [],
77+
78+
/// Instruction Specific Syndrome. Architecturally, this field can be defined independently
79+
/// for each defined Exception class. However, in practice, some ISS encodings are used for
80+
/// more than one Exception class.
81+
ISS OFFSET(0) NUMBITS(25) []
82+
]
83+
}
84+
85+
pub struct Reg;
86+
87+
impl RegisterReadOnly<u64, ESR_EL2::Register> for Reg {
88+
sys_coproc_read_raw!(u64, "ESR_EL2", "x");
89+
}
90+
91+
pub static ESR_EL2: Reg = Reg {};

src/regs/hcr_el2.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//
55
// Author(s):
66
// - Andre Richter <andre.o.richter@gmail.com>
7+
// - Bradley Landherr <landhb@users.noreply.github.com>
78

89
//! Hypervisor Configuration Register - EL2
910
//!
@@ -89,7 +90,26 @@ register_bitfields! {u64,
8990
///
9091
/// When HCR_EL2.TGE is 1, the PE ignores the value of this field for all purposes other
9192
/// than a direct read of this field.
92-
SWIO OFFSET(1) NUMBITS(1) []
93+
SWIO OFFSET(1) NUMBITS(1) [],
94+
95+
/// Virtualization enable. Enables stage 2 address translation for the EL1&0 translation regime,
96+
/// when EL2 is enabled in the current Security state. The possible values are:
97+
///
98+
/// 0 EL1&0 stage 2 address translation disabled.
99+
/// 1 EL1&0 stage 2 address translation enabled.
100+
///
101+
/// When the value of this bit is 1, data cache invalidate instructions executed at EL1 perform
102+
/// a data cache clean and invalidate. For the invalidate by set/way instruction this behavior
103+
/// applies regardless of the value of the HCR_EL2.SWIO bit.
104+
///
105+
/// This bit is permitted to be cached in a TLB.
106+
///
107+
/// When ARMv8.1-VHE is implemented, and the value of HCR_EL2.{E2H, TGE} is {1, 1}, this
108+
/// field behaves as 0 for all purposes other than a direct read of the value of this field.
109+
VM OFFSET(0) NUMBITS(1) [
110+
Disable = 0,
111+
Enable = 1
112+
]
93113
]
94114
}
95115

0 commit comments

Comments
 (0)