Set the correct IOAPIC INTIN pin number for pci bus interrupt sources during MP spec table generation (on emulators). Currently, the pin number is set to the interrupt line field in the device's configuration space, which is set to either IRQ 10 or 11 as the boot rom driver expects. This works since qemu maps all ISA compatible PIC IRQs onto IOAPIC pins 0-15, including PIRQs. But it will break if, for some reason, the IRQ is routed to something other than the INTLINE value using, for eg. ACPI _CRS. This patch ensures the pin number is set to the correct value (16-23) that the INTx pin is routed to in APIC mode, in agreement with the ACPI _PRT provided routing.
Tested on a Linux 5.17.2 guest on qemu with the pci=nomsi and acpi=noirq boot parameters to force MP table parsing for interrupt sources.
Signed-off-by: Jay Khandkar jaykhandkar2002@gmail.com --- src/fw/mptable.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/src/fw/mptable.c b/src/fw/mptable.c index 47385cc..3a7b02f 100644 --- a/src/fw/mptable.c +++ b/src/fw/mptable.c @@ -18,6 +18,33 @@ #include "util.h" // MaxCountCPUs #include "x86.h" // cpuid
+/* table to obtain IOAPIC INTIN pin # for a certain pci slot and pin */ + +/* daisy chaining in line with acpi _PRT */ +#define SLOT_GSIE {0x14, 0x15, 0x16, 0x17} +#define SLOT_GSIF {0x15, 0x16, 0x17, 0x14} +#define SLOT_GSIG {0x16, 0x17, 0x14, 0x15} +#define SLOT_GSIH {0x17, 0x14, 0x15, 0x16} +#define SLOT_GSIA {0x10, 0x11, 0x12, 0x13} + +u8 pirq_intin[32][4] = { SLOT_GSIE, SLOT_GSIF, SLOT_GSIG, SLOT_GSIH, + SLOT_GSIE, SLOT_GSIF, SLOT_GSIG, SLOT_GSIH, + SLOT_GSIE, SLOT_GSIF, SLOT_GSIG, SLOT_GSIH, + SLOT_GSIE, SLOT_GSIF, SLOT_GSIG, SLOT_GSIH, + SLOT_GSIE, SLOT_GSIF, SLOT_GSIG, SLOT_GSIH, + SLOT_GSIE, SLOT_GSIF, SLOT_GSIG, SLOT_GSIH, + SLOT_GSIE, + + /* INTA -> PIRQA for slot 25 - 31, but 30 + see the default value of D<N>IR */ + SLOT_GSIA, SLOT_GSIA, SLOT_GSIA, SLOT_GSIA, + SLOT_GSIA, + + /* PCIe->PCI bridge. use PIRQ[E-H] */ + SLOT_GSIE, + + SLOT_GSIA }; + void mptable_setup(void) { @@ -114,7 +141,6 @@ mptable_setup(void) if (pci_bdf_to_bus(bdf) != 0) break; int pin = pci_config_readb(bdf, PCI_INTERRUPT_PIN); - int irq = pci_config_readb(bdf, PCI_INTERRUPT_LINE); if (pin == 0) continue; if (dev != pci_bdf_to_busdev(bdf)) { @@ -131,7 +157,7 @@ mptable_setup(void) intsrc->srcbus = pci_bdf_to_bus(bdf); /* PCI bus */ intsrc->srcbusirq = (pci_bdf_to_dev(bdf) << 2) | (pin - 1); intsrc->dstapic = ioapic_id; - intsrc->dstirq = irq; + intsrc->dstirq = pirq_intin[pci_bdf_to_dev(bdf)][pin - 1]; intsrc++; }
On Fri, Apr 15, 2022 at 04:33:34PM +0530, Jay Khandkar wrote:
Set the correct IOAPIC INTIN pin number for pci bus interrupt sources during MP spec table generation (on emulators). Currently, the pin number is set to the interrupt line field in the device's configuration space, which is set to either IRQ 10 or 11 as the boot rom driver expects. This works since qemu maps all ISA compatible PIC IRQs onto IOAPIC pins 0-15, including PIRQs. But it will break if, for some reason, the IRQ is routed to something other than the INTLINE value using, for eg. ACPI _CRS. This patch ensures the pin number is set to the correct value (16-23) that the INTx pin is routed to in APIC mode, in agreement with the ACPI _PRT provided routing.
Tested on a Linux 5.17.2 guest on qemu with the pci=nomsi and acpi=noirq boot parameters to force MP table parsing for interrupt sources.
Signed-off-by: Jay Khandkar jaykhandkar2002@gmail.com
src/fw/mptable.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/src/fw/mptable.c b/src/fw/mptable.c index 47385cc..3a7b02f 100644 --- a/src/fw/mptable.c +++ b/src/fw/mptable.c
If you look at the top of that file you'll see the notice:
// DO NOT ADD NEW FEATURES HERE. (See paravirt.c / biostables.c instead.)
The mptable.c file in seabios is no longer modified. If a guest OS needs a different mptable then it will be necessary to extend qemu to pass the desired mptable to seabios (as is done for smbios and acpi).
Cheers, -Kevin
On Fri, Apr 15, 2022 at 11:50:15AM -0400, Kevin O'Connor wrote:
On Fri, Apr 15, 2022 at 04:33:34PM +0530, Jay Khandkar wrote:
Set the correct IOAPIC INTIN pin number for pci bus interrupt sources during MP spec table generation (on emulators). Currently, the pin number is set to the interrupt line field in the device's configuration space, which is set to either IRQ 10 or 11 as the boot rom driver expects. This works since qemu maps all ISA compatible PIC IRQs onto IOAPIC pins 0-15, including PIRQs. But it will break if, for some reason, the IRQ is routed to something other than the INTLINE value using, for eg. ACPI _CRS. This patch ensures the pin number is set to the correct value (16-23) that the INTx pin is routed to in APIC mode, in agreement with the ACPI _PRT provided routing.
Tested on a Linux 5.17.2 guest on qemu with the pci=nomsi and acpi=noirq boot parameters to force MP table parsing for interrupt sources.
Signed-off-by: Jay Khandkar jaykhandkar2002@gmail.com
src/fw/mptable.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/src/fw/mptable.c b/src/fw/mptable.c index 47385cc..3a7b02f 100644 --- a/src/fw/mptable.c +++ b/src/fw/mptable.c
If you look at the top of that file you'll see the notice:
// DO NOT ADD NEW FEATURES HERE. (See paravirt.c / biostables.c instead.)
The mptable.c file in seabios is no longer modified. If a guest OS needs a different mptable then it will be necessary to extend qemu to pass the desired mptable to seabios (as is done for smbios and acpi).
Cheers, -Kevin
Ah, my bad. Thanks! D Ah, my bad. Thanks!
diff --git a/src/fw/mptable.c b/src/fw/mptable.c index 47385cc..3a7b02f 100644 --- a/src/fw/mptable.c +++ b/src/fw/mptable.c
If you look at the top of that file you'll see the notice:
// DO NOT ADD NEW FEATURES HERE. (See paravirt.c / biostables.c instead.)
The mptable.c file in seabios is no longer modified. If a guest OS needs a different mptable then it will be necessary to extend qemu to pass the desired mptable to seabios (as is done for smbios and acpi).
Maybe its time to think about removing this code? Current state of affairs in qemu is:
# qemu-default -M help Supported machines are: [ ... ] pc-i440fx-2.1 Standard PC (i440FX + PIIX, 1996) pc-i440fx-2.0 Standard PC (i440FX + PIIX, 1996) pc-i440fx-1.7 Standard PC (i440FX + PIIX, 1996) (deprecated) pc-i440fx-1.6 Standard PC (i440FX + PIIX, 1996) (deprecated) pc-i440fx-1.5 Standard PC (i440FX + PIIX, 1996) (deprecated) pc-i440fx-1.4 Standard PC (i440FX + PIIX, 1996) (deprecated) [ ... ]
So qemu plans to remove support for machine types 1.7 and older, this will probably happen later this year in the 7.1 or 7.2 release.
qemu added support for passing acpi tables to the firmware in version 1.7, so the compatibility code is only used for machine types 1.6 and older.
So in a year or so the only purpose the compatibility code will serve is confusing people ...
take care, Gerd
On Tue, Apr 19, 2022 at 11:46:59AM +0200, Gerd Hoffmann wrote:
diff --git a/src/fw/mptable.c b/src/fw/mptable.c index 47385cc..3a7b02f 100644 --- a/src/fw/mptable.c +++ b/src/fw/mptable.c
If you look at the top of that file you'll see the notice:
// DO NOT ADD NEW FEATURES HERE. (See paravirt.c / biostables.c instead.)
The mptable.c file in seabios is no longer modified. If a guest OS needs a different mptable then it will be necessary to extend qemu to pass the desired mptable to seabios (as is done for smbios and acpi).
Maybe its time to think about removing this code? Current state of affairs in qemu is:
# qemu-default -M help Supported machines are: [ ... ] pc-i440fx-2.1 Standard PC (i440FX + PIIX, 1996) pc-i440fx-2.0 Standard PC (i440FX + PIIX, 1996) pc-i440fx-1.7 Standard PC (i440FX + PIIX, 1996) (deprecated) pc-i440fx-1.6 Standard PC (i440FX + PIIX, 1996) (deprecated) pc-i440fx-1.5 Standard PC (i440FX + PIIX, 1996) (deprecated) pc-i440fx-1.4 Standard PC (i440FX + PIIX, 1996) (deprecated) [ ... ]
So qemu plans to remove support for machine types 1.7 and older, this will probably happen later this year in the 7.1 or 7.2 release.
qemu added support for passing acpi tables to the firmware in version 1.7, so the compatibility code is only used for machine types 1.6 and older.
So in a year or so the only purpose the compatibility code will serve is confusing people ...
I know qemu produces the acpi and smbios tables. I wasn't aware it will currently pass in the mptable to seabios. (Nor the PIR table.)
I'm okay with removing support from seabios. As a first step we can change the Kconfig defaults to not produce the tables.
-Kevin
On Tue, 19 Apr 2022 09:52:42 -0400 Kevin O'Connor kevin@koconnor.net wrote:
On Tue, Apr 19, 2022 at 11:46:59AM +0200, Gerd Hoffmann wrote:
diff --git a/src/fw/mptable.c b/src/fw/mptable.c index 47385cc..3a7b02f 100644 --- a/src/fw/mptable.c +++ b/src/fw/mptable.c
If you look at the top of that file you'll see the notice:
// DO NOT ADD NEW FEATURES HERE. (See paravirt.c / biostables.c instead.)
The mptable.c file in seabios is no longer modified. If a guest OS needs a different mptable then it will be necessary to extend qemu to pass the desired mptable to seabios (as is done for smbios and acpi).
Maybe its time to think about removing this code? Current state of affairs in qemu is:
# qemu-default -M help Supported machines are: [ ... ] pc-i440fx-2.1 Standard PC (i440FX + PIIX, 1996) pc-i440fx-2.0 Standard PC (i440FX + PIIX, 1996) pc-i440fx-1.7 Standard PC (i440FX + PIIX, 1996) (deprecated) pc-i440fx-1.6 Standard PC (i440FX + PIIX, 1996) (deprecated) pc-i440fx-1.5 Standard PC (i440FX + PIIX, 1996) (deprecated) pc-i440fx-1.4 Standard PC (i440FX + PIIX, 1996) (deprecated) [ ... ]
So qemu plans to remove support for machine types 1.7 and older, this will probably happen later this year in the 7.1 or 7.2 release.
qemu added support for passing acpi tables to the firmware in version 1.7, so the compatibility code is only used for machine types 1.6 and older.
So in a year or so the only purpose the compatibility code will serve is confusing people ...
I know qemu produces the acpi and smbios tables. I wasn't aware it will currently pass in the mptable to seabios. (Nor the PIR table.)
As far as I'm aware QEMU doesn't produce legacy mptable (which was supplemented by ACPI spec in 1996), so guest will have to parse ACPI tales instead (MADT at minimum). I guess whoever plays with some very legacy OS or does it for educational purpose can use old Seabios to do that.
Along with this perhaps we also should prepare to remove code that generates SeaBIOS own version of ACPI tables /MADT/DSDT/SSDT/SRAT/ since QEMU does this task from 1.7 and onward. Old SeaBIOS ACPI code is likely bit-rotted at this point, we do not exercise related code in QEMU tests. That will also allow QEMU to drop quite a bit of legacy ABI/code that it's kept around since this code is still present in SeaBIOS.
I'm okay with removing support from seabios. As a first step we can change the Kconfig defaults to not produce the tables.
-Kevin _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org
Dear Igor, dear Kevin, dear Gerd,
Am 20.04.22 um 11:14 schrieb Igor Mammedov:
On Tue, 19 Apr 2022 09:52:42 -0400 Kevin O'Connor wrote:
On Tue, Apr 19, 2022 at 11:46:59AM +0200, Gerd Hoffmann wrote:
diff --git a/src/fw/mptable.c b/src/fw/mptable.c index 47385cc..3a7b02f 100644 --- a/src/fw/mptable.c +++ b/src/fw/mptable.c
If you look at the top of that file you'll see the notice:
// DO NOT ADD NEW FEATURES HERE. (See paravirt.c / biostables.c instead.)
The mptable.c file in seabios is no longer modified. If a guest OS needs a different mptable then it will be necessary to extend qemu to pass the desired mptable to seabios (as is done for smbios and acpi).
Maybe its time to think about removing this code? Current state of affairs in qemu is:
# qemu-default -M help Supported machines are: [ ... ] pc-i440fx-2.1 Standard PC (i440FX + PIIX, 1996) pc-i440fx-2.0 Standard PC (i440FX + PIIX, 1996) pc-i440fx-1.7 Standard PC (i440FX + PIIX, 1996) (deprecated) pc-i440fx-1.6 Standard PC (i440FX + PIIX, 1996) (deprecated) pc-i440fx-1.5 Standard PC (i440FX + PIIX, 1996) (deprecated) pc-i440fx-1.4 Standard PC (i440FX + PIIX, 1996) (deprecated) [ ... ]
So qemu plans to remove support for machine types 1.7 and older, this will probably happen later this year in the 7.1 or 7.2 release.
qemu added support for passing acpi tables to the firmware in version 1.7, so the compatibility code is only used for machine types 1.6 and older.
So in a year or so the only purpose the compatibility code will serve is confusing people ...
I know qemu produces the acpi and smbios tables. I wasn't aware it will currently pass in the mptable to seabios. (Nor the PIR table.)
As far as I'm aware QEMU doesn't produce legacy mptable (which was supplemented by ACPI spec in 1996), so guest will have to parse ACPI tales instead (MADT at minimum). I guess whoever plays with some very legacy OS or does it for educational purpose can use old Seabios to do that.
Along with this perhaps we also should prepare to remove code that generates SeaBIOS own version of ACPI tables /MADT/DSDT/SSDT/SRAT/ since QEMU does this task from 1.7 and onward. Old SeaBIOS ACPI code is likely bit-rotted at this point, we do not exercise related code in QEMU tests. That will also allow QEMU to drop quite a bit of legacy ABI/code that it's kept around since this code is still present in SeaBIOS.
I'm okay with removing support from seabios. As a first step we can change the Kconfig defaults to not produce the tables.
Please excuse my ignorance, but will it still be possible to run alternative OS projects like KolibriOS [1] in QEMU and coreboot with SeaBIOS payload?
Kind regards,
Paul
On Wed, 20 Apr 2022 13:32:33 +0200 Paul Menzel pmenzel@molgen.mpg.de wrote:
Dear Igor, dear Kevin, dear Gerd,
Am 20.04.22 um 11:14 schrieb Igor Mammedov:
On Tue, 19 Apr 2022 09:52:42 -0400 Kevin O'Connor wrote:
On Tue, Apr 19, 2022 at 11:46:59AM +0200, Gerd Hoffmann wrote:
diff --git a/src/fw/mptable.c b/src/fw/mptable.c index 47385cc..3a7b02f 100644 --- a/src/fw/mptable.c +++ b/src/fw/mptable.c
If you look at the top of that file you'll see the notice:
// DO NOT ADD NEW FEATURES HERE. (See paravirt.c / biostables.c instead.)
The mptable.c file in seabios is no longer modified. If a guest OS needs a different mptable then it will be necessary to extend qemu to pass the desired mptable to seabios (as is done for smbios and acpi).
Maybe its time to think about removing this code? Current state of affairs in qemu is:
# qemu-default -M help Supported machines are: [ ... ] pc-i440fx-2.1 Standard PC (i440FX + PIIX, 1996) pc-i440fx-2.0 Standard PC (i440FX + PIIX, 1996) pc-i440fx-1.7 Standard PC (i440FX + PIIX, 1996) (deprecated) pc-i440fx-1.6 Standard PC (i440FX + PIIX, 1996) (deprecated) pc-i440fx-1.5 Standard PC (i440FX + PIIX, 1996) (deprecated) pc-i440fx-1.4 Standard PC (i440FX + PIIX, 1996) (deprecated) [ ... ]
So qemu plans to remove support for machine types 1.7 and older, this will probably happen later this year in the 7.1 or 7.2 release.
qemu added support for passing acpi tables to the firmware in version 1.7, so the compatibility code is only used for machine types 1.6 and older.
So in a year or so the only purpose the compatibility code will serve is confusing people ...
I know qemu produces the acpi and smbios tables. I wasn't aware it will currently pass in the mptable to seabios. (Nor the PIR table.)
As far as I'm aware QEMU doesn't produce legacy mptable (which was supplemented by ACPI spec in 1996), so guest will have to parse ACPI tales instead (MADT at minimum). I guess whoever plays with some very legacy OS or does it for educational purpose can use old Seabios to do that.
Along with this perhaps we also should prepare to remove code that generates SeaBIOS own version of ACPI tables /MADT/DSDT/SSDT/SRAT/ since QEMU does this task from 1.7 and onward. Old SeaBIOS ACPI code is likely bit-rotted at this point, we do not exercise related code in QEMU tests. That will also allow QEMU to drop quite a bit of legacy ABI/code that it's kept around since this code is still present in SeaBIOS.
I'm okay with removing support from seabios. As a first step we can change the Kconfig defaults to not produce the tables.
Please excuse my ignorance, but will it still be possible to run alternative OS projects like KolibriOS [1] in QEMU and coreboot with SeaBIOS payload?
It boots for me in QEMU with MPTable disabled in config SeaBIOS.
relevant discussion https://lists.gnu.org/archive/html/qemu-devel/2022-01/msg04271.html
gist: legacy tables aren't maintained nor really tested and subject to break without notice, add ACPI support to pet OS if possible (RSTD lookup and parsing MADT is not that difficult and well documented in ACPI spec)
Kind regards,
Paul
Hi,
On 20. 04. 22 15:18, Igor Mammedov wrote:
relevant discussion https://lists.gnu.org/archive/html/qemu-devel/2022-01/msg04271.html
gist: legacy tables aren't maintained nor really tested and subject to break without notice, add ACPI support to pet OS if possible (RSTD lookup and parsing MADT is not that difficult and well documented in ACPI spec)
Well thats true for CPUs, but false for IRQ routing. To get PCI/PCIe routing you need to run ACPI bytecode interpreter to execute _PRT methods in the DSDT. For a toy OS, it means to integrate ACPICA, as no-one will write it from scratch.
Also, some other use cases for MP-Table might be certified software where codebase size matters (and some flexibility of configuration of platform is still allowed).
Thanks, Rudolf