Re: [PATCH 0/7] Kexec-tools: Improve RISC-V port

2024-08-14 Thread Dave Young
On Mon, 12 Aug 2024 at 22:36, Petr Tesarik  wrote:
>
> Hi,
>
> On Sat, 18 May 2024 09:33:04 +0100
> Simon Horman  wrote:
>
> > On Sat, May 18, 2024 at 11:39:18AM +0800, Dave Young wrote:
> > > On Wed, 11 Oct 2023 at 13:24, Song Shuai  
> > > wrote:
> > > >
> > > >
> > > >
> > > > 在 2023/9/20 19:56, Simon Horman 写道:
> > > > > On Fri, Sep 15, 2023 at 11:50:06AM +0800, Song Shuai wrote:
> > > > >> Hi,
> > > > >>
> > > > >> This series is created to improve RISC-V port of kexec-tools,
> > > > >> and is based on the horms/kexec-tools:build-test-riscv-v2 branch.
> > > > >
> > > > > In my mind the big question is how to move RISC-V support
> > > > > from that branch, to being merged into main.
> > > > >
> > > > > IIRC there were some issues that needed to be addressed.
> > > > > Perhaps they are all addressed by this series, and with
> > > > > some appropriate squashing we can move forwards with a series
> > > > > based on main?
> > > >
> > > > Hi, Simon and Nick:
> > > >
> > > > I squashed the first four patches as a "RISC-V: Some fixes for riscv
> > > > port" patch and then took the horms/main as the base to collect the 2
> > > > patches from horms/build-test-riscv-v2 branch and this series togother.
> > > > These are the Github link and all commits for RISC-V.
> > > >
> > > > https://github.com/sugarfillet/kexec-tools/commits/main_rv
> > > >
> > > > 5dc133e RISC-V: Support loading Image binary file
> > > > b042f6d RISC-V: Separate elf_riscv_find_pbase out
> > > > 8f344c7 RISC-V: Enable kexec_file_load syscall
> > > > 7d4b982 RISC-V: Some fixes for riscv port
> > > > 3205c1c local: RISC-V: distribute purgatory/riscv/Makefile
> > > > 54f9daf RISC-V: Add support for riscv kexec/kdump on kexec-tools
> > > >
> > > > Since I didn't found the issues/fixes as Nick mentioned with these
> > > > commits, I prefer to merge them into horms/main and let more kexec/kdump
> > > > users to help improve/fixup RISC-V port.
> > >
> > > Hi,  I noticed another pr for Fedora kexec-tools:
> > > https://src.fedoraproject.org/rpms/kexec-tools/pull-request/24
> > >
> > > It is bad to take it as Fedora only,   I would suggest posting all the
> > > refreshed patches together here again for review.
> > >
> > > If no enough reviewers can review them my another suggestion is to
> > > drop the kexec_load support code for the time being, and only enable
> > > the kexec_file_load support code in kexec-tools, and I assume below
> > > kernel commit make the kexec_file_load kernel piece of work done.
> > > Then it will be easier to review and make something working at least.
> > > commit 6261586e0c91db14c34f894f4bc48f2300cff1d4
> > > Author: Liao Chang 
> > > Date:   Fri Apr 8 18:09:11 2022 +0800
> > >
> > > RISC-V: Add kexec_file support
> >
> > Hi,
> >
> > I would gladly take a patchset for kexec-tools that adds RISC-V support in
> > a coherent manner.
>
> Have I missed some progress on this topic? FWIW I can take care of
> RISC-V support in kexec-tools, I even received a VisionFive 2 board
> from RVI last year specifically to help with kexec.
>
> I merely don't want to duplicate efforts or "steal" someone else's
> project. Is RISC-V support in kexec-tools an orphaned project now?
>

I thought about a simple kexec_file_load only approach previously but
I have no time to work on it actually.  In theory I think a simple
kexec_file_load implementation should only share some common functions
eg. arguments parsing, file reading etc. and load the kernel and
initrd into memory, pass the fds and cmdline buffer into kernel,
that's all,  Even no need to have the arch specific file format
checking as they should have been done in the related kernel code.
But looking at the code it is not easy.  Currently the kexec_load and
kexec_file_load implementations are not logically separate in the code
and the cleanup is hard.

Thanks
Dave


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH 0/7] Kexec-tools: Improve RISC-V port

2024-08-13 Thread Simon Horman
On Mon, Aug 12, 2024 at 04:36:33PM +0200, Petr Tesarik wrote:
> Hi,
> 
> On Sat, 18 May 2024 09:33:04 +0100
> Simon Horman  wrote:
> 
> > On Sat, May 18, 2024 at 11:39:18AM +0800, Dave Young wrote:
> > > On Wed, 11 Oct 2023 at 13:24, Song Shuai  
> > > wrote:  
> > > >
> > > >
> > > >
> > > > 在 2023/9/20 19:56, Simon Horman 写道:  
> > > > > On Fri, Sep 15, 2023 at 11:50:06AM +0800, Song Shuai wrote:  
> > > > >> Hi,
> > > > >>
> > > > >> This series is created to improve RISC-V port of kexec-tools,
> > > > >> and is based on the horms/kexec-tools:build-test-riscv-v2 branch.  
> > > > >
> > > > > In my mind the big question is how to move RISC-V support
> > > > > from that branch, to being merged into main.
> > > > >
> > > > > IIRC there were some issues that needed to be addressed.
> > > > > Perhaps they are all addressed by this series, and with
> > > > > some appropriate squashing we can move forwards with a series
> > > > > based on main?  
> > > >
> > > > Hi, Simon and Nick:
> > > >
> > > > I squashed the first four patches as a "RISC-V: Some fixes for riscv
> > > > port" patch and then took the horms/main as the base to collect the 2
> > > > patches from horms/build-test-riscv-v2 branch and this series togother.
> > > > These are the Github link and all commits for RISC-V.
> > > >
> > > > https://github.com/sugarfillet/kexec-tools/commits/main_rv
> > > >
> > > > 5dc133e RISC-V: Support loading Image binary file
> > > > b042f6d RISC-V: Separate elf_riscv_find_pbase out
> > > > 8f344c7 RISC-V: Enable kexec_file_load syscall
> > > > 7d4b982 RISC-V: Some fixes for riscv port
> > > > 3205c1c local: RISC-V: distribute purgatory/riscv/Makefile
> > > > 54f9daf RISC-V: Add support for riscv kexec/kdump on kexec-tools
> > > >
> > > > Since I didn't found the issues/fixes as Nick mentioned with these
> > > > commits, I prefer to merge them into horms/main and let more kexec/kdump
> > > > users to help improve/fixup RISC-V port.  
> > > 
> > > Hi,  I noticed another pr for Fedora kexec-tools:
> > > https://src.fedoraproject.org/rpms/kexec-tools/pull-request/24
> > > 
> > > It is bad to take it as Fedora only,   I would suggest posting all the
> > > refreshed patches together here again for review.
> > > 
> > > If no enough reviewers can review them my another suggestion is to
> > > drop the kexec_load support code for the time being, and only enable
> > > the kexec_file_load support code in kexec-tools, and I assume below
> > > kernel commit make the kexec_file_load kernel piece of work done.
> > > Then it will be easier to review and make something working at least.
> > > commit 6261586e0c91db14c34f894f4bc48f2300cff1d4
> > > Author: Liao Chang 
> > > Date:   Fri Apr 8 18:09:11 2022 +0800
> > > 
> > > RISC-V: Add kexec_file support  
> > 
> > Hi,
> > 
> > I would gladly take a patchset for kexec-tools that adds RISC-V support in
> > a coherent manner.
> 
> Have I missed some progress on this topic? FWIW I can take care of
> RISC-V support in kexec-tools, I even received a VisionFive 2 board
> from RVI last year specifically to help with kexec.
> 
> I merely don't want to duplicate efforts or "steal" someone else's
> project. Is RISC-V support in kexec-tools an orphaned project now?

Hi Petr,

If there has been progress then I am not aware of it.
And if you would like to step up and provide a single, well structured,
patchset that adds RISC-V support then I for one would be most grateful.


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH 0/7] Kexec-tools: Improve RISC-V port

2024-08-12 Thread Petr Tesarik
Hi,

On Sat, 18 May 2024 09:33:04 +0100
Simon Horman  wrote:

> On Sat, May 18, 2024 at 11:39:18AM +0800, Dave Young wrote:
> > On Wed, 11 Oct 2023 at 13:24, Song Shuai  
> > wrote:  
> > >
> > >
> > >
> > > 在 2023/9/20 19:56, Simon Horman 写道:  
> > > > On Fri, Sep 15, 2023 at 11:50:06AM +0800, Song Shuai wrote:  
> > > >> Hi,
> > > >>
> > > >> This series is created to improve RISC-V port of kexec-tools,
> > > >> and is based on the horms/kexec-tools:build-test-riscv-v2 branch.  
> > > >
> > > > In my mind the big question is how to move RISC-V support
> > > > from that branch, to being merged into main.
> > > >
> > > > IIRC there were some issues that needed to be addressed.
> > > > Perhaps they are all addressed by this series, and with
> > > > some appropriate squashing we can move forwards with a series
> > > > based on main?  
> > >
> > > Hi, Simon and Nick:
> > >
> > > I squashed the first four patches as a "RISC-V: Some fixes for riscv
> > > port" patch and then took the horms/main as the base to collect the 2
> > > patches from horms/build-test-riscv-v2 branch and this series togother.
> > > These are the Github link and all commits for RISC-V.
> > >
> > > https://github.com/sugarfillet/kexec-tools/commits/main_rv
> > >
> > > 5dc133e RISC-V: Support loading Image binary file
> > > b042f6d RISC-V: Separate elf_riscv_find_pbase out
> > > 8f344c7 RISC-V: Enable kexec_file_load syscall
> > > 7d4b982 RISC-V: Some fixes for riscv port
> > > 3205c1c local: RISC-V: distribute purgatory/riscv/Makefile
> > > 54f9daf RISC-V: Add support for riscv kexec/kdump on kexec-tools
> > >
> > > Since I didn't found the issues/fixes as Nick mentioned with these
> > > commits, I prefer to merge them into horms/main and let more kexec/kdump
> > > users to help improve/fixup RISC-V port.  
> > 
> > Hi,  I noticed another pr for Fedora kexec-tools:
> > https://src.fedoraproject.org/rpms/kexec-tools/pull-request/24
> > 
> > It is bad to take it as Fedora only,   I would suggest posting all the
> > refreshed patches together here again for review.
> > 
> > If no enough reviewers can review them my another suggestion is to
> > drop the kexec_load support code for the time being, and only enable
> > the kexec_file_load support code in kexec-tools, and I assume below
> > kernel commit make the kexec_file_load kernel piece of work done.
> > Then it will be easier to review and make something working at least.
> > commit 6261586e0c91db14c34f894f4bc48f2300cff1d4
> > Author: Liao Chang 
> > Date:   Fri Apr 8 18:09:11 2022 +0800
> > 
> > RISC-V: Add kexec_file support  
> 
> Hi,
> 
> I would gladly take a patchset for kexec-tools that adds RISC-V support in
> a coherent manner.

Have I missed some progress on this topic? FWIW I can take care of
RISC-V support in kexec-tools, I even received a VisionFive 2 board
from RVI last year specifically to help with kexec.

I merely don't want to duplicate efforts or "steal" someone else's
project. Is RISC-V support in kexec-tools an orphaned project now?

Petr T

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[ANNOUNCE] kexec-tools 2.0.29

2024-07-18 Thread Simon Horman
Hi all,

I am happy to announce the release of kexec-tools 2.0.29.

This is a feature release coinciding with the release of v6.10
of the Linux Kernel.

This release can be downloaded from kernel.org:

http://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.29.tar.xz
http://kernel.org/pub/linux/utils/kernel/kexec/

It is also tagged it in git:

git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git

Thanks to everyone who has contributed to kexec!

Commits since v2.0.28:

992c419f6cbf kexec-tools 2.0.29
920ae8851837 kexec-tools 2.0.29-rc1
0be146b65771 doc/hotplug: update man and --help
b8408c95e7c0 powerpc/kexec_load: add hotplug support
3c47f384f1c4 kexec_load: Use new kexec flag for hotplug support
4fd0553cdfe3 x86-linux-setup.c: Use POSIX basename API
2e8a93af1e85 kexec: loongarch: fix load command line segment error
69ccfa12d5e3 kexec: loongarch: add multi crash kernel segment support
3194d1eba9c1 LoongArch: fix kernel image size error
2a3e54e9f734 ARM: Fix add_buffer_phys_virt() align issue
f53bcef5063c Fix incorrect Free Software Foundation address in the license
623ceb333c18 util_lib/elf_info.c: fix a warning
9d9cf8de8b2a kexec_file: add kexec_file flag to support debug printing
6ee2ac1bf739 workflow: update to use checkout@v4
328de8e00e29 Fix building on x86_64 with binutils 2.41
94fbe64fb22d kexec: don't use kexec_file_load on XEN
21ea4569856a kexec-tools 2.0.28.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[ANNOUNCE] kexec-tools 2.0.29-rc1

2024-07-12 Thread Simon Horman
Hi all,

I am happy to announce the release of kexec-tools 2.0.29-rc1.

This is an incremental feature pre-release.

So long as no serious problems arise I intend to release kexec-tools 2.0.29
in a weeks time. Testing of 2.0.29-rc1 would be greatly appreciated.

I do not have any outstanding changes for 2.0.29 at this time.
And I would like to only accept bug fixes at this time and take
features patches once 2.0.29 has been released.

The pre-release can be downloaded from kernel.org:


https://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.29-rc1.tar.xz
https://kernel.org/pub/linux/utils/kernel/kexec/

I have also tagged it in git:

https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git

Thanks to everyone who has contributed to kexec.


For reference the changes since v2.0.28 are:

920ae8851837 kexec-tools 2.0.29-rc1
0be146b65771 doc/hotplug: update man and --help
b8408c95e7c0 powerpc/kexec_load: add hotplug support
3c47f384f1c4 kexec_load: Use new kexec flag for hotplug support
4fd0553cdfe3 x86-linux-setup.c: Use POSIX basename API
2e8a93af1e85 kexec: loongarch: fix load command line segment error
69ccfa12d5e3 kexec: loongarch: add multi crash kernel segment support
3194d1eba9c1 LoongArch: fix kernel image size error
2a3e54e9f734 ARM: Fix add_buffer_phys_virt() align issue
f53bcef5063c Fix incorrect Free Software Foundation address in the license
623ceb333c18 util_lib/elf_info.c: fix a warning
9d9cf8de8b2a kexec_file: add kexec_file flag to support debug printing
6ee2ac1bf739 workflow: update to use checkout@v4
328de8e00e29 Fix building on x86_64 with binutils 2.41
94fbe64fb22d kexec: don't use kexec_file_load on XEN
21ea4569856a kexec-tools 2.0.28.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [ANNOUNCE] kexec-tools v2.0.29 preparation

2024-07-09 Thread Simon Horman
On Sun, Jul 07, 2024 at 09:00:18PM +0530, Sourabh Jain wrote:
> Hello Simon,
> 
> On 04/07/24 17:45, Simon Horman wrote:
> > Hi all,
> > 
> > I am planning to release kexec-tools v2.0.29 in the next two weeks
> > to roughly coincide with the release of the v6.10 kernel.
> > 
> > I would like to ask interested parties to send any patches they would like
> > included in v2.0.29 within one week so they can be considered for inclusion
> > in an rc release.
> 
> It would be helpful if we could consider the below patch series for the
> v2.0.29 release.
> https://lore.kernel.org/all/20240707152456.87899-1-sourabhj...@linux.ibm.com/

Sure, will do.

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [ANNOUNCE] kexec-tools v2.0.29 preparation

2024-07-07 Thread Sourabh Jain

Hello Simon,

On 04/07/24 17:45, Simon Horman wrote:

Hi all,

I am planning to release kexec-tools v2.0.29 in the next two weeks
to roughly coincide with the release of the v6.10 kernel.

I would like to ask interested parties to send any patches they would like
included in v2.0.29 within one week so they can be considered for inclusion
in an rc release.


It would be helpful if we could consider the below patch series for the 
v2.0.29 release.

https://lore.kernel.org/all/20240707152456.87899-1-sourabhj...@linux.ibm.com/


Thanks,
Sourabh Jain

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[ANNOUNCE] kexec-tools v2.0.29 preparation

2024-07-04 Thread Simon Horman
Hi all,

I am planning to release kexec-tools v2.0.29 in the next two weeks
to roughly coincide with the release of the v6.10 kernel.

I would like to ask interested parties to send any patches they would like
included in v2.0.29 within one week so they can be considered for inclusion
in an rc release.

For reference the patches queued up since v2.0.28 are as follows.

Thanks to everyone who has contributed to kexec-tools!

4fd0553cdfe3 x86-linux-setup.c: Use POSIX basename API
2e8a93af1e85 kexec: loongarch: fix load command line segment error
69ccfa12d5e3 kexec: loongarch: add multi crash kernel segment support
3194d1eba9c1 LoongArch: fix kernel image size error
2a3e54e9f734 ARM: Fix add_buffer_phys_virt() align issue
f53bcef5063c Fix incorrect Free Software Foundation address in the license
623ceb333c18 util_lib/elf_info.c: fix a warning
9d9cf8de8b2a kexec_file: add kexec_file flag to support debug printing
6ee2ac1bf739 workflow: update to use checkout@v4
328de8e00e29 Fix building on x86_64 with binutils 2.41
94fbe64fb22d kexec: don't use kexec_file_load on XEN
21ea4569856a kexec-tools 2.0.28.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH 0/7] Kexec-tools: Improve RISC-V port

2024-05-18 Thread Simon Horman
On Sat, May 18, 2024 at 11:39:18AM +0800, Dave Young wrote:
> On Wed, 11 Oct 2023 at 13:24, Song Shuai  wrote:
> >
> >
> >
> > 在 2023/9/20 19:56, Simon Horman 写道:
> > > On Fri, Sep 15, 2023 at 11:50:06AM +0800, Song Shuai wrote:
> > >> Hi,
> > >>
> > >> This series is created to improve RISC-V port of kexec-tools,
> > >> and is based on the horms/kexec-tools:build-test-riscv-v2 branch.
> > >
> > > In my mind the big question is how to move RISC-V support
> > > from that branch, to being merged into main.
> > >
> > > IIRC there were some issues that needed to be addressed.
> > > Perhaps they are all addressed by this series, and with
> > > some appropriate squashing we can move forwards with a series
> > > based on main?
> >
> > Hi, Simon and Nick:
> >
> > I squashed the first four patches as a "RISC-V: Some fixes for riscv
> > port" patch and then took the horms/main as the base to collect the 2
> > patches from horms/build-test-riscv-v2 branch and this series togother.
> > These are the Github link and all commits for RISC-V.
> >
> > https://github.com/sugarfillet/kexec-tools/commits/main_rv
> >
> > 5dc133e RISC-V: Support loading Image binary file
> > b042f6d RISC-V: Separate elf_riscv_find_pbase out
> > 8f344c7 RISC-V: Enable kexec_file_load syscall
> > 7d4b982 RISC-V: Some fixes for riscv port
> > 3205c1c local: RISC-V: distribute purgatory/riscv/Makefile
> > 54f9daf RISC-V: Add support for riscv kexec/kdump on kexec-tools
> >
> > Since I didn't found the issues/fixes as Nick mentioned with these
> > commits, I prefer to merge them into horms/main and let more kexec/kdump
> > users to help improve/fixup RISC-V port.
> 
> Hi,  I noticed another pr for Fedora kexec-tools:
> https://src.fedoraproject.org/rpms/kexec-tools/pull-request/24
> 
> It is bad to take it as Fedora only,   I would suggest posting all the
> refreshed patches together here again for review.
> 
> If no enough reviewers can review them my another suggestion is to
> drop the kexec_load support code for the time being, and only enable
> the kexec_file_load support code in kexec-tools, and I assume below
> kernel commit make the kexec_file_load kernel piece of work done.
> Then it will be easier to review and make something working at least.
> commit 6261586e0c91db14c34f894f4bc48f2300cff1d4
> Author: Liao Chang 
> Date:   Fri Apr 8 18:09:11 2022 +0800
> 
> RISC-V: Add kexec_file support

Hi,

I would gladly take a patchset for kexec-tools that adds RISC-V support in
a coherent manner.


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH 0/7] Kexec-tools: Improve RISC-V port

2024-05-17 Thread Dave Young
On Wed, 11 Oct 2023 at 13:24, Song Shuai  wrote:
>
>
>
> 在 2023/9/20 19:56, Simon Horman 写道:
> > On Fri, Sep 15, 2023 at 11:50:06AM +0800, Song Shuai wrote:
> >> Hi,
> >>
> >> This series is created to improve RISC-V port of kexec-tools,
> >> and is based on the horms/kexec-tools:build-test-riscv-v2 branch.
> >
> > In my mind the big question is how to move RISC-V support
> > from that branch, to being merged into main.
> >
> > IIRC there were some issues that needed to be addressed.
> > Perhaps they are all addressed by this series, and with
> > some appropriate squashing we can move forwards with a series
> > based on main?
>
> Hi, Simon and Nick:
>
> I squashed the first four patches as a "RISC-V: Some fixes for riscv
> port" patch and then took the horms/main as the base to collect the 2
> patches from horms/build-test-riscv-v2 branch and this series togother.
> These are the Github link and all commits for RISC-V.
>
> https://github.com/sugarfillet/kexec-tools/commits/main_rv
>
> 5dc133e RISC-V: Support loading Image binary file
> b042f6d RISC-V: Separate elf_riscv_find_pbase out
> 8f344c7 RISC-V: Enable kexec_file_load syscall
> 7d4b982 RISC-V: Some fixes for riscv port
> 3205c1c local: RISC-V: distribute purgatory/riscv/Makefile
> 54f9daf RISC-V: Add support for riscv kexec/kdump on kexec-tools
>
> Since I didn't found the issues/fixes as Nick mentioned with these
> commits, I prefer to merge them into horms/main and let more kexec/kdump
> users to help improve/fixup RISC-V port.

Hi,  I noticed another pr for Fedora kexec-tools:
https://src.fedoraproject.org/rpms/kexec-tools/pull-request/24

It is bad to take it as Fedora only,   I would suggest posting all the
refreshed patches together here again for review.

If no enough reviewers can review them my another suggestion is to
drop the kexec_load support code for the time being, and only enable
the kexec_file_load support code in kexec-tools, and I assume below
kernel commit make the kexec_file_load kernel piece of work done.
Then it will be easier to review and make something working at least.
commit 6261586e0c91db14c34f894f4bc48f2300cff1d4
Author: Liao Chang 
Date:   Fri Apr 8 18:09:11 2022 +0800

RISC-V: Add kexec_file support

Thanks
Dave


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [kexec-tools][PATCH] ARM: Fix add_buffer_phys_virt() align issue

2024-04-26 Thread Simon Horman
On Wed, Apr 24, 2024 at 02:17:27PM +0200, Alexander Kanavin wrote:
> From: Haiqing Bai 
> 
> When "CONFIG_ARM_LPAE" is enabled,3 level page table
> is used by MMU, the "SECTION_SIZE" is defined with
> (1 << 21), but 'add_buffer_phys_virt()' hardcode this
> to (1 << 20).
> 
> Suggested-By: fredrik.markst...@gmail.com
> Signed-off-by: Haiqing Bai 
> Signed-off-by: Alexander Kanavin 

Thanks, applied.

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[kexec-tools][PATCH] ARM: Fix add_buffer_phys_virt() align issue

2024-04-24 Thread Alexander Kanavin
From: Haiqing Bai 

When "CONFIG_ARM_LPAE" is enabled,3 level page table
is used by MMU, the "SECTION_SIZE" is defined with
(1 << 21), but 'add_buffer_phys_virt()' hardcode this
to (1 << 20).

Suggested-By: fredrik.markst...@gmail.com
Signed-off-by: Haiqing Bai 
Signed-off-by: Alexander Kanavin 
---
 kexec/arch/arm/crashdump-arm.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 1ec1826..cc20f63 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -242,6 +242,7 @@ int load_crashdump_segments(struct kexec_info *info, char 
*mod_cmdline)
void *buf;
int err;
int last_ranges;
+   unsigned short align_bit_shift = 20;
 
/*
 * First fetch all the memory (RAM) ranges that we are going to pass to
@@ -283,6 +284,7 @@ int load_crashdump_segments(struct kexec_info *info, char 
*mod_cmdline)
 
/* for support LPAE enabled kernel*/
elf_info.class = ELFCLASS64;
+   align_bit_shift = 21;
 
err = crash_create_elf64_headers(info, &elf_info,
 usablemem_rgns.ranges,
@@ -304,8 +306,9 @@ int load_crashdump_segments(struct kexec_info *info, char 
*mod_cmdline)
 * 1MB) so that available memory passed in kernel command line will be
 * aligned to 1MB. This is because kernel create_mapping() wants memory
 * regions to be aligned to SECTION_SIZE.
+* The SECTION_SIZE of LPAE kernel is '1UL << 21' defined in 
pgtable-3level.h
 */
-   elfcorehdr = add_buffer_phys_virt(info, buf, bufsz, bufsz, 1 << 20,
+   elfcorehdr = add_buffer_phys_virt(info, buf, bufsz, bufsz, 1 << 
align_bit_shift,
  crash_kernel_mem.start,
  crash_kernel_mem.end, -1, 0);
 
-- 
2.39.2


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH kexec-tools] workflow: update to use checkout@v4

2024-02-07 Thread Simon Horman
On Fri, Feb 02, 2024 at 09:55:41AM +0100, Simon Horman wrote:
> Update to use checkout@v4.
> 
> This addresses the following warning that appears in GitHub runs:
> 
> "Node.js 16 actions are deprecated. Please update the following actions
>  to use Node.js 20: actions/checkout@v3. For more information
>  see: 
> https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.
> 
> Link: https://github.com/horms/kexec-tools/actions/runs/7753454923
> Signed-off-by: Simon Horman 

Applied.

- workflow: update to use checkout@v4
  
https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/commit/?id=6ee2ac1bf739


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH] kexec-tools: purgatory: fix build on `binutils-2.42`

2024-02-04 Thread Baoquan He
On 02/02/24 at 09:57am, Simon Horman wrote:
> On Fri, Feb 02, 2024 at 12:16:38PM +0800, Baoquan He wrote:
> > On 02/02/24 at 11:01am, Coiby Xu wrote:
> > > Hi,
> > > 
> > > FYI, before this patch, Michel already sent "[PATCH] Fix building on 
> > > x86_64
> > > with binutils 2.41" to address the same issue. Currently I almost know
> > > nothing about
> > > assembly but Michel's patch seems to be more complete because two more
> > > files are touched.
> > 
> > Thanks for telling, I didn't notice that one. I didn't know these
> > either, leave them to Sergei and Michel to decide what is the
> > appropriate solution.
> 
> Hi,
> 
> I did go ahead and apply Michael's patch.
> Let's follow-up with incremental changes if necessary.

Sounds great, thanks.


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH] kexec-tools: purgatory: fix build on `binutils-2.42`

2024-02-02 Thread Simon Horman
On Fri, Feb 02, 2024 at 12:16:38PM +0800, Baoquan He wrote:
> On 02/02/24 at 11:01am, Coiby Xu wrote:
> > Hi,
> > 
> > FYI, before this patch, Michel already sent "[PATCH] Fix building on x86_64
> > with binutils 2.41" to address the same issue. Currently I almost know
> > nothing about
> > assembly but Michel's patch seems to be more complete because two more
> > files are touched.
> 
> Thanks for telling, I didn't notice that one. I didn't know these
> either, leave them to Sergei and Michel to decide what is the
> appropriate solution.

Hi,

I did go ahead and apply Michael's patch.
Let's follow-up with incremental changes if necessary.

...

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH kexec-tools] workflow: update to use checkout@v4

2024-02-02 Thread Simon Horman
Update to use checkout@v4.

This addresses the following warning that appears in GitHub runs:

"Node.js 16 actions are deprecated. Please update the following actions
 to use Node.js 20: actions/checkout@v3. For more information
 see: 
https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.

Link: https://github.com/horms/kexec-tools/actions/runs/7753454923
Signed-off-by: Simon Horman 
---
 .github/workflows/build.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d0007f14b274..46edde66e384 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -28,7 +28,7 @@ jobs:
 libxen: libxen
 steps:
 - name: Checkout
-  uses: actions/checkout@v3
+  uses: actions/checkout@v4
 
 - name: Set Environment
   env:


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH] kexec-tools: purgatory: fix build on `binutils-2.42`

2024-02-01 Thread Baoquan He
On 02/02/24 at 11:01am, Coiby Xu wrote:
> Hi,
> 
> FYI, before this patch, Michel already sent "[PATCH] Fix building on x86_64
> with binutils 2.41" to address the same issue. Currently I almost know
> nothing about
> assembly but Michel's patch seems to be more complete because two more
> files are touched.

Thanks for telling, I didn't notice that one. I didn't know these
either, leave them to Sergei and Michel to decide what is the
appropriate solution.

> 
> On Wed, Jan 31, 2024 at 07:04:57PM +0800, Baoquan He wrote:
> > On 01/31/24 at 10:05am, Sergei Trofimovich wrote:
> > > `binutils-2.42` introduced stricter checks on what `.arch` can be used
> > > in 64-bit mode and started failing the build as:
> > > 
> > > $ as-2.42 --64 -o entry32-16-debug.o entry32-16-debug.s
> > > purgatory/arch/i386/entry32-16-debug.S: Assembler messages:
> > > purgatory/arch/i386/entry32-16-debug.S:28: Error: 64bit mode not 
> > > supported on `i386'.
> > > 
> > > The change moves `.code32` before `.arch 386` as suggested in
> > > https://sourceware.org/PR31319
> > 
> > I am not familiar with the gas behaviour, the fix sounds good from
> > discussion in above link.
> > 
> > Reviewed-by: Baoquan He 
> > 
> > > 
> > > Signed-off-by: Sergei Trofimovich 
> > > ---
> > >  purgatory/arch/i386/entry32-16-debug.S | 2 +-
> > >  purgatory/arch/i386/entry32-16.S   | 2 +-
> > >  2 files changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/purgatory/arch/i386/entry32-16-debug.S 
> > > b/purgatory/arch/i386/entry32-16-debug.S
> > > index 5167944..297d6f5 100644
> > > --- a/purgatory/arch/i386/entry32-16-debug.S
> > > +++ b/purgatory/arch/i386/entry32-16-debug.S
> > > @@ -25,10 +25,10 @@
> > >   .globl entry16_debug_pre32
> > >   .globl entry16_debug_first32
> > >   .globl entry16_debug_old_first32
> > > + .code32
> > >   .arch i386
> > >   .balign 16
> > >  entry16_debug:
> > > - .code32
> > >   /* Compute where I am running at (assumes esp valid) */
> > >   call1f
> > >  1:   popl%ebx
> > > diff --git a/purgatory/arch/i386/entry32-16.S 
> > > b/purgatory/arch/i386/entry32-16.S
> > > index c051aab..7a84565 100644
> > > --- a/purgatory/arch/i386/entry32-16.S
> > > +++ b/purgatory/arch/i386/entry32-16.S
> > > @@ -20,10 +20,10 @@
> > >  #undef i386  
> > >   .text
> > >   .globl entry16, entry16_regs
> > > + .code32
> > >   .arch i386
> > >   .balign 16
> > >  entry16:
> > > - .code32
> > >   /* Compute where I am running at (assumes esp valid) */
> > >   call1f
> > >  1:   popl%ebx
> > > --
> > > 2.43.0
> > > 
> > 
> 
> -- 
> Best regards,
> Coiby
> 


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: Re: [PATCH] kexec-tools: purgatory: fix build on `binutils-2.42`

2024-02-01 Thread Coiby Xu

Hi,

FYI, before this patch, Michel already sent 
"[PATCH] Fix building on x86_64 with binutils 2.41" 
to address the same issue. Currently I almost know nothing about

assembly but Michel's patch seems to be more complete because two more
files are touched.

On Wed, Jan 31, 2024 at 07:04:57PM +0800, Baoquan He wrote:

On 01/31/24 at 10:05am, Sergei Trofimovich wrote:

`binutils-2.42` introduced stricter checks on what `.arch` can be used
in 64-bit mode and started failing the build as:

$ as-2.42 --64 -o entry32-16-debug.o entry32-16-debug.s
purgatory/arch/i386/entry32-16-debug.S: Assembler messages:
purgatory/arch/i386/entry32-16-debug.S:28: Error: 64bit mode not supported 
on `i386'.

The change moves `.code32` before `.arch 386` as suggested in
https://sourceware.org/PR31319


I am not familiar with the gas behaviour, the fix sounds good from
discussion in above link.

Reviewed-by: Baoquan He 



Signed-off-by: Sergei Trofimovich 
---
 purgatory/arch/i386/entry32-16-debug.S | 2 +-
 purgatory/arch/i386/entry32-16.S   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/purgatory/arch/i386/entry32-16-debug.S 
b/purgatory/arch/i386/entry32-16-debug.S
index 5167944..297d6f5 100644
--- a/purgatory/arch/i386/entry32-16-debug.S
+++ b/purgatory/arch/i386/entry32-16-debug.S
@@ -25,10 +25,10 @@
.globl entry16_debug_pre32
.globl entry16_debug_first32
.globl entry16_debug_old_first32
+   .code32
.arch i386
.balign 16
 entry16_debug:
-   .code32
/* Compute where I am running at (assumes esp valid) */
call1f
 1: popl%ebx
diff --git a/purgatory/arch/i386/entry32-16.S b/purgatory/arch/i386/entry32-16.S
index c051aab..7a84565 100644
--- a/purgatory/arch/i386/entry32-16.S
+++ b/purgatory/arch/i386/entry32-16.S
@@ -20,10 +20,10 @@
 #undef i386
.text
.globl entry16, entry16_regs
+   .code32
.arch i386
.balign 16
 entry16:
-   .code32
/* Compute where I am running at (assumes esp valid) */
call1f
 1: popl%ebx
--
2.43.0





--
Best regards,
Coiby


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH] kexec-tools: purgatory: fix build on `binutils-2.42`

2024-01-31 Thread Sergei Trofimovich
`binutils-2.42` introduced stricter checks on what `.arch` can be used
in 64-bit mode and started failing the build as:

$ as-2.42 --64 -o entry32-16-debug.o entry32-16-debug.s
purgatory/arch/i386/entry32-16-debug.S: Assembler messages:
purgatory/arch/i386/entry32-16-debug.S:28: Error: 64bit mode not supported 
on `i386'.

The change moves `.code32` before `.arch 386` as suggested in
https://sourceware.org/PR31319

Signed-off-by: Sergei Trofimovich 
---
 purgatory/arch/i386/entry32-16-debug.S | 2 +-
 purgatory/arch/i386/entry32-16.S   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/purgatory/arch/i386/entry32-16-debug.S 
b/purgatory/arch/i386/entry32-16-debug.S
index 5167944..297d6f5 100644
--- a/purgatory/arch/i386/entry32-16-debug.S
+++ b/purgatory/arch/i386/entry32-16-debug.S
@@ -25,10 +25,10 @@
.globl entry16_debug_pre32
.globl entry16_debug_first32
.globl entry16_debug_old_first32
+   .code32
.arch i386
.balign 16
 entry16_debug:
-   .code32
/* Compute where I am running at (assumes esp valid) */
call1f
 1: popl%ebx
diff --git a/purgatory/arch/i386/entry32-16.S b/purgatory/arch/i386/entry32-16.S
index c051aab..7a84565 100644
--- a/purgatory/arch/i386/entry32-16.S
+++ b/purgatory/arch/i386/entry32-16.S
@@ -20,10 +20,10 @@
 #undef i386
.text
.globl entry16, entry16_regs
+   .code32
.arch i386
.balign 16
 entry16:
-   .code32
/* Compute where I am running at (assumes esp valid) */
call1f
 1: popl%ebx
-- 
2.43.0


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH] kexec-tools: purgatory: fix build on `binutils-2.42`

2024-01-31 Thread Baoquan He
On 01/31/24 at 10:05am, Sergei Trofimovich wrote:
> `binutils-2.42` introduced stricter checks on what `.arch` can be used
> in 64-bit mode and started failing the build as:
> 
> $ as-2.42 --64 -o entry32-16-debug.o entry32-16-debug.s
> purgatory/arch/i386/entry32-16-debug.S: Assembler messages:
> purgatory/arch/i386/entry32-16-debug.S:28: Error: 64bit mode not 
> supported on `i386'.
> 
> The change moves `.code32` before `.arch 386` as suggested in
> https://sourceware.org/PR31319

I am not familiar with the gas behaviour, the fix sounds good from
discussion in above link.

Reviewed-by: Baoquan He 

> 
> Signed-off-by: Sergei Trofimovich 
> ---
>  purgatory/arch/i386/entry32-16-debug.S | 2 +-
>  purgatory/arch/i386/entry32-16.S   | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/purgatory/arch/i386/entry32-16-debug.S 
> b/purgatory/arch/i386/entry32-16-debug.S
> index 5167944..297d6f5 100644
> --- a/purgatory/arch/i386/entry32-16-debug.S
> +++ b/purgatory/arch/i386/entry32-16-debug.S
> @@ -25,10 +25,10 @@
>   .globl entry16_debug_pre32
>   .globl entry16_debug_first32
>   .globl entry16_debug_old_first32
> + .code32
>   .arch i386
>   .balign 16
>  entry16_debug:
> - .code32
>   /* Compute where I am running at (assumes esp valid) */
>   call1f
>  1:   popl%ebx
> diff --git a/purgatory/arch/i386/entry32-16.S 
> b/purgatory/arch/i386/entry32-16.S
> index c051aab..7a84565 100644
> --- a/purgatory/arch/i386/entry32-16.S
> +++ b/purgatory/arch/i386/entry32-16.S
> @@ -20,10 +20,10 @@
>  #undef i386  
>   .text
>   .globl entry16, entry16_regs
> + .code32
>   .arch i386
>   .balign 16
>  entry16:
> - .code32
>   /* Compute where I am running at (assumes esp valid) */
>   call1f
>  1:   popl%ebx
> -- 
> 2.43.0
> 


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[ANNOUNCE] kexec-tools 2.0.28

2024-01-11 Thread Simon Horman
Hi all,

I am happy to announce the release of kexec-tools 2.0.28.

This is a feature release coinciding with the release of v6.7
of the Linux Kernel.

This release can be downloaded from kernel.org:

http://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.28.tar.xz
http://kernel.org/pub/linux/utils/kernel/kexec/

It is also tagged it in git:

git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git

Thanks to everyone who has contributed to kexec!

Commits since v2.0.27:

adef8a8e4bfd kexec-tools 2.0.28
5d7bc25cf15b kexec-tools 2.0.28-rc1
549466430ae6 LoongArch: Load vmlinux.efi to the link address
ba0ac0efe299 LoongArch: Fix an issue with relocatable vmlinux
74dfaefd6316 m68k: fix getrandom() use with uclibc
22dcf5cb940a lzma: Relax memory limit for lzma decompressor
44e7b73c331f kexec: ppc64: print help to stdout instead of stderr
74d66d405f30 workflow: update to Ubuntu 22.04
ab3a70af8567 kexec/loongarch64: fix 'make dist' file loss issue
6419b008fde7 kexec: provide a memfd_create() wrapper if not present in libc
118b567ce74a crashdump/x86: set the elfcorehdr segment size for hotplug
d59d17f37239 crashdump/x86: identify elfcorehdr segment for hotplug
a56376080a93 crashdump: exclude elfcorehdr segment from digest for hotplug
75ac71fd94ff crashdump: setup general hotplug support
d6cfd2984844 crashdump: introduce the hotplug command line options
c36d3e8b2e99 kexec: define KEXEC_UPDATE_ELFCOREHDR
bd0200c47c45 kexec: update manpage with explicit mention of clean kexec
2495ccfc5206 zboot: add loongarch kexec_load support
8f08e3b51f25 zboot: enable arm64 kexec_load for zboot image
c3f35ff06e54 build: fix tarball creation
056c179cd3c2 kexec-tools 2.0.27.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[ANNOUNCE] kexec-tools 2.0.28-rc1

2024-01-03 Thread Simon Horman
Hi all,

I am happy to announce the release of kexec-tools 2.0.28-rc1.

This is an incremental feature pre-release.

So long as no serious problems arise I intend to release kexec-tools 2.0.28
in a weeks time. Testing of 2.0.28-rc1 would be greatly appreciated.

I do not have any outstanding changes for 2.0.28 at this time.
And I would like to only accept bug fixes at this time and take
features patches once 2.0.28 has been released.

The pre-release can be downloaded from kernel.org:


https://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.28-rc1.tar.xz
https://kernel.org/pub/linux/utils/kernel/kexec/

I have also tagged it in git:

https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git

Thanks to everyone who has contributed to kexec.


For reference the changes since v2.0.27 are:

5d7bc25cf15b kexec-tools 2.0.28-rc1
549466430ae6 LoongArch: Load vmlinux.efi to the link address
ba0ac0efe299 LoongArch: Fix an issue with relocatable vmlinux
74dfaefd6316 m68k: fix getrandom() use with uclibc
22dcf5cb940a lzma: Relax memory limit for lzma decompressor
44e7b73c331f kexec: ppc64: print help to stdout instead of stderr
74d66d405f30 workflow: update to Ubuntu 22.04
ab3a70af8567 kexec/loongarch64: fix 'make dist' file loss issue
6419b008fde7 kexec: provide a memfd_create() wrapper if not present in libc
118b567ce74a crashdump/x86: set the elfcorehdr segment size for hotplug
d59d17f37239 crashdump/x86: identify elfcorehdr segment for hotplug
a56376080a93 crashdump: exclude elfcorehdr segment from digest for hotplug
75ac71fd94ff crashdump: setup general hotplug support
d6cfd2984844 crashdump: introduce the hotplug command line options
c36d3e8b2e99 kexec: define KEXEC_UPDATE_ELFCOREHDR
bd0200c47c45 kexec: update manpage with explicit mention of clean kexec
2495ccfc5206 zboot: add loongarch kexec_load support
8f08e3b51f25 zboot: enable arm64 kexec_load for zboot image
c3f35ff06e54 build: fix tarball creation
056c179cd3c2 kexec-tools 2.0.27.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[ANNOUNCE] kexec-tools v2.0.28 preparation

2023-12-18 Thread Simon Horman
Hi all,

I am planning to release kexec-tools v2.0.28 in the next two weeks
to roughly coincide with the release of the v6.7 kernel.

I would like to ask interested parties to send any patches they would like
included in v2.0.28 within one week so they can be considered for inclusion
in an rc release.

For reference the patches queued up since v2.0.27 are as follows.

Thanks to everyone who has contributed to kexec-tools!

549466430ae6 LoongArch: Load vmlinux.efi to the link address
ba0ac0efe299 LoongArch: Fix an issue with relocatable vmlinux
74dfaefd6316 m68k: fix getrandom() use with uclibc
22dcf5cb940a lzma: Relax memory limit for lzma decompressor
44e7b73c331f kexec: ppc64: print help to stdout instead of stderr
74d66d405f30 workflow: update to Ubuntu 22.04
ab3a70af8567 kexec/loongarch64: fix 'make dist' file loss issue
6419b008fde7 kexec: provide a memfd_create() wrapper if not present in libc
118b567ce74a crashdump/x86: set the elfcorehdr segment size for hotplug
d59d17f37239 crashdump/x86: identify elfcorehdr segment for hotplug
a56376080a93 crashdump: exclude elfcorehdr segment from digest for hotplug
75ac71fd94ff crashdump: setup general hotplug support
d6cfd2984844 crashdump: introduce the hotplug command line options
c36d3e8b2e99 kexec: define KEXEC_UPDATE_ELFCOREHDR
bd0200c47c45 kexec: update manpage with explicit mention of clean kexec
2495ccfc5206 zboot: add loongarch kexec_load support
8f08e3b51f25 zboot: enable arm64 kexec_load for zboot image
c3f35ff06e54 build: fix tarball creation
056c179cd3c2 kexec-tools 2.0.27.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH kexec-tools] workflow: update to Ubuntu 22.04

2023-10-18 Thread Simon Horman
On Wed, Oct 11, 2023 at 10:59:33AM +0200, Simon Horman wrote:
> Bump workflow to use latest LTS release.
> 
> Signed-off-by: Simon Horman 

FTR, this has been applied.

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH kexec-tools] workflow: update to Ubuntu 22.04

2023-10-11 Thread Simon Horman
Bump workflow to use latest LTS release.

Signed-off-by: Simon Horman 
---
 .github/workflows/build.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 4c6e9d730488..d0007f14b274 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -5,7 +5,7 @@ on: push
 jobs:
   build:
 name: Build
-runs-on: ubuntu-20.04
+runs-on: ubuntu-22.04
 strategy:
   matrix:
 arch:
-- 
2.30.2


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH 0/7] Kexec-tools: Improve RISC-V port

2023-10-10 Thread Song Shuai



在 2023/9/20 19:56, Simon Horman 写道:

On Fri, Sep 15, 2023 at 11:50:06AM +0800, Song Shuai wrote:

Hi,

This series is created to improve RISC-V port of kexec-tools,
and is based on the horms/kexec-tools:build-test-riscv-v2 branch.


In my mind the big question is how to move RISC-V support
from that branch, to being merged into main.

IIRC there were some issues that needed to be addressed.
Perhaps they are all addressed by this series, and with
some appropriate squashing we can move forwards with a series
based on main?


Hi, Simon and Nick:

I squashed the first four patches as a "RISC-V: Some fixes for riscv 
port" patch and then took the horms/main as the base to collect the 2 
patches from horms/build-test-riscv-v2 branch and this series togother. 
These are the Github link and all commits for RISC-V.


https://github.com/sugarfillet/kexec-tools/commits/main_rv

5dc133e RISC-V: Support loading Image binary file
b042f6d RISC-V: Separate elf_riscv_find_pbase out
8f344c7 RISC-V: Enable kexec_file_load syscall
7d4b982 RISC-V: Some fixes for riscv port
3205c1c local: RISC-V: distribute purgatory/riscv/Makefile
54f9daf RISC-V: Add support for riscv kexec/kdump on kexec-tools

Since I didn't found the issues/fixes as Nick mentioned with these 
commits, I prefer to merge them into horms/main and let more kexec/kdump 
users to help improve/fixup RISC-V port.


I would like to listen to your advice.





For your convenience, here is my Github branch for kexec-tools:
https://github.com/sugarfillet/kexec-tools/commits/rv-Image

The first four patches fixes some build or runtime issues:

   RISC-V: Use linux,usable-memory-range for crash kernel
   RISC-V: Fix the undeclared ‘EM_RISCV’ build failure
   RISC-V: Get memory ranges from iomem
   RISC-V: Correct the usage of command line option

The last three patches enable the kexec_file_load syscall to load
vmlinux and support loading Image binary file for two syscalls.

   RISC-V: Enable kexe_file_load
   RISC-V: Separate elf_riscv_find_pbase out
   RISC-V: Support loading Image binary file

Note that:

RISC-V Linux kexec_load_file's support for Image file has been sent out but not 
merged [1].

[1]: 
https://lore.kernel.org/linux-riscv/20230914020044.1397356-1-songshuaish...@tinylab.org/T/#t

Li Zhengyu (1):
   RISC-V: Enable kexe_file_load

Song Shuai (6):
   RISC-V: Use linux,usable-memory-range for crash kernel
   RISC-V: Fix the undeclared ‘EM_RISCV’ build failure
   RISC-V: Get memory ranges from iomem
   RISC-V: Correct the usage of command line option
   RISC-V: Separate elf_riscv_find_pbase out
   RISC-V: Support loading Image binary file

  kexec/arch/riscv/Makefile|   2 +
  kexec/arch/riscv/crashdump-riscv.c   |   2 +-
  kexec/arch/riscv/image-header.h  |  88 ++
  kexec/arch/riscv/iomem.h |  10 ++
  kexec/arch/riscv/kexec-elf-riscv.c   |  77 +---
  kexec/arch/riscv/kexec-image-riscv.c |  95 +++
  kexec/arch/riscv/kexec-riscv.c   | 176 ++-
  kexec/arch/riscv/kexec-riscv.h   |  21 
  kexec/kexec-syscall.h|   3 +
  9 files changed, 368 insertions(+), 106 deletions(-)
  create mode 100644 kexec/arch/riscv/image-header.h
  create mode 100644 kexec/arch/riscv/iomem.h
  create mode 100644 kexec/arch/riscv/kexec-image-riscv.c

--
2.20.1





--
Thanks
Song Shuai

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [kexec-tools] Archive file is missed iomem.h file under loongarch architecture.

2023-10-10 Thread Ming Wang
Hi, Simon

On 10/10/23 21:01, Simon Horman wrote:
> On Mon, Oct 09, 2023 at 05:47:43PM +0800, Ming Wang wrote:
>> Hi,  maintainers,
>>
>>
>> I get the kexec-tools 2.0.27 from 
>> http://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.27.tar.gz, 
>>
>> But I noticed that the kexec-tools-2.0.27/kexec/arch/loongarch/iomem.h file 
>> was missing from
>>
>> this archive.
>>
>>
>> This causes build errors in many distributions, like debian.  The error 
>> message is as follows,
>>
>> make[1]: *** [Makefile:123: kexec/arch/loongarch/crashdump-loongarch.o] 
>> Error 1
>> kexec/arch/loongarch/kexec-loongarch.c:27:10: fatal error: iomem.h: No such 
>> file or directory
>>27 | #include "iomem.h"
>>
>> See also: 
>> https://buildd.debian.org/status/package.php?p=kexec-tools&suite=sid
>>
>>
>> Can this archive be repaired and updated?
>>
>>
>> Thanks, Ming
> Hi,
>
> I need to think about how to deal with this from a release PoV.
> But can you check if the patch below resolves your problem?
>
> diff --git a/kexec/arch/loongarch/Makefile b/kexec/arch/loongarch/Makefile
> index cee7e569a2a2..f91d0baf049a 100644
> --- a/kexec/arch/loongarch/Makefile
> +++ b/kexec/arch/loongarch/Makefile
> @@ -19,5 +19,6 @@ loongarch_VIRT_TO_PHYS =
>  dist += kexec/arch/loongarch/Makefile $(loongarch_KEXEC_SRCS)
> \
>   kexec/arch/loongarch/kexec-loongarch.h  
> \
>   kexec/arch/loongarch/image-header.h 
> \
> + kexec/arch/loongarch/iomem.h
> \
>   kexec/arch/loongarch/crashdump-loongarch.h  
> \
>   kexec/arch/loongarch/include/arch/options.h

Add this patch and then make dist, it's OK.

Sorry, I was stupid. This can  fix the problem of missing files.




___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [kexec-tools] Archive file is missed iomem.h file under loongarch architecture.

2023-10-10 Thread Ming Wang
Hi, Simon

Thank you for your reply.

On 10/10/23 21:01, Simon Horman wrote:
> On Mon, Oct 09, 2023 at 05:47:43PM +0800, Ming Wang wrote:
>> Hi,  maintainers,
>>
>>
>> I get the kexec-tools 2.0.27 from 
>> http://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.27.tar.gz, 
>>
>> But I noticed that the kexec-tools-2.0.27/kexec/arch/loongarch/iomem.h file 
>> was missing from
>>
>> this archive.
>>
>>
>> This causes build errors in many distributions, like debian.  The error 
>> message is as follows,
>>
>> make[1]: *** [Makefile:123: kexec/arch/loongarch/crashdump-loongarch.o] 
>> Error 1
>> kexec/arch/loongarch/kexec-loongarch.c:27:10: fatal error: iomem.h: No such 
>> file or directory
>>27 | #include "iomem.h"
>>
>> See also: 
>> https://buildd.debian.org/status/package.php?p=kexec-tools&suite=sid
>>
>>
>> Can this archive be repaired and updated?
>>
>>
>> Thanks, Ming
> Hi,
>
> I need to think about how to deal with this from a release PoV.
> But can you check if the patch below resolves your problem?

Thanks for the patch, I think this patch is necessary.


But it doesn't solve my problem. My purpose is to port the loongarch 
architecture
kexec-tools tool to Debian.

However,debian community's automatic build system pulled the source from
http://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.27.tar.gz


So, my problem may still require updating the archive.
But I can wait for version 2.0.8 then continuing the debian porting work.

Should this problem be fixed in 2.0.28?

>
> diff --git a/kexec/arch/loongarch/Makefile b/kexec/arch/loongarch/Makefile
> index cee7e569a2a2..f91d0baf049a 100644
> --- a/kexec/arch/loongarch/Makefile
> +++ b/kexec/arch/loongarch/Makefile
> @@ -19,5 +19,6 @@ loongarch_VIRT_TO_PHYS =
>  dist += kexec/arch/loongarch/Makefile $(loongarch_KEXEC_SRCS)
> \
>   kexec/arch/loongarch/kexec-loongarch.h  
> \
>   kexec/arch/loongarch/image-header.h 
> \
> + kexec/arch/loongarch/iomem.h
> \
>   kexec/arch/loongarch/crashdump-loongarch.h  
> \
>   kexec/arch/loongarch/include/arch/options.h


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [kexec-tools] Archive file is missed iomem.h file under loongarch architecture.

2023-10-10 Thread Simon Horman
On Mon, Oct 09, 2023 at 05:47:43PM +0800, Ming Wang wrote:
> Hi,  maintainers,
> 
> 
> I get the kexec-tools 2.0.27 from 
> http://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.27.tar.gz, 
> 
> But I noticed that the kexec-tools-2.0.27/kexec/arch/loongarch/iomem.h file 
> was missing from
> 
> this archive.
> 
> 
> This causes build errors in many distributions, like debian.  The error 
> message is as follows,
> 
> make[1]: *** [Makefile:123: kexec/arch/loongarch/crashdump-loongarch.o] Error 
> 1
> kexec/arch/loongarch/kexec-loongarch.c:27:10: fatal error: iomem.h: No such 
> file or directory
>27 | #include "iomem.h"
> 
> See also: https://buildd.debian.org/status/package.php?p=kexec-tools&suite=sid
> 
> 
> Can this archive be repaired and updated?
> 
> 
> Thanks, Ming

Hi,

I need to think about how to deal with this from a release PoV.
But can you check if the patch below resolves your problem?

diff --git a/kexec/arch/loongarch/Makefile b/kexec/arch/loongarch/Makefile
index cee7e569a2a2..f91d0baf049a 100644
--- a/kexec/arch/loongarch/Makefile
+++ b/kexec/arch/loongarch/Makefile
@@ -19,5 +19,6 @@ loongarch_VIRT_TO_PHYS =
 dist += kexec/arch/loongarch/Makefile $(loongarch_KEXEC_SRCS)  
\
kexec/arch/loongarch/kexec-loongarch.h  
\
kexec/arch/loongarch/image-header.h 
\
+   kexec/arch/loongarch/iomem.h
\
kexec/arch/loongarch/crashdump-loongarch.h  
\
kexec/arch/loongarch/include/arch/options.h

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[kexec-tools] Archive file is missed iomem.h file under loongarch architecture.

2023-10-09 Thread Ming Wang
Hi,  maintainers,


I get the kexec-tools 2.0.27 from 
http://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.27.tar.gz, 

But I noticed that the kexec-tools-2.0.27/kexec/arch/loongarch/iomem.h file was 
missing from

this archive.


This causes build errors in many distributions, like debian.  The error message 
is as follows,

make[1]: *** [Makefile:123: kexec/arch/loongarch/crashdump-loongarch.o] Error 1
kexec/arch/loongarch/kexec-loongarch.c:27:10: fatal error: iomem.h: No such 
file or directory
   27 | #include "iomem.h"

See also: https://buildd.debian.org/status/package.php?p=kexec-tools&suite=sid


Can this archive be repaired and updated?


Thanks,
Ming


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH 0/7] Kexec-tools: Improve RISC-V port

2023-09-20 Thread Nick Kossifidis

On 9/15/23 06:50, Song Shuai wrote:

Hi,

This series is created to improve RISC-V port of kexec-tools,
and is based on the horms/kexec-tools:build-test-riscv-v2 branch.

For your convenience, here is my Github branch for kexec-tools:
https://github.com/sugarfillet/kexec-tools/commits/rv-Image

The first four patches fixes some build or runtime issues:

   RISC-V: Use linux,usable-memory-range for crash kernel
   RISC-V: Fix the undeclared ‘EM_RISCV’ build failure
   RISC-V: Get memory ranges from iomem
   RISC-V: Correct the usage of command line option

The last three patches enable the kexec_file_load syscall to load
vmlinux and support loading Image binary file for two syscalls.

   RISC-V: Enable kexe_file_load
   RISC-V: Separate elf_riscv_find_pbase out
   RISC-V: Support loading Image binary file



A few years back I did the initial work for kexec on riscv, and the idea 
was to work on the kexec-tools repo on riscv github:


https://github.com/riscv-collab/kexec-tools/tree/riscv

and then when we have something in a good shape, to push our work 
upstream. People keep sending patches to the kexec mailing list (the 
riscv port of kexec-tools is not upstream so this patch series won't 
apply), instead of pull requests to the above repo.


You have an X set of updates, some other people have posted another set 
of fixes (e.g. I rememver a fix for initramfs/initrd), please let's work 
on the github repo, get something that looks ok and then push our work 
upstream. If you want access to the github repo instead of doing pull 
requests etc let me know.


I'm sorry I didn't have the time to work on this further.

Regards,
Nick

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH 0/7] Kexec-tools: Improve RISC-V port

2023-09-20 Thread Simon Horman
On Fri, Sep 15, 2023 at 11:50:06AM +0800, Song Shuai wrote:
> Hi,
> 
> This series is created to improve RISC-V port of kexec-tools,
> and is based on the horms/kexec-tools:build-test-riscv-v2 branch.

In my mind the big question is how to move RISC-V support
from that branch, to being merged into main.

IIRC there were some issues that needed to be addressed.
Perhaps they are all addressed by this series, and with
some appropriate squashing we can move forwards with a series
based on main?

> 
> For your convenience, here is my Github branch for kexec-tools:
> https://github.com/sugarfillet/kexec-tools/commits/rv-Image
> 
> The first four patches fixes some build or runtime issues:  
> 
>   RISC-V: Use linux,usable-memory-range for crash kernel
>   RISC-V: Fix the undeclared ‘EM_RISCV’ build failure
>   RISC-V: Get memory ranges from iomem
>   RISC-V: Correct the usage of command line option
> 
> The last three patches enable the kexec_file_load syscall to load
> vmlinux and support loading Image binary file for two syscalls.
> 
>   RISC-V: Enable kexe_file_load
>   RISC-V: Separate elf_riscv_find_pbase out
>   RISC-V: Support loading Image binary file
> 
> Note that: 
> 
> RISC-V Linux kexec_load_file's support for Image file has been sent out but 
> not merged [1].
> 
> [1]: 
> https://lore.kernel.org/linux-riscv/20230914020044.1397356-1-songshuaish...@tinylab.org/T/#t
>  
> 
> Li Zhengyu (1):
>   RISC-V: Enable kexe_file_load
> 
> Song Shuai (6):
>   RISC-V: Use linux,usable-memory-range for crash kernel
>   RISC-V: Fix the undeclared ‘EM_RISCV’ build failure
>   RISC-V: Get memory ranges from iomem
>   RISC-V: Correct the usage of command line option
>   RISC-V: Separate elf_riscv_find_pbase out
>   RISC-V: Support loading Image binary file
> 
>  kexec/arch/riscv/Makefile|   2 +
>  kexec/arch/riscv/crashdump-riscv.c   |   2 +-
>  kexec/arch/riscv/image-header.h  |  88 ++
>  kexec/arch/riscv/iomem.h |  10 ++
>  kexec/arch/riscv/kexec-elf-riscv.c   |  77 +---
>  kexec/arch/riscv/kexec-image-riscv.c |  95 +++
>  kexec/arch/riscv/kexec-riscv.c   | 176 ++-
>  kexec/arch/riscv/kexec-riscv.h   |  21 
>  kexec/kexec-syscall.h|   3 +
>  9 files changed, 368 insertions(+), 106 deletions(-)
>  create mode 100644 kexec/arch/riscv/image-header.h
>  create mode 100644 kexec/arch/riscv/iomem.h
>  create mode 100644 kexec/arch/riscv/kexec-image-riscv.c
> 
> -- 
> 2.20.1
> 

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH 0/7] Kexec-tools: Improve RISC-V port

2023-09-14 Thread Song Shuai
Hi,

This series is created to improve RISC-V port of kexec-tools,
and is based on the horms/kexec-tools:build-test-riscv-v2 branch.

For your convenience, here is my Github branch for kexec-tools:
https://github.com/sugarfillet/kexec-tools/commits/rv-Image

The first four patches fixes some build or runtime issues:  

  RISC-V: Use linux,usable-memory-range for crash kernel
  RISC-V: Fix the undeclared ‘EM_RISCV’ build failure
  RISC-V: Get memory ranges from iomem
  RISC-V: Correct the usage of command line option

The last three patches enable the kexec_file_load syscall to load
vmlinux and support loading Image binary file for two syscalls.

  RISC-V: Enable kexe_file_load
  RISC-V: Separate elf_riscv_find_pbase out
  RISC-V: Support loading Image binary file

Note that: 

RISC-V Linux kexec_load_file's support for Image file has been sent out but not 
merged [1].

[1]: 
https://lore.kernel.org/linux-riscv/20230914020044.1397356-1-songshuaish...@tinylab.org/T/#t
 

Li Zhengyu (1):
  RISC-V: Enable kexe_file_load

Song Shuai (6):
  RISC-V: Use linux,usable-memory-range for crash kernel
  RISC-V: Fix the undeclared ‘EM_RISCV’ build failure
  RISC-V: Get memory ranges from iomem
  RISC-V: Correct the usage of command line option
  RISC-V: Separate elf_riscv_find_pbase out
  RISC-V: Support loading Image binary file

 kexec/arch/riscv/Makefile|   2 +
 kexec/arch/riscv/crashdump-riscv.c   |   2 +-
 kexec/arch/riscv/image-header.h  |  88 ++
 kexec/arch/riscv/iomem.h |  10 ++
 kexec/arch/riscv/kexec-elf-riscv.c   |  77 +---
 kexec/arch/riscv/kexec-image-riscv.c |  95 +++
 kexec/arch/riscv/kexec-riscv.c   | 176 ++-
 kexec/arch/riscv/kexec-riscv.h   |  21 
 kexec/kexec-syscall.h|   3 +
 9 files changed, 368 insertions(+), 106 deletions(-)
 create mode 100644 kexec/arch/riscv/image-header.h
 create mode 100644 kexec/arch/riscv/iomem.h
 create mode 100644 kexec/arch/riscv/kexec-image-riscv.c

-- 
2.20.1


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [kexec-tools PATCH] build: fix tarball creation

2023-09-01 Thread Simon Horman
On Mon, Aug 28, 2023 at 11:58:15AM +0200, Leah Neukirchen wrote:
> The fix in 41b77edac did not work, bsdtar still complains about
> "hardlink pointing to itself".
> 
> Simplify the code instead: since the staging directory contains
> exactly the files we want, just package it as a whole.
> 
> Signed-off-by: Leah Neukirchen 

Thanks, applied.

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[kexec-tools PATCH] build: fix tarball creation

2023-08-28 Thread Leah Neukirchen
The fix in 41b77edac did not work, bsdtar still complains about
"hardlink pointing to itself".

Simplify the code instead: since the staging directory contains
exactly the files we want, just package it as a whole.

Signed-off-by: Leah Neukirchen 
---
 Makefile.in | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 09bbd5c..3cad22a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -179,8 +179,6 @@ GENERATED_SRCS:= $(SPEC)
 TARBALL=$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar
 TARBALL.gz=$(TARBALL).gz
 SRCS:= $(dist)
-PSRCS:=$(foreach s, $(SRCS), $(PACKAGE_NAME)-$(PACKAGE_VERSION)/$(s))
-PGSRCS:=$(foreach s, $(GENERATED_SRCS), 
$(PACKAGE_NAME)-$(PACKAGE_VERSION)/$(s))
 
 MAN_PAGES:=$(KEXEC_MANPAGE) $(VMCORE_DMESG_MANPAGE)
 BINARIES_i386:=$(KEXEC_TEST)
@@ -223,8 +221,7 @@ $(TARBALL): $(SRCS) $(GENERATED_SRCS)
$(MKDIR) $(PACKAGE_NAME)-$(PACKAGE_VERSION)
$(TAR) -c $(SRCS) $(GENERATED_SRCS) | \
$(TAR) -C $(PACKAGE_NAME)-$(PACKAGE_VERSION) -x
-   $(TAR) -cf $@ $(PSRCS)
-   $(TAR) -rf $@ $(PGSRCS)
+   $(TAR) -cf $@ $(PACKAGE_NAME)-$(PACKAGE_VERSION)
$(RM) -rf $(PACKAGE_NAME)-$(PACKAGE_VERSION)
 
 $(TARBALL.gz): $(TARBALL)
-- 
2.42.0


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[ANNOUNCE] kexec-tools 2.0.27

2023-08-28 Thread Simon Horman
Hi all,

I am happy to announce the release of kexec-tools 2.0.27.

This is a feature release coinciding with the release of v6.5
of the Linux Kernel.

This release can be downloaded from kernel.org:

http://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.27.tar.xz
http://kernel.org/pub/linux/utils/kernel/kexec/

It is also tagged it in git:

git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git

Thanks to everyone who has contributed to kexec!

Commits since v2.0.26:

17590eedff6d kexec-tools 2.0.27
777ca453ca69 kexec-tools 2.0.27-rc1
f67c4146d7b5 arm64: Hook up the ZBOOT support as vmlinuz
fc7b83bdf734 arm64: Add ZBOOT PE containing compressed image support
f41c4182b0c4 kexec/zboot: Add arch independent zboot support
1572b91da7c4 kexec: Introduce a member kernel_fd in kexec_info
714fa11590fe kexec/arm64: Simplify the code for zImage
a8de94e5f033 LoongArch: kdump: Set up kernel image segment
4203eaccfa92 kexec: __NR_kexec_file_load is set to undefined on LoongArch
63e9a012112e ppc64: Add elf-ppc64 file types/options and an arch specific flag 
to man page
806711fca9e9 x86: add devicetree support
29fe5067ed07 kexec: make -a the default
e63fefd4fc35 ppc64: add --reuse-cmdline parameter support
8fc55927f700 kexec-tools 2.0.26.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[ANNOUNCE] kexec-tools 2.0.27-rc1

2023-08-18 Thread Simon Horman
Hi all,

I am happy to announce the release of kexec-tools 2.0.27-rc1.

This is an incremental feature pre-release.

So long as no serious problems arise I intend to release kexec-tools 2.0.27
in a weeks time. Testing of 2.0.27-rc1 would be greatly appreciated.

I do not have any outstanding changes for 2.0.27 at this time.
And I would like to only accept bug fixes at this time and take
features patches once 2.0.27 has been released.

The pre-release can be downloaded from kernel.org:


https://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.27-rc1.tar.xz
https://kernel.org/pub/linux/utils/kernel/kexec/

I have also tagged it in git:

https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git

Thanks to everyone who has contributed to kexec.


For reference the changes since v2.0.26 are:

777ca453ca69 kexec-tools 2.0.27-rc1
f67c4146d7b5 arm64: Hook up the ZBOOT support as vmlinuz
fc7b83bdf734 arm64: Add ZBOOT PE containing compressed image support
f41c4182b0c4 kexec/zboot: Add arch independent zboot support
1572b91da7c4 kexec: Introduce a member kernel_fd in kexec_info
714fa11590fe kexec/arm64: Simplify the code for zImage
a8de94e5f033 LoongArch: kdump: Set up kernel image segment
4203eaccfa92 kexec: __NR_kexec_file_load is set to undefined on LoongArch
63e9a012112e ppc64: Add elf-ppc64 file types/options and an arch specific flag 
to man page
806711fca9e9 x86: add devicetree support
29fe5067ed07 kexec: make -a the default
e63fefd4fc35 ppc64: add --reuse-cmdline parameter support
8fc55927f700 kexec-tools 2.0.26.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [ANNOUNCE] kexec-tools v2.0.27 preparation

2023-08-15 Thread Simon Horman
On Mon, Aug 14, 2023 at 11:19:07AM +0800, Coiby Xu wrote:
> Hi Sourabh,
> 
> On Mon, Aug 14, 2023 at 08:17:34AM +0530, Sourabh Jain wrote:
> > Hello Simon,
> > 
> > Can we include below fix?
> > https://lists.fedoraproject.org/archives/list/ke...@lists.fedoraproject.org/thread/O3W4SLVVFT6J25U5YSXNZ3URZ4QY6SRU/
> 
> I'll review your patch! Note the patch is against Fedora's kexec-tools
> so it doesn't apply to this upstream kexec-tools. The relationship
> between Fedora's kexec-tools and this upstream kexec-tools can be
> described as follows,
> 1. Fedora's kexec-tools packages the kexec binary which is provides by 
> upstream
> kexec-tools; 2. The kexec binary is used for loading the kdump kernel and
> initrd but
> it's not responsible for building the kdump initrd. Fedora's kexec-tools
> is used to build the kdump initrd instead.
> 
> Currrently it's WIP to split current Fedora kexec-tools into
> kexec-tools, kdump-utils, makedumpfile and eppic. Hopefully after it's
> done, you and other uses will no longer be confused by the relationship
> between Fedora's kexec-tools and this upstream kexec-tools.

Thanks for the clarification, I'm assuming no action is needed on my part
at this time. Let me know if I am mistaken.

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [ANNOUNCE] kexec-tools v2.0.27 preparation

2023-08-13 Thread Sourabh Jain

Hello Coiby,

On 14/08/23 08:49, Coiby Xu wrote:

Hi Sourabh,

On Mon, Aug 14, 2023 at 08:17:34AM +0530, Sourabh Jain wrote:

Hello Simon,

Can we include below fix?
https://lists.fedoraproject.org/archives/list/ke...@lists.fedoraproject.org/thread/O3W4SLVVFT6J25U5YSXNZ3URZ4QY6SRU/ 



I'll review your patch! Note the patch is against Fedora's kexec-tools
so it doesn't apply to this upstream kexec-tools. The relationship
between Fedora's kexec-tools and this upstream kexec-tools can be
described as follows,
1. Fedora's kexec-tools packages the kexec binary which is provides by 
upstream
kexec-tools; 2. The kexec binary is used for loading the kdump kernel 
and initrd but

it's not responsible for building the kdump initrd. Fedora's kexec-tools
is used to build the kdump initrd instead.
Currrently it's WIP to split current Fedora kexec-tools into
kexec-tools, kdump-utils, makedumpfile and eppic. Hopefully after it's
done, you and other uses will no longer be confused by the relationship
between Fedora's kexec-tools and this upstream kexec-tools.


My Thunderbird filters mail from ke...@lists.fedoraproject.org and 
kexec@lists.infradead.org

to the same folder so I got confused. I should update my Thunderbird filter.

Thanks for clarification.
Sourabh


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [ANNOUNCE] kexec-tools v2.0.27 preparation

2023-08-13 Thread Coiby Xu

Hi Sourabh,

On Mon, Aug 14, 2023 at 08:17:34AM +0530, Sourabh Jain wrote:

Hello Simon,

Can we include below fix?
https://lists.fedoraproject.org/archives/list/ke...@lists.fedoraproject.org/thread/O3W4SLVVFT6J25U5YSXNZ3URZ4QY6SRU/


I'll review your patch! Note the patch is against Fedora's kexec-tools
so it doesn't apply to this upstream kexec-tools. The relationship
between Fedora's kexec-tools and this upstream kexec-tools can be
described as follows,
1. Fedora's kexec-tools packages the kexec binary which is provides by upstream
kexec-tools; 
2. The kexec binary is used for loading the kdump kernel and initrd but

it's not responsible for building the kdump initrd. Fedora's kexec-tools
is used to build the kdump initrd instead. 


Currrently it's WIP to split current Fedora kexec-tools into
kexec-tools, kdump-utils, makedumpfile and eppic. Hopefully after it's
done, you and other uses will no longer be confused by the relationship
between Fedora's kexec-tools and this upstream kexec-tools.

--
Best regards,
Coiby


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [ANNOUNCE] kexec-tools v2.0.27 preparation

2023-08-13 Thread Sourabh Jain

Hello Simon,

Can we include below fix?
https://lists.fedoraproject.org/archives/list/ke...@lists.fedoraproject.org/thread/O3W4SLVVFT6J25U5YSXNZ3URZ4QY6SRU/

Thanks,
Sourabh

On 11/08/23 13:00, Simon Horman wrote:

Hi all,

I am planning to release kexec-tools v2.0.27 in the next two weeks
to roughly coincide with the release of the v6.5 kernel.

I would like to ask interested parties to send any patches they would like
included in v2.0.27 within one week so they can be considered for inclusion
in an rc release.

For reference the patches queued up since v2.0.26 are as follows.

Thanks to everyone who has contributed to kexec-tools!

f67c4146d7b5 arm64: Hook up the ZBOOT support as vmlinuz
fc7b83bdf734 arm64: Add ZBOOT PE containing compressed image support
f41c4182b0c4 kexec/zboot: Add arch independent zboot support
1572b91da7c4 kexec: Introduce a member kernel_fd in kexec_info
714fa11590fe kexec/arm64: Simplify the code for zImage
a8de94e5f033 LoongArch: kdump: Set up kernel image segment
4203eaccfa92 kexec: __NR_kexec_file_load is set to undefined on LoongArch
63e9a012112e ppc64: Add elf-ppc64 file types/options and an arch specific flag 
to man page
806711fca9e9 x86: add devicetree support
29fe5067ed07 kexec: make -a the default
e63fefd4fc35 ppc64: add --reuse-cmdline parameter support
8fc55927f700 kexec-tools 2.0.26.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec



___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[ANNOUNCE] kexec-tools v2.0.27 preparation

2023-08-11 Thread Simon Horman
Hi all,

I am planning to release kexec-tools v2.0.27 in the next two weeks
to roughly coincide with the release of the v6.5 kernel.

I would like to ask interested parties to send any patches they would like
included in v2.0.27 within one week so they can be considered for inclusion
in an rc release.

For reference the patches queued up since v2.0.26 are as follows.

Thanks to everyone who has contributed to kexec-tools!

f67c4146d7b5 arm64: Hook up the ZBOOT support as vmlinuz
fc7b83bdf734 arm64: Add ZBOOT PE containing compressed image support
f41c4182b0c4 kexec/zboot: Add arch independent zboot support
1572b91da7c4 kexec: Introduce a member kernel_fd in kexec_info
714fa11590fe kexec/arm64: Simplify the code for zImage
a8de94e5f033 LoongArch: kdump: Set up kernel image segment
4203eaccfa92 kexec: __NR_kexec_file_load is set to undefined on LoongArch
63e9a012112e ppc64: Add elf-ppc64 file types/options and an arch specific flag 
to man page
806711fca9e9 x86: add devicetree support
29fe5067ed07 kexec: make -a the default
e63fefd4fc35 ppc64: add --reuse-cmdline parameter support
8fc55927f700 kexec-tools 2.0.26.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH V2] RISC-V: Add support for riscv kexec/kdump on kexec-tools

2023-07-19 Thread Petr Tesařík
On Tue, 18 Jul 2023 17:40:17 +0800
Xianting Tian  wrote:

> 在 2023/7/18 下午5:37, Petr Tesařík 写道:
> > On Mon, 27 Mar 2023 16:27:56 +0800
> > Guo Ren  wrote:
> >  
> >> F.Y.I
> >>
> >> xianting_...@126.com
> >>
> >> On Mon, Mar 27, 2023 at 9:52 AM Baoquan He  wrote:  
> >>> Hi Xianting,
> >>>
> >>> On 10/26/22 at 10:59am, Xianting Tian wrote:  
> >>>> 在 2022/10/26 上午10:13, Xianting Tian 写道:  
> >>>>> Hi Simon
> >>>>>
> >>>>> thanks for the comments
> >>>>>
> >>>>> 在 2022/10/21 下午11:27, Simon Horman 写道:  
> >>>>>> On Thu, Oct 20, 2022 at 11:15:48AM +0800, Xianting Tian wrote:  
> >>>>>>> From: Nick Kossifidis 
> >>>>>>>
> >>>>>>> This patch adds support for loading the ELF kernel image. It parses
> >>>>>>> the current/provided device tree to determine the system's memory
> >>>>>>> layout, and /proc/iomem for the various kernel segments.
> >>>>>>>
> >>>>>>> This patch was firstly developed by Nick Kossifidis, and two fixes (
> >>>>>>>  1: fail to find free memory area for dtb load when using
> >>>>>>> initrd image,
> >>>>>>> lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
> >>>>>>>  2: fix memory range size calculation,
> >>>>>>>  kexec/arch/riscv/crashdump-riscv.c:line 85
> >>>>>>> ) are contributed by Yixun Lan, Xianting Tian.
> >>>>>>>
> >>>>>>> Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V
> >>>>>>> Xuantie 910 CPU.  
> >>>>>> Hi,
> >>>>>>
> >>>>>> thanks for some patch.
> >>>>>>
> >>>>>> Some minor feedback follows.
> >>>>>>
> >>>>>> Separately, I'll post a patch to add RISC-V builds to the github
> >>>>>> workflow. If you could include that in V3 I'd be most grateful.
> >>>>>> 
> >>>>>>> Tested-by: Yixun Lan 
> >>>>>>> Co-developed-by: Xianting Tian 
> >>>>>>> Co-developed-by: Yixun Lan 
> >>>>>>> Signed-off-by: Nick Kossifidis   
> >>>>>> ...
> >>>>>> 
> >>>>>>> +ret = mem_regions_alloc_and_add(mem_ranges, start,
> >>>>>>> +end - start, type);  
> >>>>>> mem_regions_alloc_and_add isn't always available.
> >>>>>> f.e. on mips this causes a build failure.
> >>>>>>
> >>>>>> Ref: 
> >>>>>> https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595
> >>>>>>   
> >>>>> As you know, mem_regions_sort, mem_regions_alloc_and_add are the common
> >>>>> funtions,
> >>>>>
> >>>>> The build error of mips is caused by this riscv patch?
> >>>>>
> >>>>> kexec/mem_regions.c:void mem_regions_sort(struct memory_ranges *ranges)
> >>>>> kexec/mem_regions.h:void mem_regions_sort(struct memory_ranges *ranges);
> >>>>>
> >>>>>
> >>>>> kexec/mem_regions.c:int mem_regions_alloc_and_add(struct memory_ranges
> >>>>> *ranges,
> >>>>> kexec/mem_regions.h:int mem_regions_alloc_and_add(struct memory_ranges
> >>>>> *ranges,
> >>>>> 
> >>>>>> ...
> >>>>>> 
> >>>>>>> +int dtb_get_memory_ranges(char *dtb, struct memory_ranges
> >>>>>>> *mem_ranges, struct memory_ranges *extra_ranges)
> >>>>>>> +{  
> >>>>>> ...
> >>>>>> 
> >>>>>>> +mem_regions_sort(mem_ranges);  
> >>>>>> Likewise, mem_regions_sort isn't always available.
> >>>>>> f.e. on mips this causes a build failure.
> >>>>>>
> >>>>>> ...
> >>>>>> 
> >>>>>>> diff --git a/purgatory/arch/riscv/Makefile
> >>>>>>> b/purgatory/arch/riscv/Makefile
> >>>>>>> new file mode 100644
> >>>>>>> index 000..8bded71
> >>>>>>> --- /dev/null
> >>>>>>> +++ b/purgatory/arch/riscv/Makefile
> >>>>>>> @@ -0,0 +1,7 @@
> >>>>>>> +#
> >>>>>>> +# Purgatory riscv
> >>>>>>> +#
> >>>>>>> +
> >>>>>>> +riscv_PURGATORY_SRCS =
> >>>>>>> +
> >>>>>>> +dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)  
> >>>>>> s/sh/riscv/
> >>>>>>
> >>>>>> Else the distribution tarball won't include this Makefile
> >>>>>>
> >>>>>> You can exercise this using:
> >>>>>> make distcheck 
> >>>>>> DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"  
> >>>>> thanks, I will fix this.  
> >>>> the fix is in my personal gitee
> >>>>
> >>>> https://gitee.com/xianting-tian/kexec-tools/commits/master  
> >>> Is this patchset reposting still in your working plan? I don't see the
> >>> code in kexe-tools, so ping to ask.
> >>>
> >>> If this is not your work tasks any more, people interested can pick this
> >>> patchset and post after polishing.  
> > Now it seems I am interested. FYI my plan is to start working on this
> > if there is no further reaction from anybody else within a fortnight.  
> Good, please feel free to do it.

Oh, thank you for your quick answer!

Good. Cloned from Gitee, rebasing, testing...

Petr T

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH V2] RISC-V: Add support for riscv kexec/kdump on kexec-tools

2023-07-18 Thread Xianting Tian


在 2023/7/18 下午5:37, Petr Tesařík 写道:

On Mon, 27 Mar 2023 16:27:56 +0800
Guo Ren  wrote:


F.Y.I

xianting_...@126.com

On Mon, Mar 27, 2023 at 9:52 AM Baoquan He  wrote:

Hi Xianting,

On 10/26/22 at 10:59am, Xianting Tian wrote:

在 2022/10/26 上午10:13, Xianting Tian 写道:

Hi Simon

thanks for the comments

在 2022/10/21 下午11:27, Simon Horman 写道:

On Thu, Oct 20, 2022 at 11:15:48AM +0800, Xianting Tian wrote:

From: Nick Kossifidis 

This patch adds support for loading the ELF kernel image. It parses
the current/provided device tree to determine the system's memory
layout, and /proc/iomem for the various kernel segments.

This patch was firstly developed by Nick Kossifidis, and two fixes (
 1: fail to find free memory area for dtb load when using
initrd image,
lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
 2: fix memory range size calculation,
 kexec/arch/riscv/crashdump-riscv.c:line 85
) are contributed by Yixun Lan, Xianting Tian.

Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V
Xuantie 910 CPU.

Hi,

thanks for some patch.

Some minor feedback follows.

Separately, I'll post a patch to add RISC-V builds to the github
workflow. If you could include that in V3 I'd be most grateful.
  

Tested-by: Yixun Lan 
Co-developed-by: Xianting Tian 
Co-developed-by: Yixun Lan 
Signed-off-by: Nick Kossifidis 

...
  

+ret = mem_regions_alloc_and_add(mem_ranges, start,
+end - start, type);

mem_regions_alloc_and_add isn't always available.
f.e. on mips this causes a build failure.

Ref: 
https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595

As you know, mem_regions_sort, mem_regions_alloc_and_add are the common
funtions,

The build error of mips is caused by this riscv patch?

kexec/mem_regions.c:void mem_regions_sort(struct memory_ranges *ranges)
kexec/mem_regions.h:void mem_regions_sort(struct memory_ranges *ranges);


kexec/mem_regions.c:int mem_regions_alloc_and_add(struct memory_ranges
*ranges,
kexec/mem_regions.h:int mem_regions_alloc_and_add(struct memory_ranges
*ranges,
  

...
  

+int dtb_get_memory_ranges(char *dtb, struct memory_ranges
*mem_ranges, struct memory_ranges *extra_ranges)
+{

...
  

+mem_regions_sort(mem_ranges);

Likewise, mem_regions_sort isn't always available.
f.e. on mips this causes a build failure.

...
  

diff --git a/purgatory/arch/riscv/Makefile
b/purgatory/arch/riscv/Makefile
new file mode 100644
index 000..8bded71
--- /dev/null
+++ b/purgatory/arch/riscv/Makefile
@@ -0,0 +1,7 @@
+#
+# Purgatory riscv
+#
+
+riscv_PURGATORY_SRCS =
+
+dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)

s/sh/riscv/

Else the distribution tarball won't include this Makefile

You can exercise this using:
make distcheck DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"

thanks, I will fix this.

the fix is in my personal gitee

https://gitee.com/xianting-tian/kexec-tools/commits/master

Is this patchset reposting still in your working plan? I don't see the
code in kexe-tools, so ping to ask.

If this is not your work tasks any more, people interested can pick this
patchset and post after polishing.

Now it seems I am interested. FYI my plan is to start working on this
if there is no further reaction from anybody else within a fortnight.

Good, please feel free to do it.


Petr T


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH V2] RISC-V: Add support for riscv kexec/kdump on kexec-tools

2023-07-18 Thread Petr Tesařík
On Mon, 27 Mar 2023 16:27:56 +0800
Guo Ren  wrote:

> F.Y.I
> 
> xianting_...@126.com
> 
> On Mon, Mar 27, 2023 at 9:52 AM Baoquan He  wrote:
> >
> > Hi Xianting,
> >
> > On 10/26/22 at 10:59am, Xianting Tian wrote:  
> > >
> > > 在 2022/10/26 上午10:13, Xianting Tian 写道:  
> > > > Hi Simon
> > > >
> > > > thanks for the comments
> > > >
> > > > 在 2022/10/21 下午11:27, Simon Horman 写道:  
> > > > > On Thu, Oct 20, 2022 at 11:15:48AM +0800, Xianting Tian wrote:  
> > > > > > From: Nick Kossifidis 
> > > > > >
> > > > > > This patch adds support for loading the ELF kernel image. It parses
> > > > > > the current/provided device tree to determine the system's memory
> > > > > > layout, and /proc/iomem for the various kernel segments.
> > > > > >
> > > > > > This patch was firstly developed by Nick Kossifidis, and two fixes (
> > > > > > 1: fail to find free memory area for dtb load when using
> > > > > > initrd image,
> > > > > > lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
> > > > > > 2: fix memory range size calculation,
> > > > > > kexec/arch/riscv/crashdump-riscv.c:line 85
> > > > > > ) are contributed by Yixun Lan, Xianting Tian.
> > > > > >
> > > > > > Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V
> > > > > > Xuantie 910 CPU.  
> > > > > Hi,
> > > > >
> > > > > thanks for some patch.
> > > > >
> > > > > Some minor feedback follows.
> > > > >
> > > > > Separately, I'll post a patch to add RISC-V builds to the github
> > > > > workflow. If you could include that in V3 I'd be most grateful.
> > > > >  
> > > > > > Tested-by: Yixun Lan 
> > > > > > Co-developed-by: Xianting Tian 
> > > > > > Co-developed-by: Yixun Lan 
> > > > > > Signed-off-by: Nick Kossifidis   
> > > > > ...
> > > > >  
> > > > > > +ret = mem_regions_alloc_and_add(mem_ranges, start,
> > > > > > +end - start, type);  
> > > > > mem_regions_alloc_and_add isn't always available.
> > > > > f.e. on mips this causes a build failure.
> > > > >
> > > > > Ref: 
> > > > > https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595
> > > > >   
> > > >
> > > > As you know, mem_regions_sort, mem_regions_alloc_and_add are the common
> > > > funtions,
> > > >
> > > > The build error of mips is caused by this riscv patch?
> > > >
> > > > kexec/mem_regions.c:void mem_regions_sort(struct memory_ranges *ranges)
> > > > kexec/mem_regions.h:void mem_regions_sort(struct memory_ranges *ranges);
> > > >
> > > >
> > > > kexec/mem_regions.c:int mem_regions_alloc_and_add(struct memory_ranges
> > > > *ranges,
> > > > kexec/mem_regions.h:int mem_regions_alloc_and_add(struct memory_ranges
> > > > *ranges,
> > > >  
> > > > >
> > > > > ...
> > > > >  
> > > > > > +int dtb_get_memory_ranges(char *dtb, struct memory_ranges
> > > > > > *mem_ranges, struct memory_ranges *extra_ranges)
> > > > > > +{  
> > > > > ...
> > > > >  
> > > > > > +mem_regions_sort(mem_ranges);  
> > > > > Likewise, mem_regions_sort isn't always available.
> > > > > f.e. on mips this causes a build failure.
> > > > >
> > > > > ...
> > > > >  
> > > > > > diff --git a/purgatory/arch/riscv/Makefile
> > > > > > b/purgatory/arch/riscv/Makefile
> > > > > > new file mode 100644
> > > > > > index 000..8bded71
> > > > > > --- /dev/null
> > > > > > +++ b/purgatory/arch/riscv/Makefile
> > > > > > @@ -0,0 +1,7 @@
> > > > > > +#
> > > > > > +# Purgatory riscv
> > > > > > +#
> > > > > > +
> > > > > > +riscv_PURGATORY_SRCS =
> > > > > > +
> > > > > > +dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)  
> > > > > s/sh/riscv/
> > > > >
> > > > > Else the distribution tarball won't include this Makefile
> > > > >
> > > > > You can exercise this using:
> > > > >make distcheck 
> > > > > DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"  
> > > > thanks, I will fix this.  
> > >
> > > the fix is in my personal gitee
> > >
> > > https://gitee.com/xianting-tian/kexec-tools/commits/master  
> >
> > Is this patchset reposting still in your working plan? I don't see the
> > code in kexe-tools, so ping to ask.
> >
> > If this is not your work tasks any more, people interested can pick this
> > patchset and post after polishing.

Now it seems I am interested. FYI my plan is to start working on this
if there is no further reaction from anybody else within a fortnight.

Petr T

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[RFC PATCH kexec-tools v3 1/1] kexec: Add and mark pmem region into PT_LOADs

2023-06-02 Thread Li Zhijian
It does:
1. Add pmem region into PT_LOADs of vmcore so that pmem region is
   dumpable
Only the region described by PT_LOADs of /proc/vmcore are dumpable/readble
by dumping applications. Previously, on x86/x86_64 only system ram resources
will be injected into PT_LOADs.
So in order to make the entire pmem resource is dumpable/readable, we need
to add pmem region into the PT_LOADs of /proc/vmcore.

2. Mark pmem region's p_flags as PF_DEV so that we are able to ignore
   the specific pages
For pmem, metadata is specific to the namespace rather than the entire
pmem region. Therefore, ranges that have not yet created a namespace or
are unusable due to alignment reasons will not be associated with metadata.

When an application attempts to access regions that do not have
corresponding metadata, it will encounter an access error. With this flag,
the dumping applications are able to know this access error, and then
take special actions correspondingly.

CC: Baoquan He 
CC: Vivek Goyal 
CC: Dave Young 
CC: kexec@lists.infradead.org
Signed-off-by: Li Zhijian 
---
 kexec/crashdump-elf.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kexec/crashdump-elf.c b/kexec/crashdump-elf.c
index b8bb686a17ca..ab257e825187 100644
--- a/kexec/crashdump-elf.c
+++ b/kexec/crashdump-elf.c
@@ -25,6 +25,8 @@ do {  
\
 } while(0)
 #endif
 
+#define PF_DEV (1 << 4)
+
 /* Prepares the crash memory headers and stores in supplied buffer. */
 int FUNC(struct kexec_info *info,
 struct crash_elf_info *elf_info,
@@ -199,7 +201,7 @@ int FUNC(struct kexec_info *info,
 * A seprate program header for Backup Region*/
for (i = 0; i < ranges; i++, range++) {
unsigned long long mstart, mend;
-   if (range->type != RANGE_RAM)
+   if (range->type != RANGE_RAM && range->type != RANGE_PMEM)
continue;
mstart = range->start;
mend = range->end;
@@ -209,6 +211,8 @@ int FUNC(struct kexec_info *info,
bufp += sizeof(PHDR);
phdr->p_type= PT_LOAD;
phdr->p_flags   = PF_R|PF_W|PF_X;
+   if (range->type == RANGE_PMEM)
+   phdr->p_flags |= PF_DEV;
phdr->p_offset  = mstart;
 
if (mstart == info->backup_src_start
-- 
2.29.2




[RFC PATCH v2 kexec-tools] kexec: Add and mark pmem region into PT_LOADs

2023-04-27 Thread Li Zhijian
It does:
1. Add pmem region into PT_LOADs of vmcore
2. Mark pmem region's p_flags as PF_DEV

CC: Baoquan He 
CC: Vivek Goyal 
CC: Dave Young 
Signed-off-by: Li Zhijian 
---
 kexec/crashdump-elf.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kexec/crashdump-elf.c b/kexec/crashdump-elf.c
index b8bb686a17ca..ab257e825187 100644
--- a/kexec/crashdump-elf.c
+++ b/kexec/crashdump-elf.c
@@ -25,6 +25,8 @@ do {  
\
 } while(0)
 #endif
 
+#define PF_DEV (1 << 4)
+
 /* Prepares the crash memory headers and stores in supplied buffer. */
 int FUNC(struct kexec_info *info,
 struct crash_elf_info *elf_info,
@@ -199,7 +201,7 @@ int FUNC(struct kexec_info *info,
 * A seprate program header for Backup Region*/
for (i = 0; i < ranges; i++, range++) {
unsigned long long mstart, mend;
-   if (range->type != RANGE_RAM)
+   if (range->type != RANGE_RAM && range->type != RANGE_PMEM)
continue;
mstart = range->start;
mend = range->end;
@@ -209,6 +211,8 @@ int FUNC(struct kexec_info *info,
bufp += sizeof(PHDR);
phdr->p_type= PT_LOAD;
phdr->p_flags   = PF_R|PF_W|PF_X;
+   if (range->type == RANGE_PMEM)
+   phdr->p_flags |= PF_DEV;
phdr->p_offset  = mstart;
 
if (mstart == info->backup_src_start
-- 
2.29.2


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH V2] RISC-V: Add support for riscv kexec/kdump on kexec-tools

2023-03-27 Thread Guo Ren
F.Y.I

xianting_...@126.com

On Mon, Mar 27, 2023 at 9:52 AM Baoquan He  wrote:
>
> Hi Xianting,
>
> On 10/26/22 at 10:59am, Xianting Tian wrote:
> >
> > 在 2022/10/26 上午10:13, Xianting Tian 写道:
> > > Hi Simon
> > >
> > > thanks for the comments
> > >
> > > 在 2022/10/21 下午11:27, Simon Horman 写道:
> > > > On Thu, Oct 20, 2022 at 11:15:48AM +0800, Xianting Tian wrote:
> > > > > From: Nick Kossifidis 
> > > > >
> > > > > This patch adds support for loading the ELF kernel image. It parses
> > > > > the current/provided device tree to determine the system's memory
> > > > > layout, and /proc/iomem for the various kernel segments.
> > > > >
> > > > > This patch was firstly developed by Nick Kossifidis, and two fixes (
> > > > > 1: fail to find free memory area for dtb load when using
> > > > > initrd image,
> > > > > lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
> > > > > 2: fix memory range size calculation,
> > > > > kexec/arch/riscv/crashdump-riscv.c:line 85
> > > > > ) are contributed by Yixun Lan, Xianting Tian.
> > > > >
> > > > > Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V
> > > > > Xuantie 910 CPU.
> > > > Hi,
> > > >
> > > > thanks for some patch.
> > > >
> > > > Some minor feedback follows.
> > > >
> > > > Separately, I'll post a patch to add RISC-V builds to the github
> > > > workflow. If you could include that in V3 I'd be most grateful.
> > > >
> > > > > Tested-by: Yixun Lan 
> > > > > Co-developed-by: Xianting Tian 
> > > > > Co-developed-by: Yixun Lan 
> > > > > Signed-off-by: Nick Kossifidis 
> > > > ...
> > > >
> > > > > +ret = mem_regions_alloc_and_add(mem_ranges, start,
> > > > > +end - start, type);
> > > > mem_regions_alloc_and_add isn't always available.
> > > > f.e. on mips this causes a build failure.
> > > >
> > > > Ref: 
> > > > https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595
> > >
> > > As you know, mem_regions_sort, mem_regions_alloc_and_add are the common
> > > funtions,
> > >
> > > The build error of mips is caused by this riscv patch?
> > >
> > > kexec/mem_regions.c:void mem_regions_sort(struct memory_ranges *ranges)
> > > kexec/mem_regions.h:void mem_regions_sort(struct memory_ranges *ranges);
> > >
> > >
> > > kexec/mem_regions.c:int mem_regions_alloc_and_add(struct memory_ranges
> > > *ranges,
> > > kexec/mem_regions.h:int mem_regions_alloc_and_add(struct memory_ranges
> > > *ranges,
> > >
> > > >
> > > > ...
> > > >
> > > > > +int dtb_get_memory_ranges(char *dtb, struct memory_ranges
> > > > > *mem_ranges, struct memory_ranges *extra_ranges)
> > > > > +{
> > > > ...
> > > >
> > > > > +mem_regions_sort(mem_ranges);
> > > > Likewise, mem_regions_sort isn't always available.
> > > > f.e. on mips this causes a build failure.
> > > >
> > > > ...
> > > >
> > > > > diff --git a/purgatory/arch/riscv/Makefile
> > > > > b/purgatory/arch/riscv/Makefile
> > > > > new file mode 100644
> > > > > index 000..8bded71
> > > > > --- /dev/null
> > > > > +++ b/purgatory/arch/riscv/Makefile
> > > > > @@ -0,0 +1,7 @@
> > > > > +#
> > > > > +# Purgatory riscv
> > > > > +#
> > > > > +
> > > > > +riscv_PURGATORY_SRCS =
> > > > > +
> > > > > +dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)
> > > > s/sh/riscv/
> > > >
> > > > Else the distribution tarball won't include this Makefile
> > > >
> > > > You can exercise this using:
> > > >make distcheck DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"
> > > thanks, I will fix this.
> >
> > the fix is in my personal gitee
> >
> > https://gitee.com/xianting-tian/kexec-tools/commits/master
>
> Is this patchset reposting still in your working plan? I don't see the
> code in kexe-tools, so ping to ask.
>
> If this is not your work tasks any more, people interested can pick this
> patchset and post after polishing.
>
> Thanks
> Baoquan
>


-- 
Best Regards
 Guo Ren

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH V2] RISC-V: Add support for riscv kexec/kdump on kexec-tools

2023-03-26 Thread Baoquan He
Hi Xianting,

On 10/26/22 at 10:59am, Xianting Tian wrote:
> 
> 在 2022/10/26 上午10:13, Xianting Tian 写道:
> > Hi Simon
> > 
> > thanks for the comments
> > 
> > 在 2022/10/21 下午11:27, Simon Horman 写道:
> > > On Thu, Oct 20, 2022 at 11:15:48AM +0800, Xianting Tian wrote:
> > > > From: Nick Kossifidis 
> > > > 
> > > > This patch adds support for loading the ELF kernel image. It parses
> > > > the current/provided device tree to determine the system's memory
> > > > layout, and /proc/iomem for the various kernel segments.
> > > > 
> > > > This patch was firstly developed by Nick Kossifidis, and two fixes (
> > > >     1: fail to find free memory area for dtb load when using
> > > > initrd image,
> > > > lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
> > > >     2: fix memory range size calculation,
> > > >     kexec/arch/riscv/crashdump-riscv.c:line 85
> > > > ) are contributed by Yixun Lan, Xianting Tian.
> > > > 
> > > > Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V
> > > > Xuantie 910 CPU.
> > > Hi,
> > > 
> > > thanks for some patch.
> > > 
> > > Some minor feedback follows.
> > > 
> > > Separately, I'll post a patch to add RISC-V builds to the github
> > > workflow. If you could include that in V3 I'd be most grateful.
> > > 
> > > > Tested-by: Yixun Lan 
> > > > Co-developed-by: Xianting Tian 
> > > > Co-developed-by: Yixun Lan 
> > > > Signed-off-by: Nick Kossifidis 
> > > ...
> > > 
> > > > +    ret = mem_regions_alloc_and_add(mem_ranges, start,
> > > > +    end - start, type);
> > > mem_regions_alloc_and_add isn't always available.
> > > f.e. on mips this causes a build failure.
> > > 
> > > Ref: 
> > > https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595
> > 
> > As you know, mem_regions_sort, mem_regions_alloc_and_add are the common
> > funtions,
> > 
> > The build error of mips is caused by this riscv patch?
> > 
> > kexec/mem_regions.c:void mem_regions_sort(struct memory_ranges *ranges)
> > kexec/mem_regions.h:void mem_regions_sort(struct memory_ranges *ranges);
> > 
> > 
> > kexec/mem_regions.c:int mem_regions_alloc_and_add(struct memory_ranges
> > *ranges,
> > kexec/mem_regions.h:int mem_regions_alloc_and_add(struct memory_ranges
> > *ranges,
> > 
> > > 
> > > ...
> > > 
> > > > +int dtb_get_memory_ranges(char *dtb, struct memory_ranges
> > > > *mem_ranges, struct memory_ranges *extra_ranges)
> > > > +{
> > > ...
> > > 
> > > > +    mem_regions_sort(mem_ranges);
> > > Likewise, mem_regions_sort isn't always available.
> > > f.e. on mips this causes a build failure.
> > > 
> > > ...
> > > 
> > > > diff --git a/purgatory/arch/riscv/Makefile
> > > > b/purgatory/arch/riscv/Makefile
> > > > new file mode 100644
> > > > index 000..8bded71
> > > > --- /dev/null
> > > > +++ b/purgatory/arch/riscv/Makefile
> > > > @@ -0,0 +1,7 @@
> > > > +#
> > > > +# Purgatory riscv
> > > > +#
> > > > +
> > > > +riscv_PURGATORY_SRCS =
> > > > +
> > > > +dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)
> > > s/sh/riscv/
> > > 
> > > Else the distribution tarball won't include this Makefile
> > > 
> > > You can exercise this using:
> > >    make distcheck DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"
> > thanks, I will fix this.
> 
> the fix is in my personal gitee
> 
> https://gitee.com/xianting-tian/kexec-tools/commits/master

Is this patchset reposting still in your working plan? I don't see the
code in kexe-tools, so ping to ask.

If this is not your work tasks any more, people interested can pick this
patchset and post after polishing.

Thanks
Baoquan


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[ANNOUNCE] kexec-tools 2.0.26

2022-12-21 Thread Simon Horman
Hi all,

I am happy to announce the release of kexec-tools 2.0.26.

This is a feature release coinciding with the release of v6.1
of the Linux Kernel.

This release can be downloaded from kernel.org:

http://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.26.tar.xz
http://kernel.org/pub/linux/utils/kernel/kexec/

It is also tagged it in git:

git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git

Thanks to everyone who has contributed to kexec!

Commits since v2.0.25:

ae1bd3dde601 kexec-tools 2.0.26
ffb186b83420 kexec-tools 2.0.26-rc1
b9de05184816 m68k: pass rng seed via BI_RNG_SEED
b0381b817910 workflow: update to checkout@v3
834be38cc044 LoongArch: Remove redundant cmdline parameters when using 
--reuse-cmdline option
84138f41efd5 LoongArch: Add purgatory framework code
615b6757dcab LoongArch: PE format image loading support
1c8bf2dc0127 LoongArch: Add kexec/kdump support
dceb1d8926e6 config: Add LoongArch architecture support in config.guess and 
config.sub files
6b6187f546f0 ppc64: remove rma_top limit
bc38df5e8e24 kexec-tools 2.0.25.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[ANNOUNCE] kexec-tools 2.0.26-rc1

2022-12-07 Thread Simon Horman
Hi all,

I am happy to announce the release of kexec-tools 2.0.26-rc1.

This is an incremental feature pre-release.

So long as no serious problems arise I intend to release kexec-tools 2.0.26
in a weeks time. Testing of 2.0.26-rc1 would be greatly appreciated.

I do not have any outstanding changes for 2.0.26 at this time.
And I would like to only accept bug fixes at this time and take
features patches once 2.0.26 has been released.

The pre-release can be downloaded from kernel.org:


https://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.26-rc1.tar.xz
https://kernel.org/pub/linux/utils/kernel/kexec/

I have also tagged it in git:

https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git

Thanks to everyone who has contributed to kexec.


For reference the changes since v2.0.25 are:

ffb186b83420 kexec-tools 2.0.26-rc1
b9de05184816 m68k: pass rng seed via BI_RNG_SEED
b0381b817910 workflow: update to checkout@v3
834be38cc044 LoongArch: Remove redundant cmdline parameters when using 
--reuse-cmdline option
84138f41efd5 LoongArch: Add purgatory framework code
615b6757dcab LoongArch: PE format image loading support
1c8bf2dc0127 LoongArch: Add kexec/kdump support
dceb1d8926e6 config: Add LoongArch architecture support in config.guess and 
config.sub files
6b6187f546f0 ppc64: remove rma_top limit
bc38df5e8e24 kexec-tools 2.0.25.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[ANNOUNCE] kexec-tools v2.0.26 preparation

2022-11-30 Thread Simon Horman
Hi all,

I am planning to release kexec-tools v2.0.26 in the next two weeks
to roughly coincide with the release of the v6.1 kernel.

I would like to ask interested parties to send any patches they would like
included in v2.0.26 within one week so they can be considered for inclusion
in an rc release.

For reference the patches queued up since v2.0.25 are as follows.

Thanks to everyone who has contributed to kexec-tools!

b9de05184816 m68k: pass rng seed via BI_RNG_SEED
b0381b817910 workflow: update to checkout@v3
834be38cc044 LoongArch: Remove redundant cmdline parameters when using 
--reuse-cmdline option
84138f41efd5 LoongArch: Add purgatory framework code
615b6757dcab LoongArch: PE format image loading support
1c8bf2dc0127 LoongArch: Add kexec/kdump support
dceb1d8926e6 config: Add LoongArch architecture support in config.guess and 
config.sub files
6b6187f546f0 ppc64: remove rma_top limit
bc38df5e8e24 kexec-tools 2.0.25.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH kexec-tools v3] m68k: pass rng seed via BI_RNG_SEED

2022-11-18 Thread Simon Horman
On Mon, Nov 14, 2022 at 04:43:03PM +0100, Jason A. Donenfeld wrote:
> In order to pass fresh entropy to kexec'd kernels, use BI_RNG_SEED
> for passing a seed, with the same semantics that kexec-tools currently
> uses for i386's setup_data.
> 
> Link: https://git.kernel.org/torvalds/c/dc63a086daee92c63e3
> Signed-off-by: Jason A. Donenfeld 

Thanks Jason,

applied.

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH kexec-tools v3] m68k: pass rng seed via BI_RNG_SEED

2022-11-14 Thread Jason A. Donenfeld
In order to pass fresh entropy to kexec'd kernels, use BI_RNG_SEED
for passing a seed, with the same semantics that kexec-tools currently
uses for i386's setup_data.

Link: https://git.kernel.org/torvalds/c/dc63a086daee92c63e3
Signed-off-by: Jason A. Donenfeld 
---
 kexec/arch/m68k/bootinfo.c   | 23 +++
 kexec/arch/m68k/bootinfo.h   | 10 ++
 kexec/arch/m68k/kexec-elf-m68k.c |  1 +
 3 files changed, 34 insertions(+)

diff --git a/kexec/arch/m68k/bootinfo.c b/kexec/arch/m68k/bootinfo.c
index 18bf226..086a34b 100644
--- a/kexec/arch/m68k/bootinfo.c
+++ b/kexec/arch/m68k/bootinfo.c
@@ -2,6 +2,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "../../kexec.h"
 
@@ -152,6 +153,11 @@ void bootinfo_print(void)
printf("BI_COMMAND_LINE: %s\n", bi->string);
break;
 
+   case BI_RNG_SEED:
+   /* These are secret, so never print them to the console 
*/
+   printf("BI_RNG_SEED: 0x%08x bytes\n", 
be16_to_cpu(bi->rng_seed.len));
+   break;
+
default:
printf("BI tag 0x%04x size %u\n", tag, size);
break;
@@ -212,6 +218,23 @@ void bootinfo_set_ramdisk(unsigned long ramdisk_addr,
bi->mem_info.size = ramdisk_size;
 }
 
+void bootinfo_add_rng_seed(void)
+{
+   enum { RNG_SEED_LEN = 32 };
+   struct bi_rec *bi;
+
+   /* Remove existing rng seed records */
+   bi_remove(BI_RNG_SEED);
+
+   /* Add new rng seed record */
+   bi = bi_add(BI_RNG_SEED, sizeof(bi->rng_seed) + RNG_SEED_LEN);
+   if (getrandom(bi->rng_seed.data, RNG_SEED_LEN, GRND_NONBLOCK) != 
RNG_SEED_LEN) {
+   bi_remove(BI_RNG_SEED);
+   return;
+   }
+   bi->rng_seed.len = cpu_to_be16(RNG_SEED_LEN);
+}
+
 
 /*
  * Check the bootinfo version in the kernel image
diff --git a/kexec/arch/m68k/bootinfo.h b/kexec/arch/m68k/bootinfo.h
index b6f453d..bb8a03a 100644
--- a/kexec/arch/m68k/bootinfo.h
+++ b/kexec/arch/m68k/bootinfo.h
@@ -3,6 +3,11 @@
 #define DEFAULT_BOOTINFO_FILE  "/proc/bootinfo"
 #define MAX_BOOTINFO_SIZE  1536
 
+/* New in 6.2's . Remove once 6.2 is baseline version. */
+#ifndef BI_RNG_SEED
+#define BI_RNG_SEED 0x0008
+#endif
+
 
 /*
  *  Convenience overlay of several struct bi_record variants
@@ -20,6 +25,10 @@ struct bi_rec {
__be32 size;
} mem_info;
char string[0];
+   struct {
+   __be16 len;
+   __u8 data[0];
+   } rng_seed;
};
 };
 
@@ -39,5 +48,6 @@ extern int bootinfo_get_memory_ranges(struct memory_range 
**range);
 extern void bootinfo_set_cmdline(const char *cmdline);
 extern void bootinfo_set_ramdisk(unsigned long ramdisk_addr,
 unsigned long ramdisk_size);
+extern void bootinfo_add_rng_seed(void);
 extern void bootinfo_check_bootversion(const struct kexec_info *info);
 extern void add_bootinfo(struct kexec_info *info, unsigned long addr);
diff --git a/kexec/arch/m68k/kexec-elf-m68k.c b/kexec/arch/m68k/kexec-elf-m68k.c
index 8d00eb9..a2bf7ee 100644
--- a/kexec/arch/m68k/kexec-elf-m68k.c
+++ b/kexec/arch/m68k/kexec-elf-m68k.c
@@ -162,6 +162,7 @@ int elf_m68k_load(int argc, char **argv, const char *buf, 
off_t len,
/* Update and add bootinfo */
bootinfo_set_cmdline(cmdline);
bootinfo_set_ramdisk(ramdisk_addr, ramdisk_size);
+   bootinfo_add_rng_seed();
if (kexec_debug)
bootinfo_print();
add_bootinfo(info, bootinfo_addr);
-- 
2.38.1


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH v2 RESEND kexec-tools] m68k: pass rng seed via BI_RNG_SEED

2022-11-14 Thread Jason A. Donenfeld
Hi Simon,

Sorry about that. Not sure why my toolchain missed it. v3 coming up.

Jason

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH v2 RESEND kexec-tools] m68k: pass rng seed via BI_RNG_SEED

2022-11-14 Thread Simon Horman
On Fri, Nov 11, 2022 at 02:35:33AM +0100, Jason A. Donenfeld wrote:
> In order to pass fresh entropy to kexec'd kernels, use BI_RNG_SEED
> for passing a seed, with the same semantics that kexec-tools currently
> uses for i386's setup_data.
> 
> Link: https://git.kernel.org/torvalds/c/dc63a086daee92c63e3
> Signed-off-by: Jason A. Donenfeld 
> ---
> Seems like this was forgotten about, so resending.

Hi Jason,

Sorry about missing this earlier.

I was planning to apply it just now, but it seems that
the github workflow flagged a problem:

In file included from ../../kexec/arch/m68k/kexec-m68k.c:19:
../../kexec/arch/m68k/bootinfo.h:25:4: error: unknown type name ‘u8’
   25 |u8 data[0];
  |^~
make[1]: *** [Makefile:124: kexec/arch/m68k/kexec-m68k.o] Error 1
make[1]: *** Waiting for unfinished jobs
In file included from ../../kexec/arch/m68k/kexec-elf-m68k.c:27:
../../kexec/arch/m68k/bootinfo.h:25:4: error: unknown type name ‘u8’
   25 |u8 data[0];
  |^~
make[1]: *** [Makefile:124: kexec/arch/m68k/kexec-elf-m68k.o] Error 1
make: *** [Makefile:276: distcheck] Error 2
make[1]: Leaving directory 
'/home/runner/work/kexec-tools/kexec-tools/kexec-tools-2.0.25.git/_build/sub'
Error: Process completed with exit code 2.

Ref: 
https://github.com/horms/kexec-tools/actions/runs/3462830642/jobs/5782238446

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH v2 RESEND kexec-tools] m68k: pass rng seed via BI_RNG_SEED

2022-11-10 Thread Jason A. Donenfeld
In order to pass fresh entropy to kexec'd kernels, use BI_RNG_SEED
for passing a seed, with the same semantics that kexec-tools currently
uses for i386's setup_data.

Link: https://git.kernel.org/torvalds/c/dc63a086daee92c63e3
Signed-off-by: Jason A. Donenfeld 
---
Seems like this was forgotten about, so resending.

 kexec/arch/m68k/bootinfo.c   | 23 +++
 kexec/arch/m68k/bootinfo.h   |  5 +
 kexec/arch/m68k/kexec-elf-m68k.c |  1 +
 3 files changed, 29 insertions(+)

diff --git a/kexec/arch/m68k/bootinfo.c b/kexec/arch/m68k/bootinfo.c
index 18bf226..086a34b 100644
--- a/kexec/arch/m68k/bootinfo.c
+++ b/kexec/arch/m68k/bootinfo.c
@@ -2,6 +2,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "../../kexec.h"
 
@@ -152,6 +153,11 @@ void bootinfo_print(void)
printf("BI_COMMAND_LINE: %s\n", bi->string);
break;
 
+   case BI_RNG_SEED:
+   /* These are secret, so never print them to the console 
*/
+   printf("BI_RNG_SEED: 0x%08x bytes\n", 
be16_to_cpu(bi->rng_seed.len));
+   break;
+
default:
printf("BI tag 0x%04x size %u\n", tag, size);
break;
@@ -212,6 +218,23 @@ void bootinfo_set_ramdisk(unsigned long ramdisk_addr,
bi->mem_info.size = ramdisk_size;
 }
 
+void bootinfo_add_rng_seed(void)
+{
+   enum { RNG_SEED_LEN = 32 };
+   struct bi_rec *bi;
+
+   /* Remove existing rng seed records */
+   bi_remove(BI_RNG_SEED);
+
+   /* Add new rng seed record */
+   bi = bi_add(BI_RNG_SEED, sizeof(bi->rng_seed) + RNG_SEED_LEN);
+   if (getrandom(bi->rng_seed.data, RNG_SEED_LEN, GRND_NONBLOCK) != 
RNG_SEED_LEN) {
+   bi_remove(BI_RNG_SEED);
+   return;
+   }
+   bi->rng_seed.len = cpu_to_be16(RNG_SEED_LEN);
+}
+
 
 /*
  * Check the bootinfo version in the kernel image
diff --git a/kexec/arch/m68k/bootinfo.h b/kexec/arch/m68k/bootinfo.h
index b6f453d..90f75ad 100644
--- a/kexec/arch/m68k/bootinfo.h
+++ b/kexec/arch/m68k/bootinfo.h
@@ -20,6 +20,10 @@ struct bi_rec {
__be32 size;
} mem_info;
char string[0];
+   struct {
+   __be16 len;
+   u8 data[0];
+   } rng_seed;
};
 };
 
@@ -39,5 +43,6 @@ extern int bootinfo_get_memory_ranges(struct memory_range 
**range);
 extern void bootinfo_set_cmdline(const char *cmdline);
 extern void bootinfo_set_ramdisk(unsigned long ramdisk_addr,
 unsigned long ramdisk_size);
+extern void bootinfo_add_rng_seed(void);
 extern void bootinfo_check_bootversion(const struct kexec_info *info);
 extern void add_bootinfo(struct kexec_info *info, unsigned long addr);
diff --git a/kexec/arch/m68k/kexec-elf-m68k.c b/kexec/arch/m68k/kexec-elf-m68k.c
index 8d00eb9..a2bf7ee 100644
--- a/kexec/arch/m68k/kexec-elf-m68k.c
+++ b/kexec/arch/m68k/kexec-elf-m68k.c
@@ -162,6 +162,7 @@ int elf_m68k_load(int argc, char **argv, const char *buf, 
off_t len,
/* Update and add bootinfo */
bootinfo_set_cmdline(cmdline);
bootinfo_set_ramdisk(ramdisk_addr, ramdisk_size);
+   bootinfo_add_rng_seed();
if (kexec_debug)
bootinfo_print();
add_bootinfo(info, bootinfo_addr);
-- 
2.38.1


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH V2] RISC-V: Add support for riscv kexec/kdump on kexec-tools

2022-10-28 Thread Simon Horman
On Wed, Oct 26, 2022 at 10:13:48AM +0800, Xianting Tian wrote:
> Hi Simon
> 
> thanks for the comments
> 
> 在 2022/10/21 下午11:27, Simon Horman 写道:
> > On Thu, Oct 20, 2022 at 11:15:48AM +0800, Xianting Tian wrote:
> > > From: Nick Kossifidis 
> > > 
> > > This patch adds support for loading the ELF kernel image. It parses
> > > the current/provided device tree to determine the system's memory
> > > layout, and /proc/iomem for the various kernel segments.
> > > 
> > > This patch was firstly developed by Nick Kossifidis, and two fixes (
> > > 1: fail to find free memory area for dtb load when using initrd image,
> > >lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
> > > 2: fix memory range size calculation,
> > > kexec/arch/riscv/crashdump-riscv.c:line 85
> > > ) are contributed by Yixun Lan, Xianting Tian.
> > > 
> > > Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 
> > > CPU.
> > Hi,
> > 
> > thanks for some patch.
> > 
> > Some minor feedback follows.
> > 
> > Separately, I'll post a patch to add RISC-V builds to the github
> > workflow. If you could include that in V3 I'd be most grateful.
> > 
> > > Tested-by: Yixun Lan 
> > > Co-developed-by: Xianting Tian 
> > > Co-developed-by: Yixun Lan 
> > > Signed-off-by: Nick Kossifidis 
> > ...
> > 
> > > + ret = mem_regions_alloc_and_add(mem_ranges, start,
> > > + end - start, type);
> > mem_regions_alloc_and_add isn't always available.
> > f.e. on mips this causes a build failure.
> > 
> > Ref: 
> > https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595
> 
> As you know, mem_regions_sort, mem_regions_alloc_and_add are the common
> funtions,
> 
> The build error of mips is caused by this riscv patch?

Yes, I think so.

The workflow passes on main: 
https://github.com/horms/kexec-tools/actions/runs/3344523519
But not with the riscv patch applied: 
https://github.com/horms/kexec-tools/tree/build-test-riscv-v2

> kexec/mem_regions.c:void mem_regions_sort(struct memory_ranges *ranges)
> kexec/mem_regions.h:void mem_regions_sort(struct memory_ranges *ranges);
> 
> 
> kexec/mem_regions.c:int mem_regions_alloc_and_add(struct memory_ranges
> *ranges,
> kexec/mem_regions.h:int mem_regions_alloc_and_add(struct memory_ranges
> *ranges,
> 
> > 
> > ...
> > 
> > > +int dtb_get_memory_ranges(char *dtb, struct memory_ranges *mem_ranges, 
> > > struct memory_ranges *extra_ranges)
> > > +{
> > ...
> > 
> > > + mem_regions_sort(mem_ranges);
> > Likewise, mem_regions_sort isn't always available.
> > f.e. on mips this causes a build failure.
> > 
> > ...
> > 
> > > diff --git a/purgatory/arch/riscv/Makefile b/purgatory/arch/riscv/Makefile
> > > new file mode 100644
> > > index 000..8bded71
> > > --- /dev/null
> > > +++ b/purgatory/arch/riscv/Makefile
> > > @@ -0,0 +1,7 @@
> > > +#
> > > +# Purgatory riscv
> > > +#
> > > +
> > > +riscv_PURGATORY_SRCS =
> > > +
> > > +dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)
> > s/sh/riscv/
> > 
> > Else the distribution tarball won't include this Makefile
> > 
> > You can exercise this using:
> >make distcheck DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"
> thanks, I will fix this.

Thanks.

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH V2] RISC-V: Add support for riscv kexec/kdump on kexec-tools

2022-10-25 Thread Xianting Tian


在 2022/10/26 上午10:13, Xianting Tian 写道:

Hi Simon

thanks for the comments

在 2022/10/21 下午11:27, Simon Horman 写道:

On Thu, Oct 20, 2022 at 11:15:48AM +0800, Xianting Tian wrote:

From: Nick Kossifidis 

This patch adds support for loading the ELF kernel image. It parses
the current/provided device tree to determine the system's memory
layout, and /proc/iomem for the various kernel segments.

This patch was firstly developed by Nick Kossifidis, and two fixes (
    1: fail to find free memory area for dtb load when using initrd 
image,

lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
    2: fix memory range size calculation,
    kexec/arch/riscv/crashdump-riscv.c:line 85
) are contributed by Yixun Lan, Xianting Tian.

Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 
910 CPU.

Hi,

thanks for some patch.

Some minor feedback follows.

Separately, I'll post a patch to add RISC-V builds to the github
workflow. If you could include that in V3 I'd be most grateful.


Tested-by: Yixun Lan 
Co-developed-by: Xianting Tian 
Co-developed-by: Yixun Lan 
Signed-off-by: Nick Kossifidis 

...


+    ret = mem_regions_alloc_and_add(mem_ranges, start,
+    end - start, type);

mem_regions_alloc_and_add isn't always available.
f.e. on mips this causes a build failure.

Ref: 
https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595


As you know, mem_regions_sort, mem_regions_alloc_and_add are the 
common funtions,


The build error of mips is caused by this riscv patch?

kexec/mem_regions.c:void mem_regions_sort(struct memory_ranges *ranges)
kexec/mem_regions.h:void mem_regions_sort(struct memory_ranges *ranges);


kexec/mem_regions.c:int mem_regions_alloc_and_add(struct memory_ranges 
*ranges,
kexec/mem_regions.h:int mem_regions_alloc_and_add(struct memory_ranges 
*ranges,




...

+int dtb_get_memory_ranges(char *dtb, struct memory_ranges 
*mem_ranges, struct memory_ranges *extra_ranges)

+{

...


+    mem_regions_sort(mem_ranges);

Likewise, mem_regions_sort isn't always available.
f.e. on mips this causes a build failure.

...

diff --git a/purgatory/arch/riscv/Makefile 
b/purgatory/arch/riscv/Makefile

new file mode 100644
index 000..8bded71
--- /dev/null
+++ b/purgatory/arch/riscv/Makefile
@@ -0,0 +1,7 @@
+#
+# Purgatory riscv
+#
+
+riscv_PURGATORY_SRCS =
+
+dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)

s/sh/riscv/

Else the distribution tarball won't include this Makefile

You can exercise this using:
   make distcheck DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"

thanks, I will fix this.


the fix is in my personal gitee

https://gitee.com/xianting-tian/kexec-tools/commits/master


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH V2] RISC-V: Add support for riscv kexec/kdump on kexec-tools

2022-10-25 Thread Xianting Tian

Hi Simon

thanks for the comments

在 2022/10/21 下午11:27, Simon Horman 写道:

On Thu, Oct 20, 2022 at 11:15:48AM +0800, Xianting Tian wrote:

From: Nick Kossifidis 

This patch adds support for loading the ELF kernel image. It parses
the current/provided device tree to determine the system's memory
layout, and /proc/iomem for the various kernel segments.

This patch was firstly developed by Nick Kossifidis, and two fixes (
1: fail to find free memory area for dtb load when using initrd image,
   lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
2: fix memory range size calculation,
kexec/arch/riscv/crashdump-riscv.c:line 85
) are contributed by Yixun Lan, Xianting Tian.

Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 CPU.

Hi,

thanks for some patch.

Some minor feedback follows.

Separately, I'll post a patch to add RISC-V builds to the github
workflow. If you could include that in V3 I'd be most grateful.


Tested-by: Yixun Lan 
Co-developed-by: Xianting Tian 
Co-developed-by: Yixun Lan 
Signed-off-by: Nick Kossifidis 

...


+   ret = mem_regions_alloc_and_add(mem_ranges, start,
+   end - start, type);

mem_regions_alloc_and_add isn't always available.
f.e. on mips this causes a build failure.

Ref: 
https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595


As you know, mem_regions_sort, mem_regions_alloc_and_add are the common 
funtions,


The build error of mips is caused by this riscv patch?

kexec/mem_regions.c:void mem_regions_sort(struct memory_ranges *ranges)
kexec/mem_regions.h:void mem_regions_sort(struct memory_ranges *ranges);


kexec/mem_regions.c:int mem_regions_alloc_and_add(struct memory_ranges 
*ranges,
kexec/mem_regions.h:int mem_regions_alloc_and_add(struct memory_ranges 
*ranges,




...


+int dtb_get_memory_ranges(char *dtb, struct memory_ranges *mem_ranges, struct 
memory_ranges *extra_ranges)
+{

...


+   mem_regions_sort(mem_ranges);

Likewise, mem_regions_sort isn't always available.
f.e. on mips this causes a build failure.

...


diff --git a/purgatory/arch/riscv/Makefile b/purgatory/arch/riscv/Makefile
new file mode 100644
index 000..8bded71
--- /dev/null
+++ b/purgatory/arch/riscv/Makefile
@@ -0,0 +1,7 @@
+#
+# Purgatory riscv
+#
+
+riscv_PURGATORY_SRCS =
+
+dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)

s/sh/riscv/

Else the distribution tarball won't include this Makefile

You can exercise this using:
   make distcheck DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"

thanks, I will fix this.

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH kexec-tools] github: add RISC-V to workflow

2022-10-21 Thread Simon Horman
Add RISC-V builds to workflow

Signed-off-by: Simon Horman 
---
 .github/workflows/build.yml | 3 +++
 1 file changed, 3 insertions(+)

 Hi Xianting Tian,

 Please consider including this a v3 patch-set
 to add RISC-V to kexec-tools.

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e554751e0017..2731282d9521 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -19,6 +19,8 @@ jobs:
 - powerpc
 - powerpc64
 - powerpc64le
+- riscv32
+- riscv64
 - sh4
 - s390x
 - x86_64-x32
@@ -42,6 +44,7 @@ jobs:
 case $ARCH in
   arm) GNU_ARCH="arm-linux-gnueabi" ;;
   arm64)   GNU_ARCH="aarch64-linux-gnu" ;;
+  riscv32) CROSS_COMPILER_PKG="gcc-riscv64-linux-gnu" ;;
   x86_64)  ;;
   x86_64-x32)  GNU_ARCH="x86_64-linux-gnux32"
CROSS_COMPILER_PKG="gcc-x86-64-linux-gnux32" ;;
-- 
2.30.2


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH V2] RISC-V: Add support for riscv kexec/kdump on kexec-tools

2022-10-21 Thread Simon Horman
On Thu, Oct 20, 2022 at 11:15:48AM +0800, Xianting Tian wrote:
> From: Nick Kossifidis 
> 
> This patch adds support for loading the ELF kernel image. It parses
> the current/provided device tree to determine the system's memory
> layout, and /proc/iomem for the various kernel segments.
> 
> This patch was firstly developed by Nick Kossifidis, and two fixes (
>1: fail to find free memory area for dtb load when using initrd image,
>   lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
>2: fix memory range size calculation,
>kexec/arch/riscv/crashdump-riscv.c:line 85
> ) are contributed by Yixun Lan, Xianting Tian.
> 
> Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 CPU.

Hi,

thanks for some patch.

Some minor feedback follows.

Separately, I'll post a patch to add RISC-V builds to the github
workflow. If you could include that in V3 I'd be most grateful.

> 
> Tested-by: Yixun Lan 
> Co-developed-by: Xianting Tian 
> Co-developed-by: Yixun Lan 
> Signed-off-by: Nick Kossifidis 

...

> + ret = mem_regions_alloc_and_add(mem_ranges, start,
> + end - start, type);

mem_regions_alloc_and_add isn't always available.
f.e. on mips this causes a build failure.

Ref: 
https://github.com/horms/kexec-tools/actions/runs/3298491143/jobs/5440677595

...

> +int dtb_get_memory_ranges(char *dtb, struct memory_ranges *mem_ranges, 
> struct memory_ranges *extra_ranges)
> +{

...

> + mem_regions_sort(mem_ranges);

Likewise, mem_regions_sort isn't always available.
f.e. on mips this causes a build failure.

...

> diff --git a/purgatory/arch/riscv/Makefile b/purgatory/arch/riscv/Makefile
> new file mode 100644
> index 000..8bded71
> --- /dev/null
> +++ b/purgatory/arch/riscv/Makefile
> @@ -0,0 +1,7 @@
> +#
> +# Purgatory riscv
> +#
> +
> +riscv_PURGATORY_SRCS =
> +
> +dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS)

s/sh/riscv/

Else the distribution tarball won't include this Makefile

You can exercise this using:
  make distcheck DISTCHECK_CONFIGURE_FLAGS="--host=riscv64-linux-gnu"

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH V2] RISC-V: Add support for riscv kexec/kdump on kexec-tools

2022-10-21 Thread Xianting Tian
From: Nick Kossifidis 

This patch adds support for loading the ELF kernel image. It parses
the current/provided device tree to determine the system's memory
layout, and /proc/iomem for the various kernel segments.

This patch was firstly developed by Nick Kossifidis, and two fixes (
   1: fail to find free memory area for dtb load when using initrd image,
  lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
   2: fix memory range size calculation,
   kexec/arch/riscv/crashdump-riscv.c:line 85
) are contributed by Yixun Lan, Xianting Tian.

Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 CPU.

Tested-by: Yixun Lan 
Co-developed-by: Xianting Tian 
Co-developed-by: Yixun Lan 
Signed-off-by: Nick Kossifidis 
---
Changes
  V1 -> V2:
  1, Rebase the patch to latest kexec code.
  2, Set patch author Nick Kossifidis.

 configure.ac|   3 +
 include/elf.h   |   1 +
 kexec/Makefile  |   1 +
 kexec/arch/riscv/Makefile   |  35 ++
 kexec/arch/riscv/crashdump-riscv.c  | 140 
 kexec/arch/riscv/include/arch/options.h |  43 +++
 kexec/arch/riscv/kexec-elf-riscv.c  | 255 ++
 kexec/arch/riscv/kexec-riscv.c  | 365 +++
 kexec/arch/riscv/kexec-riscv.h  |  32 ++
 kexec/dt-ops.c  | 442 +++-
 kexec/dt-ops.h  |   7 +
 kexec/kexec-syscall.h   |   4 +
 purgatory/Makefile  |   1 +
 purgatory/arch/riscv/Makefile   |   7 +
 14 files changed, 1335 insertions(+), 1 deletion(-)
 create mode 100644 kexec/arch/riscv/Makefile
 create mode 100644 kexec/arch/riscv/crashdump-riscv.c
 create mode 100644 kexec/arch/riscv/include/arch/options.h
 create mode 100644 kexec/arch/riscv/kexec-elf-riscv.c
 create mode 100644 kexec/arch/riscv/kexec-riscv.c
 create mode 100644 kexec/arch/riscv/kexec-riscv.h
 create mode 100644 purgatory/arch/riscv/Makefile

diff --git a/configure.ac b/configure.ac
index d081c82..9204c37 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,6 +61,9 @@ case $target_cpu in
loongarch*)
ARCH="loongarch"
;;
+   riscv32|riscv64)
+   ARCH="riscv"
+   ;;
* )
AC_MSG_ERROR([unsupported architecture $target_cpu])
;;
diff --git a/include/elf.h b/include/elf.h
index 1c8d2cc..93a5ee5 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -259,6 +259,7 @@ typedef struct
 #define EM_ARC_A5  93  /* ARC Cores Tangent-A5 */
 #define EM_XTENSA  94  /* Tensilica Xtensa Architecture */
 #define EM_AARCH64 183 /* ARM AARCH64 */
+#define EM_RISCV   243 /* RISC-V */
 #define EM_LOONGARCH   258 /* Loongson Loongarch*/
 #define EM_NUM 184
 
diff --git a/kexec/Makefile b/kexec/Makefile
index 8a52e8d..405864a 100644
--- a/kexec/Makefile
+++ b/kexec/Makefile
@@ -88,6 +88,7 @@ include $(srcdir)/kexec/arch/mips/Makefile
 include $(srcdir)/kexec/arch/cris/Makefile
 include $(srcdir)/kexec/arch/ppc/Makefile
 include $(srcdir)/kexec/arch/ppc64/Makefile
+include $(srcdir)/kexec/arch/riscv/Makefile
 include $(srcdir)/kexec/arch/s390/Makefile
 include $(srcdir)/kexec/arch/sh/Makefile
 include $(srcdir)/kexec/arch/x86_64/Makefile
diff --git a/kexec/arch/riscv/Makefile b/kexec/arch/riscv/Makefile
new file mode 100644
index 000..f26cc90
--- /dev/null
+++ b/kexec/arch/riscv/Makefile
@@ -0,0 +1,35 @@
+#
+# kexec riscv
+#
+riscv_KEXEC_SRCS =  kexec/arch/riscv/kexec-riscv.c
+riscv_KEXEC_SRCS += kexec/arch/riscv/kexec-elf-riscv.c
+riscv_KEXEC_SRCS += kexec/arch/riscv/crashdump-riscv.c
+
+riscv_MEM_REGIONS = kexec/mem_regions.c
+
+riscv_DT_OPS += kexec/dt-ops.c
+
+riscv_ARCH_REUSE_INITRD =
+
+riscv_CPPFLAGS += -I $(srcdir)/kexec/
+
+dist += kexec/arch/riscv/Makefile $(riscv_KEXEC_SRCS)  \
+   kexec/arch/riscv/kexec-riscv.h  \
+   kexec/arch/riscv/include/arch/options.h
+
+ifdef HAVE_LIBFDT
+
+LIBS += -lfdt
+
+else
+
+include $(srcdir)/kexec/libfdt/Makefile.libfdt
+
+libfdt_SRCS += $(LIBFDT_SRCS:%=kexec/libfdt/%)
+
+riscv_CPPFLAGS += -I$(srcdir)/kexec/libfdt
+
+riscv_KEXEC_SRCS += $(libfdt_SRCS)
+
+endif
+
diff --git a/kexec/arch/riscv/crashdump-riscv.c 
b/kexec/arch/riscv/crashdump-riscv.c
new file mode 100644
index 000..3ed4fe3
--- /dev/null
+++ b/kexec/arch/riscv/crashdump-riscv.c
@@ -0,0 +1,140 @@
+#include 
+#include 
+#include 
+
+#include "kexec.h"
+#include "crashdump.h"
+#include "kexec-elf.h"
+#include "mem_regions.h"
+
+static struct crash_elf_info elf_info = {
+#if __riscv_xlen == 64
+   .class  = ELFCLASS64,
+#else
+   .class  = ELFCLASS32,
+#endif
+   .data   = ELFDATA2LSB,
+   .machine= EM_RISCV,
+};
+
+static struct memory_ranges crash_mem_ranges = {0};
+struct m

Re: [PATCH kexec-tools] m68k: pass rng seed via BI_VIRT_RNG_SEED

2022-09-23 Thread Jason A. Donenfeld
Hi Geert,

On Fri, Sep 23, 2022 at 3:07 PM Geert Uytterhoeven  wrote:
> This won't work as expected: BI_VIRT_* tags are only valid if the
> machine type is MACH_VIRT.
> Worse, this will trigger for other platform-specific tags using the same 
> value:
> Likewise, this will destroy existing BI_AMIGA_CHIPSET and BI_MAC_SCCBASE
> tags, breaking Amiga and Mac.
> As random seeds can now be generic, I think it makes sense to introduce
> a machine-independent BI_RND_SEED.
> In hindsight, we should have done this from the beginning...

Yes, I agree. I thought that would be rejected, though, which is why I
didn't do that before. I'll send a patch switching over to that.
There's no point in keeping the old one around, I don't think, so I'll
just move everything over to the new.

Jason

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH kexec-tools] m68k: pass rng seed via BI_VIRT_RNG_SEED

2022-09-23 Thread Geert Uytterhoeven
Hi Jason,

On Fri, Sep 23, 2022 at 2:47 PM Jason A. Donenfeld  wrote:
> In order to pass fresh entropy to kexec'd kernels, use BI_VIRT_RNG_SEED
> for passing a seed, with the same semantics that kexec-tools currently
> uses for i386's setup_data.
>
> Cc: Geert Uytterhoeven 
> Signed-off-by: Jason A. Donenfeld 

Thanks for your patch!

> --- a/kexec/arch/m68k/bootinfo.c
> +++ b/kexec/arch/m68k/bootinfo.c
> @@ -135,40 +135,45 @@ void bootinfo_print(void)
> size = bi->size;
> switch (tag) {
> case BI_MACHTYPE:
> printf("BI_MACHTYPE: 0x%08x\n", bi->machtype);
> break;
>
> case BI_MEMCHUNK:
> printf("BI_MEMCHUNK: 0x%08x bytes at 0x%08x\n",
>bi->mem_info.size, bi->mem_info.addr);
> break;
>
> case BI_RAMDISK:
> printf("BI_RAMDISK: 0x%08x bytes at 0x%08x\n",
>bi->mem_info.size, bi->mem_info.addr);
> break;

Hmm, lots of context.

>
> case BI_COMMAND_LINE:
> printf("BI_COMMAND_LINE: %s\n", bi->string);
> break;
>
> +   case BI_VIRT_RNG_SEED:

This won't work as expected: BI_VIRT_* tags are only valid if the
machine type is MACH_VIRT.

Worse, this will trigger for other platform-specific tags using the same value:

arch/m68k/include/uapi/asm/bootinfo-amiga.h:#define
BI_AMIGA_CHIPSET0x8006  /* native chipset present (__be32) */
arch/m68k/include/uapi/asm/bootinfo-mac.h:#define BI_MAC_SCCBASE
 0x8006  /* Mac SCC base address */
arch/m68k/include/uapi/asm/bootinfo-virt.h:#define
BI_VIRT_RNG_SEED 0x8006

> +   /* These are secret, so never print them to the 
> console */
> +   printf("BI_VIRT_RNG_SEED: 0x%08x bytes\n", 
> be16_to_cpu(bi->bytes.len));
> +   break;
> +
> default:
> printf("BI tag 0x%04x size %u\n", tag, size);
> break;
> }
> bi = bi_next(bi, size);
> }
>  }

>  }
>
> +void bootinfo_add_rng_seed(void)
> +{
> +   struct bi_rec *bi;
> +   enum { RNG_SEED_LEN = 32 };
> +
> +   /* Remove existing rng seed records */
> +   bi_remove(BI_VIRT_RNG_SEED);
> +
> +   /* Add new rng seed record */
> +   bi = bi_add(BI_VIRT_RNG_SEED, sizeof(bi->bytes) + RNG_SEED_LEN);

Likewise, this will destroy existing BI_AMIGA_CHIPSET and BI_MAC_SCCBASE
tags, breaking Amiga and Mac.

> +   if (getrandom(bi->bytes.data, RNG_SEED_LEN, GRND_NONBLOCK) != 
> RNG_SEED_LEN) {
> +   bi_remove(BI_VIRT_RNG_SEED);
> +   return;
> +   }
> +   bi->bytes.len = cpu_to_be16(RNG_SEED_LEN);
> +}
> +
>

As random seeds can now be generic, I think it makes sense to introduce
a machine-independent BI_RND_SEED.
In hindsight, we should have done this from the beginning...

> --- a/kexec/arch/m68k/bootinfo.h
> +++ b/kexec/arch/m68k/bootinfo.h
> @@ -1,43 +1,49 @@
>  #include 
> +#include 
>
>  #define DEFAULT_BOOTINFO_FILE  "/proc/bootinfo"
>  #define MAX_BOOTINFO_SIZE  1536
>
>
>  /*
>   *  Convenience overlay of several struct bi_record variants
>   */
>
>  struct bi_rec {
> __be16 tag;
> __be16 size;
> union {
> __be32 data[0];
> /* shorthands for the types we use */
> __be32 machtype;
> struct {
> __be32 addr;
> __be32 size;
> } mem_info;
> char string[0];
> +   struct {
> +   __be16 len;
> +   u8 data[0];
> +   } bytes;

I'd rather call this rng_seed, to avoid confusion between "data"
and "bytes",

> };
>  };

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH kexec-tools] m68k: pass rng seed via BI_VIRT_RNG_SEED

2022-09-23 Thread Jason A. Donenfeld
On Fri, Sep 23, 2022 at 2:47 PM Jason A. Donenfeld  wrote:
> Geert - I don't have a toolchain for testing this. Could you verify it
> works, if you have a chance? -Jason
>
>  kexec/arch/m68k/bootinfo.c   | 22 ++
>  kexec/arch/m68k/bootinfo.h   |  6 ++
>  kexec/arch/m68k/kexec-elf-m68k.c |  1 +
>  3 files changed, 29 insertions(+)
>
> diff --git a/kexec/arch/m68k/bootinfo.c b/kexec/arch/m68k/bootinfo.c
> index 18bf226..74e65a0 100644
> --- a/kexec/arch/m68k/bootinfo.c
> +++ b/kexec/arch/m68k/bootinfo.c

I forgot to add `#include ` I suspect.

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH kexec-tools] m68k: pass rng seed via BI_VIRT_RNG_SEED

2022-09-23 Thread Jason A. Donenfeld
In order to pass fresh entropy to kexec'd kernels, use BI_VIRT_RNG_SEED
for passing a seed, with the same semantics that kexec-tools currently
uses for i386's setup_data.

Cc: Geert Uytterhoeven 
Signed-off-by: Jason A. Donenfeld 
---
Geert - I don't have a toolchain for testing this. Could you verify it
works, if you have a chance? -Jason

 kexec/arch/m68k/bootinfo.c   | 22 ++
 kexec/arch/m68k/bootinfo.h   |  6 ++
 kexec/arch/m68k/kexec-elf-m68k.c |  1 +
 3 files changed, 29 insertions(+)

diff --git a/kexec/arch/m68k/bootinfo.c b/kexec/arch/m68k/bootinfo.c
index 18bf226..74e65a0 100644
--- a/kexec/arch/m68k/bootinfo.c
+++ b/kexec/arch/m68k/bootinfo.c
@@ -135,40 +135,45 @@ void bootinfo_print(void)
size = bi->size;
switch (tag) {
case BI_MACHTYPE:
printf("BI_MACHTYPE: 0x%08x\n", bi->machtype);
break;
 
case BI_MEMCHUNK:
printf("BI_MEMCHUNK: 0x%08x bytes at 0x%08x\n",
   bi->mem_info.size, bi->mem_info.addr);
break;
 
case BI_RAMDISK:
printf("BI_RAMDISK: 0x%08x bytes at 0x%08x\n",
   bi->mem_info.size, bi->mem_info.addr);
break;
 
case BI_COMMAND_LINE:
printf("BI_COMMAND_LINE: %s\n", bi->string);
break;
 
+   case BI_VIRT_RNG_SEED:
+   /* These are secret, so never print them to the console 
*/
+   printf("BI_VIRT_RNG_SEED: 0x%08x bytes\n", 
be16_to_cpu(bi->bytes.len));
+   break;
+
default:
printf("BI tag 0x%04x size %u\n", tag, size);
break;
}
bi = bi_next(bi, size);
}
 }
 
 int bootinfo_get_memory_ranges(struct memory_range **range)
 {
struct memory_range *ranges;
unsigned int i;
struct bi_rec *bi;
 
ranges = xmalloc(num_memchunks * sizeof(struct memory_range));
for (i = 0, bi = NULL;
 i < num_memchunks && (bi = bi_find(bi, BI_MEMCHUNK)); i++) {
ranges[i].start = bi->mem_info.addr;
ranges[i].end = bi->mem_info.addr + bi->mem_info.size - 1;
ranges[i].type = RANGE_RAM;
@@ -195,40 +200,57 @@ void bootinfo_set_cmdline(const char *cmdline)
memcpy(bi->string, cmdline, size);
 }
 
 void bootinfo_set_ramdisk(unsigned long ramdisk_addr,
  unsigned long ramdisk_size)
 {
struct bi_rec *bi;
 
/* Remove existing ramdisk records */
bi_remove(BI_RAMDISK);
 
if (!ramdisk_size)
return;
 
/* Add new ramdisk record */
bi = bi_add(BI_RAMDISK, sizeof(bi->mem_info));
bi->mem_info.addr = ramdisk_addr;
bi->mem_info.size = ramdisk_size;
 }
 
+void bootinfo_add_rng_seed(void)
+{
+   struct bi_rec *bi;
+   enum { RNG_SEED_LEN = 32 };
+
+   /* Remove existing rng seed records */
+   bi_remove(BI_VIRT_RNG_SEED);
+
+   /* Add new rng seed record */
+   bi = bi_add(BI_VIRT_RNG_SEED, sizeof(bi->bytes) + RNG_SEED_LEN);
+   if (getrandom(bi->bytes.data, RNG_SEED_LEN, GRND_NONBLOCK) != 
RNG_SEED_LEN) {
+   bi_remove(BI_VIRT_RNG_SEED);
+   return;
+   }
+   bi->bytes.len = cpu_to_be16(RNG_SEED_LEN);
+}
+
 
 /*
  * Check the bootinfo version in the kernel image
  * All failures are non-fatal, as kexec may be used to load
  * non-Linux images
  */
 
 void bootinfo_check_bootversion(const struct kexec_info *info)
 {
struct bi_rec *bi;
const struct bootversion *bv;
uint16_t major, minor;
unsigned int i;
 
bv = info->segment[0].buf;
if (bv->magic != BOOTINFOV_MAGIC) {
printf("WARNING: No bootversion in kernel image\n");
return;
}
 
diff --git a/kexec/arch/m68k/bootinfo.h b/kexec/arch/m68k/bootinfo.h
index b6f453d..6dff2ad 100644
--- a/kexec/arch/m68k/bootinfo.h
+++ b/kexec/arch/m68k/bootinfo.h
@@ -1,43 +1,49 @@
 #include 
+#include 
 
 #define DEFAULT_BOOTINFO_FILE  "/proc/bootinfo"
 #define MAX_BOOTINFO_SIZE  1536
 
 
 /*
  *  Convenience overlay of several struct bi_record variants
  */
 
 struct bi_rec {
__be16 tag;
__be16 size;
union {
__be32 data[0];
/* shorthands for the types we use */
__be32 machtype;
struct {
__be32 addr;
__be32 size;
} mem_info;
char string[0];
+  

Re: [PATCH] RISC-V: Add support for riscv kexec/kdump on kexec-tools

2022-09-19 Thread Xianting Tian

Sorry for the disturb, Could I get the comments for this patch?

thanks

在 2022/9/14 下午3:52, Xianting Tian 写道:

This patch adds support for loading the ELF kernel image. It parses
the current/provided device tree to determine the system's memory
layout, and /proc/iomem for the various kernel segments.

This patch was firstly developed by Nick Kossifidis, and two fixes (
1: fail to find free memory area for dtb load when using initrd image,
   lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
2: fix memory range size calculation,
kexec/arch/riscv/crashdump-riscv.c:line 85
) are contributed by Yixun Lan, Xianting Tian.

Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 CPU.

Tested-by: Yixun Lan 
Signed-off-by: Xianting Tian 
Signed-off-by: Yixun Lan 
Signed-off-by: Nick Kossifidis 
---
  configure.ac|   3 +
  include/elf.h   |   3 +-
  kexec/Makefile  |   1 +
  kexec/arch/riscv/Makefile   |  35 ++
  kexec/arch/riscv/crashdump-riscv.c  | 140 
  kexec/arch/riscv/include/arch/options.h |  43 +++
  kexec/arch/riscv/kexec-elf-riscv.c  | 255 ++
  kexec/arch/riscv/kexec-riscv.c  | 365 +++
  kexec/arch/riscv/kexec-riscv.h  |  32 ++
  kexec/dt-ops.c  | 442 +++-
  kexec/dt-ops.h  |   7 +
  kexec/kexec-syscall.h   |   4 +
  purgatory/Makefile  |   1 +
  purgatory/arch/riscv/Makefile   |   7 +
  14 files changed, 1336 insertions(+), 2 deletions(-)
  create mode 100644 kexec/arch/riscv/Makefile
  create mode 100644 kexec/arch/riscv/crashdump-riscv.c
  create mode 100644 kexec/arch/riscv/include/arch/options.h
  create mode 100644 kexec/arch/riscv/kexec-elf-riscv.c
  create mode 100644 kexec/arch/riscv/kexec-riscv.c
  create mode 100644 kexec/arch/riscv/kexec-riscv.h
  create mode 100644 purgatory/arch/riscv/Makefile

diff --git a/configure.ac b/configure.ac
index 0d825ef..7cc55b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,6 +58,9 @@ case $target_cpu in
hppa*)
ARCH="hppa"
;;
+   riscv32|riscv64 )
+   ARCH="riscv"
+   ;;
* )
AC_MSG_ERROR([unsupported architecture $target_cpu])
;;
diff --git a/include/elf.h b/include/elf.h
index b7677a2..123f167 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -259,7 +259,8 @@ typedef struct
  #define EM_ARC_A5 93  /* ARC Cores Tangent-A5 */
  #define EM_XTENSA 94  /* Tensilica Xtensa Architecture */
  #define EM_AARCH64183 /* ARM AARCH64 */
-#define EM_NUM 184
+#define EM_RISCV   243 /* RISC-V */
+#define EM_NUM 244
  
  /* If it is necessary to assign new unofficial EM_* values, please

 pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
diff --git a/kexec/Makefile b/kexec/Makefile
index e69e309..ca17831 100644
--- a/kexec/Makefile
+++ b/kexec/Makefile
@@ -88,6 +88,7 @@ include $(srcdir)/kexec/arch/mips/Makefile
  include $(srcdir)/kexec/arch/cris/Makefile
  include $(srcdir)/kexec/arch/ppc/Makefile
  include $(srcdir)/kexec/arch/ppc64/Makefile
+include $(srcdir)/kexec/arch/riscv/Makefile
  include $(srcdir)/kexec/arch/s390/Makefile
  include $(srcdir)/kexec/arch/sh/Makefile
  include $(srcdir)/kexec/arch/x86_64/Makefile
diff --git a/kexec/arch/riscv/Makefile b/kexec/arch/riscv/Makefile
new file mode 100644
index 000..f26cc90
--- /dev/null
+++ b/kexec/arch/riscv/Makefile
@@ -0,0 +1,35 @@
+#
+# kexec riscv
+#
+riscv_KEXEC_SRCS =  kexec/arch/riscv/kexec-riscv.c
+riscv_KEXEC_SRCS += kexec/arch/riscv/kexec-elf-riscv.c
+riscv_KEXEC_SRCS += kexec/arch/riscv/crashdump-riscv.c
+
+riscv_MEM_REGIONS = kexec/mem_regions.c
+
+riscv_DT_OPS += kexec/dt-ops.c
+
+riscv_ARCH_REUSE_INITRD =
+
+riscv_CPPFLAGS += -I $(srcdir)/kexec/
+
+dist += kexec/arch/riscv/Makefile $(riscv_KEXEC_SRCS)  \
+   kexec/arch/riscv/kexec-riscv.h  \
+   kexec/arch/riscv/include/arch/options.h
+
+ifdef HAVE_LIBFDT
+
+LIBS += -lfdt
+
+else
+
+include $(srcdir)/kexec/libfdt/Makefile.libfdt
+
+libfdt_SRCS += $(LIBFDT_SRCS:%=kexec/libfdt/%)
+
+riscv_CPPFLAGS += -I$(srcdir)/kexec/libfdt
+
+riscv_KEXEC_SRCS += $(libfdt_SRCS)
+
+endif
+
diff --git a/kexec/arch/riscv/crashdump-riscv.c 
b/kexec/arch/riscv/crashdump-riscv.c
new file mode 100644
index 000..3ed4fe3
--- /dev/null
+++ b/kexec/arch/riscv/crashdump-riscv.c
@@ -0,0 +1,140 @@
+#include 
+#include 
+#include 
+
+#include "kexec.h"
+#include "crashdump.h"
+#include "kexec-elf.h"
+#include "mem_regions.h"
+
+static struct crash_elf_info elf_info = {
+#if __riscv_xlen == 64
+   .class  = ELFCLASS64,
+#else
+   .class  = ELFCLASS32,
+#endif
+   .data   = ELFDAT

Re: [PATCH] RISC-V: Add support for riscv kexec/kdump on kexec-tools

2022-09-19 Thread Guo Ren
F.Y.I Nick Kossifidis

The first author should be him.

On Wed, Sep 14, 2022 at 3:52 PM Xianting Tian
 wrote:
>
> This patch adds support for loading the ELF kernel image. It parses
> the current/provided device tree to determine the system's memory
> layout, and /proc/iomem for the various kernel segments.
>
> This patch was firstly developed by Nick Kossifidis, and two fixes (
>1: fail to find free memory area for dtb load when using initrd image,
>   lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
>2: fix memory range size calculation,
>kexec/arch/riscv/crashdump-riscv.c:line 85
> ) are contributed by Yixun Lan, Xianting Tian.
>
> Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 CPU.
>
> Tested-by: Yixun Lan 
> Signed-off-by: Xianting Tian 
> Signed-off-by: Yixun Lan 
> Signed-off-by: Nick Kossifidis 
> ---
>  configure.ac|   3 +
>  include/elf.h   |   3 +-
>  kexec/Makefile  |   1 +
>  kexec/arch/riscv/Makefile   |  35 ++
>  kexec/arch/riscv/crashdump-riscv.c  | 140 
>  kexec/arch/riscv/include/arch/options.h |  43 +++
>  kexec/arch/riscv/kexec-elf-riscv.c  | 255 ++
>  kexec/arch/riscv/kexec-riscv.c  | 365 +++
>  kexec/arch/riscv/kexec-riscv.h  |  32 ++
>  kexec/dt-ops.c  | 442 +++-
>  kexec/dt-ops.h  |   7 +
>  kexec/kexec-syscall.h   |   4 +
>  purgatory/Makefile  |   1 +
>  purgatory/arch/riscv/Makefile   |   7 +
>  14 files changed, 1336 insertions(+), 2 deletions(-)
>  create mode 100644 kexec/arch/riscv/Makefile
>  create mode 100644 kexec/arch/riscv/crashdump-riscv.c
>  create mode 100644 kexec/arch/riscv/include/arch/options.h
>  create mode 100644 kexec/arch/riscv/kexec-elf-riscv.c
>  create mode 100644 kexec/arch/riscv/kexec-riscv.c
>  create mode 100644 kexec/arch/riscv/kexec-riscv.h
>  create mode 100644 purgatory/arch/riscv/Makefile
>
> diff --git a/configure.ac b/configure.ac
> index 0d825ef..7cc55b0 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -58,6 +58,9 @@ case $target_cpu in
> hppa*)
> ARCH="hppa"
> ;;
> +   riscv32|riscv64 )
> +   ARCH="riscv"
> +   ;;
> * )
> AC_MSG_ERROR([unsupported architecture $target_cpu])
> ;;
> diff --git a/include/elf.h b/include/elf.h
> index b7677a2..123f167 100644
> --- a/include/elf.h
> +++ b/include/elf.h
> @@ -259,7 +259,8 @@ typedef struct
>  #define EM_ARC_A5  93  /* ARC Cores Tangent-A5 */
>  #define EM_XTENSA  94  /* Tensilica Xtensa Architecture */
>  #define EM_AARCH64 183 /* ARM AARCH64 */
> -#define EM_NUM 184
> +#define EM_RISCV   243 /* RISC-V */
> +#define EM_NUM 244
>
>  /* If it is necessary to assign new unofficial EM_* values, please
> pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
> diff --git a/kexec/Makefile b/kexec/Makefile
> index e69e309..ca17831 100644
> --- a/kexec/Makefile
> +++ b/kexec/Makefile
> @@ -88,6 +88,7 @@ include $(srcdir)/kexec/arch/mips/Makefile
>  include $(srcdir)/kexec/arch/cris/Makefile
>  include $(srcdir)/kexec/arch/ppc/Makefile
>  include $(srcdir)/kexec/arch/ppc64/Makefile
> +include $(srcdir)/kexec/arch/riscv/Makefile
>  include $(srcdir)/kexec/arch/s390/Makefile
>  include $(srcdir)/kexec/arch/sh/Makefile
>  include $(srcdir)/kexec/arch/x86_64/Makefile
> diff --git a/kexec/arch/riscv/Makefile b/kexec/arch/riscv/Makefile
> new file mode 100644
> index 000..f26cc90
> --- /dev/null
> +++ b/kexec/arch/riscv/Makefile
> @@ -0,0 +1,35 @@
> +#
> +# kexec riscv
> +#
> +riscv_KEXEC_SRCS =  kexec/arch/riscv/kexec-riscv.c
> +riscv_KEXEC_SRCS += kexec/arch/riscv/kexec-elf-riscv.c
> +riscv_KEXEC_SRCS += kexec/arch/riscv/crashdump-riscv.c
> +
> +riscv_MEM_REGIONS = kexec/mem_regions.c
> +
> +riscv_DT_OPS += kexec/dt-ops.c
> +
> +riscv_ARCH_REUSE_INITRD =
> +
> +riscv_CPPFLAGS += -I $(srcdir)/kexec/
> +
> +dist += kexec/arch/riscv/Makefile $(riscv_KEXEC_SRCS)  \
> +   kexec/arch/riscv/kexec-riscv.h  \
> +   kexec/arch/riscv/include/arch/options.h
> +
> +ifdef HAVE_LIBFDT
> +
> +LIBS += -lfdt
> +
> +else
> +
> +include $(srcdir)/kexec/libfdt/Makefile.libfdt
> +
> +libfdt_SRCS += $(LIBFDT_SRCS:%=kexec/libfdt/%)
> +
> +riscv_CPPFLAGS += -I$(srcdir)/kexec/libfdt
> +
> +riscv_KEXEC_SRCS += $(libfdt_SRCS)
> +
> +endif
> +
> diff --git a/kexec/arch/riscv/crashdump-riscv.c 
> b/kexec/arch/riscv/crashdump-riscv.c
> new file mode 100644
> index 000..3ed4fe3
> --- /dev/null
> +++ b/kexec/arch/riscv/crashdump-riscv.c
> @@ -0,0 +1,140 @@
> +#include 
> +#include 
> +#include 
> +
> +#include "kexec.h"
> +#include "crashdump.h"
> +#include "ke

Re: [PATCH] RISC-V: Add support for riscv kexec/kdump on kexec-tools

2022-09-19 Thread Xianting Tian

sorry, I will send v2 patch to switch the author to NICK.

在 2022/9/19 下午3:57, Guo Ren 写道:

F.Y.I Nick Kossifidis

The first author should be him.

On Wed, Sep 14, 2022 at 3:52 PM Xianting Tian
 wrote:

This patch adds support for loading the ELF kernel image. It parses
the current/provided device tree to determine the system's memory
layout, and /proc/iomem for the various kernel segments.

This patch was firstly developed by Nick Kossifidis, and two fixes (
1: fail to find free memory area for dtb load when using initrd image,
   lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
2: fix memory range size calculation,
kexec/arch/riscv/crashdump-riscv.c:line 85
) are contributed by Yixun Lan, Xianting Tian.

Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 CPU.

Tested-by: Yixun Lan 
Signed-off-by: Xianting Tian 
Signed-off-by: Yixun Lan 
Signed-off-by: Nick Kossifidis 
---
  configure.ac|   3 +
  include/elf.h   |   3 +-
  kexec/Makefile  |   1 +
  kexec/arch/riscv/Makefile   |  35 ++
  kexec/arch/riscv/crashdump-riscv.c  | 140 
  kexec/arch/riscv/include/arch/options.h |  43 +++
  kexec/arch/riscv/kexec-elf-riscv.c  | 255 ++
  kexec/arch/riscv/kexec-riscv.c  | 365 +++
  kexec/arch/riscv/kexec-riscv.h  |  32 ++
  kexec/dt-ops.c  | 442 +++-
  kexec/dt-ops.h  |   7 +
  kexec/kexec-syscall.h   |   4 +
  purgatory/Makefile  |   1 +
  purgatory/arch/riscv/Makefile   |   7 +
  14 files changed, 1336 insertions(+), 2 deletions(-)
  create mode 100644 kexec/arch/riscv/Makefile
  create mode 100644 kexec/arch/riscv/crashdump-riscv.c
  create mode 100644 kexec/arch/riscv/include/arch/options.h
  create mode 100644 kexec/arch/riscv/kexec-elf-riscv.c
  create mode 100644 kexec/arch/riscv/kexec-riscv.c
  create mode 100644 kexec/arch/riscv/kexec-riscv.h
  create mode 100644 purgatory/arch/riscv/Makefile

diff --git a/configure.ac b/configure.ac
index 0d825ef..7cc55b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,6 +58,9 @@ case $target_cpu in
 hppa*)
 ARCH="hppa"
 ;;
+   riscv32|riscv64 )
+   ARCH="riscv"
+   ;;
 * )
 AC_MSG_ERROR([unsupported architecture $target_cpu])
 ;;
diff --git a/include/elf.h b/include/elf.h
index b7677a2..123f167 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -259,7 +259,8 @@ typedef struct
  #define EM_ARC_A5  93  /* ARC Cores Tangent-A5 */
  #define EM_XTENSA  94  /* Tensilica Xtensa Architecture */
  #define EM_AARCH64 183 /* ARM AARCH64 */
-#define EM_NUM 184
+#define EM_RISCV   243 /* RISC-V */
+#define EM_NUM 244

  /* If it is necessary to assign new unofficial EM_* values, please
 pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
diff --git a/kexec/Makefile b/kexec/Makefile
index e69e309..ca17831 100644
--- a/kexec/Makefile
+++ b/kexec/Makefile
@@ -88,6 +88,7 @@ include $(srcdir)/kexec/arch/mips/Makefile
  include $(srcdir)/kexec/arch/cris/Makefile
  include $(srcdir)/kexec/arch/ppc/Makefile
  include $(srcdir)/kexec/arch/ppc64/Makefile
+include $(srcdir)/kexec/arch/riscv/Makefile
  include $(srcdir)/kexec/arch/s390/Makefile
  include $(srcdir)/kexec/arch/sh/Makefile
  include $(srcdir)/kexec/arch/x86_64/Makefile
diff --git a/kexec/arch/riscv/Makefile b/kexec/arch/riscv/Makefile
new file mode 100644
index 000..f26cc90
--- /dev/null
+++ b/kexec/arch/riscv/Makefile
@@ -0,0 +1,35 @@
+#
+# kexec riscv
+#
+riscv_KEXEC_SRCS =  kexec/arch/riscv/kexec-riscv.c
+riscv_KEXEC_SRCS += kexec/arch/riscv/kexec-elf-riscv.c
+riscv_KEXEC_SRCS += kexec/arch/riscv/crashdump-riscv.c
+
+riscv_MEM_REGIONS = kexec/mem_regions.c
+
+riscv_DT_OPS += kexec/dt-ops.c
+
+riscv_ARCH_REUSE_INITRD =
+
+riscv_CPPFLAGS += -I $(srcdir)/kexec/
+
+dist += kexec/arch/riscv/Makefile $(riscv_KEXEC_SRCS)  \
+   kexec/arch/riscv/kexec-riscv.h  \
+   kexec/arch/riscv/include/arch/options.h
+
+ifdef HAVE_LIBFDT
+
+LIBS += -lfdt
+
+else
+
+include $(srcdir)/kexec/libfdt/Makefile.libfdt
+
+libfdt_SRCS += $(LIBFDT_SRCS:%=kexec/libfdt/%)
+
+riscv_CPPFLAGS += -I$(srcdir)/kexec/libfdt
+
+riscv_KEXEC_SRCS += $(libfdt_SRCS)
+
+endif
+
diff --git a/kexec/arch/riscv/crashdump-riscv.c 
b/kexec/arch/riscv/crashdump-riscv.c
new file mode 100644
index 000..3ed4fe3
--- /dev/null
+++ b/kexec/arch/riscv/crashdump-riscv.c
@@ -0,0 +1,140 @@
+#include 
+#include 
+#include 
+
+#include "kexec.h"
+#include "crashdump.h"
+#include "kexec-elf.h"
+#include "mem_regions.h"
+
+static struct crash_elf_info elf_info = {
+#if __riscv_xlen == 64
+   .class  = 

[PATCH] RISC-V: Add support for riscv kexec/kdump on kexec-tools

2022-09-18 Thread Xianting Tian
This patch adds support for loading the ELF kernel image. It parses
the current/provided device tree to determine the system's memory
layout, and /proc/iomem for the various kernel segments.

This patch was firstly developed by Nick Kossifidis, and two fixes (
   1: fail to find free memory area for dtb load when using initrd image,
  lists.infradead.org/pipermail/linux-riscv/2022-August/018398.html;
   2: fix memory range size calculation,
   kexec/arch/riscv/crashdump-riscv.c:line 85
) are contributed by Yixun Lan, Xianting Tian.

Tested on Qemu's rv64 virt machine and SoC of T-Head RISC-V Xuantie 910 CPU.

Tested-by: Yixun Lan 
Signed-off-by: Xianting Tian 
Signed-off-by: Yixun Lan 
Signed-off-by: Nick Kossifidis 
---
 configure.ac|   3 +
 include/elf.h   |   3 +-
 kexec/Makefile  |   1 +
 kexec/arch/riscv/Makefile   |  35 ++
 kexec/arch/riscv/crashdump-riscv.c  | 140 
 kexec/arch/riscv/include/arch/options.h |  43 +++
 kexec/arch/riscv/kexec-elf-riscv.c  | 255 ++
 kexec/arch/riscv/kexec-riscv.c  | 365 +++
 kexec/arch/riscv/kexec-riscv.h  |  32 ++
 kexec/dt-ops.c  | 442 +++-
 kexec/dt-ops.h  |   7 +
 kexec/kexec-syscall.h   |   4 +
 purgatory/Makefile  |   1 +
 purgatory/arch/riscv/Makefile   |   7 +
 14 files changed, 1336 insertions(+), 2 deletions(-)
 create mode 100644 kexec/arch/riscv/Makefile
 create mode 100644 kexec/arch/riscv/crashdump-riscv.c
 create mode 100644 kexec/arch/riscv/include/arch/options.h
 create mode 100644 kexec/arch/riscv/kexec-elf-riscv.c
 create mode 100644 kexec/arch/riscv/kexec-riscv.c
 create mode 100644 kexec/arch/riscv/kexec-riscv.h
 create mode 100644 purgatory/arch/riscv/Makefile

diff --git a/configure.ac b/configure.ac
index 0d825ef..7cc55b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,6 +58,9 @@ case $target_cpu in
hppa*)
ARCH="hppa"
;;
+   riscv32|riscv64 )
+   ARCH="riscv"
+   ;;
* )
AC_MSG_ERROR([unsupported architecture $target_cpu])
;;
diff --git a/include/elf.h b/include/elf.h
index b7677a2..123f167 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -259,7 +259,8 @@ typedef struct
 #define EM_ARC_A5  93  /* ARC Cores Tangent-A5 */
 #define EM_XTENSA  94  /* Tensilica Xtensa Architecture */
 #define EM_AARCH64 183 /* ARM AARCH64 */
-#define EM_NUM 184
+#define EM_RISCV   243 /* RISC-V */
+#define EM_NUM 244
 
 /* If it is necessary to assign new unofficial EM_* values, please
pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
diff --git a/kexec/Makefile b/kexec/Makefile
index e69e309..ca17831 100644
--- a/kexec/Makefile
+++ b/kexec/Makefile
@@ -88,6 +88,7 @@ include $(srcdir)/kexec/arch/mips/Makefile
 include $(srcdir)/kexec/arch/cris/Makefile
 include $(srcdir)/kexec/arch/ppc/Makefile
 include $(srcdir)/kexec/arch/ppc64/Makefile
+include $(srcdir)/kexec/arch/riscv/Makefile
 include $(srcdir)/kexec/arch/s390/Makefile
 include $(srcdir)/kexec/arch/sh/Makefile
 include $(srcdir)/kexec/arch/x86_64/Makefile
diff --git a/kexec/arch/riscv/Makefile b/kexec/arch/riscv/Makefile
new file mode 100644
index 000..f26cc90
--- /dev/null
+++ b/kexec/arch/riscv/Makefile
@@ -0,0 +1,35 @@
+#
+# kexec riscv
+#
+riscv_KEXEC_SRCS =  kexec/arch/riscv/kexec-riscv.c
+riscv_KEXEC_SRCS += kexec/arch/riscv/kexec-elf-riscv.c
+riscv_KEXEC_SRCS += kexec/arch/riscv/crashdump-riscv.c
+
+riscv_MEM_REGIONS = kexec/mem_regions.c
+
+riscv_DT_OPS += kexec/dt-ops.c
+
+riscv_ARCH_REUSE_INITRD =
+
+riscv_CPPFLAGS += -I $(srcdir)/kexec/
+
+dist += kexec/arch/riscv/Makefile $(riscv_KEXEC_SRCS)  \
+   kexec/arch/riscv/kexec-riscv.h  \
+   kexec/arch/riscv/include/arch/options.h
+
+ifdef HAVE_LIBFDT
+
+LIBS += -lfdt
+
+else
+
+include $(srcdir)/kexec/libfdt/Makefile.libfdt
+
+libfdt_SRCS += $(LIBFDT_SRCS:%=kexec/libfdt/%)
+
+riscv_CPPFLAGS += -I$(srcdir)/kexec/libfdt
+
+riscv_KEXEC_SRCS += $(libfdt_SRCS)
+
+endif
+
diff --git a/kexec/arch/riscv/crashdump-riscv.c 
b/kexec/arch/riscv/crashdump-riscv.c
new file mode 100644
index 000..3ed4fe3
--- /dev/null
+++ b/kexec/arch/riscv/crashdump-riscv.c
@@ -0,0 +1,140 @@
+#include 
+#include 
+#include 
+
+#include "kexec.h"
+#include "crashdump.h"
+#include "kexec-elf.h"
+#include "mem_regions.h"
+
+static struct crash_elf_info elf_info = {
+#if __riscv_xlen == 64
+   .class  = ELFCLASS64,
+#else
+   .class  = ELFCLASS32,
+#endif
+   .data   = ELFDATA2LSB,
+   .machine= EM_RISCV,
+};
+
+static struct memory_ranges crash_mem_ranges = {0};
+struct memory_range elfcorehdr_mem = {0};
+
+s

Re: RISC-V: patched kexec-tools on github for review/testing

2022-09-06 Thread Yixun Lan
Hi Vasily Averin:

On Tue, Sep 6, 2022 at 2:49 PM Vasily Averin  wrote:
>
> On 7/5/22 15:23, Nick Kossifidis wrote:
> > On 7/2/22 14:35, Yixun Lan wrote:
> >> I'd also like to try kexec on unmatched board, and encounter the same error
> >> as Alexandre Ghiti reported, generally I'm using almost same cmdline
> >
> > The kernel-side patches have already been merged upstream, for
> > kexec-tools there are some people working on fixes, I'm expecting
> > pull requests on the github before I do a pull request upstream. You
> > should be able to use kexec without initrd.
>
> Dear Nick, Yuxun,
> first of all thank you very much for your great work.
> Could you please clarify about state of makedumpfile on RISC-V?
>
Speak for myself, I haven't played with the makedumpfile tool yet
and a quick check [1], seems there is no RISC-V support so far

[1] https://github.com/makedumpfile/makedumpfile/tree/master/arch

Yixun

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: RISC-V: patched kexec-tools on github for review/testing

2022-09-06 Thread Vasily Averin
On 7/5/22 15:23, Nick Kossifidis wrote:
> On 7/2/22 14:35, Yixun Lan wrote:
>> I'd also like to try kexec on unmatched board, and encounter the same error
>> as Alexandre Ghiti reported, generally I'm using almost same cmdline
> 
> The kernel-side patches have already been merged upstream, for
> kexec-tools there are some people working on fixes, I'm expecting
> pull requests on the github before I do a pull request upstream. You
> should be able to use kexec without initrd.

Dear Nick, Yuxun,
first of all thank you very much for your great work.
Could you please clarify about state of makedumpfile on RISC-V?

Thank you,
Vasily Averin

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: RISC-V: patched kexec-tools on github for review/testing

2022-08-19 Thread Yixun Lan
Hi Alexandre, Nick:

On Wed, Oct 6, 2021 at 11:15 AM Alexandre Ghiti
 wrote:
>
> Hi Nick,
>
> On Tue, Oct 5, 2021 at 4:07 PM Alexandre Ghiti
>  wrote:
> >
> > On Tue, Oct 5, 2021 at 2:15 PM Nick Kossifidis  wrote:
> > >
> > > Hello all,
> > >
> > > I've uploaded my kexec-tools patches for riscv on github for
> > > testing/review before sending them upstream.
> > > https://github.com/riscv-collab/kexec-tools/tree/riscv
> > >
> > > Both kexec and kdump were tested on latest rv64 qemu, using for-next
> > > branch with this patch applied:
> > > https://patchwork.kernel.org/project/linux-riscv/patch/20211002122026.1451269-1-m...@ics.forth.gr/
> > >
> >
> > I'll test that asap and review your patch too.
> >
> > Thanks for your time Nick!
> >
> > Alex
> >
>
> So I followed the instructions here:
> https://documentation.suse.com/fr-fr/sles/12-SP3/html/SLES-all/cha-tuning-kexec.html#cha-tuning-kexec-basic-usage,
> below the output on an Unmatched board using a vmlinux stored on a sd
> card:
>
> ubuntu@ubuntu:~$ sudo sbin/kexec -l vmlinux --append="$(cat
> /proc/cmdline)" --initrd=/boot/initrd.img
> Warning: No cmdline provided, using append string as cmdline
> Warning: No dtb provided, using /sys/firmware/fdt
> [ 1813.472671] INFO: task kworker/1:0:988 blocked for more than 120 seconds.
> [ 1813.478751]   Not tainted 5.15.0-rc1+ #15
> [ 1813.483110] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs"
> disables this message.
> Could not find a free area of memory of 0x3000 bytes...
> locate_hole failed

I've finally spent some time debugging this, and found the fix:

--- a/kexec/arch/riscv/kexec-riscv.c
+++ b/kexec/arch/riscv/kexec-riscv.c
@@ -120,7 +120,7 @@ int load_extra_segments(struct kexec_info *info,
uint64_t kernel_base,
   initrd_base + initrd_size);

dbgprintf("Base addr for initrd image: 0x%lX\n", initrd_base);
-   min_usable = initrd_base;
+   max_usable = initrd_base;
}

the initrd image has been put at end of memory space( from high
address down to low address),
for example, my case here:
  the crash memory: 0x9000 - 0xA000
  and the initrd base: 0x9F78F000

so, the max_usable address need to update
>
> I used the Ubuntu kernel, so this is pretty large:
> -rwxrwxr-x 1 ubuntu ubuntu 277M Oct  5 15:47 vmlinux
> -rw-r--r-- 1 root root 98M Sep 21 03:25 /boot/initrd.img
>
> Then if I don't load the initrd (I sometimes have the same warning as
> above) I can at least kexec the new kernel but it fails to boot:
>
> ubuntu@ubuntu:~$ sudo ./sbin/kexec -e
> Warning: No cmdline or append string provided
> Warning: No dtb provided, using /sys/firmware/fdt
> [...]
> [0.00] SBI v0.2 HSM extension detected
> [0.00] CPU with hartid=0 is not available
> [0.00] [ cut here ]
> [0.00] kernel BUG at arch/riscv/kernel/smpboot.c:107!
> [0.00] Kernel BUG [#1]
> [0.00] Modules linked in:
> [0.00] CPU: 0 PID: 0 Comm: swapper Not tainted 5.15.0-rc1+ #15
> [0.00] Hardware name: SiFive HiFive Unmatched A00 (DT)
> [0.00] epc : setup_smp+0xcc/0x142
> [0.00]  ra : setup_smp+0xc4/0x142
> [0.00] epc : 80a04080 ra : 80a04078 sp :
> 81803ec0
> [0.00]  gp : 81a23220 tp : 81810500 t0 :
> 81a3551f
> [0.00]  t1 :  t2 :  s0 :
> 81803f00
> [0.00]  s1 :  a0 :  a1 :
> 
> [0.00]  a2 :  a3 : 0001 a4 :
> 
> [0.00]  a5 : 80c64500 a6 : 0004 a7 :
> ff00
> [0.00]  s2 : 0005 s3 :  s4 :
> 8118f9a8
> [0.00]  s5 : 0007 s6 : 80c0b790 s7 :
> 8200
> [0.00]  s8 : 0fff s9 : 81000200 s10:
> 0018
> [0.00]  s11: 000b t3 : 00ff t4 :
> 
> [0.00]  t5 : 80c0b7a0 t6 : 81803bd8
> [0.00] status: 00020100 badaddr: 
> cause: 0003
> [0.00] [] setup_smp+0xcc/0x142
> [0.00] [] setup_arch+0x56a/0x590
> [0.00] [] start_kernel+0xaa/0xa5c
> [0.00] random: get_random_bytes called from
> oops_exit+0x44/0x70 with crng_init=0
> [0.00] ---[ end trace  ]---
> [0.00] Kernel panic - not syncing: Attempted to kill the idle ta

[ANNOUNCE] kexec-tools 2.0.25

2022-07-30 Thread Simon Horman
Hi all,

I am happy to announce the release of kexec-tools 2.0.25.

This is a feature release coinciding with the release of v5.19
of the Linux Kernel.

This release can be downloaded from kernel.org:

http://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.25.tar.xz
http://kernel.org/pub/linux/utils/kernel/kexec/

It is also tagged it in git:

git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git

Thanks to everyone who has contributed to kexec!

Commits since v2.0.24:

0fded956184b kexec-tools 2.0.25
bfab31851465 kexec-tools 2.0.25-rc1
c3950959f428 kexec-tools: Remove duplicate ultoa() definitions and redefine it
6cd3e94813f7 i386: pass rng seed via setup_data
db26ac7f6a9c kexec-tools: mips: Pass initrd parameter via cmdline
1b87ea9ccaf0 arm64/crashdump-arm64: increase CRASH_MAX_MEMORY_RANGES to 32k
2ddfaf31fa83 kexec-tools 2.0.23.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[ANNOUNCE] kexec-tools 2.0.25-rc1

2022-07-19 Thread Simon Horman
Hi all,

I am happy to announce the release of kexec-tools 2.0.25-rc1.

This is an incremental feature pre-release.

So long as no serious problems arise I intend to release kexec-tools 2.0.25
in a weeks time. Testing of 2.0.25-rc1 would be greatly appreciated.

I do not have any outstanding changes for 2.0.25 at this time.
And I would like to only accept bug fixes at this time and take
features patches once 2.0.25 has been released.

The pre-release can be downloaded from kernel.org:


https://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.25-rc1.tar.xz
https://kernel.org/pub/linux/utils/kernel/kexec/

I have also tagged it in git:

https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git

Thanks to everyone who has contributed to kexec.


For reference the changes since v2.0.24 are:

bfab31851465 kexec-tools 2.0.25-rc1
c3950959f428 kexec-tools: Remove duplicate ultoa() definitions and redefine it
6cd3e94813f7 i386: pass rng seed via setup_data
db26ac7f6a9c kexec-tools: mips: Pass initrd parameter via cmdline
1b87ea9ccaf0 arm64/crashdump-arm64: increase CRASH_MAX_MEMORY_RANGES to 32k
2ddfaf31fa83 kexec-tools 2.0.23.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH] kexec-tools: Remove duplicate ultoa() definitions and redefine it

2022-07-19 Thread Simon Horman
On Fri, Jul 15, 2022 at 06:05:14PM +0800, Tiezhu Yang wrote:
> There exist duplicate ultoa() definitions in many archs, remove them,
> and also redefine ultoa() in kexec/kexec.h to make it more readable.
> 
> Signed-off-by: Tiezhu Yang 

Thanks, this is very much appreciated.
Applied.

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH] kexec-tools: Remove duplicate ultoa() definitions and redefine it

2022-07-15 Thread Tiezhu Yang
There exist duplicate ultoa() definitions in many archs, remove them,
and also redefine ultoa() in kexec/kexec.h to make it more readable.

Signed-off-by: Tiezhu Yang 
---
 kexec/arch/i386/crashdump-x86.c| 19 ---
 kexec/arch/mips/crashdump-mips.c   | 19 ---
 kexec/arch/mips/kexec-elf-mips.c   | 19 ---
 kexec/arch/ppc64/crashdump-ppc64.c | 19 ---
 kexec/arch/sh/crashdump-sh.c   | 19 ---
 kexec/kexec.h  | 16 
 6 files changed, 16 insertions(+), 95 deletions(-)

diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index 9826f6d..df1f24c 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -601,25 +601,6 @@ static int delete_memmap(struct memory_range *memmap_p, 
int *nr_memmap,
return 0;
 }
 
-/* Converts unsigned long to ascii string. */
-static void ultoa(unsigned long i, char *str)
-{
-   int j = 0, k;
-   char tmp;
-
-   do {
-   str[j++] = i % 10 + '0';
-   } while ((i /=10) > 0);
-   str[j] = '\0';
-
-   /* Reverse the string. */
-   for (j = 0, k = strlen(str) - 1; j < k; j++, k--) {
-   tmp = str[k];
-   str[k] = str[j];
-   str[j] = tmp;
-   }
-}
-
 static void cmdline_add_memmap_internal(char *cmdline, unsigned long startk,
unsigned long endk, int type)
 {
diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
index d9f4515..00f4335 100644
--- a/kexec/arch/mips/crashdump-mips.c
+++ b/kexec/arch/mips/crashdump-mips.c
@@ -224,25 +224,6 @@ static int get_crash_memory_ranges(struct memory_range 
**range, int *ranges)
return 0;
 }
 
-/* Converts unsigned long to ascii string. */
-static void ultoa(unsigned long i, char *str)
-{
-   int j = 0, k;
-   char tmp;
-
-   do {
-   str[j++] = i % 10 + '0';
-   } while ((i /= 10) > 0);
-   str[j] = '\0';
-
-   /* Reverse the string. */
-   for (j = 0, k = strlen(str) - 1; j < k; j++, k--) {
-   tmp = str[k];
-   str[k] = str[j];
-   str[j] = tmp;
-   }
-}
-
 /* Adds the appropriate mem= options to command line, indicating the
  * memory region the new kernel can use to boot into. */
 static int cmdline_add_mem(char *cmdline, unsigned long addr,
diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
index 31f4c47..230d806 100644
--- a/kexec/arch/mips/kexec-elf-mips.c
+++ b/kexec/arch/mips/kexec-elf-mips.c
@@ -40,25 +40,6 @@ static const int probe_debug = 0;
 #define CMDLINE_PREFIX "kexec "
 static char cmdline_buf[COMMAND_LINE_SIZE] = CMDLINE_PREFIX;
 
-/* Converts unsigned long to ascii string. */
-static void ultoa(unsigned long i, char *str)
-{
-   int j = 0, k;
-   char tmp;
-
-   do {
-   str[j++] = i % 10 + '0';
-   } while ((i /= 10) > 0);
-   str[j] = '\0';
-
-   /* Reverse the string. */
-   for (j = 0, k = strlen(str) - 1; j < k; j++, k--) {
-   tmp = str[k];
-   str[k] = str[j];
-   str[j] = tmp;
-   }
-}
-
 /* Adds initrd parameters to command line. */
 static int cmdline_add_initrd(char *cmdline, unsigned long addr, char 
*new_para)
 {
diff --git a/kexec/arch/ppc64/crashdump-ppc64.c 
b/kexec/arch/ppc64/crashdump-ppc64.c
index 91f9521..6d47898 100644
--- a/kexec/arch/ppc64/crashdump-ppc64.c
+++ b/kexec/arch/ppc64/crashdump-ppc64.c
@@ -436,25 +436,6 @@ err:
return -1;
 }
 
-/* Converts unsigned long to ascii string. */
-static void ultoa(uint64_t i, char *str)
-{
-   int j = 0, k;
-   char tmp;
-
-   do {
-   str[j++] = i % 10 + '0';
-   } while ((i /=10) > 0);
-   str[j] = '\0';
-
-   /* Reverse the string. */
-   for (j = 0, k = strlen(str) - 1; j < k; j++, k--) {
-   tmp = str[k];
-   str[k] = str[j];
-   str[j] = tmp;
-   }
-}
-
 static int add_cmdline_param(char *cmdline, uint64_t addr, char *cmdstr,
char *byte)
 {
diff --git a/kexec/arch/sh/crashdump-sh.c b/kexec/arch/sh/crashdump-sh.c
index aa25dea..36e9aaf 100644
--- a/kexec/arch/sh/crashdump-sh.c
+++ b/kexec/arch/sh/crashdump-sh.c
@@ -90,25 +90,6 @@ static struct crash_elf_info elf_info32 =
page_offset: PAGE_OFFSET,
 };
 
-/* Converts unsigned long to ascii string. */
-static void ultoa(unsigned long i, char *str)
-{
-   int j = 0, k;
-   char tmp;
-
-   do {
-   str[j++] = i % 10 + '0';
-   } while ((i /=10) > 0);
-   str[j] = '\0';
-
-   /* Reverse the string. */
-   for (j = 0, k = strlen(str) - 1; j < k; j++, k--) {
-   tmp = str[k];
-   str[k] = str[j];
-   str[j] = tmp;
-   }
-}
-
 static int add_cmdline_param(char *cmdline, uint64_t addr, char *cmdstr,
  

Re: [PATCH kexec-tools] i386: pass rng seed via setup_data

2022-07-15 Thread Simon Horman
On Mon, Jul 11, 2022 at 05:41:10PM +0200, Jason A. Donenfeld wrote:
> Linux ≥5.20 expects a RNG seed via setup_data as of the upstream commit
> in the link below. That commit adjusts kexec_file_load to pass
> SETUP_RNG_SEED. kexec-tools should follow suite, so add more or less the
> same code here.
> 
> Link: https://git.kernel.org/tip/tip/c/68b8e9713c8
> Signed-off-by: Jason A. Donenfeld 

Thanks, applied.

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[ANNOUNCE] kexec-tools v2.0.25 preparation

2022-07-14 Thread Simon Horman
Hi all,

I am planning to release kexec-tools v2.0.25 in the next two weeks
to roughly coincide with the release of the v5.19 kernel.

I would like to ask interested parties to send any patches they would like
included in v2.0.25 within one week so they can be considered for inclusion
in an rc release.

For reference the patches queued up since v2.0.24 are as follows.

Thanks to everyone who has contributed to kexec-tools!

db26ac7f6a9c kexec-tools: mips: Pass initrd parameter via cmdline
1b87ea9ccaf0 arm64/crashdump-arm64: increase CRASH_MAX_MEMORY_RANGES to 32k
2ddfaf31fa83 kexec-tools 2.0.23.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: RISC-V: patched kexec-tools on github for review/testing

2022-07-05 Thread Yixun Lan
HI Nick

On Tue, Jul 5, 2022 at 12:24 PM Nick Kossifidis  wrote:
>
> Hello Yixun,
>
> On 7/2/22 14:35, Yixun Lan wrote:
> > hi Nick
> >
> > ping, any update for this? any new patch for kexec-tools?
> >
> > I'd also like to try kexec on unmatched board, and encounter the same error
> > as Alexandre Ghiti reported, generally I'm using almost same cmdline
> >
> > Yixun Lan
>
> The kernel-side patches have already been merged upstream, for
> kexec-tools there are some people working on fixes, I'm expecting pull
> requests on the github before I do a pull request upstream. You should
> be able to use kexec without initrd.
>
> Regards,
> Nick

Thanks for the reply and updated information
I was looking forward to use "--initrd" in order to boot a complicated OS,

Anyway, I will try kexec without initrd, and please keep me posted
when there is PR

Regards

Yixun Lan

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: RISC-V: patched kexec-tools on github for review/testing

2022-07-05 Thread Nick Kossifidis

Hello Yixun,

On 7/2/22 14:35, Yixun Lan wrote:

hi Nick

ping, any update for this? any new patch for kexec-tools?

I'd also like to try kexec on unmatched board, and encounter the same error
as Alexandre Ghiti reported, generally I'm using almost same cmdline

Yixun Lan


The kernel-side patches have already been merged upstream, for 
kexec-tools there are some people working on fixes, I'm expecting pull 
requests on the github before I do a pull request upstream. You should 
be able to use kexec without initrd.


Regards,
Nick

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: RISC-V: patched kexec-tools on github for review/testing

2022-07-02 Thread Yixun Lan
gt;
> >>
> >> This looks weird, I'll check it out (we have an unmatched here so I'll
> >> try to get my hands on it sometime next week).
> >>
> >> Did you try kdump ? Do you get the same error ?
> >
> > kdump works fine, it fails to find the rootfs but I think my setup is
> > faulty here.
> > I took a quick look at kexec_relocate.S, and the use of va_pa_offset
> > is also wrong here, we should use va_kernel_pa_offset as it is used to
> > modify a text address But fixing that did not work either.
> >
> > Alex
> >
>
> Sorry for the delay, I finally got some time to work on this. As it
> turns out I'm passing cpu id instead of hart id to the next kernel (that
> comment on smp.h claiming that raw_smp_processor_id returns the hart id
> didn't help much) and interestingly enough cpu id and hart id match on
> qemu and also sometimes match on the unmatched / unleashed board. Also
> on unmatched / unleashed, hart id 0 is used by the non-linux hart so if
> we pass the cpu id of the boot cpu that's always going to be 0 it'll be
> invalid, but that's not always the case, especially for kdump. I'm also
> getting an error when trying to mount the rootfs on kdump on the
> unmatched board, because swiotlb can't allocate bounce buffers and the
> pcie driver doesn't work, so no nvme access. I'm looking for a way to
> make this work without messing things up, in any case I'll send some
> patches over the weekend. For the initrd issue I need to patch
> kexec-tools.
>
> Regards,
> Nick
>

ping, any update for this? any new patch for kexec-tools?

I'd also like to try kexec on unmatched board, and encounter the same error
as Alexandre Ghiti reported, generally I'm using almost same cmdline

Yixun Lan

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH v6] kexec-tools: mips: Pass initrd parameter via cmdline

2022-06-26 Thread Simon Horman
On Sat, Jun 25, 2022 at 10:49:49AM +0800, Hui Li wrote:
> Under loongson platform, use command:
> kexec -l vmlinux... --append="root=UUID=28e1..." --initrd=...
> kexec -e
> quick restart failed like this:
> 
> 
> [3.420791] VFS: Cannot open root device "UUID=6462a8a4-02fb-49..."
> [3.431262] Please append a correct "root=" boot option; ...
> ...
> ...
> ...
> [3.543175]   0801 4194304 sda1 554e69cc-01
> [3.543175]
> [3.549494]   080262914560 sda2 554e69cc-02
> [3.549495]
> [3.555818]   0803 8388608 sda3 554e69cc-03
> [3.555819]
> [3.562139]   0804   174553229 sda4 554e69cc-04
> [3.562139]
> [3.568463] 0b00 1048575 sr0
> [3.568464]  driver: sr
> [3.574524] Kernel panic - not syncing: VFS: Unable to mount root fs...
> [3.582750] ---[ end Kernel panic - not syncing: VFS:...
> ***
> 
> The kernel cannot parse the UUID, the UUID is parsed in the initrd.
> For compatibility with previous platforms, loongson platform obtain
> initrd parameter through cmdline in kernel, the kernel supports use
> cmdline to parse initrd. But under the mips architecture, kexec-tools
> pass the initrd through DTB.
> 
> Made the following modifications:
> 
> (1) in kexec/arch/mips/kexec-elf-mips.c
> Add patch_initrd_info(), at runtime to distinguish different cpu,
> only for loongson cpu, add initrd parameter to cmdline.
> 
> (2) in kexec/arch/mips/crashdump-mips.c
> Because loongson uses a different page_offset, it should be modified
> to ensure that crashdump functionality is correct and reliable.
> 
> (3) in kexec/arch/mips/crashdump-mips.h
> Added platform-specific page_offset macro definition.
> 
> Signed-off-by: Hui Li 

Thanks for addressing all my review comments.
I have applied this patch for inclusion in the next release
of kexec-tools.

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH v6] kexec-tools: mips: Pass initrd parameter via cmdline

2022-06-24 Thread Hui Li
Under loongson platform, use command:
kexec -l vmlinux... --append="root=UUID=28e1..." --initrd=...
kexec -e
quick restart failed like this:


[3.420791] VFS: Cannot open root device "UUID=6462a8a4-02fb-49..."
[3.431262] Please append a correct "root=" boot option; ...
...
...
...
[3.543175]   0801 4194304 sda1 554e69cc-01
[3.543175]
[3.549494]   080262914560 sda2 554e69cc-02
[3.549495]
[3.555818]   0803 8388608 sda3 554e69cc-03
[3.555819]
[3.562139]   0804   174553229 sda4 554e69cc-04
[3.562139]
[3.568463] 0b00 1048575 sr0
[3.568464]  driver: sr
[3.574524] Kernel panic - not syncing: VFS: Unable to mount root fs...
[3.582750] ---[ end Kernel panic - not syncing: VFS:...
***

The kernel cannot parse the UUID, the UUID is parsed in the initrd.
For compatibility with previous platforms, loongson platform obtain
initrd parameter through cmdline in kernel, the kernel supports use
cmdline to parse initrd. But under the mips architecture, kexec-tools
pass the initrd through DTB.

Made the following modifications:

(1) in kexec/arch/mips/kexec-elf-mips.c
Add patch_initrd_info(), at runtime to distinguish different cpu,
only for loongson cpu, add initrd parameter to cmdline.

(2) in kexec/arch/mips/crashdump-mips.c
Because loongson uses a different page_offset, it should be modified
to ensure that crashdump functionality is correct and reliable.

(3) in kexec/arch/mips/crashdump-mips.h
Added platform-specific page_offset macro definition.

Signed-off-by: Hui Li 
---
 kexec/arch/mips/crashdump-mips.c |  5 ++-
 kexec/arch/mips/crashdump-mips.h |  2 +
 kexec/arch/mips/kexec-elf-mips.c | 76 +++-
 3 files changed, 80 insertions(+), 3 deletions(-)

diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
index aa09c83..d9f4515 100644
--- a/kexec/arch/mips/crashdump-mips.c
+++ b/kexec/arch/mips/crashdump-mips.c
@@ -334,7 +334,10 @@ static int patch_elf_info(void)
if (strncmp(line, "cpu model", 9) == 0) {
/* OCTEON uses a different page_offset. */
if (strstr(line, "Octeon"))
-   elf_info64.page_offset = 0x8000ULL;
+   elf_info64.page_offset = OCTEON_PAGE_OFFSET;
+   /* LOONGSON uses a different page_offset. */
+   else if (strstr(line, "Loongson"))
+   elf_info64.page_offset = LOONGSON_PAGE_OFFSET;
break;
}
}
diff --git a/kexec/arch/mips/crashdump-mips.h b/kexec/arch/mips/crashdump-mips.h
index 7edd859..55c9925 100644
--- a/kexec/arch/mips/crashdump-mips.h
+++ b/kexec/arch/mips/crashdump-mips.h
@@ -13,6 +13,8 @@ int load_crashdump_segments(struct kexec_info *info, char 
*mod_cmdline,
 #endif
 #define __pa(x)((unsigned long)(X) & 0x7fff)
 
+#define LOONGSON_PAGE_OFFSET   0x8000ULL
+#define OCTEON_PAGE_OFFSET 0x8000ULL
 
 #define CRASH_MAX_MEMMAP_NR(KEXEC_MAX_SEGMENTS + 1)
 #define CRASH_MAX_MEMORY_RANGES(MAX_MEMORY_RANGES + 2)
diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
index a2d11fc..31f4c47 100644
--- a/kexec/arch/mips/kexec-elf-mips.c
+++ b/kexec/arch/mips/kexec-elf-mips.c
@@ -40,6 +40,77 @@ static const int probe_debug = 0;
 #define CMDLINE_PREFIX "kexec "
 static char cmdline_buf[COMMAND_LINE_SIZE] = CMDLINE_PREFIX;
 
+/* Converts unsigned long to ascii string. */
+static void ultoa(unsigned long i, char *str)
+{
+   int j = 0, k;
+   char tmp;
+
+   do {
+   str[j++] = i % 10 + '0';
+   } while ((i /= 10) > 0);
+   str[j] = '\0';
+
+   /* Reverse the string. */
+   for (j = 0, k = strlen(str) - 1; j < k; j++, k--) {
+   tmp = str[k];
+   str[k] = str[j];
+   str[j] = tmp;
+   }
+}
+
+/* Adds initrd parameters to command line. */
+static int cmdline_add_initrd(char *cmdline, unsigned long addr, char 
*new_para)
+{
+   int cmdlen, len;
+   char str[30], *ptr;
+
+   ptr = str;
+   strcpy(str, new_para);
+   ptr += strlen(str);
+   ultoa(addr, ptr);
+   len = strlen(str);
+   cmdlen = strlen(cmdline) + len;
+   if (cmdlen > (COMMAND_LINE_SIZE - 1))
+   die("Command line overflow\n");
+   strcat(cmdline, str);
+
+   return 0;
+}
+
+/* add initrd to cmdline to compatible with previous platforms. */
+static int patch_initrd_info(char *cmdline, unsigned long base,
+unsigned long size)
+{
+   const char cpuinfo[] 

Re: [PATCH v5] kexec-tools: mips: Pass initrd parameter via cmdline

2022-06-24 Thread Simon Horman
On Fri, Jun 24, 2022 at 05:32:19PM +0800, Hui Li wrote:
> Under loongson platform, use command:
> kexec -l vmlinux... --append="root=UUID=28e1..." --initrd=...
> kexec -e
> quick restart failed like this:
> 
> 
> [3.420791] VFS: Cannot open root device "UUID=6462a8a4-02fb-49..."
> [3.431262] Please append a correct "root=" boot option; ...
> ...
> ...
> ...
> [3.543175]   0801 4194304 sda1 554e69cc-01
> [3.543175]
> [3.549494]   080262914560 sda2 554e69cc-02
> [3.549495]
> [3.555818]   0803 8388608 sda3 554e69cc-03
> [3.555819]
> [3.562139]   0804   174553229 sda4 554e69cc-04
> [3.562139]
> [3.568463] 0b00 1048575 sr0
> [3.568464]  driver: sr
> [3.574524] Kernel panic - not syncing: VFS: Unable to mount root fs...
> [3.582750] ---[ end Kernel panic - not syncing: VFS:...
> ***
> 
> The kernel cannot parse the UUID, the UUID is parsed in the initrd.
> For compatibility with previous platforms, loongson platform obtain
> initrd parameter through cmdline in kernel, the kernel supports use
> cmdline to parse initrd. But under the mips architecture, kexec-tools
> pass the initrd through DTB.
> 
> Made the following modifications:
> 
> (1) in kexec/arch/mips/kexec-elf-mips.c
> Add patch_initrd_info(), at runtime to distinguish different cpu,
> only for loongson cpu, add initrd parameter to cmdline.
> 
> (2) in kexec/arch/mips/crashdump-mips.c
> Because loongson uses a different page_offset, it should be modified
> to ensure that crashdump functionality is correct and reliable.
> 
> (3) in kexec/arch/mips/crashdump-mips.h
> Added platform-specific page_offset macro definition.
> 
> Signed-off-by: Hui Li 

Sorry, I seem to see a compile failure with this version:

$ make
...
 mipsel-linux-gnu-gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes 
-I../../include -I../../util_lib/include -Iinclude/ -I../../kexec/libfdt 
-I../../kexec/arch/mips/include  -c -MD -o kexec/arch/mips/kexec-elf-mips.o 
../../kexec/arch/mips/kexec-elf-mips.c
../../kexec/arch/mips/kexec-elf-mips.c: In function ‘patch_initrd_info’:
../../kexec/arch/mips/kexec-elf-mips.c:102:20: error: ‘LOONGSON_PAGE_OFFSET’ 
undeclared (first use in this function)
  102 |  page_offset = LOONGSON_PAGE_OFFSET;
  |^~~~
../../kexec/arch/mips/kexec-elf-mips.c:102:20: note: each undeclared identifier 
is reported only once for each function it appears in

Ref: https://github.com/horms/kexec-tools/runs/7043602833?check_suite_focus=true


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH v5] kexec-tools: mips: Pass initrd parameter via cmdline

2022-06-24 Thread Hui Li
Under loongson platform, use command:
kexec -l vmlinux... --append="root=UUID=28e1..." --initrd=...
kexec -e
quick restart failed like this:


[3.420791] VFS: Cannot open root device "UUID=6462a8a4-02fb-49..."
[3.431262] Please append a correct "root=" boot option; ...
...
...
...
[3.543175]   0801 4194304 sda1 554e69cc-01
[3.543175]
[3.549494]   080262914560 sda2 554e69cc-02
[3.549495]
[3.555818]   0803 8388608 sda3 554e69cc-03
[3.555819]
[3.562139]   0804   174553229 sda4 554e69cc-04
[3.562139]
[3.568463] 0b00 1048575 sr0
[3.568464]  driver: sr
[3.574524] Kernel panic - not syncing: VFS: Unable to mount root fs...
[3.582750] ---[ end Kernel panic - not syncing: VFS:...
***

The kernel cannot parse the UUID, the UUID is parsed in the initrd.
For compatibility with previous platforms, loongson platform obtain
initrd parameter through cmdline in kernel, the kernel supports use
cmdline to parse initrd. But under the mips architecture, kexec-tools
pass the initrd through DTB.

Made the following modifications:

(1) in kexec/arch/mips/kexec-elf-mips.c
Add patch_initrd_info(), at runtime to distinguish different cpu,
only for loongson cpu, add initrd parameter to cmdline.

(2) in kexec/arch/mips/crashdump-mips.c
Because loongson uses a different page_offset, it should be modified
to ensure that crashdump functionality is correct and reliable.

(3) in kexec/arch/mips/crashdump-mips.h
Added platform-specific page_offset macro definition.

Signed-off-by: Hui Li 
---
 kexec/arch/mips/crashdump-mips.c |  5 ++-
 kexec/arch/mips/crashdump-mips.h |  4 +-
 kexec/arch/mips/kexec-elf-mips.c | 76 +++-
 3 files changed, 81 insertions(+), 4 deletions(-)

diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
index aa09c83..d9f4515 100644
--- a/kexec/arch/mips/crashdump-mips.c
+++ b/kexec/arch/mips/crashdump-mips.c
@@ -334,7 +334,10 @@ static int patch_elf_info(void)
if (strncmp(line, "cpu model", 9) == 0) {
/* OCTEON uses a different page_offset. */
if (strstr(line, "Octeon"))
-   elf_info64.page_offset = 0x8000ULL;
+   elf_info64.page_offset = OCTEON_PAGE_OFFSET;
+   /* LOONGSON uses a different page_offset. */
+   else if (strstr(line, "Loongson"))
+   elf_info64.page_offset = LOONGSON_PAGE_OFFSET;
break;
}
}
diff --git a/kexec/arch/mips/crashdump-mips.h b/kexec/arch/mips/crashdump-mips.h
index 7edd859..641dc50 100644
--- a/kexec/arch/mips/crashdump-mips.h
+++ b/kexec/arch/mips/crashdump-mips.h
@@ -5,7 +5,9 @@ struct kexec_info;
 int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline,
unsigned long max_addr, unsigned long min_base);
 #ifdef __mips64
-#define PAGE_OFFSET0xa800ULL
+#define PAGE_OFFSET 0xa800ULL
+#define LOONGSON_PAGE_OFFSET0x8000ULL
+#define OCTEON_PAGE_OFFSET  0x8000ULL
 #define MAXMEM 0
 #else
 #define PAGE_OFFSET0x8000
diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
index a2d11fc..31f4c47 100644
--- a/kexec/arch/mips/kexec-elf-mips.c
+++ b/kexec/arch/mips/kexec-elf-mips.c
@@ -40,6 +40,77 @@ static const int probe_debug = 0;
 #define CMDLINE_PREFIX "kexec "
 static char cmdline_buf[COMMAND_LINE_SIZE] = CMDLINE_PREFIX;
 
+/* Converts unsigned long to ascii string. */
+static void ultoa(unsigned long i, char *str)
+{
+   int j = 0, k;
+   char tmp;
+
+   do {
+   str[j++] = i % 10 + '0';
+   } while ((i /= 10) > 0);
+   str[j] = '\0';
+
+   /* Reverse the string. */
+   for (j = 0, k = strlen(str) - 1; j < k; j++, k--) {
+   tmp = str[k];
+   str[k] = str[j];
+   str[j] = tmp;
+   }
+}
+
+/* Adds initrd parameters to command line. */
+static int cmdline_add_initrd(char *cmdline, unsigned long addr, char 
*new_para)
+{
+   int cmdlen, len;
+   char str[30], *ptr;
+
+   ptr = str;
+   strcpy(str, new_para);
+   ptr += strlen(str);
+   ultoa(addr, ptr);
+   len = strlen(str);
+   cmdlen = strlen(cmdline) + len;
+   if (cmdlen > (COMMAND_LINE_SIZE - 1))
+   die("Command line overflow\n");
+   strcat(cmdline, str);
+
+   return 0;
+}
+
+/* add initrd to cmdline to compatible with previous platforms. */
+static int patch_initrd_info(char *cmdline, unsigned long base,
+  

Re: [PATCH v4] kexec-tools: mips: Pass initrd parameter via cmdline

2022-06-23 Thread Simon Horman
On Fri, Jun 10, 2022 at 04:53:52PM +0800, Hui Li wrote:
> Under loongson platform, use command:
> kexec -l vmlinux... --append="root=UUID=28e1..." --initrd=...
> kexec -e
> quick restart failed like this:
> 
> 
> [3.420791] VFS: Cannot open root device "UUID=6462a8a4-02fb-49..."
> [3.431262] Please append a correct "root=" boot option; ...
> ...
> ...
> ...
> [3.543175]   0801 4194304 sda1 554e69cc-01
> [3.543175]
> [3.549494]   080262914560 sda2 554e69cc-02
> [3.549495]
> [3.555818]   0803 8388608 sda3 554e69cc-03
> [3.555819]
> [3.562139]   0804   174553229 sda4 554e69cc-04
> [3.562139]
> [3.568463] 0b00 1048575 sr0
> [3.568464]  driver: sr
> [3.574524] Kernel panic - not syncing: VFS: Unable to mount root fs...
> [3.582750] ---[ end Kernel panic - not syncing: VFS:...
> ***
> 
> The kernel cannot parse the UUID, the UUID is parsed in the initrd.
> For compatibility with previous platforms, loongson platform obtain
> initrd parameter through cmdline in kernel, the kernel supports use
> cmdline to parse initrd. But under the mips architecture, kexec-tools
> pass the initrd through DTB.
> 
> So some modifications as follows:
> 
> (1) in kexec/arch/mips/kexec-elf-mips.c
> Add patch_initrd_info(), at runtime to distinguish different cpu,
> only for loongson cpu, add initrd parameter to cmdline.
> 
> (2) in kexec/arch/mips/crashdump-mips.c
> Because loongson uses a different page_offset, it should be modified
> to ensure that crashdump functionality is correct and reliable.
> 
> Signed-off-by: Hui Li 

Hi Hui Li,

thanks for the follow-up and sorry for the slow response.

Overall I am happy with this approach.
I have made a few minor comments inline for your consideration.

> ---
>  kexec/arch/mips/crashdump-mips.c |  3 ++
>  kexec/arch/mips/kexec-elf-mips.c | 73 +++-
>  2 files changed, 74 insertions(+), 2 deletions(-)
> 
> diff --git a/kexec/arch/mips/crashdump-mips.c 
> b/kexec/arch/mips/crashdump-mips.c
> index aa09c83..548aeff 100644
> --- a/kexec/arch/mips/crashdump-mips.c
> +++ b/kexec/arch/mips/crashdump-mips.c
> @@ -335,6 +335,9 @@ static int patch_elf_info(void)
>   /* OCTEON uses a different page_offset. */
>   if (strstr(line, "Octeon"))
>   elf_info64.page_offset = 0x8000ULL;
> + /* LOONGSON uses a different page_offset. */
> + else if (strstr(line, "Loongson"))
> + elf_info64.page_offset = 0x8000ULL;

nit: 0x8000ULL is used twice. Perhaps we could make it a #define.
And perhaps 0x8000ULL too, while we are here.

>   break;
>   }
>   }
> diff --git a/kexec/arch/mips/kexec-elf-mips.c 
> b/kexec/arch/mips/kexec-elf-mips.c
> index a2d11fc..b9e0341 100644
> --- a/kexec/arch/mips/kexec-elf-mips.c
> +++ b/kexec/arch/mips/kexec-elf-mips.c
> @@ -40,6 +40,74 @@ static const int probe_debug = 0;
>  #define CMDLINE_PREFIX "kexec "
>  static char cmdline_buf[COMMAND_LINE_SIZE] = CMDLINE_PREFIX;
>  
> +/* Converts unsigned long to ascii string. */
> +static void ultoa(unsigned long i, char *str)
> +{
> + int j = 0, k;
> + char tmp;
> +
> + do {
> + str[j++] = i % 10 + '0';
> + } while ((i /= 10) > 0);
> + str[j] = '\0';
> +
> + /* Reverse the string. */
> + for (j = 0, k = strlen(str) - 1; j < k; j++, k--) {
> + tmp = str[k];
> + str[k] = str[j];
> + str[j] = tmp;
> + }
> +}
> +
> +/* Adds initrd parameters to command line. */
> +static int cmdline_add_initrd(char *cmdline, unsigned long addr, char 
> *new_para)
> +{
> + int cmdlen, len;
> + char str[30], *ptr;
> +
> + ptr = str;
> + strcpy(str, new_para);
> + ptr += strlen(str);
> + ultoa(addr, ptr);
> + len = strlen(str);
> + cmdlen = strlen(cmdline) + len;
> + if (cmdlen > (COMMAND_LINE_SIZE - 1))
> + die("Command line overflow\n");
> + strcat(cmdline, str);
> +
> + return 0;
> +}
> +
> +/* add initrd to cmdline to compatible with previous platforms. */
> +static int patch_initrd_info(char *cmdline, unsigned long initrd_base, 
> unsigned long initrd_size)

nit: I would prefer if the code was less than 80 colu

[PATCH v4] kexec-tools: mips: Pass initrd parameter via cmdline

2022-06-10 Thread Hui Li
Under loongson platform, use command:
kexec -l vmlinux... --append="root=UUID=28e1..." --initrd=...
kexec -e
quick restart failed like this:


[3.420791] VFS: Cannot open root device "UUID=6462a8a4-02fb-49..."
[3.431262] Please append a correct "root=" boot option; ...
...
...
...
[3.543175]   0801 4194304 sda1 554e69cc-01
[3.543175]
[3.549494]   080262914560 sda2 554e69cc-02
[3.549495]
[3.555818]   0803 8388608 sda3 554e69cc-03
[3.555819]
[3.562139]   0804   174553229 sda4 554e69cc-04
[3.562139]
[3.568463] 0b00 1048575 sr0
[3.568464]  driver: sr
[3.574524] Kernel panic - not syncing: VFS: Unable to mount root fs...
[3.582750] ---[ end Kernel panic - not syncing: VFS:...
***

The kernel cannot parse the UUID, the UUID is parsed in the initrd.
For compatibility with previous platforms, loongson platform obtain
initrd parameter through cmdline in kernel, the kernel supports use
cmdline to parse initrd. But under the mips architecture, kexec-tools
pass the initrd through DTB.

So some modifications as follows:

(1) in kexec/arch/mips/kexec-elf-mips.c
Add patch_initrd_info(), at runtime to distinguish different cpu,
only for loongson cpu, add initrd parameter to cmdline.

(2) in kexec/arch/mips/crashdump-mips.c
Because loongson uses a different page_offset, it should be modified
to ensure that crashdump functionality is correct and reliable.

Signed-off-by: Hui Li 
---
 kexec/arch/mips/crashdump-mips.c |  3 ++
 kexec/arch/mips/kexec-elf-mips.c | 73 +++-
 2 files changed, 74 insertions(+), 2 deletions(-)

diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
index aa09c83..548aeff 100644
--- a/kexec/arch/mips/crashdump-mips.c
+++ b/kexec/arch/mips/crashdump-mips.c
@@ -335,6 +335,9 @@ static int patch_elf_info(void)
/* OCTEON uses a different page_offset. */
if (strstr(line, "Octeon"))
elf_info64.page_offset = 0x8000ULL;
+   /* LOONGSON uses a different page_offset. */
+   else if (strstr(line, "Loongson"))
+   elf_info64.page_offset = 0x8000ULL;
break;
}
}
diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
index a2d11fc..b9e0341 100644
--- a/kexec/arch/mips/kexec-elf-mips.c
+++ b/kexec/arch/mips/kexec-elf-mips.c
@@ -40,6 +40,74 @@ static const int probe_debug = 0;
 #define CMDLINE_PREFIX "kexec "
 static char cmdline_buf[COMMAND_LINE_SIZE] = CMDLINE_PREFIX;
 
+/* Converts unsigned long to ascii string. */
+static void ultoa(unsigned long i, char *str)
+{
+   int j = 0, k;
+   char tmp;
+
+   do {
+   str[j++] = i % 10 + '0';
+   } while ((i /= 10) > 0);
+   str[j] = '\0';
+
+   /* Reverse the string. */
+   for (j = 0, k = strlen(str) - 1; j < k; j++, k--) {
+   tmp = str[k];
+   str[k] = str[j];
+   str[j] = tmp;
+   }
+}
+
+/* Adds initrd parameters to command line. */
+static int cmdline_add_initrd(char *cmdline, unsigned long addr, char 
*new_para)
+{
+   int cmdlen, len;
+   char str[30], *ptr;
+
+   ptr = str;
+   strcpy(str, new_para);
+   ptr += strlen(str);
+   ultoa(addr, ptr);
+   len = strlen(str);
+   cmdlen = strlen(cmdline) + len;
+   if (cmdlen > (COMMAND_LINE_SIZE - 1))
+   die("Command line overflow\n");
+   strcat(cmdline, str);
+
+   return 0;
+}
+
+/* add initrd to cmdline to compatible with previous platforms. */
+static int patch_initrd_info(char *cmdline, unsigned long initrd_base, 
unsigned long initrd_size)
+{
+   const char cpuinfo[] = "/proc/cpuinfo";
+   char line[MAX_LINE];
+   FILE *fp;
+   unsigned long page_offset = PAGE_OFFSET;
+
+   fp = fopen(cpuinfo, "r");
+   if (!fp) {
+   fprintf(stderr, "Cannot open %s: %s\n",
+   cpuinfo, strerror(errno));
+   return -1;
+   }
+   while (fgets(line, sizeof(line), fp) != 0) {
+   if (strncmp(line, "cpu model", 9) == 0) {
+   /* LOONGSON64  uses a different page_offset. */
+   if (strstr(line, "Loongson")) {
+   if (arch_options.core_header_type == 
CORE_TYPE_ELF64)
+   page_offset = (unsigned 
long)0x8000ULL;
+   cmdline_add_initrd(cmdline, page_offset + 
init

[PATCH v2 2/2] kexec-tools: mips: Add initrd parameter to cmdline

2022-04-23 Thread Hui Li
Loongson platform obtain the initrd parameter through cmdline in kernel.
But kexec-tools pass the initrd through DTB.So add initrd parameter
to cmdline in order to compatible with some platforms.It is still
to pass the initrd parameter via command line.

Signed-off-by: Hui Li 
---
 kexec/arch/mips/kexec-elf-mips.c | 43 
 1 file changed, 43 insertions(+)

diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
index a2d11fc..1de418e 100644
--- a/kexec/arch/mips/kexec-elf-mips.c
+++ b/kexec/arch/mips/kexec-elf-mips.c
@@ -40,6 +40,44 @@ static const int probe_debug = 0;
 #define CMDLINE_PREFIX "kexec "
 static char cmdline_buf[COMMAND_LINE_SIZE] = CMDLINE_PREFIX;
 
+/* Converts unsigned long to ascii string. */
+static void ultoa(unsigned long i, char *str)
+{
+   int j = 0, k;
+   char tmp;
+
+   do {
+   str[j++] = i % 10 + '0';
+   } while ((i /= 10) > 0);
+   str[j] = '\0';
+   /* Reverse the string. */
+   for (j = 0, k = strlen(str) - 1; j < k; j++, k--) {
+   tmp = str[k];
+   str[k] = str[j];
+   str[j] = tmp;
+   }
+}
+
+/* Adds initrd parameters to command line. */
+static int cmdline_add_initrd(char *cmdline, unsigned long addr, char 
*new_para)
+{
+   int cmdlen, len;
+   char str[30], *ptr;
+
+   ptr = str;
+   strcpy(str, new_para);
+   ptr += strlen(str);
+   ultoa(addr, ptr);
+   len = strlen(str);
+   cmdlen = strlen(cmdline) + len;
+   if (cmdlen > (COMMAND_LINE_SIZE - 1))
+   die("Command line overflow\n");
+   strcat(cmdline, str);
+
+   return 0;
+}
+
+
 int elf_mips_probe(const char *buf, off_t len)
 {
struct mem_ehdr ehdr;
@@ -171,6 +209,11 @@ int elf_mips_load(int argc, char **argv, const char *buf, 
off_t len,
/* Now that the buffer for initrd is prepared, update the dtb
 * with an appropriate location */
dtb_set_initrd(&dtb_buf, &dtb_length, initrd_base, initrd_base 
+ initrd_size);
+
+   /* Add the initrd parameters to cmdline */
+   cmdline_add_initrd(cmdline_buf, PAGE_OFFSET + initrd_base, " 
rd_start=");
+   cmdline_add_initrd(cmdline_buf, initrd_size, " rd_size=");
+
}
 
 
-- 
2.20.1


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH v2 1/2] kexec-tools: mips: Add CONFIG_LOONGSON option.

2022-04-23 Thread Hui Li
Under the mips architecture,PAGE_OFFSE is defined as 0xa800ULL.
But now loongson and many cpu's PAGE_OFFSET use 0x8000ULL 
in kernel.so. add a --with-loongson option to distinguish PAGE_OFFSET 
between different platforms under mips.

Signed-off-by: Hui Li 
---
 configure.ac | 5 +
 kexec/arch/mips/crashdump-mips.h | 6 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index cf8e8a2..26bfbcd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -111,6 +111,11 @@ AC_ARG_WITH([booke],
AC_DEFINE(CONFIG_BOOKE,1,
[Define to build for BookE]))
 
+AC_ARG_WITH([loongson],
+   AC_HELP_STRING([--with-loongson],[build for loongson]),
+   AC_DEFINE(CONFIG_LOONGSON,1,
+   [Define to build for LoongsoN]))
+
 dnl ---Programs
 dnl To specify a different compiler, just 'export CC=/path/to/compiler'
 if test "${build}" != "${host}" ; then
diff --git a/kexec/arch/mips/crashdump-mips.h b/kexec/arch/mips/crashdump-mips.h
index 7edd859..d53c696 100644
--- a/kexec/arch/mips/crashdump-mips.h
+++ b/kexec/arch/mips/crashdump-mips.h
@@ -5,7 +5,11 @@ struct kexec_info;
 int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline,
unsigned long max_addr, unsigned long min_base);
 #ifdef __mips64
-#define PAGE_OFFSET0xa800ULL
+#ifdef CONFIG_LOONGSON
+#define PAGE_OFFSET 0x8000ULL
+#else
+#define PAGE_OFFSET 0xa800ULL
+#endif
 #define MAXMEM 0
 #else
 #define PAGE_OFFSET0x8000
-- 
2.20.1


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[ANNOUNCE] kexec-tools 2.0.24

2022-04-09 Thread Simon Horman
Hi all,

I am happy to announce the release of kexec-tools 2.0.24.

This is a feature release coinciding with the release of v5.17
of the Linux Kernel.

This release can be downloaded from kernel.org:

http://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.24.tar.xz
http://kernel.org/pub/linux/utils/kernel/kexec/

It is also tagged it in git:

git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git

Thanks to everyone who has contributed to kexec!

Commits since v2.0.23:

1d82b3faa331 kexec-tools 2.0.24
272af539f785 kexec-tools 2.0.24-rc1
c1ae085bd211 arm64: fix static data relocations in machine_apply_elf_rel()
2b78a27a64f0 kexec/elf: assign one to align if sh_addralign equals zero
1d8273d82b66 arm64/crashdump-arm64: explicit type conversion to suppress 
compiler warning
33778949c132 arm64/kexec-arm64: add support for R_AARCH64_MOVW_UABS_G* rela
e2a86b319245 arm64/kexec-arm64: use enum to organize the reloc type
8e3f663a4dfe arm64/kexec-arm64: add support for R_AARCH64_LDST128_ABS_LO12_NC 
rela
36805fe6ba33 kexec-tools: fix leak FILE pointer.
1b03cf7adc3c purgatory: do not enable vectorization automatically for purgatory 
compiling
dcfcc73c73e6 kexec-tools: Determine if the image is lzma commpressed
f4c59879b830 util_lib/elf_info: harden parsing of printk buffer
30bfe30bb609 github: run apt-get update before installing packages
501646beec2b kexec-xen: Allow xen_kexec_exec() to return in case of Live Update
1d7a308bf734 kexec-tools: print error if kexec_file_load fails
6effda061f75 kexec-tools: mips: Concatenate --reuse-cmdline and --append
8dda434a05ff kexec-tools: mips: Add some debug info
95de9eccf413 arm64: fix PAGE_OFFSET calc for flipped mm
454395e18ff1 arm64: read VA_BITS from kcore for 52-bits VA kernel
bde864387a10 arm64/crashdump: unify routine to get page_offset
67ea2d99e135 arm64: make phys_offset signed
2e1ec106dc5a s390: add support for --reuse-cmdline
d6516ba4c88f use slurp_proc_file() in get_command_line()
193e51deccc6 add slurp_proc_file()
91a3d0e00a5c s390: use KEXEC_ALL_OPTIONS
defb80a20bf1 s390: add variable command line size
b5a34a20984c arm64: support more than one crash kernel regions
186e7b0752d8 s390: handle R_390_PLT32DBL reloc entries in 
machine_apply_elf_rel()
1614959f2f0d arm64/crashdump: deduce paddr of _text based on kernel code size
10b7e1fb5d0c kexec-tools 2.0.23.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[ANNOUNCE] kexec-tools 2.0.24-rc1

2022-04-01 Thread Simon Horman
Hi all,

I am happy to announce the release of kexec-tools 2.0.24-rc1.

This is an incremental feature pre-release.

So long as no serious problems arise I intend to release kexec-tools 2.0.24
in a weeks time. Testing of 2.0.24-rc1 would be greatly appreciated.

I do not have any outstanding changes for 2.0.24 at this time.
And I would like to only accept bug fixes at this time and take
features patches once 2.0.24 has been released.

The pre-release can be downloaded from kernel.org:


https://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.24-rc1.tar.xz
https://kernel.org/pub/linux/utils/kernel/kexec/

I have also tagged it in git:

https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git

Thanks to everyone who has contributed to kexec.


For reference the changes since v2.0.23 are:

272af539f785 kexec-tools 2.0.24-rc1
c1ae085bd211 arm64: fix static data relocations in machine_apply_elf_rel()
2b78a27a64f0 kexec/elf: assign one to align if sh_addralign equals zero
1d8273d82b66 arm64/crashdump-arm64: explicit type conversion to suppress 
compiler warning
33778949c132 arm64/kexec-arm64: add support for R_AARCH64_MOVW_UABS_G* rela
e2a86b319245 arm64/kexec-arm64: use enum to organize the reloc type
8e3f663a4dfe arm64/kexec-arm64: add support for R_AARCH64_LDST128_ABS_LO12_NC 
rela
36805fe6ba33 kexec-tools: fix leak FILE pointer.
1b03cf7adc3c purgatory: do not enable vectorization automatically for purgatory 
compiling
dcfcc73c73e6 kexec-tools: Determine if the image is lzma commpressed
f4c59879b830 util_lib/elf_info: harden parsing of printk buffer
30bfe30bb609 github: run apt-get update before installing packages
501646beec2b kexec-xen: Allow xen_kexec_exec() to return in case of Live Update
1d7a308bf734 kexec-tools: print error if kexec_file_load fails
6effda061f75 kexec-tools: mips: Concatenate --reuse-cmdline and --append
8dda434a05ff kexec-tools: mips: Add some debug info
95de9eccf413 arm64: fix PAGE_OFFSET calc for flipped mm
454395e18ff1 arm64: read VA_BITS from kcore for 52-bits VA kernel
bde864387a10 arm64/crashdump: unify routine to get page_offset
67ea2d99e135 arm64: make phys_offset signed
2e1ec106dc5a s390: add support for --reuse-cmdline
d6516ba4c88f use slurp_proc_file() in get_command_line()
193e51deccc6 add slurp_proc_file()
91a3d0e00a5c s390: use KEXEC_ALL_OPTIONS
defb80a20bf1 s390: add variable command line size
b5a34a20984c arm64: support more than one crash kernel regions
186e7b0752d8 s390: handle R_390_PLT32DBL reloc entries in 
machine_apply_elf_rel()
1614959f2f0d arm64/crashdump: deduce paddr of _text based on kernel code size
10b7e1fb5d0c kexec-tools 2.0.23.git

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH] kexec-tools: fix leak FILE pointer.

2022-03-30 Thread Simon Horman
On Wed, Mar 30, 2022 at 07:09:51PM +0800, Lichen Liu wrote:
> Close fp if file size is smaller than 13 bytes.
> 
> Signed-off-by: Lichen Liu 

Thanks, applied.

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH] kexec-tools: fix leak FILE pointer.

2022-03-30 Thread Lichen Liu
Close fp if file size is smaller than 13 bytes.

Signed-off-by: Lichen Liu 
---
 kexec/lzma.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kexec/lzma.c b/kexec/lzma.c
index f27cfe2..2fc07e6 100644
--- a/kexec/lzma.c
+++ b/kexec/lzma.c
@@ -170,8 +170,11 @@ int is_lzma_file(const char *filename)
 
const size_t size = fread(buf, 1, sizeof(buf), fp);
 
-   if (size != 13)
+   if (size != 13) {
+   /* file is too small to be a lzma file. */
+   fclose(fp);
return 0;
+   }
 
lzma_filter filter = { .id = LZMA_FILTER_LZMA1 };
 
-- 
2.27.0


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH v2] kexec-tools: Determine if the image is lzma commpressed

2022-03-30 Thread Lichen Liu
Hi Simon,

I will send a new patch to fix it.

Thanks!


On Wed, Mar 30, 2022 at 5:14 PM Simon Horman  wrote:
>
> On Wed, Mar 30, 2022 at 01:33:26PM +0800, Lichen Liu wrote:
> > Currently there are 2 functions for decompressing compressed image. The
> > zlib_decompress_file() will determine if the image is compressed by gzip
> > before read, but lzma_decompress_file() will not. This can cause misleading
> > information to be printed when the image is not compressed by lzma and
> > debug option is used:
> >
> > ]# kexec -d -s -l /boot/vmlinuz-5.14.10-300.fc35.x86_64 \
> > --initrd /boot/initramfs-5.14.10-300.fc35.x86_64.img \
> > --reuse-cmdline
> > Try gzip decompression.
> > Try LZMA decompression.
> > lzma_decompress_file: read on /boot/vmlinuz-5.14.10-300.fc35.x86_64 of
> > 65536 bytes failed
> >
> > Add a helper function is_lzma_file() to help behave consistently.
> >
> > Signed-off-by: Lichen Liu 
> > ---
> > Changes in v2:
> > - add a fclose() when file is too small.
>
> Hi Lichen Liu,
>
> I have already applied v1 of this patch,
> so could you consider providing a follow-up patch
> which contains the delta between v1 and v2?
>
> Thanks!
>
> Ref: 
> https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/commit/1b03cf7adc3c
>
> ___
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
>


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH v2] kexec-tools: Determine if the image is lzma commpressed

2022-03-30 Thread Simon Horman
On Wed, Mar 30, 2022 at 01:33:26PM +0800, Lichen Liu wrote:
> Currently there are 2 functions for decompressing compressed image. The
> zlib_decompress_file() will determine if the image is compressed by gzip
> before read, but lzma_decompress_file() will not. This can cause misleading
> information to be printed when the image is not compressed by lzma and
> debug option is used:
> 
> ]# kexec -d -s -l /boot/vmlinuz-5.14.10-300.fc35.x86_64 \
> --initrd /boot/initramfs-5.14.10-300.fc35.x86_64.img \
> --reuse-cmdline
> Try gzip decompression.
> Try LZMA decompression.
> lzma_decompress_file: read on /boot/vmlinuz-5.14.10-300.fc35.x86_64 of
> 65536 bytes failed
> 
> Add a helper function is_lzma_file() to help behave consistently.
> 
> Signed-off-by: Lichen Liu 
> ---
> Changes in v2:
> - add a fclose() when file is too small.

Hi Lichen Liu,

I have already applied v1 of this patch,
so could you consider providing a follow-up patch
which contains the delta between v1 and v2?

Thanks!

Ref: 
https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/commit/1b03cf7adc3c

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [ANNOUNCE] kexec-tools v2.0.24 preparation

2022-03-30 Thread Simon Horman
On Wed, Mar 30, 2022 at 11:07:01AM +0800, Dave Young wrote:
> On 03/29/22 at 06:16pm, Baoquan He wrote:
> > On 03/29/22 at 11:17am, Simon Horman wrote:
> > > On Sat, Mar 26, 2022 at 02:55:43PM +0800, RuiRui Yang wrote:
> > > > Hi Simon,
> > > > 
> > > > Recently RH CKI detected a kexec/kdump failure with kexec_load being
> > > > used,  the 2nd kernel can not boot, just reset to bios/firmware
> > > > instead.
> > > > 
> > > > This only happens with gcc 12.x compiled kexec-tools,  add
> > > > "-fno-tree-vectorize" to purgatory/Makefile CFLAGS make the bug
> > > > dissappear, but I hope people can help to verify and confirm it does
> > > > fix the problem.   It would be better to wait a few days so that we
> > > > can fix it in the coming release, what do you think?
> > > > 
> > > > Cced Baoquan who is handling the issue..
> > > > 
> > > > Thanks!
> > > 
> > > Hi RuiRui,
> > > 
> > > thanks for letting us know.
> > > 
> > > I'm happy with delaying the release for a short time to accommodate
> > > resolving this problem. Please let us know when there is some progress.
> > 
> > Thanks for quick response, Simon. I have sent a patch to fix this,
> > please check the patch v2 with subject 'purgatory: do not enable
> > vectorization automatically for purgatory compiling'.
> > 
> > I tested on machine where the issue can stably reproduced, and can
> > confirm adding -fno-tree-vectorize to compiling options of purgatory can
> > fix the issue.
> > 
> > Dave, please check if it is expected from you.
> > 
> 
> Hi Baoquan, it works for me.  Thanks for posting it. 
> 
> Simon, I used another email/name Ruirui Yang, the two emails both are
> fine, but I usually use "Dave Young" in community, just fyi in case this
> cause some confusion :)

Thanks, as you can see I was a little confused (often is the case).

It sounds like the patch is good, I'll look into applying it.

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH v2] kexec-tools: Determine if the image is lzma commpressed

2022-03-29 Thread Lichen Liu
Currently there are 2 functions for decompressing compressed image. The
zlib_decompress_file() will determine if the image is compressed by gzip
before read, but lzma_decompress_file() will not. This can cause misleading
information to be printed when the image is not compressed by lzma and
debug option is used:

]# kexec -d -s -l /boot/vmlinuz-5.14.10-300.fc35.x86_64 \
--initrd /boot/initramfs-5.14.10-300.fc35.x86_64.img \
--reuse-cmdline
Try gzip decompression.
Try LZMA decompression.
lzma_decompress_file: read on /boot/vmlinuz-5.14.10-300.fc35.x86_64 of
65536 bytes failed

Add a helper function is_lzma_file() to help behave consistently.

Signed-off-by: Lichen Liu 
---
Changes in v2:
- add a fclose() when file is too small.

---
 kexec/lzma.c | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/kexec/lzma.c b/kexec/lzma.c
index 5bfccb7..2fc07e6 100644
--- a/kexec/lzma.c
+++ b/kexec/lzma.c
@@ -155,6 +155,42 @@ ssize_t lzread(LZFILE *lzfile, void *buf, size_t len)
}
 }
 
+int is_lzma_file(const char *filename)
+{
+   FILE *fp;
+   int ret = 0;
+   uint8_t buf[13];
+
+   if (!filename)
+   return 0;
+
+   fp = fopen(filename, "r");
+   if (fp == NULL)
+   return 0;
+
+   const size_t size = fread(buf, 1, sizeof(buf), fp);
+
+   if (size != 13) {
+   /* file is too small to be a lzma file. */
+   fclose(fp);
+   return 0;
+   }
+
+   lzma_filter filter = { .id = LZMA_FILTER_LZMA1 };
+
+   switch (lzma_properties_decode(&filter, NULL, buf, 5)) {
+   case LZMA_OK:
+   ret = 1;
+   break;
+   default:
+   /* It's not a lzma file */
+   ret = 0;
+   }
+
+   fclose(fp);
+   return ret;
+}
+
 char *lzma_decompress_file(const char *filename, off_t *r_size)
 {
LZFILE *fp;
@@ -168,6 +204,9 @@ char *lzma_decompress_file(const char *filename, off_t 
*r_size)
if (!filename)
return NULL;
 
+   if (!is_lzma_file(filename))
+   return NULL;
+
fp = lzopen(filename, "rb");
if (fp == 0) {
dbgprintf("Cannot open `%s'\n", filename);
-- 
2.27.0


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH] kexec-tools: Determine if the image is lzma commpressed

2022-03-29 Thread Lichen Liu
Thank you, Martin!
I'll post a new version to fix it.


On Wed, Mar 30, 2022 at 10:10 AM Martin Faltesek  wrote:
>
> Sorry I don't have overall observations about this patch. But saw
> missing fclose after size != 13.
>
> On Fri, Mar 25, 2022 at 2:09 AM Lichen Liu  wrote:
> >
> > Currently there are 2 functions for decompressing compressed image. The
> > zlib_decompress_file() will determine if the image is compressed by gzip
> > before read, but lzma_decompress_file() will not. This can cause misleading
> > information to be printed when the image is not compressed by lzma and
> > debug option is used:
> >
> > ]# kexec -d -s -l /boot/vmlinuz-5.14.10-300.fc35.x86_64 \
> > --initrd /boot/initramfs-5.14.10-300.fc35.x86_64.img \
> > --reuse-cmdline
> > Try gzip decompression.
> > Try LZMA decompression.
> > lzma_decompress_file: read on /boot/vmlinuz-5.14.10-300.fc35.x86_64 of
> > 65536 bytes failed
> >
> > Add a helper function is_lzma_file() to help behave consistently.
> >
> > Signed-off-by: Lichen Liu 
> > ---
> >  kexec/lzma.c | 36 
> >  1 file changed, 36 insertions(+)
> >
> > diff --git a/kexec/lzma.c b/kexec/lzma.c
> > index 5bfccb7..f27cfe2 100644
> > --- a/kexec/lzma.c
> > +++ b/kexec/lzma.c
> > @@ -155,6 +155,39 @@ ssize_t lzread(LZFILE *lzfile, void *buf, size_t len)
> > }
> >  }
> >
> > +int is_lzma_file(const char *filename)
> > +{
> > +   FILE *fp;
> > +   int ret = 0;
> > +   uint8_t buf[13];
> > +
> > +   if (!filename)
> > +   return 0;
> > +
> > +   fp = fopen(filename, "r");
> > +   if (fp == NULL)
> > +   return 0;
> > +
> > +   const size_t size = fread(buf, 1, sizeof(buf), fp);
> > +
> > +   if (size != 13)
> > +   return 0;
> > +
> > +   lzma_filter filter = { .id = LZMA_FILTER_LZMA1 };
> > +
> > +   switch (lzma_properties_decode(&filter, NULL, buf, 5)) {
> > +   case LZMA_OK:
> > +   ret = 1;
> > +   break;
> > +   default:
> > +   /* It's not a lzma file */
> > +   ret = 0;
> > +   }
> > +
> > +   fclose(fp);
> > +   return ret;
> > +}
> > +
> >  char *lzma_decompress_file(const char *filename, off_t *r_size)
> >  {
> > LZFILE *fp;
> > @@ -168,6 +201,9 @@ char *lzma_decompress_file(const char *filename, off_t 
> > *r_size)
> > if (!filename)
> > return NULL;
> >
> > +   if (!is_lzma_file(filename))
> > +   return NULL;
> > +
> > fp = lzopen(filename, "rb");
> > if (fp == 0) {
> > dbgprintf("Cannot open `%s'\n", filename);
> > --
> > 2.27.0
> >
> >
> > ___
> > kexec mailing list
> > kexec@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/kexec
>


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


  1   2   3   4   5   6   7   8   9   10   >