From patchwork Tue Oct 20 14:57:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lad Prabhakar X-Patchwork-Id: 11847171 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, T_TVD_MIME_NO_HEADERS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2220FC4363D for ; Tue, 20 Oct 2020 14:58:10 +0000 (UTC) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A502B21D7B for ; Tue, 20 Oct 2020 14:58:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=lists.cip-project.org header.i=@lists.cip-project.org header.b="DLLhc54O" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A502B21D7B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+64572+5619+4520388+8129055@lists.cip-project.org X-Received: by 127.0.0.2 with SMTP id Z7uQYY4521723xdUhSeG7Rl5; Tue, 20 Oct 2020 07:58:09 -0700 X-Received: from relmlie6.idc.renesas.com (relmlie6.idc.renesas.com []) by mx.groups.io with SMTP id smtpd.web09.8069.1603205878331425469 for ; Tue, 20 Oct 2020 07:58:08 -0700 X-IronPort-AV: E=Sophos;i="5.77,397,1596466800"; d="scan'208";a="60088231" X-Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 20 Oct 2020 23:58:08 +0900 X-Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 2A6E7433DEA7; Tue, 20 Oct 2020 23:58:06 +0900 (JST) From: "Lad Prabhakar" To: cip-dev@lists.cip-project.org, Nobuhiro Iwamatsu , Pavel Machek Cc: Biju Das , Lad Prabhakar Subject: [cip-dev] [PATCH 4.19.y-cip 22/26] PCI: endpoint: Cast the page number to phys_addr_t Date: Tue, 20 Oct 2020 15:57:28 +0100 Message-Id: <20201020145732.30343-23-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: <20201020145732.30343-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20201020145732.30343-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: Bulk List-Unsubscribe: Sender: cip-dev@lists.cip-project.org List-Id: Mailing-List: list cip-dev@lists.cip-project.org; contact cip-dev+owner@lists.cip-project.org Reply-To: cip-dev@lists.cip-project.org X-Gm-Message-State: ySabQRkKN6g3E7cWx4b0UeMWx4520388AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.cip-project.org; q=dns/txt; s=20140610; t=1603205889; bh=eLnZd2Sy2SuzyFBiWJj9lD6qH412LNr6ZH9MTiD9Z1Y=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=DLLhc54Ozh5wWN+ZgzqLzfXi+dWZWeL3wM8pRE+igCFXYrgE6POsSCzkcFyjeK+kUSi khjvEa8aqupzH9srBbhKQuE/YA5Ij9SvQ6EeTGCOCz0r3UJ66OWLHL2im0yCgPf1x+9nZ /XH1Er0p+Q3c+buE3u/4ApZZrSpiJamBmH8= From: Alan Mikhak commit daee4f4e42c792997f4fee47dcdfa65dd720ec02 upstream. Modify pci_epc_mem_alloc_addr() to cast the variable 'pageno' from type 'int' to 'phys_addr_t' before shifting left. This cast is needed to avoid treating bit 31 of 'pageno' as the sign bit which would otherwise get sign-extended to produce a negative value. When added to the base address of PCI memory space, the negative value would produce an invalid physical address which falls before the start of the PCI memory space. Signed-off-by: Alan Mikhak Signed-off-by: Lorenzo Pieralisi Acked-by: Kishon Vijay Abraham I Signed-off-by: Lad Prabhakar --- drivers/pci/endpoint/pci-epc-mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/endpoint/pci-epc-mem.c b/drivers/pci/endpoint/pci-epc-mem.c index 0471643cf536..abfac1109a13 100644 --- a/drivers/pci/endpoint/pci-epc-mem.c +++ b/drivers/pci/endpoint/pci-epc-mem.c @@ -136,7 +136,7 @@ void __iomem *pci_epc_mem_alloc_addr(struct pci_epc *epc, if (pageno < 0) goto ret; - *phys_addr = mem->phys_base + (pageno << page_shift); + *phys_addr = mem->phys_base + ((phys_addr_t)pageno << page_shift); virt_addr = ioremap(*phys_addr, size); if (!virt_addr) bitmap_release_region(mem->bitmap, pageno, order);