From patchwork Wed Feb 24 16:29:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Poimboeuf X-Patchwork-Id: 386933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32BB7C4332B for ; Wed, 24 Feb 2021 16:33:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0B4764EF1 for ; Wed, 24 Feb 2021 16:33:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234658AbhBXQdA (ORCPT ); Wed, 24 Feb 2021 11:33:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52682 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234670AbhBXQbU (ORCPT ); Wed, 24 Feb 2021 11:31:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614184182; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EoUyH4tB9klRBpxMdtA+3ioOLqqMzutoUlyl1zVvLUo=; b=FwHdKS8qAz0NdBiPfjhY0KbbLsiy3QLibsvAP2VSYQVSNshBA/O0F9MnldGRJD7McszHng j1MkNzxzOUTDiiUp1OlGUMi02fJ5BzHv/60BjMVUhZe66/i/490eJlyM6mmPX5RfNwYqnU z3vKdX0kXaINj0tSXupJlCFx+F7VcKE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-166-zYRW8OXmOjWnjx0U8NBX4w-1; Wed, 24 Feb 2021 11:29:38 -0500 X-MC-Unique: zYRW8OXmOjWnjx0U8NBX4w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 655BF801965; Wed, 24 Feb 2021 16:29:36 +0000 (UTC) Received: from treble.redhat.com (ovpn-118-134.rdu2.redhat.com [10.10.118.134]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2877960862; Wed, 24 Feb 2021 16:29:35 +0000 (UTC) From: Josh Poimboeuf To: x86@kernel.org, Herbert Xu Cc: linux-kernel@vger.kernel.org, Miroslav Benes , Peter Zijlstra , Eric Biggers , Ard Biesheuvel , Sami Tolvanen , linux-crypto@vger.kernel.org, "David S . Miller" Subject: [PATCH 03/13] x86/crypto/aesni-intel_avx: Fix register usage comments Date: Wed, 24 Feb 2021 10:29:16 -0600 Message-Id: <8655d4513a0ed1eddec609165064153973010aa2.1614182415.git.jpoimboe@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Fix register usage comments to match reality. Signed-off-by: Josh Poimboeuf --- arch/x86/crypto/aesni-intel_avx-x86_64.S | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/x86/crypto/aesni-intel_avx-x86_64.S b/arch/x86/crypto/aesni-intel_avx-x86_64.S index 4fdf38e92d51..188f1848a730 100644 --- a/arch/x86/crypto/aesni-intel_avx-x86_64.S +++ b/arch/x86/crypto/aesni-intel_avx-x86_64.S @@ -286,7 +286,7 @@ VARIABLE_OFFSET = 16*8 # combined for GCM encrypt and decrypt functions # clobbering all xmm registers -# clobbering r10, r11, r12, r13, r14, r15 +# clobbering r10, r11, r12, r13, r15, rax .macro GCM_ENC_DEC INITIAL_BLOCKS GHASH_8_ENCRYPT_8_PARALLEL GHASH_LAST_8 GHASH_MUL ENC_DEC REP vmovdqu AadHash(arg2), %xmm8 vmovdqu HashKey(arg2), %xmm13 # xmm13 = HashKey @@ -988,7 +988,7 @@ _partial_block_done_\@: ## num_initial_blocks = b mod 4# ## encrypt the initial num_initial_blocks blocks and apply ghash on the ciphertext ## r10, r11, r12, rax are clobbered -## arg1, arg3, arg4, r14 are used as a pointer only, not modified +## arg1, arg2, arg3, arg4 are used as pointers only, not modified .macro INITIAL_BLOCKS_AVX REP num_initial_blocks T1 T2 T3 T4 T5 CTR XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 T6 T_key ENC_DEC i = (8-\num_initial_blocks) @@ -1223,7 +1223,7 @@ _initial_blocks_done\@: # encrypt 8 blocks at a time # ghash the 8 previously encrypted ciphertext blocks -# arg1, arg3, arg4 are used as pointers only, not modified +# arg1, arg2, arg3, arg4 are used as pointers only, not modified # r11 is the data offset value .macro GHASH_8_ENCRYPT_8_PARALLEL_AVX REP T1 T2 T3 T4 T5 T6 CTR XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 T7 loop_idx ENC_DEC @@ -1936,7 +1936,7 @@ SYM_FUNC_END(aesni_gcm_finalize_avx_gen2) ## num_initial_blocks = b mod 4# ## encrypt the initial num_initial_blocks blocks and apply ghash on the ciphertext ## r10, r11, r12, rax are clobbered -## arg1, arg3, arg4, r14 are used as a pointer only, not modified +## arg1, arg2, arg3, arg4 are used as pointers only, not modified .macro INITIAL_BLOCKS_AVX2 REP num_initial_blocks T1 T2 T3 T4 T5 CTR XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 T6 T_key ENC_DEC VER i = (8-\num_initial_blocks) @@ -2178,7 +2178,7 @@ _initial_blocks_done\@: # encrypt 8 blocks at a time # ghash the 8 previously encrypted ciphertext blocks -# arg1, arg3, arg4 are used as pointers only, not modified +# arg1, arg2, arg3, arg4 are used as pointers only, not modified # r11 is the data offset value .macro GHASH_8_ENCRYPT_8_PARALLEL_AVX2 REP T1 T2 T3 T4 T5 T6 CTR XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 T7 loop_idx ENC_DEC From patchwork Wed Feb 24 16:29:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Poimboeuf X-Patchwork-Id: 386934 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B968CC433E6 for ; Wed, 24 Feb 2021 16:33:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 696F364EF1 for ; Wed, 24 Feb 2021 16:33:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234451AbhBXQcw (ORCPT ); Wed, 24 Feb 2021 11:32:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49072 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234708AbhBXQbT (ORCPT ); Wed, 24 Feb 2021 11:31:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614184187; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BGP1D+fN8RYYb6r5ixsRX3SnpxjoEGyiGCXv8vP6/MA=; b=AczzPNyftfCwbLDC90SetT5H8nj4WjjNqt/A9Hb7otKshDaBUJp1agLN5P2Pn3oEIL6alz 1RNInWk+MVSEkhbL9Mb2xsfwn2lMCV9zIAJ+/Urah0olJ3MRWPGyWl4K74NtuKSRMOpBME eZJuTQC7hWqtqMK5ITyWXZIZs8tbFZA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-573-EpMdybTKMISHxWLyChJ06A-1; Wed, 24 Feb 2021 11:29:43 -0500 X-MC-Unique: EpMdybTKMISHxWLyChJ06A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 67D3179EC3; Wed, 24 Feb 2021 16:29:41 +0000 (UTC) Received: from treble.redhat.com (ovpn-118-134.rdu2.redhat.com [10.10.118.134]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13EF960CE7; Wed, 24 Feb 2021 16:29:39 +0000 (UTC) From: Josh Poimboeuf To: x86@kernel.org, Herbert Xu Cc: linux-kernel@vger.kernel.org, Miroslav Benes , Peter Zijlstra , Eric Biggers , Ard Biesheuvel , Sami Tolvanen , linux-crypto@vger.kernel.org, "David S . Miller" Subject: [PATCH 06/13] x86/crypto/crc32c-pcl-intel: Standardize jump table Date: Wed, 24 Feb 2021 10:29:19 -0600 Message-Id: <5357a039def90b8ef6b5874ef12cda008ecf18ba.1614182415.git.jpoimboe@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Simplify the jump table code so that it resembles a compiler-generated table. This enables ORC unwinding by allowing objtool to follow all the potential code paths. Signed-off-by: Josh Poimboeuf --- arch/x86/crypto/crc32c-pcl-intel-asm_64.S | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S index 884dc767b051..ac1f303eed0f 100644 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S @@ -53,7 +53,7 @@ .endm .macro JMPTBL_ENTRY i -.word crc_\i - crc_array +.quad crc_\i .endm .macro JNC_LESS_THAN j @@ -168,10 +168,7 @@ continue_block: xor crc2, crc2 ## branch into array - lea jump_table(%rip), %bufp - movzwq (%bufp, %rax, 2), len - lea crc_array(%rip), %bufp - lea (%bufp, len, 1), %bufp + mov jump_table(,%rax,8), %bufp JMP_NOSPEC bufp ################################################################ From patchwork Wed Feb 24 16:29:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Poimboeuf X-Patchwork-Id: 386932 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D815EC433E0 for ; Wed, 24 Feb 2021 16:33:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90D0164F00 for ; Wed, 24 Feb 2021 16:33:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234680AbhBXQcz (ORCPT ); Wed, 24 Feb 2021 11:32:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29740 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234717AbhBXQbU (ORCPT ); Wed, 24 Feb 2021 11:31:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614184186; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eOHOjeFiMtzP9OGzSSHIXYUBmM19lsPz/JuM7QoJPBE=; b=TgLQCDy2bgsRVBHmbKeIYGLmStUd1Ogi9NQAC3rVtSH+4TgAP7LSwW4YytPKZu6lJd0yE5 kp2dHgzV08+385U7V0axuoodY9T9HAPCgEr3WcYHVU6gJGmDajbVs5PQeU0+O6zpdNQYlK 8Md705a3C2MuHgD5lU6ZycnO49JbqTE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-41-1h4Bbw7aMJuFblwKAqeTwQ-1; Wed, 24 Feb 2021 11:29:45 -0500 X-MC-Unique: 1h4Bbw7aMJuFblwKAqeTwQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0F3FF79EC1; Wed, 24 Feb 2021 16:29:43 +0000 (UTC) Received: from treble.redhat.com (ovpn-118-134.rdu2.redhat.com [10.10.118.134]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA4DA60862; Wed, 24 Feb 2021 16:29:41 +0000 (UTC) From: Josh Poimboeuf To: x86@kernel.org, Herbert Xu Cc: linux-kernel@vger.kernel.org, Miroslav Benes , Peter Zijlstra , Eric Biggers , Ard Biesheuvel , Sami Tolvanen , linux-crypto@vger.kernel.org, "David S . Miller" Subject: [PATCH 07/13] x86/crypto/sha_ni: Standardize stack alignment prologue Date: Wed, 24 Feb 2021 10:29:20 -0600 Message-Id: <5033e1a79867dff1b18e1b4d0783c38897d3f223.1614182415.git.jpoimboe@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Use a more standard prologue for saving the stack pointer before realigning the stack. This enables ORC unwinding by allowing objtool to understand the stack realignment. Signed-off-by: Josh Poimboeuf --- arch/x86/crypto/sha1_ni_asm.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/crypto/sha1_ni_asm.S b/arch/x86/crypto/sha1_ni_asm.S index 11efe3a45a1f..5d8415f482bd 100644 --- a/arch/x86/crypto/sha1_ni_asm.S +++ b/arch/x86/crypto/sha1_ni_asm.S @@ -59,8 +59,6 @@ #define DATA_PTR %rsi /* 2nd arg */ #define NUM_BLKS %rdx /* 3rd arg */ -#define RSPSAVE %rax - /* gcc conversion */ #define FRAME_SIZE 32 /* space for 2x16 bytes */ @@ -96,7 +94,8 @@ .text .align 32 SYM_FUNC_START(sha1_ni_transform) - mov %rsp, RSPSAVE + push %rbp + mov %rsp, %rbp sub $FRAME_SIZE, %rsp and $~0xF, %rsp @@ -288,7 +287,8 @@ SYM_FUNC_START(sha1_ni_transform) pextrd $3, E0, 1*16(DIGEST_PTR) .Ldone_hash: - mov RSPSAVE, %rsp + mov %rbp, %rsp + pop %rbp ret SYM_FUNC_END(sha1_ni_transform) From patchwork Wed Feb 24 16:29:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Poimboeuf X-Patchwork-Id: 386929 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 594FAC433E0 for ; Wed, 24 Feb 2021 16:36:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0390064EF5 for ; Wed, 24 Feb 2021 16:36:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235353AbhBXQfs (ORCPT ); Wed, 24 Feb 2021 11:35:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:57547 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235268AbhBXQdk (ORCPT ); Wed, 24 Feb 2021 11:33:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614184324; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AuvWSaJ9jqWTQR6peCcPaZV/0nyJwPI7/KUXsD2VZRA=; b=RuLvmd2bph2Xgh7JoGsT0u9mrTZ8LUaDRgL0EzJ4keDSPBIo9c7+gU5K0WikovJ/Wgc4ip VwvSIyVehWh/97HxnHhCx//G3bSsSLKhVHnK3JcIKVayEOa1UDEvwe7X1JlhaqlUMOvhH9 gcJSs/1v01LiJyH7rMX07eFpiUwQiPg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-37-qtnbYkXpOa2FDxm45LwWDA-1; Wed, 24 Feb 2021 11:29:46 -0500 X-MC-Unique: qtnbYkXpOa2FDxm45LwWDA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 798931005501; Wed, 24 Feb 2021 16:29:44 +0000 (UTC) Received: from treble.redhat.com (ovpn-118-134.rdu2.redhat.com [10.10.118.134]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40F5960862; Wed, 24 Feb 2021 16:29:43 +0000 (UTC) From: Josh Poimboeuf To: x86@kernel.org, Herbert Xu Cc: linux-kernel@vger.kernel.org, Miroslav Benes , Peter Zijlstra , Eric Biggers , Ard Biesheuvel , Sami Tolvanen , linux-crypto@vger.kernel.org, "David S . Miller" Subject: [PATCH 08/13] x86/crypto/sha1_avx2: Standardize stack alignment prologue Date: Wed, 24 Feb 2021 10:29:21 -0600 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Use a more standard prologue for saving the stack pointer before realigning the stack. This enables ORC unwinding by allowing objtool to understand the stack realignment. Signed-off-by: Josh Poimboeuf --- arch/x86/crypto/sha1_avx2_x86_64_asm.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/crypto/sha1_avx2_x86_64_asm.S b/arch/x86/crypto/sha1_avx2_x86_64_asm.S index 1e594d60afa5..5eed620f4676 100644 --- a/arch/x86/crypto/sha1_avx2_x86_64_asm.S +++ b/arch/x86/crypto/sha1_avx2_x86_64_asm.S @@ -645,9 +645,9 @@ _loop3: RESERVE_STACK = (W_SIZE*4 + 8+24) /* Align stack */ - mov %rsp, %rbx + push %rbp + mov %rsp, %rbp and $~(0x20-1), %rsp - push %rbx sub $RESERVE_STACK, %rsp avx2_zeroupper @@ -665,8 +665,8 @@ _loop3: avx2_zeroupper - add $RESERVE_STACK, %rsp - pop %rsp + mov %rbp, %rsp + pop %rbp pop %r15 pop %r14 From patchwork Wed Feb 24 16:29:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Poimboeuf X-Patchwork-Id: 386931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AC58C4332E for ; Wed, 24 Feb 2021 16:33:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D212A64EF1 for ; Wed, 24 Feb 2021 16:33:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234878AbhBXQdD (ORCPT ); Wed, 24 Feb 2021 11:33:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29146 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234881AbhBXQb3 (ORCPT ); Wed, 24 Feb 2021 11:31:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614184194; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a5xSosP/C+AktqnKcTC1zhdA3nQKp0XFHHslguVKp40=; b=geetHY4gZPx309/naBbC7EsfAQP1kq2hDd+CEjcCu8RzlqFrsF9g/3ZEfo73DKLN+1U17d Ayn2TYVA4Jgl8Ta34O5ouZjq+1vuzixMsQw+fMjjlwn0mh4OlGAKWvXw9r7Y8y8w6wYCPa 9SRmB2LOxjhJJqHoLlT5JK5jngXFYkg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-407-sHhUE2crP_ihPEziQ6xsKw-1; Wed, 24 Feb 2021 11:29:50 -0500 X-MC-Unique: sHhUE2crP_ihPEziQ6xsKw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 00382107ACE4; Wed, 24 Feb 2021 16:29:49 +0000 (UTC) Received: from treble.redhat.com (ovpn-118-134.rdu2.redhat.com [10.10.118.134]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8A5260CE7; Wed, 24 Feb 2021 16:29:47 +0000 (UTC) From: Josh Poimboeuf To: x86@kernel.org, Herbert Xu Cc: linux-kernel@vger.kernel.org, Miroslav Benes , Peter Zijlstra , Eric Biggers , Ard Biesheuvel , Sami Tolvanen , linux-crypto@vger.kernel.org, "David S . Miller" Subject: [PATCH 11/13] x86/crypto/sha512-avx2: Standardize stack alignment prologue Date: Wed, 24 Feb 2021 10:29:24 -0600 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Use a more standard prologue for saving the stack pointer before realigning the stack. This enables ORC unwinding by allowing objtool to understand the stack realignment. Signed-off-by: Josh Poimboeuf --- arch/x86/crypto/sha512-avx2-asm.S | 42 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S index 3a44bdcfd583..072cb0f0deae 100644 --- a/arch/x86/crypto/sha512-avx2-asm.S +++ b/arch/x86/crypto/sha512-avx2-asm.S @@ -102,17 +102,13 @@ SRND_SIZE = 1*8 INP_SIZE = 1*8 INPEND_SIZE = 1*8 CTX_SIZE = 1*8 -RSPSAVE_SIZE = 1*8 -GPRSAVE_SIZE = 5*8 frame_XFER = 0 frame_SRND = frame_XFER + XFER_SIZE frame_INP = frame_SRND + SRND_SIZE frame_INPEND = frame_INP + INP_SIZE frame_CTX = frame_INPEND + INPEND_SIZE -frame_RSPSAVE = frame_CTX + CTX_SIZE -frame_GPRSAVE = frame_RSPSAVE + RSPSAVE_SIZE -frame_size = frame_GPRSAVE + GPRSAVE_SIZE +frame_size = frame_CTX + CTX_SIZE ## assume buffers not aligned #define VMOVDQ vmovdqu @@ -570,18 +566,18 @@ frame_size = frame_GPRSAVE + GPRSAVE_SIZE # "blocks" is the message length in SHA512 blocks ######################################################################## SYM_FUNC_START(sha512_transform_rorx) + # Save GPRs + push %rbx + push %r12 + push %r13 + push %r14 + push %r15 + # Allocate Stack Space - mov %rsp, %rax + push %rbp + mov %rsp, %rbp sub $frame_size, %rsp and $~(0x20 - 1), %rsp - mov %rax, frame_RSPSAVE(%rsp) - - # Save GPRs - mov %rbx, 8*0+frame_GPRSAVE(%rsp) - mov %r12, 8*1+frame_GPRSAVE(%rsp) - mov %r13, 8*2+frame_GPRSAVE(%rsp) - mov %r14, 8*3+frame_GPRSAVE(%rsp) - mov %r15, 8*4+frame_GPRSAVE(%rsp) shl $7, NUM_BLKS # convert to bytes jz done_hash @@ -672,15 +668,17 @@ loop2: done_hash: -# Restore GPRs - mov 8*0+frame_GPRSAVE(%rsp), %rbx - mov 8*1+frame_GPRSAVE(%rsp), %r12 - mov 8*2+frame_GPRSAVE(%rsp), %r13 - mov 8*3+frame_GPRSAVE(%rsp), %r14 - mov 8*4+frame_GPRSAVE(%rsp), %r15 - # Restore Stack Pointer - mov frame_RSPSAVE(%rsp), %rsp + mov %rbp, %rsp + pop %rbp + + # Restore GPRs + pop %r15 + pop %r14 + pop %r13 + pop %r12 + pop %rbx + ret SYM_FUNC_END(sha512_transform_rorx) From patchwork Wed Feb 24 16:29:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Poimboeuf X-Patchwork-Id: 386930 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 558DBC43332 for ; Wed, 24 Feb 2021 16:33:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A6D164EFC for ; Wed, 24 Feb 2021 16:33:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235227AbhBXQdJ (ORCPT ); Wed, 24 Feb 2021 11:33:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28416 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234934AbhBXQb3 (ORCPT ); Wed, 24 Feb 2021 11:31:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614184198; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/DLjCfyPdWpsrA8C7WRrfmxuAmIfnze3qgJu059srp4=; b=E64oJ7T8mwld4VY1r4y45ENIU7KjE1caB11DXZ3x3+0pLU0qz5Tk0t1WLmxl6kVngTUx6Z 8zEfD6t0TRzu/7frMwg4sEXQJS3eRNFtyMoS1tes+5miJHR/xhURTe3mg60xML9XoCaJh3 fw9PXYQTmAL+bgC+2xPDHHnk0DUpXnU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-145-EE2OuDdWNTW4amn49x2nhw-1; Wed, 24 Feb 2021 11:29:54 -0500 X-MC-Unique: EE2OuDdWNTW4amn49x2nhw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 29115107ACE4; Wed, 24 Feb 2021 16:29:52 +0000 (UTC) Received: from treble.redhat.com (ovpn-118-134.rdu2.redhat.com [10.10.118.134]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9F8A60862; Wed, 24 Feb 2021 16:29:50 +0000 (UTC) From: Josh Poimboeuf To: x86@kernel.org, Herbert Xu Cc: linux-kernel@vger.kernel.org, Miroslav Benes , Peter Zijlstra , Eric Biggers , Ard Biesheuvel , Sami Tolvanen , linux-crypto@vger.kernel.org, "David S . Miller" Subject: [PATCH 13/13] x86/crypto: Enable objtool in crypto code Date: Wed, 24 Feb 2021 10:29:26 -0600 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Now that all the stack alignment prologues have been cleaned up in the crypto code, enable objtool. Among other benefits, this will allow ORC unwinding to work. Signed-off-by: Josh Poimboeuf --- arch/x86/crypto/Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile index b28e36b7c96b..d0959e7b809f 100644 --- a/arch/x86/crypto/Makefile +++ b/arch/x86/crypto/Makefile @@ -2,8 +2,6 @@ # # x86 crypto algorithms -OBJECT_FILES_NON_STANDARD := y - obj-$(CONFIG_CRYPTO_TWOFISH_586) += twofish-i586.o twofish-i586-y := twofish-i586-asm_32.o twofish_glue.o obj-$(CONFIG_CRYPTO_TWOFISH_X86_64) += twofish-x86_64.o