Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3801099ybi; Mon, 29 Jul 2019 12:54:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPuekeo0IbPDA0I0R1Filse6sWFKHhtke/ADBjaFrfq27o0HD2aSsnTWy6ptT9LKgnkZTp X-Received: by 2002:a63:e610:: with SMTP id g16mr103077453pgh.392.1564430053608; Mon, 29 Jul 2019 12:54:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430053; cv=none; d=google.com; s=arc-20160816; b=Fs/oufVw5nN13GHAoYu5XApxHuxHWkFJqPqAlLGkNTqVwXOfuXJ/D11oOf2sSeJQXD U4XirOE8BnLEUlCqiYBJTpBNvrMDECPA+I+zjBOaqJujgxxSbhxmsSDtZRZCJ5hc7kHu 7hlXJFmjWQCyUxMTcofcQdwFrtLmc4jn5FY0/HV8ib1VCD6+v0fhLV6XQzzUal7jAeYT uZf+DfWGJTVNK/d13sZBQeF2AYVWDl9IFyAxvIGydFjgRqy2NcfoAZZRF1jyRgKgX4uW HmdKutARSL/4o8sJANANxtYbY6XEVXBqiLM4+Sx37JkZ8uyl881b7LOFJ+Cp6UHutA50 cYlA== 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=FXaEF+xZxbob/sANK4aQQwMlm7ujrSzJFjlTFyG+nxg=; b=pL5/jaaMh3Twu31S73OCK4ELaxyrydPQADCMGBxOEurJ6h67+z69aMG2u8CMbQiOjT +Rt9mrFYgZ9Jg/EHTJkpQImEJ8ghTV5nkELhG4y1sOCAaPmMdMLPP7Yu3b88cdfJTqng xXgSOGvxSn9GbM5wgrOGxrcMjsz5Svlotryr+pEUbyFil5eqMGgqadUx0MrKMvo8LoZL nGrsca0oG4uf/jQq+6EuBsEzxsAeYN/Zco5yMZGI1qGw81v+xEZdz+yfAM6zIIbsyUQ/ DmUKRqYIlLAbCB7t5FpmNUj3FlRjfNIr4TA5GMxV4jmW5wFPiNdYEEkCV6VFNAA034bD UZVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="F/9MAQgV"; 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 k13si2070882pgt.285.2019.07.29.12.53.58; Mon, 29 Jul 2019 12:54:13 -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="F/9MAQgV"; 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 S2403924AbfG2Twj (ORCPT + 99 others); Mon, 29 Jul 2019 15:52:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:44250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403898AbfG2Tw0 (ORCPT ); Mon, 29 Jul 2019 15:52:26 -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 22F4A2171F; Mon, 29 Jul 2019 19:52:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429945; bh=dLN48frxHIgBkJc6jUET3AT4ObeOAhRSb1d7Fprxev4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F/9MAQgVMnq0M/+EmvwH7cl2Bged338bNhegx0KiHT6NUqBu+3BNuCIZSjqIfyUYK Ner678Th/gaT5+aLrbti098Wgu1hG7NvKjH2FtVm/7yKF9O/UEOAT6bh1vEu3nUdpq ZYV567KcFG6lSUNgS6yflA4vFXcPRCmTcQZL9Sjk= 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 5.2 145/215] powerpc/eeh: Handle hugepages in ioremap space Date: Mon, 29 Jul 2019 21:22:21 +0200 Message-Id: <20190729190804.835475505@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@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 f192d57db47d..c0e4b73191f3 100644 --- a/arch/powerpc/kernel/eeh.c +++ b/arch/powerpc/kernel/eeh.c @@ -354,10 +354,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