Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5978423ybp; Tue, 15 Oct 2019 07:51:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWM4OpYXUo9MDcxx+22MolKyseHvOEGApG0FQFJiO7JC7OBVLvpWDULW83I9Zj4HpzIii9 X-Received: by 2002:a05:6402:28f:: with SMTP id l15mr34397778edv.90.1571151105089; Tue, 15 Oct 2019 07:51:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571151105; cv=none; d=google.com; s=arc-20160816; b=fURZX9rsjOJ919BoidqrpNAUDv9PXaMlZ7RVLvpqvQ/sUvBptoC16LHAfmiw1A+Jn+ p3C5mbkwdD60DqdtneuQsbS+g+L2iDnwALdaC4OEFQn73YDp0cW7hNHtwxj7RfHUEO9r CxQHGlDZ6Z95EHCnp/wEwqCqUookWuPnHv/P3v+SI5NFf+jO9ojj0ZTKBlgD0LOe64QL Afj+3ny0+lSbPOCypGi4YIcU5OwGxy7qbGzoHuTg4YxztNqmR4yjnsU4O4PpwcQTt6i9 m5klJQ2StziFP8GcQ1MYhgIiUgFn5zB7yCaIcenxmF3dNN0TUwI1G6+Wlb0tGi2K17yl GlPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=IMdvkmLChocoXgHA9FJiANbHKciQtRlqzkYwXAP8CCI=; b=a022rsIbMGMlsH1ByMECFgq3te876XXzY9gATRB+vX7qGWH6C/55JnYtUEKkRoT/EU Siv3/eTh4Kk9uQuvK3vPWsSYMV3yX2HczL9VJeXaeh6Cy+OBRms8aHaff2/BtZoesqko vaIkghWOj68Y9ANj/GABhbNTGvPU4yClwOg1z/1K7hAJcu7zfNKFdiJ1OuXeW22yX9OU LLlRYEdNmztjol+zRaamBq7/LKybX4i9I+1HzbNSJ0Z3LaxORfj9S0U0pUJ47/RleHz/ ey1h+UDY3ePntFxVapeBBMyHOmaTFKTr/QEfdEYF0qTaWlZN7bWIKyKHLsgbtw1HWlgI oXow== ARC-Authentication-Results: i=1; mx.google.com; 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 v39si15391246edc.234.2019.10.15.07.51.21; Tue, 15 Oct 2019 07:51:45 -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; 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 S1732736AbfJOOvC (ORCPT + 99 others); Tue, 15 Oct 2019 10:51:02 -0400 Received: from foss.arm.com ([217.140.110.172]:40224 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732979AbfJOOvC (ORCPT ); Tue, 15 Oct 2019 10:51:02 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F30C91000; Tue, 15 Oct 2019 07:51:01 -0700 (PDT) Received: from e121166-lin.cambridge.arm.com (unknown [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EF9583F718; Tue, 15 Oct 2019 07:51:00 -0700 (PDT) Date: Tue, 15 Oct 2019 15:50:58 +0100 From: Lorenzo Pieralisi To: Alan Mikhak Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, kishon@ti.com, bhelgaas@google.com, palmer@sifive.com, paul.walmsley@sifive.com Subject: Re: [PATCH v2] PCI: endpoint: Cast the page number to phys_addr_t Message-ID: <20191015145058.GB22698@e121166-lin.cambridge.arm.com> References: <1570640816-5390-1-git-send-email-alan.mikhak@sifive.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1570640816-5390-1-git-send-email-alan.mikhak@sifive.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 09, 2019 at 10:06:56AM -0700, Alan Mikhak wrote: > From: Alan Mikhak > > 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 > Acked-by: Kishon Vijay Abraham I > --- > drivers/pci/endpoint/pci-epc-mem.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Applied to pci/endpoint, thanks. Lorenzo > diff --git a/drivers/pci/endpoint/pci-epc-mem.c b/drivers/pci/endpoint/pci-epc-mem.c > index 2bf8bd1f0563..d2b174ce15de 100644 > --- a/drivers/pci/endpoint/pci-epc-mem.c > +++ b/drivers/pci/endpoint/pci-epc-mem.c > @@ -134,7 +134,7 @@ void __iomem *pci_epc_mem_alloc_addr(struct pci_epc *epc, > if (pageno < 0) > return NULL; > > - *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); > -- > 2.7.4 >