From patchwork Thu Oct 8 07:24:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Fedin X-Patchwork-Id: 7349491 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id ED7E9BEEA4 for ; Thu, 8 Oct 2015 07:24:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1AF6E2063D for ; Thu, 8 Oct 2015 07:24:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E4AFB2073B for ; Thu, 8 Oct 2015 07:24:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753730AbbJHHYj (ORCPT ); Thu, 8 Oct 2015 03:24:39 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:46477 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753726AbbJHHYf (ORCPT ); Thu, 8 Oct 2015 03:24:35 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NVW00HO04KWD590@mailout3.w1.samsung.com>; Thu, 08 Oct 2015 08:24:32 +0100 (BST) X-AuditID: cbfec7f4-f79c56d0000012ee-14-56161a308d18 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 58.0D.04846.03A16165; Thu, 8 Oct 2015 08:24:32 +0100 (BST) Received: from fedinw7x64.rnd.samsung.ru ([106.109.131.169]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NVW00AG84KQJI10@eusync4.samsung.com>; Thu, 08 Oct 2015 08:24:32 +0100 (BST) From: Pavel Fedin To: linux-pci@vger.kernel.org, devicetree@vger.kernel.org Cc: Rob Herring , Frank Rowand , Grant Likely Subject: [PATCH v2 1/2] PCI: of: Add 64-bit address recognition without LPAE support Date: Thu, 08 Oct 2015 10:24:25 +0300 Message-id: <858110a5c4fb0b2094417cc8429560bdaae81c66.1444288748.git.p.fedin@samsung.com> X-Mailer: git-send-email 2.4.4 In-reply-to: References: In-reply-to: References: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKLMWRmVeSWpSXmKPExsVy+t/xa7oGUmJhBo8ms1vMP3KO1WLmm/9s Fgf+7GC0ODvvOJtF694j7A6sHjtn3WX32LSqk83jzrU9bB6fN8kFsERx2aSk5mSWpRbp2yVw ZVzo8CjYz11x53ZlA+Nezi5GTg4JAROJH0vWsELYYhIX7q1n62Lk4hASWMoo0f39DgtIQkig jUli6ddcEJtNQF3i9NcPYHERAUuJ3U23GUFsZoFSiVWbFjOD2MICYRI/L3cCxTk4WARUJa4f 5QMJ8wpES3zed4MdYpecxJXr09lASjgFzCVeXQGrFhIwkzj6Qxa76ARG/gWMDKsYRVNLkwuK k9JzDfWKE3OLS/PS9ZLzczcxQgLryw7GxcesDjEKcDAq8fD+MBYJE2JNLCuuzD3EKMHBrCTC a8IlFibEm5JYWZValB9fVJqTWnyIUZqDRUmcd+6u9yFCAumJJanZqakFqUUwWSYOTqkGRleN p46pZwN+tsoUyv6Pv7w7e6552p2/wlOuC79c4R/kVZY995PFhyusXf4XKjfLOO31X7a8cYme o4mWlqLWQ/kvMnN+mV6et8HjSqZnt4XU6pYFK3o7XTbekmbMNhJK4+tuCJ91cGvlPT8Gmdrs mwvtGjeeKe/bcG4FT/m8CS+sP+4tuXNDWYmlOCPRUIu5qDgRAKE60VQoAgAA Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If non-LPAE kernel is booted up on a machine with 64-bit PCI resources, PCI controller probe fails with: PCI host bridge /pcie@10000000 ranges: IO 0x3eff0000..0x3effffff -> 0x00000000 MEM 0x10000000..0x3efeffff -> 0x10000000 MEM 0x8000000000..0xffffffffff -> 0x8000000000 pci-host-generic 3f000000.pcie: resource collision: [mem 0x00000000-0xffffffff] conflicts with /pl011@9000000 [mem 0x09000000-0x09000fff] pci-host-generic: probe of 3f000000.pcie failed with error -16 This happens because res->start assignment in of_pci_range_to_resource() truncates the upper part of the address, because res->start is of phys_addr_t type, which is 32-bit on non-LPAE kernels. This patch adds explicit recognition of 64-bit resources, preventing from potential problems when e. g. 0x8000001234 would be converted to 0x00001234. Signed-off-by: Pavel Fedin --- drivers/of/address.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/of/address.c b/drivers/of/address.c index 384574c..cd53fe4 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -330,6 +330,12 @@ int of_pci_range_to_resource(struct of_pci_range *range, } res->start = port; } else { + if ((sizeof(resource_size_t) < 8) && + upper_32_bits(range->cpu_addr)) { + err = -EINVAL; + goto invalid_range; + } + res->start = range->cpu_addr; } res->end = res->start + range->size - 1;