Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1877036imm; Thu, 2 Aug 2018 02:31:40 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf83k8Kc9xRtlC/OXA4IjQJpniDvRltt8emkf0WoOrmeQ6RUlnHm98ehcFJOKxApIAV36Gn X-Received: by 2002:a17:902:1ab:: with SMTP id b40-v6mr1653249plb.55.1533202300104; Thu, 02 Aug 2018 02:31:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533202300; cv=none; d=google.com; s=arc-20160816; b=ixcHj3DdAszk/azya2BfvZ8jqtHEAoqVsJ3ismzr++6txQv1vGJtC+evCagfeoZaZF qCMrXROSfrONmM8bAHBFOx11U0TQSa9+6czA2Svj+xlmCoBGvke/iiuwu3tMZBX2nXDx yG1lv4CeRf43K/iQUU/jOEyrYGxPutZViHKWkpx0tuavZTtIFr2G8Ebnz0zPdVtkPorI HSaQFkpeDOIk8IR2Z6kNQ0bmRkoILZySRov/KyRDBI59Do05AnZiXYTvhFHA2iJaPP91 tp7fa5OdJWRaiRunbljaObDp2B3SfOuwn+g5TAZdjbxKC3D9jfHjDShavNgNJXR3xj/K Znhg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=jw4h3O1M0Qn6wCggzRZAAhvk0f/wYxiM+h83cwHulxs=; b=qr8vfp4iqmMKby80hptpk18QJkOwX4NYGt4yK7bgg69zSu692+2UkEXAGLV3617YPx /8L20o9fCMsN2Riexv+5xgSJJdtlSal5dWn0EOkiCogqrgxZUcVHg2oPd8pGtjt6Kj46 o1c/UrJT3ZsneoOZgJrl3JKhsXCTNXVF0Jb39tA/TWpEbSMj2t9iJHtECPQxosW8mUOx FJehCxXU4i/6UWLkhdb3MLreWiT+zsG3zOOyO/+FORyIgcUUyJhy7HhRvoTAYna3Q0LO yP+TOpdS0LWdbN3TtTg5wBEb3GFBZQUFH1EOMvqUWZu7IqzHWN15KOp4wypNsm+OaEuj ikYQ== 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 h16-v6si1784117pgb.39.2018.08.02.02.31.25; Thu, 02 Aug 2018 02:31:40 -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 S1731210AbeHBLUx (ORCPT + 99 others); Thu, 2 Aug 2018 07:20:53 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:21644 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726739AbeHBLUx (ORCPT ); Thu, 2 Aug 2018 07:20:53 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 41h4fJ6Ybrz9ttlZ; Thu, 2 Aug 2018 11:30:32 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id 31Ph5a-JHjag; Thu, 2 Aug 2018 11:30:32 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 41h4fJ5zwcz9ttl9; Thu, 2 Aug 2018 11:30:32 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2BBA48B845; Thu, 2 Aug 2018 11:30:34 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id qOQPdc2gfZeM; Thu, 2 Aug 2018 11:30:34 +0200 (CEST) Received: from po14934vm.idsi0.si.c-s.fr (unknown [192.168.232.3]) by messagerie.si.c-s.fr (Postfix) with ESMTP id ACF7C8B843; Thu, 2 Aug 2018 11:30:33 +0200 (CEST) Subject: Re: [PATCH] powerpc/mm: fix always true/false warning in slice.c To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , malat@debian.org, aneesh.kumar@linux.vnet.ibm.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <63b696ab7be8b941fa1e1589f28260320d12a32a.1529589640.git.christophe.leroy@c-s.fr> <871scqwbbo.fsf@concordia.ellerman.id.au> From: Christophe Leroy Message-ID: <1f090f15-eda3-90b1-2aab-ac73d9abb550@c-s.fr> Date: Thu, 2 Aug 2018 09:30:31 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <871scqwbbo.fsf@concordia.ellerman.id.au> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/29/2018 02:55 AM, Michael Ellerman wrote: > Christophe Leroy writes: > >> This patch fixes the following warnings (obtained with make W=1). >> >> arch/powerpc/mm/slice.c: In function 'slice_range_to_mask': >> arch/powerpc/mm/slice.c:73:12: error: comparison is always true due to limited range of data type [-Werror=type-limits] >> if (start < SLICE_LOW_TOP) { > > Presumably only on 32-bit ? Sure > >> diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c >> index 9530c6db406a..17c57760e06c 100644 >> --- a/arch/powerpc/mm/slice.c >> +++ b/arch/powerpc/mm/slice.c >> @@ -79,7 +86,7 @@ static void slice_range_to_mask(unsigned long start, unsigned long len, >> - (1u << GET_LOW_SLICE_INDEX(start)); >> } >> >> - if ((start + len) > SLICE_LOW_TOP) { >> + if (!slice_addr_is_low(end)) { >> unsigned long start_index = GET_HIGH_SLICE_INDEX(start); >> unsigned long align_end = ALIGN(end, (1UL << SLICE_HIGH_SHIFT)); >> unsigned long count = GET_HIGH_SLICE_INDEX(align_end) - start_index; > > This worries me. I'll change it in v2 to: if (SLICE_NUM_HIGH && !slice_addr_is_low(end)) { > > By casting before the comparison in the helper you squash the compiler > warning, but the code is still broken if (start + len) overflows. > > Presumably that "never happens", but it just seems fishy. > > The other similar check in that file does: > > if (SLICE_NUM_HIGH && ((start + len) > SLICE_LOW_TOP)) { > > Where SLICE_NUM_HIGH == 0 on 32-bit. > > > Could we fix the less than comparisons with SLICE_LOW_TOP with something > similar, eg: > > if (!SLICE_NUM_HIGH || start < SLICE_LOW_TOP) { > > ie. limit them to the 64-bit code? That's not enough to make GCC happy: arch/powerpc/mm/slice.c: In function ‘slice_range_to_mask’: arch/powerpc/mm/slice.c:74:31: error: comparison is always true due to limited range of data type [-Werror=type-limits] if (!SLICE_NUM_HIGH || start < SLICE_LOW_TOP) { Christophe > > cheers >