opensbi icon indicating copy to clipboard operation
opensbi copied to clipboard

`sbi_cppc_write` is never passed the full 64-bit value when `__riscv_xlen == 32`

Open repnop opened this issue 1 year ago • 1 comments

https://github.com/riscv-software-src/opensbi/blob/791704cd09c019decf438f6e4f56423cc95cb66a/lib/sbi/sbi_ecall_cppc.c#L36

Unless there's something I've missed in the SBI specification about CPPC register values never exceeding 32-bits when XLEN is 32, this line is wrong whenever the code is compiled for __riscv_xlen == 32, as it implicitly promotes the unsigned long (32-bits) to a uint64_t instead of reading the full 64-bit value out of a1 and a2 and combining them into a 64-bit value.

repnop avatar Nov 25 '23 22:11 repnop

Yes, this line needs to be fixed for RV32. Please send a patch to the OpenSBI mailing list.

avpatel avatar Nov 26 '23 01:11 avpatel