LoongArch: Load vmlinux.efi to the link address
Subsystems (2)
PATCH v2 1/1 LoongArch: Load vmlinux.efi to the link address
Currently, kexec loads vmlinux.efi to address 0 instead of the link address. This causes kexec to fail to boot the new vmlinux.efi on qemu.
pei_loongarch_load: kernel_segment: 0000000000000000
pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yes
loongarch_load_other_segments:333: command_line: kexec console=ttyS0,115200
kexec_load: entry = 0x13f1000 flags = 0x1020000
nr_segments = 2
segment[0].buf = 0x7fffeea38010
segment[0].bufsz = 0x1b55200
segment[0].mem = (nil)
segment[0].memsz = 0x1ca0000
segment[1].buf = 0x5555570940b0
segment[1].bufsz = 0x200
segment[1].mem = 0x1ca0000
segment[1].memsz = 0x4000
This patch constrains the range of the kernel segment by hole_min and hole_max to place vmlinux.efi exactly at the link address.
pei_loongarch_load: kernel_segment: 0000000000200000
pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yes
loongarch_load_other_segments:339: command_line: kexec console=ttyS0,115200
kexec_load: entry = 0x13f1000 flags = 0x1020000
nr_segments = 2
segment[0].buf = 0x7ffff2028010
segment[0].bufsz = 0x1b55200
segment[0].mem = 0x200000
segment[0].memsz = 0x1ca0000
segment[1].buf = 0x555557498098
segment[1].bufsz = 0x200
segment[1].mem = 0x1ea0000
segment[1].memsz = 0x4000
---
v1->v2:
* Fix the issue preventing it from working on the physical machine.
kexec/arch/loongarch/kexec-loongarch.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
kexec/arch/loongarch/kexec-loongarch.c +7 -3
@@ -265,9 +265,13 @@ unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) hole =ULONG_MAX ; } }else { - hole =locate_hole (info, - loongarch_mem.text_offset + loongarch_mem.image_size, -MiB (1 ),0 ,ULONG_MAX ,1 ); +unsigned long hole_min; +unsigned long hole_max; + + hole_min = loongarch_mem.text_offset; + hole_max = hole_min + loongarch_mem.image_size; + hole =locate_hole (info, loongarch_mem.image_size, +MiB (1 ), hole_min, hole_max,1 );if (hole ==ULONG_MAX )dbgprintf ("%s: locate_hole failed\n" , __func__);
Signature · 7 lines
2.42.0 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Quoted 74 lines · WANG Rui
Currently, kexec loads vmlinux.efi to address 0 instead of the link address. This causes kexec to fail to boot the new vmlinux.efi on qemu.
pei_loongarch_load:kernel_segment: 0000000000000000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:333:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7fffeea38010
segment[0].bufsz =0x1b55200
segment[0].mem = (nil)
segment[0].memsz =0x1ca0000
segment[1].buf =0x5555570940b0
segment[1].bufsz =0x200
segment[1].mem =0x1ca0000
segment[1].memsz =0x4000This patch constrains the range of the kernel segment by
hole_minandhole_maxto place vmlinux.efi exactly at the link address.
pei_loongarch_load:kernel_segment: 0000000000200000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:339:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7ffff2028010
segment[0].bufsz =0x1b55200
segment[0].mem =0x200000
segment[0].memsz =0x1ca0000
segment[1].buf =0x555557498098
segment[1].bufsz =0x200
segment[1].mem =0x1ea0000
segment[1].memsz =0x4000Signed-off-by WANG Rui <[email protected]>---
v1->v2:
* Fix the issue preventing it from working on the physical machine.kexec/arch/loongarch/kexec-loongarch.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)kexec/arch/loongarch/kexec-loongarch.c +7
-4@@ -265,9 +265,13 @@ unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) hole =ULONG_MAX ; } }else { - hole =locate_hole (info, - loongarch_mem.text_offset + loongarch_mem.image_size, -MiB (1 ),0 ,ULONG_MAX ,1 ); +unsigned long hole_min; +unsigned long hole_max; + + hole_min = loongarch_mem.text_offset; + hole_max = hole_min + loongarch_mem.image_size; + hole =locate_hole (info, loongarch_mem.image_size, +MiB (1 ), hole_min, hole_max,1 );if (hole ==ULONG_MAX )dbgprintf ("%s: locate_hole failed\n" , __func__); --
Quoted 2 lines
2.42.0
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 63 lines · WANG Rui
Currently, kexec loads vmlinux.efi to address 0 instead of the link address. This causes kexec to fail to boot the new vmlinux.efi on qemu.
pei_loongarch_load:kernel_segment: 0000000000000000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:333:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7fffeea38010
segment[0].bufsz =0x1b55200
segment[0].mem = (nil)
segment[0].memsz =0x1ca0000
segment[1].buf =0x5555570940b0
segment[1].bufsz =0x200
segment[1].mem =0x1ca0000
segment[1].memsz =0x4000This patch constrains the range of the kernel segment by
hole_minandhole_maxto place vmlinux.efi exactly at the link address.
pei_loongarch_load:kernel_segment: 0000000000200000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:339:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7ffff2028010
segment[0].bufsz =0x1b55200
segment[0].mem =0x200000
segment[0].memsz =0x1ca0000
segment[1].buf =0x555557498098
segment[1].bufsz =0x200
segment[1].mem =0x1ea0000
segment[1].memsz =0x4000Signed-off-by WANG Rui <[email protected]>---
v1->v2:
* Fix the issue preventing it from working on the physical machine.kexec/arch/loongarch/kexec-loongarch.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)kexec/arch/loongarch/kexec-loongarch.c +0
-3@@ -265,9 +265,13 @@ unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) hole =ULONG_MAX ; } }else { - hole =locate_hole (info, - loongarch_mem.text_offset + loongarch_mem.image_size, -MiB (1 ),0 ,ULONG_MAX ,1 );
kexec/arch/loongarch/kexec-loongarch.c unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) · line 277
Quoted 10 lines
kexec/arch/loongarch/kexec-loongarch.c +7
-0+unsigned long hole_min; +unsigned long hole_max; + + hole_min = loongarch_mem.text_offset; + hole_max = hole_min + loongarch_mem.image_size; + hole =locate_hole (info, loongarch_mem.image_size, +MiB (1 ), hole_min, hole_max,1 );if (hole ==ULONG_MAX )dbgprintf ("%s: locate_hole failed\n" , __func__);
Hi,
Previously when I played with the zboot kernel on a kvm guest I noticed this issue, but I found that the 1st 2M memory is memblock reserved but it is not shown in /proc/iomem as reserved, I suspect the 1st 2M is not usable for some arch specific reason but I was not sure.
Below patch can fix it but due to my rusty knowledge of loongarch I
did not send it out. I suspect even if the locate_hole avoids the wrong memory, in the 2nd kernel it could still access it. Correct?
Index: linux/arch/loongarch/kernel/mem.c
===================================================================
--- linux.orig/arch/loongarch/kernel/mem.c 2023-06-02
10:24:09.633593320 +0800
+++ linux/arch/loongarch/kernel/mem.c 2023-10-05 15:27:05.609455460 +0800
@@ -52,8 +52,8 @@
memblock_set_current_limit(PFN_PHYS(max_low_pfn));
memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0);- /* Reserve the first 2MB */ - memblock_reserve(PHYS_OFFSET, 0x200000); + /* Mark the first 2MB as nomap */ + memblock_mark_nomap(PHYS_OFFSET, 0x200000);
/* Reserve the kernel text/data/bss */
memblock_reserve(__pa_symbol(&_text),Quoted 9 lines
--
2.42.0_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 78 lines · RuiRui Yang
Quoted 63 lines · WANG Rui
Currently, kexec loads vmlinux.efi to address 0 instead of the link address. This causes kexec to fail to boot the new vmlinux.efi on qemu.
pei_loongarch_load:kernel_segment: 0000000000000000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:333:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7fffeea38010
segment[0].bufsz =0x1b55200
segment[0].mem = (nil)
segment[0].memsz =0x1ca0000
segment[1].buf =0x5555570940b0
segment[1].bufsz =0x200
segment[1].mem =0x1ca0000
segment[1].memsz =0x4000This patch constrains the range of the kernel segment by
hole_minandhole_maxto place vmlinux.efi exactly at the link address.
pei_loongarch_load:kernel_segment: 0000000000200000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:339:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7ffff2028010
segment[0].bufsz =0x1b55200
segment[0].mem =0x200000
segment[0].memsz =0x1ca0000
segment[1].buf =0x555557498098
segment[1].bufsz =0x200
segment[1].mem =0x1ea0000
segment[1].memsz =0x4000Signed-off-by WANG Rui <[email protected]>---
v1->v2:
* Fix the issue preventing it from working on the physical machine.kexec/arch/loongarch/kexec-loongarch.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)kexec/arch/loongarch/kexec-loongarch.c +0
-3@@ -265,9 +265,13 @@ unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) hole =ULONG_MAX ; } }else { - hole =locate_hole (info, - loongarch_mem.text_offset + loongarch_mem.image_size, -MiB (1 ),0 ,ULONG_MAX ,1 );kexec/arch/loongarch/kexec-loongarch.c unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) · line 277
Quoted 10 lines
kexec/arch/loongarch/kexec-loongarch.c +7
-0+unsigned long hole_min; +unsigned long hole_max; + + hole_min = loongarch_mem.text_offset; + hole_max = hole_min + loongarch_mem.image_size; + hole =locate_hole (info, loongarch_mem.image_size, +MiB (1 ), hole_min, hole_max,1 );if (hole ==ULONG_MAX )dbgprintf ("%s: locate_hole failed\n" , __func__);Hi,
Quoted 5 lines
Previously when I played with the zboot kernel on a kvm guest I noticed this issue, but I found that the 1st 2M memory is memblock reserved but it is not shown in
/proc/iomemas reserved, I suspect the 1st 2M is not usable for some arch specific reason but I was not sure.
Below patch can fix it but due to my rusty knowledge of loongarch I
Correct about my English wording a bit, I meant about rusty knowledge of kexec details and newbish loongarch knowledge,
BTW, the webmail often randomly choose the sender email, I usually use another email for community, that is Dave Young <[email protected]>, same person ;)
Anyway, since this is loongarch specific, it would be better to leave you guys the arch people to see how to fix it better.
Quoted 25 lines
did not send it out. I suspect even if the
locate_holeavoids the wrong memory, in the 2nd kernel it could still access it. Correct?Index:
linux/arch/loongarch/kernel/mem.c
===================================================================
---linux.orig/arch/loongarch/kernel/mem.c2023-06-02
10:24:09.633593320 +0800
+++linux/arch/loongarch/kernel/mem.c2023-10-05 15:27:05.609455460 +0800(quoted diff) +2
-2@@ -52,8 +52,8 @@ memblock_set_current_limit(PFN_PHYS(max_low_pfn)); memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0); - /* Reserve the first 2MB */ - memblock_reserve(PHYS_OFFSET, 0x200000); + /* Mark the first 2MB as nomap */ + memblock_mark_nomap(PHYS_OFFSET, 0x200000); /* Reserve the kernel text/data/bss */ memblock_reserve(__pa_symbol(&_text),Quoted 6 lines
--
2.42.0
Quoted 5 lines
Quoted 5 lines
_______________________________________________
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,
Quoted 86 lines · RuiRui Yang
Quoted 78 lines · RuiRui Yang
Quoted 63 lines · WANG Rui
Currently, kexec loads vmlinux.efi to address 0 instead of the link address. This causes kexec to fail to boot the new vmlinux.efi on qemu.
pei_loongarch_load:kernel_segment: 0000000000000000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:333:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7fffeea38010
segment[0].bufsz =0x1b55200
segment[0].mem = (nil)
segment[0].memsz =0x1ca0000
segment[1].buf =0x5555570940b0
segment[1].bufsz =0x200
segment[1].mem =0x1ca0000
segment[1].memsz =0x4000This patch constrains the range of the kernel segment by
hole_minandhole_maxto place vmlinux.efi exactly at the link address.
pei_loongarch_load:kernel_segment: 0000000000200000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:339:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7ffff2028010
segment[0].bufsz =0x1b55200
segment[0].mem =0x200000
segment[0].memsz =0x1ca0000
segment[1].buf =0x555557498098
segment[1].bufsz =0x200
segment[1].mem =0x1ea0000
segment[1].memsz =0x4000Signed-off-by WANG Rui <[email protected]>---
v1->v2:
* Fix the issue preventing it from working on the physical machine.kexec/arch/loongarch/kexec-loongarch.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)kexec/arch/loongarch/kexec-loongarch.c +0
-3@@ -265,9 +265,13 @@ unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) hole =ULONG_MAX ; } }else { - hole =locate_hole (info, - loongarch_mem.text_offset + loongarch_mem.image_size, -MiB (1 ),0 ,ULONG_MAX ,1 );kexec/arch/loongarch/kexec-loongarch.c unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) · line 277
Quoted 10 lines
kexec/arch/loongarch/kexec-loongarch.c +7
-0+unsigned long hole_min; +unsigned long hole_max; + + hole_min = loongarch_mem.text_offset; + hole_max = hole_min + loongarch_mem.image_size; + hole =locate_hole (info, loongarch_mem.image_size, +MiB (1 ), hole_min, hole_max,1 );if (hole ==ULONG_MAX )dbgprintf ("%s: locate_hole failed\n" , __func__);Hi,
Quoted 5 lines
Previously when I played with the zboot kernel on a kvm guest I noticed this issue, but I found that the 1st 2M memory is memblock reserved but it is not shown in
/proc/iomemas reserved, I suspect the 1st 2M is not usable for some arch specific reason but I was not sure.
Below patch can fix it but due to my rusty knowledge of loongarch I
Quoted 11 lines
Correct about my English wording a bit, I meant about rusty knowledge of kexec details and newbish loongarch knowledge,
BTW, the webmail often randomly choose the sender email, I usually use another email for community, that is Dave Young <[email protected]>, same person ;)Anyway, since this is loongarch specific, it would be better to leave you guys the arch people to see how to fix it better.
Quoted 2 lines
did not send it out. I suspect even if the
locate_holeavoids the wrong memory, in the 2nd kernel it could still access it. Correct?
I can confirm that the mapping of the 1st 2M in iomem on qemu causes kexec to not work. The root cause is that LoongArch's vmlinux.efi can only run on the link address, which is why I limit the allocation location of the kernel segment through hole min/max, not the kernel's iomem.
Hucai, what do you think about the 1st 2M mapping type in the kernel?
Quoted 29 lines
Quoted 28 lines
Index:
linux/arch/loongarch/kernel/mem.c
===================================================================
---linux.orig/arch/loongarch/kernel/mem.c2023-06-02
10:24:09.633593320 +0800
+++linux/arch/loongarch/kernel/mem.c2023-10-05 15:27:05.609455460 +0800(quoted diff) +2
-2@@ -52,8 +52,8 @@ memblock_set_current_limit(PFN_PHYS(max_low_pfn)); memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0); - /* Reserve the first 2MB */ - memblock_reserve(PHYS_OFFSET, 0x200000); + /* Mark the first 2MB as nomap */ + memblock_mark_nomap(PHYS_OFFSET, 0x200000); /* Reserve the kernel text/data/bss */ memblock_reserve(__pa_symbol(&_text),Quoted 11 lines
--
2.42.0_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Signature · 7 lines
WANG Rui _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Hi, all,
Quoted 102 lines · WANG Rui
Hi,
Quoted 86 lines · RuiRui Yang
Quoted 78 lines · RuiRui Yang
Quoted 63 lines · WANG Rui
Currently, kexec loads vmlinux.efi to address 0 instead of the link address. This causes kexec to fail to boot the new vmlinux.efi on qemu.
pei_loongarch_load:kernel_segment: 0000000000000000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:333:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7fffeea38010
segment[0].bufsz =0x1b55200
segment[0].mem = (nil)
segment[0].memsz =0x1ca0000
segment[1].buf =0x5555570940b0
segment[1].bufsz =0x200
segment[1].mem =0x1ca0000
segment[1].memsz =0x4000This patch constrains the range of the kernel segment by
hole_minandhole_maxto place vmlinux.efi exactly at the link address.
pei_loongarch_load:kernel_segment: 0000000000200000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:339:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7ffff2028010
segment[0].bufsz =0x1b55200
segment[0].mem =0x200000
segment[0].memsz =0x1ca0000
segment[1].buf =0x555557498098
segment[1].bufsz =0x200
segment[1].mem =0x1ea0000
segment[1].memsz =0x4000Signed-off-by WANG Rui <[email protected]>---
v1->v2:
* Fix the issue preventing it from working on the physical machine.kexec/arch/loongarch/kexec-loongarch.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)kexec/arch/loongarch/kexec-loongarch.c +0
-3@@ -265,9 +265,13 @@ unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) hole =ULONG_MAX ; } }else { - hole =locate_hole (info, - loongarch_mem.text_offset + loongarch_mem.image_size, -MiB (1 ),0 ,ULONG_MAX ,1 );kexec/arch/loongarch/kexec-loongarch.c unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) · line 277
Quoted 10 lines
kexec/arch/loongarch/kexec-loongarch.c +7
-0+unsigned long hole_min; +unsigned long hole_max; + + hole_min = loongarch_mem.text_offset; + hole_max = hole_min + loongarch_mem.image_size; + hole =locate_hole (info, loongarch_mem.image_size, +MiB (1 ), hole_min, hole_max,1 );if (hole ==ULONG_MAX )dbgprintf ("%s: locate_hole failed\n" , __func__);Hi,
Quoted 5 lines
Previously when I played with the zboot kernel on a kvm guest I noticed this issue, but I found that the 1st 2M memory is memblock reserved but it is not shown in
/proc/iomemas reserved, I suspect the 1st 2M is not usable for some arch specific reason but I was not sure.
Below patch can fix it but due to my rusty knowledge of loongarch IQuoted 11 lines
Correct about my English wording a bit, I meant about rusty knowledge of kexec details and newbish loongarch knowledge,
BTW, the webmail often randomly choose the sender email, I usually use another email for community, that is Dave Young <[email protected]>, same person ;)Anyway, since this is loongarch specific, it would be better to leave you guys the arch people to see how to fix it better.
Quoted 2 lines
did not send it out. I suspect even if the
locate_holeavoids the wrong memory, in the 2nd kernel it could still access it. Correct?
Quoted 7 lines
I can confirm that the mapping of the 1st 2M in iomem on qemu causes kexec to not work. The root cause is that LoongArch's vmlinux.efi can only run on the link address, which is why I limit the allocation location of the kernel segment through hole min/max, not the kernel's iomem.
Hucai, what do you think about the 1st 2M mapping type in the kernel?
I agree with WANG Rui, this should be fixed in kexec-tools, and 'nomap' is not for such a usage.
Huacai
Quoted 32 lines
Quoted 24 lines
Quoted 24 lines
Index:
linux/arch/loongarch/kernel/mem.c
===================================================================
---linux.orig/arch/loongarch/kernel/mem.c2023-06-02
10:24:09.633593320 +0800
+++linux/arch/loongarch/kernel/mem.c2023-10-05 15:27:05.609455460 +0800(quoted diff) +2
-2@@ -52,8 +52,8 @@ memblock_set_current_limit(PFN_PHYS(max_low_pfn)); memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0); - /* Reserve the first 2MB */ - memblock_reserve(PHYS_OFFSET, 0x200000); + /* Mark the first 2MB as nomap */ + memblock_mark_nomap(PHYS_OFFSET, 0x200000); /* Reserve the kernel text/data/bss */ memblock_reserve(__pa_symbol(&_text),Quoted 6 lines
--
2.42.0Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 3 lines
--
WANG Rui
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 111 lines · Huacai Chen
Hi, all,
Quoted 108 lines · WANG Rui
Hi,
Quoted 86 lines · RuiRui Yang
Quoted 78 lines · RuiRui Yang
Quoted 63 lines · WANG Rui
Currently, kexec loads vmlinux.efi to address 0 instead of the link address. This causes kexec to fail to boot the new vmlinux.efi on qemu.
pei_loongarch_load:kernel_segment: 0000000000000000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:333:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7fffeea38010
segment[0].bufsz =0x1b55200
segment[0].mem = (nil)
segment[0].memsz =0x1ca0000
segment[1].buf =0x5555570940b0
segment[1].bufsz =0x200
segment[1].mem =0x1ca0000
segment[1].memsz =0x4000This patch constrains the range of the kernel segment by
hole_minandhole_maxto place vmlinux.efi exactly at the link address.
pei_loongarch_load:kernel_segment: 0000000000200000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:339:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7ffff2028010
segment[0].bufsz =0x1b55200
segment[0].mem =0x200000
segment[0].memsz =0x1ca0000
segment[1].buf =0x555557498098
segment[1].bufsz =0x200
segment[1].mem =0x1ea0000
segment[1].memsz =0x4000Signed-off-by WANG Rui <[email protected]>---
v1->v2:
* Fix the issue preventing it from working on the physical machine.kexec/arch/loongarch/kexec-loongarch.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)kexec/arch/loongarch/kexec-loongarch.c +0
-3@@ -265,9 +265,13 @@ unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) hole =ULONG_MAX ; } }else { - hole =locate_hole (info, - loongarch_mem.text_offset + loongarch_mem.image_size, -MiB (1 ),0 ,ULONG_MAX ,1 );kexec/arch/loongarch/kexec-loongarch.c unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) · line 277
Quoted 10 lines
kexec/arch/loongarch/kexec-loongarch.c +7
-0+unsigned long hole_min; +unsigned long hole_max; + + hole_min = loongarch_mem.text_offset; + hole_max = hole_min + loongarch_mem.image_size; + hole =locate_hole (info, loongarch_mem.image_size, +MiB (1 ), hole_min, hole_max,1 );if (hole ==ULONG_MAX )dbgprintf ("%s: locate_hole failed\n" , __func__);Hi,
Quoted 5 lines
Previously when I played with the zboot kernel on a kvm guest I noticed this issue, but I found that the 1st 2M memory is memblock reserved but it is not shown in
/proc/iomemas reserved, I suspect the 1st 2M is not usable for some arch specific reason but I was not sure.
Below patch can fix it but due to my rusty knowledge of loongarch IQuoted 11 lines
Correct about my English wording a bit, I meant about rusty knowledge of kexec details and newbish loongarch knowledge,
BTW, the webmail often randomly choose the sender email, I usually use another email for community, that is Dave Young <[email protected]>, same person ;)Anyway, since this is loongarch specific, it would be better to leave you guys the arch people to see how to fix it better.
Quoted 2 lines
did not send it out. I suspect even if the
locate_holeavoids the wrong memory, in the 2nd kernel it could still access it. Correct?I can confirm that the mapping of the 1st 2M in iomem on qemu causes kexec to not work. The root cause is that LoongArch's vmlinux.efi can only run on the link address, which is why I limit the allocation location of the kernel segment through hole min/max, not the kernel's iomem.
Quoted 3 lines
Quoted 1 line
Hucai, what do you think about the 1st 2M mapping type in the kernel?
I agree with WANG Rui, this should be fixed in kexec-tools, and 'nomap' is not for such a usage.
Can I confirm that you'd still like this patch applied?
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi, Simon,
Quoted 113 lines · Simon Horman
Quoted 111 lines · Huacai Chen
Hi, all,
Quoted 108 lines · WANG Rui
Hi,
Quoted 86 lines · RuiRui Yang
Quoted 78 lines · RuiRui Yang
Quoted 63 lines · WANG Rui
Currently, kexec loads vmlinux.efi to address 0 instead of the link address. This causes kexec to fail to boot the new vmlinux.efi on qemu.
pei_loongarch_load:kernel_segment: 0000000000000000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:333:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7fffeea38010
segment[0].bufsz =0x1b55200
segment[0].mem = (nil)
segment[0].memsz =0x1ca0000
segment[1].buf =0x5555570940b0
segment[1].bufsz =0x200
segment[1].mem =0x1ca0000
segment[1].memsz =0x4000This patch constrains the range of the kernel segment by
hole_minandhole_maxto place vmlinux.efi exactly at the link address.
pei_loongarch_load:kernel_segment: 0000000000200000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:339:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7ffff2028010
segment[0].bufsz =0x1b55200
segment[0].mem =0x200000
segment[0].memsz =0x1ca0000
segment[1].buf =0x555557498098
segment[1].bufsz =0x200
segment[1].mem =0x1ea0000
segment[1].memsz =0x4000Signed-off-by WANG Rui <[email protected]>---
v1->v2:
* Fix the issue preventing it from working on the physical machine.kexec/arch/loongarch/kexec-loongarch.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)kexec/arch/loongarch/kexec-loongarch.c +0
-3@@ -265,9 +265,13 @@ unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) hole =ULONG_MAX ; } }else { - hole =locate_hole (info, - loongarch_mem.text_offset + loongarch_mem.image_size, -MiB (1 ),0 ,ULONG_MAX ,1 );kexec/arch/loongarch/kexec-loongarch.c unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) · line 277
Quoted 10 lines
kexec/arch/loongarch/kexec-loongarch.c +7
-0+unsigned long hole_min; +unsigned long hole_max; + + hole_min = loongarch_mem.text_offset; + hole_max = hole_min + loongarch_mem.image_size; + hole =locate_hole (info, loongarch_mem.image_size, +MiB (1 ), hole_min, hole_max,1 );if (hole ==ULONG_MAX )dbgprintf ("%s: locate_hole failed\n" , __func__);Hi,
Quoted 5 lines
Previously when I played with the zboot kernel on a kvm guest I noticed this issue, but I found that the 1st 2M memory is memblock reserved but it is not shown in
/proc/iomemas reserved, I suspect the 1st 2M is not usable for some arch specific reason but I was not sure.
Below patch can fix it but due to my rusty knowledge of loongarch IQuoted 11 lines
Correct about my English wording a bit, I meant about rusty knowledge of kexec details and newbish loongarch knowledge,
BTW, the webmail often randomly choose the sender email, I usually use another email for community, that is Dave Young <[email protected]>, same person ;)Anyway, since this is loongarch specific, it would be better to leave you guys the arch people to see how to fix it better.
Quoted 2 lines
did not send it out. I suspect even if the
locate_holeavoids the wrong memory, in the 2nd kernel it could still access it. Correct?I can confirm that the mapping of the 1st 2M in iomem on qemu causes kexec to not work. The root cause is that LoongArch's vmlinux.efi can only run on the link address, which is why I limit the allocation location of the kernel segment through hole min/max, not the kernel's iomem.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Hucai, what do you think about the 1st 2M mapping type in the kernel?
I agree with WANG Rui, this should be fixed in kexec-tools, and 'nomap' is not for such a usage.
Can I confirm that you'd still like this patch applied?
Yes, v1 breaks the real machine, while v2 works on both real machine and qemu.
Huacai
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedQuoted 116 lines · Huacai Chen
Hi, Simon,
Quoted 113 lines · Simon Horman
Quoted 111 lines · Huacai Chen
Hi, all,
Quoted 108 lines · WANG Rui
Hi,
Quoted 86 lines · RuiRui Yang
Quoted 78 lines · RuiRui Yang
Quoted 63 lines · WANG Rui
Currently, kexec loads vmlinux.efi to address 0 instead of the link address. This causes kexec to fail to boot the new vmlinux.efi on qemu.
pei_loongarch_load:kernel_segment: 0000000000000000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:333:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7fffeea38010
segment[0].bufsz =0x1b55200
segment[0].mem = (nil)
segment[0].memsz =0x1ca0000
segment[1].buf =0x5555570940b0
segment[1].bufsz =0x200
segment[1].mem =0x1ca0000
segment[1].memsz =0x4000This patch constrains the range of the kernel segment by
hole_minandhole_maxto place vmlinux.efi exactly at the link address.
pei_loongarch_load:kernel_segment: 0000000000200000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:339:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7ffff2028010
segment[0].bufsz =0x1b55200
segment[0].mem =0x200000
segment[0].memsz =0x1ca0000
segment[1].buf =0x555557498098
segment[1].bufsz =0x200
segment[1].mem =0x1ea0000
segment[1].memsz =0x4000Signed-off-by WANG Rui <[email protected]>---
v1->v2:
* Fix the issue preventing it from working on the physical machine.kexec/arch/loongarch/kexec-loongarch.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)kexec/arch/loongarch/kexec-loongarch.c +0
-3@@ -265,9 +265,13 @@ unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) hole =ULONG_MAX ; } }else { - hole =locate_hole (info, - loongarch_mem.text_offset + loongarch_mem.image_size, -MiB (1 ),0 ,ULONG_MAX ,1 );kexec/arch/loongarch/kexec-loongarch.c unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) · line 277
Quoted 10 lines
kexec/arch/loongarch/kexec-loongarch.c +7
-0+unsigned long hole_min; +unsigned long hole_max; + + hole_min = loongarch_mem.text_offset; + hole_max = hole_min + loongarch_mem.image_size; + hole =locate_hole (info, loongarch_mem.image_size, +MiB (1 ), hole_min, hole_max,1 );if (hole ==ULONG_MAX )dbgprintf ("%s: locate_hole failed\n" , __func__);Hi,
Quoted 5 lines
Previously when I played with the zboot kernel on a kvm guest I noticed this issue, but I found that the 1st 2M memory is memblock reserved but it is not shown in
/proc/iomemas reserved, I suspect the 1st 2M is not usable for some arch specific reason but I was not sure.
Below patch can fix it but due to my rusty knowledge of loongarch IQuoted 11 lines
Correct about my English wording a bit, I meant about rusty knowledge of kexec details and newbish loongarch knowledge,
BTW, the webmail often randomly choose the sender email, I usually use another email for community, that is Dave Young <[email protected]>, same person ;)Anyway, since this is loongarch specific, it would be better to leave you guys the arch people to see how to fix it better.
Quoted 2 lines
did not send it out. I suspect even if the
locate_holeavoids the wrong memory, in the 2nd kernel it could still access it. Correct?I can confirm that the mapping of the 1st 2M in iomem on qemu causes kexec to not work. The root cause is that LoongArch's vmlinux.efi can only run on the link address, which is why I limit the allocation location of the kernel segment through hole min/max, not the kernel's iomem.
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Hucai, what do you think about the 1st 2M mapping type in the kernel?
I agree with WANG Rui, this should be fixed in kexec-tools, and 'nomap' is not for such a usage.
Can I confirm that you'd still like this patch applied?
Yes, v1 breaks the real machine, while v2 works on both real machine and qemu.
Thanks, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hello Simon,
Could you apply this patch (v2) instead of patch (v1) [1] ? Thanks!
[1] https://lore.kernel.org/kexec/[email protected]/
Quoted 74 lines · WANG Rui
Currently, kexec loads vmlinux.efi to address 0 instead of the link address. This causes kexec to fail to boot the new vmlinux.efi on qemu.
pei_loongarch_load:kernel_segment: 0000000000000000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:333:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7fffeea38010
segment[0].bufsz =0x1b55200
segment[0].mem = (nil)
segment[0].memsz =0x1ca0000
segment[1].buf =0x5555570940b0
segment[1].bufsz =0x200
segment[1].mem =0x1ca0000
segment[1].memsz =0x4000This patch constrains the range of the kernel segment by
hole_minandhole_maxto place vmlinux.efi exactly at the link address.
pei_loongarch_load:kernel_segment: 0000000000200000pei_loongarch_load: kernel_entry: 00000000013f1000 pei_loongarch_load: image_size: 0000000001ca0000 pei_loongarch_load: text_offset: 0000000000200000 pei_loongarch_load: phys_offset: 0000000000000000 pei_loongarch_load: PE format: yesloongarch_load_other_segments:339:
command_line: kexec console=ttyS0,115200
kexec_load: entry =0x13f1000flags =0x1020000
nr_segments= 2
segment[0].buf =0x7ffff2028010
segment[0].bufsz =0x1b55200
segment[0].mem =0x200000
segment[0].memsz =0x1ca0000
segment[1].buf =0x555557498098
segment[1].bufsz =0x200
segment[1].mem =0x1ea0000
segment[1].memsz =0x4000Signed-off-by WANG Rui <[email protected]>---
v1->v2:
* Fix the issue preventing it from working on the physical machine.kexec/arch/loongarch/kexec-loongarch.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)kexec/arch/loongarch/kexec-loongarch.c +7
-4@@ -265,9 +265,13 @@ unsigned long loongarch_locate_kernel_segment(struct kexec_info *info) hole =ULONG_MAX ; } }else { - hole =locate_hole (info, - loongarch_mem.text_offset + loongarch_mem.image_size, -MiB (1 ),0 ,ULONG_MAX ,1 ); +unsigned long hole_min; +unsigned long hole_max; + + hole_min = loongarch_mem.text_offset; + hole_max = hole_min + loongarch_mem.image_size; + hole =locate_hole (info, loongarch_mem.image_size, +MiB (1 ), hole_min, hole_max,1 );if (hole ==ULONG_MAX )dbgprintf ("%s: locate_hole failed\n" , __func__); --
Quoted 2 lines
2.42.0
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec