Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xen-pciback: Allow setting PCI_MSIX_FLAGS_MASKALL too

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 <marmarek@invisiblethingslab.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Link: https://lore.kernel.org/r/20221114103110.1519413-1-marmarek@invisiblethingslab.com
Signed-off-by: Juergen Gross <jgross@suse.com>

authored by

Marek Marczykowski-Górecki and committed by
Juergen Gross
5e29500e da36a2a7

+6 -3
+6 -3
drivers/xen/xen-pciback/conf_space_capability.c
··· 190 190 }; 191 191 192 192 static struct msi_msix_field_config { 193 - u16 enable_bit; /* bit for enabling MSI/MSI-X */ 194 - unsigned int int_type; /* interrupt type for exclusiveness check */ 193 + u16 enable_bit; /* bit for enabling MSI/MSI-X */ 194 + u16 allowed_bits; /* bits allowed to be changed */ 195 + unsigned int int_type; /* interrupt type for exclusiveness check */ 195 196 } msi_field_config = { 196 197 .enable_bit = PCI_MSI_FLAGS_ENABLE, 198 + .allowed_bits = PCI_MSI_FLAGS_ENABLE, 197 199 .int_type = INTERRUPT_TYPE_MSI, 198 200 }, msix_field_config = { 199 201 .enable_bit = PCI_MSIX_FLAGS_ENABLE, 202 + .allowed_bits = PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL, 200 203 .int_type = INTERRUPT_TYPE_MSIX, 201 204 }; 202 205 ··· 232 229 return 0; 233 230 234 231 if (!dev_data->allow_interrupt_control || 235 - (new_value ^ old_value) & ~field_config->enable_bit) 232 + (new_value ^ old_value) & ~field_config->allowed_bits) 236 233 return PCIBIOS_SET_FAILED; 237 234 238 235 if (new_value & field_config->enable_bit) {