Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp461149imp; Wed, 20 Feb 2019 03:20:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IZygUlcTrLPn3vvKr+xE2ZhUUr0idGRuK3P+kfV//igQMilbq6La7/c40WYygEiRlB55utr X-Received: by 2002:a62:e704:: with SMTP id s4mr34228306pfh.94.1550661642280; Wed, 20 Feb 2019 03:20:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550661642; cv=none; d=google.com; s=arc-20160816; b=c6JCHnG3EuyZy97O39ZNhtQTk/YRtGNqozOmmJmIkKoB/OFvWzkDzE5BchHZYPjRIQ z9CAz+gxVSnBkB4jYdVDEt4Bs12x1Tln2ag1nMdcD7uB6vYmSexy9a6ZN3r4QB1ZjrpU 0+qN60/PR6SMAY5DjvNibRzcwQgCnE6O7+5BUhiePJ49M/Ud11fzArmlcM9YPSLi0O+P UPZ6A5t0Xze3HECkLzSVJLn2ubFDUlv5xZ2Bpffjkd5e9sBDz853+VaabHEQLbuRPPRn HGjCk1b9J2Nr8iV7erYTRajRcKuGQPGustt3xKiqQsfi2GdmBepfXHbajLkYF6aOme2Y dOdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=fymqQS0lkki3yuAVEY16ovgvmO8/V/KFLIYaKxTVUNA=; b=FK/XdEgO4XfK2+50Oqpl5xYe6foTSXc8iS62cAvdD85al547VRpak4h98jCY6AFFsM wJnQGmuOB8ZbPgzDu43lMXdcHNQrQiAmEvxn9MiBCVoCaQNwHJRqXTWm09QGAvzdFjzp yYWRO/DwsmpKXixhe41JiI9mz+iJcTrAN95JoDaHxSDVdg/WhbfPaSK+aXAmEVhYS8eb 0RxHx8rG3bO7FZvTCzVHoz7VLRcwakrLfputHZhIxyFm8ADG//Wp2zuto7RJ3XtHwJmw OuggUpH+r5cpeTT83uIlqdwE+DMywGNRoBovehucWjAHPFmQQVFV7USJlV2nz7otdT1u LLmA== 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 m5si17131239pgq.193.2019.02.20.03.20.26; Wed, 20 Feb 2019 03:20:42 -0800 (PST) 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 S1727921AbfBTLSt (ORCPT + 99 others); Wed, 20 Feb 2019 06:18:49 -0500 Received: from ozlabs.org ([203.11.71.1]:36755 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727157AbfBTLSp (ORCPT ); Wed, 20 Feb 2019 06:18:45 -0500 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 444FTs4sxKz9s71; Wed, 20 Feb 2019 22:18:41 +1100 (AEDT) From: Michael Ellerman To: Segher Boessenkool Cc: Balbir Singh , erhard_f@mailbox.org, jack@suse.cz, linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, aneesh.kumar@linux.vnet.ibm.com Subject: Re: [PATCH] powerpc/64s: Fix possible corruption on big endian due to pgd/pud_present() In-Reply-To: <20190219201539.GT14180@gate.crashing.org> References: <20190214062339.7139-1-mpe@ellerman.id.au> <20190216105511.GA31125@350D> <20190216142206.GE14180@gate.crashing.org> <20190217062333.GC31125@350D> <87ef86dd9v.fsf@concordia.ellerman.id.au> <20190217215556.GH31125@350D> <87imxhrkdt.fsf@concordia.ellerman.id.au> <20190219201539.GT14180@gate.crashing.org> Date: Wed, 20 Feb 2019 22:18:38 +1100 Message-ID: <87sgwi7lo1.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Segher Boessenkool writes: > On Mon, Feb 18, 2019 at 11:49:18AM +1100, Michael Ellerman wrote: >> Balbir Singh writes: >> > Fair enough, my point was that the compiler can help out. I'll see what >> > -Wconversion finds on my local build :) >> >> I get about 43MB of warnings here :) > > Yes, -Wconversion complains about a lot of things that are idiomatic C. > There is a reason -Wconversion is not in -Wall or -Wextra. Actually a lot of those go away when I add -Wno-sign-conversion. And what's left seems mostly reasonable, they all indicate the possibility of a bug I think. In fact this works and would have caught the bug: diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index d8c8d7c9df15..3114e3f368e2 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -904,7 +904,12 @@ static inline int pud_none(pud_t pud) static inline int pud_present(pud_t pud) { + __diag_push(); + __diag_warn(GCC, 8, "-Wconversion", "ulong -> int"); + return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PRESENT)); + + __diag_pop(); } extern struct page *pud_page(pud_t pud); Obviously we're not going to instrument every function like that. But we could start instrumenting particular files. cheers