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 5685D43BCD; Sat, 2 Mar 2024 21:49:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2438840284; Sat, 2 Mar 2024 21:49:36 +0100 (CET) Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) by mails.dpdk.org (Postfix) with ESMTP id B508240271 for ; Sat, 2 Mar 2024 21:49:34 +0100 (CET) Received: by mail-il1-f169.google.com with SMTP id e9e14a558f8ab-365c773ae6cso12677725ab.2 for ; Sat, 02 Mar 2024 12:49:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1709412574; x=1710017374; darn=dpdk.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=XfMTLZ9wcy7ubyh8VpVl+3DDjRtxqFUmFtXx/XEI2Bw=; b=GwEgp53VGgL6ft3qzVgKlhofJhkLINEZ6Qc3iPoSOR2gagCiII85OvPanPHjEGAqkh 0taanNT8xbhYp1PWP/CPovHmwJgqnpSAdNPAFsyeay/3KsanKJF4GJ3Xu08o2hDtHfLl 98Wdnv0P7Va0bbnWKwyVNGkQwpuUH45lljqIeuZgGz0ukLJzwCmFTADUtRowYAr7Ma2d okEUXd8N1AGhT2CGIVuL4MXgjqYcCBLBccOOYi0BJoUFLPxox52loAfRQg9uIsIzHBYZ W1qWEu64jgwmAhBHpTdOqGuscZe55gPHcYYqm8l47iiUNkmryg+pYHmdk0301hDY8px6 SlDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709412574; x=1710017374; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XfMTLZ9wcy7ubyh8VpVl+3DDjRtxqFUmFtXx/XEI2Bw=; b=KIAWtNEyu/+iLUHuyOFmHm33Sv54z6aZ5lSAcahuYj9obgag0tba9V7OHumGRSlvk7 cbCftbvbbtxqjJUKLA8Blq2OBaQBXQzKvZqJC0iisHeGnwtukbGWNT5atRCkG+HR5Cm5 uZBAVuoBR8L060tz2/skFrAdRtgQlqsqBW75F6/qjpSvACtRycS6NEQQmtNG0wzTx5/T R0YFv8h2pIlrBxiAw/zu2L48sTehFwF57oL7cKnXWqhMDZ9CW9y7G8J7A4erHM09P3E5 0jlq9OzibLuVDHEXYbhC4Ztsxj14REZc6enL1fpVN279OheA0Dq8A6v7u5u2rRTDtEgd lp3A== X-Gm-Message-State: AOJu0Yx6bJBRAIYWIjxADU0H5pevzgDXBSm9hn+w/z7dE8fUkZCvzYlZ jWEwIRb6Ken6RJrwrjicqKiJ3fimej67as/CZ3vDZivOSDhA01X8ZLAbBpAvjlqFyKJFpMt7503 T X-Google-Smtp-Source: AGHT+IFvLitezLxyK6psb0+rrQvMVuW0qT7hYXYjqLrG3OgJxjL8RueW9u6xuk0V0w4Oo7aVyl6ddw== X-Received: by 2002:a05:6e02:1687:b0:365:b506:509e with SMTP id f7-20020a056e02168700b00365b506509emr7295098ila.17.1709412573970; Sat, 02 Mar 2024 12:49:33 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id 23-20020a630d57000000b005dc87f5dfcfsm4890690pgn.78.2024.03.02.12.49.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 12:49:33 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Bruce Richardson , Konstantin Ananyev , Zhihong Wang , Yuanhan Liu , Xiaoyun Li Subject: [PATCH] rte_memcpy: fix off by one for size 16 and 32 Date: Sat, 2 Mar 2024 12:49:23 -0800 Message-ID: <20240302204923.227105-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 The rte_memcpy code would do extra instructions for size 16 and 32 which potentially could reference past end of data. For size of 16, only single mov16 is needed. same for size of 32, only single mov32. Fixes: f5472703c0bd ("eal: optimize aligned memcpy on x86") Fixes: d35cc1fe6a7a ("eal/x86: revert select optimized memcpy at run-time") Suggested-by: Morten Brørup Signed-off-by: Stephen Hemminger --- lib/eal/x86/include/rte_memcpy.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/eal/x86/include/rte_memcpy.h b/lib/eal/x86/include/rte_memcpy.h index 72a92290e05d..00479a4bfbe6 100644 --- a/lib/eal/x86/include/rte_memcpy.h +++ b/lib/eal/x86/include/rte_memcpy.h @@ -233,13 +233,15 @@ rte_memcpy_generic(void *dst, const void *src, size_t n) */ if (n <= 32) { rte_mov16((uint8_t *)dst, (const uint8_t *)src); - rte_mov16((uint8_t *)dst - 16 + n, + if (n > 16) + rte_mov16((uint8_t *)dst - 16 + n, (const uint8_t *)src - 16 + n); return ret; } if (n <= 64) { rte_mov32((uint8_t *)dst, (const uint8_t *)src); - rte_mov32((uint8_t *)dst - 32 + n, + if (n > 32) + rte_mov32((uint8_t *)dst - 32 + n, (const uint8_t *)src - 32 + n); return ret; } -- 2.43.0