From: Ard Biesheuvel <ardb@kernel.org>
To: linux-efi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org,
Ard Biesheuvel <ardb@kernel.org>,
Johan Hovold <johan+linaro@kernel.org>,
Maximilian Luz <luzmaximilian@gmail.com>,
Nathan Chancellor <nathan@kernel.org>,
Steev Klimaszewski <steev@kali.org>,
Shawn Guo <shawn.guo@linaro.org>
Subject: [RFT PATCH 1/2] arm64: efi: Prefer a flat virtual mapping of the runtime services
Date: Tue, 17 Jan 2023 15:27:17 +0100 [thread overview]
Message-ID: <20230117142718.564299-2-ardb@kernel.org> (raw)
In-Reply-To: <20230117142718.564299-1-ardb@kernel.org>
With some systems, we cannot omit the boot time call to
SetVirtualAddressMap() even if the kernel VA space is sufficiently
large, because some buggy EFI implementations exist that misbehave if
SetVirtualAddressMap() is never called.
However, this does not mean we must reshuffle the EFI memory map: we can
simply invoke SetVirtualAddressMap() with a memory map that places each
EFI runtime region at the same virtual address that it takes up in the
physical address map.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/arm64/include/asm/efi.h | 2 ++
drivers/firmware/efi/libstub/efi-stub.c | 6 +++++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h
index de4ff90785b2c96a..98c4dc4da5a90e8c 100644
--- a/arch/arm64/include/asm/efi.h
+++ b/arch/arm64/include/asm/efi.h
@@ -114,6 +114,8 @@ static inline unsigned long efi_get_kimg_min_align(void)
#define EFI_ALLOC_ALIGN SZ_64K
#define EFI_ALLOC_LIMIT ((1UL << 48) - 1)
+#define EFI_USE_FLAT_VA_MAPPING (VA_BITS_MIN >= 48)
+
/*
* On ARM systems, virtually remapped UEFI runtime services are set up in two
* distinct stages:
diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
index 2955c1ac6a36ee00..40869320d601492a 100644
--- a/drivers/firmware/efi/libstub/efi-stub.c
+++ b/drivers/firmware/efi/libstub/efi-stub.c
@@ -44,8 +44,12 @@
#define EFI_RT_VIRTUAL_OFFSET 0
#endif
+#ifndef EFI_USE_FLAT_VA_MAPPING
+#define EFI_USE_FLAT_VA_MAPPING (EFI_RT_VIRTUAL_OFFSET != 0)
+#endif
+
static u64 virtmap_base = EFI_RT_VIRTUAL_BASE;
-static bool flat_va_mapping = (EFI_RT_VIRTUAL_OFFSET != 0);
+static bool flat_va_mapping = EFI_USE_FLAT_VA_MAPPING;
struct screen_info * __weak alloc_screen_info(void)
{
--
2.39.0
_______________________________________________
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:[~2023-01-17 14:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-17 14:27 [RFT PATCH 0/2] arm64: efi: Call SetVaMap() with a 1:1 mapping Ard Biesheuvel
2023-01-17 14:27 ` Ard Biesheuvel [this message]
2023-01-17 14:27 ` [RFT PATCH 2/2] arm64: efi: Force use of SetVirtualAddressMap() on MS Surface Ard Biesheuvel
2023-01-17 15:20 ` [RFT PATCH 0/2] arm64: efi: Call SetVaMap() with a 1:1 mapping Ard Biesheuvel
2023-01-17 17:30 ` Nathan Chancellor
2023-01-18 7:56 ` Ard Biesheuvel
2023-01-18 15:26 ` Nathan Chancellor
2023-01-18 15:33 ` Ard Biesheuvel
2023-02-27 19:43 ` Darren Hart
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=20230117142718.564299-2-ardb@kernel.org \
--to=ardb@kernel.org \
--cc=johan+linaro@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-efi@vger.kernel.org \
--cc=luzmaximilian@gmail.com \
--cc=nathan@kernel.org \
--cc=shawn.guo@linaro.org \
--cc=steev@kali.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).