Re: [PATCH v1 3/4] memblock: add MEMBLOCK_DRIVER_MANAGED to mimic IORESOURCE_SYSRAM_DRIVER_MANAGED

2021-09-30 Thread Mike Rapoport
On Wed, Sep 29, 2021 at 06:54:01PM +0200, David Hildenbrand wrote: > On 29.09.21 18:39, Mike Rapoport wrote: > > Hi, > > > > On Mon, Sep 27, 2021 at 05:05:17PM +0200, David Hildenbrand wrote: > > > Let's add a flag that corresponds to IORESOURCE_SYSRAM_DRIVER_MANAGED. > > > Similar to

[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 ++

[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
Now, that we have linear map page tables configured, keep MMU enabled to allow faster relocation of segments to final destination. Cavium ThunderX2: Kernel Image size: 38M Iniramfs size: 46M Total relocation size: 84M MMU-disabled: relocation 7.489539915s MMU-enabled: relocation

[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 ---

[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
To perform the kexec relocation with the MMU enabled, we need a copy of the linear map. Create one, and install it from the relocation code. This has to be done from the assembly code as it will be idmapped with TTBR0. The kernel runs in TTRB1, so can't use the break-before-make sequence on the

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

2021-09-30 Thread Pasha Tatashin
If we have a EL2 mode without VHE, the EL2 vectors are needed in order to switch to EL2 and jump to new world with hypervisor privileges. In preparation to MMU enabled relocation, configure our EL2 table now. Kexec uses #HVC_SOFT_RESTART to branch to the new world, so extend el1_sync vector that

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

2021-09-30 Thread Pasha Tatashin
Currently, kexec relocation function (arm64_relocate_new_kernel) accepts the following arguments: head: start of array that contains relocation information. entry: entry point for new kernel or purgatory. dtb_mem:first and only argument to entry. The number of

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

2021-09-30 Thread Pasha Tatashin
kexec does dcache maintenance when it re-writes all memory. Our dcache_by_line_op macro depends on reading the sanitized DminLine from memory. Kexec may have overwritten this, so open-codes the sequence. dcache_by_line_op is a whole set of macros, it uses dcache_line_size which uses read_ctr for

[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 Acked-by:

[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
Changelog: v18: - Addressed comments from Will Deacon - Added Acks from Catalin Marinas v17: - Merged with 5.15-rc1 as requested by Catalin Marinas - Added Tested-by: Pingfan Liu v16: - Merged with 5.14-rc4 v15: - Changed

Re: [PATCH 1/2] kexec, KEYS: make the code in bzImage64_verify_sig public

2021-09-30 Thread Dave Young
On 09/30/21 at 08:49pm, Dave Young wrote: > Hi Coiby, > On 09/27/21 at 08:50am, Coiby Xu wrote: > > From: Coiby Xu > > > > The code in bzImage64_verify_sig could make use of system keyrings including > > .buitin_trusted_keys, .secondary_trusted_keys and .platform keyring to > > verify > >

Re: [PATCH 1/2] kexec, KEYS: make the code in bzImage64_verify_sig public

2021-09-30 Thread Dave Young
Hi Coiby, On 09/27/21 at 08:50am, Coiby Xu wrote: > From: Coiby Xu > > The code in bzImage64_verify_sig could make use of system keyrings including > .buitin_trusted_keys, .secondary_trusted_keys and .platform keyring to verify > signed kernel image as PE file. Move it to a public function. > >

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) > > > > +{ > > > > + struct kimage *kimage = (struct kimage *)arg; > > >

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

2021-09-30 Thread Will Deacon
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) > > > +{ > > > + struct kimage *kimage = (struct kimage *)arg; > > > + struct page *page = kimage_alloc_control_pages(kimage,