core dumps running in bhyve

Chuck Tuffli chuck at tuffli.net
Tue Dec 25 01:25:31 UTC 2018


Using the latest bhyve, I'm seeing core dumps in the guest when running:
    nvmecontrol identify nvme0
against the emulated NVMe drive. The location of the core dump changes
from run to run, but I suspect the root cause is a memory corruption
caused by the transfer of the Identify data (4KB) back to the guest.
This transfer of data is actually a memcpy to an address returned from
vm_map_gpa() based on the physical address provided by the guest.

Based on the signature of one of the core dumps, I modified
nvmecontrol to always pass a 4KB aligned buffer to the driver instead
of the (typically) unaligned address of the structure on the stack.
With this change, nvmecontrol in the guest no longer core dumps. What
I don't understand is why this changes the behavior. Do the addresses
passed to vm_map_gpa() need to be page aligned? Or did moving the
memory location from the stack to the heap merely mitigate what is
corrupted?

Thoughts?

--chuck


More information about the freebsd-hackers mailing list