Bug#1135292: trixie-pu: package grub2/2.12-9+deb13u2
Aurelien Jarno
aurel32 at debian.org
Thu Apr 30 20:41:14 BST 2026
Package: release.debian.org
Severity: normal
Tags: trixie
X-Debbugs-Cc: grub2 at packages.debian.org
Control: affects -1 + src:grub2
User: release.debian.org at packages.debian.org
Usertags: pu
[ Reason ]
On RISC-V, the grub2 version in trixie attempts to access the CPU cycle
counter to maintain internal timing. This is permitted on real hardware
or on QEMU emulated machines, but it is forbidden when running as a KVM
guest, resulting in the illegal instruction error reported in bug
#1108898. The solution is to use the timer counter instead that is
permitted and still provides enough accuracy for grub usage.
RISC-V CPUs with the Hypervisor extension are becoming more common,
making this bug more important.
[ Impact ]
This issue prevents running KVM trixie guests using grub2 (including
d-i) on riscv64.
[ Tests ]
I have tested the patch on riscv64 and I can confirm that it fixes the
issue on KVM based virtual machine and does not introduce any regression
on QEMU emulated machines nor on real hardware.
[ Risks ]
I believe, the risks are small, the patch is minimal and touching
architecture specific code. This change has been in testing/sid since
beginning of last December (version 2.14~git20250718.0e36779-2) without
any reported issue.
[ Checklist ]
[x] *all* changes are documented in the d/changelog
[x] I reviewed all changes and I approve them
[x] attach debdiff against the package in (old)stable
[x] the issue is verified as fixed in unstable
[ Changes ]
* Non-maintainer upload.
* Apply patch from upstream to fix an illegal instruction on riscv64 in
grub.efi (Closes: #1108898)
-------------- next part --------------
diff -Nru grub2-2.12/debian/changelog grub2-2.12/debian/changelog
--- grub2-2.12/debian/changelog 2026-02-15 14:50:20.000000000 +0100
+++ grub2-2.12/debian/changelog 2026-04-30 21:02:01.000000000 +0200
@@ -1,3 +1,11 @@
+grub2 (2.12-9+deb13u2) trixie; urgency=medium
+
+ * Non-maintainer upload.
+ * Apply patch from upstream to fix an illegal instruction on riscv64 in
+ grub.efi (Closes: #1108898)
+
+ -- Aurelien Jarno <aurel32 at debian.org> Thu, 30 Apr 2026 21:02:01 +0200
+
grub2 (2.12-9+deb13u1) trixie; urgency=medium
* Non-maintainer upload.
diff -Nru grub2-2.12/debian/patches/series grub2-2.12/debian/patches/series
--- grub2-2.12/debian/patches/series 2026-02-15 14:50:20.000000000 +0100
+++ grub2-2.12/debian/patches/series 2026-04-30 21:02:01.000000000 +0200
@@ -71,6 +71,7 @@
extra_deps_lst.patch
upstream/acpi-Fix-out-of-bounds-access-in-grub_acpi_xsdt_find_tabl.patch
upstream/zfs-fix-LINUX_ROOT_DEVICE-when-grub-probe-fails.patch
+upstream/kern-riscv-efi-init-Use-time-register-in-grub_efi_ge.patch
install-signed.patch
grub-install-extra-removable.patch
grub-install-removable-shim.patch
diff -Nru grub2-2.12/debian/patches/upstream/kern-riscv-efi-init-Use-time-register-in-grub_efi_ge.patch grub2-2.12/debian/patches/upstream/kern-riscv-efi-init-Use-time-register-in-grub_efi_ge.patch
--- grub2-2.12/debian/patches/upstream/kern-riscv-efi-init-Use-time-register-in-grub_efi_ge.patch 1970-01-01 01:00:00.000000000 +0100
+++ grub2-2.12/debian/patches/upstream/kern-riscv-efi-init-Use-time-register-in-grub_efi_ge.patch 2026-04-30 21:02:01.000000000 +0200
@@ -0,0 +1,47 @@
+From c5ae124e11f28f637cbd38cb4d6c1b9817baa135 Mon Sep 17 00:00:00 2001
+From: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
+Date: Mon, 12 Aug 2024 16:13:18 +0200
+Subject: [PATCH] kern/riscv/efi/init: Use time register in
+ grub_efi_get_time_ms()
+
+The cycle register is not guaranteed to count at constant frequency.
+If it is counting at all depends on the state the performance monitoring
+unit. Use the time register to measure time.
+
+Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
+Reviewed-by: Daniel Kiper <daniel.kiper at oracle.com>
+---
+ grub-core/kern/riscv/efi/init.c | 15 +++++++--------
+ 1 file changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/grub-core/kern/riscv/efi/init.c b/grub-core/kern/riscv/efi/init.c
+index 38795fe67..0d7de4f54 100644
+--- a/grub-core/kern/riscv/efi/init.c
++++ b/grub-core/kern/riscv/efi/init.c
+@@ -33,16 +33,15 @@ grub_efi_get_time_ms (void)
+ grub_uint64_t tmr;
+
+ #if __riscv_xlen == 64
+- asm volatile ("rdcycle %0" : "=r" (tmr));
++ asm volatile ("rdtime %0" : "=r"(tmr));
+ #else
+ grub_uint32_t lo, hi, tmp;
+- asm volatile (
+- "1:\n"
+- "rdcycleh %0\n"
+- "rdcycle %1\n"
+- "rdcycleh %2\n"
+- "bne %0, %2, 1b"
+- : "=&r" (hi), "=&r" (lo), "=&r" (tmp));
++ asm volatile ("1:\n"
++ "rdtimeh %0\n"
++ "rdtime %1\n"
++ "rdtimeh %2\n"
++ "bne %0, %2, 1b"
++ : "=&r" (hi), "=&r" (lo), "=&r" (tmp));
+ tmr = ((grub_uint64_t)hi << 32) | lo;
+ #endif
+
+--
+2.53.0
+
More information about the Pkg-grub-devel
mailing list