Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp57045imm; Thu, 30 Aug 2018 06:57:16 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYstHNcPulmWvGFRsMS1qnaA/7LLQeqeyLu2PEMvm+3oc1QTGnYsvhorJ8z4Y2QpcXxvjTg X-Received: by 2002:a63:a5c:: with SMTP id z28-v6mr9627313pgk.209.1535637436322; Thu, 30 Aug 2018 06:57:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535637436; cv=none; d=google.com; s=arc-20160816; b=KBTfaYY5U5+tzw6LXW0BtxTgqvyXtAjlcrFlmMtBL4x7Kb1k4old7WYuTsnah0ep8K PHJ8trkOCfDyJe/tBE5ZOeTM6YABTQI0rzaEVBGBJZ8qJoxCJC/M9KuN8/7EorE+7bEJ F72jtCvuq/vPPE82wuNEbOdQGgdE2PPrblguEQlj4gNEWS1U6XEZZcFw+UbCNv919QGU yQ097qN8tTOYJ51y6nM/06yW19vefpSws5hNOI3tRCX+Td6bVpdbMRS5W/WVg5Y2eYmk Dd3lQ8TXo03gFvu0KIEeusVTBmf7tvIQmep8UyRJ7KZK7rq6ED8rGk9UzG3vzx+UM740 IFeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=ZHXvTi3gJ9cj8Xt4my+GKuI/CVNl0/7Ar6R6Z08cGIw=; b=YnPaUBmpC8QJQ+EsIEzrRlPtj/48MLxBO62d47V3JhmnKZnoGrldtxTCEeC7yxouzo 9e25bUdQxSSHHOBaCcdC55d/QHJbfVtUYjrC91YXCWZd3CpEME5bjUHHVBtYEaByB3cv GIf12Fl24mrFp+FFY32wU/IYJBcA9GAvl/go1OHldvfy+jywmUeAaUExXDZw+tIxY3iY 7drvpyxqvoe9a8h2f+TNtsAF6TINqbV4POti//9rgvsht4vUDLB51CjPbqQXqYwCK6Ts RBqbUAWZXVMr/HmSNC/gkq6HUpL3GWVysAr3WE9LZ673Gc70cot91om+hh+lGiMk2Iiw usXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=R2qhYPzv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k11-v6si6514824pgi.328.2018.08.30.06.57.00; Thu, 30 Aug 2018 06:57:16 -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; dkim=pass header.i=@kernel.org header.s=default header.b=R2qhYPzv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729073AbeH3R4s (ORCPT + 99 others); Thu, 30 Aug 2018 13:56:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:37968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728604AbeH3R4s (ORCPT ); Thu, 30 Aug 2018 13:56:48 -0400 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0A18E20836; Thu, 30 Aug 2018 13:54:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1535637273; bh=StQvhtI+/F8HFYbg85QBEGjNa2g4hBKh5cKHFErAVTk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=R2qhYPzvk1MlXCtgniA/l4GzsFoLwXfLtaqn0OL15Pg+wP+KFzEDx9KjlC3OgJTng zIgl9lbXgCknJhsy8RwltN5yTdgk8k1hf6cSuZvjRPMu7sqgeL+eLimjQIiAjfZ58a ohe8bqL6EoDo0EjAUslNkLEjc6csUMaOWGM8aBBc= Received: by mail-wr1-f46.google.com with SMTP id o37-v6so8153997wrf.6; Thu, 30 Aug 2018 06:54:32 -0700 (PDT) X-Gm-Message-State: APzg51CfgWJRfgtU/IZBVZ5MO4cY9+F7RrGb8BSPZ7MNTtPnZgV7gqJL OgaFUJPTXMc+aR3KAwxS3KCTtQzlJ/22fwuhZSY= X-Received: by 2002:adf:f24e:: with SMTP id b14-v6mr7167864wrp.184.1535637271519; Thu, 30 Aug 2018 06:54:31 -0700 (PDT) MIME-Version: 1.0 References: <3053033.se6UkFii4W@tauon.chronox.de> <2002208.sm9qV7UXju@tauon.chronox.de> In-Reply-To: <2002208.sm9qV7UXju@tauon.chronox.de> From: Krzysztof Kozlowski Date: Thu, 30 Aug 2018 15:54:19 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Locking for HW crypto accelerators To: smueller@chronox.de Cc: herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 30 Aug 2018 at 15:19, Stephan Mueller wrote: > > Am Donnerstag, 30. August 2018, 15:09:05 CEST schrieb Krzysztof Kozlowski: > > Hi Krzysztof, > > > Thanks Stephan for hints. Let's assume the each of init, update and > > final are atomic... but how about the relation between update and > > final? I have two concurrent users in user-space but only one HW: > > > > Process A: Process B: > > init() and set_key() > > init() and different key > > update(some_data) > > update(different_data) > > final() > > final() > > > > The final() from process A will now produce the result of hashing/CRC > > of some_data and different_data (and even maybe mixed with init() for > > different key). All because in the meantime process B added its own > > data to the HW. > > The question is where is the state of the cipher operation kept that is > produced with each of the init/update/final calls. Your answer implies that > this state is kept in hardware. Yes, that's correct. The HW once initialized to specific CRC parameters (size, polynomial, initial value), will operate on this till another init happens. > But commonly the state is kept in software. Look at ahash_request for example, > the __ctx pointer is intended to point to the memory the driver needs to store > its state. > > Pick a random driver implementation and search for ahash_request_ctx, for > example. I see now some drivers are indeed saving and restoring state. Thanks! Best regards, Krzysztof