On Mon, Aug 29, 2022 at 04:40:20PM +0200, Greg Steuck wrote:
> I tried to boot a kcov-enabled config which we run on syzkaller VMs on
> real HW today. It hung, so I minimized the hanging kernel config to just
> this:
> 
> include "arch/amd64/conf/GENERIC.MP"
> pseudo-device kcov 1
> 
> My machine is an unexciting Lenovo ThinkPad X1 Carbon 7th Gen (20QE).
> I marked the spot where it *would* hang in the dmesg below:

Ran into the same problem while running OpenBSD with KCOV enabled on
Hyper-V. Caused by accessing curproc too early. Could you give this diff
a try?

diff --git sys/kern/kern_task.c sys/kern/kern_task.c
index 71de6dc902b..4669d7c7bfd 100644
--- sys/kern/kern_task.c
+++ sys/kern/kern_task.c
@@ -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 sys/kern/kern_timeout.c sys/kern/kern_timeout.c
index 4ca81ad42df..9553b31ba1f 100644
--- sys/kern/kern_timeout.c
+++ sys/kern/kern_timeout.c
@@ -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 sys/sys/kcov.h sys/sys/kcov.h
index 2c357f8855b..8398a6f6edc 100644
--- sys/sys/kcov.h
+++ sys/sys/kcov.h
@@ -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 *);

Reply via email to