Skip to content

Commit

Permalink
Allow setting PCI_MSIX_FLAGS_MASKALL too
Browse files Browse the repository at this point in the history
  • Loading branch information
marmarek committed Nov 15, 2022
1 parent f312a98 commit a479945
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
62 changes: 62 additions & 0 deletions 0001-xen-pciback-Allow-setting-PCI_MSIX_FLAGS_MASKALL-too.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
From 16ffd72062cf0e3f8ca98051a78235f4ac37c339 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
<[email protected]>
Date: Mon, 14 Nov 2022 10:55:35 +0100
Subject: [PATCH] xen-pciback: Allow setting PCI_MSIX_FLAGS_MASKALL too
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When Xen domain configures MSI-X, the usual approach is to enable MSI-X
together with masking all of them via the config space, then fill the
table and only then clear PCI_MSIX_FLAGS_MASKALL. Allow doing this via
QEMU running in a stub domain.

Previously, when changing PCI_MSIX_FLAGS_MASKALL was not allowed, the
whole write was aborted, preventing change to the PCI_MSIX_FLAGS_ENABLE
bit too.

Note the Xen hypervisor intercepts this write anyway, and may keep the
PCI_MSIX_FLAGS_MASKALL bit set if it wishes to. It will store the
guest-requested state and will apply it eventually.

Signed-off-by: Marek Marczykowski-Górecki <[email protected]>
---
drivers/xen/xen-pciback/conf_space_capability.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/xen/xen-pciback/conf_space_capability.c b/drivers/xen/xen-pciback/conf_space_capability.c
index 5e53b4817f16..097316a74126 100644
--- a/drivers/xen/xen-pciback/conf_space_capability.c
+++ b/drivers/xen/xen-pciback/conf_space_capability.c
@@ -190,13 +190,16 @@ static const struct config_field caplist_pm[] = {
};

static struct msi_msix_field_config {
- u16 enable_bit; /* bit for enabling MSI/MSI-X */
- unsigned int int_type; /* interrupt type for exclusiveness check */
+ u16 enable_bit; /* bit for enabling MSI/MSI-X */
+ u16 allowed_bits; /* bits allowed to be changed */
+ unsigned int int_type; /* interrupt type for exclusiveness check */
} msi_field_config = {
.enable_bit = PCI_MSI_FLAGS_ENABLE,
+ .allowed_bits = PCI_MSI_FLAGS_ENABLE,
.int_type = INTERRUPT_TYPE_MSI,
}, msix_field_config = {
.enable_bit = PCI_MSIX_FLAGS_ENABLE,
+ .allowed_bits = PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL,
.int_type = INTERRUPT_TYPE_MSIX,
};

@@ -229,7 +232,7 @@ static int msi_msix_flags_write(struct pci_dev *dev, int offset, u16 new_value,
return 0;

if (!dev_data->allow_interrupt_control ||
- (new_value ^ old_value) & ~field_config->enable_bit)
+ (new_value ^ old_value) & ~field_config->allowed_bits)
return PCIBIOS_SET_FAILED;

if (new_value & field_config->enable_bit) {
--
2.37.3

1 change: 1 addition & 0 deletions kernel.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ Patch21: 0001-fb-addr-fix-obtain-upper-32-bits.patch
Patch22: 0001-fb-addr-fix-obtain-full-video-frame-buffer-address.patch
Patch23: increase-reclaim-speed.patch
Patch26: 0001-Re-enable-interrupts-before-loading-PNVM.patch
Patch27: 0001-xen-pciback-Allow-setting-PCI_MSIX_FLAGS_MASKALL-too.patch

%description
Qubes Dom0 kernel.
Expand Down

0 comments on commit a479945

Please sign in to comment.