Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3837053pxy; Tue, 4 May 2021 11:00:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwk8KS9VZ2v9ktlJbroHyj7w9RBaCNXbWPam7ZE4tkhT/6yqOAAvpQu4CtAa6vKeDgt+Ak+ X-Received: by 2002:a05:6402:2714:: with SMTP id y20mr10837331edd.348.1620151257787; Tue, 04 May 2021 11:00:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620151257; cv=none; d=google.com; s=arc-20160816; b=FaGKFFh2fja8ZqE9NKFjoFZ1/fhnfpi0J2K61uftA1pkHMBN+RIsYA8QhDWrce8VW4 b1BDSn9rtptHkB5N0YO+brjyfKv52hxSw8ie16RELj6NysiR7PoGYcAmwC8pGElF1Nub S/fKDSyQNN7vzBan69fobFWxDXvKBzqaI/8Fh/TqBbnLXtY7oOhUjQQ/QwI9CDdekaG3 WOc+W9uu7VNDEpv89nFj0UZO8bxeH/tkUHZFQmdTTI1Kg6F0dim/SANYayFYiPRGnXHP 17UmHAuHs0iEuwmNhxnIx2YeEUmAZgT7qLcByw27YrCdha6izq+gLRO6g1QymWu+o3Z6 0obA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=0BLOUmre5h4HrjXqamzFt21DhFoJQRKssZbKTAMVr1g=; b=0FJL7qPa1HVw13m1/qHMMLac77AdWrWJ7lJpNs59U7t1AwVmM/KJ0VNtPhXzTKkFGq PadbXgqHfhtjiGUKs7Tz8wUiWcRqwmuCW0VTNBthelQ+E2LwirHwoXuEhpER4Ufu9bmf lQPPRqcbFMnv1uUhygE2oLI841ig3lKTjyalxBZovy52hgbdgTaaLZcWbJWPIf+h8Sz2 hU4Wdv6Ux/hdA8MuNTUP8FaDEFA5EPxyzldd0VQ988EcLdVSt6JpW1ezIZqBQh4R3iMi vdi/XQXbCeIHMgJRAcaxylAyyQf3ephP+xJ/l1ASNlI76lfU/hyxXFmEvvK5Mj8wCVwP ezpA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z11si12204796edp.458.2021.05.04.11.00.21; Tue, 04 May 2021 11:00:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232006AbhEDSAl (ORCPT + 99 others); Tue, 4 May 2021 14:00:41 -0400 Received: from smtp06.smtpout.orange.fr ([80.12.242.128]:53199 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231635AbhEDSAj (ORCPT ); Tue, 4 May 2021 14:00:39 -0400 Received: from [192.168.1.18] ([86.243.172.93]) by mwinf5d41 with ME id 0hzg2500421Fzsu03hzghD; Tue, 04 May 2021 19:59:43 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 04 May 2021 19:59:43 +0200 X-ME-IP: 86.243.172.93 Subject: Re: [RFC PATCH] crypto: arc4: Implement a version optimized for memory usage To: Eric Biggers Cc: herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: From: Christophe JAILLET Message-ID: Date: Tue, 4 May 2021 19:59:38 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Le 04/05/2021 à 18:57, Eric Biggers a écrit : > On Sun, May 02, 2021 at 09:29:46PM +0200, Christophe JAILLET wrote: >> +#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) >> +#define S_type u8 >> +#else >> +#define S_type u32 >> +#endif >> + >> struct arc4_ctx { >> - u32 S[256]; >> + S_type S[256]; >> u32 x, y; >> }; > > Is it actually useful to keep both versions? It seems we could just use the u8 > version everywhere. Note that there aren't actually any unaligned memory > accesses, so choosing the version conditionally on > CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS seems odd. What are you trying to > determine by checking that? Hi, this is a bad interpretation from me. I thought that S[1] would likely use an odd address and would trigger an unaligned access. But as we would read only 1 byte, this is not the case. Looking at [1], we have : "At this point, it should be clear that accessing a single byte (u8 or char) will never cause an unaligned access, because all memory addresses are evenly divisible by one." I wanted to avoid potential performance cost related to using char (i.e u8) instead of int (i.e. u32). On some architecture this could require some shift or masking or whatever to "unpack" the values of S. [1]: https://www.kernel.org/doc/html/latest/core-api/unaligned-memory-access.html CJ > > - Eric >