aboutsummaryrefslogtreecommitdiffstats
path: root/sys-boot/grub/files/grub-2.06-add-boot-hartid-to-fdt.patch
diff options
context:
space:
mode:
Diffstat (limited to 'sys-boot/grub/files/grub-2.06-add-boot-hartid-to-fdt.patch')
-rw-r--r--sys-boot/grub/files/grub-2.06-add-boot-hartid-to-fdt.patch35
1 files changed, 35 insertions, 0 deletions
diff --git a/sys-boot/grub/files/grub-2.06-add-boot-hartid-to-fdt.patch b/sys-boot/grub/files/grub-2.06-add-boot-hartid-to-fdt.patch
new file mode 100644
index 0000000..3b6b464
--- /dev/null
+++ b/sys-boot/grub/files/grub-2.06-add-boot-hartid-to-fdt.patch
@@ -0,0 +1,35 @@
+diff -Naur grub-2.06/grub-core/loader/riscv64/linux.c grub-2.06-mod/grub-core/loader/riscv64/linux.c
+--- grub-2.06/grub-core/loader/riscv64/linux.c 2021-07-03 19:45:08.797409969 +0200
++++ grub-2.06-mod/grub-core/loader/riscv64/linux.c 2021-07-03 19:43:54.673239976 +0200
+@@ -48,6 +48,13 @@
+ static grub_addr_t initrd_start;
+ static grub_addr_t initrd_end;
+
++#define get_hartid(__v) \
++{ \
++ __asm__ __volatile__ ("mv %0, tp" \
++ : "=r" (__v) : \
++ : "memory"); \
++}
++
+ grub_err_t
+ grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh)
+ {
+@@ -68,6 +75,7 @@
+ finalize_params_linux (void)
+ {
+ int node, retval;
++ int hartid;
+
+ void *fdt;
+
+@@ -83,6 +91,9 @@
+ if (node < 1)
+ goto failure;
+
++ get_hartid(hartid);
++ grub_fdt_set_prop32 (fdt, node, "boot-hartid", hartid);
++
+ /* Set initrd info */
+ if (initrd_start && initrd_end > initrd_start)
+ {