Skip to contentSkip to conversation

Add zstdio support for booting Trixie kernels in Xen

PATCH In review Logan Gunthorpe via Grub-devel 3 participants 7 messages Oct 21, 2025 – Oct 22, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover Add zstdio support for booting Trixie kernels in Xen

Hi,

Here is v3 of this series. I've addressed all the noted code formatting issues.

But I've declined to make the change to the safe math primitives because I'm sure overflow is not possible and it divereges from the original xzio source this work is based on.

Logan

--

Changes in v3:
* Fixed various code cleanups as suggested by Daniel
* Removed all tab characters to address formatting issues noticed by Avnish

Changes in v2:
* Fixed Numerous code formatting issues as noticed by Avnish

--

Debian has started compressing the kernel images in the Trixie release. This breaks booting xen kernels seeing grub has no support to decompress the zstd images[1][2].

To improve this situation, this patch series adds zstdio support in a way that's very similar to xzio. The first patch adds this support. The remaining patchs expand the file_filter tests so this functionality is covered.

--

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1102066
[2] https://www.mail-archive.com/[email protected]/msg41663.html

Logan Gunthorpe (4):
io: Implement zstdio decompression
tests/file_filter: Regenerate gpg keys
tests/file_filter: Add zstd test file
tests/file_filter: Add zstd tests

 Makefile.util.def               |   1 +
 grub-core/Makefile.core.def     |   7 +
 grub-core/io/zstdio.c           | 243 ++++++++++++++++++++++++++++++++
 include/grub/file.h             |   3 +-
 tests/file_filter/file.gz.sig   | Bin 96 -> 310 bytes
 tests/file_filter/file.lzop.sig | Bin 96 -> 310 bytes
 tests/file_filter/file.xz.sig   | Bin 96 -> 310 bytes
 tests/file_filter/file.zstd     | Bin 0 -> 26 bytes
 tests/file_filter/file.zstd.sig | Bin 0 -> 310 bytes
 tests/file_filter/keys          | Bin 994 -> 1308 bytes
 tests/file_filter/keys.pub      | Bin 990 -> 657 bytes
 tests/file_filter/test.cfg      |   1 +
 tests/file_filter_test.in       |   7 +-
 13 files changed, 259 insertions(+), 3 deletions(-)
 create mode 100644 grub-core/io/zstdio.c
 create mode 100644 tests/file_filter/file.zstd
 create mode 100644 tests/file_filter/file.zstd.sig

base-commit: 6b5c671d35b1b84468da1fef2b9bd8e05682f7e6 --
2.47.3

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#1 lore raw

PATCH v3 1/4 io: Implement zstdio decompression

Add zstd based io decompression.

Based largely on the existing xzio, implement the same features using the zstd library already included in the project.

---
 Makefile.util.def           |   1 +
 grub-core/Makefile.core.def |   7 ++
 grub-core/io/zstdio.c       | 243 ++++++++++++++++++++++++++++++++++++
 include/grub/file.h         |   3 +-
 4 files changed, 253 insertions(+), 1 deletion(-)
 create mode 100644 grub-core/io/zstdio.c
Makefile.util.def +1 -0
index 038253b37a42..74786177f908 100644
@@ -162,6 +162,7 @@ library = {
   common = grub-core/io/gzio.c;
   common = grub-core/io/xzio.c;
   common = grub-core/io/lzopio.c;
+  common = grub-core/io/zstdio.c;
   common = grub-core/kern/ia64/dl_helper.c;
   common = grub-core/kern/arm/dl_helper.c;
   common = grub-core/kern/arm64/dl_helper.c;
grub-core/Makefile.core.def +7 -0
index a729cb6a8e61..a2635d61b6e8 100644
@@ -2512,6 +2512,13 @@ module = {
   cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/minilzo -DMINILZO_HAVE_CONFIG_H';
 };
 
+module = {
+  name = zstdio;
+  common = io/zstdio.c;
+  cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/zstd';
+  cflags='-Wno-unreachable-code';
+};
+
 module = {
   name = testload;
   common = commands/testload.c;
grub-core/io/zstdio.c new file +243 -0

243 lines not on this page · raw message

include/grub/file.h +2 -1
index 16a4b7d26437..d51834e6abd2 100644
@@ -190,9 +190,10 @@ typedef enum grub_file_filter_id
     GRUB_FILE_FILTER_GZIO,
     GRUB_FILE_FILTER_XZIO,
     GRUB_FILE_FILTER_LZOPIO,
+    GRUB_FILE_FILTER_ZSTDIO,
     GRUB_FILE_FILTER_MAX,
     GRUB_FILE_FILTER_COMPRESSION_FIRST = GRUB_FILE_FILTER_GZIO,
-    GRUB_FILE_FILTER_COMPRESSION_LAST = GRUB_FILE_FILTER_LZOPIO,
+    GRUB_FILE_FILTER_COMPRESSION_LAST = GRUB_FILE_FILTER_ZSTDIO,
   } grub_file_filter_id_t;
 
 typedef grub_file_t (*grub_file_filter_t) (grub_file_t in, enum grub_file_type type);
Signature · 7 lines
2.47.3


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Reviewed-by on v3 1/4
#2 lore raw

Re: [PATCH v3 1/4] io: Implement zstdio decompression

Quoted 6 lines · Logan Gunthorpe

Add zstd based io decompression.

Based largely on the existing xzio, implement the same features using the zstd library already included in the project.

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#3 lore raw

PATCH v3 2/4 tests/file_filter: Regenerate gpg keys

In reply to Logan Gunthorpe via Grub-devel

The 'keys' file is not a valid GPG secret key so it is not possible to generate new signatures.

Create a new key and use gpg --export-secret-key to export the key and gpg --export to export the public key. Then resign all the signatures with gpg --detach-sign.

---
 tests/file_filter/file.gz.sig   | Bin 96 -> 310 bytes
 tests/file_filter/file.lzop.sig | Bin 96 -> 310 bytes
 tests/file_filter/file.xz.sig   | Bin 96 -> 310 bytes
 tests/file_filter/keys          | Bin 994 -> 1308 bytes
 tests/file_filter/keys.pub      | Bin 990 -> 657 bytes
 5 files changed, 0 insertions(+), 0 deletions(-)
tests/file_filter/file.gz.sig binary +0 -0
index 602e6187e22d7fc288a52ac572f38cc1066083cb..27cdcff2dac7d94c8a16468431054cc15b2c9cea 100644
GIT binary patch
tests/file_filter/file.lzop.sig binary +0 -0
index 7c68dcf931e438973f5c4bfe9a0f9d5ca68fbacc..05949ae7287ad7e102d2ada99284df99de52df8b 100644
GIT binary patch
tests/file_filter/file.xz.sig binary +0 -0
index 57569242e4742cdfb929307ec19440cf91f49e9a..9633a2fa15b2f0d3584afacf84d55a8bd8011fab 100644
GIT binary patch
tests/file_filter/keys binary +0 -0
index 1afa71382364060d08bb0c28e36a1ff98d585fe8..67f29b88e338ff6d34527f3feb7d74479b19845c 100644
GIT binary patch
tests/file_filter/keys.pub binary +0 -0
index 61d4e7a7bd3adf6c66a69b4e7bd10bdf7c7877c3..44418a6f4fcb2d013abe723a733bbb073d03d828 100644
GIT binary patch
Signature · 7 lines
2.47.3


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#4 lore raw

PATCH v3 3/4 tests/file_filter: Add zstd test file

In reply to Logan Gunthorpe via Grub-devel

Add a file.zstd similar to the other compression methods and generate a gpg signature with gpg --detach-sign

---
 tests/file_filter/file.zstd     | Bin 0 -> 26 bytes
 tests/file_filter/file.zstd.sig | Bin 0 -> 310 bytes
 2 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 tests/file_filter/file.zstd
 create mode 100644 tests/file_filter/file.zstd.sig
tests/file_filter/file.zstd new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..6ea24ccf8390f456a63f15e1d0f473d0a0ebc75e
GIT binary patch
tests/file_filter/file.zstd.sig new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..ab101bb6e883a09dd41ab8fe348cf8a9ce5843c7
GIT binary patch
Signature · 7 lines
2.47.3


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#5 lore raw

PATCH v3 4/4 tests/file_filter: Add zstd tests

In reply to Logan Gunthorpe via Grub-devel

Test zstd decompression in the same way that other decompressors are tested.

---
 tests/file_filter/test.cfg | 1 +
 tests/file_filter_test.in  | 7 +++++--
 2 files changed, 6 insertions(+), 2 deletions(-)
tests/file_filter/test.cfg +1 -0
index 4308aaca52ba..ec4d10ab4b23 100644
@@ -3,4 +3,5 @@ set check_signatures=enforce
 cat /file.gz
 cat /file.xz
 cat /file.lzop
+cat /file.zstd
 set check_signatures=
tests/file_filter_test.in +5 -2
index ed6abcb5af43..18324f1a0933 100644
@@ -19,14 +19,15 @@ grubshell=@builddir@/grub-shell
 
 . "@builddir@/grub-core/modinfo.sh"
 
-filters="gzio xzio lzopio pgp"
+filters="gzio xzio lzopio zstdio pgp"
 modules="cat mpi"
 
 for mod in $(cut -d ' ' -f 2 "@builddir@/grub-core/crypto.lst"  | sort -u); do
     modules="$modules $mod"
 done
 
-for file in file.gz file.xz file.lzop file.gz.sig file.xz.sig file.lzop.sig keys.pub; do
+for file in file.gz file.xz file.lzop file.zstd file.gz.sig file.xz.sig \
+            file.lzop.sig file.zstd.sig keys.pub; do
     files="$files /$file=@srcdir@/tests/file_filter/$file"
 done
 
@@ -35,6 +36,8 @@ result="Hello, user!
 
 Hello, user!
 
+Hello, user!
+
 Hello, user!"
 
 out="$("${grubshell}" --modules="$modules $filters" --files="$files" "@srcdir@/tests/file_filter/test.cfg")"
Signature · 7 lines
2.47.3


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#6 lore raw
In reply to Logan Gunthorpe via Grub-devel
Quoted 32 lines · Logan Gunthorpe via Grub-devel

Hi,

Here is v3 of this series. I've addressed all the noted code formatting issues.

But I've declined to make the change to the safe math primitives because I'm sure overflow is not possible and it divereges from the original xzio source this work is based on.

Logan

--

Changes in v3:
* Fixed various code cleanups as suggested by Daniel
* Removed all tab characters to address formatting issues noticed by Avnish

Changes in v2:
* Fixed Numerous code formatting issues as noticed by Avnish

--

Debian has started compressing the kernel images in the Trixie release. This breaks booting xen kernels seeing grub has no support to decompress the zstd images[1][2].

To improve this situation, this patch series adds zstdio support in a way that's very similar to xzio. The first patch adds this support. The remaining patchs expand the file_filter tests so this functionality is covered.

--

Quoted 8 lines

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1102066
[2] https://www.mail-archive.com/[email protected]/msg41663.html

Logan Gunthorpe (4):
io: Implement zstdio decompression
tests/file_filter: Regenerate gpg keys
tests/file_filter: Add zstd test file
tests/file_filter: Add zstd tests

For all patches Reviewed-by: Daniel Kiper <[email protected]>...

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel