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

[PATCH v8 10/13] vpci/header: reset the command register when adding devices


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Thu, 20 Jul 2023 00:32:33 +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=nFkYMNZ/YSdMjIjhyT2BLIGgyk/+pe/n0+TIrOCbGnw=; b=dWUqfBegTH1Pmxrns1UUxQnJQYXDvFMhvxQyz1qXY3CDMa1fgzt1yK98MugOZ+FeBLIqlPDq2s6LfdJcKCm6vJwQ5F+U1vouTw6HCsBCRsvi6iFbjOKDVMwBg5vIXMJaiQQIYucCIF9QsPk3acl+Gw0yEIS9LA1G/ckbWDCsh5sPwLqWHNEXqAeguc3253RKi5utUt86T70hS4m1h2VReuw0/F4hiVjaQPkZfPcH7yf31qp10qL3EEN3rlkL4Yl8PYztuoCPNYXfIs8JCiA4ZIgmMIxNHIOn+dVD5gDMoYFA/hLJzN6sYyr9UletxZ4PwZofe8HYk2vCEq2STAl0yQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TmM4Ni51K9+lPW5CTwQ3iRc6+CBnX1wRg4Cz9ZuCUNG0mesjkS7AFqOniuH5vWgKHFGhX8uGBfX6uRxPI+tUq113lzXDIx6o7aGSKNszlYm/7FQyoKSOkDlQkDSnzveGogU1xcA1uyIghyi89x/PmdPrkwUQB/osELWDFNAWnHMNLsyHQSya0eFSPbl9V+aYLvmzVq+snxGL1gjG3cWP7ahMgHEz6XKD190CoLDxrIR4bxoym8OqV0C9L+TztVr1ttOBaGXY8r7hnjJjt0tQMoxcgiTWQ0s/z9IiIQWNs3/bgXo12ioCgH8n23wgBlvOpb0qzI3CQZkt1tIn929IrQ==
  • Cc: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Delivery-date: Thu, 20 Jul 2023 00:32:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZuqGsniCLpx4fUkKP62aGMajP0g==
  • Thread-topic: [PATCH v8 10/13] 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 ae05d242a5..44a9940fb9 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -749,6 +749,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.41.0



 


Rackspace

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