Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Pingfan Liu <piliu@redhat.com>
Cc: Pingfan Liu <piliu@redhat.com>, Simon Horman <horms@kernel.org>,
	Eric Biederman <ebiederm@xmission.com>,
	Baoquan He <bhe@redhat.com>, Dave Young <dyoung@redhat.com>,
	Ard Biesheuvel <ardb@kernel.org>,
	Jan Hendrik Farr <kernel@jfarr.cc>,
	Philipp Rudo <prudo@redhat.com>,
	Lennart Poettering <mzxreary@0pointer.de>,
	kexec@lists.infradead.org
Subject: [PATCH 1/3] kexec: Introduce default_initrd_fd to pass internal initrd information
Date: Tue,  8 Oct 2024 19:54:01 +0800	[thread overview]
Message-ID: <20241008115408.21944-2-piliu@redhat.com> (raw)
In-Reply-To: <20241008115408.21944-1-piliu@redhat.com>

At present, initrd information is passed through --initrd args, but for
the UKI case, the initrd may be stored in the .initrd section.

It means that initrd is perceived at the probe stage. And there should
be a way to carry this information forward to the load stage. In oder to
implement that, introducing a global default_initrd_fd to do it.

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Cc: Simon Horman <horms@kernel.org>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: kexec@lists.infradead.org

---
 kexec/arch/arm64/kexec-image-arm64.c | 3 ++-
 kexec/arch/x86_64/kexec-bzImage64.c  | 3 ++-
 kexec/kexec.c                        | 2 ++
 kexec/kexec.h                        | 1 +
 4 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/kexec/arch/arm64/kexec-image-arm64.c b/kexec/arch/arm64/kexec-image-arm64.c
index a196747..188e7f6 100644
--- a/kexec/arch/arm64/kexec-image-arm64.c
+++ b/kexec/arch/arm64/kexec-image-arm64.c
@@ -50,7 +50,8 @@ int image_arm64_load(int argc, char **argv, const char *kernel_buf,
 				result = EFAILED;
 				goto exit;
 			}
-		}
+		} else if (default_initrd_fd != -1)
+			info->initrd_fd = default_initrd_fd;
 
 		if (arm64_opts.command_line) {
 			info->command_line = (char *)arm64_opts.command_line;
diff --git a/kexec/arch/x86_64/kexec-bzImage64.c b/kexec/arch/x86_64/kexec-bzImage64.c
index aba4e3b..e337dc0 100644
--- a/kexec/arch/x86_64/kexec-bzImage64.c
+++ b/kexec/arch/x86_64/kexec-bzImage64.c
@@ -307,7 +307,8 @@ int bzImage64_load_file(int argc, char **argv, struct kexec_info *info)
 			ret = -1;
 			goto out;
 		}
-	}
+	} else if (default_initrd_fd != -1)
+		info->initrd_fd = default_initrd_fd;
 
 	info->command_line = command_line;
 	info->command_line_len = command_line_len;
diff --git a/kexec/kexec.c b/kexec/kexec.c
index 7c614b0..91edb56 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -67,6 +67,8 @@ int do_hotplug = 0;
 static unsigned long kexec_flags = 0;
 /* Flags for kexec file (fd) based syscall */
 static unsigned long kexec_file_flags = 0;
+/* initrd detected in probe phase */
+int default_initrd_fd = -1;
 int kexec_debug = 0;
 
 void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr)
diff --git a/kexec/kexec.h b/kexec/kexec.h
index 31c323f..396687d 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -114,6 +114,7 @@ do { \
 #define _ALIGN(addr, size)     _ALIGN_UP(addr, size)
 
 extern unsigned long long mem_min, mem_max;
+extern int default_initrd_fd;
 extern int kexec_debug;
 
 #define dbgprintf(...) \
-- 
2.41.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  reply	other threads:[~2024-10-08 11:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-08 11:54 [PATCH 0/3] kexec: Add support for UKI format kernel Pingfan Liu
2024-10-08 11:54 ` Pingfan Liu [this message]
2024-10-08 11:54 ` [PATCH 2/3] kexec: Introduce UKI image parser Pingfan Liu
2024-10-11  8:44   ` Simon Horman
2024-10-11 11:14     ` Pingfan Liu
2024-10-14  2:43       ` Pingfan Liu
2024-10-15 13:26         ` Simon Horman
2024-10-16 11:37           ` Pingfan Liu
2024-10-08 11:54 ` [PATCH 3/3] arm64: Support UKI image format Pingfan Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241008115408.21944-2-piliu@redhat.com \
    --to=piliu@redhat.com \
    --cc=ardb@kernel.org \
    --cc=bhe@redhat.com \
    --cc=dyoung@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=horms@kernel.org \
    --cc=kernel@jfarr.cc \
    --cc=kexec@lists.infradead.org \
    --cc=mzxreary@0pointer.de \
    --cc=prudo@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox