From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
To: Ard Biesheuvel <ardb@kernel.org>, torvalds@linux-foundation.org
Cc: linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
catalin.marinas@arm.com, will@kernel.org,
Ilias Apalodimas <ilias.apalodimas@linaro.org>
Subject: Re: [PATCH] arm64: efi: Make runtime region misalignment warning less noisy
Date: Sun, 6 Nov 2022 00:24:34 +0100 [thread overview]
Message-ID: <86e2cd39-630a-da76-bbfd-99815a8c2753@canonical.com> (raw)
In-Reply-To: <20221105225234.3089177-1-ardb@kernel.org>
On 11/5/22 23:52, Ard Biesheuvel wrote:
> The EFI spec requires that on arm64 systems, all runtime code and data
> regions that share a 64k page can be mapped with the same memory type
> attributes. Unfortunately, this does not take permission attributes into
> account, and so the firmware is permitted to expose runtime code and
> data regions that share 64k pages, and this may prevent the OS from
> using restricted permissions in such cases, e.g., map data regions with
> non-exec attributes.
This is the relevant paragraph in the UEFI specification:
<cite>
The ARM architecture allows mapping pages at a variety of granularities,
including 4KiB and 64KiB. If a 64KiB physical page contains any 4KiB
page with any of the following types listed below, then all 4KiB pages
in the 64KiB page must use identical ARM Memory Page Attributes (as
described in Map EFI Cacheability Attributes to AArch64 Memory Types):
- EfiRuntimeServicesCode
- EfiRuntimeServicesData
- EfiReserved
- EfiACPIMemoryNVS
Mixed attribute mappings within a larger page are not allowed.
</cite>
It remains unclear if only EFI Cacheability of also other page
attributes are meant. The UEFI specification should be clarified in this
respect.
>
> We currently emit a warning when hitting this at boot, but the warning
> is problematic for a number of reasons:
> - it uses WARN() which spews a lot of irrelevant information into the
> log about the execution context where the issue was detected;
> - it only takes the start of the region into account and not the size
Is the occurrence of the warning specific to U-Boot or do you see the
warning with EDK II too?
>
> Let's just drop the warning, as the condition does not strictly violate
> the spec (although it only occurs with U-Boot), and fix the check to
> take both the start and the end addresses into account.
>
> Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> ---
> arch/arm64/kernel/efi.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
> index e1be6c429810d0d5..3dd6f0c66f8aeb78 100644
> --- a/arch/arm64/kernel/efi.c
> +++ b/arch/arm64/kernel/efi.c
> @@ -25,8 +25,8 @@ static __init pteval_t create_mapping_protection(efi_memory_desc_t *md)
> if (type == EFI_MEMORY_MAPPED_IO)
> return PROT_DEVICE_nGnRE;
>
> - if (WARN_ONCE(!PAGE_ALIGNED(md->phys_addr),
> - "UEFI Runtime regions are not aligned to 64 KB -- buggy firmware?"))
> + if (!PAGE_ALIGNED(md->phys_addr) ||
> + !PAGE_ALIGNED(md->num_pages * EFI_PAGE_SIZE))
Enhancing the check is correct.
The warning tells that Linux cannot establish secure settings for some
pages. It would be preferable to keep it and fix the UEFI specification
and the firmware instead.
Best regards
Heinrich
> /*
> * If the region is not aligned to the page size of the OS, we
> * can not use strict permissions, since that would also affect
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-11-05 23:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-05 22:52 [PATCH] arm64: efi: Make runtime region misalignment warning less noisy Ard Biesheuvel
2022-11-05 23:24 ` Heinrich Schuchardt [this message]
2022-11-06 2:26 ` Heinrich Schuchardt
2022-11-06 9:48 ` Ard Biesheuvel
2022-11-06 10:40 ` Ard Biesheuvel
2022-11-06 10:44 ` Heinrich Schuchardt
2022-11-06 10:51 ` 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=86e2cd39-630a-da76-bbfd-99815a8c2753@canonical.com \
--to=heinrich.schuchardt@canonical.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=ilias.apalodimas@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-efi@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=will@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