Comments (7)
it's host-endian, not big-endian: that is, we don't do, or attempt to do, any handling of different endianness at all. We certainly wouldn't be against supporting this, but not something we're planning to work on ourselves.
from libvfio-user.
To clarify my environment: I ran a qemu vfio-user client against a qemu vfio-user server on a big-endian host. So, both client and server are in big-endian byte order and hence expected to interoperate.
However, I found that server and client disagree on the bit field layout in the header flags field. The qemu client would treat flags as a single uint32_t value in host byte order and so the flags field of a reply message would be 0x00 0x00 0x00 0x01
in memory (which I consider correct per the spec, considering that the flags field is supposed to be in host byte order, which is big endian). However, libvfio-user's bit field places the type bits at other end of the uint32_t, i.e. a flags field of a reply message is encoded as 0x10 0x00 0x00 0x00
. Unsurprisingly, I didn't even get past version negotiation ;-)
Then I researched what the net has to say about bit fields and byte order, and found that the standards leave this implementation defined. In practice, compilers are forced to implement whatever widespread conventions there are (e.g. Linux does https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/ip.h?h=03702d4d29be4e2510ec80b248dbbde4e57030d9#n88 for example). At the end of the day, it's IMO prudent to accept that bit field encoding is a mine field and rather rely on shifting and masking to pack/unpack the flags field.
from libvfio-user.
I see, because the client doesn't use bitfields, we get bitten by the different on big endian systems.
Makes sense.
from libvfio-user.
@mnissler-rivos are you planning to submit a patch?
from libvfio-user.
It's not a priority for me given that none of my stuff is running on big-endian host systems (I found this after checking on big-ending when checking qemu behavior in context of a code review there). If you're all OK with replacing the bitfield with #define
s, I can put together a quick MR and test it later this week.
from libvfio-user.
I'm not sure there's any other way around this other than using #define
s, so I'd take such a PR, @jlevon ?
from libvfio-user.
yup for sure thanks
from libvfio-user.
Related Issues (20)
- Fails to build on Fedora i686 and ppc64le HOT 17
- support for very large 64-bit bars HOT 5
- libvfio-user responds with duplicated FD in get_region_info when sparse maps is used HOT 2
- implement test to demonstrate performance benefit of shadow ioeventfd
- implement new capabilities
- mmap_len in dma_map_region may be incorrect
- nvmf_subsystem_add_listener return error when CONFIG_ARM64_64K_PAGES=y HOT 3
- QEMU crash when execute device_add and device_del alternately HOT 2
- test/unit-tests.c GCC13 compilation error, dangling-pointer HOT 5
- Add support for emulating CXL devices HOT 3
- CI workflow doesn't use flake8 version 5.0.4
- spec: not clear whether VFIO_USER_DMA_WRITE should track dirty pages
- nvmf_vfio_user_prop_req_rsp: failed to map Admin queue HOT 13
- Unclear qemu version recommendation HOT 1
- arch linux CI workflow fails HOT 11
- clean up msg->out.iov in error cases
- consider generating graphs for migration transitions HOT 2
- initial migration state not specified HOT 2
- support for vIOMMU with mmap() HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libvfio-user.