Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1230327ybi; Fri, 2 Aug 2019 11:34:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzItgRS2xrRq3ftYfg+50Z1sEssmfbShlTBZ/O5Ysf5sbvEVtAfO4RdhlTw8hQ4P/B+R74b X-Received: by 2002:a17:902:82c4:: with SMTP id u4mr132661048plz.196.1564770874775; Fri, 02 Aug 2019 11:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564770874; cv=none; d=google.com; s=arc-20160816; b=Hrg/tPz2PHdhzQZYWnNGaPWfjogX6hBkj4cZ+v6gQFWVPU6ZBLR9s1Lnd5KgGdt6EE Nd+8VOjgwJaheyCxoVbXZBY2zBKILW0+dpeoeDzlr/K1YTipEIdyNOE5yIfJ/q4weK6U CFkOYyiNgaGFCyVpN4c2YOlkBZplrMDaIBFVVdnKuvxggrNfkdOTxXuKKfAZYNGXt9GJ sH2fXQT1LOdvYvkEFOKkj8dzt2rEUjnTQ03oa7JIO3++6CpTXYxdcS5TIX+h/G1ll3gh Xp6TbPr8mgOjC8zMK8S2kTo5m1NKQChlzxBrTxuNDS9kE1CUSUSu+wGFVtDolZzCBgc3 v1OQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5keDvHRlnY9id9ANYhn1c82AW+t0kEC4RrpJgligezA=; b=ZoGG7xUOsStzT4+fBNObu7Y9fl25Rid3/AiOvImjm5UrCN7w9JptN8CvJPTMiZA4Ua 7Lopz4Ch5Yuljw0r+pDDK3Oa5p4IQtzcIwg68+LKCabcpILLGyA372bEPwlBijiyp/zp WvbPC7LkTqjFO0O0Vp6yWcLRCh/ykSQbIS7gd/l3pP1wOOAQURQu9n26fEePf+T8Zjh8 KM9idYKdm0oEt9M0vwl5KK5owRaQy8ioXVRrtQNOxtpJ6YcOFCmIGC+jgcd8BKrUWx4R w8wCz/1zKFOcZFuX1c7hWLxxoJyhWOTquWJv7RWmMZYt4WvQao0L0iOJVOREXAzPbc79 cL5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=L4HcumaP; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l21si18029022pgk.259.2019.08.02.11.33.32; Fri, 02 Aug 2019 11:34:34 -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=L4HcumaP; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405834AbfHBJwS (ORCPT + 99 others); Fri, 2 Aug 2019 05:52:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:57844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391927AbfHBJwR (ORCPT ); Fri, 2 Aug 2019 05:52:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AC4952064A; Fri, 2 Aug 2019 09:52:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564739536; bh=W49HWKwARpa5D/ym3uOo4LYKD8a8lHya8whk1BLO9Ro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L4HcumaPgAmKWTgZeD/YZn+8WrSgqKPiqtVbuwjha6rRi9RBPpD0Smb3aInXF5ZkO +CGraq8HI0d6sFagmTmLBT66WUXNwD4Dg+AskLEMXW3RjUTssO4PzBROYvr+s/yZwV 1+9B/+aNOrAr4DqjV62/M+gsz4o81YaBNsVWywUs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sachin Sant , Oliver OHalloran , Michael Ellerman , Sasha Levin Subject: [PATCH 4.9 195/223] powerpc/eeh: Handle hugepages in ioremap space Date: Fri, 2 Aug 2019 11:37:00 +0200 Message-Id: <20190802092249.910684301@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092238.692035242@linuxfoundation.org> References: <20190802092238.692035242@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 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 8336b9016ca9..a7f229e59892 100644 --- a/arch/powerpc/kernel/eeh.c +++ b/arch/powerpc/kernel/eeh.c @@ -362,10 +362,19 @@ static inline unsigned long eeh_token_to_phys(unsigned long token) NULL, &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