Skip to content

Commit 3ece3e8

Browse files
committed
PCI/MSI: Handle the NOMASK flag correctly for all PCI/MSI backends
The conversion of the XEN specific global variable pci_msi_ignore_mask to a MSI domain flag, missed the facts that: 1) Legacy architectures do not provide a interrupt domain 2) Parent MSI domains do not necessarily have a domain info attached Both cases result in an unconditional NULL pointer dereference. This was unfortunatly missed in review and testing revealed it late. Cure this by using the existing pci_msi_domain_supports() helper, which handles all possible cases correctly. Fixes: c3164d2 ("PCI/MSI: Convert pci_msi_ignore_mask to per MSI domain flag") Reported-by: Daniel Gomez <[email protected]> Reported-by: Borislav Petkov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Tested-by: Marek Szyprowski <[email protected]> Tested-by: Borislav Petkov <[email protected]> Tested-by: Daniel Gomez <[email protected]> Link: https://lore.kernel.org/all/87iknwyp2o.ffs@tglx Closes: https://lore.kernel.org/all/qn7fzggcj6qe6r6gdbwcz23pzdz2jx64aldccmsuheabhmjgrt@tawf5nfwuvw7
1 parent dce3ab4 commit 3ece3e8

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

drivers/pci/msi/msi.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,6 @@ static void pci_msi_set_enable(struct pci_dev *dev, int enable)
285285
static int msi_setup_msi_desc(struct pci_dev *dev, int nvec,
286286
struct irq_affinity_desc *masks)
287287
{
288-
const struct irq_domain *d = dev_get_msi_domain(&dev->dev);
289-
const struct msi_domain_info *info = d->host_data;
290288
struct msi_desc desc;
291289
u16 control;
292290

@@ -297,7 +295,7 @@ static int msi_setup_msi_desc(struct pci_dev *dev, int nvec,
297295
/* Lies, damned lies, and MSIs */
298296
if (dev->dev_flags & PCI_DEV_FLAGS_HAS_MSI_MASKING)
299297
control |= PCI_MSI_FLAGS_MASKBIT;
300-
if (info->flags & MSI_FLAG_NO_MASK)
298+
if (pci_msi_domain_supports(dev, MSI_FLAG_NO_MASK, DENY_LEGACY))
301299
control &= ~PCI_MSI_FLAGS_MASKBIT;
302300

303301
desc.nvec_used = nvec;
@@ -604,20 +602,18 @@ static void __iomem *msix_map_region(struct pci_dev *dev,
604602
*/
605603
void msix_prepare_msi_desc(struct pci_dev *dev, struct msi_desc *desc)
606604
{
607-
const struct irq_domain *d = dev_get_msi_domain(&dev->dev);
608-
const struct msi_domain_info *info = d->host_data;
609-
610605
desc->nvec_used = 1;
611606
desc->pci.msi_attrib.is_msix = 1;
612607
desc->pci.msi_attrib.is_64 = 1;
613608
desc->pci.msi_attrib.default_irq = dev->irq;
614609
desc->pci.mask_base = dev->msix_base;
615-
desc->pci.msi_attrib.can_mask = !(info->flags & MSI_FLAG_NO_MASK) &&
616-
!desc->pci.msi_attrib.is_virtual;
617610

618-
if (desc->pci.msi_attrib.can_mask) {
611+
612+
if (!pci_msi_domain_supports(dev, MSI_FLAG_NO_MASK, DENY_LEGACY) &&
613+
!desc->pci.msi_attrib.is_virtual) {
619614
void __iomem *addr = pci_msix_desc_addr(desc);
620615

616+
desc->pci.msi_attrib.can_mask = 1;
621617
desc->pci.msix_ctrl = readl(addr + PCI_MSIX_ENTRY_VECTOR_CTRL);
622618
}
623619
}
@@ -715,8 +711,6 @@ static int msix_setup_interrupts(struct pci_dev *dev, struct msix_entry *entries
715711
static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,
716712
int nvec, struct irq_affinity *affd)
717713
{
718-
const struct irq_domain *d = dev_get_msi_domain(&dev->dev);
719-
const struct msi_domain_info *info = d->host_data;
720714
int ret, tsize;
721715
u16 control;
722716

@@ -747,7 +741,7 @@ static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,
747741
/* Disable INTX */
748742
pci_intx_for_msi(dev, 0);
749743

750-
if (!(info->flags & MSI_FLAG_NO_MASK)) {
744+
if (!pci_msi_domain_supports(dev, MSI_FLAG_NO_MASK, DENY_LEGACY)) {
751745
/*
752746
* Ensure that all table entries are masked to prevent
753747
* stale entries from firing in a crash kernel.

0 commit comments

Comments
 (0)