Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932074AbbGSUZM (ORCPT ); Sun, 19 Jul 2015 16:25:12 -0400 Received: from mail-lb0-f180.google.com ([209.85.217.180]:34813 "EHLO mail-lb0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753530AbbGSUZH (ORCPT ); Sun, 19 Jul 2015 16:25:07 -0400 From: Rasmus Villemoes To: Guenter Roeck Cc: Sowmini Varadhan , linux-kernel@vger.kernel.org, akpm@linux-foundation.org, benh@kernel.crashing.org, davem@davemloft.net Subject: Re: [PATCH] iommu-common: Do not use 64 bit constant 0xffffffffffffffffl for computing align_mask Organization: D03 References: <20150719121653.GA30645@oracle.com> <20150719152724.GB3729@roeck-us.net> X-Hashcash: 1:20:150719:akpm@linux-foundation.org::d8nFhjlERisDghrV:0000000000000000000000000000000000000LNL X-Hashcash: 1:20:150719:linux-kernel@vger.kernel.org::I2qVVh3Aow3FDEZ1:0000000000000000000000000000000000qbP X-Hashcash: 1:20:150719:linux@roeck-us.net::F538QDQo90FFFBed:00000000000000000000000000000000000000000000/Tt X-Hashcash: 1:20:150719:sowmini.varadhan@oracle.com::MILg8ATkUZW5Yyns:00000000000000000000000000000000001KX2 X-Hashcash: 1:20:150719:benh@kernel.crashing.org::ky+2+vIqZSE8Yoir:000000000000000000000000000000000000042fB X-Hashcash: 1:20:150719:davem@davemloft.net::sTkOLC4ffJlJ5GNy:0000000000000000000000000000000000000000005F74 Date: Sun, 19 Jul 2015 22:25:03 +0200 In-Reply-To: <20150719152724.GB3729@roeck-us.net> (Guenter Roeck's message of "Sun, 19 Jul 2015 08:27:24 -0700") Message-ID: <874mkzevz4.fsf@rasmusvillemoes.dk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1839 Lines: 46 On Sun, Jul 19 2015, Guenter Roeck wrote: > On Sun, Jul 19, 2015 at 02:20:14PM +0200, Sowmini Varadhan wrote: >> >> Using a 64 bit constant generates "warning: integer constant is too >> large for 'long' type" on 32 bit platforms. Instead use ~0l to get >> the desired effect. >> >> Detected by Andrew Morton who has confirmed that this patch >> fixes the warning on i386/gcc-4.4.3, i386/gcc-4.4.0 and arm/gcc-4.4.4. >> >> Signed-off-by: Sowmini Varadhan >> --- >> lib/iommu-common.c | 2 +- >> 1 files changed, 1 insertions(+), 1 deletions(-) >> >> diff --git a/lib/iommu-common.c b/lib/iommu-common.c >> index df30632..fd1297d 100644 >> --- a/lib/iommu-common.c >> +++ b/lib/iommu-common.c >> @@ -119,7 +119,7 @@ unsigned long iommu_tbl_range_alloc(struct device *dev, >> unsigned long align_mask = 0; >> >> if (align_order > 0) >> - align_mask = 0xffffffffffffffffl >> (64 - align_order); >> + align_mask = ~0l >> (64 - align_order); >> > Wonder if this just hides the real problem. Unless align_order > is very large, the resulting mask on 32 bit systems may be 0. > Is this really the idea ? Probably not, but that's not what would happen on x86: the shift only depends on the lower 5 or 6 bits - I don't know if other platforms also has that behaviour. So for align_order == 2 and x86_32 we'd effectively end up with a shift of 62 & 31 == 30 (though technically undefined behaviour), and the desired mask of 0x3. Wouldn't GENMASK(align_order-1, 0) work for all cases (assuming align_order has a sane value)? Rasmus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/