From patchwork Mon Jun 7 07:10:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 43732 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F11A2383B411 for ; Mon, 7 Jun 2021 07:12:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F11A2383B411 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1623049970; bh=Cil+9ElyCdkrVgLb9uSxY3BoHI/7oJMfCfWV4qicFGI=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=x9cftSv1LY5YI+T2G59Y0MvbdU0JAIrpQcDdoWvOtgbUjwUIyJxz66wrGTirwrdP5 B1a4TDGqICBF8AllffE5kmjwpY+yIQYGm2umx9KuH5vghAHFEbs02W5dy0TLXbORGO 97MwnpPOpYx/yPXtYzj2tqYQ+fZHYFWW1XV5rLAY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by sourceware.org (Postfix) with ESMTPS id B80D53853818 for ; Mon, 7 Jun 2021 07:11:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B80D53853818 Received: by mail-qt1-x82c.google.com with SMTP id v6so2997630qta.9 for ; Mon, 07 Jun 2021 00:11:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Cil+9ElyCdkrVgLb9uSxY3BoHI/7oJMfCfWV4qicFGI=; b=HqtFW4siy2Uo1xX1edNrVw6sXWYsEXbGWorbghlA9tlGh1k3dXOY6VnxRniVFjvFld /HRFMxewMt5+zlEcmDB4jPIhRqnloJV4ilE8UO+94xSwcBSSKa6c3JLeE/xJVjDKrLHa Fk4CvsPMk9qGDabLxhvNYVVc4O5tvxMihpnpuyFAOEX0tEdq8o4dlIJZb07GbOLD+DvA purCRB3Nr8XVhga5oDfPlGMRKBsjmuRLt7F0S2vfV5hLHTfxbu2P67RLC65+gZe1JCY7 OtoH0huhUMqvy4kGP88bicdF5Pku4BjkqOvJCt6WIKuUmSSTHCMHr5kmp+L7PQlF0KR0 iCTQ== X-Gm-Message-State: AOAM533pkJMZNDPqUP5UjJZS+8ngZkHUFZla1mmw8bjUfAfeb4og8k5D lEZbA76qb5ruo7SIl7TfPDRTPdv0rbM= X-Google-Smtp-Source: ABdhPJytSNvwS6x5u3cySIrIomvp7FYStt9lLe+N7Ejr+22rsgGkj1zfqdxr0vx8wbPSE7ctAUns6Q== X-Received: by 2002:ac8:7d0b:: with SMTP id g11mr489366qtb.276.1623049906196; Mon, 07 Jun 2021 00:11:46 -0700 (PDT) Received: from localhost.localdomain (pool-71-245-178-39.pitbpa.fios.verizon.net. [71.245.178.39]) by smtp.googlemail.com with ESMTPSA id 97sm8173094qte.20.2021.06.07.00.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 00:11:45 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v1 3/3] x86: memset-vec-unaligned-erms.S fix bug with overflow. Date: Mon, 7 Jun 2021 03:10:26 -0400 Message-Id: <20210607071025.449866-3-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210607071025.449866-1-goldstein.w.n@gmail.com> References: <20210607071025.449866-1-goldstein.w.n@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Noah Goldstein via Libc-alpha From: Noah Goldstein Reply-To: Noah Goldstein Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" The following commit: author Noah Goldstein Thu, 20 May 2021 17:13:51 +0000 (13:13 -0400) commit 6abf27980a947f9b6e514d6b33b83059d39566ae added a bug to memset so that if destination + length overflowed memset would return early rather than throw a Segmentation Fault as is expected behavior: This commit fixes that bug. Signed-off-by: Noah Goldstein --- .../multiarch/memset-vec-unaligned-erms.S | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S b/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S index ff196844a0..3399a2bf1e 100644 --- a/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S +++ b/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S @@ -63,6 +63,16 @@ # endif #endif +# if VEC_SIZE == 16 +# define LOG_VEC_SIZE 4 +# elif VEC_SIZE == 32 +# define LOG_VEC_SIZE 5 +# elif VEC_SIZE == 64 +# define LOG_VEC_SIZE 6 +# else +# error Unsupported VEC_SIZE +#endif + #define PAGE_SIZE 4096 #ifndef SECTION @@ -196,14 +206,17 @@ L(return): ret #endif + .p2align 4 L(loop_start): VMOVU %VEC(0), (VEC_SIZE * 2)(%rdi) VMOVU %VEC(0), (VEC_SIZE * 3)(%rdi) cmpq $(VEC_SIZE * 8), %rdx jbe L(loop_end) + leaq -(VEC_SIZE * 4 + 1)(%rdi, %rdx), %rcx andq $-(VEC_SIZE * 2), %rdi + subq %rdi, %rcx subq $-(VEC_SIZE * 4), %rdi - leaq -(VEC_SIZE * 4)(%rax, %rdx), %rcx + sarq $(LOG_VEC_SIZE + 2), %rcx .p2align 4 L(loop): VMOVA %VEC(0), (%rdi) @@ -211,8 +224,8 @@ L(loop): VMOVA %VEC(0), (VEC_SIZE * 2)(%rdi) VMOVA %VEC(0), (VEC_SIZE * 3)(%rdi) subq $-(VEC_SIZE * 4), %rdi - cmpq %rcx, %rdi - jb L(loop) + decq %rcx + jne L(loop) L(loop_end): /* NB: rax is set as ptr in MEMSET_VDUP_TO_VEC0_AND_SET_RETURN. rdx as length is also unchanged. */