Skip to content

Commit c7ebfc4

Browse files
andre4ik3bluca
authored andcommitted
boot: allocate cleanup pages below 4GiB only on x86
Outside of x86, some machines (e.g. Apple silicon, AMD Opteron A1100) have physical memory mapped above 4GiB, meaning this allocation will fail, causing the entire boot process to fail on these machines. This commit makes it so that the below-4GB address space allocation requirement is only set on x86 platforms, and not on other platforms (that don't have the specific Linux x86 boot protocol), thereby fixing boot on those that have no memory mapped below 4GiB in their address space. Tested on an Apple silicon M1 laptop and an AMD x86_64 desktop tower. Fixes: #35026 Manual backport of 6e207b3. (cherry picked from commit a9d9db7) (cherry picked from commit 8923d93) (cherry picked from commit 6f0a01d) (cherry picked from commit 9601ac9)
1 parent 8fe12f4 commit c7ebfc4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/boot/efi/stub.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,20 @@ static EFI_STATUS combine_initrd(
4242
n += extra_initrd_sizes[i];
4343
}
4444

45+
#if defined(__i386__) || defined(__x86_64__)
4546
_cleanup_pages_ Pages pages = xmalloc_pages(
4647
AllocateMaxAddress,
4748
EfiLoaderData,
4849
EFI_SIZE_TO_PAGES(n),
4950
UINT32_MAX /* Below 4G boundary. */);
51+
#else
52+
_cleanup_pages_ Pages pages = xmalloc_pages(
53+
AllocateAnyPages,
54+
EfiLoaderData,
55+
EFI_SIZE_TO_PAGES(n),
56+
0 /* Ignored. */);
57+
#endif
58+
5059
uint8_t *p = PHYSICAL_ADDRESS_TO_POINTER(pages.addr);
5160
if (initrd_base != 0) {
5261
UINTN pad;

0 commit comments

Comments
 (0)