Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2324475pxk; Mon, 14 Sep 2020 10:13:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6hlDXG8s/DqEUsVQlD8ni6AemKP65eEbYxk8uMCkFSy0+KrrR4OyvVgZnvn5rVE2GdrDW X-Received: by 2002:a17:907:2078:: with SMTP id qp24mr16947853ejb.500.1600103619295; Mon, 14 Sep 2020 10:13:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600103619; cv=pass; d=google.com; s=arc-20160816; b=lzT5tZ/EWT7AVyYChc0PLTqao5CS2fM5hcvQT1W4vsL83OE8MlPe8H8kwD64mJ6kAI I5jrIokKUi+2SrcAEIULRJODVuqE2hZf5hiIj3uBLunRt3RzuQrubyIRnDi5OnRCSV/G LbSH+vRFuKCH9Dvyk+mfxsPVLtiQZejZhU2DWqkt0tJS6hlAdO5IDmndcx2h/I7Leyt5 9J5Z7XGD4cKa/KhFTy1MoK2toiVJlHmn7deNFLSXcfodmNLKP9TiibpYyOEDsn8vqSkX 6rlZ3wVK37FNYEVGaahESLeMsh83YjvJto4rBAX2T0dPixs+WvT/KBCBKzB8eOLLawJF TBGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:in-reply-to:user-agent:date:message-id:from :references:cc:to:subject:dkim-signature; bh=+lEMaqZPAGmfUmG53kQ2EAfcxgjdj7Bo38ItSZvEgZA=; b=ENM2ayZUCa+vm74/vEyiykWt1/1O28NH+mtfJt9ENLH8+LyWwLeIybqDsjoSagseBb yyyV9PoC7mF9TamRS4uoWFlc6yiv1fNs/8LlqqkVBccoyxOgEI1wo7K7bMUd8mjVl2vU HdsTLbKiCU6Wz3QShthzjvLq4GuBQIvVdhqBkQPOwnHgcJD7ldI3w+INCjTDe2i9XNns jdF2ADlnPJdDzKyClGF/YCvVPJ91hXtVKvfi/B2lzIwzfsCE8ELIXjAt3J9LEDj4jqYn UnzAo2/bFvwQd7OAXfeYYjZkUWjmlu7fFpSL56f1GWR6blD3JuUC8Paq5r1sQg+/jA3B 9O0g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=bNVDaxYO; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si7555078edn.2.2020.09.14.10.13.08; Mon, 14 Sep 2020 10:13:39 -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; dkim=pass header.i=@nxp.com header.s=selector2 header.b=bNVDaxYO; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726162AbgINRMf (ORCPT + 99 others); Mon, 14 Sep 2020 13:12:35 -0400 Received: from mail-eopbgr140079.outbound.protection.outlook.com ([40.107.14.79]:39006 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726033AbgINRMW (ORCPT ); Mon, 14 Sep 2020 13:12:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g79RKX/IGLkC3Ym/9GmhEx96UeZAZwA/kn4SuHHcowzXtyNBFIsWtAE2xhxY5hOR6xJE5WY2ohzIpQjGyhhUjhNnIMswm8fI0trKVlUTaj8j+oEUyz9DHnL3LuBqlu/xA8Ah5u73LFxH8cwR6a7/ZrfteaMm06vAiTStDY+JHFP0EFXik58mPLgPSC8gSV30kNtAuwyI0PA9OYxnuW1I1PBQUVOJhyUzg9qmG0jAggPQFM9OqJsoZfs4Be+ZGSSAcTUT6Z+G7cQG+B7r/LJhEw4KnvtdR1d1+HcvJDeFD168wV3OKbz6AWww5S18Vk3DLb5Aos5GCGf3u1JBHheWsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+lEMaqZPAGmfUmG53kQ2EAfcxgjdj7Bo38ItSZvEgZA=; b=RDezNg4WSzmJ+7SRQF8DIHFjx85ZIpJEzyRCoJBMzehUJOtBc8NDGbzuI9W3jEv8OB9U1VvDdTvo0kGie/Y9WKo9X6Jv+smR70jvFLcHGhJnOUi5Q/tHbfsCPhDSM2UIL2krVrSCf5U73PQBFqnfHN8rwiwGxTh4k1qof5Pa0pwfno845n2BN3hLE2TnNDxikEqmugewiRfzHh1XwHRFgsNuY4GGdszuKdsJFzfMTWqhGtJqwtE2UwOs4PiROYKP5XBzofj/LIOrr+wVGjWt9Y81K0q3tLXKCSDIyH6DPZExz/6QzZp6eNKjKEsx1KQ0ibsNBAQnoaQmKCqeFYGXuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+lEMaqZPAGmfUmG53kQ2EAfcxgjdj7Bo38ItSZvEgZA=; b=bNVDaxYOP3DSkLe6eHyQk7t3+IL/dRnGO+aYpeIyEiod3xvPBngVWYkTv17J/LND2rtHg/exWsfEwcMyVDjHzZS+AEKId9WR4uL2ycom2PzdiBiejFfSMvKxslfraDIpVn+9l03MpGLSJv6r+ALeTGvFpvvyaP7t/F+H+G9vaXo= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB4046.eurprd04.prod.outlook.com (2603:10a6:803:4d::29) by VI1PR04MB4047.eurprd04.prod.outlook.com (2603:10a6:803:40::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Mon, 14 Sep 2020 17:12:17 +0000 Received: from VI1PR04MB4046.eurprd04.prod.outlook.com ([fe80::847a:fcdb:3b92:7a7d]) by VI1PR04MB4046.eurprd04.prod.outlook.com ([fe80::847a:fcdb:3b92:7a7d%5]) with mapi id 15.20.3370.019; Mon, 14 Sep 2020 17:12:17 +0000 Subject: Re: [PATCH RESEND 1/9] crypto: caam/jr - add fallback for XTS with more than 8B IV To: Ard Biesheuvel Cc: Herbert Xu , "Andrei Botila (OSS)" , Aymen Sghaier , "David S. Miller" , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20200806163551.14395-1-andrei.botila@oss.nxp.com> <20200806163551.14395-2-andrei.botila@oss.nxp.com> <20200821034651.GA25442@gondor.apana.org.au> <20200908221019.GA23497@gondor.apana.org.au> <67159207-1082-48be-d085-971a84b525e0@nxp.com> From: =?UTF-8?Q?Horia_Geant=c4=83?= Message-ID: <38f9904b-5bf7-ea99-ed8a-27cb49f405bd@nxp.com> Date: Mon, 14 Sep 2020 20:12:14 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-ClientProxiedBy: AM4PR05CA0036.eurprd05.prod.outlook.com (2603:10a6:205::49) To VI1PR04MB4046.eurprd04.prod.outlook.com (2603:10a6:803:4d::29) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.0.129] (78.97.206.147) by AM4PR05CA0036.eurprd05.prod.outlook.com (2603:10a6:205::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16 via Frontend Transport; Mon, 14 Sep 2020 17:12:16 +0000 X-Originating-IP: [78.97.206.147] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a9860642-231e-407d-99ae-08d858d1553a X-MS-TrafficTypeDiagnostic: VI1PR04MB4047: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CPxR1hqQFG5KPQZWLLjzheieMGgeIisxN4n/+wb5Cz6T/VFM9/w++KCef+OA95kpyzcxtMaUlLQ2dBAvJp4AJWiWV5fYU1YIVtLxgOFea2iQGoh3GUG4A5Sk0Mg1hyi/euy77jkZ+qJQJ/cOYk9iTfCZgGllSXhnyaj68lb3kmK5GOegLT9/f6HG7HKMMFj2RsOBzkivLs8xy/riYj4kwjlAz/B1cRnL0teE2Fk8p5ykej2mOym4kKSVL7sF1NPkJZQFqozeeQvOkRW6R1toj+ykUhSGXIixJVomw/Lx4+zy72smAmdEVCD6XDbnweDIk6XXTdrHau3xPz3avbedn++BxVkJ76um1ZrwJXqCYDKA6LKJTs7qGWrLlBtm40Zk X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB4046.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(136003)(346002)(366004)(39860400002)(376002)(31696002)(4326008)(16576012)(52116002)(26005)(66476007)(66556008)(86362001)(53546011)(66946007)(83380400001)(54906003)(956004)(5660300002)(2616005)(6486002)(478600001)(186003)(16526019)(8676002)(6916009)(8936002)(316002)(36756003)(2906002)(31686004)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: cF7IHlGBwd/Yc2TeiHRHti3q85kp1oxGHTG+CesXv2dCTm2dgVZAtgorm1mrcOfoIoUKe629lTY47muUTNqPHfCf/fSb45RIxUpKOT0qutDoDUcYq6rEk1dMz39k8COWEbzD5KuC9wE/uqhnmo32egk0//ue2N83CUZaLrtIG3iFO2ZQvig9jQBTPlQ40qlL52KYqbAF1NBhGRZ/WCQbLCYwHPmvRbvmH+AZwOt5uN0GXWR+lrtgEAkl0HGWQz+qNroV2N9f3dwhBe2aHxOXGEWUr1krzcssRFbvq9VqRdbXTyKXS8APR9SUUosyvQ4Hwp20kPryNLTVeF68BGNfehXWOpm0x4YB507DMCDEnwN+Ofz+vC1oauWwcUQZ8Oq8gTHXCIhKpeR5R4pHGicD3hcKN1ztu6wdk2h7irGj79rkYCItjFtzDRffI2Jf2qwSFnhfKFkpVF9HnYmsxNsvitLaDdh3eti2vqAUsmvkkae9fqGK91xndDrkLnN+0wjtr5FoRaJjr2W3RlQtX19bOzRfzcX+mM2JKZYxGple1onJOIBkUWeRw3LYdt8PLZVsKy/rknWFPPOUvO5II3ER3L2jSauIP5I0+I0zu77EMQkFzE6fdd/p6dGvzsWzAzyDI00/ud/cKprFzGdXAtuJDw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a9860642-231e-407d-99ae-08d858d1553a X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB4046.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2020 17:12:17.5877 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TAQ0T3thXMUC77FsVJdVhd4xCCGjh4xohxCRVqZ8asTk+Pf3KGdWoIyCnhDCSKL9kan8KsEPIqNCBOfz+09/6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4047 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 9/14/2020 7:28 PM, Ard Biesheuvel wrote: > On Mon, 14 Sep 2020 at 19:24, Horia Geantă wrote: >> >> On 9/9/2020 1:10 AM, Herbert Xu wrote: >>> On Tue, Sep 08, 2020 at 01:35:04PM +0300, Horia Geantă wrote: >>>> >>>>> Just go with the get_unaligned unconditionally. >>>> >>>> Won't this lead to sub-optimal code for ARMv7 >>>> in case the IV is aligned? >>> >>> If this should be optimised in ARMv7 then that should be done >>> in get_unaligned itself and not open-coded. >>> >> I am not sure what's wrong with avoiding using the unaligned accessors >> in case data is aligned. >> >> Documentation/core-api/unaligned-memory-access.rst clearly states: >> These macros work for memory accesses of any length (not just 32 bits as >> in the examples above). Be aware that when compared to standard access of >> aligned memory, using these macros to access unaligned memory can be costly in >> terms of performance. >> >> So IMO it makes sense to use get_unaligned() only when needed. >> There are several cases of users doing this, e.g. siphash. >> > > For ARMv7 code, using the unaligned accessors unconditionally is fine, > and it will not affect performance. > > In general, when CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is defined, > you can use the unaligned accessors. If it is not, it helps to have > different code paths. > arch/arm/include/asm/unaligned.h doesn't make use of linux/unaligned/access_ok.h, even if CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is set. I understand the comment in the file, however using get_unaligned() unconditionally takes away the opportunity to generate optimized code (using ldrd/ldm) when data is aligned. > This is a bit murky, and through the years, the interpretation of > unaligned-memory-access.rst has shifted a bit, but in this case, it > makes no sense to make the distinction. > Thanks, Horia