QEMU MP table

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
8infy
Member
Member
Posts: 188
Joined: Sun Apr 05, 2020 1:01 pm

QEMU MP table

Post by 8infy »

Hi. I'm implementing the MP spec right now (pls don't ask why, just because I wanted to, I will be doing ACPI later)

And I noticed this weirdness in QEMU where ISA iRQs are for some reason coming from the PCI bus. You can see it on this image below.
Image

Why does this happen? Is this normal? In bochs it looks correctly, I only see 1 bus which is ISA and all IRQs are coming from it.

UPD: hmmm, I just checked and there's also ISA irq 4 and 12, mapped 1 : 1, whereas these ones are not. So there's two irq 4 and 12 sources... So what's that about?
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: QEMU MP table

Post by bzt »

Well, ISA bus is not used since PCI was introduced (I mean physically, the motherboards are equivpted with different circuits and slots). To keep compatibility for software, on real machines PCI could emulate many ISA peripherals. This kind of emulation is pretty common on IBM PC, the machines you can buy these days don't have no PS2 controllers, no PIT, no RTC, no PIC either, the original chip's interfaces are emulated for compatibility by newer chips (USB-HID emulates PS2, IOAPIC emulates PIC, HPET emulates PIT/RTC etc.).

About your issue, I'm guessing with bochs you have configured an original IBM PC (therefore it emulates the original ISA bus), while in qemu you're emulating a more modern machine (therefore ISA is emulated within the emulator), specially if you're using KVM. I'm not sure about this, I'm just making a well-educated guess here. From what you have wrote, this could be perfectly normal.

Cheers,
bzt
nullplan
Member
Member
Posts: 1911
Joined: Wed Aug 30, 2017 8:24 am

Re: QEMU MP table

Post by nullplan »

bzt wrote:Well, ISA bus is not used since PCI was introduced (I mean physically, the motherboards are equivpted with different circuits and slots).
That is false. Most chipsets to this day connect their boot ROMs via something called an LPC bus, which is an ISA bus with pin multiplexing. ISA never dies. ISA is eternal!
bzt wrote:This kind of emulation is pretty common on IBM PC, the machines you can buy these days don't have no PS2 controllers, no PIT, no RTC, no PIC either,
No, instead they have a southbridge, containing all of this functionality internally. That's why it is called "Chipset" sometimes, because it simply integrates all of these old designs.
bzt wrote:the original chip's interfaces are emulated for compatibility by newer chips (USB-HID emulates PS2, IOAPIC emulates PIC, HPET emulates PIT/RTC etc.).
Oh god, no. Are you talking about "legacy-free" computers? Those were a brief fad in the late nineties and early naughties. Those actually did what you are describing, but with BIOS/SMM emulation. And if the OS wanted to get at the newer hardware, it had to go through some hoops to tell the firmware to knock it off.

Since then, mainboard manufacturers actually found the silicon necessary to put all the hardware into one chip. The southbridge (aka I/O controller hub, because we have to rename everything every decade to maintain confusion) simply contains all of those peripherals and allows you to talk to them using either interface. For instance, look at this thingy here: https://www.intel.com/content/www/us/en ... sheet.html

Just looking at the table of contents, you can see that this single chip contains an interface like the 8259 PIC, and another like the APIC. There is also PIT and RTC, as well as HPET. It's all in one chip. There is no need to get BIOS to emulate the PIT via HPET, since PIT and HPET are both present. Getting the BIOS to emulate PS/2 via USB, though, might actually still happen, which is why there is a handoff protocol defined in the ?HCI specifications.

This would also explain how ISA IRQs come from a PCI bus, since the southbridge is usually connected to the PCI bus.
Carpe diem!
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: QEMU MP table

Post by bzt »

nullplan wrote:
bzt wrote:Well, ISA bus is not used since PCI was introduced (I mean physically, the motherboards are equivpted with different circuits and slots).
That is false. Most chipsets to this day connect their boot ROMs via something called an LPC bus
Which has absolutely nothing to do with what I've said. I repeat: "I mean physically, the motherboards are equivpted with different circuits and slots". Since you'll never see slots like these on any motherboard manufactured in the last twenty years, means I wasn't wrong nor "false":
Image
nullplan wrote:That's why it is called "Chipset" sometimes, because it simply integrates all of these old designs.
Then please show me a modern "chipset" that has an actual i8259A chip integrated for example. Good luck finding one.
nullplan wrote:Oh god, no. Are you talking about "legacy-free" computers? Those were a brief fad in the late nineties and early naughties. Those actually did what you are describing, but with BIOS/SMM emulation. And if the OS wanted to get at the newer hardware, it had to go through some hoops to tell the firmware to knock it off.
Oh god, yes. All modern computers use USB ports, and they are just emulating the PS2 controller (in this regard doesn't matter where the actual emulation happens, the point is, motherboards don't have PS2 controllers any more, but your software can still use the PS2 IO ports). Likewise, all i8253 chips are emulated via HPET legacy replacement mode, there's no actual PIT chip any more.

This is usually totally transparent to the software up until the point where you want to use the latest features, in which case you must turn off the legacy emulations. For example, if you want to use HPET, then you must disable legacy replacement mode, and after that you can say bye-bye to PIT IO ports. Likewise, if you want to use LAPIC/IOAPIC, then you must turn off legacy PIC emulation (otherwise you'll experience interesting artifacts, if that even works at all).
nullplan wrote:There is no need to get BIOS to emulate the PIT via HPET
That's interesting, I'm curious how could any software (BIOS or not) emulate IO ports and IRQs, especially in real mode. It is more likely they are all emulated in hardware (in your "chipset").
nullplan wrote:Since then, mainboard manufacturers actually found the silicon necessary to put all the hardware into one chip.
And this is relevant for software how? Is this differ to my answer "there's a new hardware which emulates the old interface" in how? You're not helping the OP with this.

Cheers,
bzt
Last edited by bzt on Thu Jul 16, 2020 1:15 pm, edited 1 time in total.
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: QEMU MP table

Post by nexos »

Whether or not the ISA bus is modern PC's is irrelevant to the OP's question. The BIOS configures routing IRQs to the PCI bus, and the chipset preforms some magic to make legacy software and new software work. I don't think that ISA cards are in modern machines, as Intel stated they are removing legacy hardware from their chipsets, How it works is irrelevant to QEMU and Bochs, however. How IRQs are mapped to the IOAPIC is entirely up to the firmware. To see the same in Bochs, use Bochs latest BIOS.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
Octocontrabass
Member
Member
Posts: 5883
Joined: Mon Mar 25, 2013 7:01 pm

Re: QEMU MP table

Post by Octocontrabass »

8infy wrote:UPD: hmmm, I just checked and there's also ISA irq 4 and 12, mapped 1 : 1, whereas these ones are not. So there's two irq 4 and 12 sources... So what's that about?
The "source bus IRQ" in the MP tables has different meanings depending on the bus.

ISA buses have a handful of IRQ lines for the whole bus, and the "source bus IRQ" is just the IRQ line's number.

PCI buses have four IRQ lines per device, and the "source bus IRQ" is a bitfield identifying the device ID (in bits 6-2) and the IRQ line (in bits 1-0). So your PCI "IRQ 4" is bus 0, device 1, INTA, and your PCI "IRQ 12" is bus 0, device 3, INTA.
bzt wrote:That's interesting, I'm curious how could any software (BIOS or not) emulate IO ports and IRQs, especially in real mode. It is more likely they are all emulated in hardware (in your "chipset").
I haven't looked into how IRQs are typically emulated, but I/O ports are emulated with help from the chipset raising SMI whenever the port is accessed.
8infy
Member
Member
Posts: 188
Joined: Sun Apr 05, 2020 1:01 pm

Re: QEMU MP table

Post by 8infy »

Octocontrabass wrote:
8infy wrote:UPD: hmmm, I just checked and there's also ISA irq 4 and 12, mapped 1 : 1, whereas these ones are not. So there's two irq 4 and 12 sources... So what's that about?
The "source bus IRQ" in the MP tables has different meanings depending on the bus.

ISA buses have a handful of IRQ lines for the whole bus, and the "source bus IRQ" is just the IRQ line's number.

PCI buses have four IRQ lines per device, and the "source bus IRQ" is a bitfield identifying the device ID (in bits 6-2) and the IRQ line (in bits 1-0). So your PCI "IRQ 4" is bus 0, device 1, INTA, and your PCI "IRQ 12" is bus 0, device 3, INTA.
bzt wrote:That's interesting, I'm curious how could any software (BIOS or not) emulate IO ports and IRQs, especially in real mode. It is more likely they are all emulated in hardware (in your "chipset").
I haven't looked into how IRQs are typically emulated, but I/O ports are emulated with help from the chipset raising SMI whenever the port is accessed.
Thanks! So both of them are INTA but routed to different ioapic pins? Who takes care of the routing and how is it done? Also where can I read about what each possible bus type means (maybe other busses have things that are different about them too)? I don't think the MP spec talks about it.
Octocontrabass
Member
Member
Posts: 5883
Joined: Mon Mar 25, 2013 7:01 pm

Re: QEMU MP table

Post by Octocontrabass »

8infy wrote:So both of them are INTA but routed to different ioapic pins?
Yes.
8infy wrote:Who takes care of the routing and how is it done?
Most of the routing is fixed in hardware or configured by firmware during boot so you can pretend it's fixed in hardware. All you need to do is switch from legacy IRQ routing to "Symmetric I/O" using the methods described in the MP spec.
8infy wrote:Also where can I read about what each possible bus type means (maybe other busses have things that are different about them too)? I don't think the MP spec talks about it.
Don't worry about those until you see them in MP tables. Other than PCI, they're all obsolete.
Post Reply