Received: by 10.223.185.116 with SMTP id b49csp2572569wrg; Mon, 12 Feb 2018 11:51:03 -0800 (PST) X-Google-Smtp-Source: AH8x225VlwZ/HjJlUgWAY3J1wXd24ALOH4I0ZYl35Cn2y0QdtRdtP88nFJOHYdo/zI1ZQOapF1xR X-Received: by 2002:a17:902:570f:: with SMTP id k15-v6mr11440615pli.321.1518465063004; Mon, 12 Feb 2018 11:51:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518465062; cv=none; d=google.com; s=arc-20160816; b=XBZN4e+/Hr97DbtRJa5MOCsZDETWwlHT80p7SlzMR/uFUuo3AWvyWnonTUaVBtuieR yY00qz8ktyh71MXA6UT8QF5dt6o6eZbTraYs4+DD77VjW7SZG7U5JSRu8IpjngFLKqtH hrYHsT+iHdgx28rLAkAR9CXwm5MFvARUaVsKOM6C9FAqLXgWDZ1coMFxmCh1vHPvmy9K s7VXm/TCxDEFWlXuauOro9BxajbvHOF+qXNlvyRBbrGdw9BOPHhbXj6UEyQMjIIop9LB LssvFNHdZc7pYastOCwrb5qvtAXpUFbuLippVDggKWVEJbqa3Ode0QL5MfLk3cUM9e3F BR4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature:dkim-signature :arc-authentication-results; bh=GnyvC8fCukxbq4zbuAzyvEFrDKxYJqPprEwiNmqMZys=; b=idxRhQ5yGef8Tn36IQIrwcY0nHT+3acLuDhnyutnyiuw4Cl34kPm1eVov+v7W1QXM9 mHynlXgrGPg2rrWgi846uKZaSEIcqeWq2UrfHskuE21LTAn8sf3K3uDxDIRWcR7ON+xA G3UBtkbGCbwK2E4LN2jNGY0j1r8whRvZE4UcQocXjOdMIOFNV/7W48iu2N9iNRpAW8Y2 xD0RjgvvTh7CsBRAr3890KhK4xVWQcUYQwyg1pBX4vjRbWAj7SKP+0WWldKn4W3Fs2fY Kw/duiWg+TkIzuuFZCTjF7nJ0WL3hgj7Ad9TpUSJP+d6hcibJTTJB7kTjgPVpQyg/1CU ZNnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=Rt6Ubgyi; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=aUBngr+t; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t137si201427pgb.736.2018.02.12.11.50.48; Mon, 12 Feb 2018 11:51:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=Rt6Ubgyi; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=aUBngr+t; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752536AbeBLTsf (ORCPT + 99 others); Mon, 12 Feb 2018 14:48:35 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:59092 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751048AbeBLTsc (ORCPT ); Mon, 12 Feb 2018 14:48:32 -0500 Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1CJjAjM020246; Mon, 12 Feb 2018 11:47:49 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=facebook; bh=GnyvC8fCukxbq4zbuAzyvEFrDKxYJqPprEwiNmqMZys=; b=Rt6UbgyiBhhqeL5T7ReiznOa486bht/6q6sLeL4ork2BQYtcAFnU99F9hM2Nh9N/E6ZU ftHCGpxpdpwGZ8na1IB9QAAsRs1VsVYcPHjRARrrVoJI5l+N/ryC2EKg0CsvJYq2PY6u LCLZ1gvi37CylC7Vo9CZFMIJ3rQp0SOIteg= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2g3dtn8t90-2 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 12 Feb 2018 11:47:49 -0800 Received: from NAM01-BY2-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.19) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 12 Feb 2018 11:47:47 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=GnyvC8fCukxbq4zbuAzyvEFrDKxYJqPprEwiNmqMZys=; b=aUBngr+tXx0OdKqBCh5MxUIZk7sOXUDFLWxRmeaWQWP9TYOu2t6Q8jWB46bOiKziUrhiRS8CJu6hJILO97lsL3UVgBVixgcTfmgAs1E0G/74fvKIl3ITkh57Q7qokgagQUePDuGvDbsjwdmz+EN+3puKtlpuo8ripFgDcCDhyTo= Received: from localhost (2620:10d:c090:200::6:842f) by BN6PR15MB1746.namprd15.prod.outlook.com (10.174.238.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.485.10; Mon, 12 Feb 2018 19:47:44 +0000 Date: Mon, 12 Feb 2018 11:47:41 -0800 From: Dave Watson To: Herbert Xu , Junaid Shahid , Steffen Klassert , CC: "David S. Miller" , Hannes Frederic Sowa , Tim Chen , Sabrina Dubroca , , Stephan Mueller , Ilya Lesokhin Subject: [PATCH 00/14] x86/crypto gcmaes SSE scatter/gather support Message-ID: <20180212194741.GA59290@davejwatson-mba.local> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline User-Agent: Mutt/1.6.0 (2016-04-01) X-Originating-IP: [2620:10d:c090:200::6:842f] X-ClientProxiedBy: MWHPR20CA0018.namprd20.prod.outlook.com (10.171.151.156) To BN6PR15MB1746.namprd15.prod.outlook.com (10.174.238.136) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 88c30968-95d4-44fb-feb3-08d572517c94 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020);SRVR:BN6PR15MB1746; X-Microsoft-Exchange-Diagnostics: 1;BN6PR15MB1746;3:7cvmua0yJubrDrUIwcB+t/VK4mn46lSYhWMLS6syIEn4i3LOwoAMbwYuSPYeke4vYSkBdzlcu7uZ4KMWI3JPmUfItemrm4RtJ1viBod2vXx4/0GOmhzKNXyeYjovoWBzCyo6W5lmP1s0GjPgSns4oUCVfdyROzifb2UOXYixPIq40L13N0t02o4DG1bKaqy2BkyleFTMRwn78zgiGewgn5oV48rKKRg6iuvV2bz8QNVgnrTywW6bcdz9adIEbV0A;25:d1sDZfNI5gf19VpuKNrLlqzteb5UwVmDwXoer1tHxImP86Kt0uGOjoIFTlM6lCf4m/uW/PyoVoKCz+bQ1K4ZjwyKtr1eOCyftQv+zh9Bbcv3nPHvWyrtRR7SE1/NMfqIMFNUrOJyH2UH4P7MrXfUtrHyFzFN+WIjUOCC1WlohRrOhxtkx3FGPR+50izghKiEEsqPzl8EDaRA1kfV6vyNyXxel6Bq9bBMNO4j9gsZEtnL0tqqzsJxGBUtFSR1PHzLgDB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gAKh+ktzrjbsjC4wHKBeBHsfJibwOHyKBHaH6ddCo6qpPog0U/9inAKPcuakug1XfQIAImjXHhYpZu1e9vL/qPB5EC5taBT/nGYtRHreuAf6TsiI4REriz1kbF8vvj+7AMLhQ52zpfm2SZ7hhRzSRNnzprGgTpvj X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(266576461109395); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(3231101)(11241501184)(2400082)(944501161)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:BN6PR15MB1746;BCL:0;PCL:0;RULEID:;SRVR:BN6PR15MB1746; X-Forefront-PRVS: 0581B5AB35 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6069001)(396003)(346002)(376002)(39860400002)(39380400002)(366004)(189003)(199004)(54906003)(1076002)(305945005)(68736007)(6666003)(7416002)(7736002)(6116002)(98436002)(81156014)(110136005)(58126008)(83506002)(16586007)(5660300001)(33656002)(8936002)(52396003)(81166006)(2906002)(52116002)(6496006)(6486002)(47776003)(316002)(8676002)(50466002)(186003)(16526019)(86362001)(97736004)(76506005)(23726003)(33896004)(106356001)(9686003)(478600001)(59450400001)(4326008)(53936002)(25786009)(386003)(105586002)(18370500001);DIR:OUT;SFP:1102;SCL:1;SRVR:BN6PR15MB1746;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN6PR15MB1746;23:UOK4H89i4/PvalBtAXjsOBPN1U1fAz5utHyWZCcnU?= =?us-ascii?Q?1ft0spbJRofngQGgL/R2GXQI1ykLNh9QrPmg1LNLIXpAsFe2rvjY9Fivc2yu?= =?us-asc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K1CPEJCB7fUdcSWTpJsUdqVlnQ/3kG85l33UlHOhil2Zt2x+tbVbR/YMmnb1tjn4RvqWOnFEUjMSrC02qbz8+b35YK9ZfiI0qeqa0SksCS7rzwa6MIN9wmCOJvn7jiYcEeujAAtRNWlDUKvW/NZnrxJFGLGoZmLF86uBOmsV4zrZtiRWB0G42qxsufT1BpBGC SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN6PR15MB1746;20:PRuUrnIYhFvtgLpJlTOa9/TRlo519vLP0vzv7vHi/UBQ7W9UYDnl20FRmDo6xHEr20MKejxDjuRggpo+1JEvYLns1fZwTyV154ZYCQp5y53bc+XpMrs7QKF9FmzBF/KbyjkEgj23y6dQxehDopwakbL6Q+Hf/otw2VLXQK7WgVE= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2018 19:47:44.8662 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 88c30968-95d4-44fb-feb3-08d572517c94 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR15MB1746 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-12_08:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch set refactors the x86 aes/gcm SSE crypto routines to support true scatter/gather by adding gcm_enc/dec_update methods. The layout is: * First 5 patches refactor the code to use macros, so changes only need to be applied once for encode and decode. There should be no functional changes. * The next 6 patches introduce a gcm_context structure to be passed between scatter/gather calls to maintain state. The struct is also used as scratch space for the existing enc/dec routines. * The last 2 set up the asm function entry points for scatter gather support, and then call the new routines per buffer in the passed in sglist in aesni-intel_glue. Testing: asm itself fuzz tested vs. existing code and isa-l asm. Ran libkcapi test suite, passes. Passes my TLS tests. IPSec or testing of other aesni users would be appreciated. perf of a large (16k messages) TLS sends sg vs. no sg: no-sg 33287255597 cycles 53702871176 instructions 43.47% _crypt_by_4 17.83% memcpy 16.36% aes_loop_par_enc_done sg 27568944591 cycles 54580446678 instructions 49.87% _crypt_by_4 17.40% aes_loop_par_enc_done 1.79% aes_loop_initial_5416 1.52% aes_loop_initial_4974 1.27% gcmaes_encrypt_sg.constprop.15 Dave Watson (14): x86/crypto: aesni: Merge INITIAL_BLOCKS_ENC/DEC x86/crypto: aesni: Macro-ify func save/restore x86/crypto: aesni: Add GCM_INIT macro x86/crypto: aesni: Add GCM_COMPLETE macro x86/crypto: aesni: Merge encode and decode to GCM_ENC_DEC macro x86/crypto: aesni: Introduce gcm_context_data x86/crypto: aesni: Split AAD hash calculation to separate macro x86/crypto: aesni: Fill in new context data structures x86/crypto: aesni: Move ghash_mul to GCM_COMPLETE x86/crypto: aesni: Move HashKey computation from stack to gcm_context x86/crypto: aesni: Introduce partial block macro x86/crypto: aesni: Add fast path for > 16 byte update x86/crypto: aesni: Introduce scatter/gather asm function stubs x86/crypto: aesni: Update aesni-intel_glue to use scatter/gather arch/x86/crypto/aesni-intel_asm.S | 1414 ++++++++++++++++++------------------ arch/x86/crypto/aesni-intel_glue.c | 263 ++++++- 2 files changed, 932 insertions(+), 745 deletions(-) -- 2.9.5