From: mingo@kernel.org (Ingo Molnar)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 6/8] efi/arm*: libstub: wire up GOP handling into the ARM UEFI stub
Date: Thu, 10 Mar 2016 10:25:53 +0100 [thread overview]
Message-ID: <20160310092552.GA19588@gmail.com> (raw)
In-Reply-To: <CAKv+Gu_rtQjWJ-=Nf-dEYEHVB5dwKMA_Mv2rVujBz9t=3qnUrA@mail.gmail.com>
* Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> On 10 March 2016 at 16:03, Ingo Molnar <mingo@kernel.org> wrote:
> >
> > * Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> >
> >> > So screen_info_guid should probably not be a 'const': you have to cast it away
> >> > anyway, adding artificial linebreaks and uglifying the code. It's also a bad
> >> > practice to cast away const-ness, it hinders move-consts-to-readonly-sections
> >> > efforts.
> >>
> >> The problem here is that the UEFI spec never uses const qualifiers in
> >> its APIs for by-ref parameters that are obviously never modified by
> >> the caller, such as these GUIDs. [...]
> >
> > Ah, ok. Two related thoughts came up:
> >
> > 1)
> >
> > While I was looking at this code and was asking myself why the EFI runtime is
> > generally invoked via a relatively fragile, non-type-checking vararg construct.
> >
> > Wouldn't you be better off by explicitly defining all the API variants, and then
> > internally calling the EFI runtime?
> >
> > That would neatly solve such const artifacts as well.
> >
> > So instead of:
> >
> >
> > + status = efi_call_early(allocate_pool, EFI_RUNTIME_SERVICES_DATA,
> > + sizeof(*si), (void **)&si);
> >
> > we could have something like:
> >
> > status = efi_early__allocate_pool(EFI_RUNTIME_SERVICES_DATA, sizeof(*si), &si);
> >
> > ...
> >
> > efi_early__free_pool(si);
> >
> >
> > i.e. it would look a lot more like a properly distributed, typed, structured
> > family of C function APIs, instead of this single central bastard of an ioctl()
> > interface.
> >
> > There's over 100 invocations of the EFI runtime in the Linux kernel, I think it
> > would be worth the effort. The wrapper inlines should be mostly trivial.
> >
> > That would also add an opportunity to actually document most of these calls.
> >
>
> If only. The ARM and arm64 wrappers actually simply resolve to
> correctly typed calls. While I am not an expert on the x86 side of
> things, I think the vararg stuff is needed to be able to perform the
> thunking required to do function calls using the MS ABI for x86_64.
So at least the efi_early calls seem to just be using a function pointer:
arch/x86/include/asm/efi.h: __efi_early()->call(__efi_early()->f, __VA_ARGS__);
Furthermore, my suggestion would work with arbitrarily structured thunking: my
suggestion was to put a typed C layer in there - and the layer itself could then
call the vararg construct internally. It's a C type demuxing, only a syntactic
effort, it does not change any real call signature.
> As far as documentation is concerned, all of these functions and
> protocol methods are documented in the UEFI spec, which is freely
> accessible. It may be somewhat redundant to have our own documentation
> for them.
I mean a properly split up typed C interface 'documents itself' to a large degree
- while with opaque varargs bugs can slip in more easily.
This is really an obvious argument ... it's the well known 'why ioctl()s are bad'
API argument.
It has no bearing on this series obviously, it's a cleanup suggestion that could
be done separately.
Thanks,
Ingo
next prev parent reply other threads:[~2016-03-10 9:25 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-10 5:40 [PATCH 0/8] EFI framebuffer support for ARM and arm64 Ard Biesheuvel
2016-03-10 5:40 ` [PATCH 1/8] efi: make install_configuration_table() boot service usable Ard Biesheuvel
2016-03-18 10:59 ` Matt Fleming
2016-03-18 11:02 ` Ard Biesheuvel
2016-03-10 5:40 ` [PATCH 2/8] efi: libstub: move Graphics Output Protocol handling to generic code Ard Biesheuvel
2016-03-18 11:25 ` Matt Fleming
2016-03-10 5:40 ` [PATCH 3/8] efi/x86: libstub: move to generic GOP code Ard Biesheuvel
2016-03-10 5:40 ` [PATCH 4/8] efi/x86: efifb: move DMI based quirks handling out of generic code Ard Biesheuvel
2016-03-18 10:50 ` Matt Fleming
2016-03-21 13:42 ` Peter Jones
2016-03-10 5:40 ` [PATCH 5/8] efi: efifb: use builtin_platform_driver and drop unused includes Ard Biesheuvel
2016-03-18 10:52 ` Matt Fleming
2016-03-21 13:43 ` Peter Jones
2016-03-10 5:40 ` [PATCH 6/8] efi/arm*: libstub: wire up GOP handling into the ARM UEFI stub Ard Biesheuvel
2016-03-10 8:25 ` Ingo Molnar
2016-03-10 8:36 ` Ard Biesheuvel
2016-03-10 9:03 ` Ingo Molnar
2016-03-10 9:14 ` Ard Biesheuvel
2016-03-10 9:25 ` Ingo Molnar [this message]
2016-03-10 10:25 ` Ard Biesheuvel
2016-03-10 14:49 ` Matt Fleming
2016-03-10 14:30 ` Matt Fleming
2016-03-18 11:37 ` Matt Fleming
2016-03-10 5:40 ` [PATCH 7/8] efi/arm*: efifb: expose efifb platform device if GOP is available Ard Biesheuvel
2016-03-10 5:40 ` [PATCH 8/8] efi/arm: populate screen_info based on data provided by the UEFI stub Ard Biesheuvel
2016-03-18 11:53 ` Matt Fleming
2016-03-18 11:57 ` Ard Biesheuvel
2016-03-10 16:12 ` [PATCH 0/8] EFI framebuffer support for ARM and arm64 Mark Langsdorf
2016-03-10 16:23 ` Ard Biesheuvel
2016-03-11 17:52 ` Alexander Graf
2016-03-11 18:24 ` Ard Biesheuvel
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-all 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=20160310092552.GA19588@gmail.com \
--to=mingo@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).