Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp773449rwl; Wed, 12 Apr 2023 04:04:15 -0700 (PDT) X-Google-Smtp-Source: AKy350a1a54o6OdfZQ9W3BG+YxEtakzaHZMiWYH/jKzvFHY16iJf6lUWCXHCTNule1JTj8Ysk/jK X-Received: by 2002:a17:90a:1d6:b0:247:a17:9258 with SMTP id 22-20020a17090a01d600b002470a179258mr68438pjd.2.1681297454916; Wed, 12 Apr 2023 04:04:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681297454; cv=none; d=google.com; s=arc-20160816; b=KPP6B6yLI5o7n6lu7Xr5O1Efo10IoUFAhXnvOFMNnd9ljBqPFDf4lX+hyK4ZcbkGc5 21wcq70LbGe2kriXhdWsPd0nSIgvO0WjRWxkX3ZCrQy6qHQOSd/a4Px8gBpd2vosH84B 0ZahNxbNcxke8nGd1mv3e49zjv0dXZJ/tFJ/AZCHrMLep0q2Cj5Sjfmq0rEIaTyqYW/e DxDDKYlGw5k3qN0PcQd/G4nH0zrSf3JnKnL7Ukvhpu/IXcKxBdvBGovjcOcFz2eHSd1t eVzvBXk0/M9RqyZKli0X537ek/KHCPkzpcKwXEtCdknUF93r3kYiLCazipMS2FkyrKER Tj0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jYcy8DgUloK9gUvw3UuaBQQQvKvkx+WxeMzSRbQ5HJ8=; b=bP55phR4ItUSNuu0pgkNC8SA83u/Uor9QhjwAFYCl2KEEkMyedtcbcXNaIOJtf5aox E2LTi1LUsaAa8z0AkCPcjK7WkdI7S9KBTOpyo5AwQ08qj3V+soN0uENNd2QZIrAJXzWX 7n11fIm4TGqhYIObcZRrVfNX39gJ8vQLae0PYriA5OYnGLMpR89ZPpImrqfTvEHC/8DA RJtCE6AtLpGoDXAnL3iRO3HzH4qbrrVQoZcwCfaCnBwcn3lGCZsIOV1tPkkbvytFKIFO bAjNJEnsPAqdSewFw4aFKt7JbboGjUZPQXbJD+jVbNcwc8szW3HWtJhHJ9naBnsfJVB1 ggdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SLwSFHux; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o5-20020a17090ab88500b0023d0131c21asi1702872pjr.66.2023.04.12.04.04.03; Wed, 12 Apr 2023 04:04:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SLwSFHux; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229709AbjDLLBR (ORCPT + 99 others); Wed, 12 Apr 2023 07:01:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229765AbjDLLBO (ORCPT ); Wed, 12 Apr 2023 07:01:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1F876E80 for ; Wed, 12 Apr 2023 04:01:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6C02662889 for ; Wed, 12 Apr 2023 11:01:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2243C433D2; Wed, 12 Apr 2023 11:01:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681297262; bh=Em7n8Yu3fpuklxDgt7kSen6J5HDRU2CHTf0mvOk/VXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SLwSFHuxumLEd66E7pWBfWlk6BaxpYm6klPr7ZJCB0PFtPoNlrrMo/NGXi4ehgU// FmYjwl7hsSSV6iwoiLww6gR2Y2BIRKiC3w+4NKBhdnslxrP2OO/+zfMRCbaQLUUQAH 4J8wmdtFw7Ld3ffilsGNq8pB4tIHavU2RX4Kk+UG0u1uRxjdZm243A2pAP9wGcdwe6 1heQTzcGkrCisyUaHa+RzYlB4Q26zjBI+sDZkv7CFpC3E1Uwl7aUnAQuI8UJySzIFe hTDuibp4PLF8nOD6G/wIZGt2tl62k1xdz3S2oaPQK+KmVixrLkwUIJRDOwPqGiHXqW 6qo9iPVQzoDKw== From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: Ard Biesheuvel , Herbert Xu , Eric Biggers , Kees Cook Subject: [PATCH v2 10/13] crypto: x86/sha256 - Use RIP-relative addressing Date: Wed, 12 Apr 2023 13:00:32 +0200 Message-Id: <20230412110035.361447-11-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230412110035.361447-1-ardb@kernel.org> References: <20230412110035.361447-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1743; i=ardb@kernel.org; h=from:subject; bh=Em7n8Yu3fpuklxDgt7kSen6J5HDRU2CHTf0mvOk/VXI=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIcWs3//Y1k03+9xcdLoniqYffRH4QDFJ8a1g7qHp1u8es 8mWzNzbUcrCIMbBICumyCIw+++7nacnStU6z5KFmcPKBDKEgYtTACayyICRYUOl1OVdCoyN3PY+ zDnsX/PzH9inrZn7T8lQkcFHo8luLsNfUQ7Rqy/1vmcfNzm/3o85XFJy7dkCp/5U38mJu+dullj CAAA= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Prefer RIP-relative addressing where possible, which removes the need for boot time relocation fixups. Signed-off-by: Ard Biesheuvel --- arch/x86/crypto/sha256-avx2-asm.S | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S index 3eada94168526665..e2a4024fb0a3f5d5 100644 --- a/arch/x86/crypto/sha256-avx2-asm.S +++ b/arch/x86/crypto/sha256-avx2-asm.S @@ -589,19 +589,23 @@ last_block_enter: .align 16 loop1: - vpaddd K256+0*32(SRND), X0, XFER + leaq K256+0*32(%rip), INP ## reuse INP as scratch reg + vpaddd (INP, SRND), X0, XFER vmovdqa XFER, 0*32+_XFER(%rsp, SRND) FOUR_ROUNDS_AND_SCHED _XFER + 0*32 - vpaddd K256+1*32(SRND), X0, XFER + leaq K256+1*32(%rip), INP + vpaddd (INP, SRND), X0, XFER vmovdqa XFER, 1*32+_XFER(%rsp, SRND) FOUR_ROUNDS_AND_SCHED _XFER + 1*32 - vpaddd K256+2*32(SRND), X0, XFER + leaq K256+2*32(%rip), INP + vpaddd (INP, SRND), X0, XFER vmovdqa XFER, 2*32+_XFER(%rsp, SRND) FOUR_ROUNDS_AND_SCHED _XFER + 2*32 - vpaddd K256+3*32(SRND), X0, XFER + leaq K256+3*32(%rip), INP + vpaddd (INP, SRND), X0, XFER vmovdqa XFER, 3*32+_XFER(%rsp, SRND) FOUR_ROUNDS_AND_SCHED _XFER + 3*32 @@ -611,11 +615,13 @@ loop1: loop2: ## Do last 16 rounds with no scheduling - vpaddd K256+0*32(SRND), X0, XFER + leaq K256+0*32(%rip), INP + vpaddd (INP, SRND), X0, XFER vmovdqa XFER, 0*32+_XFER(%rsp, SRND) DO_4ROUNDS _XFER + 0*32 - vpaddd K256+1*32(SRND), X1, XFER + leaq K256+1*32(%rip), INP + vpaddd (INP, SRND), X1, XFER vmovdqa XFER, 1*32+_XFER(%rsp, SRND) DO_4ROUNDS _XFER + 1*32 add $2*32, SRND -- 2.39.2