On 10/12/20 11:37 AM, Mark Cave-Ayland wrote:
On 12/10/2020 08:19, Philippe Mathieu-Daudé wrote:

In commit a01d8cadadf we changed the number of IRQs to 4 but
forgot to update the map_irq() function. Do it now.

Fixes: a01d8cadadf ("Fix memory corruption ... in PreP emulation")
Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org>
---
Cc: Jocelyn Mayer <l_ind...@magic.fr>
Cc: Julian Seward <jul...@valgrind.org>
Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org>
---
  hw/pci-host/prep.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c
index 064593d1e52..2224135fedb 100644
--- a/hw/pci-host/prep.c
+++ b/hw/pci-host/prep.c
@@ -195,7 +195,7 @@ static const MemoryRegionOps raven_io_ops = {
static int raven_map_irq(PCIDevice *pci_dev, int irq_num)
  {
-    return (irq_num + (pci_dev->devfn >> 3)) & 1;
+    return (irq_num + (pci_dev->devfn >> 3)) & 3;
  }
static void raven_set_irq(void *opaque, int irq_num, int level)

It feels like this should also have a corresponding change in OpenBIOS for
consistency, even though technically because of the OR on IRQ 15 it doesn't 
really
matter. The relevant part in OpenBIOS can be found here:
https://git.qemu.org/?p=openbios.git;a=blob;f=drivers/pci.c;h=34ae69a907b6312a3a7ab218afe8ba9efded1df7;hb=7f28286f5cb1ca682e3ba0a8706d8884f12bc49e#l2001
and in particular this section:

     /* Use the same "physical" routing as QEMU's raven_map_irq() although
        ultimately all 4 PCI interrupts are ORd to IRQ 15 as indicated
        by the PReP specification */
     props[(*ncells)++] = arch->irqs[((intno - 1) + (addr >> 11)) & 1];

Done:
https://github.com/openbios/openbios/pull/7



ATB,

Mark.


Reply via email to