From 73e6a6f7f5e349e3e80c23d84a5f3ff867d68447 Mon Sep 17 00:00:00 2001 From: kettenis Date: Thu, 10 Aug 2023 21:01:50 +0000 Subject: [PATCH] Take advantage of the fact that the WFI instruction does continue immediately if there is a pending interrupt to fix a potential race in the idle loop. ok guenther@ --- sys/arch/arm64/arm64/machdep.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/arch/arm64/arm64/machdep.c b/sys/arch/arm64/arm64/machdep.c index 6b2dcba9c05..d0c1601139f 100644 --- a/sys/arch/arm64/arm64/machdep.c +++ b/sys/arch/arm64/arm64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.83 2023/07/13 08:33:36 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.84 2023/08/10 21:01:50 kettenis Exp $ */ /* * Copyright (c) 2014 Patrick Wildt * Copyright (c) 2021 Mark Kettenis @@ -209,6 +209,7 @@ consinit(void) void cpu_idle_enter(void) { + disable_irq_daif(); } void (*cpu_idle_cycle_fcn)(void) = cpu_wfi; @@ -216,13 +217,15 @@ void (*cpu_idle_cycle_fcn)(void) = cpu_wfi; void cpu_idle_cycle(void) { - enable_irq_daif(); cpu_idle_cycle_fcn(); + enable_irq_daif(); + disable_irq_daif(); } void cpu_idle_leave(void) { + enable_irq_daif(); } /* Dummy trapframe for proc0. */ -- 2.20.1