Received: by 10.223.185.116 with SMTP id b49csp1020274wrg; Fri, 16 Feb 2018 10:57:25 -0800 (PST) X-Google-Smtp-Source: AH8x2275HQG4PlCWLpun1oV9Ihr6apkH5hAivWeICYlcnM6DYCc80BJPKblShCz1mIKwf9lmOmRm X-Received: by 10.98.28.66 with SMTP id c63mr6971841pfc.109.1518807445244; Fri, 16 Feb 2018 10:57:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518807445; cv=none; d=google.com; s=arc-20160816; b=qH6ddSLAQ4yLQ1wk4gB3r1oxDWAaVM+/Ww/FlL2hmPwgd6nqAv15dmDUgVuMpa1JKP ttT/Ad4+YHokrjpX5KPH96W0Kzl6B/q9g+FXzFXsDfeaQc+oHXGdSyFyoSGq4+ymTvLX nYL/fVERXpiXipW1cCA/D55aGo58OGfnKHEDMclfqj46OGuzkSgVOgHmeiG/+CNu9HDF YbmCadH1cGe85qaYMVTHBm9oMNnEgnCDisk/RnSRVmxCGNqO6LUUYvN8k+Fh4Hr5ho64 aGEiZRBS6HIte9sb1aJZ4NfzglU2cfXldLSYMsOL/iwdWNok3EiLZdEXVv7SpmiAGwut /neQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=YATLJcXOwBJtE3MoP/fPgNjCVpiJKTFxcsWNW/XgtkU=; b=FSjOaU/D41eV79CdHlyqumrVeZ7Q6/rsqMe6m56izovdrOk922gPcr2KEkaVzECeKa aMC++DeqY7aZjHodLBjMidEWfn5WO5dqjEhm/aktwFLQ//HByFN0GlrkFuwReGXZ8LNc 9FGc3iEEqWgUqVW2A3vzRsfbBG7JKnQ0VfT+aAKqApdo+YtodTHxj/q9Wr3gAk5syMFd OhDUNmXq7A/FLvcep8JB3AJjiZANRtBgHKbtPfsbEdp375UZGL4qjMtyfrHMw6PEL/bK 2ZLUj4PoSRAcV12XLWgJyBnH0slNBT0M1d1dDR3byHipVPSi7wm9yfl+0/va8iYjf/Rd 66Xw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5-v6si66921plh.450.2018.02.16.10.57.10; Fri, 16 Feb 2018 10:57:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932995AbeBPJ4T (ORCPT + 99 others); Fri, 16 Feb 2018 04:56:19 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:38121 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932979AbeBPJ4S (ORCPT ); Fri, 16 Feb 2018 04:56:18 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3zjT6y4ksfz1qwRq; Fri, 16 Feb 2018 10:56:10 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 3zjT6y1BgPz1sQwx; Fri, 16 Feb 2018 10:56:10 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id vlSleiBRFdwz; Fri, 16 Feb 2018 10:56:08 +0100 (CET) X-Auth-Info: /U1vaX5GzsmiyiBR1KOgY1XOY4Np53JOM1mxKi5RcwA= Received: from [IPv6:::1] (unknown [195.140.253.167]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 16 Feb 2018 10:56:08 +0100 (CET) Subject: Re: [PATCH v3 0/5] crypto: ahash.c: Require export/import in ahash To: Kamil Konieczny , Herbert Xu Cc: linux-crypto@vger.kernel.org, "David S. Miller" , Bartlomiej Zolnierkiewicz , Sonic Zhang , Fabio Estevam , Shawn Guo , Tom Lendacky , Jan Engelhardt , Arvind Yadav , Linus Walleij , Joakim Bech , linux-kernel@vger.kernel.org References: <20180118183404.12583-1-k.konieczny@partner.samsung.com> <20180215154132.GA7352@gondor.apana.org.au> <6b29116a-c39c-9813-34a0-d5c05bd30c9d@denx.de> <32069edc-e816-6ab0-f057-b1dab5d30db4@partner.samsung.com> <14364c45-8f56-e6d6-66f2-8357bf89a894@denx.de> <77b4e0a0-0e2c-af7a-690e-4d516d616717@partner.samsung.com> From: Marek Vasut Message-ID: <9c9d274c-f2fc-7f2c-1ae9-81dd0f116bbb@denx.de> Date: Fri, 16 Feb 2018 10:49:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <77b4e0a0-0e2c-af7a-690e-4d516d616717@partner.samsung.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/16/2018 10:16 AM, Kamil Konieczny wrote: > > On 15.02.2018 19:32, Marek Vasut wrote: >> On 02/15/2018 07:06 PM, Kamil Konieczny wrote: >>> >>> >>> On 15.02.2018 18:06, Marek Vasut wrote: >>>> On 02/15/2018 06:00 PM, Kamil Konieczny wrote: >>>>> >>>>> >>>>> On 15.02.2018 17:27, Marek Vasut wrote: >>>>>> On 02/15/2018 04:41 PM, Herbert Xu wrote: >>>>>>> On Thu, Jan 18, 2018 at 07:33:59PM +0100, Kamil Konieczny wrote: >>>>>>>> First four patches add empty hash export and import functions to each driver, >>>>>>>> with the same behaviour as in crypto framework. The last one drops them from >>>>>>>> crypto framework. Last one for ahash.c depends on all previous. >>>>>>>> >>>>>>>> Changes in v3: >>>>>>>> added change for bfin_crc.c >>>>>>>> make this a patchset, instead of unreleated patches >>>>>>>> make commit message more descriptive >>>>>>>> >>>>>>>> Kamil Konieczny (5): >>>>>>>> crypto: mxs-dcp: Add empty hash export and import >>>>>>>> crypto: n2_core: Add empty hash export and import >>>>>>>> crypto: ux500/hash: Add empty export and import >>>>>>>> crypto: bfin_crc: Add empty hash export and import >>>>>>>> crypto: ahash.c: Require export/import in ahash >>>>>>>> >>>>>>>> crypto/ahash.c | 18 ++---------------- >>>>>>>> drivers/crypto/bfin_crc.c | 12 ++++++++++++ >>>>>>>> drivers/crypto/mxs-dcp.c | 14 ++++++++++++++ >>>>>>>> drivers/crypto/n2_core.c | 12 ++++++++++++ >>>>>>>> drivers/crypto/ux500/hash/hash_core.c | 18 ++++++++++++++++++ >>>>>>>> 5 files changed, 58 insertions(+), 16 deletions(-) >>>>>>> >>>>>>> All applied. Thanks. >>>>>> >>>>>> This makes no sense, cfr my comment on 5/5 >>>>>> >>>>>> Seems like if the driver doesn't implement those, the core can easily >>>>>> detect that and perform the necessary action. Moving the checks out of >>>>>> core seems like the wrong thing to do, rather you should enhance the >>>>>> checks in core if they're insufficient in my opinion. >>>>> >>>>> The bug can only be in driver which will not implement those two functions, >>>>> but we already had all drivers with those due to patches 1..4 >>>>> All other drivers do have them. >>>> >>>> The core can very well check if these functions are not populated and >>>> return ENOSYS >>>> >>>>> Additionally, with crypto we want minimize code and run as fast as possible. >>>> >>>> So you remove all NULL pointer checks ? Esp. in security-sensitive code? >>>> What is the impact of this non-critical path code on performance? >>>> >>>> Come on ... >>>> >>> >>> Why you want checks for something that not exist ? >>> >>> Those without them will not work and will do Oops in crypto testmgr, >>> so such drivers should not be used nor accepted in drivers/crypto >>> >>> Ask yourself why crypto do not check for NULL in ahash digest or other >>> required ahash functions. >> >> Are you suggesting that the kernel code should NOT perform NULL pointer >> checks ? >> >> Are you suggesting each driver should implement every single callback >> available and if it is not implemented, return -ENOSYS ? This looks like >> a MASSIVE code duplication. > > It is source code duplication. One do not load all crypto drivers at once, > simple because one board has only one crypto HW (or few closely related), You can compile kernel with generic config and at that point you have all the duplicated code stored on your machine. But this discussion is moving away from the point I was concerned about -- that this patchset _increases_ code duplication and I find this wrong. > and if one even try, almost none of them will initialize on given > hardware. E.g. on Exynos board only exynos drivers will load, on board with > omap crypto only omap crypto will load. > >>>>> Moving checks out of core will impose on driver author need for implement >>>>> those functions, or declare them empty, but in case of empty ones >>>>> crypto will not work properly with such driver. >>>> >>>> You can very well impose that in the core, except you don't duplicate >>>> the code. >>> >>> Now size of crypto core is reduced. >> >> You implemented the same code thrice, it surely is not reduced. > > As I said above, it reduces binary size at cost of more source code in few drivers. It does NOT reduce the binary size, just try compiling all the drivers in and it will make the kernel bigger. -- Best regards, Marek Vasut