From patchwork Mon Jun 17 13:30:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 167040 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2871081ilk; Mon, 17 Jun 2019 06:31:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKK9d4hY7wsQ5jpKETRiPfODusHTLsqVpckZhPBgVQZa5MLNqCo34ibOyhHScFK99X1eZO X-Received: by 2002:a17:902:8d91:: with SMTP id v17mr88938759plo.91.1560778284065; Mon, 17 Jun 2019 06:31:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560778284; cv=none; d=google.com; s=arc-20160816; b=ga7CVlcFjLmtwPPPoxP8qUv1mjxby947u6wHOzFCbE9k56k1Y0TUgmC6igcU6JVAGO gLc2S9ptMngrNVVzhyA/R7KULu05+JUvAUgC3sraSNWezmh6pbgNf+96ijKkz4uzrn3l IqT0DQFBra/k5NLJZnJsM+CHL2Od0igPChgxn92ZNUsaxq4ZoyF75YJD/RSzNaZqHmWJ a33JHcsU9hZUnlfMaqLrmX/UT7qJh4X0WTcNuXYr+Zut0PhCvTa+u8JN9TfVbS3wNNT+ VkIn5kY47oiXi4MxxVWK6Sk/cOk99+pgrjuGb398aJS9uW96pnBuE0Mj0moAKaOkGMHE Tm9g== 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 :message-id:date:subject:cc:to:from; bh=KzRNO7vTMjIYLulG0YVSsIrZ13IHHuN+vsh7z1U/ZSs=; b=JLE3EcLyXMmihM/xuqlT5caP5NtKoQHizpM3Zr3pCtlWVwCs/eUCjYvEV7jqZiqzqh CTDl9fWToEDqkjj6yngI/bFhrLiXWApjFEThDGMgrzTM+/YblhVTOUk5Jum8Jw5kUlwo SJzMyHUIJjhd2RXcb8s8BSCH4adlJ4Ce3cQndLXQgpGnHIqBXngcjm6/UZxLa30qqPIj 2BIaCiq4tteLIksbVQBX8kYSjD5w+1Re/G83bk3EJO2ideMReKZc81gfE7CYuh8fJQXY z/jutC5kG9b7OAl6xJj2qUERES2yUZZwPCthsL2B4anFR9bypoRZE2lBBXQ9prlbW5cg dtMg== 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 k137si11326667pga.59.2019.06.17.06.31.23; Mon, 17 Jun 2019 06:31:24 -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 S1727693AbfFQNbW (ORCPT + 27 others); Mon, 17 Jun 2019 09:31:22 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:60331 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725884AbfFQNbW (ORCPT ); Mon, 17 Jun 2019 09:31:22 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.145]) with ESMTPA (Nemesis) id 1MMWcT-1hsbSL1duZ-00JXkC; Mon, 17 Jun 2019 15:31:02 +0200 From: Arnd Bergmann To: Joerg Roedel Cc: Christoph Hellwig , Arnd Bergmann , Srinath Mannam , Lorenzo Pieralisi , Bjorn Helgaas , Oza Pawandeep , Robin Murphy , Eric Auger , Julien Grall , Marc Zyngier , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH] iommu: fix integer truncation Date: Mon, 17 Jun 2019 15:30:54 +0200 Message-Id: <20190617133101.2817807-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:chTa38z/gjbzCpsUfTMZ6NKpNwxA24x4uqV4fTfRNlScDoohZxE 1UR/Jwd1cvsBZi9Cwv+CO14naU7ifAmSljpXWNFEf53fU9hdB6iM1CqSUCsspUGu0vXhGrA eGscsZlCrDJPIncYviaP81EDiKdWdO3eE8blN7GXzwc0BPHW8ybWkzP+mCcPefHu5pCJXDe etGOFg30YMgkRmbiSvkNw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:A9saYNOYImg=:MVpURSDPPJlAyB6iXvqW2g avKf+edpDy4W5PssdS5cRVc4QNS1IlH8SqaiwcpcqQXD5AG730d6miFbVQm+3NfvN2fKB5ypX mekwCj9hp4VhkTs/rAmlhLLgKhakc25AoveIlnlqhQ82UR013qCyjfBEggCtnz6JFyWCpY0Ae gpTuCoiLcCBfgpb93voa3QEQAbcc0kFG+LuKCP1c/aQ3c6oOiynW3XBvMU1o7eMy0MXdh5WFc 3CqkjBO90fS7PmvkJIzCgYFlqiilL9QIwK6xN7TsZu3cqJMUMU59rRybbxHKwPqzWdZw7Uajc onvzMU9c/4dJsQkE/NcH1hreerofhpQpfKiUcTnp/NVxYIIU+FQzBYMaytFte09AFjS6hH5SI OgCNV/LEkhtk9accU8jWFayunL9DI2LkoRgWJM+Xd8aPqJvIUQSZAWkKkSWdSzZxkuK9mvted Dnvvr+TU5OPkk3Ry5JtTQ6oLS2tdlvdswGpG/ZWDQmxkHrMl3554mxtCA/4zXhT8qYxVtK0HI P2+eToyhOGotRjL8WKjylitmFO37HSxajlTmyBsMLbjhD9INYY51awWfebQE6EIRyd9v5U3G8 n7kUgACkf13306KMTVkAjJroK7sZ2Jfnowpg2mBA/VR39OVzCyTW9BW94kXMGi0HRm7uG5ycZ BxugJchd22/ncPSJ9wx634vmWAW+yb/5sub343qczvMcyzJVnW9t47eD2Y3EOt1aLs0CIkDAG fqoBrshYUPEhHxepgHU3v2EJ3Vzlr27+eDCJbw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 32-bit architectures, phys_addr_t may be different from dma_add_t, both smaller and bigger. This can lead to an overflow during an assignment that clang warns about: drivers/iommu/dma-iommu.c:230:10: error: implicit conversion from 'dma_addr_t' (aka 'unsigned long long') to 'phys_addr_t' (aka 'unsigned int') changes value from 18446744073709551615 to 4294967295 [-Werror,-Wconstant-conversion] Use phys_addr_t here because that is the type that the variable was declared as. Fixes: aadad097cd46 ("iommu/dma: Reserve IOVA for PCIe inaccessible DMA address") Signed-off-by: Arnd Bergmann --- drivers/iommu/dma-iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.20.0 diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index cc0613c83d71..a9f13313a22f 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -226,8 +226,8 @@ static int iova_reserve_pci_windows(struct pci_dev *dev, start = window->res->end - window->offset + 1; /* If window is last entry */ if (window->node.next == &bridge->dma_ranges && - end != ~(dma_addr_t)0) { - end = ~(dma_addr_t)0; + end != ~(phys_addr_t)0) { + end = ~(phys_addr_t)0; goto resv_iova; } }