Received: by 10.223.185.116 with SMTP id b49csp1136767wrg; Wed, 14 Feb 2018 12:11:16 -0800 (PST) X-Google-Smtp-Source: AH8x225FBGI0+PMrnpJcH5deIDlDkDLs/ZNvgT/uP0jlk8/RtbDTCnh+5YO5aek0rM4SYL12FiBe X-Received: by 2002:a17:902:12f:: with SMTP id 44-v6mr172308plb.403.1518639076792; Wed, 14 Feb 2018 12:11:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518639076; cv=none; d=google.com; s=arc-20160816; b=CfkO0X02YNNddmBH7PYXTyiwQerThlkYHADkwCteTz/IOsvwel4eulhqBQbRH2PjQE 5Ed/ERU9Eq/D0+PnFDbDKcCfClIW8RYrcePp7dKp0PoEMX/LsOrBIe4s/n5FfglFWPQ/ Md7G4/4J4puepbwJ+b59bbG4juExluCy/7aStGUo1La08I7Ek7VSOkSEf7ZN0cZFEL4W /i6aQgOK455mClQL2C9DPlW6yWjEkgYqSm0umw2XFkElFG7+AouaBNeEns9F9IrqWUb+ tttkYOM6QlUBapYrDt4e/VpVJb1c6ykNHeiizLOEUOSvkixroPq6FBFY9XYlD8FmsqCp xSSQ== 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=a5tCz7n3WTe1HHBXsxycZCid4Ze9BJgiNkpGlyyW4js=; b=SSUwXn7w07eYgqx1hqWWvwX1jt72EzvZGuQAXTNotKPrv3wCo/ihUnIjxSvQfYPFgv jDr4Q6FiSyWE5ce5Y+PB0UN+C3mrHbvoKr4Hcg82Qvh230Y4ExsKAEtQCxNfZht5HgVv XV/KWIEcxy1PTlDPTkBeZ5VxgbiBVGVD1tpsOizPnjo7d7gJLJvxpzn2gLd33tZjapT6 p+3asoZH0L6EGJWY2lWGG0s/wed+tPOGuKTUfhb4Hv2LDy3Y9MilXfVAxCEz6WO1+rSj 0QKtDwENpAKi8WWOsfUv0/DtVYkQXSyzwUvrQcmlImfWyFoBYSsQVd8KeDNSiKW0ZaoC dRiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=JNZscCJs; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=PtPeEuVH; 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 o21si1796284pfj.203.2018.02.14.12.11.01; Wed, 14 Feb 2018 12:11:16 -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=JNZscCJs; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=PtPeEuVH; 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 S1161475AbeBNRlN (ORCPT + 99 others); Wed, 14 Feb 2018 12:41:13 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:38474 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161447AbeBNRk6 (ORCPT ); Wed, 14 Feb 2018 12:40:58 -0500 Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1EHcCCh011806; Wed, 14 Feb 2018 09:40:44 -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=a5tCz7n3WTe1HHBXsxycZCid4Ze9BJgiNkpGlyyW4js=; b=JNZscCJsXdx8OzbOw2a47HMXJOFIVmwtyX6jPyFME3JhePxMkRDvBbbLB7Egl8nrZ2vJ xWvYNGal6SPCc90h2PWX/KW6ZrTZ7ZBz+QCa3aEQiPuWhjEk3EsW0nR/FQC2qnKAI0S4 HR8vkcRDySKhp0HcFeFp0QOaCOwWwE2LCS8= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2g4r6ys06a-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 14 Feb 2018 09:40:44 -0800 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.34) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 14 Feb 2018 12:40: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=a5tCz7n3WTe1HHBXsxycZCid4Ze9BJgiNkpGlyyW4js=; b=PtPeEuVHsm3VwZzUMWDHh0nldTHtzpfi7a2S7EALZ7ULjiQ34l/cY8/54NmSlhLiyRJovWhJ04WeNSLVuCLR04RaOuuzxW4HRBdnc2wjArYrJmXDtqkc2tKTeDgmkBl3zAG1p2Vrf4MfoUNXU47zcUKTltAE/nwC75mCppXRmVc= Received: from localhost (2620:10d:c090:180::622a) by CY4PR15MB1752.namprd15.prod.outlook.com (10.174.53.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.485.10; Wed, 14 Feb 2018 17:40:40 +0000 Date: Wed, 14 Feb 2018 09:40:31 -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 12/14] x86/crypto: aesni: Add fast path for > 16 byte update Message-ID: <20180214174031.GA62186@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: MWHPR20CA0011.namprd20.prod.outlook.com (10.171.151.149) To CY4PR15MB1752.namprd15.prod.outlook.com (10.174.53.142) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e980dea2-9b02-4415-8e7e-08d573d210bf X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060)(7193020);SRVR:CY4PR15MB1752; X-Microsoft-Exchange-Diagnostics: 1;CY4PR15MB1752;3:uTfg2SMLgCAuzNQwCDnQfFRgkHFOQO7FuWjae0jbW5Z7yD7NskAI7GxeGLe8z06PrqrWtpcZWmP4aroPW9CKx7JzAzGumU6opPdhmkffu9qt87Ydt+PLWVWU7HKcCnwQih3MdXLg0lppXSlIHpjhLG79mtTEsRgDk2LBsrGJcB9imLUHbYlaqSdTaScrU3N2r3o7J8+RTB5F4FXGFFr+I0NpyQHo0+RbIx3sgaRraZz1INLV3Beg8wOxFx82nNvu;25:ANOs8bH6TAoKepIMbPUPG4qwM6gKRlLaR7Buz3YgXxZoOrfvU60FOG1eDDq4Mzb0Gnfbwf2LOClcjoB8zuK8JFH1faxRfkXTUS4Se/qP3yU9hZQ7BJ6FDaRIBEWXdKY60OP1LgSMhUg9PuWZ63VjLIyKxuxHz4TjUXdGCr2mnOn57DEY7FblaJYsxxkwVriPcJLmlVHqWGbJ5c21dyFf5q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hzSoIpOIF5mlcZonwWPKSL4sm3Iup4rkRd4GERdAJolKVoDQhjtcR7Fmy1/VVaU00PdhUl+r7vX2y7cQwZ4IivfZUjx2rT84Tngc/k11xP9qs0oUD/svbCqRJhvsIuAInktZ3pBh/b57VPutYuvGZH7El6rdmYQp/eRNsWx1gYRVanrUSXAJqMFXL/dkypBuN2hVyz+jsmMzqrTqHdxjJDqasPhQA= 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)(10201501046)(93006095)(93001095)(3002001)(3231101)(11241501184)(944501161)(6041288)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(6072148)(201708071742011);SRVR:CY4PR15MB1752;BCL:0;PCL:0;RULEID:;SRVR:CY4PR15MB1752; X-Forefront-PRVS: 0583A86C08 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(979002)(6069001)(7916004)(376002)(39860400002)(39380400002)(396003)(346002)(366004)(199004)(189003)(305945005)(59450400001)(6496006)(52116002)(9686003)(52396003)(83506002)(54906003)(16586007)(58126008)(76176011)(386003)(33896004)(86362001)(16526019)(6486002)(8936002)(316002)(50466002)(97736004)(76506005)(7416002)(110136005)(81166006)(105586002)(53936002)(186003)(68736007)(4326008)(47776003)(1076002)(2950100002)(8676002)(33716001)(6666003)(81156014)(106356001)(2906002)(25786009)(23726003)(33656002)(15650500001)(5660300001)(6116002)(478600001)(7736002)(18370500001)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4PR15MB1752;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;CY4PR15MB1752;23:UgCuLQb3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+LjXc3TZHwArhwFWBX6knw+SowD4LyH9hfzNvx3HONYNme5wacAP1yL/klK5YdspjrxfcYXHTesU+SmsK6b7xO5OGxhhwlQ+v4bh3CSHcxkXzqpxZoWVscRgY/7UioQTRj+A=;24:TEeZ/OXKIxRcnK1E3UMeMwMVNgIh+UlVyzrWVNQTV6cBpTixvtZniSmFKgWgGVn1jH79NYi1opqRFtE/zIzVRBPmuZdkqYw3xOGcIRbxNRI=;7:lxuBrxpWsjf6JqFR+Ebr95p/mqoU/AUH0PYQo8oZuC6b5TCQ5WuwzRSH208qo31QmPezAOsxW3MGTW7xAqb/Lo0S9oQ4eW9O3VvFOC0FkSm2N5R/ugYUxnV9oiqi1Fs/KupN1shvDgpu3n9vMVhWEav2iIf4aiLgtmhLhybDnTV9SMKb8dxK5+cxLcXHmYxNr72HZTKxYwcKTBVsdYO7koJ5XWqOWGAly2kKVzAc7g4SiE2IiIwy0CaCS9dqpdbl SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY4PR15MB1752;20:MC/VDNAWLmWP0nq542Sls84eBiBf6vOKODUfqoap6U0xh+8vYQ9/5546WYPdAm+FuE2fJNb8bfS6u84VWQ4GJeMkn/cRm2uiNEXuhY8MCTakkGtYKsRA/ufVfuVzA8KFq2ZU85ENco89ALr0gZj8ob1sSsaRxDni4ds4mFtBBss= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2018 17:40:40.3015 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e980dea2-9b02-4415-8e7e-08d573d210bf X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR15MB1752 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 We can fast-path any < 16 byte read if the full message is > 16 bytes, and shift over by the appropriate amount. Usually we are reading > 16 bytes, so this should be faster than the READ_PARTIAL macro introduced in b20209c91e2 for the average case. Signed-off-by: Dave Watson --- arch/x86/crypto/aesni-intel_asm.S | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S index 398bd2237f..b941952 100644 --- a/arch/x86/crypto/aesni-intel_asm.S +++ b/arch/x86/crypto/aesni-intel_asm.S @@ -355,12 +355,37 @@ _zero_cipher_left_\@: ENCRYPT_SINGLE_BLOCK %xmm0, %xmm1 # Encrypt(K, Yn) movdqu %xmm0, PBlockEncKey(%arg2) + cmp $16, %arg5 + jge _large_enough_update_\@ + lea (%arg4,%r11,1), %r10 mov %r13, %r12 READ_PARTIAL_BLOCK %r10 %r12 %xmm2 %xmm1 + jmp _data_read_\@ + +_large_enough_update_\@: + sub $16, %r11 + add %r13, %r11 + + # receive the last <16 Byte block + movdqu (%arg4, %r11, 1), %xmm1 + sub %r13, %r11 + add $16, %r11 + + lea SHIFT_MASK+16(%rip), %r12 + # adjust the shuffle mask pointer to be able to shift 16-r13 bytes + # (r13 is the number of bytes in plaintext mod 16) + sub %r13, %r12 + # get the appropriate shuffle mask + movdqu (%r12), %xmm2 + # shift right 16-r13 bytes + PSHUFB_XMM %xmm2, %xmm1 + +_data_read_\@: lea ALL_F+16(%rip), %r12 sub %r13, %r12 + .ifc \operation, dec movdqa %xmm1, %xmm2 .endif -- 2.9.5