[RFC PATCH v3 07/20] x86/kexec: Copy control page into place in machine_kexec_prepare()
David Woodhouse
dwmw2 at infradead.org
Mon Nov 25 01:54:37 PST 2024
From: David Woodhouse <dwmw at amazon.co.uk>
There's no need for this to wait until the actual machine_kexec() invocation;
future changes will need to make the control page read-only and executable,
so all writes should be completed before machine_kexec_prepare() returns.
Signed-off-by: David Woodhouse <dwmw at amazon.co.uk>
---
arch/x86/kernel/machine_kexec_64.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index c9ae65c9a27c..431a117f3fb3 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -307,17 +307,16 @@ static void load_segments(void)
int machine_kexec_prepare(struct kimage *image)
{
- unsigned long control_page;
+ void *control_page = page_address(image->control_code_page);
int result;
- /* Calculate the offsets */
- control_page = page_to_pfn(image->control_code_page) << PAGE_SHIFT;
-
/* Setup the identity mapped 64bit page table */
- result = init_pgtable(image, control_page);
+ result = init_pgtable(image, __pa(control_page));
if (result)
return result;
+ __memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
+
return 0;
}
@@ -369,7 +368,6 @@ void machine_kexec(struct kimage *image)
}
control_page = page_address(image->control_code_page);
- __memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
page_list[PA_CONTROL_PAGE] = virt_to_phys(control_page);
page_list[VA_CONTROL_PAGE] = (unsigned long)control_page;
--
2.47.0
More information about the kexec
mailing list