From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 575AB3009C7 for ; Mon, 30 Mar 2026 14:38:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774881535; cv=none; b=cC2PfjrkEILQymXSu5Qb0u29TndJh9v+/u4VBCahZ9D6/l7Be9kRXzKqlt+m2sJeOwpoE+1q4kZZhWh8PZfTxPVP7JJ45HEy+e/p5ZgTRB5NDP6fTS+Jj/hlgrkQmqzBj7NE2pQlvjxOVFcx3EJ/tnYrb2FqipRWnGFn9EjUJiw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774881535; c=relaxed/simple; bh=koix8bOEomZhxXXqSljRHzrLE4EdrdQWjNIZqocOroI=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:References: In-Reply-To:Content-Type; b=W6hqUz4o99GcWjej7aCr8lnOunIyt/eRAD1AFHlxCFoaVjrel5v6U2B9azZSj0qpF3lOXnHkrQwUNYNj2MhMyXem7SKQUjcU4LdM5Ro76zQBVqfz3N3r01YXQO1T69OoBlx2E8Pw58LgKNS5VgnkwSTS3TNTFvxpGSts9iMTUvQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GdAsOAK2; arc=none smtp.client-ip=209.85.221.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GdAsOAK2" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-43cf7258875so81140f8f.2 for ; Mon, 30 Mar 2026 07:38:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774881532; x=1775486332; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=Ig7fKYjfwkrimY9Uw52BzM2CblH3tO3yAFQK+rKl0qE=; b=GdAsOAK2dSnJuDuhV4LG++DtX3frXATlaQQyeutv7A8dl6nj2JxRQa6hbZUdzb3FZG GXXKWJgNlepXtKHDHm4OLCmmJXBeRLfgRUMZAy9oMNSI2z/k7V1oFhNsgz6IKklnKu87 UwrqmV85K/X3A61EG/Zd1BYUO6MPxetMKvXpJvaCb/3o9hIdufndBQIG5itR39wzd6Te u0fAAe35szsotJEvLyZPVvctl9HMzH36OhaKpWvgDMZI39HcV03thKq64HwQT12ei5FZ ehzQD2Pe/9w6oemGGNhbhd52+eZanCLqYv9TvGE3yFLZh2t57ia7lm2gQKHzoCCkexQl B/zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774881532; x=1775486332; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ig7fKYjfwkrimY9Uw52BzM2CblH3tO3yAFQK+rKl0qE=; b=IPS9VPcH4E5mf6orx3MlzAfyVM23gmbcVYs176WEc2naHCppWq7okCIWtoZGHOE4RV 2pCRf2O72khMbwKtrYr3XOmY/fSs9uvteAb+GQCqLPtc1Ysd6xp62SREM5k6KgMGE0in 6dJDwkEnKQA+oGy7Rhgxc0bG91K+2jjP6k09NjD+6dzsk+OkX/VbcJhZ8Q8WD16bGBH6 P/jPZ1LuTf9aW4dEqTtga0NrQS+P0o/ci5cr1AC1LtC4ccazGV5Zu8YvXuHcl5eEfPiB tsHBcKp/lUhXJcSLkdBXdB5S8183tb1Qo6iwtoJcXdwnuOMzM4U5uZLuqtgL36p7rRHR ToMQ== X-Forwarded-Encrypted: i=1; AJvYcCV2+V5tMlY3selgMfvlMLzDOX1pyLAaqe1A+YUmlHeqoklO00fKxrxA7+CY9tLN5DV/L4JD+s5JF06uwkQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwmKUXTe5sBNBBap10n0OkJKXHvkI9PWKeEMlAtYKUNRWySC61v KOdBadmcAlNcv5QLFePbsf5vsaTRCeORqTZxca+meVIaZrlXjNgwy09AeQ/3jGML X-Gm-Gg: ATEYQzzvMpNuKK3FD2d5gdqYswfWUT0GrVXwBkSBxIeKmpzBtE+qcCJIEGMWGnwBQfK Dtdjw57x2E6bBiuaviTHe1W1QTw6Dik0N78IoolfxHH1tqBRal4LQKQoqKfrqPqjMtQehFXwWQB ZyrEzx5gz9u5JCGN/X0TL7v84mKOW+PRVzCco5G73zfZXSKvrp8+ykDP8zmH5mG9cLJErLvrvZc skfwAeyHLp6HWrN/viOFcJqq4PUcibC8eTFAYoOCVDeh6qLzOQIBkAafMpdivCzJTCBRH9mp8yC lrcFAw8Dtv5K/CrdOY1iYyh8+Cwi2pYWrOGvBhvLgYGglvx847ztofowFs8iD8FV9ASdRGrQITo uW2ONIqQaG3uil72F1IVaXb4S5Zri+/4gImPM4BcpC3vGC6WuHAUQfFhTugVXzQar0aiPDwlLFm 0Wjhd+kZ7s0F4NUPSOmnIvMnOePpbDi6Lxr77+MODIZglkKOmeQCMYNJ1Hwa+WGL1xbw== X-Received: by 2002:a05:600c:4f84:b0:486:fcf9:5ba with SMTP id 5b1f17b1804b1-48727f774b5mr127792725e9.7.1774881531411; Mon, 30 Mar 2026 07:38:51 -0700 (PDT) Received: from [128.93.82.131] (wifi-pro-82-131.paris.inria.fr. [128.93.82.131]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4873bbcac33sm85585965e9.15.2026.03.30.07.38.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Mar 2026 07:38:51 -0700 (PDT) Message-ID: <6c016af0-718c-4986-b707-c4ce74b72739@gmail.com> Date: Mon, 30 Mar 2026 16:38:50 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Thomas Fourier Subject: Re: [PATCH] crypto: eip93 - Fix dma_unmap_single() direction in eip93_hash_handle_result() To: Christian Marangi Cc: stable@vger.kernel.org, Antoine Tenart , Herbert Xu , "David S. Miller" , Richard van Schagen , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260330091817.25797-2-fourier.thomas@gmail.com> <69ca4458.050a0220.3569e7.2980@mx.google.com> Content-Language: en-US, fr In-Reply-To: <69ca4458.050a0220.3569e7.2980@mx.google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, On 30/03/2026 11:37, Christian Marangi wrote: > On Mon, Mar 30, 2026 at 11:18:14AM +0200, Thomas Fourier wrote: > > Hi, > > was this tested with the crypto self test? This was only compile tested. The change is based on the documentation which states that dma_map_single() and dma_unmap_single() should take all the same parameters. From what I understand, it could cause issues with bounce buffers and IOMMU permission if it is activated. > > I need to check the code again but in theory with handle result, we should > get the data from device in sa_state and cache should be invalidated. If we > want to use matching maybe we should change to BIDIRECTIONAL? Yes, sa_state is set before the mapping for the device and read after the unmapping so I think the BIDIRECTIONAL tag is required. Should I split the changes between eip93-common.c which seem good regarding that as is, and eip93-hash.c and change the direction to BIDIRECTIONNAL? > > The mismatched flag was to invalidate relevant cache on tramissing to device and > then invalidate relevant cache when reading it. > >> --- >> drivers/crypto/inside-secure/eip93/eip93-common.c | 4 ++-- >> drivers/crypto/inside-secure/eip93/eip93-hash.c | 2 +- >> 2 files changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/crypto/inside-secure/eip93/eip93-common.c b/drivers/crypto/inside-secure/eip93/eip93-common.c >> index f4ad6beff15e..75659a45ea5a 100644 >> --- a/drivers/crypto/inside-secure/eip93/eip93-common.c >> +++ b/drivers/crypto/inside-secure/eip93/eip93-common.c >> @@ -687,12 +687,12 @@ void eip93_handle_result(struct eip93_device *eip93, struct eip93_cipher_reqctx >> if (rctx->sa_state_ctr) >> dma_unmap_single(eip93->dev, rctx->sa_state_ctr_base, >> sizeof(*rctx->sa_state_ctr), >> - DMA_FROM_DEVICE); >> + DMA_TO_DEVICE); >> >> if (rctx->sa_state) >> dma_unmap_single(eip93->dev, rctx->sa_state_base, >> sizeof(*rctx->sa_state), >> - DMA_FROM_DEVICE); >> + DMA_TO_DEVICE); >> >> if (!IS_ECB(rctx->flags)) >> memcpy(reqiv, rctx->sa_state->state_iv, rctx->ivsize); >> diff --git a/drivers/crypto/inside-secure/eip93/eip93-hash.c b/drivers/crypto/inside-secure/eip93/eip93-hash.c >> index 2705855475b2..19a41a0db667 100644 >> --- a/drivers/crypto/inside-secure/eip93/eip93-hash.c >> +++ b/drivers/crypto/inside-secure/eip93/eip93-hash.c >> @@ -67,7 +67,7 @@ void eip93_hash_handle_result(struct crypto_async_request *async, int err) >> int i; >> >> dma_unmap_single(eip93->dev, rctx->sa_state_base, >> - sizeof(*sa_state), DMA_FROM_DEVICE); >> + sizeof(*sa_state), DMA_TO_DEVICE); >> >> /* >> * With partial_hash assume SHA256_DIGEST_SIZE buffer is passed. >> -- >> 2.43.0 >> >