Page MenuHomeFreeBSD

bhyve: fix byte order for manually set NVMe eui64
Needs ReviewPublic

Authored by novel on Fri, Aug 21, 1:50 PM.
Tags
None
Referenced Files
F167533470: D59080.diff
Sat, Aug 22, 1:17 PM
F167499430: D59080.id.diff
Sat, Aug 22, 7:59 AM
F167411126: D59080.id184646.diff
Fri, Aug 21, 2:55 PM
F167409510: D59080.diff
Fri, Aug 21, 2:46 PM

Details

Reviewers
chuck
Group Reviewers
bhyve
Summary

Manually specified eui64 value gets converted to big endian twice:
first using htobe64() and then using be64enc(). On little-endian hosts
that results in a little-endian value instead of a big-endian.

Fix by removing htobe64() for a user submitted value.

Fixes: 409a80e5a434 ("bhyve: Create EUI64 for NVMe namespaces")

Test Plan

Manually specified eui64

/usr/sbin/bhyve -c 1 -m 1024 -u -H -P -s 0:0,hostbridge \
    -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
    -s 1:0,lpc \
    -s 2:0,ahci,hd:/var/lib/libvirt/images/freebsd15.0.img \
    -s 5:0,nvme,/data/img/10gb_ufs.img,eui64=0xdeadbeef00000001 \
    -l com1,stdio \
    eui64-repro

Unpatched:

root@freebsd:~ # nvmecontrol identify nvme0ns1 | grep 'IEEE EUI64'                                                                                                                                                                                                                                                     
IEEE EUI64:                  01000000efbeadde                                                                                                                                                                                                                                                                          
root@freebsd:~ #

Patched:

root@freebsd:~ # nvmecontrol identify nvme0ns1 | grep 'IEEE EUI64'                                                                                                                                                                                                                                                     
IEEE EUI64:                  deadbeef00000001                                                                                                                                                                                                                                                                          
root@freebsd:~ #

Autogenerated eui64

/usr/sbin/bhyve -c 1 -m 1024 -u -H -P -s 0:0,hostbridge
    -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
    -s 1:0,lpc \
    -s 2:0,ahci,hd:/var/lib/libvirt/images/freebsd15.0.img \
    -s 5:0,nvme,/data/img/10gb_ufs.img \
    -l com1,stdio \
    eui64-repro

Unpatched:

root@freebsd:~ # nvmecontrol identify nvme0ns1 | grep 'IEEE EUI64'                                                                                                                                                                                                                                                     
IEEE EUI64:                  589cfc20a0a10001                                                                                                                                                                                                                                                                          
root@freebsd:~ #

Patched:

root@freebsd:~ # nvmecontrol identify nvme0ns1 | grep 'IEEE EUI64'                                                                                                                                                                                                                                                     
IEEE EUI64:                  589cfc20a0a10001                                                                                                                                                                                                                                                                          
root@freebsd:~ #

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 75945
Build 72828: arc lint + arc unit

Event Timeline

novel requested review of this revision.Fri, Aug 21, 1:50 PM
markj added a subscriber: markj.

I'm not very familiar with nvme, but I presume this might cause problems in existing VM images that embed this identifer somewhere?

I'm not very familiar with nvme, but I presume this might cause problems in existing VM images that embed this identifer somewhere?

I imagine that users who specify 'eui64=` for their NVMe devices will need to reverse the value they pass to bhyve to keep the value the same inside a VM. I think users who use autogenerated value are not affected.

I'm not very familiar with nvme, but I presume this might cause problems in existing VM images that embed this identifer somewhere?

I imagine that users who specify 'eui64=` for their NVMe devices will need to reverse the value they pass to bhyve to keep the value the same inside a VM.

Right, this looks like a backward compatibility break. I can't tell whether it's likely to hurt anyone.

I think users who use autogenerated value are not affected.

Right.