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

2021-08-02 Thread Pavel 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: Pavel Tatashin ---

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

2021-08-02 Thread Pavel 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: Pavel Tatashin --- arch/arm64/include/asm/kexec.h| 6 ++ arch/arm64/kernel/cpu-reset.S

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

2021-08-02 Thread Pavel 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 v16 13/15] arm64: kexec: remove the pre-kexec PoC maintenance

2021-08-02 Thread Pavel 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: Pavel Tatashin --- arch/arm64/kernel/machine_kexec.c | 43 --- 1 file changed, 43 deletions(-) diff --git

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

2021-08-02 Thread Pavel 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: Pavel Tatashin --- arch/arm64/include/asm/sections.h | 1 +

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

2021-08-02 Thread Pavel 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 v16 09/15] arm64: kexec: relocate in EL1 mode

2021-08-02 Thread Pavel 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: Pavel Tatashin --- arch/arm64/kernel/cpu-reset.h | 3 +--

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

2021-08-02 Thread Pavel 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 v16 06/15] arm64: kexec: Use dcache ops macros instead of open-coding

2021-08-02 Thread Pavel 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 v16 05/15] arm64: kexec: skip relocation code for inplace kexec

2021-08-02 Thread Pavel 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: Pavel Tatashin Suggested-by: James Morse --- arch/arm64/kernel/machine_kexec.c | 34 ++---

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

2021-08-02 Thread Pavel 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 v16 04/15] arm64: kexec: flush image and lists during kexec load time

2021-08-02 Thread Pavel 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: Pavel Tatashin ---

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

2021-08-02 Thread Pavel Tatashin
Changelog: v16: - Merged with 5.14-rc4 v15: - Changed trans_pgd_copy_el2_vectors() to use vector table that only shared by kexec and hibernate. This way sync does not have dangling branch that was recently introduced. (Reported by Marc Zyngier)

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

2021-08-02 Thread Pavel 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: Pavel Tatashin ---

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

2021-08-02 Thread Pavel 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: Pavel Tatashin ---

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

2021-08-02 Thread Pavel 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: Pavel

Re: [PATCH 07/11] treewide: Replace the use of mem_encrypt_active() with prot_guest_has()

2021-08-02 Thread Christophe Leroy
Le 28/07/2021 à 00:26, Tom Lendacky a écrit : Replace occurrences of mem_encrypt_active() with calls to prot_guest_has() with the PATTR_MEM_ENCRYPT attribute. What about https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20210730114231.23445-1-w...@kernel.org/ ? Christophe Cc: