[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/7] pci: designware: clamp viewport index
From: |
Ben Dooks |
Subject: |
[PATCH 3/7] pci: designware: clamp viewport index |
Date: |
Wed, 13 Jul 2022 17:54:45 +0100 |
The current Linux driver for this assumes it can write the 255 into
this register and then read back the value to work out how many
viewports are supported.
Clamp the value so that the probe works and does not cause memory
corruption as the value is not well clamped elsewhere in the driver.
Signed-off-by: Ben Dooks <ben.dooks@sifive.com>
---
hw/pci-host/designware.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c
index d213d7324c..6403416634 100644
--- a/hw/pci-host/designware.c
+++ b/hw/pci-host/designware.c
@@ -345,6 +345,10 @@ static void designware_pcie_root_config_write(PCIDevice
*d, uint32_t address,
break;
case DESIGNWARE_PCIE_ATU_VIEWPORT:
+ /* clamp this value, linux uses it to calculate the
+ * available number of viewports */
+ if (val >= DESIGNWARE_PCIE_NUM_VIEWPORTS)
+ val = DESIGNWARE_PCIE_NUM_VIEWPORTS-1;
root->atu_viewport = val;
break;
--
2.35.1
- updates for designware pci-host, Ben Dooks, 2022/07/13
- [PATCH 1/7] pci: designware: add 64-bit viewport limit, Ben Dooks, 2022/07/13
- [PATCH 3/7] pci: designware: clamp viewport index,
Ben Dooks <=
- [PATCH 6/7] pci: designware: correct host's class_id, Ben Dooks, 2022/07/13
- [PATCH 7/7] pci: designware: add initial tracing events, Ben Dooks, 2022/07/13
- [PATCH 5/7] pci: designware: move msi to entry 5, Ben Dooks, 2022/07/13
- [PATCH 2/7] pci: designware: fix DESIGNWARE_PCIE_ATU_UPPER_TARGET, Ben Dooks, 2022/07/13
- [PATCH 4/7] pci: designware: ignore new bits in ATU CR1, Ben Dooks, 2022/07/13
- Re: updates for designware pci-host, Ben Dooks, 2022/07/27