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.14 29/41] irqchip/gic-v3-its: Ensure nr_ites >= nr_lpis
Date: Mon, 19 Mar 2018 19:08:29 +0100	[thread overview]
Message-ID: <20180319180734.138841577@linuxfoundation.org> (raw)
In-Reply-To: <20180319180732.195217948@linuxfoundation.org>

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

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

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

commit 4f2c7583e33eb08dc09dd2e25574b80175ba7d93 upstream.

When struct its_device instances are created, the nr_ites member
will be set to a power of 2 that equals or exceeds the requested
number of MSIs passed to the msi_prepare() callback. At the same
time, the LPI map is allocated to be some multiple of 32 in size,
where the allocated size may be less than the requested size
depending on whether a contiguous range of sufficient size is
available in the global LPI bitmap.

This may result in the situation where the nr_ites < nr_lpis, and
since nr_ites is what we program into the hardware when we map the
device, the additional LPIs will be non-functional.

For bog standard hardware, this does not really matter. However,
in cases where ITS device IDs are shared between different PCIe
devices, we may end up allocating these additional LPIs without
taking into account that they don't actually work.

So let's make nr_ites at least 32. This ensures that all allocated
LPIs are 'live', and that its_alloc_device_irq() will fail when
attempts are made to allocate MSIs beyond what was allocated in
the first place.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
[maz: updated comment]
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 |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -1310,7 +1310,7 @@ static struct irq_chip its_irq_chip = {
  * This gives us (((1UL << id_bits) - 8192) >> 5) possible allocations.
  */
 #define IRQS_PER_CHUNK_SHIFT	5
-#define IRQS_PER_CHUNK		(1 << IRQS_PER_CHUNK_SHIFT)
+#define IRQS_PER_CHUNK		(1UL << IRQS_PER_CHUNK_SHIFT)
 #define ITS_MAX_LPI_NRBITS	16 /* 64K LPIs */
 
 static unsigned long *lpi_bitmap;
@@ -2026,11 +2026,10 @@ static struct its_device *its_create_dev
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	/*
-	 * At least one bit of EventID is being used, hence a minimum
-	 * of two entries. No, the architecture doesn't let you
-	 * express an ITT with a single entry.
+	 * We allocate at least one chunk worth of LPIs bet device,
+	 * and thus that many ITEs. The device may require less though.
 	 */
-	nr_ites = max(2UL, roundup_pow_of_two(nvecs));
+	nr_ites = max(IRQS_PER_CHUNK, roundup_pow_of_two(nvecs));
 	sz = nr_ites * its->ite_size;
 	sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1;
 	itt = kzalloc(sz, GFP_KERNEL);

  parent reply	other threads:[~2018-03-19 18:31 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-19 18:08 [PATCH 4.14 00/41] 4.14.29-stable review Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 01/41] x86/cpufeatures: Add Intel Total Memory Encryption cpufeature Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 02/41] x86/cpufeatures: Add Intel PCONFIG cpufeature Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 03/41] selftests/x86/entry_from_vm86: Exit with 1 if we fail Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 04/41] selftests/x86: Add tests for User-Mode Instruction Prevention Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 05/41] selftests/x86: Add tests for the STR and SLDT instructions Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 06/41] selftests/x86/entry_from_vm86: Add test cases for POPF Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 07/41] x86/vm86/32: Fix POPF emulation Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 08/41] x86/speculation, objtool: Annotate indirect calls/jumps for objtool on 32-bit kernels Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 09/41] x86/speculation: Remove Skylake C2 from Speculation Control microcode blacklist Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 10/41] KVM: x86: Fix device passthrough when SME is active Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 11/41] x86/mm: Fix vmalloc_fault to use pXd_large Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 13/41] ALSA: pcm: Fix UAF in snd_pcm_oss_get_formats() Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 14/41] ALSA: hda - Revert power_save option default value Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 15/41] ALSA: seq: Fix possible UAF in snd_seq_check_queue() Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 16/41] ALSA: seq: Clear client entry before deleting else at closing Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 17/41] drm/nouveau/bl: Fix oops on driver unbind Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 21/41] fs: Teach path_connected to handle nfs filesystems with multiple roots Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 22/41] KVM: arm/arm64: Reduce verbosity of KVM init log Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 23/41] kvm: arm/arm64: vgic-v3: Tighten synchronization for guests using v2 on v3 Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 24/41] KVM: arm/arm64: vgic: Dont populate multiple LRs with the same vintid Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 25/41] lock_parent() needs to recheck if dentry got __dentry_killed under it Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 26/41] fs/aio: Add explicit RCU grace period when freeing kioctx Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 27/41] fs/aio: Use RCU accessors for kioctx_table->table[] Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 28/41] RDMAVT: Fix synchronization around percpu_ref Greg Kroah-Hartman
2018-03-19 18:08 ` Greg Kroah-Hartman [this message]
2018-03-19 18:08 ` [PATCH 4.14 31/41] btrfs: add missing initialization in btrfs_check_shared Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 32/41] btrfs: alloc_chunk: fix DUP stripe size handling Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 33/41] btrfs: Fix use-after-free when cleaning up fs_devs with a single stale device Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 34/41] btrfs: remove spurious WARN_ON(ref->count < 0) in find_parent_nodes Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 35/41] btrfs: Fix memory barriers usage with device stats counters Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 36/41] scsi: qla2xxx: Fix smatch warning in qla25xx_delete_{rsp|req}_que Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 37/41] scsi: qla2xxx: Fix NULL pointer access for fcport structure Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 38/41] scsi: qla2xxx: Fix logo flag for qlt_free_session_done() Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 39/41] scsi: qla2xxx: Fix crashes in qla2x00_probe_one on probe failure Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 40/41] USB: gadget: udc: Add missing platform_device_put() on error in bdc_pci_probe() Greg Kroah-Hartman
2018-03-19 18:08 ` [PATCH 4.14 41/41] usb: dwc3: Fix GDBGFIFOSPACE_TYPE values Greg Kroah-Hartman
2018-03-20  7:01 ` [PATCH 4.14 00/41] 4.14.29-stable review Naresh Kamboju
2018-03-20 16:10 ` Guenter Roeck
2018-03-20 16:31 ` 王金浦
2018-03-21 11:08   ` Greg Kroah-Hartman
2018-03-20 20:12 ` Shuah Khan

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=20180319180734.138841577@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).