Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3116468ybi; Thu, 18 Jul 2019 21:20:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwE1+IKveUvwBihmePd7aXEA35Z7o4S0Br8nTF//GbyZen6D3VA+Qmso45EqUJhZjbZQZZW X-Received: by 2002:a17:902:1003:: with SMTP id b3mr55188163pla.172.1563510046085; Thu, 18 Jul 2019 21:20:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563510046; cv=none; d=google.com; s=arc-20160816; b=gVmXnbTLUh0z6HiKimVshFfBvgbRUodhsBq7ZGCDGHUTDQWKl5yA2tvMWkzBLrDBtX ZD+9hoN71e3Y7KBuQg5LHaeDr2J7ghUtdHVdWGdgriCFKjDlm7IYLCa28+sFxKwf+O5E jeUouDesO0lUbapKkBMRakpLiXUQ6kkG3eA9TqTBnKF6GRkz9UKygxzorjVQ0fFqJkpx b4RZjOCuYfFvZjZypsiX+6slAbOoAzmGJakQ3LJ2f47elW8ytWo+/yFZEHDBdITVj8n4 9fseJ4LDnhiabx4kfc6C+N9vMtzA6j2o+qVYVomf0rGb/BZ2kefK+sZOhFrx96FlLYZo 0Gcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RvFNaOgQHUgtWenrTSERf6TGdhxpuE2/DbQIDa6tang=; b=VNXPs/9Dx3i8bvMnyd6VP4crx1SGGSUbXlSlRTB+at3t27GgiKppTHS/LcuIvF/Wf4 xAthJec8/zermIfsGcMPIjwl6RyRb4O/HX8PuKzAl6oG5rWfinpTWUkXGTWX+y90tiI2 SHZrw8ZHHHNLR2n2/MPfqUwpF68lmihFGsvenb22zaXY3YTl0VAMdUST2KxXDyaJZziR QVmB+K1XUl5Aio3adlR9xvz7t00gHStK2ASfEn6Z5BhO05cEbyO6vXCeh05lHf8wllgx naK6AeHlyeIOeQruSKBIS14Zoq7xLmdz+UZovt5xt+gCryWSBn3fgaUqqHsU4loP3sZ8 aJlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nPJWQlRD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id br15si371714pjb.43.2019.07.18.21.20.31; Thu, 18 Jul 2019 21:20:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nPJWQlRD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388238AbfGSEMx (ORCPT + 99 others); Fri, 19 Jul 2019 00:12:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:48302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388958AbfGSEMq (ORCPT ); Fri, 19 Jul 2019 00:12:46 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 103B72189D; Fri, 19 Jul 2019 04:12:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563509565; bh=70rOfI1NUMza8q/+UGj7NaQBTt0XEWgZa39z5HZ3bEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nPJWQlRDVA3grWZ1HnK/ywiw8JzYFYaPNJ6DvU8ZA9ZwwTXLTJoDy1tG4kFPDqFfS lNFXfCu5w9X7uFb9PSHr5Y6/6qMNa8QgxkeGUU38U3Rae6Q+/MYp2HVtIVixwSFOlv Zkq6gKIAnjP2TtrzdDT1HOSU8DYLdej7thdmTLkE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oliver O'Halloran , Sachin Sant , Michael Ellerman , Sasha Levin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 4.14 51/60] powerpc/eeh: Handle hugepages in ioremap space Date: Fri, 19 Jul 2019 00:11:00 -0400 Message-Id: <20190719041109.18262-51-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719041109.18262-1-sashal@kernel.org> References: <20190719041109.18262-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oliver O'Halloran [ Upstream commit 33439620680be5225c1b8806579a291e0d761ca0 ] In commit 4a7b06c157a2 ("powerpc/eeh: Handle hugepages in ioremap space") support for using hugepages in the vmalloc and ioremap areas was enabled for radix. Unfortunately this broke EEH MMIO error checking. Detection works by inserting a hook which checks the results of the ioreadXX() set of functions. When a read returns a 0xFFs response we need to check for an error which we do by mapping the (virtual) MMIO address back to a physical address, then mapping physical address to a PCI device via an interval tree. When translating virt -> phys we currently assume the ioremap space is only populated by PAGE_SIZE mappings. If a hugepage mapping is found we emit a WARN_ON(), but otherwise handles the check as though a normal page was found. In pathalogical cases such as copying a buffer containing a lot of 0xFFs from BAR memory this can result in the system not booting because it's too busy printing WARN_ON()s. There's no real reason to assume huge pages can't be present and we're prefectly capable of handling them, so do that. Fixes: 4a7b06c157a2 ("powerpc/eeh: Handle hugepages in ioremap space") Reported-by: Sachin Sant Signed-off-by: Oliver O'Halloran Tested-by: Sachin Sant Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20190710150517.27114-1-oohall@gmail.com Signed-off-by: Sasha Levin --- arch/powerpc/kernel/eeh.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c index 45322b37669a..d2ba7936d0d3 100644 --- a/arch/powerpc/kernel/eeh.c +++ b/arch/powerpc/kernel/eeh.c @@ -361,10 +361,19 @@ static inline unsigned long eeh_token_to_phys(unsigned long token) ptep = find_init_mm_pte(token, &hugepage_shift); if (!ptep) return token; - WARN_ON(hugepage_shift); - pa = pte_pfn(*ptep) << PAGE_SHIFT; - return pa | (token & (PAGE_SIZE-1)); + pa = pte_pfn(*ptep); + + /* On radix we can do hugepage mappings for io, so handle that */ + if (hugepage_shift) { + pa <<= hugepage_shift; + pa |= token & ((1ul << hugepage_shift) - 1); + } else { + pa <<= PAGE_SHIFT; + pa |= token & (PAGE_SIZE - 1); + } + + return pa; } /* -- 2.20.1