diff mbox

[v2,2/3] arm: Add [U]EFI runtime services support

Message ID 20131017140739.GI10834@console-pimps.org (mailing list archive)
State New, archived
Headers show

Commit Message

Matt Fleming Oct. 17, 2013, 2:07 p.m. UTC
On Thu, 03 Oct, at 12:24:40PM, Leif Lindholm wrote:
> +/*
> + * If you need to (temporarily) support buggy firmware.
> + */
> +#define KEEP_BOOT_SERVICES_REGIONS

Have you seen firmware that requires this? I'm just curious more than
anything else.

> +/*
> + * Returns 1 if 'facility' is enabled, 0 otherwise.
> + */
> +int efi_enabled(int facility)
> +{
> +	return test_bit(facility, &arm_efi_facility) != 0;
> +}
> +EXPORT_SYMBOL(efi_enabled);

This should move to drivers/firmware/efi/efi.c. Let me write a patch
that moves the x86 stuff out of arch/x86 and means you can get rid of
this hunk.

> +/*
> + * Called explicitly from init/mm.c
> + */

That's init/main.c.

> +void __init efi_enter_virtual_mode(void)
> +{
> +	efi_status_t status;
> +
> +	if (!efi_enabled(EFI_BOOT)) {
> +		pr_info("EFI services will not be available.\n");
> +		return;

This is dead code as PATCH 3 does,

Comments

Leif Lindholm Oct. 17, 2013, 2:31 p.m. UTC | #1
On Thu, Oct 17, 2013 at 03:07:39PM +0100, Matt Fleming wrote:
> > +/*
> > + * If you need to (temporarily) support buggy firmware.
> > + */
> > +#define KEEP_BOOT_SERVICES_REGIONS
> 
> Have you seen firmware that requires this? I'm just curious more than
> anything else.

Not really.
I _think_ I saw it on a debug build of a development platform once.
That coincided with me seeing a post on linux-efi about some laptop
that broke unless boot services regions were preserved, so I decided
to put it in there for any future debugging.
 
> > +/*
> > + * Returns 1 if 'facility' is enabled, 0 otherwise.
> > + */
> > +int efi_enabled(int facility)
> > +{
> > +	return test_bit(facility, &arm_efi_facility) != 0;
> > +}
> > +EXPORT_SYMBOL(efi_enabled);
> 
> This should move to drivers/firmware/efi/efi.c. Let me write a patch
> that moves the x86 stuff out of arch/x86 and means you can get rid of
> this hunk.
 
Excellent, thanks!

> > +/*
> > + * Called explicitly from init/mm.c
> > + */
> 
> That's init/main.c.
 
*cough*, right.

> > +void __init efi_enter_virtual_mode(void)
> > +{
> > +	efi_status_t status;
> > +
> > +	if (!efi_enabled(EFI_BOOT)) {
> > +		pr_info("EFI services will not be available.\n");
> > +		return;
> 
> This is dead code as PATCH 3 does,
> 
> diff --git a/init/main.c b/init/main.c
> index af310af..ec6d76e 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -875,6 +875,10 @@ static noinline void __init
> kernel_init_freeable(void)
> 	smp_prepare_cpus(setup_max_cpus);
> 
> 	do_pre_smp_initcalls();
> +
> +	if (IS_ENABLED(CONFIG_ARM) && efi_enabled(EFI_BOOT))
> +		efi_enter_virtual_mode();
> +

True.

However, this call site is likely to change in the future (preferably
to an early_initcall), if we redesign the memory mapping to be reusable
after kexec(). At which point the test in efi_enter_virtual_mode() will
make sense again.

Could I change the test in init/main.c to do
     if (IS_ENABLED(CONFIG_ARM) && IS_ENABLED(CONFIG_EFI))
instead?

/
    Leif
Mark Salter Oct. 17, 2013, 4:58 p.m. UTC | #2
On Thu, 2013-10-17 at 16:31 +0200, Leif Lindholm wrote:
> On Thu, Oct 17, 2013 at 03:07:39PM +0100, Matt Fleming wrote:
> > > +/*
> > > + * If you need to (temporarily) support buggy firmware.
> > > + */
> > > +#define KEEP_BOOT_SERVICES_REGIONS
> > 
> > Have you seen firmware that requires this? I'm just curious more than
> > anything else.
> 
> Not really.
> I _think_ I saw it on a debug build of a development platform once.
> That coincided with me seeing a post on linux-efi about some laptop
> that broke unless boot services regions were preserved, so I decided
> to put it in there for any future debugging.
>  

I see a fairly consistent segfault when the arm64 kernel calls the
SetVirtualAddressMap function. It doesn't happen when the boot services
regions are included in the mapping. This is with edk2 firmware. I
haven't really dug into where it goes wrong.
diff mbox

Patch

diff --git a/init/main.c b/init/main.c
index af310af..ec6d76e 100644
--- a/init/main.c
+++ b/init/main.c
@@ -875,6 +875,10 @@  static noinline void __init
kernel_init_freeable(void)
	smp_prepare_cpus(setup_max_cpus);

	do_pre_smp_initcalls();
+
+	if (IS_ENABLED(CONFIG_ARM) && efi_enabled(EFI_BOOT))
+		efi_enter_virtual_mode();
+