Page MenuHomeFreeBSD

fix virtio Device Configuration Space on big endian platforms (i.e. PowerPC64). Also enable virtio drivers on default PowerPC64 kernel configuration
AbandonedPublic

Authored by alfredo on Apr 3 2019, 6:28 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jun 23, 3:22 PM
Unknown Object (File)
May 25 2024, 4:48 AM
Unknown Object (File)
May 22 2024, 3:17 AM
Unknown Object (File)
Apr 20 2024, 2:50 PM
Unknown Object (File)
Dec 20 2023, 3:45 AM
Unknown Object (File)
Dec 10 2023, 7:04 PM
Unknown Object (File)
Nov 28 2023, 2:18 PM
Unknown Object (File)
Nov 26 2023, 1:22 AM

Details

Reviewers
jhibbits
bryanv
Summary

virtio-net and virtio-scsi driver didn't work on PowerPC64 due to an endianess problem on Device Configuration Space area. This area was assumed to be in same endianess as the guest OS, but virtio-1.x spec says:

2.3 Device Configuration Space
Device configuration space is generally used for rarely-changing or initialization-time parameters. Where configuration fields are optional, their existence is indicated by feature bits: Future versions of this specification will likely extend the device configuration space by adding extra fields at the tail. Note: The device configuration space uses the little-endian format for multi-byte fields.

This patch fixes the endianess on Big Endian platforms such as PowerPC64 and enables it on default kernel configuration.

Reference: http://docs.oasis-open.org/virtio/virtio/v1.0/cs04/virtio-v1.0-cs04.html#x1-170003

Test Plan

Check virtio-net and virtio-scsi on PowerPC64 elfv2 kernel, on QEMU using the following parameters:

qemu-system-ppc64 -name guest=alfredo3 -m 4096 -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd -drive if=none,id=hd,file=vdisks/vm3-disk1.qcow2,format=qcow2 -device virtio-net-pci,netdev=vneta0,disable-legacy=off,disable-modern=off -netdev tap,id=vneta0 -nographic -vga none -cpu POWER8E -smp 8 -enable-kvm -machine pseries-3.0,accel=kvm,cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken,cap-hpt-max-page-size=16M -mem-prealloc -mem-path /dev/hugepages

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 23497
Build 22504: arc lint + arc unit

Event Timeline

bryanv requested changes to this revision.Apr 3 2019, 7:08 PM

This is not correct. You are quoting from the V1 spec but the FreeBSD VirtIO drivers are written against the pre-V1 (0.9.5 aka legacy) which uses guest endian.

I have a rather dated branch that adds support for V1 but I have not had the time to commit it: https://github.com/bryanv/freebsd/tree/virtio

This revision now requires changes to proceed.Apr 3 2019, 7:08 PM
alfredo edited the summary of this revision. (Show Details)
alfredo edited the test plan for this revision. (Show Details)

remove LE/BE ifdefs as recommended

bryanv requested changes to this revision.Apr 3 2019, 7:27 PM

Please reread my prior comment. This is not correct.

This revision now requires changes to proceed.Apr 3 2019, 7:27 PM

Please reread my prior comment. This is not correct.

I see, I wasn't aware of this, thank you for your feedback.
Sounds like the issue is different, I guess FreeBSD virtio drivers shouldn't be attaching on this setup. It needs more investigation.

Abandoning this change as it requires more investigation whatever problem is on QEMU or FreeBSD