Project

General

Profile

Actions

Bug #12939

closed

avoid packing and bitfields in bhyve VMCB

Added by Patrick Mooney almost 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Category:
bhyve
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
bhyve
Gerrit CR:
External Bug:

Description

The control and state structs for the SVM VMCB in bhyve are defined as packed structs and make heavy use of C bitfields. The former attribute (packed-ness) causes gcc9 to gripe about alignment issues:

../../i86pc/io/vmm/amd/svm.c:1518:49: error: taking address of packed member of 'struct vmcb_state' may result in an unaligned pointer value [-Werror=address-of-packed-member]
 1518 |   handled = x86_emulate_cpuid(svm_sc->vm, vcpu, &state->rax,
      |                                                 ^~~~~~~~~~~

The latter (bitfield usage) goes against our style inclinations in illumos.

It would be nice to clean up the struct definitions for both vmcb_ctrl and vmcb_state to address these issues.

Actions #1

Updated by Electric Monk almost 3 years ago

  • Gerrit CR set to 783
Actions #2

Updated by Patrick Mooney almost 3 years ago

In a test compile, tsoome reported that bhyve is gcc9 clean with the proposed fix.

Actions #3

Updated by Patrick Mooney almost 3 years ago

I fired up bhyve on a hardware machine and confirmed that my test instance booted and ran fine. Inspecting the VMCB under mdb -k yielded the expected contents.

Actions #4

Updated by Patrick Mooney almost 3 years ago

Mike Zeller has also tested this in his environment, running VMs over the weekend on platform featuring the change.

Actions #5

Updated by Electric Monk almost 3 years ago

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

git commit a517c69d55a640319d65033c3b1275bb8a9c56ab

commit  a517c69d55a640319d65033c3b1275bb8a9c56ab
Author: Patrick Mooney <pmooney@pfmooney.com>
Date:   2020-07-15T04:47:00.000Z

    12939 avoid packing and bitfields in bhyve VMCB
    Reviewed by: Mike Zeller <mike.zeller@joyent.com>
    Reviewed by: Toomas Soome <tsoome@me.com>
    Reviewed by: Andy Fiddaman <andy@omniosce.org>
    Approved by: Dan McDonald <danmcd@joyent.com>

Actions

Also available in: Atom PDF