Skip to content

Commit 5a4e30a

Browse files
committed
hv: Restore CYC_OVRD WFI mode and handle FIQ disable
Put the WFI mode back how macOS expects it on boot, since it won't set it itself. Then, also trap attempts by macOS to disable FIQs. This happens in the sleep/core off path. It is not sufficient to make all that work properly, but it's a start. Signed-off-by: Hector Martin <[email protected]>
1 parent 8cf0df0 commit 5a4e30a

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/hv.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ void hv_init(void)
8080
// Compute tick interval
8181
hv_tick_interval = mrs(CNTFRQ_EL0) / HV_TICK_RATE;
8282

83+
// Set deep WFI back to defaults
84+
reg_mask(SYS_IMP_APL_CYC_OVRD, CYC_OVRD_WFI_MODE_MASK, CYC_OVRD_WFI_MODE(0));
85+
8386
sysop("dsb ishst");
8487
sysop("tlbi alle1is");
8588
sysop("dsb ish");
@@ -169,6 +172,8 @@ static void hv_init_secondary(struct hv_secondary_info_t *info)
169172
msr(SYS_IMP_APL_SPRR_CONFIG_EL1, info->sprr_config);
170173
msr(SYS_IMP_APL_GXF_CONFIG_EL1, info->gxf_config);
171174

175+
reg_mask(SYS_IMP_APL_CYC_OVRD, CYC_OVRD_WFI_MODE_MASK, CYC_OVRD_WFI_MODE(0));
176+
172177
if (gxf_enabled())
173178
gl2_call(hv_set_gxf_vbar, 0, 0, 0, 0);
174179

src/hv_exc.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,11 @@ static bool hv_handle_msr(struct exc_info *ctx, u64 iss)
270270
if (is_read) {
271271
regs[rt] = mrs(SYS_IMP_APL_CYC_OVRD);
272272
} else {
273-
msr(SYS_IMP_APL_CYC_OVRD, regs[rt] & ~CYC_OVRD_DISABLE_WFI_RET);
274-
if (regs[rt] & CYC_OVRD_DISABLE_WFI_RET)
275-
printf("msr(SYS_IMP_APL_CYC_OVRD, 0x%08lx): Filtered WFI RET disable\n",
273+
msr(SYS_IMP_APL_CYC_OVRD,
274+
regs[rt] & ~(CYC_OVRD_DISABLE_WFI_RET | CYC_OVRD_FIQ_MODE_MASK));
275+
if (regs[rt] & (CYC_OVRD_DISABLE_WFI_RET | CYC_OVRD_FIQ_MODE_MASK))
276+
printf("msr(SYS_IMP_APL_CYC_OVRD, 0x%08lx): Filtered WFI RET disable and/or "
277+
"FIQ mode\n",
276278
regs[rt]);
277279
}
278280
return true;

0 commit comments

Comments
 (0)