Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1192511ybp; Wed, 9 Oct 2019 10:08:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLYW+MIyPF4qEuBQ1Ao20sjrhDtg4SOvVp4aeSsrTowFktTxc1zwL2lrDrwkgh3fty0Rpu X-Received: by 2002:a17:906:82cf:: with SMTP id a15mr3866229ejy.279.1570640910101; Wed, 09 Oct 2019 10:08:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570640910; cv=none; d=google.com; s=arc-20160816; b=Ise+N6T9/Xzq+/Wy0beeGFEKQnUqWrhUxmJ9sogH6WoFLq7QHmXE8PUsxCKMcBKXfd xqTWgjxW/Te9tdhQvUlptzLMzKedbV0IhjVefErgTJmSS8QNC19ys+31+1EBrfQn+3/p irnETLkxTy7QeJs/q0AvBW3DeabeEUcamfSVdX1dXuHPq+YvWcauycPKysTsrVezodIr D7YQDoxF7qMR75f3kkZEfr2TW7IhCBe9N32Di3iy6c1aNlBlix+NkZWL0nn3yb7XUQQ1 MQWhrFMQa/BAO6GTNwuEw6Tsguk7q8w9wiAkNAMTpLSbYSrmyJfvOeyhGN/zjYMzEG2i TAZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=fa9xrD4T1rxzQNwYuOjdLGG0r9pM+goY6z40NA+UpNk=; b=VmfFrA+lALoSNZ9OSLu74Cfl8egdrThvsoHuUfOuJpF4wwlA+89umikN0mX4h5zE+p 7pDljBFKOb94gYj1ZJuwVYjxTOSViGaSumLv0RuZIp8Oc+zvUvpkRu2+rgGM/zreasWn 0P5m4eAx4KSh2WYWvVSvoNY2Hda2tl+7KCq+MzzQ4wGm5r9r0gJemIirPbbpphenxGhF /FBY08bBtdhU9aTgdiVWq5IpQC86zTsaCd9T6TkznDx8QRCcVhL/Lbobw+6ldgO8JwlP VI0plpnYwWLPUvhvN3T+AhGSojckrYkNnQXXBQrO4J1qOthUvu1Yn8UVrCOzol0qGnWS dZVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=eWSMm4RG; 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 y10si1559862eje.50.2019.10.09.10.07.56; Wed, 09 Oct 2019 10:08:30 -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=@sifive.com header.s=google header.b=eWSMm4RG; 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 S1731853AbfJIRHM (ORCPT + 99 others); Wed, 9 Oct 2019 13:07:12 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:41823 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731416AbfJIRHM (ORCPT ); Wed, 9 Oct 2019 13:07:12 -0400 Received: by mail-pl1-f194.google.com with SMTP id t10so1342339plr.8 for ; Wed, 09 Oct 2019 10:07:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id; bh=fa9xrD4T1rxzQNwYuOjdLGG0r9pM+goY6z40NA+UpNk=; b=eWSMm4RGsYvvraPfWPNbhEvXx67CRd+v1lzqeVnY4XCqgS3cNk+xkxmVVBvM4XQYg0 rXBiQuhNKFbx+5xo+tJc8EWRV8qgU3eFQTerVRsnfsf5Z1TOnpHsEaABH2VpNcy8WiAh RSfds7USbSSZTFSezm6bh4LLU2pODq7gxz1yAcPtl0O3CATiThpWHCsL/Sm0gKKWXtH/ aieAhKj4ZyFoIaHM+l5aGuYQMKHeqH9YF5km1RnzXa47MKTp4uD16JLKwF6MDKLwu0NF AlLlKdRoyeINr0rXk+pQcOCZaO2LPWHKB5cqGgx4OPYp7EfXS3IDpHhV9SFY+henXQ/T c0Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fa9xrD4T1rxzQNwYuOjdLGG0r9pM+goY6z40NA+UpNk=; b=ogAq7JeYFTg9fpTevoq+pLoq7FdoCnfg6gGgVCOTwKvicBkfA7dxJGy+W8y2yIjdjM TgyRSqDa8V1Ecn9PgGdrB1BNbwZb17lYIpMmemadPFAOMwBBoWbKzhQ2FKgVYHFgMMG2 TzguZeoidGP6c+LCh7IWNv0FWcqJk7rxEHcEYHGXhIP7EhRrl+sQotq/WKKqtar44zOq Dz3ROjoeZr4QH00mSG8YPnSvPdMC+mx/IpdR77Ovg4TV5Q76VtCAdkRqc2YHvw/MD4AN bJEdv8NpJyMBAlh6SxbmHvWwAaLU009Fg6AZHkWGXT8oxG52FKzgFHLZ/oJSiowuNCUI zr1Q== X-Gm-Message-State: APjAAAXKo+lcZex/sQSa2wHO0R3L+ifkqZw6lsoqu4ungAin73ywZAxW Zo8KlqLtOr0n3SN+t00PFI6rMUHITSQ= X-Received: by 2002:a17:902:a988:: with SMTP id bh8mr4277629plb.303.1570640831326; Wed, 09 Oct 2019 10:07:11 -0700 (PDT) Received: from nuc7.sifive.com ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id x20sm3417640pfp.120.2019.10.09.10.07.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Oct 2019 10:07:10 -0700 (PDT) From: Alan Mikhak X-Google-Original-From: Alan Mikhak < alan.mikhak@sifive.com > To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, kishon@ti.com, lorenzo.pieralisi@arm.com, bhelgaas@google.com, palmer@sifive.com, paul.walmsley@sifive.com Cc: Alan Mikhak Subject: [PATCH v2] PCI: endpoint: Cast the page number to phys_addr_t Date: Wed, 9 Oct 2019 10:06:56 -0700 Message-Id: <1570640816-5390-1-git-send-email-alan.mikhak@sifive.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) 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