|
| 1 | +From 16ffd72062cf0e3f8ca98051a78235f4ac37c339 Mon Sep 17 00:00:00 2001 |
| 2 | +From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= |
| 3 | + <marmarek@invisiblethingslab.com> |
| 4 | +Date: Mon, 14 Nov 2022 10:55:35 +0100 |
| 5 | +Subject: [PATCH] xen-pciback: Allow setting PCI_MSIX_FLAGS_MASKALL too |
| 6 | +MIME-Version: 1.0 |
| 7 | +Content-Type: text/plain; charset=UTF-8 |
| 8 | +Content-Transfer-Encoding: 8bit |
| 9 | + |
| 10 | +When Xen domain configures MSI-X, the usual approach is to enable MSI-X |
| 11 | +together with masking all of them via the config space, then fill the |
| 12 | +table and only then clear PCI_MSIX_FLAGS_MASKALL. Allow doing this via |
| 13 | +QEMU running in a stub domain. |
| 14 | + |
| 15 | +Previously, when changing PCI_MSIX_FLAGS_MASKALL was not allowed, the |
| 16 | +whole write was aborted, preventing change to the PCI_MSIX_FLAGS_ENABLE |
| 17 | +bit too. |
| 18 | + |
| 19 | +Note the Xen hypervisor intercepts this write anyway, and may keep the |
| 20 | +PCI_MSIX_FLAGS_MASKALL bit set if it wishes to. It will store the |
| 21 | +guest-requested state and will apply it eventually. |
| 22 | + |
| 23 | +Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> |
| 24 | +--- |
| 25 | + drivers/xen/xen-pciback/conf_space_capability.c | 9 ++++++--- |
| 26 | + 1 file changed, 6 insertions(+), 3 deletions(-) |
| 27 | + |
| 28 | +diff --git a/drivers/xen/xen-pciback/conf_space_capability.c b/drivers/xen/xen-pciback/conf_space_capability.c |
| 29 | +index 5e53b4817f16..097316a74126 100644 |
| 30 | +--- a/drivers/xen/xen-pciback/conf_space_capability.c |
| 31 | ++++ b/drivers/xen/xen-pciback/conf_space_capability.c |
| 32 | +@@ -190,13 +190,16 @@ static const struct config_field caplist_pm[] = { |
| 33 | + }; |
| 34 | + |
| 35 | + static struct msi_msix_field_config { |
| 36 | +- u16 enable_bit; /* bit for enabling MSI/MSI-X */ |
| 37 | +- unsigned int int_type; /* interrupt type for exclusiveness check */ |
| 38 | ++ u16 enable_bit; /* bit for enabling MSI/MSI-X */ |
| 39 | ++ u16 allowed_bits; /* bits allowed to be changed */ |
| 40 | ++ unsigned int int_type; /* interrupt type for exclusiveness check */ |
| 41 | + } msi_field_config = { |
| 42 | + .enable_bit = PCI_MSI_FLAGS_ENABLE, |
| 43 | ++ .allowed_bits = PCI_MSI_FLAGS_ENABLE, |
| 44 | + .int_type = INTERRUPT_TYPE_MSI, |
| 45 | + }, msix_field_config = { |
| 46 | + .enable_bit = PCI_MSIX_FLAGS_ENABLE, |
| 47 | ++ .allowed_bits = PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL, |
| 48 | + .int_type = INTERRUPT_TYPE_MSIX, |
| 49 | + }; |
| 50 | + |
| 51 | +@@ -229,7 +232,7 @@ static int msi_msix_flags_write(struct pci_dev *dev, int offset, u16 new_value, |
| 52 | + return 0; |
| 53 | + |
| 54 | + if (!dev_data->allow_interrupt_control || |
| 55 | +- (new_value ^ old_value) & ~field_config->enable_bit) |
| 56 | ++ (new_value ^ old_value) & ~field_config->allowed_bits) |
| 57 | + return PCIBIOS_SET_FAILED; |
| 58 | + |
| 59 | + if (new_value & field_config->enable_bit) { |
| 60 | +-- |
| 61 | +2.37.3 |
| 62 | + |
0 commit comments