From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.10.208.61 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796287224; b=wEtdHVExsUtqOl9wlDRugRwYib8HOmR9MGZ11YBAa0/6Zb4ns5VIgUvVSgKSi9KA2hHl C3YPXCjkFyq+ePE65zJERxdI5xpRZbpcXif16yCXOdVrSpPkYtf9OyafC38z1m6sMypBi kJxDygo76MpxsUPsQE4UkdL9O9oSW3SKVinzP4GMcw60/pojJ5qk5h3FBo98kuR9w2Pw5 fNWaPBuqnMmBX7rPE72s+WJRARdFlW/8GWE1Pr7xUW5CHzqn/LhcmgDGRvgSCtW5rFeUz 0XO5eK30uoFDccEWqiFBvLIAWHWuW8reRv8Ab9Ej08kc78XwA8gQ6jW21ZMM5mkEsAQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796287224; h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-Rspamd-Queue-Id; bh=N+ie1S64exPfgPS+8iVCyA96CwoztFRy+sqDnK+nDV8=; b=uiN9GrU9XjIyto4OZT456hJJYwYkUJs1jkYL1uA7OVb2OaZ/PWcs/hSyTfNGaSxCKfNj o/pHsMb22UxduWB0KmrAHVEAfdBOJj0rpiqyHKOhuggZa3cUMkzHRJU4gGv8bucCVIFMO I03uyqNVLMBheVu2NL8ivtFVHpZ5VeCgbf3gc1IETsGM11677mlTqnIAZZmDuS3JUrh6c ZTaRmfO0JR29y22bCPnmtngcwmalsWxRPj5o+7ip5A0AVCOw6EUqbLujunXhJpoQGij3k 8iA4eG2qyRVi14WbFbtFiekKrlhptPQAXNbpBtJDX1k1X3wY1UadxgXIqkkmSZebzVw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=mandelbit.com; spf=pass smtp.mailfrom=mandelbit.com; dkim=pass header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=wf4WcPHK; arc=none smtp.remote-ip=195.10.208.61 Received: from mout-b-201.mailbox.org (mout-b-201.mailbox.org [195.10.208.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A84C3606A332; Thu, 3 Dec 2026 08:40:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A84C3606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mandelbit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mandelbit.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=wf4WcPHK Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-201.mailbox.org (Postfix) with ESMTPS id 4jg7Nv0PFWzLmSM; Thu, 03 Dec 2026 09:40:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1796287215; 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; bh=N+ie1S64exPfgPS+8iVCyA96CwoztFRy+sqDnK+nDV8=; b=wf4WcPHK+XfOOePt7zGheWY95JfpaEZOH3bi0PRajkydX4g0QzsqHz0HVpeavIzVfA33VR nwrfTcl1V67xj4obDxgsXjIxsKwAK9QlWoOzgJS7GUdSVIZKeUBuk9605y8flIEhyAqLdu VahlnDu5N9tsi6tqTxCiJq1RFCVy290Y4NdyToK3GmyE0sElBLH3SPfp0/d5kiVxZQdrD7 guAHyxy95EsurjV5MP/BskHeRNm+vYFJ8aCuyGmEzKpHhEn9CvLeFeO+OvG8NVPGO7jwDn BV7ikjBtK88iul/b8yK4jJLgXCJYJuWv8O8Qw9RaTm7nlbqwu7vA/wLJkIOYuQ== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of ralf@mandelbit.com designates 2001:67c:2050:b231:465::202 as permitted sender) smtp.mailfrom=ralf@mandelbit.com From: Ralf Lici To: linux-crypto@vger.kernel.org Cc: Antoine Tenart , Herbert Xu , "David S. Miller" , Nikita Zhandarovich , Antonio Quartulli , linux-kernel@vger.kernel.org Subject: [PATCH crypto v2 0/2] crypto: safexcel: fix AEAD DMA mapping and cleanup Date: Thu, 3 Dec 2026 09:40:05 +0100 Message-ID: X-Mailer: git-send-email 2.56.1 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4jg7Nv0PFWzLmSM Hi, This series fixes two DMA mapping bugs in the safexcel AEAD path. The first avoids unmapping a destination list whose mapping failed. The second maps each AEAD scatterlist entry with the direction its contents need, which fixes silent output corruption on non-coherent systems. In the v1 discussion, Herbert asked which caller is affected and whether mapping the destination DMA_BIDIRECTIONAL would be enough. The caller is in-tree ovpn: its in-place requests start with an 8-byte AAD entry that shares a cache line with the payload. Mapping that entry DMA_BIDIRECTIONAL, as the in-place path already does, is what corrupts the output. The entry is bounced through SWIOTLB, and copying it back at unmap dirties a stale cache line that the next unmap then writes over the accelerator output. Patch 2 has the details. This also corrects my earlier explanation: swiotlb fills the bounce buffer in every direction, so the problem is the copy-back through a stale cache line, not uninitialized bounce data. I tested this on a GL.iNet GL-MT6000 (MT7986 EIP97, non-coherent Cortex-A53) with a matrix of AES-GCM requests in the ovpn in-place and fragmented out-of-place layouts plus linear ones, for encryption and decryption, at three data offsets and queue depths up to 400. The stock driver failed 27 of the 72 cases, all ovpn layouts, and this series fixes all of them. Unfortunately no choice of direction can fix the case where two adjacent device-written entries share a cache line and the first is small enough to be bounced. While I have not seen this with ovpn or ESP, it might explain the kTLS failure noted in v1 (still unfixed by this series). Changes since v1 https://lore.kernel.org/linux-crypto/cover.1789469436.git.ralf@mandelbit.com/ - Rebase onto crypto-2.6. - Rewrite the commit message of patch 2 to explain why DMA_BIDIRECTIONAL is not safe for small entries and to name the in-tree caller. (Herbert) Cheers! Ralf Lici Mandelbit Srl --- Ralf Lici (2): crypto: safexcel - Avoid unmapping failed DMA mappings crypto: safexcel - Map AEAD buffers with accurate DMA directions .../crypto/inside-secure/safexcel_cipher.c | 173 +++++++++++++++--- 1 file changed, 150 insertions(+), 23 deletions(-) base-commit: 26ca5f34841f0a86d0883664a1c13be89a01d351 -- 2.56.1