XM Zg
XM Zg

Reputation: 109

Why does my Linux kernel with OpenSBI not boot correctly when jumping to a new load address (0x80100000)

I used the following command to build the OpenSBI payload and Linux kernel image:

make PLATFORM=generic FW_FDT_PATH=$WORKLOAD_BUILD_ENV_HOME/dts/build/xiangshan.dtb FW_PAYLOAD_PATH=$RISCV_LINUX_HOME/arch/riscv/boot/Image

After obtaining the fw_payload.bin, I wrote a simple jump instruction to load the OpenSBI payload and jump to the new location at 0x80100000. The jump is done using a basic jump instruction to the address 0x80100000, after which the kernel should continue executing the fw_payload.bin.

However, when running this on an emulator, I can only see OpenSBI's output but not the kernel's output. If I directly run the fw_payload.bin, it works as expected and the kernel runs fine.

What could be the cause of this discrepancy? Why does the kernel fail to execute properly after jumping to 0x80100000, but works fine when the payload is executed directly?

Here is my linker.lds and jump logic:

OUTPUT_ARCH( "riscv" )

ENTRY( jump_payload )

SECTIONS
{
  . = ALIGN(4);

  begin = .;

  .header.code :
  {
    *(.header.code)
  }

  end = .;


  . = begin + 0x100000;
  .payload :
  {
     PROVIDE(_payload_start = .);
     *(.payload)
     . = ALIGN(8);
     PROVIDE(_payload_end = .);
  }
.section ".header.code", "ax", %progbits
.globl jump_payload
jump_payload:
  li t0, 0x80100000
  jr t0
  add t0, x0,x0

  .section ".payload", "ax", %progbits
  .align 4
  .global payload_bin
payload_bin:
  .incbin PAYLOAD_PATH

Upvotes: 0

Views: 58

Answers (0)

Related Questions