Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp46438img; Sun, 17 Mar 2019 19:55:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqysiNvWqU4DFCE5oyhCr3uecZclB5nr8ydnb/L+FlPXwSB79j7ynaC8rp5xhXIXCH0N/oVf X-Received: by 2002:a63:f544:: with SMTP id e4mr15612272pgk.145.1552877709191; Sun, 17 Mar 2019 19:55:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552877709; cv=none; d=google.com; s=arc-20160816; b=MgUdD1/NbiW5mdABo0QpGJKpZS+rgfQPhBQUMyGTlTApf82rRQf2/DTakRCvVp1Nvb ZGzqYTcZSpt/+UtPZlch+8FO93KxB2WYBE0wuK7ryeeaLKVRWPzPO9leV0+UIJG05ns2 E9h6weDI+3zaW2Y33Ko2baxFb/k82c2hoqAr+DxtN+h/oPYE7zynVQ5juGEJ5D6hIg7q hb5hr0EOVF+ZyDWy5X9h7r7GyKR+MgkGm2BNfYLjVMcq6aGcxcX/CnSxR6kn6J1+3UbN W4nNX9CF28Dq7TnBCldDerc2umM9n7mrG9T/SZQPb2DT8SmnswpHj1jlA/UhqR7EEO1z 6suA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:message-id :in-reply-to:subject:cc:to:from:date; bh=heIvGEdKqZcCQD/+LrAodL8ZQ1PSCJmyaTjGP5D4I20=; b=qRNH8J+r7Ssg+r2KYpDnzPr8dDloBQJgj36Z1ajFT2qgPS7zOJUzC51n+o/Dne/CDW xs8jTT9Pu4hktZxAA6WyrBWljJusxPwEwVoPpDkL0qrjoWY0xm01qhn75/RjobQxX9FE WBV2aiLsHar56ef6z9gIO40mcnr3bXuD7rYj4WJt/5hcNV8ZHPq6htyz8eugT0fD14DO vRXgyzf2cQpArxpWgVHORV3gZbaLFq+jpvHGfHVBlAdS8Kz9y16cLx/TpkaQ4vwGa5nK mj+e0OOv4UQeFBerH09h8HY7xBILSt55z+BXyboptkCs+bmQyA0mhE+ujBn0QbF1AnLE LRjQ== 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 y2si1348275pfn.57.2019.03.17.19.54.52; Sun, 17 Mar 2019 19:55:09 -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 S1727731AbfCRCx6 (ORCPT + 99 others); Sun, 17 Mar 2019 22:53:58 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:42304 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727682AbfCRCx5 (ORCPT ); Sun, 17 Mar 2019 22:53:57 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by kvm5.telegraphics.com.au (Postfix) with ESMTP id 6318727ACE; Sun, 17 Mar 2019 22:53:51 -0400 (EDT) Date: Mon, 18 Mar 2019 13:53:51 +1100 (AEDT) From: Finn Thain To: Geert Uytterhoeven cc: Andreas Schwab , kbuild test robot , kbuild-all@01.org, linux-m68k , Arnd Bergmann , Linux Kernel Mailing List Subject: Re: [m68k:master 1174/1174] arch/m68k/include/asm/string.h:72:25: warning: '__builtin_memcpy' forming offset 8 is out of the bounds [0, 7] In-Reply-To: Message-ID: References: <201903042049.npxcZzps%fengguang.wu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 Mar 2019, I wrote: > ... I did another experiment with the latter (forced inline) approach, > to see if some optimizations can still be used with -ffreestanding. > > diff --git a/include/linux/string.h b/include/linux/string.h > index 7927b875f80c..25b5bf689018 100644 > --- a/include/linux/string.h > +++ b/include/linux/string.h > @@ -436,6 +436,58 @@ __FORTIFY_INLINE char *strcpy(char *p, const char *q) > return p; > } > > +#else > + > +//__FORTIFY_INLINE char *strncpy(char *p, const char *q, __kernel_size_t size) > +//{ > +// return __builtin_strncpy(p, q, size); > +//} > + > +__FORTIFY_INLINE char *strcat(char *p, const char *q) > +{ > + return __builtin_strcat(p, q); > +} > + > +__FORTIFY_INLINE __kernel_size_t strlen(const char *p) > +{ > + return __builtin_strlen(p); > +} > + > +__FORTIFY_INLINE char *strncat(char *p, const char *q, __kernel_size_t count) > +{ > + return __builtin_strncat(p, q, count); > +} > + > +__FORTIFY_INLINE void *memset(void *p, int c, __kernel_size_t size) > +{ > + return __builtin_memset(p, c, size); > +} > + > +//__FORTIFY_INLINE void *memcpy(void *p, const void *q, __kernel_size_t size) > +//{ > +// return __builtin_memcpy(p, q, size); > +//} > + > +__FORTIFY_INLINE void *memmove(void *p, const void *q, __kernel_size_t size) > +{ > + return __builtin_memmove(p, q, size); > +} > + > +__FORTIFY_INLINE int memcmp(const void *p, const void *q, __kernel_size_t size) > +{ > + return __builtin_memcmp(p, q, size); > +} > + > +__FORTIFY_INLINE void *memchr(const void *p, int c, __kernel_size_t size) > +{ > + return __builtin_memchr(p, c, size); > +} > + > +__FORTIFY_INLINE char *strcpy(char *p, const char *q) > +{ > + return __builtin_strcpy(p, q); > +} > + > #endif > > /** > > > The result of this patch really is confusing. It still suppresses the > warning you raised: > > arch/m68k/include/asm/string.h:72:25: warning: '__builtin_memcpy' forming > offset 8 is out of the bounds [0, 7] [-Warray-bounds] > #define memcpy(d, s, n) __builtin_memcpy(d, s, n) > ^~~~~~~~~~~~~~~~~~~~~~~~~ > include/linux/string.h:456:3: note: in expansion of macro 'memcpy' > memcpy(dest, src, dest_len); > ^~~~~~ > > But it also causes new ones, because of __builtin_memset(): > > drivers/video/fbdev/core/fbcvt.c: In function 'fb_find_mode_cvt': > drivers/video/fbdev/core/fbcvt.c:312:16: warning: 'cvt.flags' may be used uninit ialized in this function [-Wmaybe-uninitialized] > cvt.flags |= FB_CVT_FLAG_MARGINS; > ^~ > > Apparently the compiler doesn't understand that __builtin_memset() has > the effect of initialization. Weird. > The other weird thing is that this warning doesn't show up when CONFIG_FORTIFY_SOURCE=y, even though the technique is much the same, that is, __builtin_memset() gets wrapped in a static inline memset() function. Anyway, a quick and dirty microbenchmark under qemu-m68k shows that this patch reduces system time for 'time find / -false' by approx. 10%. Interestingly, the -ffreestanding option doesn't make much difference to this particular microbenchmark. --