Skip to content

Commit 99571e5

Browse files
committed
hv: Use architectural ACTLR_EL12 on M2+
Signed-off-by: Asahi Lina <[email protected]>
1 parent 83ac04c commit 99571e5

6 files changed

Lines changed: 28 additions & 7 deletions

File tree

proxyclient/m1n1/hv/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class HV(Reloadable):
5050
MAIR_EL1: MAIR_EL12,
5151
AMAIR_EL1: AMAIR_EL12,
5252
CONTEXTIDR_EL1: CONTEXTIDR_EL12,
53-
ACTLR_EL1: ACTLR_EL12,
53+
# ACTLR_EL1: ACTLR_EL12, # Handled in hv_exc.c, depends on CPU version
5454
AMX_CONFIG_EL1: AMX_CONFIG_EL12,
5555
SPRR_CONFIG_EL1: SPRR_CONFIG_EL12,
5656
SPRR_PPERM_EL1: SPRR_PPERM_EL12,

src/arm_cpu_regs.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
#include "types.h"
44

5-
#define SYS_ACTLR_EL1 sys_reg(3, 0, 1, 0, 1)
6-
#define SYS_ACTLR_EL2 sys_reg(3, 4, 1, 0, 1)
7-
#define SYS_ACTLR_EL3 sys_reg(3, 6, 1, 0, 1)
5+
#define SYS_ACTLR_EL1 sys_reg(3, 0, 1, 0, 1)
6+
#define SYS_ACTLR_EL2 sys_reg(3, 4, 1, 0, 1)
7+
#define SYS_ACTLR_EL3 sys_reg(3, 6, 1, 0, 1)
8+
#define SYS_ACTLR_EL12 sys_reg(3, 5, 1, 0, 1)
89

910
#define SYS_CNTHCTL_EL2 sys_reg(3, 4, 14, 1, 0)
1011
// HCR_EL2.E2H == 1

src/chickens.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ void init_t6021_avalanche(int rev);
4242
void init_t6031_sawtooth(void);
4343
void init_t6031_everest(int rev);
4444

45+
bool cpufeat_actlr_el2;
46+
4547
const char *init_cpu(void)
4648
{
4749
const char *cpu = "Unknown";
@@ -142,6 +144,9 @@ const char *init_cpu(void)
142144
break;
143145
}
144146

147+
if (part >= MIDR_PART_T8110_BLIZZARD)
148+
cpufeat_actlr_el2 = true;
149+
145150
int core = mrs(MPIDR_EL1) & 0xff;
146151

147152
// Unknown, related to SMP?

src/hv_exc.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ static bool hv_handle_msr_unlocked(struct exc_info *ctx, u64 iss)
229229
SYSREG_PASS(sys_reg(3, 1, 15, 9, 0));
230230
SYSREG_PASS(sys_reg(3, 1, 15, 10, 0));
231231
/* Noisy traps */
232-
SYSREG_MAP(SYS_ACTLR_EL1, SYS_IMP_APL_ACTLR_EL12)
233232
SYSREG_PASS(SYS_IMP_APL_HID4)
234233
SYSREG_PASS(SYS_IMP_APL_EHID4)
235234
/* We don't normally trap hese, but if we do, they're noisy */
@@ -272,6 +271,20 @@ static bool hv_handle_msr_unlocked(struct exc_info *ctx, u64 iss)
272271
SYSREG_PASS(sys_reg(1, 0, 8, 1, 2)) // TLBI ASIDE1OS
273272
SYSREG_PASS(sys_reg(1, 0, 8, 5, 1)) // TLBI RVAE1OS
274273

274+
case SYSREG_ISS(SYS_ACTLR_EL1):
275+
if (is_read) {
276+
if (cpufeat_actlr_el2)
277+
regs[rt] = mrs(SYS_ACTLR_EL12);
278+
else
279+
regs[rt] = mrs(SYS_IMP_APL_ACTLR_EL12);
280+
} else {
281+
if (cpufeat_actlr_el2)
282+
msr(SYS_ACTLR_EL12, regs[rt]);
283+
else
284+
msr(SYS_IMP_APL_ACTLR_EL12, regs[rt]);
285+
}
286+
return true;
287+
275288
case SYSREG_ISS(SYS_IMP_APL_IPI_SR_EL1):
276289
if (is_read)
277290
regs[rt] = PERCPU(ipi_pending) ? IPI_SR_PENDING : 0;

src/utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ struct vector_args {
429429
};
430430

431431
extern u32 board_id, chip_id;
432+
extern bool cpufeat_actlr_el2;
432433

433434
extern struct vector_args next_stage;
434435

tools/apple_regs.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@
276276
{"index": 0, "name": "SPRR_AMRANGE_EL2", "fullname": "SPRR AM Range (EL2)", "enc": [3, 6, 15, 14, 3 ], "width": 64},
277277
{"index": 0, "name": "VMKEYLO_EL2", "fullname": "Pointer Authentication VM Machine Key Low", "enc": [3, 6, 15, 14, 4 ], "width": 64},
278278
{"index": 0, "name": "VMKEYHI_EL2", "fullname": "Pointer Authentication VM Machine Key High", "enc": [3, 6, 15, 14, 5 ], "width": 64},
279-
{"index": 0, "name": "ACTLR_EL12", "fullname": "Auxiliary Control Register (EL12)", "enc": [3, 6, 15, 14, 6 ], "width": 64},
279+
{"index": 0, "name": "ACTLR_EL12_PRE", "fullname": "Auxiliary Control Register (EL12, pre-spec)", "enc": [3, 6, 15, 14, 6 ], "width": 64},
280280
{"index": 0, "name": "APSTS_EL12", "fullname": "Pointer Authentication Status (EL12)", "enc": [3, 6, 15, 14, 7 ], "width": 64},
281281
{"index": 0, "name": "APCTL_EL12", "fullname": "Pointer Authentication Control (EL12)", "enc": [3, 6, 15, 15, 0 ], "width": 64},
282282
{"index": 0, "name": "GXF_CONFIG_EL12", "fullname": "GXF Configuration Register (EL12)", "enc": [3, 6, 15, 15, 1 ], "width": 64},
@@ -332,5 +332,6 @@
332332
{"name": "TRAP_PM", "msb": 57, "lsb": 57},
333333
{"name": "TRAP_UPM", "msb": 58, "lsb": 58},
334334
{"name": "TRAP_s3_1z7_c15_cx_3", "msb": 59, "lsb": 59}
335-
]}]}
335+
]}]},
336+
{"index": 0, "name": "ACTLR_EL12", "fullname": "Auxiliary Control Register (EL12)", "enc": [3, 5, 1, 0, 1 ], "width": 64}
336337
]

0 commit comments

Comments
 (0)