From: "Nate DeSimone" <nathaniel.l.desimone@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>
Subject: FW: [edk2-discuss] GSoC Proposal
Date: Wed, 13 Apr 2022 22:50:18 +0000 [thread overview]
Message-ID: <MW4PR11MB5821D15BEA1CC70E3D8AEEABCDEC9@MW4PR11MB5821.namprd11.prod.outlook.com> (raw)
In-Reply-To: <MW4PR11MB582163731C2B1EC9E59F24DDCDEC9@MW4PR11MB5821.namprd11.prod.outlook.com>
Hi Ada,
Great to meet you and welcome to the TianoCore project! Great to hear you are interested! Despite Marvin's misgivings, I think dynamic linking would be an excellent addition to EDK II! Marvin is right that we would not want to use it in UEFI spec compliant applications or OpROMs at least for now, but even if you make the assumption that this feature would only be used with EDK II it is still valuable. The primary value I see is reducing the size of BIOS images. Every DXE driver and PEIM includes a lot of statically linked libraries from MdePkg and/or MdeModulePkg depending on the exact driver and build configuration, and it adds up very quickly. On debug builds, the infrastructure for debug messages becomes particularly large. Every PEIM/DXE driver needs to have a copy of the parser for printf() style format strings. The overhead works out to ~12KB for every PEIM and DXE driver. Most BIOS images have ~250 DXE drivers and ~30 PEIMs these days. Uncompressed that works out to >3MB of overhead. The DXE drivers are typically compressed, but LZMA isn't perfect at deduplication and as optimizing compliers have gotten better the deduplication has gotten worse, which is causing this to become more important over time. I did some experiments with the Intel reference BIOS and I found that we can save roughly 1.5-2MB of space with dynamic linking, which is >10% of the flash budget. For PEI where there is no compression, the flash budget savings is >20%, and it has the extra benefit of reducing usage of precious NEM memory. Another thing to consider is that linking OpenSSL for doing code signing checks add ~65KB to the size of the PEIM doing the signature check. When you consider that moving PEI from 32-bit to 64-bit is going to increase code size by ~20%, this feature is extremely valuable for many reasons.
More forward looking, if the project to add Rust is successful then suddenly the rich set of libraries available in Rust crates becomes available to EDK II. Those are going to be big and the only way we will be able to use them is with some deduplication facility like dynamic linking. That will require having some way of using type safe Rust objects across driver boundaries... which is completely out of scope for this GSoC project, but at the same time this GSoC project would be a necessary prerequisite before we could even start thinking about that 😊.
I agree with Marvin that PE/COFF should be the preferred starting point. I believe ELF to be a security risk. It looks easy to parse on the surface but it has been well documented that the devil is in the details and as the CVE history shows it is very easy to build a ELF parser with unintended overflows and other security vulnerabilities. Perhaps most worrying to me is that I don't believe the security community has done enough research on ELF yet, whereas PE/COFF has been very heavily researched and has a mature literature.
Let me know if any of this piques your interest, I would be happy to answer any questions you have!
Hope this helps and welcome to the project!
With Best Regards,
Nate
> -----Original Message-----
> From: discuss@edk2.groups.io <discuss@edk2.groups.io> On Behalf Of Ada
> Christine
> Sent: Tuesday, April 12, 2022 11:09 AM
> To: discuss@edk2.groups.io
> Subject: [edk2-discuss] GSoC Proposal
>
> Hello, edk2 developers!
>
> I've registered as a contributor candidate for GSoC 2022 and am
> interested in working on one of the items from the Tasks list here
> https://github.com/tianocore/tianocore.github.io/wiki/Tasks.
> Specifically, adding dynamic linking support caught my attention as
> this is something i've been investigating and learning more about in
> one of my own personal projects. As a little background, my personal
> project is an experiment in OS development and I use a very small
> subset of the boot services to get started and loaded. It can be found here: https://github.com/adachristine/sophia.
> Recently I've started investigating (and begun to implement) using
> ELF's dynamic facilities to dynamically load kernel modules. I know PE
> is slightly different to ELF, but the principles seem similar enough.
>
> I've had a few glances at the EDKII source code in the past and have a
> general idea of how it all fits together. What I have in mind to
> implement this would be the following:
> - create a dynamic linker as a module package to be compiled into the
> main application
> (alternatively, implement dynamic linking as a runtime service
> driver?)
> - adjust the build system to enable building as DLLs and dynamic
> linking of module packages to the main application
> (module packages could be per-application and optionally site
> packages in a subdirectory of the ESP?)
>
> I know the details of how this would all fit together are a little
> more involved, but this is just the rough first idea that came to my
> mind. Happy to hear feedback, and if my idea seems feasible I can get
> to work on a more in-depth plan to put this together.
>
> Thanks!
>
> - Ada
>
>
>
>
prev parent reply other threads:[~2022-04-13 22:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <t4R6.1649786926384402958.oz5x@groups.io>
2022-04-13 6:54 ` [edk2-discuss] GSoC Proposal Marvin Häuser
2022-04-13 14:44 ` Rebecca Cran
[not found] ` <16E57BE84FE390E6.22782@groups.io>
2022-04-13 14:46 ` [edk2-devel] " Rebecca Cran
[not found] ` <MW4PR11MB582163731C2B1EC9E59F24DDCDEC9@MW4PR11MB5821.namprd11.prod.outlook.com>
2022-04-13 22:50 ` Nate DeSimone [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MW4PR11MB5821D15BEA1CC70E3D8AEEABCDEC9@MW4PR11MB5821.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox