From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2B80C433E1 for ; Sat, 18 Jul 2020 15:31:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 782B02076A for ; Sat, 18 Jul 2020 15:31:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Rn7Jp+F0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728093AbgGRPbd (ORCPT ); Sat, 18 Jul 2020 11:31:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726411AbgGRPbc (ORCPT ); Sat, 18 Jul 2020 11:31:32 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D4DEC0619D2 for ; Sat, 18 Jul 2020 08:31:32 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id el4so5544675qvb.13 for ; Sat, 18 Jul 2020 08:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=auwkIRQjT6Uc69u2UKmP1cyyXbEWBz03molj5iU9OA4=; b=Rn7Jp+F07KLYyMTYZgl3wpwyyEStC4DnVcLCTgf7ONn5Ajp3ogfLukeo+4mUbxVd9D djwzS8Wyl5Aa9S8bYjRS1TuFNd28p8JNjgqvDlRQOm1A6KDFzoE48Oo4aqVq4EJu9OQ9 f9CROYV3BcG1tmRAhAIOdge0DfJQjzYGIUbZKgJta5osfNuKc1ZL7VWrc7vaQU/eNR6s GlEoqGVfI+mJks5subKJ40S+iKizL2Z/9Zw95Jk29x2TAPgzz4a4XLUAjh8g0RvE3iiR gfhZ7syQbArQkcqQ5fMRRSfUus/b0lj2Z8dqhYzpUuaT1R5hPQ3TzsgK2nK4CUXWtPCF AS7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=auwkIRQjT6Uc69u2UKmP1cyyXbEWBz03molj5iU9OA4=; b=aRe8OVvTHHACDRaK5nrAwb/40fq90apnVCtbz1OPul5ZqRz/7jHbeUOJjcU5lut5+b tqiDU8fgm2O8ARtoARKFhcnsnvPSgR/UhI+cuBDWF4pxjXWDULmRHzI65nufWJgUdfEa josSnl87zwTYn6ig+GVjGgOOW3+/6pINR8CyLnm2xFCCc5EDrQQVWSGxo9b7wpqL76MK S/vRUZ9e07idlaUD9ysKYrlwmjQzNsKHN0buFaqCgLVDO6C61vERTgmd1uJ9Xkd5enBS OyrmphQmaXnmcoS6DUCrTaDc+j9vEMKXCbRm2uxiJY2QyC8nh2FeqPTfwIID9mxSyuwl Vzmg== X-Gm-Message-State: AOAM5333mGlP1BLxseQSm7B+/aw2jAt23AHS8/YYsm9FDh5zUJukb20C /P8iU6qgmXlJILIFA406Rz8fJYFq X-Google-Smtp-Source: ABdhPJzUEY75zsnGOmvWd64xcaA6KtUhLpNpA2yNJhrpDY0AaZCL/2AcO9N7kLNgZGnBZ7dnPxjuqg== X-Received: by 2002:ad4:5a46:: with SMTP id ej6mr14203491qvb.52.1595086291245; Sat, 18 Jul 2020 08:31:31 -0700 (PDT) Received: from ubuntu-n2-xlarge-x86 ([2604:1380:45d1:2600::1]) by smtp.gmail.com with ESMTPSA id o12sm13740812qtl.48.2020.07.18.08.31.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Jul 2020 08:31:30 -0700 (PDT) Date: Sat, 18 Jul 2020 08:31:29 -0700 From: Nathan Chancellor To: Geert Uytterhoeven Cc: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Geoff Levand , linuxppc-dev , Linux Kernel Mailing List , clang-built-linux , Joel Stanley , Arnd Bergmann Subject: Re: [PATCH] powerpc/boot: Use address-of operator on section symbols Message-ID: <20200718153129.GA1815449@ubuntu-n2-xlarge-x86> References: <20200624035920.835571-1-natechancellor@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 18, 2020 at 09:50:50AM +0200, Geert Uytterhoeven wrote: > Hi Nathan, > > On Wed, Jun 24, 2020 at 6:02 AM Nathan Chancellor > wrote: > > arch/powerpc/boot/main.c:107:18: warning: array comparison always > > evaluates to a constant [-Wtautological-compare] > > if (_initrd_end > _initrd_start) { > > ^ > > arch/powerpc/boot/main.c:155:20: warning: array comparison always > > evaluates to a constant [-Wtautological-compare] > > if (_esm_blob_end <= _esm_blob_start) > > ^ > > 2 warnings generated. > > > > These are not true arrays, they are linker defined symbols, which are > > just addresses. Using the address of operator silences the warning > > and does not change the resulting assembly with either clang/ld.lld > > or gcc/ld (tested with diff + objdump -Dr). > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/212 > > Reported-by: Joel Stanley > > Signed-off-by: Nathan Chancellor > > --- > > arch/powerpc/boot/main.c | 4 ++-- > > arch/powerpc/boot/ps3.c | 2 +- > > 2 files changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c > > index a9d209135975..cae31a6e8f02 100644 > > --- a/arch/powerpc/boot/main.c > > +++ b/arch/powerpc/boot/main.c > > @@ -104,7 +104,7 @@ static struct addr_range prep_initrd(struct addr_range vmlinux, void *chosen, > > { > > /* If we have an image attached to us, it overrides anything > > * supplied by the loader. */ > > - if (_initrd_end > _initrd_start) { > > + if (&_initrd_end > &_initrd_start) { > > > > Are you sure that fix is correct? > > extern char _initrd_start[]; > extern char _initrd_end[]; > extern char _esm_blob_start[]; > extern char _esm_blob_end[]; > > Of course the result of their comparison is a constant, as the addresses > are constant. If clangs warns about it, perhaps that warning should be moved > to W=1? > > But adding "&" is not correct, according to C. > > Gr{oetje,eeting}s, > > Geert > Hi Geert, Yes, I have done fairly extensive testing in the past to verify that this fix is correct. For example: $ cat test.c #include extern char _test[]; int main(void) { printf("_test: %p\n", _test); printf("&_test: %p\n", &_test); return 0; } $ cat test.lds _test = .; $ clang -Wl,-T test.lds test.c $ ./a.out _test: 0x204 &_test: 0x204 $ gcc -fuse-ld=lld -Wl,-T test.lds test.c $ ./a.out _test: 0x60a0f76301fb &_test: 0x60a0f76301fb I also did runtime verification in QEMU to confirm this is true when I was testing these commits, which are already present in Linus' tree: 63174f61dfae ("kernel/extable.c: use address-of operator on section symbols") bf2cbe044da2 ("tracing: Use address-of operator on section symbols") 8306b057a85e ("lib/dynamic_debug.c: use address-of operator on section symbols") b0d14fc43d39 ("mm/kmemleak.c: use address-of operator on section symbols") I did a lot of work to get this warning enabled as it can find bugs: 6def1a1d2d58 ("fanotify: Fix the checks in fanotify_fsid_equal") 79ba4f931067 ("IB/hfi1: Fix logical condition in msix_request_irq") -Wno-tautological-compare disables a bunch of good subwarnings, as I point out in the commit that enabled it: afe956c577b2 ("kbuild: Enable -Wtautological-compare") Cheers, Nathan From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85076C433E3 for ; Sat, 18 Jul 2020 15:33:35 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D01B820734 for ; Sat, 18 Jul 2020 15:33:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Rn7Jp+F0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D01B820734 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4B8Bpg5zmtzDrMy for ; Sun, 19 Jul 2020 01:33:31 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::f42; helo=mail-qv1-xf42.google.com; envelope-from=natechancellor@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Rn7Jp+F0; dkim-atps=neutral Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4B8BmR0HFVzDrBY for ; Sun, 19 Jul 2020 01:31:34 +1000 (AEST) Received: by mail-qv1-xf42.google.com with SMTP id ed14so5575149qvb.2 for ; Sat, 18 Jul 2020 08:31:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=auwkIRQjT6Uc69u2UKmP1cyyXbEWBz03molj5iU9OA4=; b=Rn7Jp+F07KLYyMTYZgl3wpwyyEStC4DnVcLCTgf7ONn5Ajp3ogfLukeo+4mUbxVd9D djwzS8Wyl5Aa9S8bYjRS1TuFNd28p8JNjgqvDlRQOm1A6KDFzoE48Oo4aqVq4EJu9OQ9 f9CROYV3BcG1tmRAhAIOdge0DfJQjzYGIUbZKgJta5osfNuKc1ZL7VWrc7vaQU/eNR6s GlEoqGVfI+mJks5subKJ40S+iKizL2Z/9Zw95Jk29x2TAPgzz4a4XLUAjh8g0RvE3iiR gfhZ7syQbArQkcqQ5fMRRSfUus/b0lj2Z8dqhYzpUuaT1R5hPQ3TzsgK2nK4CUXWtPCF AS7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=auwkIRQjT6Uc69u2UKmP1cyyXbEWBz03molj5iU9OA4=; b=IJNsdTWiYEr/vPwFZxhkzZGu90lHksFh2XveGgVuj0dusnJ+0xKKFU85DGbdnyNncb FVoZLxVsLckJHxXTmO8/Lz9SsIWp1AmacdhbjJYx+PFlCbHJrV+o0ulvAvsQkmbvBS3/ h1vNhl5mogZLJpPufyfPDZMgViS21OwFv2ImyzDf/36zqF7mbWiF5d5MeSinxhsg3BAI PElCwYejnUga0BUpiHDWIy+ilTuWNdcmR0l9d3Wu/jiy3mKJOblYwK5YVEprF9A/H761 YTofRSlJj54o53yXVWozxMKBIfpylhh5ZFyOEWopMmpCqiRujcbI1PUPi+PT7hVS258N KY1w== X-Gm-Message-State: AOAM530EVMTqTuZONVpma0/w44UosFcBjyN4ZEihGpyof0jDmdicRofG FfdsghxHidtaTobuInofYNU= X-Google-Smtp-Source: ABdhPJzUEY75zsnGOmvWd64xcaA6KtUhLpNpA2yNJhrpDY0AaZCL/2AcO9N7kLNgZGnBZ7dnPxjuqg== X-Received: by 2002:ad4:5a46:: with SMTP id ej6mr14203491qvb.52.1595086291245; Sat, 18 Jul 2020 08:31:31 -0700 (PDT) Received: from ubuntu-n2-xlarge-x86 ([2604:1380:45d1:2600::1]) by smtp.gmail.com with ESMTPSA id o12sm13740812qtl.48.2020.07.18.08.31.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Jul 2020 08:31:30 -0700 (PDT) Date: Sat, 18 Jul 2020 08:31:29 -0700 From: Nathan Chancellor To: Geert Uytterhoeven Subject: Re: [PATCH] powerpc/boot: Use address-of operator on section symbols Message-ID: <20200718153129.GA1815449@ubuntu-n2-xlarge-x86> References: <20200624035920.835571-1-natechancellor@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , Geoff Levand , Linux Kernel Mailing List , clang-built-linux , Paul Mackerras , Joel Stanley , linuxppc-dev Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Sat, Jul 18, 2020 at 09:50:50AM +0200, Geert Uytterhoeven wrote: > Hi Nathan, > > On Wed, Jun 24, 2020 at 6:02 AM Nathan Chancellor > wrote: > > arch/powerpc/boot/main.c:107:18: warning: array comparison always > > evaluates to a constant [-Wtautological-compare] > > if (_initrd_end > _initrd_start) { > > ^ > > arch/powerpc/boot/main.c:155:20: warning: array comparison always > > evaluates to a constant [-Wtautological-compare] > > if (_esm_blob_end <= _esm_blob_start) > > ^ > > 2 warnings generated. > > > > These are not true arrays, they are linker defined symbols, which are > > just addresses. Using the address of operator silences the warning > > and does not change the resulting assembly with either clang/ld.lld > > or gcc/ld (tested with diff + objdump -Dr). > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/212 > > Reported-by: Joel Stanley > > Signed-off-by: Nathan Chancellor > > --- > > arch/powerpc/boot/main.c | 4 ++-- > > arch/powerpc/boot/ps3.c | 2 +- > > 2 files changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c > > index a9d209135975..cae31a6e8f02 100644 > > --- a/arch/powerpc/boot/main.c > > +++ b/arch/powerpc/boot/main.c > > @@ -104,7 +104,7 @@ static struct addr_range prep_initrd(struct addr_range vmlinux, void *chosen, > > { > > /* If we have an image attached to us, it overrides anything > > * supplied by the loader. */ > > - if (_initrd_end > _initrd_start) { > > + if (&_initrd_end > &_initrd_start) { > > > > Are you sure that fix is correct? > > extern char _initrd_start[]; > extern char _initrd_end[]; > extern char _esm_blob_start[]; > extern char _esm_blob_end[]; > > Of course the result of their comparison is a constant, as the addresses > are constant. If clangs warns about it, perhaps that warning should be moved > to W=1? > > But adding "&" is not correct, according to C. > > Gr{oetje,eeting}s, > > Geert > Hi Geert, Yes, I have done fairly extensive testing in the past to verify that this fix is correct. For example: $ cat test.c #include extern char _test[]; int main(void) { printf("_test: %p\n", _test); printf("&_test: %p\n", &_test); return 0; } $ cat test.lds _test = .; $ clang -Wl,-T test.lds test.c $ ./a.out _test: 0x204 &_test: 0x204 $ gcc -fuse-ld=lld -Wl,-T test.lds test.c $ ./a.out _test: 0x60a0f76301fb &_test: 0x60a0f76301fb I also did runtime verification in QEMU to confirm this is true when I was testing these commits, which are already present in Linus' tree: 63174f61dfae ("kernel/extable.c: use address-of operator on section symbols") bf2cbe044da2 ("tracing: Use address-of operator on section symbols") 8306b057a85e ("lib/dynamic_debug.c: use address-of operator on section symbols") b0d14fc43d39 ("mm/kmemleak.c: use address-of operator on section symbols") I did a lot of work to get this warning enabled as it can find bugs: 6def1a1d2d58 ("fanotify: Fix the checks in fanotify_fsid_equal") 79ba4f931067 ("IB/hfi1: Fix logical condition in msix_request_irq") -Wno-tautological-compare disables a bunch of good subwarnings, as I point out in the commit that enabled it: afe956c577b2 ("kbuild: Enable -Wtautological-compare") Cheers, Nathan