[PATCH v5 10/13] target/riscv: Add kvm_riscv_get/put_regs_timer

2022-01-12 Thread Yifei Jiang via
Add kvm_riscv_get/put_regs_timer to synchronize virtual time context from KVM. To set register of RISCV_TIMER_REG(state) will occur a error from KVM on kvm_timer_state == 0. It's better to adapt in KVM, but it doesn't matter that adaping in QEMU. Signed-off-by: Yifei Jiang Signed-off

[PATCH v5 13/13] target/riscv: enable riscv kvm accel

2022-01-12 Thread Yifei Jiang via
Add riscv kvm support in meson.build file. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li --- meson.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/meson.build b/meson.build index c1b1db1e28..06a5476254 100644 --- a/meson.build +++ b/meson.build @@ -90,6 +90,8 @@ elif cpu

[PATCH v5 08/13] target/riscv: Handle KVM_EXIT_RISCV_SBI exit

2022-01-12 Thread Yifei Jiang via
Use char-fe to handle console sbi call, which implement early console io while apply 'earlycon=sbi' into kernel parameters. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Anup Patel Reviewed-by: Alistair Francis --- target/riscv/kvm.c | 42

[PATCH v5 12/13] target/riscv: Support virtual time context synchronization

2022-01-12 Thread Yifei Jiang via
Add virtual time context description to vmstate_kvmtimer. After cpu being loaded, virtual time context is updated to KVM. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Anup Patel Reviewed-by: Alistair Francis --- target/riscv/machine.c | 30

[PATCH v5 11/13] target/riscv: Implement virtual time adjusting with vm state changing

2022-01-12 Thread Yifei Jiang via
We hope that virtual time adjusts with vm state changing. When a vm is stopped, guest virtual time should stop counting and kvm_timer should be stopped. When the vm is resumed, guest virtual time should continue to count and kvm_timer should be restored. Signed-off-by: Yifei Jiang Signed-off

[PATCH v5 06/13] target/riscv: Support start kernel directly by KVM

2022-01-12 Thread Yifei Jiang via
Get kernel and fdt start address in virt.c, and pass them to KVM when cpu reset. Add kvm_riscv.h to place riscv specific interface. In addition, PLIC is created without M-mode PLIC contexts when KVM is enabled. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis

[PATCH v5 05/13] target/riscv: Implement kvm_arch_put_registers

2022-01-12 Thread Yifei Jiang via
Put GPR CSR and FP registers to kvm by KVM_SET_ONE_REG ioctl Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- target/riscv/kvm.c | 104 - 1 file changed, 103 insertions(+), 1 deletion

[PATCH v5 09/13] target/riscv: Add host cpu type

2022-01-12 Thread Yifei Jiang via
'host' type cpu is set isa to RV32 or RV64 simply, more isa info will obtain from KVM in kvm_arch_init_vcpu() Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- target/riscv/cpu.c | 15 +++ target/riscv/cpu.h | 1 + 2

[PATCH v5 03/13] target/riscv: Implement function kvm_arch_init_vcpu

2022-01-12 Thread Yifei Jiang via
Get isa info from kvm while kvm init. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- target/riscv/kvm.c | 34 +- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/target/riscv/kvm.c b

[PATCH v5 00/13] Add riscv kvm accel support

2022-01-12 Thread Yifei Jiang via
dd riscv32 kvm accel support. Yifei Jiang (13): update-linux-headers: Add asm-riscv/kvm.h target/riscv: Add target/riscv/kvm.c to place the public kvm interface target/riscv: Implement function kvm_arch_init_vcpu target/riscv: Implement kvm_arch_get_registers target/riscv: Implement kv

[PATCH v5 07/13] target/riscv: Support setting external interrupt by KVM

2022-01-12 Thread Yifei Jiang via
When KVM is enabled, set the S-mode external interrupt through kvm_riscv_set_irq function. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- target/riscv/cpu.c | 6 +- target/riscv/kvm-stub.c | 5 + target/riscv

[PATCH v5 01/13] update-linux-headers: Add asm-riscv/kvm.h

2022-01-12 Thread Yifei Jiang via
Add asm-riscv/kvm.h for RISC-V KVM. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Acked-by: Alistair Francis Reviewed-by: Anup Patel --- linux-headers/asm-riscv/kvm.h | 128 ++ 1 file changed, 128 insertions(+) create mode 100644 linux-headers/asm

[PATCH v5 04/13] target/riscv: Implement kvm_arch_get_registers

2022-01-12 Thread Yifei Jiang via
Get GPR CSR and FP registers from kvm by KVM_GET_ONE_REG ioctl. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- target/riscv/kvm.c | 112 - 1 file changed, 111 insertions(+), 1

[PATCH v5 02/13] target/riscv: Add target/riscv/kvm.c to place the public kvm interface

2022-01-12 Thread Yifei Jiang via
Add target/riscv/kvm.c to place kvm_arch_* function needed by kvm/kvm-all.c. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- target/riscv/kvm.c | 133 +++ target/riscv/meson.build | 1

[PATCH v4 05/12] target/riscv: Implement kvm_arch_put_registers

2022-01-09 Thread Yifei Jiang via
Put GPR CSR and FP registers to kvm by KVM_SET_ONE_REG ioctl Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- target/riscv/kvm.c | 104 - 1 file changed, 103 insertions(+), 1 deletion

[PATCH v4 11/12] target/riscv: Implement virtual time adjusting with vm state changing

2022-01-09 Thread Yifei Jiang via
We hope that virtual time adjusts with vm state changing. When a vm is stopped, guest virtual time should stop counting and kvm_timer should be stopped. When the vm is resumed, guest virtual time should continue to count and kvm_timer should be restored. Signed-off-by: Yifei Jiang Signed-off

[PATCH v4 06/12] target/riscv: Support start kernel directly by KVM

2022-01-09 Thread Yifei Jiang via
Get kernel and fdt start address in virt.c, and pass them to KVM when cpu reset. Add kvm_riscv.h to place riscv specific interface. In addition, PLIC is created without M-mode PLIC contexts when KVM is enabled. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis

[PATCH v4 10/12] target/riscv: Add kvm_riscv_get/put_regs_timer

2022-01-09 Thread Yifei Jiang via
Add kvm_riscv_get/put_regs_timer to synchronize virtual time context from KVM. To set register of RISCV_TIMER_REG(state) will occur a error from KVM on kvm_timer_state == 0. It's better to adapt in KVM, but it doesn't matter that adaping in QEMU. Signed-off-by: Yifei Jiang Signed-off

[PATCH v4 09/12] target/riscv: Add host cpu type

2022-01-09 Thread Yifei Jiang via
'host' type cpu is set isa to RV32 or RV64 simply, more isa info will obtain from KVM in kvm_arch_init_vcpu() Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- target/riscv/cpu.c | 15 +++ target/riscv/cpu.h | 1 + 2

[PATCH v4 12/12] target/riscv: Support virtual time context synchronization

2022-01-09 Thread Yifei Jiang via
Add virtual time context description to vmstate_kvmtimer. After cpu being loaded, virtual time context is updated to KVM. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Anup Patel Reviewed-by: Alistair Francis --- target/riscv/machine.c | 30

[PATCH v4 08/12] target/riscv: Handle KVM_EXIT_RISCV_SBI exit

2022-01-09 Thread Yifei Jiang via
Use char-fe to handle console sbi call, which implement early console io while apply 'earlycon=sbi' into kernel parameters. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Anup Patel --- target/riscv/kvm.c | 42 - target/riscv

[PATCH v4 07/12] target/riscv: Support setting external interrupt by KVM

2022-01-09 Thread Yifei Jiang via
When KVM is enabled, set the S-mode external interrupt through kvm_riscv_set_irq function. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- target/riscv/cpu.c | 6 +- target/riscv/kvm-stub.c | 5 + target/riscv

[PATCH v4 02/12] target/riscv: Add target/riscv/kvm.c to place the public kvm interface

2022-01-09 Thread Yifei Jiang via
Add target/riscv/kvm.c to place kvm_arch_* function needed by kvm/kvm-all.c. Meanwhile, add kvm support in meson.build file. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- meson.build | 2 + target/riscv/kvm.c

[PATCH v4 01/12] update-linux-headers: Add asm-riscv/kvm.h

2022-01-09 Thread Yifei Jiang via
Add asm-riscv/kvm.h for RISC-V KVM. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Acked-by: Alistair Francis Reviewed-by: Anup Patel --- linux-headers/asm-riscv/kvm.h | 128 ++ 1 file changed, 128 insertions(+) create mode 100644 linux-headers/asm

[PATCH v4 03/12] target/riscv: Implement function kvm_arch_init_vcpu

2022-01-09 Thread Yifei Jiang via
Get isa info from kvm while kvm init. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- target/riscv/kvm.c | 32 +++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/target/riscv/kvm.c b

[PATCH v4 00/12] Add riscv kvm accel support

2022-01-09 Thread Yifei Jiang via
Fix checkpatch error at target/riscv/sbi_ecall_interface.h. - Add riscv migration support. Changes since RFC v1 - Add separate SBI ecall interface header. - Add riscv32 kvm accel support. Yifei Jiang (12): update-linux-headers: Add asm-riscv/kvm.h target/riscv: Add target/riscv/kvm.c to place the

[PATCH v4 04/12] target/riscv: Implement kvm_arch_get_registers

2022-01-09 Thread Yifei Jiang via
Get GPR CSR and FP registers from kvm by KVM_GET_ONE_REG ioctl. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- target/riscv/kvm.c | 112 - 1 file changed, 111 insertions(+), 1

[PATCH v3 04/12] target/riscv: Implement kvm_arch_get_registers

2021-12-20 Thread Yifei Jiang via
Get GPR CSR and FP registers from kvm by KVM_GET_ONE_REG ioctl. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- target/riscv/kvm.c | 112 - 1 file changed, 111 insertions(+), 1

[PATCH v3 06/12] target/riscv: Support start kernel directly by KVM

2021-12-20 Thread Yifei Jiang via
Get kernel and fdt start address in virt.c, and pass them to KVM when cpu reset. Add kvm_riscv.h to place riscv specific interface. In addition, PLIC is created without M-mode PLIC contexts when KVM is enabled. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis

[PATCH v3 03/12] target/riscv: Implement function kvm_arch_init_vcpu

2021-12-20 Thread Yifei Jiang via
Get isa info from kvm while kvm init. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- target/riscv/kvm.c | 32 +++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/target/riscv/kvm.c b

[PATCH v3 02/12] target/riscv: Add target/riscv/kvm.c to place the public kvm interface

2021-12-20 Thread Yifei Jiang via
Add target/riscv/kvm.c to place kvm_arch_* function needed by kvm/kvm-all.c. Meanwhile, add kvm support in meson.build file. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- meson.build | 2 + target/riscv/kvm.c

[PATCH v3 11/12] target/riscv: Implement virtual time adjusting with vm state changing

2021-12-20 Thread Yifei Jiang via
We hope that virtual time adjusts with vm state changing. When a vm is stopped, guest virtual time should stop counting and kvm_timer should be stopped. When the vm is resumed, guest virtual time should continue to count and kvm_timer should be restored. Signed-off-by: Yifei Jiang Signed-off

[PATCH v3 01/12] update-linux-headers: Add asm-riscv/kvm.h

2021-12-20 Thread Yifei Jiang via
Add asm-riscv/kvm.h for RISC-V KVM, and update linux/kvm.h Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Acked-by: Alistair Francis Reviewed-by: Anup Patel --- linux-headers/asm-riscv/kvm.h | 128 ++ 1 file changed, 128 insertions(+) create mode

[PATCH v3 08/12] target/riscv: Handle KVM_EXIT_RISCV_SBI exit

2021-12-20 Thread Yifei Jiang via
Use char-fe to handle console sbi call, which implement early console io while apply 'earlycon=sbi' into kernel parameters. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Anup Patel --- target/riscv/kvm.c | 43 +- target/riscv

[PATCH v3 07/12] target/riscv: Support setting external interrupt by KVM

2021-12-20 Thread Yifei Jiang via
When KVM is enabled, set the S-mode external interrupt through kvm_riscv_set_irq function. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 6 +- target/riscv/kvm-stub.c | 5 + target/riscv/kvm.c | 17

[PATCH v3 10/12] target/riscv: Add kvm_riscv_get/put_regs_timer

2021-12-20 Thread Yifei Jiang via
Add kvm_riscv_get/put_regs_timer to synchronize virtual time context from KVM. To set register of RISCV_TIMER_REG(state) will occur a error from KVM on kvm_timer_state == 0. It's better to adapt in KVM, but it doesn't matter that adaping in QEMU. Signed-off-by: Yifei Jiang Signed-off

[PATCH v3 00/12] Add riscv kvm accel support

2021-12-20 Thread Yifei Jiang via
32 kvm accel support. Yifei Jiang (12): update-linux-headers: Add asm-riscv/kvm.h target/riscv: Add target/riscv/kvm.c to place the public kvm interface target/riscv: Implement function kvm_arch_init_vcpu target/riscv: Implement kvm_arch_get_registers target/riscv: Implement kvm_arch_pu

[PATCH v3 05/12] target/riscv: Implement kvm_arch_put_registers

2021-12-20 Thread Yifei Jiang via
Put GPR CSR and FP registers to kvm by KVM_SET_ONE_REG ioctl Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- target/riscv/kvm.c | 104 - 1 file changed, 103 insertions(+), 1 deletion

[PATCH v3 12/12] target/riscv: Support virtual time context synchronization

2021-12-20 Thread Yifei Jiang via
Add virtual time context description to vmstate_kvmtimer. After cpu being loaded, virtual time context is updated to KVM. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Anup Patel --- target/riscv/machine.c | 30 ++ 1 file changed, 30 insertions

[PATCH v3 09/12] target/riscv: Add host cpu type

2021-12-20 Thread Yifei Jiang via
'host' type cpu is set isa to RV32 or RV64 simply, more isa info will obtain from KVM in kvm_arch_init_vcpu() Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- target/riscv/cpu.c | 15 +++ target/riscv/cpu.h | 1 + 2

[PATCH v2 12/12] target/riscv: Support virtual time context synchronization

2021-12-10 Thread Yifei Jiang via
Add virtual time context description to vmstate_kvmtimer. After cpu being loaded, virtual time context is updated to KVM. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li --- target/riscv/machine.c | 37 +++-- 1 file changed, 35 insertions(+), 2 deletions

[PATCH v2 11/12] target/riscv: Implement virtual time adjusting with vm state changing

2021-12-10 Thread Yifei Jiang via
We hope that virtual time adjusts with vm state changing. When a vm is stopped, guest virtual time should stop counting and kvm_timer should be stopped. When the vm is resumed, guest virtual time should continue to count and kvm_timer should be restored. Signed-off-by: Yifei Jiang Signed-off

[PATCH v2 10/12] target/riscv: Add kvm_riscv_get/put_regs_timer

2021-12-10 Thread Yifei Jiang via
Add kvm_riscv_get/put_regs_timer to synchronize virtual time context from KVM. To set register of RISCV_TIMER_REG(state) will occur a error from KVM on kvm_timer_state == 0. It's better to adapt in KVM, but it doesn't matter that adaping in QEMU. Signed-off-by: Yifei Jiang Signed-off

[PATCH v2 08/12] target/riscv: Handle KVM_EXIT_RISCV_SBI exit

2021-12-10 Thread Yifei Jiang via
Use char-fe to handle console sbi call, which implement early console io while apply 'earlycon=sbi' into kernel parameters. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li --- target/riscv/kvm.c | 38 +++- target/riscv/sbi_ecall_interface.h | 72

[PATCH v2 06/12] target/riscv: Support start kernel directly by KVM

2021-12-10 Thread Yifei Jiang via
Get kernel and fdt start address in virt.c, and pass them to KVM when cpu reset. In addition, add kvm_riscv.h to place riscv specific interface. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- hw/riscv/boot.c | 11 hw/riscv/virt.c

[PATCH v2 05/12] target/riscv: Implement kvm_arch_put_registers

2021-12-10 Thread Yifei Jiang via
Put GPR CSR and FP registers to kvm by KVM_SET_ONE_REG ioctl Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- target/riscv/kvm.c | 104 - 1 file changed, 103 insertions(+), 1 deletion(-) diff --git a/target

[PATCH v2 07/12] target/riscv: Support setting external interrupt by KVM

2021-12-10 Thread Yifei Jiang via
When KVM is enabled, set the S-mode external interrupt through kvm_riscv_set_irq function. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 6 +- target/riscv/kvm-stub.c | 5 + target/riscv/kvm.c | 17

[PATCH v2 09/12] target/riscv: Add host cpu type

2021-12-10 Thread Yifei Jiang via
'host' type cpu is set isa to RV32 or RV64 simply, more isa info will obtain from KVM in kvm_arch_init_vcpu() Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- target/riscv/cpu.c | 15 +++ target/riscv/cpu.h | 1 + 2

[PATCH v2 02/12] target/riscv: Add target/riscv/kvm.c to place the public kvm interface

2021-12-10 Thread Yifei Jiang via
Add target/riscv/kvm.c to place kvm_arch_* function needed by kvm/kvm-all.c. Meanwhile, add kvm support in meson.build file. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Anup Patel --- meson.build | 2 + target/riscv/kvm.c

[PATCH v2 04/12] target/riscv: Implement kvm_arch_get_registers

2021-12-10 Thread Yifei Jiang via
Get GPR CSR and FP registers from kvm by KVM_GET_ONE_REG ioctl. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- target/riscv/kvm.c | 112 - 1 file changed, 111 insertions(+), 1 deletion(-) diff --git a/target

[PATCH v2 03/12] target/riscv: Implement function kvm_arch_init_vcpu

2021-12-10 Thread Yifei Jiang via
Get isa info from kvm while kvm init. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- target/riscv/kvm.c | 32 +++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c index

[PATCH v2 00/12] Add riscv kvm accel support

2021-12-10 Thread Yifei Jiang via
rface.h. - Add riscv migration support. Changes since RFC v1 - Add separate SBI ecall interface header. - Add riscv32 kvm accel support. Yifei Jiang (12): update-linux-headers: Add asm-riscv/kvm.h target/riscv: Add target/riscv/kvm.c to place the public kvm interface target/riscv

[PATCH v2 01/12] update-linux-headers: Add asm-riscv/kvm.h

2021-12-10 Thread Yifei Jiang via
Add asm-riscv/kvm.h for RISC-V KVM, and update linux/kvm.h Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Acked-by: Alistair Francis Reviewed-by: Anup Patel --- linux-headers/asm-riscv/kvm.h | 128 ++ linux-headers/linux/kvm.h | 8 +++ 2 files

[PATCH v1 11/12] target/riscv: Implement virtual time adjusting with vm state changing

2021-11-19 Thread Yifei Jiang
We hope that virtual time adjusts with vm state changing. When a vm is stopped, guest virtual time should stop counting and kvm_timer should be stopped. When the vm is resumed, guest virtual time should continue to count and kvm_timer should be restored. Signed-off-by: Yifei Jiang Signed-off

[PATCH v1 07/12] target/riscv: Support setting external interrupt by KVM

2021-11-19 Thread Yifei Jiang
G, so move riscv_cpu_update_mip() to target/riscv/cpu.c from target/riscv/cpu_helper.c Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- target/riscv/cpu.c| 34 ++ target/riscv/cpu_helper.c | 27 --- target

[PATCH v1 02/12] target/riscv: Add target/riscv/kvm.c to place the public kvm interface

2021-11-19 Thread Yifei Jiang
Add target/riscv/kvm.c to place kvm_arch_* function needed by kvm/kvm-all.c. Meanwhile, add kvm support in meson.build file. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- meson.build | 2 + target/riscv/kvm.c | 133

[PATCH v1 10/12] target/riscv: Add kvm_riscv_get/put_regs_timer

2021-11-19 Thread Yifei Jiang
Add kvm_riscv_get/put_regs_timer to synchronize virtual time context from KVM. To set register of RISCV_TIMER_REG(state) will occur a error from KVM on kvm_timer_state == 0. It's better to adapt in KVM, but it doesn't matter that adaping in QEMU. Signed-off-by: Yifei Jiang Signed-off

[PATCH v1 05/12] target/riscv: Implement kvm_arch_put_registers

2021-11-19 Thread Yifei Jiang
Put GPR CSR and FP registers to kvm by KVM_SET_ONE_REG ioctl Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- target/riscv/kvm.c | 141 - 1 file changed, 140 insertions(+), 1 deletion(-) diff --git a/target

[PATCH v1 12/12] target/riscv: Support virtual time context synchronization

2021-11-19 Thread Yifei Jiang
Add virtual time context description to vmstate_riscv_cpu. After cpu being loaded, virtual time context is updated to KVM. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li --- target/riscv/machine.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/target/riscv/machine.c

[PATCH v1 09/12] target/riscv: Add host cpu type

2021-11-19 Thread Yifei Jiang
'host' type cpu is set isa to RV32 or RV64 simply, more isa info will obtain from KVM in kvm_arch_init_vcpu() Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 15 +++ target/riscv/cpu.h | 1 + 2 files changed, 16

[PATCH v1 08/12] target/riscv: Handle KVM_EXIT_RISCV_SBI exit

2021-11-19 Thread Yifei Jiang
Use char-fe to handle console sbi call, which implement early console io while apply 'earlycon=sbi' into kernel parameters. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li --- target/riscv/kvm.c | 42 - target/riscv/sbi_ecall_interface.h | 72

[PATCH v1 01/12] update-linux-headers: Add asm-riscv/kvm.h

2021-11-19 Thread Yifei Jiang
Add asm-riscv/kvm.h for RISC-V KVM, and update linux/kvm.h Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li --- linux-headers/asm-riscv/kvm.h | 128 ++ linux-headers/linux/kvm.h | 8 +++ 2 files changed, 136 insertions(+) create mode 100644 linux

[PATCH v1 04/12] target/riscv: Implement kvm_arch_get_registers

2021-11-19 Thread Yifei Jiang
Get GPR CSR and FP registers from kvm by KVM_GET_ONE_REG ioctl. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- target/riscv/kvm.c | 150 - 1 file changed, 149 insertions(+), 1 deletion(-) diff --git a/target

[PATCH v1 06/12] target/riscv: Support start kernel directly by KVM

2021-11-19 Thread Yifei Jiang
Get kernel and fdt start address in virt.c, and pass them to KVM when cpu reset. In addition, add kvm_riscv.h to place riscv specific interface. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- hw/riscv/boot.c | 11 +++ hw/riscv/virt.c

[PATCH v1 00/12] Add riscv kvm accel support

2021-11-19 Thread Yifei Jiang
scaling support(New patches 13, 14 and 15). - Fix the bug that guest vm can't reboot. Changes since RFC v2 - Fix checkpatch error at target/riscv/sbi_ecall_interface.h. - Add riscv migration support. Changes since RFC v1 - Add separate SBI ecall interface header. - Add riscv32 kvm accel suppo

[PATCH v1 03/12] target/riscv: Implement function kvm_arch_init_vcpu

2021-11-19 Thread Yifei Jiang
Get isa info from kvm while kvm init. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- target/riscv/kvm.c | 32 +++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c index

[PATCH RFC v6 11/12] target/riscv: Implement virtual time adjusting with vm state changing

2021-08-16 Thread Yifei Jiang
We hope that virtual time adjusts with vm state changing. When a vm is stopped, guest virtual time should stop counting and kvm_timer should be stopped. When the vm is resumed, guest virtual time should continue to count and kvm_timer should be restored. Signed-off-by: Yifei Jiang Signed-off

[PATCH RFC v6 04/12] target/riscv: Implement kvm_arch_get_registers

2021-08-16 Thread Yifei Jiang
Get GPR CSR and FP registers from kvm by KVM_GET_ONE_REG ioctl. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- target/riscv/kvm.c | 150 - 1 file changed, 149 insertions(+), 1 deletion(-) diff --git a/target

[PATCH RFC v6 02/12] target/riscv: Add target/riscv/kvm.c to place the public kvm interface

2021-08-16 Thread Yifei Jiang
Add target/riscv/kvm.c to place kvm_arch_* function needed by kvm/kvm-all.c. Meanwhile, add kvm support in meson.build file. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- meson.build | 2 + target/riscv/kvm.c | 133

[PATCH RFC v6 06/12] target/riscv: Support start kernel directly by KVM

2021-08-16 Thread Yifei Jiang
Get kernel and fdt start address in virt.c, and pass them to KVM when cpu reset. In addition, add kvm_riscv.h to place riscv specific interface. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- hw/riscv/boot.c | 11 +++ hw/riscv/virt.c

[PATCH RFC v6 00/12] Add riscv kvm accel support

2021-08-16 Thread Yifei Jiang
d separate SBI ecall interface header. - Add riscv32 kvm accel support. Yifei Jiang (12): linux-header: Update linux/kvm.h target/riscv: Add target/riscv/kvm.c to place the public kvm interface target/riscv: Implement function kvm_arch_init_vcpu target/riscv: Implement kvm_arch_get_regi

[PATCH RFC v6 05/12] target/riscv: Implement kvm_arch_put_registers

2021-08-16 Thread Yifei Jiang
Put GPR CSR and FP registers to kvm by KVM_SET_ONE_REG ioctl Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- target/riscv/kvm.c | 141 - 1 file changed, 140 insertions(+), 1 deletion(-) diff --git a/target

[PATCH RFC v6 07/12] target/riscv: Support setting external interrupt by KVM

2021-08-16 Thread Yifei Jiang
G, so move riscv_cpu_update_mip() to target/riscv/cpu.c from target/riscv/cpu_helper.c Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- target/riscv/cpu.c| 34 ++ target/riscv/cpu_helper.c | 27 --- target

[PATCH RFC v6 10/12] target/riscv: Add kvm_riscv_get/put_regs_timer

2021-08-16 Thread Yifei Jiang
Add kvm_riscv_get/put_regs_timer to synchronize virtual time context from KVM. To set register of RISCV_TIMER_REG(state) will occur a error from KVM on kvm_timer_state == 0. It's better to adapt in KVM, but it doesn't matter that adaping in QEMU. Signed-off-by: Yifei Jiang Signed-off

[PATCH RFC v6 12/12] target/riscv: Support virtual time context synchronization

2021-08-16 Thread Yifei Jiang
Add virtual time context description to vmstate_riscv_cpu. After cpu being loaded, virtual time context is updated to KVM. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li --- target/riscv/machine.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/target/riscv/machine.c

[PATCH RFC v6 03/12] target/riscv: Implement function kvm_arch_init_vcpu

2021-08-16 Thread Yifei Jiang
Get isa info from kvm while kvm init. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- target/riscv/kvm.c | 27 ++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c index

[PATCH RFC v6 08/12] target/riscv: Handle KVM_EXIT_RISCV_SBI exit

2021-08-16 Thread Yifei Jiang
Use char-fe to handle console sbi call, which implement early console io while apply 'earlycon=sbi' into kernel parameters. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li --- target/riscv/kvm.c | 42 - target/riscv/sbi_ecall_interface.h | 72

[PATCH RFC v6 01/12] linux-header: Update linux/kvm.h

2021-08-16 Thread Yifei Jiang
Update linux-headers/linux/kvm.h from https://github.com/avpatel/linux/tree/riscv_kvm_v19. Only use this header file, so here do not update all linux headers by update-linux-headers.sh until above KVM series is accepted. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li --- linux-headers

[PATCH RFC v6 09/12] target/riscv: Add host cpu type

2021-08-16 Thread Yifei Jiang
'host' type cpu is set isa to RV32 or RV64 simply, more isa info will obtain from KVM in kvm_arch_init_vcpu() Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 15 +++ target/riscv/cpu.h | 1 + 2 files changed, 16

[PATCH RFC v5 12/12] target/riscv: Support virtual time context synchronization

2021-04-12 Thread Yifei Jiang
Add virtual time context description to vmstate_riscv_cpu. After cpu being loaded, virtual time context is updated to KVM. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin --- target/riscv/machine.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/target/riscv/machine.c

[PATCH RFC v5 10/12] target/riscv: Add kvm_riscv_get/put_regs_timer

2021-04-12 Thread Yifei Jiang
Add kvm_riscv_get/put_regs_timer to synchronize virtual time context from KVM. To set register of RISCV_TIMER_REG(state) will occur a error from KVM on kvm_timer_state == 0. It's better to adapt in KVM, but it doesn't matter that adaping in QEMU. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng

[PATCH RFC v5 08/12] target/riscv: Handle KVM_EXIT_RISCV_SBI exit

2021-04-12 Thread Yifei Jiang
Use char-fe to handle console sbi call, which implement early console io while apply 'earlycon=sbi' into kernel parameters. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin --- target/riscv/kvm.c | 42 - target/riscv/sbi_ecall_interface.h | 72

[PATCH RFC v5 11/12] target/riscv: Implement virtual time adjusting with vm state changing

2021-04-12 Thread Yifei Jiang
We hope that virtual time adjusts with vm state changing. When a vm is stopped, guest virtual time should stop counting and kvm_timer should be stopped. When the vm is resumed, guest virtual time should continue to count and kvm_timer should be restored. Signed-off-by: Yifei Jiang Signed-off

[PATCH RFC v5 00/12] Add riscv kvm accel support

2021-04-12 Thread Yifei Jiang
Changes since RFC v2 - Fix checkpatch error at target/riscv/sbi_ecall_interface.h. - Add riscv migration support. Changes since RFC v1 - Add separate SBI ecall interface header. - Add riscv32 kvm accel support. Yifei Jiang (12): linux-header: Update linux/kvm.h target/riscv: Add target/

[PATCH RFC v5 04/12] target/riscv: Implement kvm_arch_get_registers

2021-04-12 Thread Yifei Jiang
Get GPR CSR and FP registers from kvm by KVM_GET_ONE_REG ioctl. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin --- target/riscv/kvm.c | 150 - 1 file changed, 149 insertions(+), 1 deletion(-) diff --git a/target/riscv/kvm.c b/target/riscv

[PATCH RFC v5 07/12] hw/riscv: PLIC update external interrupt by KVM when kvm enabled

2021-04-12 Thread Yifei Jiang
Only support supervisor external interrupt currently. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin --- hw/intc/sifive_plic.c| 29 - target/riscv/kvm-stub.c | 5 + target/riscv/kvm.c | 20 target/riscv/kvm_riscv.h | 1

[PATCH RFC v5 05/12] target/riscv: Implement kvm_arch_put_registers

2021-04-12 Thread Yifei Jiang
Put GPR CSR and FP registers to kvm by KVM_SET_ONE_REG ioctl Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin --- target/riscv/kvm.c | 142 - 1 file changed, 141 insertions(+), 1 deletion(-) diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c

[PATCH RFC v5 06/12] target/riscv: Support start kernel directly by KVM

2021-04-12 Thread Yifei Jiang
Get kernel and fdt start address in virt.c, and pass them to KVM when cpu reset. In addition, add kvm_riscv.h to place riscv specific interface. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin --- hw/riscv/boot.c | 11 +++ hw/riscv/virt.c | 7 +++ include/hw

[PATCH RFC v5 09/12] target/riscv: Add host cpu type

2021-04-12 Thread Yifei Jiang
'host' type cpu is set isa to RVXLEN simply, more isa info will obtain from KVM in kvm_arch_init_vcpu() Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin --- target/riscv/cpu.c | 9 + target/riscv/cpu.h | 1 + 2 files changed, 10 insertions(+) diff --git a/target/riscv/cpu.c b

[PATCH RFC v5 01/12] linux-header: Update linux/kvm.h

2021-04-12 Thread Yifei Jiang
Update linux-headers/linux/kvm.h from https://github.com/avpatel/linux/tree/riscv_kvm_v17. Only use this header file, so here do not update all linux headers by update-linux-headers.sh until above KVM series is accepted. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin --- linux-headers

[PATCH RFC v5 02/12] target/riscv: Add target/riscv/kvm.c to place the public kvm interface

2021-04-12 Thread Yifei Jiang
Add target/riscv/kvm.c to place kvm_arch_* function needed by kvm/kvm-all.c. Meanwhile, add kvm support in meson.build file. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin Reviewed-by: Alistair Francis --- meson.build | 2 + target/riscv/kvm.c | 133

[PATCH RFC v5 03/12] target/riscv: Implement function kvm_arch_init_vcpu

2021-04-12 Thread Yifei Jiang
Get isa info from kvm while kvm init. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin --- target/riscv/kvm.c | 27 ++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c index 687dd4b621..0d924be33f 100644

[PATCH v4 1/1] target-riscv: support QMP dump-guest-memory

2021-02-01 Thread Yifei Jiang
Add the support needed for creating prstatus elf notes. This allows us to use QMP dump-guest-memory. Now ELF notes of RISC-V only contain prstatus elf notes. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Reviewed-by: Palmer

[PATCH v4 0/1] target-riscv: support QMP dump-guest-memory

2021-02-01 Thread Yifei Jiang
ion and code comments Changes since v2 1. Add build-bugs. Changes since v1 1. Fix the build failure for RISC-V linux user. Yifei Jiang (1): target-riscv: support QMP dump-guest-memory target/riscv/arch_dump.c | 202 +++ target/riscv/cpu.c | 2 + target

[PATCH v3 0/1] target-riscv: support QMP dump-guest-memory

2021-01-14 Thread Yifei Jiang
s since v1 1. Fix the build failure for RISC-V linux user. Yifei Jiang (1): target-riscv: support QMP dump-guest-memory target/riscv/arch_dump.c | 202 +++ target/riscv/cpu.c | 2 + target/riscv/cpu.h | 4 + target/riscv/cpu_bits.h | 1 +

[PATCH v3 1/1] target-riscv: support QMP dump-guest-memory

2021-01-14 Thread Yifei Jiang
Add the support needed for creating prstatus elf notes. Now elf notes only contains user_regs. This allows us to use QMP dump-guest-memory. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li --- target/riscv/arch_dump.c | 202 +++ target/riscv/cpu.c

[PATCH v2 1/1] target-riscv: support QMP dump-guest-memory

2020-12-17 Thread Yifei Jiang
Add the support needed for creating prstatus elf notes. Now elf notes only contains user_regs. This allows us to use QMP dump-guest-memory. Signed-off-by: Yifei Jiang Signed-off-by: Mingwang Li --- target/riscv/arch_dump.c | 189 +++ target/riscv/cpu.c

[PATCH v2 0/1] target-riscv: support QMP dump-guest-memory

2020-12-17 Thread Yifei Jiang
e for RISC-V linux user. Yifei Jiang (1): target-riscv: support QMP dump-guest-memory target/riscv/arch_dump.c | 189 +++ target/riscv/cpu.c | 2 + target/riscv/cpu.h | 4 + target/riscv/cpu_bits.h | 1 + target/riscv/meson.build | 1 + 5 f

[PATCH RFC v4 15/15] target/riscv: Add time frequency migration support

2020-12-03 Thread Yifei Jiang
will be abort. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin --- target/riscv/machine.c | 8 1 file changed, 8 insertions(+) diff --git a/target/riscv/machine.c b/target/riscv/machine.c index ef2d5395a8..6955542fef 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c

[PATCH RFC v4 08/15] target/riscv: Handle KVM_EXIT_RISCV_SBI exit

2020-12-03 Thread Yifei Jiang
Use char-fe to handle console sbi call, which implement early console io while apply 'earlycon=sbi' into kernel parameters. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin --- target/riscv/kvm.c | 42 - target/riscv/sbi_ecall_interface.h | 72

  1   2   >