Project

General

Profile

Actions

Bug #14521

closed

bhyve should use error checking mutexes and check results

Added by Andy Fiddaman 6 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

bhyve uses mutexes in various places but almost all use the default attributes and nowhere checks that locks and unlocks succeed properly.
Mutexes default to error checking on FreeBSD, where the code originates, but do not on illumos.

We should use the bhyve compat later to improve this situation by using error checking mutexes everywhere, and to check that things succeed as we expect, without having to excessively modify the bhyve code or litter it with #ifdef statements.


Related issues

Related to illumos gate - Feature #6209: libc mutexes break kernel writers heartsClosedRobert Mustacchi2015-09-08

Actions
Related to illumos gate - Feature #14522: Provide PTHREAD_{ERRORCHECK,RECURSIVE}_MUTEX_INITIALIZER_NPClosedAndy Fiddaman

Actions
Actions #1

Updated by Electric Monk 6 months ago

  • Gerrit CR set to 2038
Actions #2

Updated by Andy Fiddaman 6 months ago

  • Related to Feature #6209: libc mutexes break kernel writers hearts added
Actions #3

Updated by Andy Fiddaman 6 months ago

  • Related to Feature #14522: Provide PTHREAD_{ERRORCHECK,RECURSIVE}_MUTEX_INITIALIZER_NP added
Actions #4

Updated by Patrick Mooney 6 months ago

ISTR there being some bhyve userspace code which depended on recursive mutex entry. I could be misremembering, though.

Actions #5

Updated by Andy Fiddaman 6 months ago

Patrick Mooney wrote in #note-4:

ISTR there being some bhyve userspace code which depended on recursive mutex entry. I could be misremembering, though.

pci_virtio_input.c does. We don't build that yet but even if we did it should be fine as the new checked_pthread_mutex_init() function will honour the attributes it's called with, if they aren't NULL.

Actions #6

Updated by Andy Fiddaman 5 months ago

I've tested this by booting the usual array of guests under both x86 and amd64 hosts, including OmniOS, FreeBSD, Windows 10 and 11, with pass-through, framebuffer and a variety of peripherals such as the virtio-rnd device.

It has been in OmniOS bloody for a couple of weeks and been tested there too.

Actions #7

Updated by Electric Monk 5 months ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

git commit 7bb0eb348e1119aed76a61d633a9106b6b9912f1

commit  7bb0eb348e1119aed76a61d633a9106b6b9912f1
Author: Andy Fiddaman <omnios@citrus-it.co.uk>
Date:   2022-03-16T00:02:44.000Z

    14521 bhyve should use error checking mutexes and check results
    14522 Provide PTHREAD_{ERRORCHECK,RECURSIVE}_MUTEX_INITIALIZER_NP
    Portions contributed by: Robert Mustacchi <rm@fingolfin.org>
    Reviewed by: Robert Mustacchi <rm@fingolfin.org>
    Reviewed by: Jason King <jason.brian.king@gmail.com>
    Approved by: Dan McDonald <danmcd@joyent.com>

Actions

Also available in: Atom PDF