Received: by 10.223.185.116 with SMTP id b49csp1136423wrg; Wed, 14 Feb 2018 12:10:55 -0800 (PST) X-Google-Smtp-Source: AH8x225ec32bfIaMPNvDhCnoZd0vFh6X/3P86wHyrCwliKgQlRvExiHA4MVznRx8R5w46Lj6xeKj X-Received: by 10.98.161.7 with SMTP id b7mr250233pff.68.1518639055774; Wed, 14 Feb 2018 12:10:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518639055; cv=none; d=google.com; s=arc-20160816; b=g396v7LUvAfy1HWXAJ4cEnZ252YgLDUynYTDFLWH3k/zvZth8F9x3mzJifTlWKiMGy WnlrlVzAdteLNx7iIpGkQMFNE/tgHvPLnXhr8AyPxdv5y7fPShUYi8k/yqQlKqhoLhoU GRjGNZ0fIpu15d/3aS4OFrlQh48FgU2rbX5s2JS4VACDsPoNzVijm9y759Z+/yXri4sj ckhr8uWCoGvHb+jSRClvX6Ep1YrLhHvJEMJI0rEf7tP7uXVHxhMprW79ogCamFHM486o 7wL3fljgRvDnirTucKyXh79BHTmWtdXAzWgGh8hIJLWVlXoOoZRBuMAyaJOtfI/hJQmE AVsA== 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:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature:arc-authentication-results; bh=2NUlFlXDHQ0LB6pW5K+yT/zsB4TGP/FKF8AVgMEBqSg=; b=NVS4w3+aUbc/np8kNhZqvAgo7DE+yPUqGOctW48D8havtx+4J73kVjE5dCD5vNtXLP ib3nRh2F5iZS/M2EvN3fzonxa8p0SuQR0kc20pOhBScYejuXy/2zqGJqnTkqBIG422lE B9mZR5ReX7yaMkPd6fi1rEwBl49rkHq0WlvzVv5tIDo9jfFtdhHilE6/Huw6UmlfIb5V EcWgc+rFd0MYaLZMHApIKRxQUxa95PyV6qaZSZMKP4oD7xqRkAx7+jUjORYVyEfsGxJA ONBdu2eLNC2hUSxwWA2Xij1ILHJFaBAQVMoEcvYED9lYCehgC0iAikjSi/V0aS9d1fIi ndEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=YJr6N9VE; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=P6qw+QPK; 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 s196si229896pgc.129.2018.02.14.12.10.40; Wed, 14 Feb 2018 12:10:55 -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=YJr6N9VE; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=P6qw+QPK; 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 S1161391AbeBNRkH (ORCPT + 99 others); Wed, 14 Feb 2018 12:40:07 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:57590 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161343AbeBNRkD (ORCPT ); Wed, 14 Feb 2018 12:40:03 -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 w1EHYwa7012530; Wed, 14 Feb 2018 09:39:45 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=facebook; bh=2NUlFlXDHQ0LB6pW5K+yT/zsB4TGP/FKF8AVgMEBqSg=; b=YJr6N9VEX1C+FBIYSOg8cO3i3xUi6xAIuBHa4OPGzzMCdISaVT1oUyX6/v0xaZFzwdVN UCjbymQ4m87RhVAs6pJp1PAMv/x9ScDTL5BiHjZhuc0f4TjRnq88OvasvFrAiswaOBHB wXta7E80hX+SsoRHMaeQ/f5fqmmgYJ1efS8= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2g4sdw86f7-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 14 Feb 2018 09:39:44 -0800 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.25) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 14 Feb 2018 12:39:42 -0500 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=2NUlFlXDHQ0LB6pW5K+yT/zsB4TGP/FKF8AVgMEBqSg=; b=P6qw+QPK1/crLifmseUp0FZ1J9sRRPr5nrJ9lA//KTamvECBaySDW0q2pi4pmaa8DjahEcKOY2dq6ubk/rcO/I2cpJko8p0alLeCIQi2Rirgd5308JynTXwX/HNZxH57/IFEpuzO2jg88bscFoyrB5TYgrsrW1Ry6P1RFre7sgA= Received: from localhost (2620:10d:c090:180::622a) by MWHPR15MB1757.namprd15.prod.outlook.com (10.174.255.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.506.18; Wed, 14 Feb 2018 17:39:39 +0000 Date: Wed, 14 Feb 2018 09:39:36 -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 v2 07/14] x86/crypto: aesni: Split AAD hash calculation to separate macro Message-ID: <20180214173936.GA62048@davejwatson-mba> References: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0 (2016-04-01) X-Originating-IP: [2620:10d:c090:180::622a] X-ClientProxiedBy: CO2PR06CA0067.namprd06.prod.outlook.com (10.165.93.25) To MWHPR15MB1757.namprd15.prod.outlook.com (10.174.255.10) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1554bf1d-7b7c-4816-c84d-08d573d1ec7c X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020);SRVR:MWHPR15MB1757; X-Microsoft-Exchange-Diagnostics: 1;MWHPR15MB1757;3:r22lm0ofaZdlq+s5WW5cZ2TRSTJeir8v+JI8oWKpG9JfPZkw7GeEP5RoDJpYFR5jyRmejVVIL6U+NvLoxprigTyqniCDdXsNk90tfO9MiKt71G43yCpBidZHnPqHdZOtAf0sWULVbN5zVBXuI6AdSFMWUI/uKShFjDvLtabBjBEbLsyhdoLYZh9oBaxc1paDBg89AGfL1VgifuanJXIOtx6Jy3hKFpNMj6gbChsvCQgGEbw66rBHhD6f5aWtslXZ;25:xDgsRpU3hhaQHV7rvPozZVaAT5vspjKtuz4ea+9p7P6KsDDqbOerQwuO239GY1+Mc/PC6qC+beNmzexJ0eVVWU64c5beMgJ7EwjjJ57qTVnw/pzaB1jAXjMvK8p+mqUiYsfYHlFdJG98nilwQ/OG20/2S0HiNiy9pnQXfyJqMZGlLMvVUIeMbMIRXksdEOyTWY41xUNvtL4oBHi9WCmo+9GHBVIbmBFY2nedecppDaXK9sA3Zz1u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PG/h0EGhkihWDwQ4dF++CwFRqCUoPk/HTy3F+dr47jXuFHtaENu1NmEr71EigNRUZuTNbiAY6Uu/yLArQU9yZxakP21rI36ZnLU5mf1e2jyAxpSngqeIDEUh3tVgqRljtOAKe1OeK/IwJqd26Cc3zNSr3I43jMlzhAJEaVET3sRfx7mU7kMdQ7DY2HJenNtVY= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484)(266576461109395); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(3231101)(11241501184)(944501161)(6041288)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(6072148)(201708071742011);SRVR:MWHPR15MB1757;BCL:0;PCL:0;RULEID:;SRVR:MWHPR15MB1757; X-Forefront-PRVS: 0583A86C08 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6069001)(7916004)(39380400002)(39860400002)(376002)(346002)(396003)(366004)(199004)(189003)(54906003)(316002)(16586007)(6496006)(186003)(81156014)(8676002)(81166006)(58126008)(110136005)(7416002)(8936002)(52116002)(52396003)(16526019)(5660300001)(97736004)(68736007)(33716001)(6666003)(2950100002)(106356001)(23726003)(386003)(33656002)(33896004)(76176011)(105586002)(6116002)(1076002)(478600001)(2906002)(76506005)(25786009)(83506002)(9686003)(86362001)(53936002)(6486002)(47776003)(4326008)(305945005)(50466002)(7736002)(18370500001);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR15MB1757;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX: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;MWHPR15MB1757;23:RjkP7Q3J+NMsMMRnmMGy+Mu6jY2ZdU0rpc8JtZThd?= =?us-ascii?Q?lsiylcnbg8fwSeqzO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zY+nmF3pqII8kdCyQutXNFrP3GrVuJqfpLk1wvG79NhlM=;7:h98N4aOle7wbPkr+P5LzDoLLTH/HeCmIVA+MWlw0t6pzjebz4f1E2ufpyl5yH9kTZhYtNh8eHeY2TtQ3u8LLBFex2oSEjjDVVskkrfMzfRUNvwtBORF2ixhVPUJVgW/cg8cTh50lZpAI9TSg3TapyhJ72Kicenjmk7WFPFONOisKT5vxRkEwfL7zeAkF1bAMRCQLS72apjyNWvnz4Mf7qflCfJEIiqkgWpRk0FFfu2UJNAuFbVzHUJixY8eRsmD6 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR15MB1757;20:HaPA2HHVQfp5GvCh7bhEtz4eZ7Br7w5mg+cHeSWnTk26Egvx4C10VcrGE4jMo0QXDBCA4kiRWsnQmJZKXFlaBX2GSkUeUi0tux+a7QzKix4XzvtmJhyKCPW3BxjHdXoaY41UlAvynrt6OcI3RXAN9VrLDQR9gX8w8d3hEIzmY3U= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2018 17:39:39.4971 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1554bf1d-7b7c-4816-c84d-08d573d1ec7c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR15MB1757 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-14_07:,, 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 AAD hash only needs to be calculated once for each scatter/gather operation. Move it to its own macro, and call it from GCM_INIT instead of INITIAL_BLOCKS. Signed-off-by: Dave Watson --- arch/x86/crypto/aesni-intel_asm.S | 71 ++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S index 6c5a80d..58bbfac 100644 --- a/arch/x86/crypto/aesni-intel_asm.S +++ b/arch/x86/crypto/aesni-intel_asm.S @@ -229,6 +229,10 @@ ALL_F: .octa 0xffffffffffffffffffffffffffffffff mov %arg5, %r13 # %xmm13 holds HashKey<<1 (mod poly) and $-16, %r13 mov %r13, %r12 + + CALC_AAD_HASH %xmm13 %xmm0 %xmm1 %xmm2 %xmm3 %xmm4 \ + %xmm5 %xmm6 + mov %r13, %r12 .endm # GCM_ENC_DEC Encodes/Decodes given data. Assumes that the passed gcm_context @@ -496,51 +500,62 @@ _read_next_byte_lt8_\@: _done_read_partial_block_\@: .endm -/* -* if a = number of total plaintext bytes -* b = floor(a/16) -* num_initial_blocks = b mod 4 -* encrypt the initial num_initial_blocks blocks and apply ghash on -* the ciphertext -* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers -* are clobbered -* arg1, %arg3, %arg4, %r14 are used as a pointer only, not modified -*/ - - -.macro INITIAL_BLOCKS_ENC_DEC TMP1 TMP2 TMP3 TMP4 TMP5 XMM0 XMM1 \ -XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation - MOVADQ SHUF_MASK(%rip), %xmm14 - mov arg8, %r10 # %r10 = AAD - mov arg9, %r11 # %r11 = aadLen - pxor %xmm\i, %xmm\i - pxor \XMM2, \XMM2 +# CALC_AAD_HASH: Calculates the hash of the data which will not be encrypted. +# clobbers r10-11, xmm14 +.macro CALC_AAD_HASH HASHKEY TMP1 TMP2 TMP3 TMP4 TMP5 \ + TMP6 TMP7 + MOVADQ SHUF_MASK(%rip), %xmm14 + mov arg8, %r10 # %r10 = AAD + mov arg9, %r11 # %r11 = aadLen + pxor \TMP7, \TMP7 + pxor \TMP6, \TMP6 cmp $16, %r11 jl _get_AAD_rest\@ _get_AAD_blocks\@: - movdqu (%r10), %xmm\i - PSHUFB_XMM %xmm14, %xmm\i # byte-reflect the AAD data - pxor %xmm\i, \XMM2 - GHASH_MUL \XMM2, \TMP3, \TMP1, \TMP2, \TMP4, \TMP5, \XMM1 + movdqu (%r10), \TMP7 + PSHUFB_XMM %xmm14, \TMP7 # byte-reflect the AAD data + pxor \TMP7, \TMP6 + GHASH_MUL \TMP6, \HASHKEY, \TMP1, \TMP2, \TMP3, \TMP4, \TMP5 add $16, %r10 sub $16, %r11 cmp $16, %r11 jge _get_AAD_blocks\@ - movdqu \XMM2, %xmm\i + movdqu \TMP6, \TMP7 /* read the last <16B of AAD */ _get_AAD_rest\@: cmp $0, %r11 je _get_AAD_done\@ - READ_PARTIAL_BLOCK %r10, %r11, \TMP1, %xmm\i - PSHUFB_XMM %xmm14, %xmm\i # byte-reflect the AAD data - pxor \XMM2, %xmm\i - GHASH_MUL %xmm\i, \TMP3, \TMP1, \TMP2, \TMP4, \TMP5, \XMM1 + READ_PARTIAL_BLOCK %r10, %r11, \TMP1, \TMP7 + PSHUFB_XMM %xmm14, \TMP7 # byte-reflect the AAD data + pxor \TMP6, \TMP7 + GHASH_MUL \TMP7, \HASHKEY, \TMP1, \TMP2, \TMP3, \TMP4, \TMP5 + movdqu \TMP7, \TMP6 _get_AAD_done\@: + movdqu \TMP6, AadHash(%arg2) +.endm + +/* +* if a = number of total plaintext bytes +* b = floor(a/16) +* num_initial_blocks = b mod 4 +* encrypt the initial num_initial_blocks blocks and apply ghash on +* the ciphertext +* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers +* are clobbered +* arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified +*/ + + +.macro INITIAL_BLOCKS_ENC_DEC TMP1 TMP2 TMP3 TMP4 TMP5 XMM0 XMM1 \ + XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation + + movdqu AadHash(%arg2), %xmm\i # XMM0 = Y0 + xor %r11, %r11 # initialise the data pointer offset as zero # start AES for num_initial_blocks blocks -- 2.9.5