Received: by 10.213.65.68 with SMTP id h4csp45574imn; Mon, 19 Mar 2018 19:02:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELuvpCU7NLMZsZMZbgHqSoJjLpZnjSTwSYVJuRmjgU/zPCPg0kkDmcD1BTsyMO4izlb4n4r5 X-Received: by 10.99.177.66 with SMTP id g2mr10677770pgp.425.1521511377619; Mon, 19 Mar 2018 19:02:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521511377; cv=none; d=google.com; s=arc-20160816; b=aasrQ0uLt1cyt74tKrbMiOzvXqwkGG+NSsKPaaX4ehkrAb+0eQz5Lijj1gczLBj3/S 5GnsqVDDVCVi+Nm7lYVwa2DVEGkX8t3F0Tecr+Shg2gIUjUENFG1DSO0Nff/IhYi26VP bxesChoPNHaxjyCb7G4oWHkQ6QPLycw9AkjreWU2BUQzPmKWzHvRA9xbsZRYN+TkgDMH Yiu9vd/A/cajWfIPdsmU/2vkcib8aF7+ejB4YuAdcdN96nNr0edzFtaHbyvVMDZI8MI5 gubaLb/mW0nflQ3IAdruPJhgPkdxaTQA6XIc3NYbgrHRU8WydLGOq6kTgjfLkrSRqFEl xeRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=lwJX3HDG0onTPvh6vyUeHp9VFQeJQFWPLbjZDQjNa/0=; b=MUwU3Bm4/MCFH12Vk5fvg5j+8LeAz/j/yKkuJO+9jg3ctAGfkX9c/YshC79wBtPbvm MXRVXSNz2YO7gKDykfYbhXtcZgrQAaOuCCnUwsH/371kSDqt3tIYoSjsjO/iv8Hl+0vu ZNZbbKQM/0id637xEeZH/iZS/TxU0VjtY1VyQNwea84uvaz/C5Vntnv0iwbMcNwuuMol SSmIJqVwXajgC5FuuwFeQCFhQvL5G5ubwsurJYHF1wJyIpm5BXitGbo6fs48nNLYofol qdaBIWj/PSATZwXH9NMI/1N4AMVqyd9dR4GXm6y7Kty7KLMoiy3jbDNAIpzRuIBbnsUv oS7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v12-v6si561075plo.170.2018.03.19.19.02.43; Mon, 19 Mar 2018 19:02:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934211AbeCSXdl (ORCPT + 99 others); Mon, 19 Mar 2018 19:33:41 -0400 Received: from orcrist.hmeau.com ([104.223.48.154]:51162 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932534AbeCSXdj (ORCPT ); Mon, 19 Mar 2018 19:33:39 -0400 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtp (Exim 4.84_2 #2 (Debian)) id 1ey4HS-00030w-CU; Tue, 20 Mar 2018 07:33:30 +0800 Received: from herbert by gondobar with local (Exim 4.84_2) (envelope-from ) id 1ey4HL-0004Aq-Q3; Tue, 20 Mar 2018 07:33:23 +0800 Date: Tue, 20 Mar 2018 07:33:23 +0800 From: Herbert Xu To: Horia =?utf-8?Q?Geant=C4=83?= Cc: "David S. Miller" , Jonathan Corbet , "linux-crypto@vger.kernel.org" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] crypto: doc - clarify hash callbacks state machine Message-ID: <20180319233323.GA15897@gondor.apana.org.au> References: <20180305103945.3517-1-horia.geanta@nxp.com> <20180316151642.GA6606@gondor.apana.org.au> <20180319092458.GB12302@gondor.apana.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 19, 2018 at 11:04:24AM +0000, Horia Geantă wrote: > > The only solution to avoid leaks in this case is to repeatedly DMA map & unmap > the buffer. > IOW, if one wants to load/save HW state in a buffer after an .update() and to > instruct the crypto engine to do this operation, the following steps are involved: > -gpp: DMA map the buffer, get its IOVA > -gpp: program the crypto engine with IOVA, wait for crypto engine's signal > -crypto engine: load HW state from buffer, perform the partial hash, save HW > state in buffer, signal gpp > -gpp: DMA unmap the buffer What buffer are you talking about here? Is it the hash state? If it's the hash state and assuming DMA mapping was slow enough on your platform, you could solve it by maintaining a fixed set of hash states that are rotated through the actual hash requests. Let's say you allocate n such hash states which are always mapped, then if there are less than n hash requests outstanding, you could directly use the mapped hash states in the requests. If there are more than n, then you simply copy in/copy out for each hash operation. The number n limits how many operations can be pending to be processed by the hardware. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt