Page 1 of 1

Registers of PCI config space seem to be corrupted in Qemu

Posted: Sun Nov 22, 2009 8:18 am
by Armin
Hello,

I don't know if "corrupted" is the proper word but nevertheless I got a curious problem while reading registers of the PCI configuration space in Qemu:
Compared to to what I get when I execute the same code in Bochs, it seems that the register values of PCI config space lack of the last byte when executed in Qemu.

Here is a short example:
In my PCI startup code I enumerate the PCI bus to determine the base/sub class of each PCI device. Therefore I read the register at offset 0x08 of each device (e.g. Host-PCI Bridge or PCI-ISA Bridge) and the content differs like the following:

Host-PCI Bridge
Bochs: I got a value like 0x6010000
Qemu: the value of the register is 0x60100

PCI-ISA Bridge
Bochs: I got a value like 0x6000000
Qemu: the value of the register is 0x60000

In both cases only Bochs provides register values that seem to be reasonably. As written before, when run in Qemu, it seems that the registers lack of one bte.

Does anyone have an idee or know what's the difference between Bochs and Qemu?

Re: Registers of PCI config space seem to be corrupted in Qemu

Posted: Sun Nov 22, 2009 9:23 am
by Combuster
There is no obvious difference in class codes between Bochs and QEmu - in fact in both cases I get correct data returned.

What can matter is how hardware responds to various sized reads - You should always read doublewords and then perform the shifts manually. QEmu is known to differ from real hardware in this respect.

how it should be done

Re: Registers of PCI config space seem to be corrupted in Qemu

Posted: Thu Dec 17, 2009 12:47 pm
by Armin
Thank you very much!

Finally, when I read the link "how it should be done", I saw that I specified the wrong address type (bit 0 and 1) while assembling the pci configuration space address.

Cheers!

Re: Registers of PCI config space seem to be corrupted in Qemu

Posted: Fri Dec 18, 2009 6:31 am
by Combuster
Glad it helped, even after all this time