|
From: | Philippe Mathieu-Daudé |
Subject: | Re: [PATCH 4/4] hw/pci: Ensure pci_add_capability() is called before device is realized |
Date: | Wed, 22 Mar 2023 09:52:11 +0100 |
User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 |
On 22/3/23 03:18, Michael S. Tsirkin wrote:
On Tue, Mar 14, 2023 at 12:14:35PM +0100, Philippe Mathieu-Daudé wrote:PCI capabilities can't appear magically at runtime. Guests aren't expecting that. Assert all capabilities are added _before_ a device instance is realized. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- hw/pci/pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index ac41fcbf6a..ed60b352e4 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2397,7 +2397,7 @@ static void pci_del_option_rom(PCIDevice *pdev) * On success, pci_add_capability() returns a positive value * that the offset of the pci capability. * On failure, it sets an error and returns a negative error - * code. + * code. @pdev must be unrealized. */ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t offset, uint8_t size, @@ -2406,6 +2406,8 @@ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t *config; int i, overlapping_cap;+ assert(!DEVICE(pdev)->realized);+ if (!offset) { offset = pci_find_space(pdev, size); /* out of PCI config space is programming error */Fails in CI: https://gitlab.com/mstredhat/qemu/-/jobs/3976974199 qemu-system-i386: ../hw/pci/pci.c:2409: pci_add_capability: Assertion `!DEVICE(pdev)->realized' failed. Broken pipe ../tests/qtest/libqtest.c:193: kill_qemu() detected QEMU death from signal 6 (Aborted) (core dumped) TAP parsing error: Too few tests run (expected 49, got 40) (test program exited with status code -6)
Thanks for testing! Likely the AMD-Vi device, see on the cover this series is Based-on: <20230313153031.86107-1-philmd@linaro.org> "hw/i386/amd_iommu: Orphanize & QDev cleanups" 20230313153031.86107-1-philmd@linaro.org/">https://lore.kernel.org/qemu-devel/20230313153031.86107-1-philmd@linaro.org/
[Prev in Thread] | Current Thread | [Next in Thread] |