[PATCH master 2/5] filetype: introduce separate filetype_x86_efi_linux_image
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Nov 7 06:17:19 PST 2025
I originally suggested adding only filetype_x86_linux_image during
review, because I was eyeing removal of the EFI types for the other
architectures in favor of handling the EFI stub differently.
I am not pursuing this further, so let's add filetype_x86_efi_linux_image
as it will simplify code at a number of places in following commits.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
common/filetype.c | 3 ++-
efi/payload/bootm.c | 2 +-
efi/payload/image.c | 2 +-
include/filetype.h | 1 +
4 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/common/filetype.c b/common/filetype.c
index 72f84442cae9..a1807d285258 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -88,6 +88,7 @@ static const struct filetype_str filetype_str[] = {
[filetype_rockchip_rkss_image] = { "Rockchip signed boot image",
"rk-image" },
[filetype_x86_linux_image] = { "x86 Linux image", "x86-linux" },
+ [filetype_x86_efi_linux_image] = { "x86 Linux/EFI image", "x86-efi-linux" },
};
static const char *file_type_to_nr_string(enum filetype f)
@@ -437,7 +438,7 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
if (is_riscv_linux_bootimage(buf) && !memcmp(&buf[12], "barebox", 8))
return filetype_riscv_barebox_image;
if (bufsize > 0x206 && is_x86_linux_bootimage(buf))
- return filetype_x86_linux_image;
+ return is_dos_exe(buf8) ? filetype_x86_efi_linux_image : filetype_x86_linux_image;
if (le32_to_cpu(buf[5]) == 0x504d5453)
return filetype_mxs_bootstream;
diff --git a/efi/payload/bootm.c b/efi/payload/bootm.c
index 3e9ccd42bf7f..e205664b3262 100644
--- a/efi/payload/bootm.c
+++ b/efi/payload/bootm.c
@@ -276,7 +276,7 @@ static struct image_handler efi_app_handle_tr = {
static struct image_handler efi_x86_linux_handle_tr = {
.name = "EFI X86 Linux kernel",
.bootm = do_bootm_efi_stub,
- .filetype = filetype_x86_linux_image,
+ .filetype = filetype_x86_efi_linux_image,
};
static struct image_handler efi_arm64_handle_tr = {
diff --git a/efi/payload/image.c b/efi/payload/image.c
index 5d20221a135e..e4e2d26463da 100644
--- a/efi/payload/image.c
+++ b/efi/payload/image.c
@@ -191,7 +191,7 @@ static struct binfmt_hook binfmt_arm64_efi_hook = {
};
static struct binfmt_hook binfmt_x86_efi_hook = {
- .type = filetype_x86_linux_image,
+ .type = filetype_x86_efi_linux_image,
.hook = efi_execute,
};
diff --git a/include/filetype.h b/include/filetype.h
index ff4d54ee3c45..ecbbd5873b00 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -68,6 +68,7 @@ enum filetype {
filetype_zstd_compressed,
filetype_rockchip_rkss_image,
filetype_x86_linux_image,
+ filetype_x86_efi_linux_image,
filetype_max,
};
--
2.47.3
More information about the barebox
mailing list