arm64 kexec hang
Subsystems (2)
Hi Pratyush,
Quoted 3 lines · Pratyush Anand
So with following changes kexec load seems to complete without any error. However, kexec reboot does not work yet, Nothing after bye message :( (1st kernel booted with maxcpus=1)
'Bye!' doesn't mean much, other than the first kernel has almost shutdown. I recommend for debugging you either define ARM64_DEBUG_PORT for the kexec-tools build, or have a suitable earlyprintk= on the kernel command line. See the read_sink() routine in kexec-arm64.c.
Either of these will output something like this from the purgatory code:
I'm in purgatory
purgatory: kernel_entry: 0000000080080000
purgatory: dtb: 0000000080760000
Another option is to add my 'debugging: early putc' patch, build the kernel with ARM64_DEBUG_PORT defined for your
board. This will output 'stext' when the second
stage kernel is entered
The kexec --lite option will bypass purgatory and should just show 'stext'.
-Geoff
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi Geoff,
Quoted 7 lines · Geoff Levand
Hi Pratyush,
Quoted 3 lines · Pratyush Anand
So with following changes kexec load seems to complete without any error. However, kexec reboot does not work yet, Nothing after bye message :( (1st kernel booted with maxcpus=1)
Quoted 6 lines
'Bye!' doesn't mean much, other than the first kernel has almost shutdown. I recommend for debugging you either define
ARM64_DEBUG_PORTfor the kexec-tools build, or have a suitable earlyprintk= on the kernel command line. See theread_sink()routine inkexec-arm64.c.
Well, I was already using earlycon and it did not print anything after *Bye*.
I got OCD-H and is able to track the flow atleast and to see when it dies.
So, it all goes like machine_kexec ->..... -> arm64_kexec_kimage_start -> purgatory_start -> purgatory -> printf ... -> putchar
Here it dies (goes to el2_sync_invalid) as arm64_sink does not seem to be correct. arm64_sink is (-1) 0xffffffffffffffff. I also tried by just returning from printf without doing anything, still it goes to el2_sync_invalid (may be from some other location).
I will try to see tomorrow why arm64_sink is wrong and why did not it work if printf was null.
just for info: is_hyp_mode_available is true in my case.
~Pratyush
Quoted 15 lines
Either of these will output something like this from the purgatory code:
I'm in purgatory purgatory: kernel_entry: 0000000080080000 purgatory: dtb: 0000000080760000Another option is to add my 'debugging: early putc' patch, build the kernel with
ARM64_DEBUG_PORTdefined for your
board. This will output 'stext' when the second
stage kernel is enteredThe kexec --lite option will bypass purgatory and should just show 'stext'.
Quoted 8 lines
-Geoff
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi Geoff,
Quoted 17 lines · Pratyush Anand
Hi Geoff,
Quoted 13 lines · Geoff Levand
Hi Pratyush,
Quoted 3 lines · Pratyush Anand
So with following changes kexec load seems to complete without any error. However, kexec reboot does not work yet, Nothing after bye message :( (1st kernel booted with maxcpus=1)
'Bye!' doesn't mean much, other than the first kernel has almost shutdown. I recommend for debugging you either define
ARM64_DEBUG_PORTfor the kexec-tools build, or have a suitable earlyprintk= on the kernel command line. See theread_sink()routine inkexec-arm64.c.
Problem seems to be related to compilation of purgatory code.
For example see here:
70 0000000000000120 <purgatory>:
71 120: a9bf7bfd stp x29, x30, [sp,#-16]! 72 124: 910003fd mov x29, sp 73 128: 58000100 ldr x0, 148 <purgatory+0x28> 74 12c: 94000000 bl 544 <printf>
So, when it executes instruction at address 0x128 in above code, it does not contain correct address of data where "I'm in purgatory" is located. It seems that code has been compiled as 32 bit.
PC: 0x400415012c , PSTATE: 0x400003c9
(gdb) monitor reg x0
x0 (/64): 0x00000000041568F8
(gdb) monitor mdw 0x00000000041568F8 40x41568f8: fffefffe fffefffe fffefffe fffefffe : ................
The buffer location passed to printf is not correct.
Similarly, even if ARM64_DEBUG_PORT is programmed with correct UART TX register, arm64_sink is not modified correctly when elf_rel_set_symbol is called.
So correct data is at 0x00000040041568F8 and not 0x00000000041568F8
(gdb) monitor mdw 0x00000040041568F8 40x40041568f8: 206d2749 70206e69 61677275 79726f74 : I'm in purgatory
should n't the pc relative instruction like adrp be generated instead of ldr.
What does -mcmodel=large cflag do? May be it is causing to generate such instruction.
~Pratyush
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 54 lines · Pratyush Anand
Hi Geoff,
Quoted 17 lines · Pratyush Anand
Hi Geoff,
Quoted 13 lines · Geoff Levand
Hi Pratyush,
Quoted 3 lines · Pratyush Anand
So with following changes kexec load seems to complete without any error. However, kexec reboot does not work yet, Nothing after bye message :( (1st kernel booted with maxcpus=1)
'Bye!' doesn't mean much, other than the first kernel has almost shutdown. I recommend for debugging you either define
ARM64_DEBUG_PORTfor the kexec-tools build, or have a suitable earlyprintk= on the kernel command line. See theread_sink()routine inkexec-arm64.c.Problem seems to be related to compilation of purgatory code.
For example see here:
70 0000000000000120 <purgatory>: 71 120: a9bf7bfd stp x29, x30, [sp,#-16]! 72 124: 910003fd mov x29, sp 73 128: 58000100 ldr x0, 148 <purgatory+0x28> 74 12c: 94000000 bl 544 <printf>So, when it executes instruction at address
0x128in above code, it does not contain correct address of data where "I'm in purgatory" is located. It seems that code has been compiled as 32 bit.PC:
0x400415012c, PSTATE:0x400003c9
(gdb) monitor reg x0
x0 (/64):0x00000000041568F8
(gdb) monitor mdw0x00000000041568F840x41568f8: fffefffe fffefffe fffefffe fffefffe : ................The buffer location passed to printf is not correct.
Similarly, even if
ARM64_DEBUG_PORTis programmed with correct UART TX register,arm64_sinkis not modified correctly whenelf_rel_set_symbolis called.So correct data is at
0x00000040041568F8and not0x00000000041568F8(gdb) monitor mdw
0x00000040041568F840x40041568f8:206d274970206e696167727579726f74: I'm in purgatory
Quoted 6 lines
should n't the pc relative instruction like adrp be generated instead of ldr.
What does -mcmodel=large cflag do? May be it is causing to generate such instruction.
Following changes allows purgatory to execute.
kexec/arch/arm64/kexec-arm64.c +3 -3
@@ -993,8 +993,8 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, unsigned long r_type,# define R_AARCH64_CALL26 283#endif -uint32_t *location = (uint32_t *)ptr; -uint32_t data = *location; +uint64_t *location = (uint64_t *)ptr; +uint64_t data = *location;const char *type =NULL ;switch (r_type) {
@@ -1026,7 +1026,7 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, unsigned long r_type,break ; } -dbgprintf ("%s: %s %x->%x\n" , __func__, type, data, *location); +dbgprintf ("%s: %s %lx->%lx\n" , __func__, type, data, *location); }
So I get following and then nothing..
[ 162.087569] Bye!
I'm in purgatory
purgatory: kernel_entry: 0000004000280000
purg
Hopefully, I will be able to debug it further.will come back.
~Pratyush
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi Geoff,
Quoted 18 lines · Pratyush Anand
kexec/arch/arm64/kexec-arm64.c +2
-2@@ -993,8 +993,8 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, unsigned long r_type,# define R_AARCH64_CALL26 283#endif -uint32_t *location = (uint32_t *)ptr; -uint32_t data = *location; +uint64_t *location = (uint64_t *)ptr; +uint64_t data = *location;const char *type =NULL ;switch(r_type) {
kexec/arch/arm64/kexec-arm64.c void machine_apply_elf_rel(struct mem_ehdr *ehdr, · line 1031
Quoted 7 lines
kexec/arch/arm64/kexec-arm64.c +1
-1@@ -1026,7 +1026,7 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr,unsigned long r_type, break; } -dbgprintf ("%s: %s %x->%x\n" , __func__, type, data, *location); +dbgprintf ("%s: %s %lx->%lx\n" , __func__, type, data, *location); }
Thanks for your help/pointer.
So, this was it. With above changes kexec reboot works fine with purgatory too.
By the way, how much execution time expected for verify_sha256_digest? I have not quantified, but it seems that it takes minutes to execute that.
~Pratyush
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi Pratyush,
Quoted 2 lines · Pratyush Anand
So, this was it. With above changes kexec reboot works fine with purgatory too.
OK, great, thanks for working through it.
Quoted 2 lines
By the way, how much execution time expected for
verify_sha256_digest? I have not quantified, but it seems that it takes minutes to execute that.
The digest takes a long time, but it doesn't take minutes on the fast models. Maybe you could put some print statements in the code to see if it is the digest that takes the time, or something else. It could be a driver or something waiting for an event, etc.
-Geoff
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec