Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1962808lqe; Tue, 9 Apr 2024 06:05:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVUvteGEPl39DgKKLp0m8aObUrNSdgUN9EHDAtcr4QP9ccyBmOHx4PViahQhYzq5xvbxh7Z2i8K9Aq4jZGU4CoHpKIKnoVDiA41Y9e92w== X-Google-Smtp-Source: AGHT+IFNRmUwbyqgrFlcTzUxzlBchGtpZLtkXfwX6LL2Jid0+ioyiY8G+gFzW82684ZQlVHKOe2W X-Received: by 2002:a05:6a20:96c8:b0:1a7:8610:bccd with SMTP id hq8-20020a056a2096c800b001a78610bccdmr4277684pzc.57.1712667932140; Tue, 09 Apr 2024 06:05:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712667932; cv=pass; d=google.com; s=arc-20160816; b=eFfD2iwVLKxPnz2lAyG0BkvZPESsXubMNXRY/5rqTZAHwXKsnE7gkXtt440szAy80C A+z/k1u5xcTC+rncC+RA4S2HvWzBTkKHyrw9HOvuFXAsj1GL+ZgdPR60kyn41PTmZHu6 FVGfMGR5BBOT6f0fTIIixyJp76pwx4AUxm+Oeddl3LrQqXCr2haauDJg9ROJeNegxDwl zUhMIw0s5txok0fF5S2PAacDqDqXU12C89dVd70Ae+K1BtHRaRDRt7ayjcgFN0ry6gg/ o3d1zNPDtJh//tiS0iPCRwKtqt8/0Zu5Lzi+BW/5Ar5G+ETi3TrSDgaBtwzfyXCygKuP ZBNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:date:subject :in-reply-to:references:cc:to:from:message-id:dkim-signature; bh=8JWY77Jy81sKv/3l+Z79iqEIm5lCvTg7Noh+jhhkpmQ=; fh=p3Auqe0Fs1hE2R9l67sjMBE01yKFUNGXirIfGG7Dyl8=; b=DcG/p+/vCMMLdGM9HC8a5apqw3s0t1rj/tNYIDsz3D36nxra0jzTUW/O06GRLOkoBa LZxFiEqrWxCaPdN6cvlfoW94HcZXNWQoyrE5wwwls/6H5phgVwN80+quJOon6MlJveKH Her2+cKOJSihDswpDmFvxSpozij4iW1UCT+8h//UCCMOVMOYqMQwftXevNQxAMZx2Yhk IxLjuAv7QKPEnXTbSY5iPp+owB/YBqaZckXq9z38xTE0eBS4g0FWN2wk5962/EvPkkok OOINu32lFmLOlCM+q1+/w8Y7y2rLyMYbMhvu2Q4agTgH5B2HxPDG8KimKYYGhs89nZlU qACg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nexgo.de header.s=vfde-mb-mr2-23sep header.b=BHkfNvT8; arc=pass (i=1 spf=pass spfdomain=nexgo.de dkim=pass dkdomain=nexgo.de); spf=pass (google.com: domain of linux-crypto+bounces-3418-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3418-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i129-20020a639d87000000b005b8ebaa2937si8508437pgd.47.2024.04.09.06.05.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 06:05:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3418-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@nexgo.de header.s=vfde-mb-mr2-23sep header.b=BHkfNvT8; arc=pass (i=1 spf=pass spfdomain=nexgo.de dkim=pass dkdomain=nexgo.de); spf=pass (google.com: domain of linux-crypto+bounces-3418-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3418-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D3F9028488D for ; Tue, 9 Apr 2024 10:35:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9062C7E56C; Tue, 9 Apr 2024 10:35:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nexgo.de header.i=@nexgo.de header.b="BHkfNvT8" X-Original-To: linux-crypto@vger.kernel.org Received: from mr5.vodafonemail.de (mr5.vodafonemail.de [145.253.228.165]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E86E61EB46 for ; Tue, 9 Apr 2024 10:35:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=145.253.228.165 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712658936; cv=none; b=fOD7PQmiq9fhH7KB3Smw0Dcf6dSw5PdZMI/4lYqBLadwzvLtAkawrpen+4EfNH5csrf+ui6GQDCCVzUihR+rMM5OPghU9uivfSRyGqkkScMhN+SlC2PCtpXeanmxuzBe9fSdxYg0IWZeoyewA7sZ6YxUqLmJ70g0XFTyJqZnnA8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712658936; c=relaxed/simple; bh=feIO4vhUUWJr1V0i/YIkTv8TafJAXqFA1Uetb7wB0XU=; h=Message-ID:From:To:Cc:References:In-Reply-To:Subject:Date: MIME-Version:Content-Type; b=flWJyiKwOuYFBu5O+ivEPP3U0aeLQ9x11nL44pR0c4MeyAyojdYnhFIwN/6hvYLtUCosyiy/cjkAhjxy7HkCIhGhaoMKuzDQjoZsW2xwE5z+P5fa54euWiUxoaG14vwyMFN7YIJQ8xr/tY8GFeEBF9+vOFgd2kMVUaB80l1ixzo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nexgo.de; spf=pass smtp.mailfrom=nexgo.de; dkim=pass (1024-bit key) header.d=nexgo.de header.i=@nexgo.de header.b=BHkfNvT8; arc=none smtp.client-ip=145.253.228.165 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nexgo.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nexgo.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexgo.de; s=vfde-mb-mr2-23sep; t=1712658330; bh=8JWY77Jy81sKv/3l+Z79iqEIm5lCvTg7Noh+jhhkpmQ=; h=Message-ID:From:To:References:In-Reply-To:Subject:Date: Content-Type:X-Mailer:From; b=BHkfNvT8e8qUoeD7GLcmg6DIPaJHkrvYOgYv28JRF5f+L9d+c1cktRKn24QIW/YuT 4Nsrg4dnX5PSPki2fayHIYaisET3WboejGRd1yqDBcq8641jeRKXpEauEYhH0tpVOh qhp5cjIjZppLbumarKeB6kvPNxyAW+XoJ/EBM5n0= Received: from smtp.vodafone.de (unknown [10.0.0.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by mr5.vodafonemail.de (Postfix) with ESMTPS id 4VDMY60pLJz1yHn; Tue, 9 Apr 2024 10:25:30 +0000 (UTC) Received: from H270 (p54805648.dip0.t-ipconnect.de [84.128.86.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp.vodafone.de (Postfix) with ESMTPSA id 4VDMXv5yDtz9tj4; Tue, 9 Apr 2024 10:25:16 +0000 (UTC) Message-ID: <4D8C090A8BD54C05A97F57A0F640E94F@H270> From: "Stefan Kanthak" To: "Eric Biggers" , Cc: References: <5EEE09A9021540A5AAD8BFEEE915512D@H270> <20240408123734.GB732@quark.localdomain> <9088939CC5454139901CEDD97DAFB004@H270> <20240408151832.GE732@quark.localdomain> In-Reply-To: <20240408151832.GE732@quark.localdomain> Subject: Re: [PATCH 1/2] crypto: s(h)aving 40+ bytes off arch/x86/crypto/sha256_ni_asm.S Date: Tue, 9 Apr 2024 12:23:13 +0200 Organization: Me, myself & IT Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Windows Mail 6.0.6002.18197 X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7601.24158 X-purgate-type: clean X-purgate: clean X-purgate-size: 2502 X-purgate-ID: 155817::1712658325-0EFFBA4B-4A8EEA38/0/0 "Eric Biggers" wrote: > [+Cc linux-crypto] > > Please use reply-all so that the list gets included. > > On Mon, Apr 08, 2024 at 04:15:32PM +0200, Stefan Kanthak wrote: >> Hi Eric, >> >> > On Mon, Apr 08, 2024 at 11:26:52AM +0200, Stefan Kanthak wrote: >> >> Use shorter SSE2 instructions instead of some SSE4.1 >> >> use short displacements into K256 >> >> >> >> --- -/arch/x86/crypto/sha256_ni_asm.S >> >> +++ +/arch/x86/crypto/sha256_ni_asm.S >> > >> > Thanks! I'd like to benchmark this to see how it affects performance, >> >> Performance is NOT affected: if CPUs weren't superscalar, the patch might >> save 2 to 4 processor cycles as it replaces palignr/pblendw (slow) with >> punpck*qdq (fast and shorter) >> >> > but unfortunately this patch doesn't apply. It looks your email client >> > corrupted your patch by replacing tabs with spaces. Can you please use >> > 'git send-email' to send patches? >> >> I don't use git at all; I'll use cURL instead. [...] >> > Please make sure to run the crypto self-tests too. >> >> I can't, I don't use Linux at all; I just noticed that this function uses >> 4-byte displacements and palignr/pblendw instead of punpck?qdq after pshufd >> >> > The above is storing the two halves of the state in the wrong order. >> >> ARGH, you are right; I recognized it too, wanted to correct it, but was >> interrupted and forgot it after returning to the patch. Sorry. > > I'm afraid that if you don't submit a probably formatted and tested patch, your > patch can't be accepted. We can treat it as a suggestion, though since you're > sending actual code it would really help if it had your Signed-off-by. Treat is as suggestion. I but wonder that in the past 9 years since Tim Chen submitted the SHA-NI code (which was copied umpteen times by others and included in their own code bases) nobody noticed/questioned (or if so, bothered to submit a patch like mine, that reduces the code size by 5%, upstream) why he used 16x "pshufd $14, %xmm0, %xmm0" instead of the 1 byte shorter "punpckhqdq %xmm0, %xmm0" or "psrldq $8, %xmm0" (which both MAY execute on more ports or faster than the shuffle instructions, depending on the micro-architecture), why he used 8x a 4-byte instead of a 1-byte displacement, or why he used "palignr/pblendw" instead of the shorter "punpck?qdq". regards Stefan PS: aaaahhhh, you picked my suggestion up and applied it to the AES routine.