Skip to content

Commit bb98273

Browse files
committed
efi: libstub: Move screen_info handling to common code
jira LE-2157 Rebuild_History Non-Buildable kernel-5.14.0-503.14.1.el9_5 commit-author Ard Biesheuvel <[email protected]> commit 732ea9d Empty-Commit: Cherry-Pick Conflicts during history rebuild. Will be included in final tarball splat. Ref for failed cherry-pick at: ciq/ciq_backports/kernel-5.14.0-503.14.1.el9_5/732ea9db.failed Currently, arm64, RISC-V and LoongArch rely on the fact that struct screen_info can be accessed directly, due to the fact that the EFI stub and the core kernel are part of the same image. This will change after a future patch, so let's ensure that the screen_info handling is able to deal with this, by adopting the arm32 approach of passing it as a configuration table. While at it, switch to ACPI reclaim memory to hold the screen_info data, which is more appropriate for this kind of allocation. Signed-off-by: Ard Biesheuvel <[email protected]> (cherry picked from commit 732ea9d) Signed-off-by: Jonathan Maple <[email protected]> # Conflicts: # arch/arm64/include/asm/efi.h # arch/loongarch/include/asm/efi.h # arch/loongarch/kernel/efi.c # arch/riscv/include/asm/efi.h # drivers/firmware/efi/efi-init.c # drivers/firmware/efi/efi.c # drivers/firmware/efi/libstub/Makefile # drivers/firmware/efi/libstub/screen_info.c
1 parent a4e6d82 commit bb98273

File tree

1 file changed

+238
-0
lines changed

1 file changed

+238
-0
lines changed
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
efi: libstub: Move screen_info handling to common code
2+
3+
jira LE-2157
4+
Rebuild_History Non-Buildable kernel-5.14.0-503.14.1.el9_5
5+
commit-author Ard Biesheuvel <[email protected]>
6+
commit 732ea9db9d8a6a0444d18ed810cccb2428d8766b
7+
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
8+
Will be included in final tarball splat. Ref for failed cherry-pick at:
9+
ciq/ciq_backports/kernel-5.14.0-503.14.1.el9_5/732ea9db.failed
10+
11+
Currently, arm64, RISC-V and LoongArch rely on the fact that struct
12+
screen_info can be accessed directly, due to the fact that the EFI stub
13+
and the core kernel are part of the same image. This will change after a
14+
future patch, so let's ensure that the screen_info handling is able to
15+
deal with this, by adopting the arm32 approach of passing it as a
16+
configuration table. While at it, switch to ACPI reclaim memory to hold
17+
the screen_info data, which is more appropriate for this kind of
18+
allocation.
19+
20+
Signed-off-by: Ard Biesheuvel <[email protected]>
21+
(cherry picked from commit 732ea9db9d8a6a0444d18ed810cccb2428d8766b)
22+
Signed-off-by: Jonathan Maple <[email protected]>
23+
24+
# Conflicts:
25+
# arch/arm64/include/asm/efi.h
26+
# arch/loongarch/include/asm/efi.h
27+
# arch/loongarch/kernel/efi.c
28+
# arch/riscv/include/asm/efi.h
29+
# drivers/firmware/efi/efi-init.c
30+
# drivers/firmware/efi/efi.c
31+
# drivers/firmware/efi/libstub/Makefile
32+
# drivers/firmware/efi/libstub/screen_info.c
33+
diff --cc arch/arm64/include/asm/efi.h
34+
index 4cf2cb053bc8,8604473a85b8..000000000000
35+
--- a/arch/arm64/include/asm/efi.h
36+
+++ b/arch/arm64/include/asm/efi.h
37+
@@@ -97,25 -84,7 +97,28 @@@ static inline unsigned long efi_get_max
38+
return (image_addr & ~(SZ_1G - 1UL)) + (1UL << (VA_BITS_MIN - 1));
39+
}
40+
41+
++<<<<<<< HEAD
42+
+static inline unsigned long efi_get_kimg_min_align(void)
43+
+{
44+
+ extern bool efi_nokaslr;
45+
+
46+
+ /*
47+
+ * Although relocatable kernels can fix up the misalignment with
48+
+ * respect to MIN_KIMG_ALIGN, the resulting virtual text addresses are
49+
+ * subtly out of sync with those recorded in the vmlinux when kaslr is
50+
+ * disabled but the image required relocation anyway. Therefore retain
51+
+ * 2M alignment if KASLR was explicitly disabled, even if it was not
52+
+ * going to be activated to begin with.
53+
+ */
54+
+ return efi_nokaslr ? MIN_KIMG_ALIGN : EFI_KIMG_ALIGN;
55+
+}
56+
+
57+
++=======
58+
++>>>>>>> 732ea9db9d8a (efi: libstub: Move screen_info handling to common code)
59+
#define EFI_ALLOC_ALIGN SZ_64K
60+
+#define EFI_ALLOC_LIMIT ((1UL << 48) - 1)
61+
+
62+
+extern unsigned long primary_entry_offset(void);
63+
64+
/*
65+
* On ARM systems, virtually remapped UEFI runtime services are set up in two
66+
diff --cc arch/riscv/include/asm/efi.h
67+
index 1950fff0b9de,d0570936cb8c..000000000000
68+
--- a/arch/riscv/include/asm/efi.h
69+
+++ b/arch/riscv/include/asm/efi.h
70+
@@@ -31,17 -31,6 +31,20 @@@ static inline unsigned long efi_get_max
71+
return ULONG_MAX;
72+
}
73+
74+
++<<<<<<< HEAD
75+
+static inline unsigned long efi_get_kimg_min_align(void)
76+
+{
77+
+ /*
78+
+ * RISC-V requires the kernel image to placed 2 MB aligned base for 64
79+
+ * bit and 4MB for 32 bit.
80+
+ */
81+
+ return IS_ENABLED(CONFIG_64BIT) ? SZ_2M : SZ_4M;
82+
+}
83+
+
84+
+#define EFI_KIMG_PREFERRED_ADDRESS efi_get_kimg_min_align()
85+
+
86+
++=======
87+
++>>>>>>> 732ea9db9d8a (efi: libstub: Move screen_info handling to common code)
88+
void efi_virtmap_load(void);
89+
void efi_virtmap_unload(void);
90+
91+
diff --cc drivers/firmware/efi/efi-init.c
92+
index ef0820f1a924,1639159493e3..000000000000
93+
--- a/drivers/firmware/efi/efi-init.c
94+
+++ b/drivers/firmware/efi/efi-init.c
95+
@@@ -72,9 -72,6 +72,12 @@@ static void __init init_screen_info(voi
96+
if (memblock_is_map_memory(screen_info.lfb_base))
97+
memblock_mark_nomap(screen_info.lfb_base,
98+
screen_info.lfb_size);
99+
++<<<<<<< HEAD
100+
+
101+
+ if (IS_ENABLED(CONFIG_EFI_EARLYCON))
102+
+ efi_earlycon_reprobe();
103+
++=======
104+
++>>>>>>> 732ea9db9d8a (efi: libstub: Move screen_info handling to common code)
105+
}
106+
}
107+
108+
diff --cc drivers/firmware/efi/efi.c
109+
index 5e01d9ba614c,951a42d27cf4..000000000000
110+
--- a/drivers/firmware/efi/efi.c
111+
+++ b/drivers/firmware/efi/efi.c
112+
@@@ -604,8 -549,8 +604,13 @@@ static const efi_config_table_type_t co
113+
#ifdef CONFIG_EFI_COCO_SECRET
114+
{LINUX_EFI_COCO_SECRET_AREA_GUID, &efi.coco_secret, "CocoSecret" },
115+
#endif
116+
++<<<<<<< HEAD
117+
+#ifdef CONFIG_UNACCEPTED_MEMORY
118+
+ {LINUX_EFI_UNACCEPTED_MEM_TABLE_GUID, &efi.unaccepted, "Unaccepted" },
119+
++=======
120+
+ #ifdef CONFIG_EFI_GENERIC_STUB
121+
+ {LINUX_EFI_SCREEN_INFO_TABLE_GUID, &screen_info_table },
122+
++>>>>>>> 732ea9db9d8a (efi: libstub: Move screen_info handling to common code)
123+
#endif
124+
{},
125+
};
126+
diff --cc drivers/firmware/efi/libstub/Makefile
127+
index 200d57ba0a5a,3f44e272ff9c..000000000000
128+
--- a/drivers/firmware/efi/libstub/Makefile
129+
+++ b/drivers/firmware/efi/libstub/Makefile
130+
@@@ -77,15 -81,15 +77,20 @@@ efi-deps-y := fdt_rw.c fdt_ro.c fdt_wip
131+
$(obj)/lib-%.o: $(srctree)/lib/%.c FORCE
132+
$(call if_changed_rule,cc_o_c)
133+
134+
++<<<<<<< HEAD
135+
+lib-$(CONFIG_EFI_GENERIC_STUB) += efi-stub.o fdt.o string.o intrinsics.o \
136+
+ $(patsubst %.c,lib-%.o,$(efi-deps-y)) \
137+
+ systable.o screen_info.o efi-stub-entry.o
138+
++=======
139+
+ lib-$(CONFIG_EFI_GENERIC_STUB) += efi-stub.o string.o intrinsics.o systable.o \
140+
+ screen_info.o
141+
++>>>>>>> 732ea9db9d8a (efi: libstub: Move screen_info handling to common code)
142+
143+
lib-$(CONFIG_ARM) += arm32-stub.o
144+
-lib-$(CONFIG_ARM64) += arm64-stub.o arm64-entry.o
145+
+lib-$(CONFIG_ARM64) += arm64.o arm64-stub.o
146+
lib-$(CONFIG_X86) += x86-stub.o
147+
+lib-$(CONFIG_X86_64) += x86-5lvl.o
148+
lib-$(CONFIG_RISCV) += riscv-stub.o
149+
-lib-$(CONFIG_LOONGARCH) += loongarch-stub.o
150+
-
151+
CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
152+
153+
zboot-obj-$(CONFIG_RISCV) := lib-clz_ctz.o lib-ashldi3.o
154+
diff --cc drivers/firmware/efi/libstub/screen_info.c
155+
index a51ec201ca3c,8e76a8b384ba..000000000000
156+
--- a/drivers/firmware/efi/libstub/screen_info.c
157+
+++ b/drivers/firmware/efi/libstub/screen_info.c
158+
@@@ -1,8 -1,6 +1,11 @@@
159+
// SPDX-License-Identifier: GPL-2.0
160+
161+
#include <linux/efi.h>
162+
++<<<<<<< HEAD
163+
+#include <linux/screen_info.h>
164+
+
165+
++=======
166+
++>>>>>>> 732ea9db9d8a (efi: libstub: Move screen_info handling to common code)
167+
#include <asm/efi.h>
168+
169+
#include "efistub.h"
170+
@@@ -17,11 -15,18 +20,26 @@@
171+
* early, but it only works if the EFI stub is part of the core kernel image
172+
* itself. The zboot decompressor can only use the configuration table
173+
* approach.
174+
++<<<<<<< HEAD
175+
+ */
176+
+
177+
+static efi_guid_t screen_info_guid = LINUX_EFI_SCREEN_INFO_TABLE_GUID;
178+
+
179+
+struct screen_info *__alloc_screen_info(void)
180+
++=======
181+
+ *
182+
+ * In order to support both methods from the same build of the EFI stub
183+
+ * library, provide this dummy global definition of struct screen_info. If it
184+
+ * is required to satisfy a link dependency, it means we need to override the
185+
+ * __weak alloc and free methods with the ones below, and those will be pulled
186+
+ * in as well.
187+
+ */
188+
+ struct screen_info screen_info;
189+
+
190+
+ static efi_guid_t screen_info_guid = LINUX_EFI_SCREEN_INFO_TABLE_GUID;
191+
+
192+
+ struct screen_info *alloc_screen_info(void)
193+
++>>>>>>> 732ea9db9d8a (efi: libstub: Move screen_info handling to common code)
194+
{
195+
struct screen_info *si;
196+
efi_status_t status;
197+
* Unmerged path arch/loongarch/include/asm/efi.h
198+
* Unmerged path arch/loongarch/kernel/efi.c
199+
* Unmerged path arch/arm64/include/asm/efi.h
200+
* Unmerged path arch/loongarch/include/asm/efi.h
201+
* Unmerged path arch/loongarch/kernel/efi.c
202+
* Unmerged path arch/riscv/include/asm/efi.h
203+
* Unmerged path drivers/firmware/efi/efi-init.c
204+
* Unmerged path drivers/firmware/efi/efi.c
205+
* Unmerged path drivers/firmware/efi/libstub/Makefile
206+
diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
207+
index 164a248ee1b8..d07cd6ab9846 100644
208+
--- a/drivers/firmware/efi/libstub/efi-stub.c
209+
+++ b/drivers/firmware/efi/libstub/efi-stub.c
210+
@@ -43,6 +43,15 @@ void __weak free_screen_info(struct screen_info *si)
211+
{
212+
}
213+
214+
+struct screen_info * __weak alloc_screen_info(void)
215+
+{
216+
+ return &screen_info;
217+
+}
218+
+
219+
+void __weak free_screen_info(struct screen_info *si)
220+
+{
221+
+}
222+
+
223+
static struct screen_info *setup_graphics(void)
224+
{
225+
efi_guid_t gop_proto = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
226+
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
227+
index 0b51ef7ffe30..e45434ac5029 100644
228+
--- a/drivers/firmware/efi/libstub/efistub.h
229+
+++ b/drivers/firmware/efi/libstub/efistub.h
230+
@@ -1156,4 +1156,7 @@ void arch_accept_memory(phys_addr_t start, phys_addr_t end);
231+
asmlinkage efi_status_t __efiapi
232+
efi_zboot_entry(efi_handle_t handle, efi_system_table_t *systab);
233+
234+
+struct screen_info *alloc_screen_info(void);
235+
+void free_screen_info(struct screen_info *si);
236+
+
237+
#endif
238+
* Unmerged path drivers/firmware/efi/libstub/screen_info.c

0 commit comments

Comments
 (0)