From nobody Thu Dec 18 00:07:23 2025 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 8C057218ADA for ; Thu, 9 Jan 2025 14:08:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736431715; cv=none; b=cQRJ+WIWfKqqkG7xA+aM7jDkxwrrdDliW2+5AK0uJyF0O1IEbB1ONCATksxrQbQF1FGLPGO4mAM84XZhZZKfv6HVG6OlbSZkuL4kgkkIShhjWkz5QotAKPeUyyWE791dZQn+q+HZnK6wpxSUpYIiIoZN/eRBUi+/vyXt0mefgus= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736431715; c=relaxed/simple; bh=b6JswA7rfzdTMbDlCbvy9TcmyJgHcyKPKzbFliLK5Gs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aJjOUvG9JyPjpX8TSuhBDj6CsWEARomEB4omhWV0NJNyZTpAlYzTDZntz93YcoJeUdl/buI6xVYWZU0iCPsUsZL+Uh+85ScnuWMdBauytik2eByKxp9Nz8WprecRVoWTRUMc0MQRkCqsriL/Awq/kSsSMeQXnjk0S7wgKzgBqbw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=desiato.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=qh68UCXE; arc=none smtp.client-ip=90.155.92.199 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=desiato.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="qh68UCXE" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=bFcppKCEUBjugJ7xwZiGVN+OuHVqmS8GOG0BIifw77s=; b=qh68UCXENO/RYJFF8kUFvYLW+Y 01DQVBz9CP2uynDSDCh7y+78zF7+fMfrmnOdrr9gMkpR2zAsy4p/Zfn/kaTkgM5WJmLL9yv0R2op7 T72cPT1au2Hz0HiQqTDp2ik0OQrpbYzTEoipTWQgvMP0n4oeQa3PwY7wC+y43mgPv37taurGILhj3 ZRNib6VCwnkDIEmkfd4MHTFHU9H4UNv6BOU3IfGAQAoI5c9blASIIvLfimYyCafBZOhHcLv/bYNfJ Gb2xdvlmK9CWpkOBTFSS49wPAvHdhnozIkve9D20xYbtOPC3qL7WqG/6j5Hq4gPBvcKdmRLffVgI6 a50uzDiA==; Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by desiato.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tVtCa-00000009Zhg-3Cr9; Thu, 09 Jan 2025 14:08:01 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tVtCY-0000000Bx6P-3fUv; Thu, 09 Jan 2025 14:07:58 +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 v2 7/9] kexec_core: Add and update comments regarding the KEXEC_JUMP flow Date: Thu, 9 Jan 2025 14:04:19 +0000 Message-ID: <20250109140757.2841269-8-dwmw2@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250109140757.2841269-1-dwmw2@infradead.org> References: <20250109140757.2841269-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 desiato.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..464ab059c58d 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 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