Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp486374rdb; Thu, 18 Jan 2024 09:12:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgKLjhF4eMvUWYnEVEvyObFf9h1ChUTPF/c8uwoftmBJT4HF496eC1yNz+HdlREc5T5PeI X-Received: by 2002:a17:903:1205:b0:1d4:14a0:bf66 with SMTP id l5-20020a170903120500b001d414a0bf66mr1387608plh.23.1705597921656; Thu, 18 Jan 2024 09:12:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705597921; cv=pass; d=google.com; s=arc-20160816; b=MOcGkugxbPhywV5CGidd+TUvTILMg97dS7zN+jnYpmX0W3UGFCviJ6QosvtxYKdigG ECAGxHqqnOUDY0O5OB6yz36Os0eJhG+WC2uI5BwGpW/hVbGis9ANxLJv/CIxbn4qBVqI Kqi6CBWGy/ZxjbeR13QqMCJKi0LyriJwbA2Ui8G73kxHLLqLvWpHI0uT63B8hliSzcAe vhWZRJ7oc/KluIITUOUuHpVd0ny2eQXV/fjXMnaAqcFq2xtFGeFI2dwNu+UC0+af8s7c kz84lxeJuiO0SiBjf6Ba8NElCBWuc/zFw63IHejK73b2XPJvaDr4DoTRb0eIXPXF2uJ3 FidQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=rOaubHCN0d/JbHeeyKhI2Cii265DwIb3nT8U1KTfMHU=; fh=MoNanF5d0vjGrp692+ghhk+JSPJJjsLNvHcs25SnBB4=; b=Baga3FQF6Y6K3LtqhfIzfAM/KfPrBn7gs88xqvgRFbr9eMHwmGuKXgBe2nIjxu1CQN YS0EfZVL53s4+2IfA/WN8YRSRNy0qInZ4u30rF82B0BkK7HYIBXiNhkTouuEvffTgMcD mqgX411F2TmoiBuaWsljurPSQL1a8RyWcewsu2AAZZ8d++1T2T0Ob6ucKqMxyoyFAPOA bDpfAmxEC29sa2tIXwIvXdkZH3An+VRl6EDYZt4sZQ6V/olDQRst5Wk1/n/eLdOSPvQP 4YUMZyLSVoxGBZl+K0UmqPfvhQEJVe0n9d2NACfZh2YIFD86fWZkYVilNNKY3ig7O88a FMKA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=dC0uuvG2; arc=pass (i=1 spf=pass spfdomain=flex--ardb.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-crypto+bounces-1486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1486-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t8-20020a170902bc4800b001d6f3a92b6dsi1720407plz.179.2024.01.18.09.12.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 09:12:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-1486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=dC0uuvG2; arc=pass (i=1 spf=pass spfdomain=flex--ardb.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-crypto+bounces-1486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1486-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 3F776B2467F for ; Thu, 18 Jan 2024 17:07:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9AF582C847; Thu, 18 Jan 2024 17:07:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dC0uuvG2" X-Original-To: linux-crypto@vger.kernel.org Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19A562C843 for ; Thu, 18 Jan 2024 17:07:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705597664; cv=none; b=bLLSB6kVMbmkNvqJefeM1AtTC6OhNHpeciFOA8OKq60Y6SIzPja0uYsRTcOlUkRyCWy2wqVOgAjjUfd0LhGxqCuXCSiaLdhXfwvG8BuJ4AyCHiwle/xKbduZH88jUDDUhMLgpl/NFZjEyQ6LRYqlf9drT4M4gLhWp7/ZnYhI6Ms= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705597664; c=relaxed/simple; bh=esEuVtsGnTmd0hkaLNKKp1YZntXpEFU6zENBP770TFE=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:Date: In-Reply-To:Mime-Version:References:X-Developer-Key: X-Developer-Signature:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; b=FEVAROfwP8kK9eH1ucfPYzaHXGuLWetvbAj317Pq4lfwnE2dEpgnzno/PG4DACCM+DwE7bEQ67zj07fQ2v65MsmANudDAApA8Ew5ZCYP5/AGSn6yRBnc3HUXDx8XeGDOFEDVYWiuhPsooiSULleI9tY0v4Zfgz4wA9BZ5WhUDz0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=dC0uuvG2; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc24de01bd9so2630594276.1 for ; Thu, 18 Jan 2024 09:07:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705597662; x=1706202462; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=rOaubHCN0d/JbHeeyKhI2Cii265DwIb3nT8U1KTfMHU=; b=dC0uuvG2gTDmVJXshQ14JKXfWV3JCCSYpZhstZDb+oCvyNGC7zlwgyb1wR9+pQG6T/ V3bfmbjjdHK82cd+Y2X39Qz0Iy2KSvF27NjZjHrp1Sr75CWG2wbXHGFiYhzMRrQpkmd4 Zl7hD+0zNZhE2WO13MgToOsU4+BajAfUb+n57QorYFDAdspPAFtKTAsrdT0gCVqPvq7P i/8U9JzIle49ks+YHhCXLJzJn/+FTni7yJtwAqTmi4WMU5hTk1CJArk4p5MNn2wkG/G1 wa7FXpJYEOJXkHcvBWZZbk4vcxmT6ppaOKkNWQ2MkSavyFy+V+rTU6yp8GlkOEY0kpqo lUeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705597662; x=1706202462; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rOaubHCN0d/JbHeeyKhI2Cii265DwIb3nT8U1KTfMHU=; b=GV+VQ2T6Ft1QwLAw4kBcpWVTJeYR3xrlyy9REXiLPJbPurWDu3PM3/NQ582yuFhwvo ZTMeer4Ez/Z1SqbIBltOE5OnOVeAxW4QxXEGJN/rehRm6SSSKhQjMe4mAbfp4EtY9z2Z FEpTNSFueutTdSOfxO6ndGabOKewcPIE5XuURAOeY4eOlXPIuLjiMc9PAvA+stH8X9LZ e+wKJzy1oBJsMTDFm/UrgMUfl8x6xLuZhcXM3o3m8nHcWx5TvonxgnNv7w/Nl4kvGJYY UidgIChveevfoAOWZF4+vTULtpsNQlnQkoMzrEqoNPJU4yGCNLGEZKJ9ZDWVjvIYzt// aU6A== X-Gm-Message-State: AOJu0YwVKIXuTsxfoKO/QsUXeKb+0xcCLT+tx7I3cKxUaeRI4vV1ljNJ fYJxo+n7u7xIue6+v+PshM2ANX16WRFe0TfGf8UmLmFUbmlvmGqAPzZSeEkBM3VvQW1pfEDMkSb 0bIfTl2LtWc8VeFxJZt9JLX5FFwB32W5afK5/1DZQaULCGvbH+CcNlg4MmINiRPLQZlDz2ykvzU 5fqtY9ySPjfBLJfGhVfyjkUY3U7jOUVg== X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:6902:2705:b0:dc2:3411:6424 with SMTP id dz5-20020a056902270500b00dc234116424mr477264ybb.2.1705597662157; Thu, 18 Jan 2024 09:07:42 -0800 (PST) Date: Thu, 18 Jan 2024 18:06:31 +0100 In-Reply-To: <20240118170628.3049797-10-ardb+git@google.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240118170628.3049797-10-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=1868; i=ardb@kernel.org; h=from:subject; bh=8krDFuO6ohSM5gr3lqbU2dJ0WRAj0VbK0XKYMUR2NTg=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIXVl1PRHblMnpFydMvO9y8MT/1sOPy11/7lJ8t61LQHdb rMcTjDKdZSyMIhxMMiKKbIIzP77bufpiVK1zrNkYeawMoEMYeDiFICJaHsw/PfP/7J00ZtaY7v7 sjk7xb8E7wu686NMmVF2/p8Z8v0Fjx4wMrzT//i+caHsr1Un2ad+bT4c+ifc+dQlwQYOjdeTZxy 1+8sPAA== X-Mailer: git-send-email 2.43.0.381.gb435a96ce8-goog Message-ID: <20240118170628.3049797-12-ardb+git@google.com> Subject: [PATCH v2 2/8] crypto: arm64/aes-ccm - Keep NEON enabled during skcipher walk From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: ebiggers@kernel.org, herbert@gondor.apana.org.au, Ard Biesheuvel Content-Type: text/plain; charset="UTF-8" From: Ard Biesheuvel Now that kernel mode NEON no longer disables preemption, we no longer have to take care to disable and re-enable use of the NEON when calling into the skcipher walk API. So just keep it enabled until done. Signed-off-by: Ard Biesheuvel --- arch/arm64/crypto/aes-ce-ccm-glue.c | 22 +++++++++----------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/arch/arm64/crypto/aes-ce-ccm-glue.c b/arch/arm64/crypto/aes-ce-ccm-glue.c index c4f14415f5f0..b177ebea7d09 100644 --- a/arch/arm64/crypto/aes-ce-ccm-glue.c +++ b/arch/arm64/crypto/aes-ce-ccm-glue.c @@ -182,17 +182,16 @@ static int ccm_encrypt(struct aead_request *req) if (walk.nbytes == walk.total) ce_aes_ccm_final(mac, buf, ctx->key_enc, num_rounds(ctx)); - kernel_neon_end(); - if (walk.nbytes) { err = skcipher_walk_done(&walk, tail); - if (unlikely(err)) - return err; - if (unlikely(walk.nbytes)) - kernel_neon_begin(); } } while (walk.nbytes); + kernel_neon_end(); + + if (unlikely(err)) + return err; + /* copy authtag to end of dst */ scatterwalk_map_and_copy(mac, req->dst, req->assoclen + req->cryptlen, crypto_aead_authsize(aead), 1); @@ -240,17 +239,16 @@ static int ccm_decrypt(struct aead_request *req) if (walk.nbytes == walk.total) ce_aes_ccm_final(mac, buf, ctx->key_enc, num_rounds(ctx)); - kernel_neon_end(); - if (walk.nbytes) { err = skcipher_walk_done(&walk, tail); - if (unlikely(err)) - return err; - if (unlikely(walk.nbytes)) - kernel_neon_begin(); } } while (walk.nbytes); + kernel_neon_end(); + + if (unlikely(err)) + return err; + /* compare calculated auth tag with the stored one */ scatterwalk_map_and_copy(buf, req->src, req->assoclen + req->cryptlen - authsize, -- 2.43.0.381.gb435a96ce8-goog