Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2140032rwl; Sat, 8 Apr 2023 08:29:31 -0700 (PDT) X-Google-Smtp-Source: AKy350bBy1gqw6JRosuBTEzjLqtUOuOo4fPbderb0Pq69GQxaiaKL0Qnr6XO2zVJCSBvBCPoN4fY X-Received: by 2002:a17:906:d4:b0:947:bff2:1c2b with SMTP id 20-20020a17090600d400b00947bff21c2bmr2298264eji.1.1680967771477; Sat, 08 Apr 2023 08:29:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680967771; cv=none; d=google.com; s=arc-20160816; b=Wi6PD+L0F478+T8KNamTEMsqgzckcQIdDmZuJg7Jfn/YXChR7LUuxY4fthfHzPIzcC GTMYOPAYY8js/gbd2EWYQlcYaRhbmK+nwXAREhPaVXa2J+AUjl6nhvqpwbsvBLvJlRjA nMyMjGTa80E1JCy7HrZGjt51HJFHwETEoSohPU1/Uss/XZ4Fv5RYn8QLns8p/qltF5n+ zRAeKTG1AKJm7vvJTF6UvxLrDn3BcvzTgUI/hFZFeTKd/1pWa5i0WfBHmICEaaE9REAr iKWwu3YY1PFJ23trWUZdGNC8EAzGQ4gixoe+vpRQnMVLKrZGoNBIUEI5srZ/wQVgHpKQ Kt8w== 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=KaMwC4OIL37rKDzIJTDF/JtqZbZn2/0pucna2grvsJel+j5V6X0IP29hT14I0GsARx YZDpKOazw82dNMa6kezsABEqICYqy7R2nARXP/H1bSETwx1T8keEYWaKURhhlNDqyOjV 9+kJvWCyDJACMB39KGpBUdNrDYDXK24sW7L8D0GFCMmTN6SFDV2NKelclyyeemBUM81Y GxDFjrh2bTx3wr1mB57BkM9gQ5m9ObytwsMcQY6exOw+RU9TKdBQCktY4uejabruMwCW P2rkD35XCb3GbtJ62m/DyyAYbAqcdyM5RC+4/rvIulTr18lqu4Td3PGVjVV4MI8tikKX OCHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=o0l9gY5u; 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 gv18-20020a1709072bd200b0092043425e1bsi4963637ejc.714.2023.04.08.08.29.07; Sat, 08 Apr 2023 08:29:31 -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=o0l9gY5u; 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 S229976AbjDHP2B (ORCPT + 99 others); Sat, 8 Apr 2023 11:28:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbjDHP14 (ORCPT ); Sat, 8 Apr 2023 11:27:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BC49FF3C for ; Sat, 8 Apr 2023 08:27:55 -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 AD34960AD5 for ; Sat, 8 Apr 2023 15:27:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA05FC433D2; Sat, 8 Apr 2023 15:27:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680967674; bh=Em7n8Yu3fpuklxDgt7kSen6J5HDRU2CHTf0mvOk/VXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o0l9gY5u1Tiwqw9syc9pSqCZIQWVjVva3Sln3PWF+2QN+xSjviOFvhbYZYpbF62kx L6ZGXMsGfWN3wV5AyJHFwdEiTqPJODwPblPTg2EaJCFiOiQYPbum9Ki+lPjdjI6PqD suVjTL0aFFwOu0vQnh/A0X9rxBOf6r4GSsDqS+jGY7miPf4/KZYIBoE+IlFBewFZAS Hdx9RXMs39xX1a7w4+yM69bEICyILFejqRdLA5X46z3oea2XSgJNFilfNhePDu+57I 1+/TsD2ci7d2/UddUNAUzT24VM+tHAL/Er2bulpb9pfnZU+vqHmknDHR1xPGZQbODB dgG/nk+S/mlUQ== From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: Ard Biesheuvel , Herbert Xu , Eric Biggers , Kees Cook Subject: [PATCH 10/10] crypto: x86/sha256 - Use RIP-relative addressing Date: Sat, 8 Apr 2023 17:27:22 +0200 Message-Id: <20230408152722.3975985-11-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230408152722.3975985-1-ardb@kernel.org> References: <20230408152722.3975985-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=owGbwMvMwCFmkMcZplerG8N4Wi2JIcWw/eaxrZtu9rm56HRPFE0/+iLwgWKS4lvB3EPTrd89Z pMtmbm3o5SFQYyDQVZMkUVg9t93O09PlKp1niULM4eVCWQIAxenAExEx4+R4ZzC5enZL1UMjS4v nLiWy5q79u/3j50sK28eX7txvXfv04UMfyVmThYwvvrrGoeuHJ8k1+aLf2Oyn91foPDvXEXOryU KvjwA X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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