Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3130525ybi; Thu, 18 Jul 2019 21:37:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHL951dZ5GGiuczl+wLK5YOPXxdeHxsJQWDhZT2rF7/z6pjXALkqMngItpq1W82q6sFNgR X-Received: by 2002:a17:902:102c:: with SMTP id b41mr53586371pla.204.1563511051318; Thu, 18 Jul 2019 21:37:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563511051; cv=none; d=google.com; s=arc-20160816; b=KlytRjMRXWWkPyLFN3E266LIjglEb49yShm2uPYcMtTB5UBLHXGtF3imGgLtES6MSy a6LunPGZ6M07egeeKDBcI8xXKKtuxu8qCOW0GgN60/8c92NP9Yhibnhrk7D9pzujP4+8 sfv3V3QzSrHVzOJihdBjWH5cBYsHCMS3QyGmPpYtpBVGjY/fUHf1T93wJq8aQiMpv1ql pio1fRrT4f0GmdJLzS/l5ck0YNCHfj5JN2zL0hNzXFqrNaInCbBiz7wqYBhGsixNYX9c 3OhCW1yhdYzqtL/riJG7mCx1i+R5BkNY0DWrCjfa006iOqBH0Ty8Up0NK2B8U7PMSDRG CDXg== 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=YLv4lGnH1zPXGp5DGeLMs5GpT25KP3dl7XmCRfpo+gM=; b=ZpBYP28mkDoIW89TSIyd3/3BJk0x09ONURP838OGtPNqEslLTMlJFp+w2efx5+eVwg t8GUUo8K1j2ltuCF3wJEWlXWFNDxHDrrblmfYEg71+ZNv7xNrVIdkQ3KY+Bqo3vgNFJK 8oWGOGNGcSfAm8G3ivKKvy5fI2gsWFbZYBQtKxJZFQKCmpup8fs0ogFCdXy5siHCITGw WHKnYS/6TXZ8KmE8Ic3sPST6qbrUai92eVxdYNDO9OwH2utdLjbBnZgCDxOSPtvCslz7 VKvPd7fgo3pmLMWEktmrbOSv5oaniLBZLTci3FCXNJgLCskialT3alEz3EErjLvQ5ow5 RCAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FHgHoeEd; 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 b93si51161plb.11.2019.07.18.21.37.15; Thu, 18 Jul 2019 21:37:31 -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=FHgHoeEd; 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 S1731388AbfGSEfD (ORCPT + 99 others); Fri, 19 Jul 2019 00:35:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:33414 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729602AbfGSEBl (ORCPT ); Fri, 19 Jul 2019 00:01:41 -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 D123E218B8; Fri, 19 Jul 2019 04:01:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508900; bh=GCEAQWSdvul4O5OJv7f1vX7r5c8nnHE3tQdguRfUK9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FHgHoeEd7U+YzBEM5yXzq/z3VA6qrTEzdOVhYdpHUaqdk0AwMp60ZgvNFMsCHPiD2 KkibhJ6yB12UxHhaPOCKZAO4fzDJPSysFWri8kvLMoAbFzlGCMJ0Z3jq+v3LSFktgm GCKcoIw7+4SNcNreg26Sm1xDSjk0iGnVZKFG1FHk= 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 5.2 148/171] powerpc/eeh: Handle hugepages in ioremap space Date: Thu, 18 Jul 2019 23:56:19 -0400 Message-Id: <20190719035643.14300-148-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-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 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