Virtually Anything

Musings on virtualization and other stuff


Project maintained by mgerdts Hosted on GitHub Pages — Theme by mattgraham

uefi debug in bhyve

While debugging a bug in SmartOS bhyve seen on Ubuntu guests, I needed to debug two areas that most people avoid: grub and uefi. Debugging grub is not so bad, as you can at least add print statements and they appear on the console. uefi was not quite as cooperative at first.

There are several things involved at build time:

  • While running the uefi-edk2 build script, you need the command line argument -DDEBUG_ON_SERIAL_PORT=TRUE. If building uefi-edk2 in illumos-extra, this is already taken care of.
  • You may need to tweak the PcdDebugPrintErrorLevel or PcdDebugPropertyMask in BhyvePkg/BhyvePkgX64.dsc to filter the particular types of messages you see. I’ve not experimented with these.
  • In BhyvePkg/Csm/BhyveCsm16/GNUmakefile, DEBUG_PORT needs to point to the proper COM port.
  • In BhyvePkg/Csm/BhyveCsm16/Printf.c, DebugLevel needs to be set to a level that gets the desired verbosity.

These last two bullets are taken care of with this changeset. Notice that it also changes PcdDebugIoPort in BhyvePkg/BhyvePkg.dec. I had expected that that would be sufficient to change the debug port to COM1, but it seemed to have no effect.

Once I did this, I wasn’t completely out of the woods, as I found that this caused bhyve to crash because its uart emulation only handled 1 or 2 byte operations. uefi works 4 bytes at a time. Here’s the fix.

By the time you are reading this, the bhyve bug will probably be long fixed. To save you the hassle of building a debug uefi image, you can snag the one I built. You can activate that for a single bhyve zone with:

cp .../uefi-csm-rom-debug-com1-info.bin /zones/$uuid/root
vmadm update $uuid bootrom=/uefi-csm-rom-debug-com1-info.bin
Written on February 26, 2018

Comments

Want to leave a comment? Visit this post's issue page on GitHub (you'll need a GitHub account). Alternatively, you can use the Tweet buttons to the right.

Blog Entries

  • Using kvm images with bhyve
  • Mutual exclusion of bhyve and kvm on SmartOS
  • OmniOS bhyve guest
  • Why must we manually configure a serial console?
  • Socializing my blog
  • uefi debug in bhyve
  • dtrace or mdb new processes
  • ksh stack trace

This page on Twitter

Tweet Tweet to @OMGerdts