Commit 6a750b4c authored by David Woodhouse's avatar David Woodhouse Committed by Ingo Molnar
Browse files

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: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Link: https://lore.kernel.org/r/20241205153343.3275139-7-dwmw2@infradead.org
parent 4b5bc2ec
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -301,17 +301,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;
}

@@ -363,7 +362,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;