From 955735595f25b08ba2c651ce2e3dcd291a1af260 Mon Sep 17 00:00:00 2001 From: gkoehler Date: Mon, 7 Feb 2022 22:28:15 +0000 Subject: [PATCH] Allow "ddb{1}> trace" through interrupt on macppc If cpu0 sends PPC_IPI_DDB to cpu1, then cpu1 stops on its interrupt stack. Teach ININTSTK to allow traces through all interrupt stacks, not only cpu0's. ININTSTK now works by looping for all cpus. It doesn't remember which cpu owns the stack. A macppc has at most 4 cpus. ok kettenis@ miod@ --- sys/arch/powerpc/ddb/db_trace.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/sys/arch/powerpc/ddb/db_trace.c b/sys/arch/powerpc/ddb/db_trace.c index 82913cb719a..e9351e93f6c 100644 --- a/sys/arch/powerpc/ddb/db_trace.c +++ b/sys/arch/powerpc/ddb/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.18 2022/01/28 18:37:40 gkoehler Exp $ */ +/* $OpenBSD: db_trace.c,v 1.19 2022/02/07 22:28:15 gkoehler Exp $ */ /* $NetBSD: db_trace.c,v 1.15 1996/02/22 23:23:41 gwr Exp $ */ /* @@ -104,14 +104,27 @@ db_save_regs(struct trapframe *frame) /* from locore.S */ extern vaddr_t trapexit; -extern vaddr_t esym; #define INTSTK (8*1024) /* 8K interrupt stack */ #define INKERNEL(va) (((vaddr_t)(va)) >= VM_MIN_KERNEL_ADDRESS && \ ((vaddr_t)(va)) < VM_MAX_KERNEL_ADDRESS) -#define ININTSTK(va) (((vaddr_t)(va)) >= round_page(esym) && \ - ((vaddr_t)(va)) < (round_page(esym) + INTSTK)) +#define ININTSTK(va) db_in_interrupt_stack((vaddr_t)(va)) + +int +db_in_interrupt_stack(vaddr_t va) +{ + struct cpu_info *ci; + CPU_INFO_ITERATOR cii; + vaddr_t stack; + + CPU_INFO_FOREACH(cii, ci) { + stack = (vaddr_t)ci->ci_intstk; + if (va >= stack - INTSTK && va < stack) + return 1; + } + return 0; +} /* * Frame tracing. -- 2.20.1