Hi Oleksii,
On 09/01/2023 09:04, Oleksii wrote:
On Fri, 2023-01-06 at 13:40 +0000, Julien Grall wrote:
Hi,
On 06/01/2023 13:14, Oleksii Kurochko wrote:
The patch introduce sbi_putchar() SBI call which is necessary
to implement initial early_printk
Signed-off-by: Oleksii Kurochko <oleksii.kuroc...@gmail.com>
---
xen/arch/riscv/Makefile | 1 +
xen/arch/riscv/include/asm/sbi.h | 34 ++++++++++++++++++++++++
xen/arch/riscv/sbi.c | 44
++++++++++++++++++++++++++++++++
IMHO, it would be better to implement sbi.c in assembly so you can
use
print in the console before you jump to C world.
I thought that we can live with C version as we set up stack from the
start and then we can call early_printk() from assembly code too.
Is it bad approach?
It depends on how early you want to call it. For Arm, we chose to use
assembly because the C code may not be PIE (and even with PIE it may
need some relocation work).
Andrew suggested that this may not be a problem with RISC-V. I have
looked a bit more around and notice that the kernel is also calling some
C function very early (like setup_vm()). But they ensure that the code
is built with -mcmodel=medany.
It looks like you are already building Xen with this option. So all
looks good for RISC-V. That said, I would suggest to check that
__riscv_cmodel_medany is defined in files where you implement C function
called from early assembly code.
Cheers,
--
Julien Grall