kexec reboot failed due to commit 75d090fd167ac
Subsystems (4)
Hi Kirill,
Ever since v6.5-rc1, I found that I can not use kexec to reboot an Intel SPR test machine. With git bisect, the first bad commit is 75d090fd167ac ("x86/tdx: Add unaccepted memory support").
I have no idea why a tdx change would affect it, I'm not doing anything related to tdx.
Any ideas?
The kernel config is attached, let me know if you need any other info.
Thanks,
Aaron
Quoted 6 lines · Aaron Lu
Hi Kirill,
Ever since v6.5-rc1, I found that I can not use kexec to reboot an Intel SPR test machine. With git bisect, the first bad commit is
75d090fd167ac("x86/tdx: Add unaccepted memory support").
Quoted 6 lines
I have no idea why a tdx change would affect it, I'm not doing anything related to tdx.
Any ideas?
The kernel config is attached, let me know if you need any other info.
Can you provide system logs (e.g. journalctl output) when attempting to reboot?
Anyway, thanks for the regression report. I'm adding it to regzbot:
#regzbot ^introduced: 75d090fd167aca
#regzbot title: unable to reboot with kexec due to TDX unaccepted memory support
Thanks.
Signature · 1 line
An old man doll... just what I always wanted! - Clara
Quoted 16 lines · Bagas Sanjaya
Quoted 6 lines · Aaron Lu
Hi Kirill,
Ever since v6.5-rc1, I found that I can not use kexec to reboot an Intel SPR test machine. With git bisect, the first bad commit is
75d090fd167ac("x86/tdx: Add unaccepted memory support").Quoted 6 lines
I have no idea why a tdx change would affect it, I'm not doing anything related to tdx.
Any ideas?
The kernel config is attached, let me know if you need any other info.
Can you provide system logs (e.g. journalctl output) when attempting to reboot?
... ...
Aug 29 19:15:59 be3af2b6059f systemd-shutdown[1]: Syncing filesystems and block devices. Aug 29 19:15:59 be3af2b6059f systemd-shutdown[1]: Sending SIGTERM to remaining processes... Aug 29 19:16:00 be3af2b6059f systemd-journald[2629]: Journal stopped -- Boot 7e5173842b8b4be581886ff25ad0c02f -- Aug 29 19:24:27 be3af2b6059f kernel: microcode: updated early: 0x2b000161 -> 0x2b000461, date = 2023-03-13 Aug 29 19:24:27 be3af2b6059f kernel: Linux version 6.3.8-100.fc37.x86_64 ([email protected]) Aug 29 19:24:27 be3af2b6059f kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-6.3.8-100.fc37.x86_64 root=UUID=4381321e-e0>
First 3 lines are from the first kernel, then I attmpted to kexec reboot to 6.4.0-rc5-00009-g75d090fd167a and remote console hanged with the reboot message of the first kernel. After a while, I know kexec failed so I power cycled the machine to boot into a distro kernel, that is the last 3 lines. There is no trace of the failed boot.
I guess the kexeced kernel failed to start early in the boot process so the log is probably only available in serial, if any. Unfortunately, there is no serial support for this machine.
Thanks,
Aaron
Quoted 9 lines
Anyway, thanks for the regression report. I'm adding it to regzbot:
#regzbot ^introduced:
75d090fd167aca
#regzbot title: unable to reboot with kexec due to TDX unaccepted memory supportThanks.
Signature · 1 line
An old man doll... just what I always wanted! - Clara
Quoted 4 lines · Aaron Lu
Quoted 3 lines · Bagas Sanjaya
Quoted 2 lines · Aaron Lu
Hi Kirill,
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Ever since v6.5-rc1, I found that I can not use kexec to reboot an Intel SPR test machine. With git bisect, the first bad commit is
75d090fd167ac("x86/tdx: Add unaccepted memory support").I have no idea why a tdx change would affect it, I'm not doing anything related to tdx.
Any ideas?
Are we talking about bare metal? Or is it kexec in a VM?
Quoted 20 lines
Quoted 4 lines
Quoted 1 line
The kernel config is attached, let me know if you need any other info.
Can you provide system logs (e.g. journalctl output) when attempting to reboot?
... ...
Aug 29 19:15:59 be3af2b6059f systemd-shutdown[1]: Syncing filesystems and block devices. Aug 29 19:15:59 be3af2b6059f systemd-shutdown[1]: Sending SIGTERM to remaining processes... Aug 29 19:16:00 be3af2b6059f systemd-journald[2629]: Journal stopped -- Boot 7e5173842b8b4be581886ff25ad0c02f -- Aug 29 19:24:27 be3af2b6059f kernel: microcode: updated early: 0x2b000161 -> 0x2b000461, date = 2023-03-13 Aug 29 19:24:27 be3af2b6059f kernel: Linux version 6.3.8-100.fc37.x86_64 ([email protected]) Aug 29 19:24:27 be3af2b6059f kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-6.3.8-100.fc37.x86_64 root=UUID=4381321e-e0>First 3 lines are from the first kernel, then I attmpted to kexec reboot to 6.4.0-rc5-00009-g75d090fd167a and remote console hanged with the reboot message of the first kernel. After a while, I know kexec failed so I power cycled the machine to boot into a distro kernel, that is the last 3 lines. There is no trace of the failed boot.
Quoted 3 lines
I guess the kexeced kernel failed to start early in the boot process so the log is probably only available in serial, if any. Unfortunately, there is no serial support for this machine.
Could you show dmesg of the first kernel before kexec?
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
Quoted 9 lines · Kirill A. Shutemov
Quoted 8 lines · Aaron Lu
Quoted 7 lines · Bagas Sanjaya
Quoted 6 lines · Aaron Lu
Hi Kirill,
Ever since v6.5-rc1, I found that I can not use kexec to reboot an Intel SPR test machine. With git bisect, the first bad commit is
75d090fd167ac("x86/tdx: Add unaccepted memory support").
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I have no idea why a tdx change would affect it, I'm not doing anything related to tdx.
Any ideas?
Are we talking about bare metal? Or is it kexec in a VM?
Bare metal.
Quoted 20 lines
Quoted 20 lines
Quoted 4 lines
Quoted 1 line
The kernel config is attached, let me know if you need any other info.
Can you provide system logs (e.g. journalctl output) when attempting to reboot?
... ...
Aug 29 19:15:59 be3af2b6059f systemd-shutdown[1]: Syncing filesystems and block devices. Aug 29 19:15:59 be3af2b6059f systemd-shutdown[1]: Sending SIGTERM to remaining processes... Aug 29 19:16:00 be3af2b6059f systemd-journald[2629]: Journal stopped -- Boot 7e5173842b8b4be581886ff25ad0c02f -- Aug 29 19:24:27 be3af2b6059f kernel: microcode: updated early: 0x2b000161 -> 0x2b000461, date = 2023-03-13 Aug 29 19:24:27 be3af2b6059f kernel: Linux version 6.3.8-100.fc37.x86_64 ([email protected]) Aug 29 19:24:27 be3af2b6059f kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-6.3.8-100.fc37.x86_64 root=UUID=4381321e-e0>First 3 lines are from the first kernel, then I attmpted to kexec reboot to 6.4.0-rc5-00009-g75d090fd167a and remote console hanged with the reboot message of the first kernel. After a while, I know kexec failed so I power cycled the machine to boot into a distro kernel, that is the last 3 lines. There is no trace of the failed boot.
Quoted 5 lines
Quoted 3 lines
I guess the kexeced kernel failed to start early in the boot process so the log is probably only available in serial, if any. Unfortunately, there is no serial support for this machine.
Could you show dmesg of the first kernel before kexec?
Attached.
BTW, kexec is invoked like this:
kver=6.4.0-rc5-00009-g75d090fd167a
kdir=$HOME/kernels/$kver
sudo kexec -l $kdir/vmlinuz-$kver --initrd=$kdir/initramfs-$kver.img --append="root=UUID=4381321e-e01e-455a-9d46-5e8c4c5b2d02 ro net.ifnames=0 acpi_rsdp=0x728e8014 no_hash_pointers sched_verbose selinux=0"
Thanks,
Aaron
Quoted 8 lines · Aaron Lu
Quoted 1 line
Could you show dmesg of the first kernel before kexec?
Attached.
BTW, kexec is invoked like this:
kver=6.4.0-rc5-00009-g75d090fd167a
kdir=$HOME/kernels/$kver
sudo kexec -l $kdir/vmlinuz-$kver --initrd=$kdir/initramfs-$kver.img --append="root=UUID=4381321e-e01e-455a-9d46-5e8c4c5b2d02 ro net.ifnames=0 acpi_rsdp=0x728e8014no_hash_pointerssched_verboseselinux=0"
I don't understand why it happens.
Could you check if this patch changes anything:
arch/x86/boot/compressed/misc.c +2 -0
@@ -456,10 +456,12 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,debug_putstr ("\nDecompressing Linux... " ); +#if 0 if (init_unaccepted_memory ()) {debug_putstr ("Accepting memory... " );accept_memory (__pa (output),__pa (output) + needed_size); } +#endif __decompress (input_data, input_len,NULL ,NULL , output, output_len,NULL , error);
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
Quoted 22 lines · Kirill A. Shutemov
Quoted 8 lines · Aaron Lu
Quoted 1 line
Could you show dmesg of the first kernel before kexec?
Attached.
BTW, kexec is invoked like this:
kver=6.4.0-rc5-00009-g75d090fd167a
kdir=$HOME/kernels/$kver
sudo kexec -l $kdir/vmlinuz-$kver --initrd=$kdir/initramfs-$kver.img --append="root=UUID=4381321e-e01e-455a-9d46-5e8c4c5b2d02 ro net.ifnames=0 acpi_rsdp=0x728e8014no_hash_pointerssched_verboseselinux=0"I don't understand why it happens.
Could you check if this patch changes anything:
arch/x86/boot/compressed/misc.c +0
-0@@ -456,10 +456,12 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,debug_putstr ("\nDecompressing Linux... " );
arch/x86/boot/compressed/misc.c asmlinkage __visible void *extract_kernel(void *rmode, memptr heap, · line 467
Quoted 10 lines
arch/x86/boot/compressed/misc.c +2
-0+#if 0 if (init_unaccepted_memory ()) {debug_putstr ("Accepting memory... " );accept_memory (__pa (output),__pa (output) + needed_size); } +#endif __decompress (input_data, input_len,NULL ,NULL , output, output_len,NULL , error);
It solved the problem.
Quoted 30 lines · Aaron Lu
Quoted 29 lines · Kirill A. Shutemov
Quoted 8 lines · Aaron Lu
Quoted 1 line
Could you show dmesg of the first kernel before kexec?
Attached.
BTW, kexec is invoked like this:
kver=6.4.0-rc5-00009-g75d090fd167a
kdir=$HOME/kernels/$kver
sudo kexec -l $kdir/vmlinuz-$kver --initrd=$kdir/initramfs-$kver.img --append="root=UUID=4381321e-e01e-455a-9d46-5e8c4c5b2d02 ro net.ifnames=0 acpi_rsdp=0x728e8014no_hash_pointerssched_verboseselinux=0"I don't understand why it happens.
Could you check if this patch changes anything:
arch/x86/boot/compressed/misc.c +2
-0@@ -456,10 +456,12 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,debug_putstr ("\nDecompressing Linux... " ); +#if 0 if (init_unaccepted_memory ()) {debug_putstr ("Accepting memory... " );accept_memory (__pa (output),__pa (output) + needed_size); } +#endif
Quoted 5 lines
arch/x86/boot/compressed/misc.c asmlinkage __visible void *extract_kernel(void *rmode, memptr heap, · line 467
Quoted 3 lines
arch/x86/boot/compressed/misc.c +0
-0__decompress (input_data, input_len,NULL ,NULL , output, output_len,NULL , error);It solved the problem.
Looks like increasing BOOT_INIT_PGT_SIZE fixes the issue. I don't yet understand why and how unaccepted memory is involved. I will look more into it.
Enabling CONFIG_RANDOMIZE_BASE also makes the issue go away.
Kees, maybe you have a clue?
arch/x86/include/asm/boot.h +1 -1
@@ -40,7 +40,7 @@#ifdef CONFIG_X86_64 # define BOOT_STACK_SIZE 0x4000 -# define BOOT_INIT_PGT_SIZE (6*4096) +# define BOOT_INIT_PGT_SIZE (7*4096)# ifdef CONFIG_RANDOMIZE_BASE /* * Assuming all cross the 512GB boundary:
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
Quoted 37 lines · Kirill A. Shutemov
Quoted 30 lines · Aaron Lu
Quoted 29 lines · Kirill A. Shutemov
Quoted 8 lines · Aaron Lu
Quoted 1 line
Could you show dmesg of the first kernel before kexec?
Attached.
BTW, kexec is invoked like this:
kver=6.4.0-rc5-00009-g75d090fd167a
kdir=$HOME/kernels/$kver
sudo kexec -l $kdir/vmlinuz-$kver --initrd=$kdir/initramfs-$kver.img --append="root=UUID=4381321e-e01e-455a-9d46-5e8c4c5b2d02 ro net.ifnames=0 acpi_rsdp=0x728e8014no_hash_pointerssched_verboseselinux=0"I don't understand why it happens.
Could you check if this patch changes anything:
arch/x86/boot/compressed/misc.c +2
-0@@ -456,10 +456,12 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,debug_putstr ("\nDecompressing Linux... " ); +#if 0 if (init_unaccepted_memory ()) {debug_putstr ("Accepting memory... " );accept_memory (__pa (output),__pa (output) + needed_size); } +#endif Quoted 5 lines
arch/x86/boot/compressed/misc.c asmlinkage __visible void *extract_kernel(void *rmode, memptr heap, · line 467
Quoted 3 lines
arch/x86/boot/compressed/misc.c +0
-0__decompress (input_data, input_len,NULL ,NULL , output, output_len,NULL , error);It solved the problem.
Quoted 5 lines
Looks like increasing
BOOT_INIT_PGT_SIZEfixes the issue. I don't yet understand why and how unaccepted memory is involved. I will look more into it.Enabling
CONFIG_RANDOMIZE_BASEalso makes the issue go away.
Is this perhaps just luck? I.e. does is break ever on, say, 1000 boot attempts? (i.e. maybe some position is bad and KASLR happens to usually avoid it?)
Quoted 1 line
Kees, maybe you have a clue?
The only thing I can think of is that something isn't being counted correctly due to the size of code, and it just happens that this commit makes the code large enough to exceed some set of mappings?
arch/x86/include/asm/boot.h line 43
Quoted 11 lines
arch/x86/include/asm/boot.h +1
-1@@ -40,7 +40,7 @@#ifdef CONFIG_X86_64 # define BOOT_STACK_SIZE 0x4000 -# define BOOT_INIT_PGT_SIZE (6*4096) +# define BOOT_INIT_PGT_SIZE (7*4096)
That's why this might be working, for example? How large is the boot image before/after the commit, etc?
Quoted 5 lines
arch/x86/include/asm/boot.h +0
-0# ifdef CONFIG_RANDOMIZE_BASE /* * Assuming all cross the 512GB boundary: Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
-Kees
Signature · 1 line
Kees Cook
Quoted 64 lines · Kees Cook
Quoted 37 lines · Kirill A. Shutemov
Quoted 30 lines · Aaron Lu
Quoted 29 lines · Kirill A. Shutemov
Quoted 8 lines · Aaron Lu
Quoted 1 line
Could you show dmesg of the first kernel before kexec?
Attached.
BTW, kexec is invoked like this:
kver=6.4.0-rc5-00009-g75d090fd167a
kdir=$HOME/kernels/$kver
sudo kexec -l $kdir/vmlinuz-$kver --initrd=$kdir/initramfs-$kver.img --append="root=UUID=4381321e-e01e-455a-9d46-5e8c4c5b2d02 ro net.ifnames=0 acpi_rsdp=0x728e8014no_hash_pointerssched_verboseselinux=0"I don't understand why it happens.
Could you check if this patch changes anything:
arch/x86/boot/compressed/misc.c +2
-0@@ -456,10 +456,12 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,debug_putstr ("\nDecompressing Linux... " ); +#if 0 if (init_unaccepted_memory ()) {debug_putstr ("Accepting memory... " );accept_memory (__pa (output),__pa (output) + needed_size); } +#endif Quoted 5 lines
arch/x86/boot/compressed/misc.c asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,
Quoted 3 lines
arch/x86/boot/compressed/misc.c +0
-1__decompress (input_data, input_len,NULL ,NULL , output, output_len,NULL , error); --It solved the problem.
Quoted 5 lines
Looks like increasing
BOOT_INIT_PGT_SIZEfixes the issue. I don't yet understand why and how unaccepted memory is involved. I will look more into it.Enabling
CONFIG_RANDOMIZE_BASEalso makes the issue go away.Is this perhaps just luck? I.e. does is break ever on, say, 1000 boot attempts? (i.e. maybe some position is bad and KASLR happens to usually avoid it?)
Quoted 1 line
Kees, maybe you have a clue?
The only thing I can think of is that something isn't being counted correctly due to the size of code, and it just happens that this commit makes the code large enough to exceed some set of mappings?
Quoted 9 lines
arch/x86/include/asm/boot.h +0
-0@@ -40,7 +40,7 @@#ifdef CONFIG_X86_64 # define BOOT_STACK_SIZE 0x4000
Quoted 6 lines
arch/x86/include/asm/boot.h line 43
Quoted 2 lines
arch/x86/include/asm/boot.h +1
-1-# define BOOT_INIT_PGT_SIZE (6*4096) +# define BOOT_INIT_PGT_SIZE (7*4096)That's why this might be working, for example? How large is the boot image before/after the commit, etc?
Not sure why these changes would make a difference here, but choking on accept_memory() on a non-TDX suggests that init_unaccepted_memory() is poking into unmapped memory before it even decides that the unaccepted memory does not exist.
init_unaccepted_memory() has
ret = efi_get_conf_table(boot_params, &cfg_table_pa, &cfg_table_len);
if (ret) {
warn("EFI config table not found.");
return false;
}which looks for <guid, phys_addr> tuples in an array pointed to by the EFI system table, and if either of those is not mapped, things can be expected to explode.
The only odd thing there is that this code is invoked after setting up the 'demand paging' logic in the decompressor.
If you haven't yet, could you please retry the kexec boot with earlyprintk=tty<insert your UART params here>?
Quoted 44 lines · Ard Biesheuvel
Quoted 43 lines · Kees Cook
Quoted 41 lines · Kirill A. Shutemov
Quoted 30 lines · Aaron Lu
Quoted 29 lines · Kirill A. Shutemov
Quoted 8 lines · Aaron Lu
Quoted 1 line
Could you show dmesg of the first kernel before kexec?
Attached.
BTW, kexec is invoked like this:
kver=6.4.0-rc5-00009-g75d090fd167a
kdir=$HOME/kernels/$kver
sudo kexec -l $kdir/vmlinuz-$kver --initrd=$kdir/initramfs-$kver.img --append="root=UUID=4381321e-e01e-455a-9d46-5e8c4c5b2d02 ro net.ifnames=0 acpi_rsdp=0x728e8014no_hash_pointerssched_verboseselinux=0"I don't understand why it happens.
Could you check if this patch changes anything:
arch/x86/boot/compressed/misc.c +2
-0@@ -456,10 +456,12 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,debug_putstr ("\nDecompressing Linux... " ); +#if 0 if (init_unaccepted_memory ()) {debug_putstr ("Accepting memory... " );accept_memory (__pa (output),__pa (output) + needed_size); } +#endif Quoted 5 lines
arch/x86/boot/compressed/misc.c asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,
Quoted 3 lines
arch/x86/boot/compressed/misc.c +0
-1__decompress (input_data, input_len,NULL ,NULL , output, output_len,NULL , error); --It solved the problem.
Looks like increasing
BOOT_INIT_PGT_SIZEfixes the issue. I don't yet understand why and how unaccepted memory is involved. I will look more into it.
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Enabling
CONFIG_RANDOMIZE_BASEalso makes the issue go away.Is this perhaps just luck? I.e. does is break ever on, say, 1000 boot attempts? (i.e. maybe some position is bad and KASLR happens to usually avoid it?)
Yes, it can be luck.
Quoted 39 lines
Quoted 15 lines
Quoted 1 line
Kees, maybe you have a clue?
The only thing I can think of is that something isn't being counted correctly due to the size of code, and it just happens that this commit makes the code large enough to exceed some set of mappings?
Quoted 9 lines
arch/x86/include/asm/boot.h +0
-0@@ -40,7 +40,7 @@#ifdef CONFIG_X86_64 # define BOOT_STACK_SIZE 0x4000Quoted 6 lines
arch/x86/include/asm/boot.h line 43
Quoted 2 lines
arch/x86/include/asm/boot.h +1
-1-# define BOOT_INIT_PGT_SIZE (6*4096) +# define BOOT_INIT_PGT_SIZE (7*4096)That's why this might be working, for example? How large is the boot image before/after the commit, etc?
Not sure why these changes would make a difference here, but choking on
accept_memory()on a non-TDX suggests thatinit_unaccepted_memory()is poking into unmapped memory before it even decides that the unaccepted memory does not exist.
init_unaccepted_memory()hasret = efi_get_conf_table(boot_params, &cfg_table_pa, &cfg_table_len); if (ret) { warn("EFI config table not found."); return false; }which looks for <guid,
phys_addr> tuples in an array pointed to by the EFI system table, and if either of those is not mapped, things can be expected to explode.
Quoted 5 lines
The only odd thing there is that this code is invoked after setting up the 'demand paging' logic in the decompressor.
If you haven't yet, could you please retry the kexec boot with earlyprintk=tty<insert your UART params here>?
early console in extract_kernelinput_data: 0x000000807eb433a8input_len: 0x0000000000d26271
output: 0x000000807b000000output_len: 0x0000000004800c10kernel_total_size: 0x0000000003e28000needed_size: 0x0000000004a00000trampoline_32bit: 0x000000000009d000
Decompressing Linux... out of pgt_buf in arch/x86/boot/compressed/ident_map_64.c!? pages->pgt_buf_offset: 0x0000000000006000pages->pgt_buf_size: 0x0000000000006000
Error: kernel_ident_mapping_init() failed
It crashes on #PF due to stbl->nr_tables dereference in efi_get_conf_table() called from init_unaccepted_memory().
I don't see anything special about stbl location: 0x775d6018.
One other bit of information: disabling 5-level paging also helps the issue.
I will debug further.
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
Add kexec list in cc
Quoted 128 lines · Kirill A. Shutemov
Quoted 44 lines · Ard Biesheuvel
Quoted 43 lines · Kees Cook
Quoted 41 lines · Kirill A. Shutemov
Quoted 30 lines · Aaron Lu
Quoted 29 lines · Kirill A. Shutemov
Quoted 8 lines · Aaron Lu
Quoted 1 line
Could you show dmesg of the first kernel before kexec?
Attached.
BTW, kexec is invoked like this:
kver=6.4.0-rc5-00009-g75d090fd167a
kdir=$HOME/kernels/$kver
sudo kexec -l $kdir/vmlinuz-$kver --initrd=$kdir/initramfs-$kver.img --append="root=UUID=4381321e-e01e-455a-9d46-5e8c4c5b2d02 ro net.ifnames=0 acpi_rsdp=0x728e8014no_hash_pointerssched_verboseselinux=0"I don't understand why it happens.
Could you check if this patch changes anything:
arch/x86/boot/compressed/misc.c +2
-0@@ -456,10 +456,12 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,debug_putstr ("\nDecompressing Linux... " ); +#if 0 if (init_unaccepted_memory ()) {debug_putstr ("Accepting memory... " );accept_memory (__pa (output),__pa (output) + needed_size); } +#endif Quoted 5 lines
arch/x86/boot/compressed/misc.c asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,
Quoted 3 lines
arch/x86/boot/compressed/misc.c +0
-1__decompress (input_data, input_len,NULL ,NULL , output, output_len,NULL , error); --It solved the problem.
Looks like increasing
BOOT_INIT_PGT_SIZEfixes the issue. I don't yet understand why and how unaccepted memory is involved. I will look more into it.Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Enabling
CONFIG_RANDOMIZE_BASEalso makes the issue go away.Is this perhaps just luck? I.e. does is break ever on, say, 1000 boot attempts? (i.e. maybe some position is bad and KASLR happens to usually avoid it?)
Yes, it can be luck.
Quoted 39 lines
Quoted 15 lines
Quoted 1 line
Kees, maybe you have a clue?
The only thing I can think of is that something isn't being counted correctly due to the size of code, and it just happens that this commit makes the code large enough to exceed some set of mappings?
Quoted 9 lines
arch/x86/include/asm/boot.h +0
-0@@ -40,7 +40,7 @@#ifdef CONFIG_X86_64 # define BOOT_STACK_SIZE 0x4000Quoted 6 lines
arch/x86/include/asm/boot.h line 43
Quoted 2 lines
arch/x86/include/asm/boot.h +1
-1-# define BOOT_INIT_PGT_SIZE (6*4096) +# define BOOT_INIT_PGT_SIZE (7*4096)That's why this might be working, for example? How large is the boot image before/after the commit, etc?
Not sure why these changes would make a difference here, but choking on
accept_memory()on a non-TDX suggests thatinit_unaccepted_memory()is poking into unmapped memory before it even decides that the unaccepted memory does not exist.
init_unaccepted_memory()hasret = efi_get_conf_table(boot_params, &cfg_table_pa, &cfg_table_len); if (ret) { warn("EFI config table not found."); return false; }which looks for <guid,
phys_addr> tuples in an array pointed to by the EFI system table, and if either of those is not mapped, things can be expected to explode.Quoted 5 lines
The only odd thing there is that this code is invoked after setting up the 'demand paging' logic in the decompressor.
If you haven't yet, could you please retry the kexec boot with earlyprintk=tty<insert your UART params here>?
early console in
extract_kernelinput_data:0x000000807eb433a8input_len:0x0000000000d26271
output:0x000000807b000000output_len:0x0000000004800c10kernel_total_size:0x0000000003e28000needed_size:0x0000000004a00000trampoline_32bit:0x000000000009d000Decompressing Linux... out of
pgt_bufinarch/x86/boot/compressed/ident_map_64.c!?pages->pgt_buf_offset:0x0000000000006000pages->pgt_buf_size:0x0000000000006000Error:
kernel_ident_mapping_init()failedIt crashes on #PF due to
stbl->nr_tablesdereference inefi_get_conf_table()called frominit_unaccepted_memory().I don't see anything special about stbl location:
0x775d6018.One other bit of information: disabling 5-level paging also helps the issue.
I will debug further.
--
Kiryl Shutsemau / Kirill A. Shutemov
Quoted 19 lines · Dave Young
Quoted 19 lines
early console in
extract_kernelinput_data:0x000000807eb433a8input_len:0x0000000000d26271
output:0x000000807b000000output_len:0x0000000004800c10kernel_total_size:0x0000000003e28000needed_size:0x0000000004a00000trampoline_32bit:0x000000000009d000Decompressing Linux... out of
pgt_bufinarch/x86/boot/compressed/ident_map_64.c!?pages->pgt_buf_offset:0x0000000000006000pages->pgt_buf_size:0x0000000000006000Error:
kernel_ident_mapping_init()failedIt crashes on #PF due to
stbl->nr_tablesdereference inefi_get_conf_table()called frominit_unaccepted_memory().
Quoted 6 lines
Quoted 6 lines
I don't see anything special about stbl location:
0x775d6018.One other bit of information: disabling 5-level paging also helps the issue.
I will debug further.
The problem is not limited to unaccepted memory, it also triggers if we reach efi_get_rsdp_addr() in the same setup.
I think we have several problems here.
- 6 pages for !RANDOMIZE_BASE is only enough for kernel, cmdline, boot_data and setup_data if we assume that they are in different 1G regions and do not cross the 1G boundaries. 4-level paging: 1 for PGD, 1 for PUD, 4 for PMD tables.
Looks like we never map EFI/ACPI memory explicitly.
It might work if kernel/cmdline/... are in single 1G and we have spare pages to handle page faults.
- No spare memory to handle mapping for cc_info and cc_info->cpuid_phys;
- I didn't increase BOOT_INIT_PGT_SIZE when added 5-level paging support. And if start pagetables from scratch ('else' case of 'if (p4d_offset...)) we run out of memory.
I believe similar logic would apply for BOOT_PGT_SIZE for RANDOMIZE_BASE=y case.
I don't know what the right fix here. We can increase the constants to be enough to cover existing cases, but it is very fragile. I am not sure I saw all users. Some of them could silently handled with pagefault handler in some setups. And it is hard to catch new users during code review.
Also I'm not sure why do we need pagefault handler there. Looks like it just masking problems. I think everything has to be mapped explicitly.
Any comments?
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
Quoted 56 lines · Kirill A. Shutemov
Quoted 19 lines · Dave Young
Quoted 19 lines
early console in
extract_kernelinput_data:0x000000807eb433a8input_len:0x0000000000d26271
output:0x000000807b000000output_len:0x0000000004800c10kernel_total_size:0x0000000003e28000needed_size:0x0000000004a00000trampoline_32bit:0x000000000009d000Decompressing Linux... out of
pgt_bufinarch/x86/boot/compressed/ident_map_64.c!?pages->pgt_buf_offset:0x0000000000006000pages->pgt_buf_size:0x0000000000006000Error:
kernel_ident_mapping_init()failedIt crashes on #PF due to
stbl->nr_tablesdereference inefi_get_conf_table()called frominit_unaccepted_memory().Quoted 6 lines
Quoted 6 lines
I don't see anything special about stbl location:
0x775d6018.One other bit of information: disabling 5-level paging also helps the issue.
I will debug further.
The problem is not limited to unaccepted memory, it also triggers if we reach
efi_get_rsdp_addr()in the same setup.I think we have several problems here.
- 6 pages for !RANDOMIZE_BASE is only enough for kernel, cmdline,
boot_dataandsetup_dataif we assume that they are in different 1G regions and do not cross the 1G boundaries. 4-level paging: 1 for PGD, 1 for PUD, 4 for PMD tables.Looks like we never map EFI/ACPI memory explicitly.
It might work if
kernel/cmdline/... are in single 1G and we have spare pages to handle page faults.- No spare memory to handle mapping for
cc_infoandcc_info->cpuid_phys;- I didn't increase
BOOT_INIT_PGT_SIZEwhen added 5-level paging support. And if start pagetables from scratch ('else' case of 'if (p4d_offset...)) we run out of memory.I believe similar logic would apply for
BOOT_PGT_SIZEfor RANDOMIZE_BASE=y case.I don't know what the right fix here. We can increase the constants to be enough to cover existing cases, but it is very fragile. I am not sure I saw all users. Some of them could silently handled with pagefault handler in some setups. And it is hard to catch new users during code review.
Quoted 4 lines
Also I'm not sure why do we need pagefault handler there. Looks like it just masking problems. I think everything has to be mapped explicitly.
Any comments?
There was a similar related issue around the cc_info blob that is captured here: https://lore.kernel.org/lkml/[email protected]/
Personally, I'm a fan of mapping the EFI tables that will be passed to the kexec/kdump kernel. To me, that seems to more closely match the valid mappings for the tables when control is transferred to the OS from UEFI on the initial boot.
Thanks,
Tom
Quoted 1 line
Quoted 62 lines · Tom Lendacky
Quoted 56 lines · Kirill A. Shutemov
Quoted 19 lines · Dave Young
Quoted 19 lines
early console in
extract_kernelinput_data:0x000000807eb433a8input_len:0x0000000000d26271
output:0x000000807b000000output_len:0x0000000004800c10kernel_total_size:0x0000000003e28000needed_size:0x0000000004a00000trampoline_32bit:0x000000000009d000Decompressing Linux... out of
pgt_bufinarch/x86/boot/compressed/ident_map_64.c!?pages->pgt_buf_offset:0x0000000000006000pages->pgt_buf_size:0x0000000000006000Error:
kernel_ident_mapping_init()failedIt crashes on #PF due to
stbl->nr_tablesdereference inefi_get_conf_table()called frominit_unaccepted_memory().Quoted 6 lines
Quoted 6 lines
I don't see anything special about stbl location:
0x775d6018.One other bit of information: disabling 5-level paging also helps the issue.
I will debug further.
The problem is not limited to unaccepted memory, it also triggers if we reach
efi_get_rsdp_addr()in the same setup.I think we have several problems here.
- 6 pages for !RANDOMIZE_BASE is only enough for kernel, cmdline,
boot_dataandsetup_dataif we assume that they are in different 1G regions and do not cross the 1G boundaries. 4-level paging: 1 for PGD, 1 for PUD, 4 for PMD tables.Looks like we never map EFI/ACPI memory explicitly.
It might work if
kernel/cmdline/... are in single 1G and we have spare pages to handle page faults.- No spare memory to handle mapping for
cc_infoandcc_info->cpuid_phys;- I didn't increase
BOOT_INIT_PGT_SIZEwhen added 5-level paging support. And if start pagetables from scratch ('else' case of 'if (p4d_offset...)) we run out of memory.I believe similar logic would apply for
BOOT_PGT_SIZEfor RANDOMIZE_BASE=y case.I don't know what the right fix here. We can increase the constants to be enough to cover existing cases, but it is very fragile. I am not sure I saw all users. Some of them could silently handled with pagefault handler in some setups. And it is hard to catch new users during code review.
Quoted 4 lines
Also I'm not sure why do we need pagefault handler there. Looks like it just masking problems. I think everything has to be mapped explicitly.
Any comments?
Quoted 7 lines
There was a similar related issue around the
cc_infoblob that is captured
here: https://lore.kernel.org/lkml/[email protected]/Personally, I'm a fan of mapping the EFI tables that will be passed to the kexec/kdump kernel. To me, that seems to more closely match the valid mappings for the tables when control is transferred to the OS from UEFI on the initial boot.
I don't see how it would help if initialize_identity_maps() resets pagetables. See 'else' case of 'if (p4d_offset...).
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
Quoted 66 lines · Kirill A. Shutemov
Quoted 65 lines · Tom Lendacky
Quoted 56 lines · Kirill A. Shutemov
Quoted 19 lines · Dave Young
Quoted 19 lines
early console in
extract_kernelinput_data:0x000000807eb433a8input_len:0x0000000000d26271
output:0x000000807b000000output_len:0x0000000004800c10kernel_total_size:0x0000000003e28000needed_size:0x0000000004a00000trampoline_32bit:0x000000000009d000Decompressing Linux... out of
pgt_bufinarch/x86/boot/compressed/ident_map_64.c!?pages->pgt_buf_offset:0x0000000000006000pages->pgt_buf_size:0x0000000000006000Error:
kernel_ident_mapping_init()failedIt crashes on #PF due to
stbl->nr_tablesdereference inefi_get_conf_table()called frominit_unaccepted_memory().Quoted 6 lines
Quoted 6 lines
I don't see anything special about stbl location:
0x775d6018.One other bit of information: disabling 5-level paging also helps the issue.
I will debug further.
The problem is not limited to unaccepted memory, it also triggers if we reach
efi_get_rsdp_addr()in the same setup.I think we have several problems here.
- 6 pages for !RANDOMIZE_BASE is only enough for kernel, cmdline,
boot_dataandsetup_dataif we assume that they are in different 1G regions and do not cross the 1G boundaries. 4-level paging: 1 for PGD, 1 for PUD, 4 for PMD tables.Looks like we never map EFI/ACPI memory explicitly.
It might work if
kernel/cmdline/... are in single 1G and we have spare pages to handle page faults.- No spare memory to handle mapping for
cc_infoandcc_info->cpuid_phys;- I didn't increase
BOOT_INIT_PGT_SIZEwhen added 5-level paging support. And if start pagetables from scratch ('else' case of 'if (p4d_offset...)) we run out of memory.I believe similar logic would apply for
BOOT_PGT_SIZEfor RANDOMIZE_BASE=y case.I don't know what the right fix here. We can increase the constants to be enough to cover existing cases, but it is very fragile. I am not sure I saw all users. Some of them could silently handled with pagefault handler in some setups. And it is hard to catch new users during code review.
Quoted 4 lines
Also I'm not sure why do we need pagefault handler there. Looks like it just masking problems. I think everything has to be mapped explicitly.
Any comments?
There was a similar related issue around the
cc_infoblob that is captured
here: https://lore.kernel.org/lkml/[email protected]/
Quoted 7 lines
Quoted 4 lines
Personally, I'm a fan of mapping the EFI tables that will be passed to the kexec/kdump kernel. To me, that seems to more closely match the valid mappings for the tables when control is transferred to the OS from UEFI on the initial boot.
I don't see how it would help if
initialize_identity_maps()resets pagetables. See 'else' case of 'if (p4d_offset...).
Ok, I see what you mean now.
Thanks,
Tom
Quoted 1 line
Quoted 56 lines · Kirill A. Shutemov
Quoted 19 lines · Dave Young
Quoted 19 lines
early console in
extract_kernelinput_data:0x000000807eb433a8input_len:0x0000000000d26271
output:0x000000807b000000output_len:0x0000000004800c10kernel_total_size:0x0000000003e28000needed_size:0x0000000004a00000trampoline_32bit:0x000000000009d000Decompressing Linux... out of
pgt_bufinarch/x86/boot/compressed/ident_map_64.c!?pages->pgt_buf_offset:0x0000000000006000pages->pgt_buf_size:0x0000000000006000Error:
kernel_ident_mapping_init()failedIt crashes on #PF due to
stbl->nr_tablesdereference inefi_get_conf_table()called frominit_unaccepted_memory().Quoted 6 lines
Quoted 6 lines
I don't see anything special about stbl location:
0x775d6018.One other bit of information: disabling 5-level paging also helps the issue.
I will debug further.
The problem is not limited to unaccepted memory, it also triggers if we reach
efi_get_rsdp_addr()in the same setup.I think we have several problems here.
- 6 pages for !RANDOMIZE_BASE is only enough for kernel, cmdline,
boot_dataandsetup_dataif we assume that they are in different 1G regions and do not cross the 1G boundaries. 4-level paging: 1 for PGD, 1 for PUD, 4 for PMD tables.Looks like we never map EFI/ACPI memory explicitly.
It might work if
kernel/cmdline/... are in single 1G and we have spare pages to handle page faults.- No spare memory to handle mapping for
cc_infoandcc_info->cpuid_phys;- I didn't increase
BOOT_INIT_PGT_SIZEwhen added 5-level paging support. And if start pagetables from scratch ('else' case of 'if (p4d_offset...)) we run out of memory.I believe similar logic would apply for
BOOT_PGT_SIZEfor RANDOMIZE_BASE=y case.I don't know what the right fix here. We can increase the constants to be enough to cover existing cases, but it is very fragile. I am not sure I saw all users. Some of them could silently handled with pagefault handler in some setups. And it is hard to catch new users during code review.
Quoted 4 lines
Also I'm not sure why do we need pagefault handler there. Looks like it just masking problems. I think everything has to be mapped explicitly.
Any comments?
I struggle to come up with anything better than increasing the constant to a value that "ought to be enough for anybody" ©, let's say 128K.
And we can eliminate logic on no-KASLR vs. KASLR vs. KASLR+VERBOSE_BOOTUP.
Objections?
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
Quoted 22 lines · Kirill A. Shutemov
Quoted 15 lines · Kirill A. Shutemov
Quoted 14 lines · Dave Young
Quoted 14 lines
early console in
extract_kernelinput_data:0x000000807eb433a8input_len:0x0000000000d26271
output:0x000000807b000000output_len:0x0000000004800c10kernel_total_size:0x0000000003e28000needed_size:0x0000000004a00000trampoline_32bit:0x000000000009d000Decompressing Linux... out of
pgt_bufinarch/x86/boot/compressed/ident_map_64.c!?pages->pgt_buf_offset:0x0000000000006000pages->pgt_buf_size:0x0000000000006000Error:
kernel_ident_mapping_init()failed[...]
Quoted 4 lines
The problem is not limited to unaccepted memory, it also triggers if we reach
efi_get_rsdp_addr()in the same setup.I think we have several problems here.
[...]
Quoted 8 lines
Quoted 1 line
Any comments?
I struggle to come up with anything better than increasing the constant to a value that "ought to be enough for anybody" ©, let's say 128K.
And we can eliminate logic on no-KASLR vs. KASLR vs. KASLR+VERBOSE_BOOTUP.
Objections?
Apparently not, as there was no reply since then (which is why I show up here, as it looked like fixing this regression stalled).
Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat) --
Everything you wanna know about Linux kernel regression tracking:
https://linux-regtracking.leemhuis.info/about/#tldr
If I did something stupid, please tell me, as explained on that page.
#regzbot poke
Quoted 28 lines · Linux regression tracking (Thorsten Leemhuis)
Quoted 27 lines · Kirill A. Shutemov
Quoted 15 lines · Kirill A. Shutemov
Quoted 14 lines · Dave Young
Quoted 14 lines
early console in
extract_kernelinput_data:0x000000807eb433a8input_len:0x0000000000d26271
output:0x000000807b000000output_len:0x0000000004800c10kernel_total_size:0x0000000003e28000needed_size:0x0000000004a00000trampoline_32bit:0x000000000009d000Decompressing Linux... out of
pgt_bufinarch/x86/boot/compressed/ident_map_64.c!?pages->pgt_buf_offset:0x0000000000006000pages->pgt_buf_size:0x0000000000006000Error:
kernel_ident_mapping_init()failed[...]
Quoted 4 lines
The problem is not limited to unaccepted memory, it also triggers if we reach
efi_get_rsdp_addr()in the same setup.I think we have several problems here.
[...]
Quoted 1 line
Any comments?
I struggle to come up with anything better than increasing the constant to a value that "ought to be enough for anybody" ©, let's say 128K.
Quoted 6 lines
Quoted 3 lines
And we can eliminate logic on no-KASLR vs. KASLR vs. KASLR+VERBOSE_BOOTUP.
Objections?
Apparently not, as there was no reply since then (which is why I show up here, as it looked like fixing this regression stalled).
It has been fixed in upstream by the commit f530ee95b72e ("x86/boot/compressed: Reserve more memory for page tables")
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
Quoted 31 lines · Kirill A. Shutemov
Quoted 30 lines · Linux regression tracking (Thorsten Leemhuis)
Quoted 29 lines · Kirill A. Shutemov
Quoted 15 lines · Kirill A. Shutemov
Quoted 14 lines · Dave Young
Quoted 14 lines
early console in
extract_kernelinput_data:0x000000807eb433a8input_len:0x0000000000d26271
output:0x000000807b000000output_len:0x0000000004800c10kernel_total_size:0x0000000003e28000needed_size:0x0000000004a00000trampoline_32bit:0x000000000009d000Decompressing Linux... out of
pgt_bufinarch/x86/boot/compressed/ident_map_64.c!?pages->pgt_buf_offset:0x0000000000006000pages->pgt_buf_size:0x0000000000006000Error:
kernel_ident_mapping_init()failed[...]
Quoted 4 lines
The problem is not limited to unaccepted memory, it also triggers if we reach
efi_get_rsdp_addr()in the same setup.I think we have several problems here.
[...]
Quoted 1 line
Any comments?
I struggle to come up with anything better than increasing the constant to a value that "ought to be enough for anybody" ©, let's say 128K.
And we can eliminate logic on no-KASLR vs. KASLR vs. KASLR+VERBOSE_BOOTUP.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Objections?
Apparently not, as there was no reply since then (which is why I show up here, as it looked like fixing this regression stalled).
It has been fixed in upstream by the commit
f530ee95b72e("x86/boot/compressed: Reserve more memory for page tables")
Ahh, great, thx for letting me know. That commit sadly missed a Link: or
Closes: tag to the regression report, which Linus and the docs ask for (and regression tracking relies on), then it would have noticed this automatically. Whatever, things happen, thx again.
#regzbot fix: f530ee95b72e
Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat) --
Everything you wanna know about Linux kernel regression tracking:
https://linux-regtracking.leemhuis.info/about/#tldr
If I did something stupid, please tell me, as explained on that page.