Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp890678pxp; Wed, 16 Mar 2022 20:20:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQzHR5mDKeMW/nuk9IwqtAw468lj+6Qsslp5sTlzWxE9vjArSGCiVhrnXt4Srb33FhDnT+ X-Received: by 2002:a63:5810:0:b0:381:6562:46fb with SMTP id m16-20020a635810000000b00381656246fbmr1995110pgb.567.1647487228488; Wed, 16 Mar 2022 20:20:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647487228; cv=none; d=google.com; s=arc-20160816; b=cu8R0+GVSjuxwfxQ5AjpKT4DG/OrksoswI8dc4IfZWqzCZFWU1fIxsmrI9C/5/grcd SnxaLJm38kBOH1GiPVLirrCbUUlkkj4uJ+LOFhNzl/fZVBPuU8NpbkWYU+W7556x6e9R kO5ajbWvDh0vVDrZBT+Cxb0rBrKlRYVx6eW8Gt4pLJaI9vDwq2+4f9S8NQneFcvTELl1 x6EDS6Ta24Nu04PK2APiJtQ4NnELJohVDuwINyPMKoKKr53nnvYp6BtbeWNgvJlBPW5A 7q+GriFNcOBvm5UMh8E7BUTL/cAhqp2j8l4F4Sw7j6phkg48dAOT6qFxeOi9UQ1ZbggW A2mg== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=PpWHMMA2hUld+1k6b88YMHrDlpqMd0M9w4w7rSHPR+Y=; b=L6H858Hm5pQx3YI119aZopd/hJMy/SupaXILOtl2QN5i3l+n6MSAv7m86mgzDDofg0 P1fle1aC19iDPVKZaqBcYOV6lgOFbE1B3cO4uLawHt9VSDLev8b1G5h1EpIp07Zcy5z0 uNOK44sEy3DZ2HhATId8ujh4Zis+mqkvBmFP0SrzM5BZJjM7wzpJ1ZNCaCPjR2S8rqge 1GJ/Dc0g9zvUh+sUDIS1gBJiMeWtD994YXCrEaSpNjYKwD0l7OvV+5yH549dgnEmYXbz Tgowb7Ri5SabmFU+5PtMKq0IWrGsu3nvYYWWRO1USZGPXFoszzNLH9QDl62PYtX8hiNS HbUg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j13-20020a170903028d00b0014f8a32b7e8si3402057plr.555.2022.03.16.20.20.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 20:20:28 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3121824588; Wed, 16 Mar 2022 20:20:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357655AbiCPQqi (ORCPT + 99 others); Wed, 16 Mar 2022 12:46:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357562AbiCPQqQ (ORCPT ); Wed, 16 Mar 2022 12:46:16 -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 396CB2F02C for ; Wed, 16 Mar 2022 09:44:32 -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 1nUWkq-0003wy-K2; Wed, 16 Mar 2022 17:44:08 +0100 Message-ID: Date: Wed, 16 Mar 2022 17:44:08 +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: [PATCH v5 4/5] crypto: caam - add in-kernel interface for blob generator Content-Language: en-US To: Jarkko Sakkinen Cc: =?UTF-8?Q?Horia_Geant=c4=83?= , Aymen Sghaier , Herbert Xu , "David S. Miller" , kernel@pengutronix.de, David Gstir , Pankaj Gupta , Tim Harvey , Matthias Schiffer , James Bottomley , Mimi Zohar , David Howells , James Morris , Eric Biggers , "Serge E. Hallyn" , Jan Luebbe , Richard Weinberger , Franck LENORMAND , Sumit Garg , linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org References: <20220222195819.2313913-1-a.fatoum@pengutronix.de> <20220222195819.2313913-5-a.fatoum@pengutronix.de> <79b912b5e9e16f446753270f7b9463fee95ebac7.camel@kernel.org> From: Ahmad Fatoum In-Reply-To: <79b912b5e9e16f446753270f7b9463fee95ebac7.camel@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Jarkko, On 28.02.22 13:14, Jarkko Sakkinen wrote: > On Wed, 2022-02-23 at 17:20 +0100, Ahmad Fatoum wrote: >> On 23.02.22 16:41, Jarkko Sakkinen wrote: >>> On Tue, Feb 22, 2022 at 08:58:18PM +0100, Ahmad Fatoum wrote: >>>> +       /* header + (key mod immediate) + 2x pointers + op */ >>>> +       len = 4 + (4 + ALIGN(keymod_len, 4)) + 2*(4 + 4 + CAAM_PTR_SZ_MAX) + 4; >>> >>> Nit: the amount of magic numbers is overwhelming here. I neither understand >>> the statement nor how that comment should help me to understand it. >> >> header              =  4 >> (key mod immediate) = (4 + ALIGN(keymod_len, 4)) >> 2x pointer          =  2 * (4 + 4 + CAAM_PTR_SZ_MAX) >> op                  =  4 > > Please create a struct with the associated fields instead and then > it is just sizeof that. The CAAM descriptor construction code writes the current length to the first word and then macros are used to append fields to the descriptor while incrementing the length. The key modifier is in the middle of the descriptor, so this isn't representable as a C struct without using VLAs, which are banned in the kernel. Even if it worked, it's arguably not good style to define a struct just to compute the size and then cast it to a u32 * to use the same macros all other CAAM code uses. I thought this over a bit and figured that we don't really need to compute the length dynamically as it's at most 44 or 52 bytes (depending on DMA address width) anyway, so we can just use a fixed value. I still keep the addition, because I believe there is a value in seeing how we arrive at the 44 or 52 bytes instead of just hardcoding it. Just sent out v6 with these changes. Let me know what you think. Cheers, 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 |