[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v5 06/14] vpci/header: implement guest BAR register handlers
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
- Date: Thu, 3 Feb 2022 13:30:26 +0000
- Accept-language: en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LspjNt9xzAvYju5tsYSAbGYqPXK/3dvEtZAVgtq5KV0=; b=jYQBCNPHtT8/7uA8iG5Z0xhv8TzHq/HzlfJER4Yxw36YYJ2VayhrlKyjBATE2X0yU93xYezTYh6hfwjE6WVEDQKHpSzFtx3wrmPum6XVLPVrwXcJ9W6/kJ8iGxa0XZMaSVJnyJrrCswbS8+srsnKcnsfPWsD3REmKUz3JLj1gpF5laUtlvlSKA1/TWFLolHchInLStk0ARfAvKrY1q55UIqbKN7PFwuE88r5ZrxmwWYVoFKYMzX8fxuHMoxS4FmEPvUczD1LcloiJP6uyJ0Blk2rnj0XWSg18pufEFTMbjKFzcobWWuefeVj26hA5L9ShGaX6ncbHi2vE9RSHujnqg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q6ohaYmc7Ps/AZnEm2qJuGPsCwdZOYFUamjb2TInUjbXVztVMrxzHJUIEUCG+GO0U/JDbOR25lVfgJf1TV0dV5wP9/bdVqwMUzipoc8gSXMHJfH5WfNl//qwL9zcXS1l4rybB4qQ93tU7Mziybs+kQ/SMCBQzVkI1y+FvjEcejYbwrQgKj8SEreg8Ve0XTSl1sZZpDLqg9Jb6+o/6ngYBsd9TYoS7AUrVpBK6RMKN2GyeEEN1llLOe1flz0W1kDx07Ud7KNz+HK9f/Se5xZ5PRgIaJdOVyzh5jvSZpiHwkiCauTxPLlhc4TROFs/dX//2sowJiewKli8ncc2mrNwGw==
- Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>, "andrew.cooper3@xxxxxxxxxx" <andrew.cooper3@xxxxxxxxxx>, "george.dunlap@xxxxxxxxxx" <george.dunlap@xxxxxxxxxx>, "paul@xxxxxxx" <paul@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Delivery-date: Thu, 03 Feb 2022 13:30:55 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHX4ewHyWAyD811HEGp8pIjUuVWNaxf8XWAgB1bfoCABObrAIAAAsYAgAAJ6wA=
- Thread-topic: [PATCH v5 06/14] vpci/header: implement guest BAR register handlers
On 03.02.22 14:54, Jan Beulich wrote:
> On 03.02.2022 13:45, Oleksandr Andrushchenko wrote:
>>>> Also memory decoding needs to be initially disabled when used by
>>>> guests, in order to prevent the BAR being placed on top of a RAM
>>>> region. The guest physmap will be different from the host one, so it's
>>>> possible for BARs to end up placed on top of RAM regions initially
>>>> until the firmware or OS places them at a suitable address.
>>> Agree, memory decoding must be disabled
>> Isn't it already achieved by the toolstack resetting the PCI device
>> while assigning it to a guest?
> Iirc the tool stack would reset a device only after getting it back from
> a DomU. When coming straight from Dom0 or DomIO, no reset would be
> performed. Furthermore, (again iirc) there are cases where there's no
> known (standard) way to reset a device. Assigning such to a guest when
> it previously was owned by another one is risky (and hence needs an
> admin knowing what they're doing), but may be acceptable in particular
> when e.g. simply rebooting a guest.
>
> IOW - I don't think you can rely on the bit being in a particular state.
So, you mean something like:
diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 7695158e6445..9ebd57472da8 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -808,6 +808,14 @@ static int init_bars(struct pci_dev *pdev)
return rc;
}
+ /*
+ * Memory decoding needs to be initially disabled when used by
+ * guests, in order to prevent the BAR being placed on top of a RAM
+ * region.
+ */
+ if ( !is_hwdom )
+ pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd & ~PCI_COMMAND_MEMORY);
+
return (cmd & PCI_COMMAND_MEMORY) ? modify_bars(pdev, cmd, false) : 0;
}
REGISTER_VPCI_INIT(init_bars, VPCI_PRIORITY_MIDDLE);
> Jan
>
Thank you,
Oleksandr
|