From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 9E1E3941286 for ; Tue, 6 Feb 2024 15:22:00 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=nZp67mLu1matNVhizGxbNQH48BgNq/UVdcendBFRhl8=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1707232919; v=1; b=t4x6RzI/p/dqfa9AZybn14hoe7bOglhlAY2LPVvrSN64ypwrplmhREGEu5zMyJ6NLUbp7lDM usnfxnhVYdksNsv9t/OGVUhlJT0dA6ecyFzSHoodmQnM84xD/vaVOjNBAyjWj3eBt3gkeA7ipDo 8Ir+WwPrCRhPe+rsLe432ICM= X-Received: by 127.0.0.2 with SMTP id Pzt0YY7687511x9tabqRM7zn; Tue, 06 Feb 2024 07:21:59 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.24059.1707232918595275760 for ; Tue, 06 Feb 2024 07:21:58 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-668-anNhjobqM-uiVMEbSJNGrg-1; Tue, 06 Feb 2024 10:21:53 -0500 X-MC-Unique: anNhjobqM-uiVMEbSJNGrg-1 X-Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2B281862FD8; Tue, 6 Feb 2024 15:21:52 +0000 (UTC) X-Received: from [10.39.195.129] (unknown [10.39.195.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF9101103A; Tue, 6 Feb 2024 15:21:51 +0000 (UTC) Message-ID: Date: Tue, 6 Feb 2024 16:21:50 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] Dependency on CryptoLib increases my module size by 600Kb, being apparently too big for integration To: devel@edk2.groups.io, crossedcarpet@hotmail.com References: <3uMu.1707218692053543523.07Ka@groups.io> From: "Laszlo Ersek" In-Reply-To: <3uMu.1707218692053543523.07Ka@groups.io> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: Xt3H8D8jjlloHuAgPsji6qxox7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="t4x6RzI/"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 2/6/24 12:24, CrossedCarpet wrote: > Greetings everyone ,  > Integration of my module into a motherboard bricks the computer. > The integrator informed me that this might be happening due to the size > of the module given that 600kB is too big and as such the code will be > truncated once flashed. > I find this suspicious given that this would render CryptoLib hard to > use and I can also find modules like TlsDxe with sizes above 1Mb.  > Perhaps there are other ways to call this library that don't include > static linking? > Where can I read more about this module size hard limit? > Can someone give me any insight or tip on this subject? (1) There are multiple instances of BaseCryptLib and OpensslLib. For example, consider "CryptoPkg/Library/BaseCryptLibOnProtocolPpi/DxeCryptLib.inf": "Implements the BaseCryptLib and TlsLib using the services of the EDK II Crypto Protocol". (2) Which leads me to: "CryptoPkg/Driver/CryptoDxe.inf": "Produces the EDK II Crypto Protocol using the library services from BaseCryptLib and TlsLib. PcdCryptoServiceFamilyEnable is used to enable the subset of available services." Refer to "CryptoPkg/Readme.md" on CryptoDxe configuration. So, you may be able to (a) choose BaseCryptLib and/or OpensslLib instances for linking statically into your module that contain the actual crypto stuff, but a "trimmed" set of APIs (hopefully just what you need), or (b) use such a cryptlib instance that actually consumes a protocol and delegates the actual work to the CryptoDxe driver. Option (b) however requires your platform integrator to include / expose CryptoDxe, and then they need to configure the feature set of CryptoDxe very carefully (see CryptoPkg/Readme.md), lest a crypto primitive proves missing only at runtime. (With static linking and LTO, you have build-time symbol resolution and just the required feature set included; the problem is duplication across modules. With protocol / PPI abstraction, modules can share the crypto logic, but determining the *smallest sufficient* feature set for runtime, at build time, is a challenge. AIUI.) Laszlo -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115173): https://edk2.groups.io/g/devel/message/115173 Mute This Topic: https://groups.io/mt/104195858/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-