From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C46B7A0548; Thu, 9 Jun 2022 00:49:33 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 65DC340689; Thu, 9 Jun 2022 00:49:33 +0200 (CEST) Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by mails.dpdk.org (Postfix) with ESMTP id 4461A40220 for ; Thu, 9 Jun 2022 00:49:32 +0200 (CEST) Received: by mail-pf1-f176.google.com with SMTP id y196so19568135pfb.6 for ; Wed, 08 Jun 2022 15:49:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Wd5MLkN9nINvC8uphbtZnGeYwISk3XIkJXpzK0LN6dg=; b=W403gYb9V+K7a2kbzdIkt3TaqCHULXY3k15NyrFDY+eXwU2TSlslW42sFZ0ffD3IGJ gMss1jFIhmUxmRfdZdWVfN3biGv9Y0wvj8mm7v/qs6Q3V6ek5crpEXSlER2lV0i3PJm9 ALAYEazZXRe3C/Btssi33wOFeZWhM1SDDQxdd/orI6cBRPjVRg8E4z5k49FtAgbM1HuF YrV6wEwZ9Jv+dH0aNvawDxWMZYSx9wcZ/W1NBoTv15/O4T+StPwL/T2T5FMM9vzaXtNn QGSL4nbxMnVM3EmS+5i/OEl0Pfbqf2f/RqK70UPIZnWZBlP9Ybm84wJSA+/n1WDVU9Wl dlgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Wd5MLkN9nINvC8uphbtZnGeYwISk3XIkJXpzK0LN6dg=; b=tTQ8RT5azUBEZcy/as8pAjxQWIIeimtR6gdyD6L64Ha9/AfU72Bphla949jtTh/KBt ASnk+ShlqrzoeT5WrX4zm/taOkqknU+R+qdEK5/nclLZbws/G2EvXHtQDl9pMLoUcERv PvzRz58/MyFjvKxb87iKEvzk3EVtC8x8UxrJ4zeQ7pWX1f3FgWC4I9EVAA+nkwNWclkz xjEE1wI6YRyRbq0AQB7FFGI4aGpziK0fWkKcLgy4ZeujgQBlBrC5H6HuRebPydhgxbRd gYIuZUsP2ChUVAdJqkkH/2Hz2d03VsJOMageyRbYDLTq+M/90eisyTGXRP2PYJQpK3UR 622w== X-Gm-Message-State: AOAM532jnACFFzBIOgCXs32dklSzalnTboC1tHpaNeYRTehyQW5YBBrH DQtwi/x61H1i7Ah3tUc1BZUtP1nomTEHGg== X-Google-Smtp-Source: ABdhPJxTa6Lso3Xf4w2N6hBl4+Ftz+wzpVue4uOrbADWROBnsfQOZYEr1Vq/xEym7/tAgfoFv3jnhQ== X-Received: by 2002:a63:85c8:0:b0:3fd:1851:3d67 with SMTP id u191-20020a6385c8000000b003fd18513d67mr26598845pgd.520.1654728571006; Wed, 08 Jun 2022 15:49:31 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id i190-20020a6387c7000000b003fe11225bffsm4082554pge.93.2022.06.08.15.49.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 15:49:30 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [RFC] eal/x86: disable array bounds checks in rte_memcpy_generic with gcc-12 Date: Wed, 8 Jun 2022 15:49:28 -0700 Message-Id: <20220608224928.457440-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Gcc 12 adds more array bounds checking (good); but it is not smart enough to realize that for small fixed sizes, the bigger move options are not used. An example is using rte_memcpy() on a RSS key of 40 bytes may trigger rte_memcpy complaints from rte_mov128 reading past end of input. In order to keep some of the checks add special case for calls to rte_memcpy() with fixed size arguments to use the compiler builtin instead. Don't want to give all the checking for code that uses rte_memcpy() everywhere. Signed-off-by: Stephen Hemminger --- lib/eal/x86/include/rte_memcpy.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/eal/x86/include/rte_memcpy.h b/lib/eal/x86/include/rte_memcpy.h index 18aa4e43a743..b90cdd8d7326 100644 --- a/lib/eal/x86/include/rte_memcpy.h +++ b/lib/eal/x86/include/rte_memcpy.h @@ -27,6 +27,10 @@ extern "C" { #pragma GCC diagnostic ignored "-Wstringop-overflow" #endif +#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 120000) +#pragma GCC diagnostic ignored "-Warray-bounds" +#endif + /** * Copy bytes from one location to another. The locations must not overlap. * @@ -842,19 +846,21 @@ rte_memcpy_aligned(void *dst, const void *src, size_t n) return ret; } +#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 100000) +#pragma GCC diagnostic pop +#endif + static __rte_always_inline void * rte_memcpy(void *dst, const void *src, size_t n) { - if (!(((uintptr_t)dst | (uintptr_t)src) & ALIGNMENT_MASK)) + if (__builtin_constant_p(n)) + return __builtin_memcpy(dst, src, n); + else if (!(((uintptr_t)dst | (uintptr_t)src) & ALIGNMENT_MASK)) return rte_memcpy_aligned(dst, src, n); else return rte_memcpy_generic(dst, src, n); } -#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 100000) -#pragma GCC diagnostic pop -#endif - #ifdef __cplusplus } #endif -- 2.35.1