From: Marc Zyngier <marc.zyngier@arm.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>, linux-efi@vger.kernel.org
Cc: john.garry@huawei.com, linux-arm-kernel@lists.infradead.org,
Jan.Glauber@cavium.com
Subject: Re: [RFT PATCH] efi: map memreserve table before first use
Date: Tue, 20 Nov 2018 18:29:00 +0000 [thread overview]
Message-ID: <a6374bfb-9848-c265-224a-dd77118277ad@arm.com> (raw)
In-Reply-To: <20181120173542.31444-1-ard.biesheuvel@linaro.org>
Hi Ard,
On 20/11/2018 17:35, Ard Biesheuvel wrote:
> Mapping the MEMRESERVE EFI configuration table from an early initcall
> is too late: the GICv3 ITS code that creates persistent reservations
> for the boot CPU's LPI tables is invoked from init_IRQ(), which runs
> much earlier than the handling of the initcalls.
>
> So instead, move the initialization performed by the initcall into
> efi_mem_reserve_persistent() itself.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
I've just given it a go on one of my TX2s, and it boots just fine. So
for that:
Tested-by: Marc Zyngier <marc.zyngier@arm.com>
A comment below though:
> ---
> drivers/firmware/efi/efi.c | 26 ++++++++++----------------
> 1 file changed, 10 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
> index fad7c62cfc0e..40de2f6734cc 100644
> --- a/drivers/firmware/efi/efi.c
> +++ b/drivers/firmware/efi/efi.c
> @@ -967,15 +967,23 @@ bool efi_is_table_address(unsigned long phys_addr)
> }
>
> static DEFINE_SPINLOCK(efi_mem_reserve_persistent_lock);
> -static struct linux_efi_memreserve *efi_memreserve_root __ro_after_init;
> +static struct linux_efi_memreserve *efi_memreserve_root;
>
> int efi_mem_reserve_persistent(phys_addr_t addr, u64 size)
> {
> struct linux_efi_memreserve *rsv;
>
> - if (!efi_memreserve_root)
> + if (efi.mem_reserve == EFI_INVALID_TABLE_ADDR)
> return -ENODEV;
>
> + if (!efi_memreserve_root) {
> + efi_memreserve_root = memremap(efi.mem_reserve,
> + sizeof(*efi_memreserve_root),
> + MEMREMAP_WB);
> + if (WARN_ON_ONCE(!efi_memreserve_root))
> + return -ENOMEM;
This is now a bit racy if there is more than a single online CPU.
> + }
> +
> rsv = kmalloc(sizeof(*rsv), GFP_ATOMIC);
> if (!rsv)
> return -ENOMEM;
> @@ -991,20 +999,6 @@ int efi_mem_reserve_persistent(phys_addr_t addr, u64 size)
> return 0;
> }
>
> -static int __init efi_memreserve_root_init(void)
> -{
> - if (efi.mem_reserve == EFI_INVALID_TABLE_ADDR)
> - return -ENODEV;
> -
> - efi_memreserve_root = memremap(efi.mem_reserve,
> - sizeof(*efi_memreserve_root),
> - MEMREMAP_WB);
> - if (!efi_memreserve_root)
> - return -ENOMEM;
> - return 0;
> -}
> -early_initcall(efi_memreserve_root_init);
But if we keep this (+ a check that the root is indeed NULL), we should
be able to make sure efi_memreserve_root is set before we enable a
secondary CPU. Still fragile though.
Thoughts?
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2018-11-20 18:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-20 17:35 [RFT PATCH] efi: map memreserve table before first use Ard Biesheuvel
2018-11-20 18:29 ` Marc Zyngier [this message]
2018-11-20 18:35 ` Ard Biesheuvel
2018-11-20 18:44 ` Marc Zyngier
2018-11-21 9:56 ` Jan Glauber
2018-11-21 13:33 ` John Garry
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=a6374bfb-9848-c265-224a-dd77118277ad@arm.com \
--to=marc.zyngier@arm.com \
--cc=Jan.Glauber@cavium.com \
--cc=ard.biesheuvel@linaro.org \
--cc=john.garry@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-efi@vger.kernel.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