[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v7 09/12] vpci/header: reset the command register when adding devices


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Tue, 13 Jun 2023 10:32:29 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; 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=zpFpBBN8bFwrHudq+nmPmlQiloYQd/Hb7VVwCBKtEtE=; b=GC7Iymgspayv3LQlo4XrEF6QQcT0HVcv5ACEcEZNIcC46cpApW5VvjxOX3Lxs9dLl9Av6b+hEfkulZHBkq2ecOlSqVs5CVyDeT98Mcu3oGSSc2HB33v5DxLHujsrmzHV+nMtREbfLiDZsoWwbIH4KKUMb7lH7SmwosfeDrdxgh3lKgTxAHfMYg6zu9sBAgy11SmT+0J6GyzYGFoRWerQBL5jKLxaC67ALr4lHhU0FLCo1bmxkNYfw3JCQrNQVoLH6MkavjmwQNAXkk/ivswOmXtZptLplJtSPd8hm8u6Wv81nyHDnIUBZb7LKBX4B6QNVFCrYa8hKNHdlGANKAVg8w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AgvA5psbN+TuvJGRhDt2W7CS5GkdWCzvP0OkAIV1da5PrXbX/ADzl/+b4A/5Mw0X2jUQGgprsHHicbbX+vqEIwK/76jdawjwZzZjnqTO5ZNLAdDz/w86kkKP+DPjefBdiNK6aEA0LXY3sQgx8UCgCc5OMArLh3Zq7Hv6lfN8tp7t5gP4QbLsc7RPcoNqAU3t6zmUX45wi5zBec9s57xsiqp68ncDCgRqf/MewO54nJq+GV1wmP5fO5AqtiLdRCVbIrGIY0rXIkml9cQ2MmX3/kiqhcnDoF+/bd2sNWlQouLaSJkguOBoFiFHRIrIsKm1NThx6oxo2GEqt4rL1D3DDA==
  • Cc: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 13 Jun 2023 10:33:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZneJaX+tcZrSWoECrBLaG3eDtVg==
  • Thread-topic: [PATCH v7 09/12] vpci/header: reset the command register when adding devices

From: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>

Reset the command register when assigning a PCI device to a guest:
according to the PCI spec the PCI_COMMAND register is typically all 0's
after reset, but this might not be true for the guest as it needs
to respect host's settings.
For that reason, do not write 0 to the PCI_COMMAND register directly,
but go through the corresponding emulation layer (cmd_write), which
will take care about the actual bits written.

Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
---
Since v6:
- use cmd_write directly without introducing emulate_cmd_reg
- update commit message with more description on all 0's in PCI_COMMAND
Since v5:
- updated commit message
Since v1:
 - do not write 0 to the command register, but respect host settings.
---
 xen/drivers/vpci/header.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 677b93226c..1021a61ed6 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -728,6 +728,10 @@ static int cf_check init_bars(struct pci_dev *pdev)
      */
     ASSERT(header->guest_cmd == 0);
 
+    /* Reset the command register for guests. */
+    if ( !is_hwdom )
+        cmd_write(pdev, PCI_COMMAND, 0, header);
+
     /* Setup a handler for the command register. */
     rc = vpci_add_register(pdev->vpci, cmd_read, cmd_write, PCI_COMMAND,
                            2, header);
-- 
2.40.1



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.