From d8c6becdbe60fbae2264356c048da668b547635e Mon Sep 17 00:00:00 2001 From: guenther Date: Thu, 27 Jul 2023 00:28:24 +0000 Subject: [PATCH] Follow the lead of mips64 and make cpu_idle_cycle() just call the indirect pointer itself and provide an initializer for that going to the default "just enable interrupts and halt" path. ok kettenis@ --- sys/arch/amd64/amd64/locore.S | 14 +++++--------- sys/arch/amd64/amd64/machdep.c | 5 +++-- sys/arch/amd64/include/cpu.h | 3 ++- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/sys/arch/amd64/amd64/locore.S b/sys/arch/amd64/amd64/locore.S index c2536e7395b..2046f0997c8 100644 --- a/sys/arch/amd64/amd64/locore.S +++ b/sys/arch/amd64/amd64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.137 2023/07/25 06:48:37 guenther Exp $ */ +/* $OpenBSD: locore.S,v 1.138 2023/07/27 00:28:24 guenther Exp $ */ /* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */ /* @@ -473,21 +473,17 @@ bogus_proc_pmap: #endif /* DIAGNOSTIC */ END(cpu_switchto) -/* placed here for correct static branch prediction in cpu_idle_* */ NENTRY(retpoline_rax) JMP_RETPOLINE(rax) -ENTRY(cpu_idle_cycle) - RETGUARD_SETUP(cpu_idle_cycle, r11) - movq cpu_idle_cycle_fcn,%rax - cmpq $0,%rax - jne retpoline_rax +ENTRY(cpu_idle_cycle_hlt) + RETGUARD_SETUP(cpu_idle_cycle_hlt, r11) sti hlt - RETGUARD_CHECK(cpu_idle_cycle, r11) + RETGUARD_CHECK(cpu_idle_cycle_hlt, r11) ret lfence -END(cpu_idle_cycle) +END(cpu_idle_cycle_hlt) /* * savectx(struct pcb *pcb); diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index ddbeedb12b5..453de13fbfb 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.285 2023/07/10 03:32:10 guenther Exp $ */ +/* $OpenBSD: machdep.c,v 1.286 2023/07/27 00:28:25 guenther Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /*- @@ -160,7 +160,8 @@ char machine[] = MACHINE; /* * switchto vectors */ -void (*cpu_idle_cycle_fcn)(void) = NULL; +void cpu_idle_cycle_hlt(void); +void (*cpu_idle_cycle_fcn)(void) = &cpu_idle_cycle_hlt; /* the following is used externally for concurrent handlers */ int setperf_prio = 0; diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h index b5784abe689..cf322886269 100644 --- a/sys/arch/amd64/include/cpu.h +++ b/sys/arch/amd64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.157 2023/07/25 18:16:19 cheloha Exp $ */ +/* $OpenBSD: cpu.h,v 1.158 2023/07/27 00:28:24 guenther Exp $ */ /* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */ /*- @@ -406,6 +406,7 @@ void cpu_proc_fork(struct proc *, struct proc *); int amd64_pa_used(paddr_t); #define cpu_idle_enter() do { /* nothing */ } while (0) extern void (*cpu_idle_cycle_fcn)(void); +#define cpu_idle_cycle() (*cpu_idle_cycle_fcn)() #define cpu_idle_leave() do { /* nothing */ } while (0) struct region_descriptor; -- 2.20.1