From nobody Thu Dec 18 00:07:22 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 06BD21DACBB for ; Mon, 16 Dec 2024 23:37:36 +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=1734392258; cv=none; b=eKhFvkyo+znz2X1voh6b6asdWY00oEDejKspo3j1hupCBOHhf8j1T5Tjn4QBG5MwJG98zUZYoqYjMgulFq8KJ55eGsyY+6Hrc+kd4XGUsu0jcQcFr/plEfV9S5KA7FcJsg+25TPn2vPL4TJKxbBQ23ahDPPBFEA1iAftkNRL9e4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734392258; c=relaxed/simple; bh=h1wOv8MeWSS5bfN/J/5w9irQt2gV6YHa6Emr/0th+fI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XkZJ89+eW9aInK0xQ2HN+ztuviWRTsj5fdU3ntW0xCpr7GKzT3Q5MMUNTCRjhrFJOS76sma/BdoTm+FmTOYEEdlUmRwv0rPXrA/oY9Ifs6R3xeG8ZQLFuMURJArEKCybDIAepN+9olWycfNFU4fijfpHZ8dmM3wDb909K5AW6LI= 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=Zx7gwPn0; 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="Zx7gwPn0" 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:To:From:Reply-To: Cc:Content-Type:Content-ID:Content-Description; bh=xrUqJHk+DC7MJiWSLIDNfBawd31aIE7V5wzrcp1W6yM=; b=Zx7gwPn0rmONbPxIOvq+ePXTKW Zk15pJZDZDIkZLHFUp+nojiZHr5XeijgkL8l3gO/TpUea3CrhEhTjETXv6Y4iJY/jLacu/A1U5SEU UEVnOqaYEe6+B+OU8nCinx2QzHl/Vy0g5vpoMhcqyuNdibs++Cyh8pRrpIsbJX8Y3GpTO2XiWAozH 7539NDgNLojJl0KsYBe+6LAOwmS1NfJ3wguZtVUXGGlisG+9LJ1X+ndafT77hAKn5b3vsjqvv/Dv7 POPmXVwbmLF0IRf5vJKX/AIlVT86HwqM2md1pmSvQinWdKVQxuujVZUJdM1MHsHWoITKTDtxmzCVu nxh12/jQ==; 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 1tNKeA-000000034na-2gcj; Mon, 16 Dec 2024 23:37:07 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tNKeA-0000000DeWQ-1HY4; Mon, 16 Dec 2024 23:37:06 +0000 From: David Woodhouse To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Eric Biederman , David Woodhouse , Sourabh Jain , Hari Bathini , Michael Ellerman , Thomas Zimmermann , Andrew Morton , Baoquan He , Yuntao Wang , David Kaplan , Tao Liu , "Kirill A. Shutemov" , Kai Huang , Ard Biesheuvel , Josh Poimboeuf , Breno Leitao , Wei Yang , Rong Xu , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , linux-kernel@vger.kernel.org, kexec@lists.infradead.org, Simon Horman , Dave Young , Peter Zijlstra , bsz@amazon.de, nathan@kernel.org Subject: [PATCH 7/9] kexec_core: Add and update comments regarding the KEXEC_JUMP flow Date: Mon, 16 Dec 2024 23:24:14 +0000 Message-ID: <20241216233704.3208607-8-dwmw2@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241216233704.3208607-1-dwmw2@infradead.org> References: <20241216233704.3208607-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: "Rafael J. Wysocki" The KEXEC_JUMP flow is analogous to hibernation flows occurring before and after creating an image and before and after jumping from the restore kernel to the image one, which is why it uses the same device callbacks as those hibernation flows. Add comments explaining that to the code in question and update an existing comment in it which appears a bit out of context. No functional changes. Signed-off-by: Rafael J. Wysocki Signed-off-by: David Woodhouse --- kernel/kexec_core.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index c0caa14880c3..7cf8437e0f38 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -1001,6 +1001,12 @@ int kernel_kexec(void) =20 #ifdef CONFIG_KEXEC_JUMP if (kexec_image->preserve_context) { + /* + * This flow is analogous to hibernation flows that occur before + * creating an image and before jumping from the restore kernel + * to the image one, so it uses the same device device callbacks + * as those two flows. + */ pm_prepare_console(); error =3D freeze_processes(); if (error) { @@ -1011,12 +1017,10 @@ int kernel_kexec(void) error =3D dpm_suspend_start(PMSG_FREEZE); if (error) goto Resume_console; - /* At this point, dpm_suspend_start() has been called, - * but *not* dpm_suspend_end(). We *must* call - * dpm_suspend_end() now. Otherwise, drivers for - * some devices (e.g. interrupt controllers) become - * desynchronized with the actual state of the - * hardware at resume time, and evil weirdness ensues. + /* + * dpm_suspend_end() must be called after dpm_suspend_start() + * to complete the transition, like in the hibernation flows + * mentioned above. */ error =3D dpm_suspend_end(PMSG_FREEZE); if (error) @@ -1052,6 +1056,13 @@ int kernel_kexec(void) =20 #ifdef CONFIG_KEXEC_JUMP if (kexec_image->preserve_context) { + /* + * This flow is analogous to hibernation flows that occur after + * creating an image and after the image hernel has got control + * back, and in case the devices have been reset or otherwise + * manipulated in the meantime, it uses the device callbacks + * used by the latter. + */ syscore_resume(); Enable_irqs: local_irq_enable(); --=20 2.47.0