logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0007-Avoid-shifting-past-end-of-uint32_t-for-dtb-address.patch (1046B)


  1. From 56469bedea5af4f06923e086a65da3131b2239bd Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Mon, 6 Sep 2021 20:39:50 -0700
  4. Subject: [PATCH] Avoid shifting past end of uint32_t for dtb address
  5. Make it clear that the shifting of the dtb address is intended to
  6. strip the upper 0x1000 bit, since that is the base PC address.
  7. ---
  8. riscv_machine.c | 2 +-
  9. 1 file changed, 1 insertion(+), 1 deletion(-)
  10. diff --git a/riscv_machine.c b/riscv_machine.c
  11. index a7149fd..6e407c8 100644
  12. --- a/riscv_machine.c
  13. +++ b/riscv_machine.c
  14. @@ -810,7 +810,7 @@ static void copy_bios(RISCVMachine *s, const uint8_t *buf, int buf_len,
  15. q = (uint32_t *)(ram_ptr + 0x1000);
  16. q[0] = 0x297 + 0x80000000 - 0x1000; /* auipc t0, jump_addr */
  17. q[1] = 0x597; /* auipc a1, dtb */
  18. - q[2] = 0x58593 + ((fdt_addr - 4) << 20); /* addi a1, a1, dtb */
  19. + q[2] = 0x58593 + ((fdt_addr - 0x1004) << 20); /* addi a1, a1, dtb */
  20. q[3] = 0xf1402573; /* csrr a0, mhartid */
  21. q[4] = 0x00028067; /* jalr zero, t0, jump_addr */
  22. }
  23. --
  24. 2.32.0