On 28.11.2010, at 09:12, Gleb Natapov wrote: > On Thu, Nov 25, 2010 at 08:35:41AM +0100, Alexander Graf wrote: >> The way we're currently modeling mmio is too simplified. We assume that >> every device has the same endianness as the target CPU. In reality, >> most devices are little endian (all PCI and ISA ones I'm aware of). Some >> are big endian (special system devices) and a very little fraction is >> target native endian (fw_cfg). >> > As far as I can see fw_cfg calls cpu_to_le() on some of entries and > doesn't on others. Doesn't this makes it "mixed endian" (aka broken)?
There are two layers of brokenness: 1) MMIO 2) Internal structures A device that assumes native target endianness for its own MMIO is usually broken. Devices don't know which CPU they're plugged to (unless built inside of course) :). That specific issue is that fw_cfg_mem_writew directly takes the selector as is and both openbios and seabios expect it to accept values in native endianness. The way forward to fix this is probably to declare the selector as little endian and just commit a new version of openbios. Its internal structures are a different story. If the interface spec of fw_cfg (basically the .c file atm) defines some values to be a different endianness from the other, that might be acceptable. It's still unpretty though. I'd way prefer to see everything aligned to a single endianness. Alex