From: Oleksandr Andrushchenko <andr2000@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: julien@xen.org, sstabellini@kernel.org,
oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com,
Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com,
bertrand.marquis@arm.com, rahul.singh@arm.com,
Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Subject: [PATCH v2 08/11] vpci/header: Emulate PCI_COMMAND register for guests
Date: Thu, 23 Sep 2021 15:54:58 +0300 [thread overview]
Message-ID: <20210923125501.234252-9-andr2000@gmail.com> (raw)
In-Reply-To: <20210923125501.234252-1-andr2000@gmail.com>
From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Add basic emulation support for guests. At the moment only emulate
PCI_COMMAND_INTX_DISABLE bit, the rest is not emulated yet and left
as TODO.
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
---
New in v2
---
| 35 ++++++++++++++++++++++++++++++++---
1 file changed, 32 insertions(+), 3 deletions(-)
--git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index bdd18599b205..99f9c37dfb00 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -452,6 +452,32 @@ static void cmd_write(const struct pci_dev *pdev, unsigned int reg,
pci_conf_write16(pdev->sbdf, reg, cmd);
}
+static void guest_cmd_write(const struct pci_dev *pdev, unsigned int reg,
+ uint32_t cmd, void *data)
+{
+ /* TODO: Add proper emulation for all bits of the command register. */
+
+ if ( (cmd & PCI_COMMAND_INTX_DISABLE) == 0 )
+ {
+ /*
+ * Guest wants to enable INTx. It can't be enabled if:
+ * - host has INTx disabled
+ * - MSI/MSI-X enabled
+ */
+ if ( pdev->vpci->msi->enabled )
+ cmd |= PCI_COMMAND_INTX_DISABLE;
+ else
+ {
+ uint16_t current_cmd = pci_conf_read16(pdev->sbdf, reg);
+
+ if ( current_cmd & PCI_COMMAND_INTX_DISABLE )
+ cmd |= PCI_COMMAND_INTX_DISABLE;
+ }
+ }
+
+ cmd_write(pdev, reg, cmd, data);
+}
+
static void bar_write(const struct pci_dev *pdev, unsigned int reg,
uint32_t val, void *data)
{
@@ -599,9 +625,12 @@ static int add_bar_handlers(const struct pci_dev *pdev, bool is_hwdom)
struct vpci_bar *bars = header->bars;
int rc;
- /* Setup a handler for the command register: same for hwdom and guests. */
- rc = vpci_add_register(pdev->vpci, vpci_hw_read16, cmd_write, PCI_COMMAND,
- 2, header);
+ if ( is_hwdom )
+ rc = vpci_add_register(pdev->vpci, vpci_hw_read16, cmd_write,
+ PCI_COMMAND, 2, header);
+ else
+ rc = vpci_add_register(pdev->vpci, vpci_hw_read16, guest_cmd_write,
+ PCI_COMMAND, 2, header);
if ( rc )
return rc;
--
2.25.1
next prev parent reply other threads:[~2021-09-23 13:07 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-23 12:54 [PATCH v2 00/11] PCI devices passthrough on Arm, part 3 Oleksandr Andrushchenko
2021-09-23 12:54 ` [PATCH v2 01/11] vpci: Make vpci registers removal a dedicated function Oleksandr Andrushchenko
2021-09-28 11:15 ` Michal Orzel
2021-09-23 12:54 ` [PATCH v2 02/11] vpci: Add hooks for PCI device assign/de-assign Oleksandr Andrushchenko
2021-09-29 9:35 ` Michal Orzel
2021-09-23 12:54 ` [PATCH v2 03/11] vpci/header: Move register assignments from init_bars Oleksandr Andrushchenko
2021-09-23 12:54 ` [PATCH v2 04/11] vpci/header: Add and remove register handlers dynamically Oleksandr Andrushchenko
2021-09-23 12:54 ` [PATCH v2 05/11] vpci/header: Implement guest BAR register handlers Oleksandr Andrushchenko
2021-09-29 9:27 ` Michal Orzel
2021-09-23 12:54 ` [PATCH v2 06/11] vpci/header: Handle p2m range sets per BAR Oleksandr Andrushchenko
2021-09-23 12:54 ` [PATCH v2 07/11] vpci/header: program p2m with guest BAR view Oleksandr Andrushchenko
2021-09-29 8:13 ` Michal Orzel
2021-09-29 8:16 ` Jan Beulich
2021-09-29 8:24 ` Oleksandr Andrushchenko
2021-09-29 8:36 ` Jan Beulich
2021-09-29 8:58 ` Oleksandr Andrushchenko
2021-09-29 8:16 ` Oleksandr Andrushchenko
2021-09-23 12:54 ` Oleksandr Andrushchenko [this message]
2021-09-28 7:34 ` [PATCH v2 08/11] vpci/header: Emulate PCI_COMMAND register for guests Michal Orzel
2021-09-23 12:54 ` [PATCH v2 09/11] vpci/header: Reset the command register when adding devices Oleksandr Andrushchenko
2021-09-28 7:38 ` Michal Orzel
2021-09-23 12:55 ` [PATCH v2 10/11] vpci: Add initial support for virtual PCI bus topology Oleksandr Andrushchenko
2021-09-28 7:48 ` Michal Orzel
2021-09-28 7:59 ` Jan Beulich
2021-09-28 8:17 ` Michal Orzel
2021-09-28 12:58 ` Oleksandr Andrushchenko
2021-09-29 9:03 ` Oleksandr Andrushchenko
2021-09-29 9:09 ` Jan Beulich
2021-09-29 11:56 ` Oleksandr Andrushchenko
2021-09-29 12:54 ` Jan Beulich
2021-09-29 13:16 ` Oleksandr Andrushchenko
2021-09-29 13:23 ` Jan Beulich
2021-09-29 13:49 ` Oleksandr Andrushchenko
2021-09-29 14:07 ` Jan Beulich
2021-09-29 14:16 ` Oleksandr Andrushchenko
2021-09-23 12:55 ` [PATCH v2 11/11] xen/arm: Translate virtual PCI bus topology for guests Oleksandr Andrushchenko
2021-09-27 11:31 ` Jan Beulich
2021-09-27 12:08 ` Oleksandr Andrushchenko
2021-09-27 13:34 ` Jan Beulich
2021-09-27 13:43 ` Oleksandr Andrushchenko
2021-09-27 13:51 ` Jan Beulich
2021-09-27 14:04 ` Oleksandr Andrushchenko
2021-09-27 14:16 ` Jan Beulich
2021-09-27 14:20 ` Oleksandr Andrushchenko
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=20210923125501.234252-9-andr2000@gmail.com \
--to=andr2000@gmail.com \
--cc=Artem_Mygaiev@epam.com \
--cc=bertrand.marquis@arm.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=oleksandr_andrushchenko@epam.com \
--cc=oleksandr_tyshchenko@epam.com \
--cc=rahul.singh@arm.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=volodymyr_babchuk@epam.com \
--cc=xen-devel@lists.xenproject.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.