Thread (45 messages) 45 messages, 3 authors, 2021-01-25

Re: [PATCH v9 08/18] arm64: kexec: move relocation function setup

From: Pavel Tatashin <pasha.tatashin@soleen.com>
Date: 2021-01-23 01:03:47
Also in: kexec, linux-mm, lkml

On Wed, Apr 29, 2020 at 1:01 PM James Morse [off-list ref] wrote:
Hi Pavel,

On 26/03/2020 03:24, Pavel Tatashin wrote:
quoted
Currently, kernel relocation function is configured in machine_kexec()
at the time of kexec reboot by using control_code_page.

This operation, however, is more logical to be done during kexec_load,
and thus remove from reboot time. Move, setup of this function to
newly added machine_kexec_post_load().
This would avoid the need to special-case the cache maintenance, so its a good cleanup...
Yes, the computation should be moved from kexec-reboot to kexec-load
when possible.
quoted
Because once MMU is enabled, kexec control page will contain more than
relocation kernel, but also vector table, add pointer to the actual
function within this page arch.kern_reloc. Currently, it equals to the
beginning of page, we will add offsets later, when vector table is
added.
If the vector table always comes second, wouldn't this be extra work to hold the value 0?
You can control the layout of this relocation code, as it has to be written in assembly.
I don't get why this would be necessary.

quoted
diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c
index ae1bad0156cd..ec71a153cc2d 100644
--- a/arch/arm64/kernel/machine_kexec.c
+++ b/arch/arm64/kernel/machine_kexec.c
@@ -58,6 +59,17 @@ void machine_kexec_cleanup(struct kimage *kimage)
      /* Empty routine needed to avoid build errors. */
 }

+int machine_kexec_post_load(struct kimage *kimage)
+{
+     void *reloc_code = page_to_virt(kimage->control_code_page);
+
+     memcpy(reloc_code, arm64_relocate_new_kernel,
+            arm64_relocate_new_kernel_size);
+     kimage->arch.kern_reloc = __pa(reloc_code);
Could we move the two cache maintenance calls for this area in here too. Keeping it next
to the modification makes it clearer why it is required.
Yes, I moved it.
In this case we can use flush_icache_range() instead of its __variant because this now
happens much earlier.
True.
quoted
+     return 0;
+}
Regardless,
Reviewed-by: James Morse <james.morse@arm.com>
Thank you for your review.

Pasha

Thanks,

James
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help