Skip to content

Commit 6a750b4

Browse files
dwmw2Ingo Molnar
authored andcommitted
x86/kexec: Copy control page into place in machine_kexec_prepare()
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 <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Baoquan He <[email protected]> Cc: Vivek Goyal <[email protected]> Cc: Dave Young <[email protected]> Cc: Eric Biederman <[email protected]> Cc: Ard Biesheuvel <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4b5bc2e commit 6a750b4

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

arch/x86/kernel/machine_kexec_64.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,17 +301,16 @@ static void load_segments(void)
301301

302302
int machine_kexec_prepare(struct kimage *image)
303303
{
304-
unsigned long control_page;
304+
void *control_page = page_address(image->control_code_page);
305305
int result;
306306

307-
/* Calculate the offsets */
308-
control_page = page_to_pfn(image->control_code_page) << PAGE_SHIFT;
309-
310307
/* Setup the identity mapped 64bit page table */
311-
result = init_pgtable(image, control_page);
308+
result = init_pgtable(image, __pa(control_page));
312309
if (result)
313310
return result;
314311

312+
__memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
313+
315314
return 0;
316315
}
317316

@@ -363,7 +362,6 @@ void machine_kexec(struct kimage *image)
363362
}
364363

365364
control_page = page_address(image->control_code_page);
366-
__memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
367365

368366
page_list[PA_CONTROL_PAGE] = virt_to_phys(control_page);
369367
page_list[VA_CONTROL_PAGE] = (unsigned long)control_page;

0 commit comments

Comments
 (0)