From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95D82C4332F for ; Fri, 25 Nov 2022 04:36:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DBAF8E0003; Thu, 24 Nov 2022 23:36:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 28C9F8E0002; Thu, 24 Nov 2022 23:36:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17AEB8E0003; Thu, 24 Nov 2022 23:36:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 03E7F8E0002 for ; Thu, 24 Nov 2022 23:36:49 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C74E8807B8 for ; Fri, 25 Nov 2022 04:36:48 +0000 (UTC) X-FDA: 80170704096.28.EF1458A Received: from formenos.hmeau.com (helcar.hmeau.com [216.24.177.18]) by imf20.hostedemail.com (Postfix) with ESMTP id 27D9D1C0008 for ; Fri, 25 Nov 2022 04:36:47 +0000 (UTC) Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1oyQS9-000dkR-IC; Fri, 25 Nov 2022 12:36:42 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Fri, 25 Nov 2022 12:36:41 +0800 From: "Herbert Xu" Date: Fri, 25 Nov 2022 12:36:41 +0800 Subject: [v2 PATCH 7/9] crypto: akcipher - Add ctx helpers with DMA alignment References: To: Ard Biesheuvel , Will Deacon , Marc Zyngier , Arnd Bergmann , Greg Kroah-Hartman , Andrew Morton , Linus Torvalds , Linux Memory Management List , Linux ARM , Linux Kernel Mailing List , "David S. Miller" , Linux Crypto Mailing List Message-Id: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669351008; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references:references; bh=wemd1EtwVOaKHj5YUWAHzksMxNrnzyltHoWdEJe2khA=; b=H0RUyiU+plEAZTN9Tb3iLgCfFCLCabXrwIa0qpMoY0VTZCgi48NfmGz+GInmb8uVNSXse2 9mPEm2WsxkFDZxusNCXg5eQs/7Z/TR+3CWjgVJA8notGl0UjrAvu6MSlEI0AOChYKXvkfQ kPctTTS51pxvv9csCXozEfecUuGLSRs= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of herbert@gondor.apana.org.au designates 216.24.177.18 as permitted sender) smtp.mailfrom=herbert@gondor.apana.org.au; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669351008; a=rsa-sha256; cv=none; b=sVaYACksH5aTnlEJvAOhrD1ABLoBBBxtqAH0phR1Rr3jyxdL0wZXUARzf9hHN5Ok7OPi76 b/LH2uE1EYQaB/FufQZjfjxrZhViT9W3sXksjRSUW8LAPFIvlH/Dyg7AN9lRDv/6AqYo0+ RvV+HhphrESsdU0viuviKQX3m08rnWA= X-Rspamd-Queue-Id: 27D9D1C0008 Authentication-Results: imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of herbert@gondor.apana.org.au designates 216.24.177.18 as permitted sender) smtp.mailfrom=herbert@gondor.apana.org.au; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: c5dx15ecdse47w6icbtrwhnhj39ugcez X-HE-Tag: 1669351007-651767 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This patch adds helpers to access the akcipher context structure and request context structure with an added alignment for DMA access. Signed-off-by: Herbert Xu --- include/crypto/internal/akcipher.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/include/crypto/internal/akcipher.h b/include/crypto/internal/akcipher.h index 1474a2d890fc..aaf1092b93b8 100644 --- a/include/crypto/internal/akcipher.h +++ b/include/crypto/internal/akcipher.h @@ -33,15 +33,37 @@ static inline void *akcipher_request_ctx(struct akcipher_request *req) return req->__ctx; } +static inline void *akcipher_request_ctx_dma(struct akcipher_request *req) +{ + unsigned int align = crypto_dma_align(); + + if (align <= crypto_tfm_ctx_alignment()) + align = 1; + + return PTR_ALIGN(akcipher_request_ctx(req), align); +} + static inline void akcipher_set_reqsize(struct crypto_akcipher *akcipher, unsigned int reqsize) { akcipher->reqsize = reqsize; } +static inline void akcipher_set_reqsize_dma(struct crypto_akcipher *akcipher, + unsigned int reqsize) +{ + reqsize += crypto_dma_align() & ~(crypto_tfm_ctx_alignment() - 1); + akcipher->reqsize = reqsize; +} + static inline void *akcipher_tfm_ctx(struct crypto_akcipher *tfm) { - return tfm->base.__crt_ctx; + return crypto_tfm_ctx(&tfm->base); +} + +static inline void *akcipher_tfm_ctx_dma(struct crypto_akcipher *tfm) +{ + return crypto_tfm_ctx_dma(&tfm->base); } static inline void akcipher_request_complete(struct akcipher_request *req,