From da19784a104e7aeb394f4a4edeae337f2a8a0144 Mon Sep 17 00:00:00 2001 From: anton Date: Sat, 29 Jul 2023 06:52:08 +0000 Subject: [PATCH] Avoid accessing curproc early during boot when kcov is enabled as it might be unassigned until all secondary processors are up and running. --- sys/kern/kern_task.c | 5 +++-- sys/kern/kern_timeout.c | 8 +++++--- sys/sys/kcov.h | 4 +++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sys/kern/kern_task.c b/sys/kern/kern_task.c index 71de6dc902b..38ba22f03d7 100644 --- a/sys/kern/kern_task.c +++ b/sys/kern/kern_task.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_task.c,v 1.33 2022/08/15 11:38:35 mvs Exp $ */ +/* $OpenBSD: kern_task.c,v 1.34 2023/07/29 06:52:08 anton Exp $ */ /* * Copyright (c) 2013 David Gwynne @@ -363,7 +363,8 @@ task_add(struct taskq *tq, struct task *w) SET(w->t_flags, TASK_ONQUEUE); TAILQ_INSERT_TAIL(&tq->tq_worklist, w, t_entry); #if NKCOV > 0 - w->t_process = curproc->p_p; + if (!kcov_cold) + w->t_process = curproc->p_p; #endif } mtx_leave(&tq->tq_mtx); diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index 4ca81ad42df..eb39ac0eed3 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_timeout.c,v 1.94 2023/07/14 07:07:08 claudio Exp $ */ +/* $OpenBSD: kern_timeout.c,v 1.95 2023/07/29 06:52:08 anton Exp $ */ /* * Copyright (c) 2001 Thomas Nordin * Copyright (c) 2000-2001 Artur Grabowski @@ -307,7 +307,8 @@ timeout_add(struct timeout *new, int to_ticks) CIRCQ_INSERT_TAIL(&timeout_new, &new->to_list); } #if NKCOV > 0 - new->to_process = curproc->p_p; + if (!kcov_cold) + new->to_process = curproc->p_p; #endif tostat.tos_added++; mtx_leave(&timeout_mutex); @@ -406,7 +407,8 @@ timeout_abs_ts(struct timeout *to, const struct timespec *abstime) CIRCQ_INSERT_TAIL(&timeout_new, &to->to_list); } #if NKCOV > 0 - to->to_process = curproc->p_p; + if (!kcov_cold) + to->to_process = curproc->p_p; #endif tostat.tos_added++; diff --git a/sys/sys/kcov.h b/sys/sys/kcov.h index 2c357f8855b..e92aa0abeaf 100644 --- a/sys/sys/kcov.h +++ b/sys/sys/kcov.h @@ -1,4 +1,4 @@ -/* $OpenBSD: kcov.h,v 1.8 2021/12/29 07:15:13 anton Exp $ */ +/* $OpenBSD: kcov.h,v 1.9 2023/07/29 06:52:08 anton Exp $ */ /* * Copyright (c) 2018 Anton Lindqvist @@ -41,6 +41,8 @@ struct kio_remote_attach { struct proc; +extern int kcov_cold; + void kcov_exit(struct proc *); int kcov_vnode(struct vnode *); void kcov_remote_register(int, void *); -- 2.20.1