From nobody Thu Dec 18 09:42:56 2025 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C296221465 for ; Thu, 5 Dec 2024 15:34:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733412846; cv=none; b=FHgvonXTpp29POr8zIccbFv057yah12117Epa35PyajGZC/3Nq3Pxq6YyQcEQuDUY8iLscsQLTKsWG7XNVti57xxF4GtATjjzoRde91I+AHks8ne/1Su24AeICJUBIeFDKl+MFJXzi38l4tnCmhIBdQaZViZaTf3Qamh0b2BmHU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733412846; c=relaxed/simple; bh=FW6hMMPLyhwrarG5r0mql4WfDEvwbKU+qaIi/tENEuY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PNjFEHnpitSykxm4UZ1acpE2hz5Eg17kDJigv5gMoj+zkKoc/vzSRN6TlK6/cndQXcqid8hZrRbuki0gvFZuzQqhzOk1CCwjmRGy9cLPVfOmVwTCs07/icCVKxgqpPFm9hq6nD55gOcV7Wa1QxKNssIBSem2K7tuKMTikcf9nyM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=casper.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=lweXdCsw; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=casper.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="lweXdCsw" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=0nLJBUlnC0lJdbTn9E+DJez294BNmSeUZNgs1SMEfHk=; b=lweXdCswCNPW2EfnfW6TaV1ko0 cTHHM8cRL4S4SDShxpwDTUd2ZRWm2VZRr8jJF8OcndyMxCxjLP3bzSjj6JJSnYF3S1JbGX+4/9sqg s3i22oE03WbqTko+X1uLRLmvZFHmoDoAbXVdo+yytEeSgcBSVGnUwGSH3LbRIit1V0Mrvd57dK+KR WXc0/YqYHciV5MsOCGBpXnX36zqpefrf+FVCLBbOWJFVS6+6OFWdztWsx4E2UzS5SMRKT8AspwfmB sF1jrbEJf1MUTi/nDKGN/m8dkdKYLzyELfZO3EtgPpNToE7HgkIqCOIJJMdag35fVThsIbRmwZkmA yyDoCFdw==; Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by casper.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tJDrM-0000000DDp0-1cQ3; Thu, 05 Dec 2024 15:33:45 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJDrN-0000000DyLX-1p5X; Thu, 05 Dec 2024 15:33:45 +0000 From: David Woodhouse To: kexec@lists.infradead.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , David Woodhouse , "Kirill A. Shutemov" , Kai Huang , Nikolay Borisov , linux-kernel@vger.kernel.org, Simon Horman , Dave Young , Peter Zijlstra , jpoimboe@kernel.org, bsz@amazon.de Subject: [PATCH v5 06/20] x86/kexec: Copy control page into place in machine_kexec_prepare() Date: Thu, 5 Dec 2024 15:05:12 +0000 Message-ID: <20241205153343.3275139-7-dwmw2@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205153343.3275139-1-dwmw2@infradead.org> References: <20241205153343.3275139-1-dwmw2@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Content-Type: text/plain; charset="utf-8" From: David Woodhouse There's no need for this to wait until the actual machine_kexec() invocatio= n; 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 --- 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_k= exec_64.c index 7223c38a8708..3a4cbac1a0c6 100644 --- a/arch/x86/kernel/machine_kexec_64.c +++ b/arch/x86/kernel/machine_kexec_64.c @@ -301,17 +301,16 @@ static void load_segments(void) =20 int machine_kexec_prepare(struct kimage *image) { - unsigned long control_page; + void *control_page =3D page_address(image->control_code_page); int result; =20 - /* Calculate the offsets */ - control_page =3D page_to_pfn(image->control_code_page) << PAGE_SHIFT; - /* Setup the identity mapped 64bit page table */ - result =3D init_pgtable(image, control_page); + result =3D init_pgtable(image, __pa(control_page)); if (result) return result; =20 + __memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE); + return 0; } =20 @@ -363,7 +362,6 @@ void machine_kexec(struct kimage *image) } =20 control_page =3D page_address(image->control_code_page); - __memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE); =20 page_list[PA_CONTROL_PAGE] =3D virt_to_phys(control_page); page_list[VA_CONTROL_PAGE] =3D (unsigned long)control_page; --=20 2.47.0