mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: alexander.levin@verizon.com
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
	Michael Ellerman <mpe@ellerman.id.au>,
	alexander.levin@verizon.com
Subject: [PATCH AUTOSEL for 4.4 31/32] powerpc/powernv/ioda2: Gracefully fail if too many TCE levels requested
Date: Wed, 29 Nov 2017 17:21:55 +0000	[thread overview]
Message-ID: <20171129172141.28925-31-alexander.levin@verizon.com> (raw)
In-Reply-To: <20171129172141.28925-1-alexander.levin@verizon.com>

From: Alexey Kardashevskiy <aik@ozlabs.ru>

[ Upstream commit 7aafac11e308d37ed3c509829bb43d80c1811ac3 ]

The IODA2 specification says that a 64 DMA address cannot use top 4 bits
(3 are reserved and one is a "TVE select"); bottom page_shift bits
cannot be used for multilevel table addressing either.

The existing IODA2 table allocation code aligns the minimum TCE table
size to PAGE_SIZE so in the case of 64K system pages and 4K IOMMU pages,
we have 64-4-12=48 bits. Since 64K page stores 8192 TCEs, i.e. needs
13 bits, the maximum number of levels is 48/13 = 3 so we physically
cannot address more and EEH happens on DMA accesses.

This adds a check that too many levels were requested.

It is still possible to have 5 levels in the case of 4K system page size.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Acked-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 arch/powerpc/platforms/powernv/pci-ioda.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index e40d0714679e..ecb7f3220355 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -2270,6 +2270,9 @@ static long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset,
 	level_shift = entries_shift + 3;
 	level_shift = max_t(unsigned, level_shift, PAGE_SHIFT);
 
+	if ((level_shift - 3) * levels + page_shift >= 60)
+		return -EINVAL;
+
 	/* Allocate TCE table */
 	addr = pnv_pci_ioda2_table_do_alloc_pages(nid, level_shift,
 			levels, tce_table_size, &offset, &total_allocated);
-- 
2.11.0

  parent reply	other threads:[~2017-11-29 17:27 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-29 17:21 [PATCH AUTOSEL for 4.4 01/32] vti6: Don't report path MTU below IPV6_MIN_MTU alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 02/32] ARM: OMAP2+: gpmc-onenand: propagate error on initialization failure alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 04/32] selftest/powerpc: Fix false failures for skipped tests alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 03/32] x86/hpet: Prevent might sleep splat on resume alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 05/32] module: set __jump_table alignment to 8 alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 08/32] gpio: altera: Use handle_level_irq when configured as a level_high alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 07/32] ARM: OMAP2+: Release device node after it is no longer needed alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 06/32] ARM: OMAP2+: Fix device node reference counts alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 10/32] usb: gadget: configs: plug memory leak alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 09/32] HID: chicony: Add support for another ASUS Zen AiO keyboard alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 11/32] USB: gadgetfs: Fix a potential memory leak in 'dev_config()' alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 12/32] kvm: nVMX: VMCLEAR should not cause the vCPU to shut down alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 16/32] irqchip/crossbar: Fix incorrect type of register size alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 15/32] scsi: lpfc: Fix crash during Hardware error recovery on SLI3 adapters alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 13/32] libata: drop WARN from protocol error in ata_sff_qc_issue() alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 14/32] workqueue: trigger WARN if queue_delayed_work() is called with NULL @wq alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 17/32] KVM: nVMX: reset nested_run_pending if the vCPU is going to be reset alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 20/32] spi_ks8995: fix "BUG: key accdaa28 not in .data!" alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 19/32] arm64: KVM: Survive unknown traps from guests alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 18/32] arm: " alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 21/32] bnx2x: prevent crash when accessing PTP with interface down alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 22/32] bnx2x: fix possible overrun of VFPF multicast addresses array alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 24/32] ipv6: reorder icmpv6_init() and ip6_mr_init() alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 23/32] bnx2x: do not rollback VF MAC/VLAN filters we did not configure alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 26/32] i2c: riic: fix restart condition alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 29/32] axonram: Fix gendisk handling alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 25/32] crypto: s5p-sss - Fix completing crypto request in IRQ handler alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 28/32] netfilter: don't track fragmented packets alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 27/32] zram: set physical queue limits to avoid array out of bounds accesses alexander.levin
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 32/32] EDAC, i5000, i5400: Fix use of MTR_DRAM_WIDTH macro alexander.levin
2017-11-29 17:21 ` alexander.levin [this message]
2017-11-29 17:21 ` [PATCH AUTOSEL for 4.4 30/32] drm/amd/amdgpu: fix console deadlock if late init failed alexander.levin

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=20171129172141.28925-31-alexander.levin@verizon.com \
    --to=alexander.levin@verizon.com \
    --cc=aik@ozlabs.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpe@ellerman.id.au \
    --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

all inboxes | Powered by JetHome®