Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2793716pxp; Tue, 22 Mar 2022 06:17:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdbvguM1AJU7vxtkFRReEUqVOa9jRgDgHckxkps38pUx1tmRWg1lj7W+v50QvPxgRA4RhI X-Received: by 2002:a17:906:3144:b0:6ce:de5d:5e3b with SMTP id e4-20020a170906314400b006cede5d5e3bmr26149457eje.689.1647955071314; Tue, 22 Mar 2022 06:17:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647955071; cv=none; d=google.com; s=arc-20160816; b=nIv9tmEK7QQjf13029XESkoqx8aT5iu6+GLdyz/BSChu44daJDuieM81hpfgSgonDT gUkmevCgsRw4AShTtspQhT9K2HDCTmh+jEwS9rY8nzzGefaeeN/h6RTLxZ5xWiCnt5gV T9frL6PQggUWOyYrcuf+gJ/NI9ifiyhnaJIHDZ0J2syK2P4ERMFIKgZOQ4+ilCSQdsXt yH89BzvfIDVZVyYyUHa4L6DJx6PSxVamigAavLcsXIVFM3vv1iOy3BVkmMpvimsmMpof ISzN+VW1rW5z68zkwrd+97BghIhF6J9QxApk50ErNvHG/8cGUzLIMan0bKynPnc5l1E0 XIMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id; bh=JU3f6wLIRa5+u17NGFR/fDPZrfVXrF5TxWjGxMKIz3w=; b=jWqi0KgS9grnhVn9xMWQEHq4XPLgE7P1ta8/5x7YLxtsuaBupOmgwyd5dqMpxpbBpW x+AHxWzU3o2RM6L74eYzhPw18y2mwhZCgqOeZK2xQYfy9MpNJc+H7PinPPlNVaeus+rs FBLXXVIoTVqkv1NMsAYQWnOJ3QXcIgw4Jixu7i+sUcZl3mgwHzK8dBH9nvifl7ngbsRp sTc2FJv342qMW9Ac8XwaNNov6G9Hc1JY6twk1s1lhwfY8yzvlrsNmQtA+u0uNSHpk9wd OQkvjqTdhYmtfJsRIsiG0z974qWIZchjVLAqraHYqHzWjedRkVHrHZ777r4i2iEx49sO PvUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x7-20020a50f187000000b00418c2b5bed8si10899096edl.442.2022.03.22.06.17.24; Tue, 22 Mar 2022 06:17:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232609AbiCVJiv (ORCPT + 99 others); Tue, 22 Mar 2022 05:38:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231836AbiCVJis (ORCPT ); Tue, 22 Mar 2022 05:38:48 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE0755F88 for ; Tue, 22 Mar 2022 02:37:20 -0700 (PDT) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=[127.0.0.1]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1nWawt-0006Jj-Mp; Tue, 22 Mar 2022 10:37:07 +0100 Message-ID: <828a8d00-ab9a-a7eb-4ad0-f95a63c7fb39@pengutronix.de> Date: Tue, 22 Mar 2022 10:37:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [EXT] [PATCH v6 3/4] crypto: caam - add in-kernel interface for blob generator Content-Language: en-US From: Ahmad Fatoum To: Pankaj Gupta , Horia Geanta , Herbert Xu , "David S. Miller" Cc: Sumit Garg , David Gstir , Matthias Schiffer , "kernel@pengutronix.de" , Franck Lenormand , Richard Weinberger , Jan Luebbe , James Morris , Mimi Zohar , "linux-kernel@vger.kernel.org" , Eric Biggers , "linux-security-module@vger.kernel.org" , "keyrings@vger.kernel.org" , "linux-crypto@vger.kernel.org" , David Howells , Jarkko Sakkinen , "linux-integrity@vger.kernel.org" , James Bottomley , "tharvey@gateworks.com" , "Serge E. Hallyn" References: <20220316164335.1720255-1-a.fatoum@pengutronix.de> <20220316164335.1720255-4-a.fatoum@pengutronix.de> <23cd140f-1046-7059-c9bd-ca4aac1d5183@pengutronix.de> In-Reply-To: <23cd140f-1046-7059-c9bd-ca4aac1d5183@pengutronix.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: a.fatoum@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Pankaj, On 22.03.22 08:32, Ahmad Fatoum wrote: > Hello Pankaj, > > On 22.03.22 07:25, Pankaj Gupta wrote: >> Hi Ahmad, >> >> Suggested to define macro with more details. >> Please find comments in-line. >> > >> len = 4 + (4 + ALIGN(keymod_len, 4)) + 2*(4 + 4 + >>>>>> + CAAM_PTR_SZ_MAX) + 4; >> >>> +/* header + (key mod immediate) + 2x seq_intlen pointers + op */ >>> +#define CAAM_BLOB_DESC_BYTES_MAX \ >>> + (CAAM_CMD_SZ + \ >>> + CAAM_CMD_SZ + CAAM_BLOB_KEYMOD_LENGTH + \ >>> + 2 * (CAAM_CMD_SZ + CAAM_PTR_SZ_MAX) + \ >>> + CAAM_CMD_SZ) >>> + >> >> Suggested to replace the above macro like below: >> >> +#define CAAM_BLOB_DESC_BYTES_MAX \ >> + (CAAM_CMD_SZ + \ /* Command to initialize & stating length of descriptor */ >> + CAAM_CMD_SZ + CAAM_BLOB_KEYMOD_LENGTH + \ /* Command to append the key-modifier + followed by the key-modifier data */ >> + (CAAM_CMD_SZ + CAAM_PTR_SZ_MAX) + \ /* Command to include input plain key and pointer to the input key */ >> + (CAAM_CMD_SZ + CAAM_PTR_SZ_MAX) + \ /* Command to include output-key blob and pointer to the output-key blob */ >> + CAAM_CMD_SZ) /* Command describing the Operation to perform */ > > > Sure thing, will do for v7. Otherwise, if all looks good to you, > can I have your Reviewed-by? This doesn't compile as-is and it leads to quite long lines. The description isn't accurate also, because what's plain and what's blob changes depending on whether we encapsulate or decapsulate. Here's my revised macro version: #define CAAM_BLOB_DESC_BYTES_MAX \ /* Command to initialize & stating length of descriptor */ \ (CAAM_CMD_SZ + \ /* Command to append the key-modifier + key-modifier data */ \ CAAM_CMD_SZ + CAAM_BLOB_KEYMOD_LENGTH + \ /* Command to include input key + pointer to the input key */ \ CAAM_CMD_SZ + CAAM_PTR_SZ_MAX + \ /* Command to include output key + pointer to the output key */ \ CAAM_CMD_SZ + CAAM_PTR_SZ_MAX + \ /* Command describing the Operation to perform */ \ CAAM_CMD_SZ) Alternatively, I can change it back into a function: static inline u32 *caam_blob_desc_alloc(void) { size_t size = 0; /* Command to initialize & stating length of descriptor */ size += CAAM_CMD_SZ; /* Command to append the key-modifier + key-modifier data */ size += CAAM_CMD_SZ + CAAM_BLOB_KEYMOD_LENGTH; /* Command to include input plain key + pointer to the input key */ size += CAAM_CMD_SZ + CAAM_PTR_SZ_MAX; /* Command to include output-key blob + pointer to the output key */ size += CAAM_CMD_SZ + CAAM_PTR_SZ_MAX; /* Command describing the Operation to perform */ size += CAAM_CMD_SZ; return kzalloc(size, GFP_KERNEL | GFP_DMA); } Let me know what works better for you. Cheers, Ahmad > > Thanks, > Ahmad > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |