OS-7464: uninitialized boolean from OS-7419 is too truthy


Issue Type:Bug
Priority:4 - Normal
Created at:2018-12-20T23:55:22.005Z
Updated at:2018-12-21T00:11:29.656Z


Created by:Patrick Mooney [X]
Reported by:Patrick Mooney [X]
Assigned to:Patrick Mooney [X]


Fixed: A fix for this issue is checked into the tree and tested.
(Resolution Date: 2018-12-21T00:11:27.068Z)

Fix Versions

2019-01-03 Interweb (Release Date: 2019-01-03)

Related Links




The wad from OS-7419 introduced an uninitialized boolean suspend to the main function in bhyverun.c. Testing shows that gcc will optimized this to a constant 1, meaning that the boot CPU is always started suspended. This results bhyve spinning on the VM_RUN ioctl doing no effective work until that cpu is resumed (via mdb or something else). The suspend variable should instead be initialized to false.


Comment by Patrick Mooney [X]
Created at 2018-12-21T00:04:49.423Z

Part of my testing involved checking how fbsdrun_addcpu was being called as part of main. Prior to the fix, the value of suspend is clearly optimized to "1" (in r8):

    main+0x586:                     48 89 df           movq   %rbx,%rdi
    main+0x589:                     41 b8 01 00 00 00  movl   $0x1,%r8d
    main+0x58f:                     31 d2              xorl   %edx,%edx
    main+0x591:                     31 f6              xorl   %esi,%esi
    main+0x593:                     e8 88 eb ff ff     call   -0x1478   <fbsdrun_addcpu>

After the change, it is instead loaded off the stack:

    main+0x5a6:                     0f b6 45 90        movzbl -0x70(%rbp),%eax
    main+0x5aa:                     48 8b 4d b8        movq   -0x48(%rbp),%rcx
    main+0x5ae:                     48 89 df           movq   %rbx,%rdi
    main+0x5b1:                     31 d2              xorl   %edx,%edx
    main+0x5b3:                     31 f6              xorl   %esi,%esi
    main+0x5b5:                     83 e0 01           andl   $0x1,%eax
    main+0x5b8:                     41 89 c0           movl   %eax,%r8d
    main+0x5bb:                     e8 60 eb ff ff     call   -0x14a0   <fbsdrun_addcpu>

Comment by Patrick Mooney [X]
Created at 2018-12-21T00:07:45.650Z

With the patch applied, I confirmed that bhyve instances start as expected, rather than spinning on DEBUG exitcodes. I also checked than an instance with the -d flag set will properly suspend the CPU so mdb can be attached prior to execution of the first instruction.

Comment by Jira Bot
Created at 2018-12-21T00:11:29.656Z

illumos-joyent commit e663a50b59772e4addad64b4fdd70cac38e994a4 (branch master, by Patrick Mooney)

OS-7464 uninitialized boolean from OS-7419 is too truthy
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Approved by: Jerry Jelinek <jerry.jelinek@joyent.com>