From 22e908e8014cda9a02af72ae11278d2bd7ae94a6 Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Mon, 27 Jun 2016 14:38:43 +0200 Subject: [PATCH] vbox: add config option to enforce use of IOAPIC The virtual PCI model delivers IRQs to the PIC by default and to the IOAPIC only if the guest operating system selected the IOAPIC with the '_PIC' ACPI method and if it called the '_PRT' ACPI method afterwards. When running a guest operating system which uses the IOAPIC, but does not call these ACPI methods (for example Genode/NOVA), the new configuration option enforces the delivery of PCI IRQs to the IOAPIC. Fixes #2029 --- repos/ports/ports/virtualbox.hash | 2 +- repos/ports/src/virtualbox/README | 14 +++++++++++ repos/ports/src/virtualbox/devices.cc | 23 ++++++++++++++++++ .../src/virtualbox/patches/force_ioapic.patch | 24 +++++++++++++++++++ repos/ports/src/virtualbox/patches/series | 1 + 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 repos/ports/src/virtualbox/patches/force_ioapic.patch diff --git a/repos/ports/ports/virtualbox.hash b/repos/ports/ports/virtualbox.hash index 6f9c7b3b86..82d95f74d8 100644 --- a/repos/ports/ports/virtualbox.hash +++ b/repos/ports/ports/virtualbox.hash @@ -1 +1 @@ -780be1d09ef36e1c287721473830c327cf2276a4 +2ee908cb3d7d8e0189158b7b0b55bda5ba406654 diff --git a/repos/ports/src/virtualbox/README b/repos/ports/src/virtualbox/README index ab3949e55f..7ec2f238a3 100644 --- a/repos/ports/src/virtualbox/README +++ b/repos/ports/src/virtualbox/README @@ -8,3 +8,17 @@ The virtual XHCI controller can be enabled with the following configuration option: + +IOAPIC +====== + +The virtual PCI model delivers IRQs to the PIC by default and to the IOAPIC +only if the guest operating system selected the IOAPIC with the '_PIC' ACPI +method and if it called the '_PRT' ACPI method afterwards. When running a +guest operating system which uses the IOAPIC, but does not call these ACPI +methods (for example Genode/NOVA), the configuration option + + + +enforces the delivery of PCI IRQs to the IOAPIC. + diff --git a/repos/ports/src/virtualbox/devices.cc b/repos/ports/src/virtualbox/devices.cc index ba6af53d30..6c81db1bfb 100644 --- a/repos/ports/src/virtualbox/devices.cc +++ b/repos/ports/src/virtualbox/devices.cc @@ -13,6 +13,7 @@ /* Genode includes */ #include +#include /* VirtualBox includes */ #include @@ -62,3 +63,25 @@ extern "C" int VBoxDevicesRegister(PPDMDEVREGCB pCallbacks, uint32_t u32Version) return VINF_SUCCESS; } + +/* + * The virtual PCI model delivers IRQs to the PIC by default and to the IOAPIC + * only if the guest operating system selected the IOAPIC with the '_PIC' ACPI + * method and if it called the '_PRT' ACPI method afterwards. When running a + * guest operating system which uses the IOAPIC, but does not call these ACPI + * methods (for example Genode/NOVA), IRQ delivery to the IOAPIC can be + * enforced with the 'force_ioapic' configuration option. + * + * References: + * - 'pciSetIrqInternal()' in DevPCI.cpp + * - '_PIC' and '_PRT' ACPI methods in vbox.dsl + */ +bool force_ioapic() +{ + try { + Genode::Attached_rom_dataspace config("config"); + return config.xml().attribute_value("force_ioapic", false); + } catch (Genode::Rom_connection::Rom_connection_failed) { + return false; + } +} diff --git a/repos/ports/src/virtualbox/patches/force_ioapic.patch b/repos/ports/src/virtualbox/patches/force_ioapic.patch new file mode 100644 index 0000000000..587b2a0541 --- /dev/null +++ b/repos/ports/src/virtualbox/patches/force_ioapic.patch @@ -0,0 +1,24 @@ +Deliver PCI IRQs to the IOAPIC if the 'force_ioapic' configuration option is set. + +From: Christian Prochaska + +Issue #2029 +--- + src/app/virtualbox/src/VBox/Devices/Bus/DevPCI.cpp | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/app/virtualbox/src/VBox/Devices/Bus/DevPCI.cpp b/src/app/virtualbox/src/VBox/Devices/Bus/DevPCI.cpp +index c454d8b..35061d5 100644 +--- a/src/app/virtualbox/src/VBox/Devices/Bus/DevPCI.cpp ++++ b/src/app/virtualbox/src/VBox/Devices/Bus/DevPCI.cpp +@@ -663,7 +663,9 @@ static void pciSetIrqInternal(PPCIGLOBALS pGlobals, uint8_t uDevFn, PPCIDEVICE p + * is opened to route PCI interrupts directly to the I/O APIC and bypass the PIC. + * See the \_SB_.PCI0._PRT method in vbox.dsl. + */ +- const bool fIsApicEnabled = pGlobals->fUseIoApic && pbCfg[0xde] == 0xbe && pbCfg[0xad] == 0xef; ++ extern bool force_ioapic(); ++ const bool fIsApicEnabled = pGlobals->fUseIoApic && ++ (force_ioapic() || (pbCfg[0xde] == 0xbe && pbCfg[0xad] == 0xef)); + int pic_irq, pic_level; + + /* Check if the state changed. */ diff --git a/repos/ports/src/virtualbox/patches/series b/repos/ports/src/virtualbox/patches/series index 97e706a171..601556490d 100644 --- a/repos/ports/src/virtualbox/patches/series +++ b/repos/ports/src/virtualbox/patches/series @@ -25,3 +25,4 @@ posix.patch hostservice.patch vbox_dd.patch ide.patch +force_ioapic.patch