Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp384718ybt; Wed, 8 Jul 2020 02:16:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRhInHGhl6Q85Kj8Aq2bMmr/4/8x/UZUS7maSe7b90e4QBpkiB/HrCP2cxwLQlRVviUf6H X-Received: by 2002:a50:e801:: with SMTP id e1mr64410818edn.251.1594199773229; Wed, 08 Jul 2020 02:16:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594199773; cv=none; d=google.com; s=arc-20160816; b=ncc12Xoze74WiAURN9oCeAvrlgUH8Uon7I9se2qOC551mhL20hn8bqZ/9u07JanNIT 1MTyhGlKcu4ui+sWDkWvvt8DkThl0+jLS6CRrnwY3svglq0gDm93yDFarauDLwQM2vgB 4Bn6zLUgoI4I/SULBuUZGnoXJ7TOoo2fHsvVtYupv+1PRQpWA9T3rYFIo0pO7YERzwiT Bcb7KRUlnRavddL2nbQzLXIWbqc+QoNtT5OW29iOdpt7YDacUYSpeCGGlitHo/0gTadG YdninSzyXKx4KKIgdZoCQ3zarI6u1jDSACvWY8l/JUT8cv3TN34x9IVsQwl+hkf+jOd1 DULg== 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; bh=pEsS/98WrcRRX7dXR21VDIhAd54m9gqgMRdtjDiMR8Q=; b=yULLXtp0HhBWJsv/EEbsp598pUxyj0gNsdt2IXZBJssn6j3eh0ummsLb9Jl3XnLJZ7 NJiiQl0Tm9faZvQ9GehG/gKWes6+TapiFJSXg96UXAbv9Pd63N9ajyGg5elxLc072Iaa 60Vd/CXhSCloQ9jzPQQCWZjACrd8CxpmQU7NdCtqlxRiWm/ULkxOzrZrzm/8lIvhEqnV w/7NG5VyyvOCTbpfJHqOR2oz+RNDGTy24xZHdx7W3qasFKkc2Vid5pT0lBsAfuYoB4zx 2ckg7W7ciywCbva/qqohoVMRT5r88+Uv5Q/RTTcxaTuiowQ90KmPGpJkJmv/UtTU9tMa YrFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VD+sMg03; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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. [23.128.96.18]) by mx.google.com with ESMTP id lm6si15396999ejb.268.2020.07.08.02.15.49; Wed, 08 Jul 2020 02:16:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VD+sMg03; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 S1727005AbgGHJOQ (ORCPT + 99 others); Wed, 8 Jul 2020 05:14:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:56098 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726900AbgGHJOQ (ORCPT ); Wed, 8 Jul 2020 05:14:16 -0400 Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) (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 B4E6320658 for ; Wed, 8 Jul 2020 09:14:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594199655; bh=W4RJ8TnjM8EKXNimT6kcgKzCLFvLavsfK6Fdl3wz5EM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=VD+sMg03q04U0Q7nFsNixWNcWDz334HYJVnAB1Ev0o8A0x5k888MosSO5NlgVtjB7 Vva7r2KjAEc/Th0tdyaLSjbzoVJuIdQdt0lebnBzraicL1j1yNEiPL++GdneJh9M6q fy+14Uug11J1tLURdUXj8GM90UdpaFASj+cXtqf0= Received: by mail-oi1-f169.google.com with SMTP id x83so29687052oif.10 for ; Wed, 08 Jul 2020 02:14:15 -0700 (PDT) X-Gm-Message-State: AOAM533oxJnENcQ0kauZoraYynZUnVE3BWO7NerGembp/xZrcfCAS9oj BaDzN373V/yon4HjHOI3uTyADgJlrr04k4yuEWY= X-Received: by 2002:aca:f257:: with SMTP id q84mr6654032oih.174.1594199655141; Wed, 08 Jul 2020 02:14:15 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ard Biesheuvel Date: Wed, 8 Jul 2020 12:14:04 +0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: question regarding crypto driver DMA issue To: "Van Leeuwen, Pascal" Cc: "linux-crypto@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, 8 Jul 2020 at 11:56, Van Leeuwen, Pascal wrote: > > Hi, > > I have a question on behalf of a customer of ours trying to use the inside-secure crypto > API driver. They are experiencing issues with result data not arriving in the result buffer. > This seems to have something to do with not being able to DMA to said buffer, as they > can workaround the issue by explicitly allocating a DMA buffer on the fly and copying > data from there to the original destination. > > The problem I have is that I do not have access to their hardware and the driver seems > to work just fine on any hardware (both x64 and ARM64) I have available here, so I > have to approach this purely theoretically ... > > For the situation where this problem is occuring, the actual buffers are stored inside > the ahash_req structure. So my question is: is there any reason why this structure may > not be DMA-able on some systems? (as I have a hunch that may be the problem ...) > If DMA is non-coherent, and the ahash_req structure is also modified by the CPU while it is mapped for DMA, you are likely to get a conflict. It should help if you align the DMA-able fields sufficiently, and make sure you never touch them while they are mapped for writing by the device.