From: "Michael S. Tsirkin" <mst@redhat.com>
To: Roman Kagan <rvkagan@yandex-team.ru>
Cc: qemu-devel@nongnu.org,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
yc-core@yandex-team.ru
Subject: Re: [PATCH] hw/pci/pci_bridge: ensure PCIe slots have only one slot
Date: Thu, 7 Jul 2022 01:20:39 -0400 [thread overview]
Message-ID: <20220707011925-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20220704102514.1284827-1-rvkagan@yandex-team.ru>
On Mon, Jul 04, 2022 at 01:25:14PM +0300, Roman Kagan wrote:
> It's possible to create non-working configurations by attaching a device
> to a derivative of PCIe slot (pcie-root-port, ioh3420, etc) and
> specifying a slot number other that zero, e.g.:
>
> -device pcie-root-port,id=s0,... \
> -device virtio-blk-pci,bus=s0,addr=4,...
>
> Make QEMU reject such configurations and only allow addr=0 on the
> secondary bus of a PCIe slot.
>
> Signed-off-by: Roman Kagan <rvkagan@yandex-team.ru>
> ---
> hw/pci/pci_bridge.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c
> index da34c8ebcd..8b38d5ad3d 100644
> --- a/hw/pci/pci_bridge.c
> +++ b/hw/pci/pci_bridge.c
> @@ -33,6 +33,7 @@
> #include "qemu/units.h"
> #include "hw/pci/pci_bridge.h"
> #include "hw/pci/pci_bus.h"
> +#include "hw/pci/pcie_port.h"
> #include "qemu/module.h"
> #include "qemu/range.h"
> #include "qapi/error.h"
> @@ -386,6 +387,10 @@ void pci_bridge_initfn(PCIDevice *dev, const char *typename)
> br->windows = pci_bridge_region_init(br);
> QLIST_INIT(&sec_bus->child);
> QLIST_INSERT_HEAD(&parent->child, sec_bus, sibling);
> +
> + if (PCIE_SLOT(dev)) {
> + sec_bus->slot_reserved_mask = ~1u;
> + }
Please add comments explaining what's going on.
> }
>
> /* default qdev clean up function for PCI-to-PCI bridge */
> --
> 2.36.1
prev parent reply other threads:[~2022-07-07 5:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-04 10:25 [PATCH] hw/pci/pci_bridge: ensure PCIe slots have only one slot Roman Kagan
2022-07-06 18:38 ` Vladimir Sementsov-Ogievskiy
2022-07-06 19:43 ` Roman Kagan
2022-07-07 5:19 ` Michael S. Tsirkin
2022-07-07 8:31 ` Roman Kagan
2022-07-07 5:20 ` Michael S. Tsirkin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220707011925-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=rvkagan@yandex-team.ru \
--cc=yc-core@yandex-team.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).