Index | Thread | Search

From:
Mike Larkin <mlarkin@nested.page>
Subject:
Re: fix deadlock if pausing a vm with a busy-polling vcpu
To:
Dave Voutila <dv@sisu.io>
Cc:
tech@openbsd.org
Date:
Thu, 12 Feb 2026 13:24:50 -0800

Download raw body.

Thread
On Thu, Feb 12, 2026 at 10:02:17AM -0500, Dave Voutila wrote:
> If a vcpu isn't halted because it's busy polling (like at the
> bootloader prompt), issuing a pause via `vmctl pause <vm>` will
> effectively deadlock. This removes the condition that the vcpu needs
> to be in a halted state and aggressively pauses at the next vm exit.
>
> If you want to see the current deadlock, boot an installer image and
> at the boot prompt just type a single character to stop the auto-boot
> from occurring. Now try to `vmctl pause`.
>
> ok?
>
>
> diff refs/heads/master refs/heads/vmd-pause-deadlock
> commit - 012cf974ca6d25b889551a1e73afca0e5a6d0994
> commit + 35699612346148cad906319a3a64d4862bcd0f15
> blob - 6d571ce90fc27d700755eae58c2127ce874efd3f
> blob + 4b43735e16d2910a4ca843f425e32fa643016df4
> --- usr.sbin/vmd/vm.c
> +++ usr.sbin/vmd/vm.c
> @@ -826,2 +826,2 @@ vcpu_run_loop(void *arg)
>  		halted = vcpu_hlt[n];
>  		mutex_unlock(&vm_mtx);
>
> -		/* If we are halted and need to pause, pause */
> -		if (halted && paused) {
> +		/* If we need to pause, wait on the barrier. */
> +		if (paused) {
>  			ret = pthread_barrier_wait(&vm_pause_barrier);
>  			if (ret != 0 && ret != PTHREAD_BARRIER_SERIAL_THREAD) {
>  				log_warnx("%s: could not wait on pause barrier (%d)",
>

ok mlarkin