Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp1072884lqt; Fri, 19 Apr 2024 22:55:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUfaylBP5Iy4mPi5VjchFmNF/u1WqWI6Fryq5Xpn6z/VMeXiIdQ1W34LtWPy5wWK99iPkXDMcI6TliOiRZ1cm3ciwM28PJOtBGz4Jp6bg== X-Google-Smtp-Source: AGHT+IHbjXDhx1CRoJAV6mRB7toMIcp0qhRm+YEnKZhcDsgJBDvOQ/wCWV5KPXxu7Svyropgii1S X-Received: by 2002:a17:906:3502:b0:a52:22c4:8158 with SMTP id r2-20020a170906350200b00a5222c48158mr2685746eja.56.1713592525864; Fri, 19 Apr 2024 22:55:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713592525; cv=pass; d=google.com; s=arc-20160816; b=mQHfKLAJMDDSrTjTVe0ydfTPYHNTAVihA0JjsDFYnICNgwQZ6BtTwLCELORsyRZv0O BEIB/4rUn2kppf9VhztD3QIDCpHgcricKCHZ/HtyZDaQqlsqUwJ9Nx/nkAZ0yQuupfvy npxovgyDtETitYnvJ+hhrhquQPYNi+ZD13ZVkpJBTxhOZGbSBM5cEZH6GqJ1wPEKdsT9 8iPxboHGc1Te0nFXAbZrig4cvUQIwHejcOy85ncpVOqjEv91yU/BIZJIuRO7xXtD8UWQ bW2goLqouxoHcie4sZhcfWxiGgQm7lwC3usQl5XTbMJ5/y5buehsoJhwk17sz2NlKmOV kcWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=js8lykedPmOhcHGmlK+eJxRJ14n6nXcHnxuauuc6qeg=; fh=Lug2gC1H4H+8fcBw+nZBVEmAqkXnHiXUuu9mnC9ge+k=; b=0Suf4nWDmOgTRYNayfaIJJHD5bLqe+VdXNmybrZpR3Eung0bu54f8CEesh+YP2SiCp 6p0Uq7dd0IoQZthfVVnT+8CIfO0uoVL3A9sUm7Mt8D8d4D3KMf6bmY8o1/ohUDioY5i0 +vlhuHX7zlBleKwmGnxclVPHMB1Njzu2OIL3S9G0wxAEFeod0lwX6DZ6CbdlstmORj0w epkAeX/K2uNs8913//slAFgtnTgExwerUhvjIT1Io5smoarm8BMzBr2OtMZ3UK+Kpm0F 1p6eFnu5QxNZrQVW0gZI2S7DgM2Z4RGaAI5CYy5MglqSoV2daIYAsuJRhx68NxY3Ucba t8wA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KIvF8efd; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-3728-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3728-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t23-20020a1709064f1700b00a5225bbf8c9si3067828eju.121.2024.04.19.22.55.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 22:55:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3728-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KIvF8efd; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-3728-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3728-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4D0AF1F213C7 for ; Sat, 20 Apr 2024 05:55:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0DBD8F9DF; Sat, 20 Apr 2024 05:55:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KIvF8efd" X-Original-To: linux-crypto@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5A9F2563 for ; Sat, 20 Apr 2024 05:55:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713592520; cv=none; b=pIQMpv9Dw1o1CvqWSQhVjJ0nMa4AztWW4hqMHlyr0RjzIcTvHKs4n1bcV3hFGXUUiHsir47GHLbxYpCftEdBChIHqYZosmnLMtObYjMAnwbmYdKSxT3geSIFnojS63AAXLp9f+R3pZ4X5AyrtlFmnsK/YqSB4YpLVh9qChI2Bgs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713592520; c=relaxed/simple; bh=LTc0gFb4N2F95I5oWv+o2EIp3INIrFlpfFLvrZi6GgE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ZqciakYy8EylySkqlVcwM4gN4FBeMFA1IkmW4pXLYL6NKYQP5pxbRJacJ5X7ig5oh82HnnhCwXV0BMv9Um9mlB9o8XgRnajjDfGkBaz6w0qXJClA7CGIZjtZ6CJ99c9H2p3XfY5IF4wp3zQPK9DSYV/NU7WAoUxXxAyHrrNHzGA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KIvF8efd; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DA4DC072AA; Sat, 20 Apr 2024 05:55:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713592520; bh=LTc0gFb4N2F95I5oWv+o2EIp3INIrFlpfFLvrZi6GgE=; h=From:To:Cc:Subject:Date:From; b=KIvF8efdSEvuFm2BjphUJ9fzej9/stSng1sXnJp+NhTekeFgxAYtY/ZwAK/dNaHza aYB4WV5hXV91JG5RxeUT0kp1REsnQllTWnaSMWzAojmwYwLDMhrnxHevUshHtawCAt ChoGtAIEcY5zQAkarxsDuji+9aAui1YnYlTDNBniCnYe8YNhZWf4ukZPtKjdxCvGmw DKGn+DSednX0nWkDVVPnFM2WzIuSuqgskr4GJkxMrZgAshUyg3Uo8Kk9TvFiAngIUz VT8lpOz1gR1i/8P8d5yaO5W71Kgz8Q3Wi+Q7Eh2uvLbG2zNnxoSdQngmYqVFvjSQVX LXCazZ0GoGT3A== From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: x86@kernel.org Subject: [PATCH] crypto: x86/aes-xts - simplify loop in xts_crypt_slowpath() Date: Fri, 19 Apr 2024 22:54:55 -0700 Message-ID: <20240420055455.25179-1-ebiggers@kernel.org> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Eric Biggers Since the total length processed by the loop in xts_crypt_slowpath() is a multiple of AES_BLOCK_SIZE, just round the length down to AES_BLOCK_SIZE even on the last step. This doesn't change behavior, as the last step will process a multiple of AES_BLOCK_SIZE regardless. Signed-off-by: Eric Biggers --- arch/x86/crypto/aesni-intel_glue.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c index 110b3282a1f2..02a4c0c276df 100644 --- a/arch/x86/crypto/aesni-intel_glue.c +++ b/arch/x86/crypto/aesni-intel_glue.c @@ -933,20 +933,17 @@ xts_crypt_slowpath(struct skcipher_request *req, xts_crypt_func crypt_func) } err = skcipher_walk_virt(&walk, req, false); while (walk.nbytes) { - unsigned int nbytes = walk.nbytes; - - if (nbytes < walk.total) - nbytes = round_down(nbytes, AES_BLOCK_SIZE); - kernel_fpu_begin(); - (*crypt_func)(&ctx->crypt_ctx, walk.src.virt.addr, - walk.dst.virt.addr, nbytes, req->iv); + (*crypt_func)(&ctx->crypt_ctx, + walk.src.virt.addr, walk.dst.virt.addr, + walk.nbytes & ~(AES_BLOCK_SIZE - 1), req->iv); kernel_fpu_end(); - err = skcipher_walk_done(&walk, walk.nbytes - nbytes); + err = skcipher_walk_done(&walk, + walk.nbytes & (AES_BLOCK_SIZE - 1)); } if (err || !tail) return err; base-commit: 543ea178fbfadeaf79e15766ac989f3351349f02 -- 2.44.0