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 3FDF7C433FE for ; Fri, 25 Nov 2022 05:08:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B63E6B0073; Fri, 25 Nov 2022 00:08:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 818606B0074; Fri, 25 Nov 2022 00:08:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 706E86B0075; Fri, 25 Nov 2022 00:08:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 5D0DD6B0073 for ; Fri, 25 Nov 2022 00:08:01 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 25708AAE12 for ; Fri, 25 Nov 2022 05:08:01 +0000 (UTC) X-FDA: 80170782762.25.B5BC59A Received: from formenos.hmeau.com (helcar.hmeau.com [216.24.177.18]) by imf23.hostedemail.com (Postfix) with ESMTP id 60783140009 for ; Fri, 25 Nov 2022 05:08:00 +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 1oyQS5-000djv-CO; Fri, 25 Nov 2022 12:36:38 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Fri, 25 Nov 2022 12:36:37 +0800 From: "Herbert Xu" Date: Fri, 25 Nov 2022 12:36:37 +0800 Subject: [v2 PATCH 5/9] crypto: skcipher - 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-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.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=1669352880; a=rsa-sha256; cv=none; b=dx57GOrS/enzorHFwcCwAjythIz7rPoqImZyCR3aajVeyOjeDYh9MndjiGlCN3WwtFdiYA c5CNx8OeqkzELBclnEsrr4ZVsYCHHF+O4abpZi0slSsW8EZsbxxpKSytEwT8WKUS3DUtMZ kCcTMi4BlSTFGF/7TE6CUxTLBWH8tdo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669352880; 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=Th1cT6A/G89MZ+4cqPqW93HER+ZSpOHYMUqPRjUvSg4=; b=zpXij5V0DFeZOew8gDT8e7GT19XFWzYcPZU6FNfe2KUqYlL7J6m8WDVyp1zgXZZVc8uVu0 dFAaRpXLlTOuaS1dwpz+ae/OJead5FvBORcEw/94zSbNUka0BuXZ48SGs1hV0ASzv1QJjP TsrUaSfQc4X+TIjrXFT5NLElxOhB34g= X-Rspamd-Queue-Id: 60783140009 X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.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-Rspamd-Server: rspam02 X-Stat-Signature: srmrsxfss5n11kqznfpjhg4o377dusof X-HE-Tag: 1669352880-572289 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 skcipher context structure and request context structure with an added alignment for DMA access. Signed-off-by: Herbert Xu --- include/crypto/internal/skcipher.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/crypto/internal/skcipher.h b/include/crypto/internal/skcipher.h index a2339f80a615..a05a55af5b2c 100644 --- a/include/crypto/internal/skcipher.h +++ b/include/crypto/internal/skcipher.h @@ -122,6 +122,13 @@ static inline void crypto_skcipher_set_reqsize( skcipher->reqsize = reqsize; } +static inline void crypto_skcipher_set_reqsize_dma( + struct crypto_skcipher *skcipher, unsigned int reqsize) +{ + reqsize += crypto_dma_align() & ~(crypto_tfm_ctx_alignment() - 1); + skcipher->reqsize = reqsize; +} + int crypto_register_skcipher(struct skcipher_alg *alg); void crypto_unregister_skcipher(struct skcipher_alg *alg); int crypto_register_skciphers(struct skcipher_alg *algs, int count); @@ -151,11 +158,26 @@ static inline void *crypto_skcipher_ctx(struct crypto_skcipher *tfm) return crypto_tfm_ctx(&tfm->base); } +static inline void *crypto_skcipher_ctx_dma(struct crypto_skcipher *tfm) +{ + return crypto_tfm_ctx_dma(&tfm->base); +} + static inline void *skcipher_request_ctx(struct skcipher_request *req) { return req->__ctx; } +static inline void *skcipher_request_ctx_dma(struct skcipher_request *req) +{ + unsigned int align = crypto_dma_align(); + + if (align <= crypto_tfm_ctx_alignment()) + align = 1; + + return PTR_ALIGN(skcipher_request_ctx(req), align); +} + static inline u32 skcipher_request_flags(struct skcipher_request *req) { return req->base.flags;