stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Marc Zyngier <marc.zyngier@arm.com>
Subject: [PATCH 4.20 086/117] irqchip/gic-v3-its: Align PCI Multi-MSI allocation on their size
Date: Tue, 29 Jan 2019 12:35:37 +0100	[thread overview]
Message-ID: <20190129113211.709063543@linuxfoundation.org> (raw)
In-Reply-To: <20190129113207.477505932@linuxfoundation.org>

4.20-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Marc Zyngier <marc.zyngier@arm.com>

commit 8208d1708b88b412ca97f50a6d951242c88cbbac upstream.

The way we allocate events works fine in most cases, except
when multiple PCI devices share an ITS-visible DevID, and that
one of them is trying to use MultiMSI allocation.

In that case, our allocation is not guaranteed to be zero-based
anymore, and we have to make sure we allocate it on a boundary
that is compatible with the PCI Multi-MSI constraints.

Fix this by allocating the full region upfront instead of iterating
over the number of MSIs. MSI-X are always allocated one by one,
so this shouldn't change anything on that front.

Fixes: b48ac83d6bbc2 ("irqchip: GICv3: ITS: MSI support")
Cc: stable@vger.kernel.org
Reported-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/irqchip/irq-gic-v3-its.c |   25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -2399,13 +2399,14 @@ static void its_free_device(struct its_d
 	kfree(its_dev);
 }
 
-static int its_alloc_device_irq(struct its_device *dev, irq_hw_number_t *hwirq)
+static int its_alloc_device_irq(struct its_device *dev, int nvecs, irq_hw_number_t *hwirq)
 {
 	int idx;
 
-	idx = find_first_zero_bit(dev->event_map.lpi_map,
-				  dev->event_map.nr_lpis);
-	if (idx == dev->event_map.nr_lpis)
+	idx = bitmap_find_free_region(dev->event_map.lpi_map,
+				      dev->event_map.nr_lpis,
+				      get_count_order(nvecs));
+	if (idx < 0)
 		return -ENOSPC;
 
 	*hwirq = dev->event_map.lpi_base + idx;
@@ -2501,21 +2502,21 @@ static int its_irq_domain_alloc(struct i
 	int err;
 	int i;
 
-	for (i = 0; i < nr_irqs; i++) {
-		err = its_alloc_device_irq(its_dev, &hwirq);
-		if (err)
-			return err;
+	err = its_alloc_device_irq(its_dev, nr_irqs, &hwirq);
+	if (err)
+		return err;
 
-		err = its_irq_gic_domain_alloc(domain, virq + i, hwirq);
+	for (i = 0; i < nr_irqs; i++) {
+		err = its_irq_gic_domain_alloc(domain, virq + i, hwirq + i);
 		if (err)
 			return err;
 
 		irq_domain_set_hwirq_and_chip(domain, virq + i,
-					      hwirq, &its_irq_chip, its_dev);
+					      hwirq + i, &its_irq_chip, its_dev);
 		irqd_set_single_target(irq_desc_get_irq_data(irq_to_desc(virq + i)));
 		pr_debug("ID:%d pID:%d vID:%d\n",
-			 (int)(hwirq - its_dev->event_map.lpi_base),
-			 (int) hwirq, virq + i);
+			 (int)(hwirq + i - its_dev->event_map.lpi_base),
+			 (int)(hwirq + i), virq + i);
 	}
 
 	return 0;



  parent reply	other threads:[~2019-01-29 12:07 UTC|newest]

Thread overview: 124+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29 11:34 [PATCH 4.20 000/117] 4.20.6-stable review Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 001/117] amd-xgbe: Fix mdio access for non-zero ports and clause 45 PHYs Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 002/117] net: bridge: Fix ethernet header pointer before check skb forwardable Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 003/117] net: Fix usage of pskb_trim_rcsum Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 004/117] net: phy: marvell: Errata for mv88e6390 internal PHYs Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 005/117] net: phy: mdio_bus: add missing device_del() in mdiobus_register() error handling Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 006/117] net: phy: phy driver features are mandatory Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 007/117] net/sched: act_tunnel_key: fix memory leak in case of action replace Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 008/117] net_sched: refetch skb protocol for each filter Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 009/117] openvswitch: Avoid OOB read when parsing flow nlattrs Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 010/117] vhost: log dirty page correctly Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 011/117] mlxsw: pci: Increase PCI SW reset timeout Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 012/117] net: ipv4: Fix memory leak in network namespace dismantle Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 013/117] mlxsw: spectrum_fid: Update dummy FID index Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 014/117] mlxsw: pci: Ring CQs doorbell before RDQs Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 015/117] net/sched: cls_flower: allocate mask dynamically in fl_change() Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 016/117] udp: with udp_segment release on error path Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 017/117] ip6_gre: fix tunnel list corruption for x-netns Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 018/117] erspan: build the header with the right proto according to erspan_ver Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 019/117] net: phy: marvell: Fix deadlock from wrong locking Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 020/117] ip6_gre: update version related info when changing link Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 021/117] tcp: allow MSG_ZEROCOPY transmission also in CLOSE_WAIT state Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 022/117] ARM: fix the cockup in the previous patch Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 023/117] SUNRPC: Address Kerberos performance/behavior regression Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 024/117] mei: me: mark LBG devices as having dma support Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 025/117] mei: me: add denverton innovation engine device IDs Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 026/117] USB: leds: fix regression in usbport led trigger Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 027/117] USB: EHCI: ehci-mv: add MODULE_DEVICE_TABLE Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 028/117] USB: serial: ftdi_sio: fix GPIO not working in autosuspend Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 029/117] USB: serial: simple: add Motorola Tetra TPG2200 device id Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 030/117] USB: serial: pl2303: add new PID to support PL2303TB Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 031/117] ceph: clear inode pointer when snap realm gets dropped by its inode Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 032/117] ASoC: atom: fix a missing check of snd_pcm_lib_malloc_pages Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 033/117] ASoC: rt5514-spi: Fix potential NULL pointer dereference Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 034/117] ASoC: tlv320aic32x4: Kernel OOPS while entering DAPM standby mode Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 035/117] clk: zynqmp: Fix memory allocation in zynqmp_clk_setup Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 036/117] clk: socfpga: stratix10: fix rate calculation for pll clocks Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 037/117] clk: socfpga: stratix10: fix naming convention for the fixed-clocks Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 038/117] inotify: Fix fd refcount leak in inotify_add_watch() Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 039/117] ALSA: hda/realtek - Fix typo for ALC225 model Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 040/117] ALSA: hda - Add mute LED support for HP ProBook 470 G5 Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 041/117] ARCv2: lib: memeset: fix doing prefetchw outside of buffer Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 042/117] ARC: adjust memblock_reserve of kernel memory Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 043/117] ARC: perf: map generic branches to correct hardware condition Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 044/117] s390/vdso: correct vdso mapping for compat tasks Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 045/117] s390/mm: always force a load of the primary ASCE on context switch Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 046/117] s390/early: improve machine detection Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 047/117] s390/smp: fix CPU hotplug deadlock with CPU rescan Greg Kroah-Hartman
2019-01-29 11:34 ` [PATCH 4.20 048/117] s390/smp: Fix calling smp_call_ipl_cpu() from ipl CPU Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 049/117] misc: ibmvsm: Fix potential NULL pointer dereference Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 050/117] char/mwave: fix potential Spectre v1 vulnerability Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 051/117] mmc: sdhci-iproc: handle mmc_of_parse() errors during probe Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 052/117] mmc: dw_mmc-bluefield: : Fix the license information Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 053/117] mmc: meson-gx: Free irq in release() callback Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 054/117] staging: rtl8188eu: Add device code for D-Link DWA-121 rev B1 Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 055/117] tty: Handle problem if line discipline does not have receive_buf Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 056/117] uart: Fix crash in uart_write and uart_put_char Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 057/117] tty/n_hdlc: fix __might_sleep warning Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 058/117] hv_balloon: avoid touching uninitialized struct page during tail onlining Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 059/117] Drivers: hv: vmbus: Check for ring when getting debug info Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 060/117] vgacon: unconfuse vc_origin when using soft scrollback Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 061/117] CIFS: Fix possible hang during async MTU reads and writes Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 062/117] CIFS: Fix credits calculations for reads with errors Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 063/117] CIFS: Fix credit calculation for encrypted " Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 064/117] CIFS: Do not reconnect TCP session in add_credits() Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 065/117] smb3: add credits we receive from oplock/break PDUs Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 066/117] Input: xpad - add support for SteelSeries Stratus Duo Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 067/117] Input: input_event - provide override for sparc64 Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 068/117] Input: uinput - fix undefined behavior in uinput_validate_absinfo() Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 069/117] acpi/nfit: Block function zero DSMs Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 070/117] acpi/nfit: Fix command-supported detection Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 071/117] scsi: ufs: Use explicit access size in ufshcd_dump_regs Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 072/117] dm thin: fix passdown_double_checking_shared_status() Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 073/117] dm crypt: fix parsing of extended IV arguments Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 074/117] drm/amdgpu: Add APTX quirk for Lenovo laptop Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 075/117] EDAC, altera: Fix S10 persistent register offset Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 076/117] KVM: x86: Fix single-step debugging Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 077/117] KVM: x86: Fix PV IPIs for 32-bit KVM host Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 078/117] KVM: x86: WARN_ONCE if sending a PV IPI returns a fatal error Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 079/117] kvm: x86/vmx: Use kzalloc for cached_vmcs12 Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 080/117] x86/pkeys: Properly copy pkey state at fork() Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 081/117] x86/selftests/pkeys: Fork() to check for state being preserved Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 082/117] x86/kaslr: Fix incorrect i8254 outb() parameters Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 083/117] x86/entry/64/compat: Fix stack switching for XEN PV Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 084/117] posix-cpu-timers: Unbreak timer rearming Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 085/117] net: sun: cassini: Cleanup license conflict Greg Kroah-Hartman
2019-01-29 11:35 ` Greg Kroah-Hartman [this message]
2019-01-29 11:35 ` [PATCH 4.20 087/117] can: dev: __can_get_echo_skb(): fix bogous check for non-existing skb by removing it Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 088/117] can: bcm: check timer values before ktime conversion Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 089/117] can: flexcan: fix NULL pointer exception during bringup Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 090/117] vt: make vt_console_print() compatible with the unicode screen buffer Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 091/117] vt: always call notifier with the console lock held Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 092/117] vt: invoke notifier on screen size change Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 093/117] drm/meson: Fix atomic mode switching regression Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 094/117] bpf: move {prev_,}insn_idx into verifier env Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 095/117] bpf: move tmp variable into ax register in interpreter Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 096/117] nvmet-rdma: Add unlikely for response allocated check Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 097/117] nvmet-rdma: fix null dereference under heavy load Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 098/117] bpf: enable access to ax register also from verifier rewrite Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 099/117] bpf: restrict map value pointer arithmetic for unprivileged Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 100/117] bpf: restrict stack " Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 101/117] bpf: restrict unknown scalars of mixed signed bounds " Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 102/117] bpf: fix check_map_access smin_value test when pointer contains offset Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 103/117] bpf: prevent out of bounds speculation on pointer arithmetic Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 104/117] bpf: fix sanitation of alu op with pointer / scalar type from different paths Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 105/117] bpf: fix inner map masking to prevent oob under speculation Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 106/117] Drivers: hv: vmbus: Remove the useless API vmbus_get_outgoing_channel() Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 107/117] vmbus: fix subchannel removal Greg Kroah-Hartman
2019-01-29 11:35 ` [PATCH 4.20 108/117] Revert "mm, memory_hotplug: initialize struct pages for the full memory section" Greg Kroah-Hartman
2019-01-29 11:36 ` [PATCH 4.20 109/117] usb: dwc3: gadget: Clear req->needs_extra_trb flag on cleanup Greg Kroah-Hartman
2019-01-29 11:36 ` [PATCH 4.20 110/117] mt76x0: do not overwrite other MT_BBP(AGC, 8) fields Greg Kroah-Hartman
2019-01-29 11:36 ` [PATCH 4.20 111/117] mt76x0: use band parameter for LC calibration Greg Kroah-Hartman
2019-01-29 11:36 ` [PATCH 4.20 112/117] mt76x02: run calibration after scanning Greg Kroah-Hartman
2019-01-29 11:36 ` [PATCH 4.20 113/117] mt76x02: assure we update gain after scan Greg Kroah-Hartman
2019-01-29 11:36 ` [PATCH 4.20 114/117] mt76x0: do not perform MCU calibration for MT7630 Greg Kroah-Hartman
2019-01-29 11:36 ` [PATCH 4.20 115/117] mt76x0: antenna select corrections Greg Kroah-Hartman
2019-01-29 11:36 ` [PATCH 4.20 116/117] mt76x0: phy: unify calibration between mt76x0u and mt76x0e Greg Kroah-Hartman
2019-01-29 11:36 ` [PATCH 4.20 117/117] ide: fix a typo in the settings proc file name Greg Kroah-Hartman
2019-01-30  2:07 ` [PATCH 4.20 000/117] 4.20.6-stable review shuah
2019-01-30  6:49   ` Greg Kroah-Hartman
2019-01-30 13:34 ` Naresh Kamboju
2019-01-31  7:52   ` Greg Kroah-Hartman
2019-01-30 22:14 ` Guenter Roeck
2019-01-31  7:18   ` Greg Kroah-Hartman

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=20190129113211.709063543@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=ard.biesheuvel@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=stable@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).