[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 22/22] ppc440_pcix: Fix up pci config access
From: |
David Gibson |
Subject: |
[PULL 22/22] ppc440_pcix: Fix up pci config access |
Date: |
Wed, 6 Jan 2021 14:38:16 +1100 |
From: BALATON Zoltan via <qemu-ppc@nongnu.org>
This fixes a long standing issue with MorphOS booting on sam460ex
which turns out to be because of suspicious values written to PCI
config address that apparently works on real machine but caused wrong
access on this device model. This replaces a previous work around for
this with a better fix that makes it work.
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Message-Id:
<6fd215ab2bc5f8d4455cd20ed1a2f059e4415fe5.1609636173.git.balaton@eik.bme.hu>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/ppc/ppc440_pcix.c | 37 ++++++++++++++++++++++---------------
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/hw/ppc/ppc440_pcix.c b/hw/ppc/ppc440_pcix.c
index 7829d3e556..91cbcd0504 100644
--- a/hw/ppc/ppc440_pcix.c
+++ b/hw/ppc/ppc440_pcix.c
@@ -449,28 +449,35 @@ static AddressSpace *ppc440_pcix_set_iommu(PCIBus *b,
void *opaque, int devfn)
return &s->bm_as;
}
-/* The default pci_host_data_{read,write} functions in pci/pci_host.c
- * deny access to registers without bit 31 set but our clients want
- * this to work so we have to override these here */
-static void pci_host_data_write(void *opaque, hwaddr addr,
- uint64_t val, unsigned len)
+/*
+ * Some guests on sam460ex write all kinds of garbage here such as
+ * missing enable bit and low bits set and still expect this to work
+ * (apparently it does on real hardware because these boot there) so
+ * we have to override these ops here and fix it up
+ */
+static void pci_host_config_write(void *opaque, hwaddr addr,
+ uint64_t val, unsigned len)
{
PCIHostState *s = opaque;
- pci_data_write(s->bus, s->config_reg | (addr & 3), val, len);
+
+ if (addr != 0 || len != 4) {
+ return;
+ }
+ s->config_reg = (val & 0xfffffffcULL) | (1UL << 31);
}
-static uint64_t pci_host_data_read(void *opaque,
- hwaddr addr, unsigned len)
+static uint64_t pci_host_config_read(void *opaque, hwaddr addr,
+ unsigned len)
{
PCIHostState *s = opaque;
- uint32_t val;
- val = pci_data_read(s->bus, s->config_reg | (addr & 3), len);
+ uint32_t val = s->config_reg;
+
return val;
}
-const MemoryRegionOps ppc440_pcix_host_data_ops = {
- .read = pci_host_data_read,
- .write = pci_host_data_write,
+const MemoryRegionOps ppc440_pcix_host_conf_ops = {
+ .read = pci_host_config_read,
+ .write = pci_host_config_write,
.endianness = DEVICE_LITTLE_ENDIAN,
};
@@ -497,9 +504,9 @@ static void ppc440_pcix_realize(DeviceState *dev, Error
**errp)
pci_setup_iommu(h->bus, ppc440_pcix_set_iommu, s);
memory_region_init(&s->container, OBJECT(s), "pci-container",
PCI_ALL_SIZE);
- memory_region_init_io(&h->conf_mem, OBJECT(s), &pci_host_conf_le_ops,
+ memory_region_init_io(&h->conf_mem, OBJECT(s), &ppc440_pcix_host_conf_ops,
h, "pci-conf-idx", 4);
- memory_region_init_io(&h->data_mem, OBJECT(s), &ppc440_pcix_host_data_ops,
+ memory_region_init_io(&h->data_mem, OBJECT(s), &pci_host_data_le_ops,
h, "pci-conf-data", 4);
memory_region_init_io(&s->iomem, OBJECT(s), &pci_reg_ops, s,
"pci.reg", PPC440_REG_SIZE);
--
2.29.2
- [PULL 14/22] spapr: Add drc_ prefix to the DRC realize and unrealize functions, (continued)
- [PULL 14/22] spapr: Add drc_ prefix to the DRC realize and unrealize functions, David Gibson, 2021/01/05
- [PULL 15/22] ppc: Fix build with --without-default-devices, David Gibson, 2021/01/05
- [PULL 16/22] ppc: Simplify reverse dependencies of POWERNV and PSERIES on XICS and XIVE, David Gibson, 2021/01/05
- [PULL 07/22] spapr: Fix DR properties of the root node, David Gibson, 2021/01/05
- [PULL 10/22] spapr: Call spapr_drc_reset() for all DRCs at CAS, David Gibson, 2021/01/05
- [PULL 20/22] ppc440_pcix: Improve comment for IRQ mapping, David Gibson, 2021/01/05
- [PULL 19/22] sam460ex: Remove FDT_PPC dependency from KConfig, David Gibson, 2021/01/05
- [PULL 21/22] ppc440_pcix: Fix register write trace event, David Gibson, 2021/01/05
- [PULL 18/22] ppc4xx: Move common dependency on serial to common option, David Gibson, 2021/01/05
- [PULL 17/22] pnv: Fix reverse dependency on PCI express root ports, David Gibson, 2021/01/05
- [PULL 22/22] ppc440_pcix: Fix up pci config access,
David Gibson <=
- Re: [PULL 00/22] ppc-for-6.0 queue 20210106, BALATON Zoltan, 2021/01/06
- Re: [PULL 00/22] ppc-for-6.0 queue 20210106, Peter Maydell, 2021/01/06