On 06/17/2014 03:36 PM, Paolo Bonzini wrote: > Il 17/06/2014 06:59, Benjamin Herrenschmidt ha scritto: >> Thanks. I've tried the other approach of adding new functions which >> means no overhead (hopefully) for the non-swap case and less invasive >> changes to vga_template.c. >> >> Patch below. What do you think ? This or the previous approach ? Then we >> can discuss how we actually trigger the endian change and where we store >> the state :-) > > This is definitely more readable. Anyway Gerd is the VGA guy. :)
I am that lucky person who got to do endianness-on-fly-switching QOM'fication :) We have 2 ways of doing this: 1. implement a VGA register in QEMU and use it from the guest; there is a try to discuss it in "[Qemu-devel] Endian control register"; requires guest changes; 2. on SPAPR we have H_SET_MODE hypercall which guest uses when it switches endianness and current hack is to change the flag directly in VGA device from this hypercall handler. Instead of that hack, we could have added a device callback: void DeviceClass::endianness_notify(DeviceState *dev, enum device_endian endianness); or even an Interface (with the same method alone). And in H_SET_MODE we could walk through all devices in the system and poke ones which implement a callback or an interface. virtio could benefit from this as well. Ideas? -- Alexey