Re: [PATCH v2 2/2] kexec_file: Increase maximum file size to 4G

2022-06-07 Thread Pasha Tatashin
On Sun, Jun 5, 2022 at 10:56 PM Baoquan He wrote: > > On 05/27/22 at 02:55am, Pasha Tatashin wrote: > > In some case initrd can be large. For example, it could be a netboot > > image loaded by u-root, that is kexec'ing into it. > > > > The maximum size of initr

Re: [PATCH v2 1/2] fs/kernel_read_file: Allow to read files up-to ssize_t

2022-06-07 Thread Pasha Tatashin
On Sun, Jun 5, 2022 at 10:45 PM Baoquan He wrote: > > On 05/27/22 at 02:55am, Pasha Tatashin wrote: > > Currently, the maximum file size that is supported is 2G. This may be > > too small in some cases. For example, kexec_file_load() system call > > loads initramf

[PATCH v2 0/2] Allow to kexec with initramfs larger than 2G

2022-05-26 Thread Pasha Tatashin
than 2G. The first patch changes the return type from int to ssize_t in kernel_read_file* functions. The second patch increases the maximum initramfs file size to 4G. Tested: verified that can kexec_file_load() works with 4G initramfs on x86_64. Pasha Tatashin (2): fs/kernel_read_file: Allow to

[PATCH v2 1/2] fs/kernel_read_file: Allow to read files up-to ssize_t

2022-05-26 Thread Pasha Tatashin
buf_size. Signed-off-by: Pasha Tatashin --- fs/kernel_read_file.c| 38 include/linux/kernel_read_file.h | 32 +-- include/linux/limits.h | 1 + 3 files changed, 36 insertions(+), 35 deletions(-) diff --git a/fs

[PATCH v2 2/2] kexec_file: Increase maximum file size to 4G

2022-05-26 Thread Pasha Tatashin
ke it LONG_MAX, but it is safer to keep it sane, and just increase it to 4G. Increase the size to 4G, and make it obvious by having a new macro that specifies the maximum file size supported by kexec_file_load() syscall: KEXEC_FILE_SIZE_MAX. Signed-off-by: Pasha Tatashin --- kernel/kexec_file.c

Re: [PATCH] kexec_file: Increase maximum file size to 4G

2022-05-26 Thread Pasha Tatashin
On Thu, May 26, 2022 at 4:45 PM Pasha Tatashin wrote: > > On Thu, May 26, 2022 at 4:38 PM Pasha Tatashin > wrote: > > > > In some case initrd can be large. For example, it could be a netboot > > image loaded by u-root, that is kexec'ing into it. > > >

Re: [PATCH] kexec_file: Increase maximum file size to 4G

2022-05-26 Thread Pasha Tatashin
On Thu, May 26, 2022 at 4:38 PM Pasha Tatashin wrote: > > In some case initrd can be large. For example, it could be a netboot > image loaded by u-root, that is kexec'ing into it. > > The maximum size of initrd is arbitrary set to 2G. Also, the limit is > not very obvio

[PATCH] kexec_file: Increase maximum file size to 4G

2022-05-26 Thread Pasha Tatashin
ke it LONG_MAX, but it is safer to keep it sane, and just increase it to 4G. Increase the size to 4G, and make it obvious by having a new macro that specifies the maximum file size supported by kexec_file_load() syscall: KEXEC_FILE_SIZE_MAX. Signed-off-by: Pasha Tatashin --- kernel/kexec_file.

[PATCH v18 15/15] arm64: trans_pgd: remove trans_pgd_map_page()

2021-09-30 Thread Pasha Tatashin
The intend of trans_pgd_map_page() was to map contiguous range of VA memory to the memory that is getting relocated during kexec. However, since we are now using linear map instead of contiguous range this function is not needed Suggested-by: Pingfan Liu Signed-off-by: Pasha Tatashin Acked-by

[PATCH v18 14/15] arm64: kexec: remove cpu-reset.h

2021-09-30 Thread Pasha Tatashin
This header contains only cpu_soft_restart() which is never used directly anymore. So, remove this header, and rename the helper to be cpu_soft_restart(). Suggested-by: James Morse Signed-off-by: Pasha Tatashin Acked-by: Catalin Marinas --- arch/arm64/include/asm/kexec.h| 6 ++ arch

[PATCH v18 13/15] arm64: kexec: remove the pre-kexec PoC maintenance

2021-09-30 Thread Pasha Tatashin
Now that kexec does its relocations with the MMU enabled, we no longer need to clean the relocation data to the PoC. Suggested-by: James Morse Signed-off-by: Pasha Tatashin Acked-by: Catalin Marinas --- arch/arm64/kernel/machine_kexec.c | 43 --- 1 file changed, 43

[PATCH v18 12/15] arm64: kexec: keep MMU enabled during kexec relocation

2021-09-30 Thread Pasha Tatashin
second. Signed-off-by: Pasha Tatashin Tested-by: Pingfan Liu Acked-by: Catalin Marinas --- arch/arm64/include/asm/kexec.h | 3 +++ arch/arm64/kernel/asm-offsets.c | 1 + arch/arm64/kernel/machine_kexec.c | 16 +++ arch/arm64/kernel/relocate_kernel.S | 31

[PATCH v18 09/15] arm64: kexec: relocate in EL1 mode

2021-09-30 Thread Pasha Tatashin
Since we are going to keep MMU enabled during relocation, we need to keep EL1 mode throughout the relocation. Keep EL1 enabled, and switch EL2 only before entering the new world. Suggested-by: James Morse Signed-off-by: Pasha Tatashin Acked-by: Catalin Marinas --- arch/arm64/kernel/cpu

[PATCH v18 10/15] arm64: kexec: use ld script for relocation function

2021-09-30 Thread Pasha Tatashin
Currently, relocation code declares start and end variables which are used to compute its size. The better way to do this is to use ld script, and put relocation function in its own section. Signed-off-by: Pasha Tatashin Acked-by: Catalin Marinas --- arch/arm64/include/asm/sections.h | 1

[PATCH v18 11/15] arm64: kexec: install a copy of the linear-map

2021-09-30 Thread Pasha Tatashin
n the mapping it is executing from. The makes no difference yet as the relocation code runs with the MMU disabled. Suggested-by: James Morse Signed-off-by: Pasha Tatashin Acked-by: Catalin Marinas --- arch/arm64/include/asm/assembler.h | 19 +++ arch/arm64/include/asm/ke

[PATCH v18 08/15] arm64: kexec: configure EL2 vectors for kexec

2021-09-30 Thread Pasha Tatashin
is provided by trans_pgd_copy_el2_vectors() to support this case. Signed-off-by: Pasha Tatashin Acked-by: Catalin Marinas --- arch/arm64/Kconfig| 2 +- arch/arm64/include/asm/kexec.h| 1 + arch/arm64/kernel/asm-offsets.c | 1 + arch/arm64/kernel/machine_kexec.c | 31

[PATCH v18 07/15] arm64: kexec: pass kimage as the only argument to relocation function

2021-09-30 Thread Pasha Tatashin
more arguments: once we enable MMU we will need to pass information about page tables. Pass kimage to arm64_relocate_new_kernel, and teach it to get the required fields from kimage. Signed-off-by: Pasha Tatashin Acked-by: Catalin Marinas --- arch/arm64/kernel/asm-offsets.c | 7 +++ arch

[PATCH v18 06/15] arm64: kexec: Use dcache ops macros instead of open-coding

2021-09-30 Thread Pasha Tatashin
generated by the existing callers is unchanged. Suggested-by: James Morse Signed-off-by: Pasha Tatashin Acked-by: Catalin Marinas --- arch/arm64/include/asm/assembler.h | 30 ++--- arch/arm64/kernel/relocate_kernel.S | 13 +++-- 2 files changed, 26 insertions

[PATCH v18 05/15] arm64: kexec: skip relocation code for inplace kexec

2021-09-30 Thread Pasha Tatashin
In case of kdump or when segments are already in place the relocation is not needed, therefore the setup of relocation function and call to it can be skipped. Signed-off-by: Pasha Tatashin Suggested-by: James Morse Acked-by: Catalin Marinas --- arch/arm64/kernel/machine_kexec.c | 34

[PATCH v18 01/15] arm64: kernel: add helper for booted at EL2 and not VHE

2021-09-30 Thread Pasha Tatashin
Replace places that contain logic like this: is_hyp_mode_available() && !is_kernel_in_hyp_mode() With a dedicated boolean function is_hyp_nvhe(). This will be needed later in kexec in order to sooner switch back to EL2. Suggested-by: James Morse Signed-off-by: Pasha Tatashin

[PATCH v18 04/15] arm64: kexec: flush image and lists during kexec load time

2021-09-30 Thread Pasha Tatashin
Currently, during kexec load we are copying relocation function and flushing it. However, we can also flush kexec relocation buffers and if new kernel image is already in place (i.e. crash kernel), we can also flush the new kernel image itself. Signed-off-by: Pasha Tatashin Acked-by: Catalin

[PATCH v18 02/15] arm64: trans_pgd: hibernate: Add trans_pgd_copy_el2_vectors

2021-09-30 Thread Pasha Tatashin
Users of trans_pgd may also need a copy of vector table because it is also may be overwritten if a linear map can be overwritten. Move setup of EL2 vectors from hibernate to trans_pgd, so it can be later shared with kexec as well. Signed-off-by: Pasha Tatashin Acked-by: Catalin Marinas

[PATCH v18 03/15] arm64: hibernate: abstract ttrb0 setup function

2021-09-30 Thread Pasha Tatashin
Currently, only hibernate sets custom ttbr0 with safe idmaped function. Kexec, is also going to be using this functionality when relocation code is going to be idmapped. Move the setup sequence to a dedicated cpu_install_ttbr0() for custom ttbr0. Suggested-by: James Morse Signed-off-by: Pasha

[PATCH v18 00/15] arm64: MMU enabled kexec relocation

2021-09-30 Thread Pasha Tatashin
rnel.org/lkml/20190923203427.294286-1-pasha.tatas...@soleen.com v4: https://lore.kernel.org/lkml/20190909181221.309510-1-pasha.tatas...@soleen.com v3: https://lore.kernel.org/lkml/20190821183204.23576-1-pasha.tatas...@soleen.com v2: https://lore.kernel.org/lkml/20190817024629.26611-1-pasha.tatas.

Re: [PATCH v17 08/15] arm64: kexec: configure EL2 vectors for kexec

2021-09-30 Thread Pasha Tatashin
On Thu, Sep 30, 2021 at 4:16 AM Will Deacon wrote: > > On Wed, Sep 29, 2021 at 11:54:55PM -0400, Pasha Tatashin wrote: > > > > +/* Allocates pages for kexec page table */ > > > > +static void *kexec_page_alloc(void *arg) > > > > +{ > > > &

Re: [PATCH v17 00/15] arm64: MMU enabled kexec relocation

2021-09-29 Thread Pasha Tatashin
> FWIW, I'm fine with this series. I think the only concern raised by > James and not addressed is the possibility of the failure of the memory > allocation for copying the page tables during kexec. If anyone will > complain in the future, we can look into adding a fallback mechanism to > do the re

Re: [PATCH v17 00/15] arm64: MMU enabled kexec relocation

2021-09-29 Thread Pasha Tatashin
On Wed, Sep 29, 2021 at 8:49 AM Will Deacon wrote: > > On Thu, Sep 16, 2021 at 07:13:10PM -0400, Pasha Tatashin wrote: > > Changelog: > > v17: > > - Merged with 5.15-rc1 as requested by Catalin Marinas > > - Added Tested-by: Pingfan Liu > > Thi

Re: [PATCH v17 15/15] arm64: trans_pgd: remove trans_pgd_map_page()

2021-09-29 Thread Pasha Tatashin
On Wed, Sep 29, 2021 at 12:43 PM Catalin Marinas wrote: > > On Thu, Sep 16, 2021 at 07:13:25PM -0400, Pasha Tatashin wrote: > > The intend of trans_pgd_map_page() was to map contiguous range of VA > > memory to the memory that is getting relocated during kexec. However, > >

Re: [PATCH v17 10/15] arm64: kexec: use ld script for relocation function

2021-09-29 Thread Pasha Tatashin
Sorry, missed two comments: > > /* Flush the reloc_code in preparation for its execution. */ > > dcache_clean_inval_poc((unsigned long)reloc_code, > > -(unsigned long)reloc_code + > > -arm64_relocate_new_kernel_size); > > +

Re: [PATCH v17 10/15] arm64: kexec: use ld script for relocation function

2021-09-29 Thread Pasha Tatashin
On Wed, Sep 29, 2021 at 8:45 AM Will Deacon wrote: > > On Thu, Sep 16, 2021 at 07:13:20PM -0400, Pasha Tatashin wrote: > > Currently, relocation code declares start and end variables > > which are used to compute its size. > > > > The better way to do this is to

Re: [PATCH v17 08/15] arm64: kexec: configure EL2 vectors for kexec

2021-09-29 Thread Pasha Tatashin
> > +/* Allocates pages for kexec page table */ > > +static void *kexec_page_alloc(void *arg) > > +{ > > + struct kimage *kimage = (struct kimage *)arg; > > + struct page *page = kimage_alloc_control_pages(kimage, 0); > > + > > + if (!page) > > + return NULL; > > + > > +

Re: [PATCH v17 05/15] arm64: kexec: skip relocation code for inplace kexec

2021-09-29 Thread Pasha Tatashin
Hi Will, > > + cpu_install_idmap(); > > + restart = (void > > *)__pa_symbol(function_nocfi(__cpu_soft_restart)); > > + restart(is_hyp_nvhe(), kimage->start, kimage->arch.dtb_mem, > > + 0, 0); > > Why can't you call: > > cpu_soft_rest

[PATCH v17 15/15] arm64: trans_pgd: remove trans_pgd_map_page()

2021-09-16 Thread Pasha Tatashin
The intend of trans_pgd_map_page() was to map contiguous range of VA memory to the memory that is getting relocated during kexec. However, since we are now using linear map instead of contiguous range this function is not needed Suggested-by: Pingfan Liu Signed-off-by: Pasha Tatashin --- arch

[PATCH v17 14/15] arm64: kexec: remove cpu-reset.h

2021-09-16 Thread Pasha Tatashin
This header contains only cpu_soft_restart() which is never used directly anymore. So, remove this header, and rename the helper to be cpu_soft_restart(). Suggested-by: James Morse Signed-off-by: Pasha Tatashin --- arch/arm64/include/asm/kexec.h| 6 ++ arch/arm64/kernel/cpu-reset.S

[PATCH v17 11/15] arm64: kexec: install a copy of the linear-map

2021-09-16 Thread Pasha Tatashin
n the mapping it is executing from. The makes no difference yet as the relocation code runs with the MMU disabled. Suggested-by: James Morse Signed-off-by: Pasha Tatashin --- arch/arm64/include/asm/assembler.h | 19 +++ arch/arm64/include/asm/kexec.h | 2 ++ arch/arm64/k

[PATCH v17 12/15] arm64: kexec: keep MMU enabled during kexec relocation

2021-09-16 Thread Pasha Tatashin
second. Signed-off-by: Pasha Tatashin Tested-by: Pingfan Liu --- arch/arm64/include/asm/kexec.h | 3 +++ arch/arm64/kernel/asm-offsets.c | 1 + arch/arm64/kernel/machine_kexec.c | 16 +++ arch/arm64/kernel/relocate_kernel.S | 31 +++-- 4 files

[PATCH v17 13/15] arm64: kexec: remove the pre-kexec PoC maintenance

2021-09-16 Thread Pasha Tatashin
Now that kexec does its relocations with the MMU enabled, we no longer need to clean the relocation data to the PoC. Suggested-by: James Morse Signed-off-by: Pasha Tatashin --- arch/arm64/kernel/machine_kexec.c | 43 --- 1 file changed, 43 deletions(-) diff --git a

[PATCH v17 10/15] arm64: kexec: use ld script for relocation function

2021-09-16 Thread Pasha Tatashin
Currently, relocation code declares start and end variables which are used to compute its size. The better way to do this is to use ld script incited, and put relocation function in its own section. Signed-off-by: Pasha Tatashin --- arch/arm64/include/asm/sections.h | 1 + arch/arm64/kernel

[PATCH v17 09/15] arm64: kexec: relocate in EL1 mode

2021-09-16 Thread Pasha Tatashin
Since we are going to keep MMU enabled during relocation, we need to keep EL1 mode throughout the relocation. Keep EL1 enabled, and switch EL2 only before entering the new world. Suggested-by: James Morse Signed-off-by: Pasha Tatashin --- arch/arm64/kernel/cpu-reset.h | 3 +-- arch

[PATCH v17 03/15] arm64: hibernate: abstract ttrb0 setup function

2021-09-16 Thread Pasha Tatashin
Currently, only hibernate sets custom ttbr0 with safe idmaped function. Kexec, is also going to be using this functionality when relocation code is going to be idmapped. Move the setup sequence to a dedicated cpu_install_ttbr0() for custom ttbr0. Suggested-by: James Morse Signed-off-by: Pasha

[PATCH v17 08/15] arm64: kexec: configure EL2 vectors for kexec

2021-09-16 Thread Pasha Tatashin
is provided by trans_pgd_copy_el2_vectors() to support this case. Signed-off-by: Pasha Tatashin --- arch/arm64/Kconfig| 2 +- arch/arm64/include/asm/kexec.h| 1 + arch/arm64/kernel/asm-offsets.c | 1 + arch/arm64/kernel/machine_kexec.c | 31

[PATCH v17 07/15] arm64: kexec: pass kimage as the only argument to relocation function

2021-09-16 Thread Pasha Tatashin
more arguments: once we enable MMU we will need to pass information about page tables. Pass kimage to arm64_relocate_new_kernel, and teach it to get the required fields from kimage. Signed-off-by: Pasha Tatashin --- arch/arm64/kernel/asm-offsets.c | 7 +++ arch/arm64/kernel/machine_kexec.c

[PATCH v17 06/15] arm64: kexec: Use dcache ops macros instead of open-coding

2021-09-16 Thread Pasha Tatashin
generated by the existing callers is unchanged. Suggested-by: James Morse Signed-off-by: Pasha Tatashin --- arch/arm64/include/asm/assembler.h | 30 ++--- arch/arm64/kernel/relocate_kernel.S | 13 +++-- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git

[PATCH v17 04/15] arm64: kexec: flush image and lists during kexec load time

2021-09-16 Thread Pasha Tatashin
Currently, during kexec load we are copying relocation function and flushing it. However, we can also flush kexec relocation buffers and if new kernel image is already in place (i.e. crash kernel), we can also flush the new kernel image itself. Signed-off-by: Pasha Tatashin --- arch/arm64

[PATCH v17 02/15] arm64: trans_pgd: hibernate: Add trans_pgd_copy_el2_vectors

2021-09-16 Thread Pasha Tatashin
Users of trans_pgd may also need a copy of vector table because it is also may be overwritten if a linear map can be overwritten. Move setup of EL2 vectors from hibernate to trans_pgd, so it can be later shared with kexec as well. Signed-off-by: Pasha Tatashin --- arch/arm64/include/asm

[PATCH v17 01/15] arm64: kernel: add helper for booted at EL2 and not VHE

2021-09-16 Thread Pasha Tatashin
Replace places that contain logic like this: is_hyp_mode_available() && !is_kernel_in_hyp_mode() With a dedicated boolean function is_hyp_nvhe(). This will be needed later in kexec in order to sooner switch back to EL2. Suggested-by: James Morse Signed-off-by: Pasha Tatashin -

[PATCH v17 00/15] arm64: MMU enabled kexec relocation

2021-09-16 Thread Pasha Tatashin
rg/lkml/20190821183204.23576-1-pasha.tatas...@soleen.com v2: https://lore.kernel.org/lkml/20190817024629.26611-1-pasha.tatas...@soleen.com v1: https://lore.kernel.org/lkml/20190801152439.11363-1-pasha.tatas...@soleen.com Pasha Tatashin (15): arm64: kernel: add helper for booted at EL2 and not VHE arm6

[PATCH v17 05/15] arm64: kexec: skip relocation code for inplace kexec

2021-09-16 Thread Pasha Tatashin
In case of kdump or when segments are already in place the relocation is not needed, therefore the setup of relocation function and call to it can be skipped. Signed-off-by: Pasha Tatashin Suggested-by: James Morse --- arch/arm64/kernel/machine_kexec.c | 34

Re: [PATCH v16 00/15] arm64: MMU enabled kexec relocation

2021-09-16 Thread Pasha Tatashin
> > In case we are so low on memory that trans_pgd_create_copy() fails to > > allocate the linear map that uses the large pages (the size of the > > page table is tiny) the kexec fails during kexec load time (not during > > reboot time), as out of memory. The MMU enabled kexec reboot is always > >