[PATCH v4 5/9] target/loongarch: Implement kvm_arch_init function

2024-01-05 Thread Tianrui Zhao
Implement the kvm_arch_init of loongarch, in the function, the KVM_CAP_MP_STATE cap is checked by kvm ioctl. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li Reviewed-by: Richard Henderson Reviewed-by: Song Gao --- target/loongarch/kvm/kvm.c | 1 + 1 file changed, 1 insertion(+) diff

[PATCH v4 2/9] target/loongarch: Define some kvm_arch interfaces

2024-01-05 Thread Tianrui Zhao
Define some functions in target/loongarch/kvm/kvm.c, such as kvm_arch_put_registers, kvm_arch_get_registers and kvm_arch_handle_exit, etc. which are needed by kvm/kvm-all.c. Now the most functions has no content and they will be implemented in the next patches. Signed-off-by: Tianrui Zhao Signed

[PATCH v4 0/9] Add loongarch kvm accel support

2024-01-05 Thread Tianrui Zhao
SET_ONE_UREG64 macro in target/loongarch, and use the common interface kvm_get/set_one_reg to replace it. 3. Resolve the compiling errors when LoongArch is built by other archs. Tianrui Zhao (9): linux-headers: Synchronize linux headers from linux v6.7.0-rc8 target/loongarch: Define some kvm_arc

[PATCH v4 1/9] linux-headers: Synchronize linux headers from linux v6.7.0-rc8

2024-01-05 Thread Tianrui Zhao
Use the scripts/update-linux-headers.sh to synchronize linux headers from linux v6.7.0-rc8. We mainly want to add the loongarch linux headers and then add the loongarch kvm support based on it. Signed-off-by: Tianrui Zhao Acked-by: Song Gao --- include/standard-headers/drm/drm_fourcc.h

[PATCH v4 6/9] target/loongarch: Implement kvm_arch_init_vcpu

2024-01-05 Thread Tianrui Zhao
. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li Reviewed-by: Song Gao --- target/loongarch/cpu.h| 2 ++ target/loongarch/kvm/kvm.c| 23 +++ target/loongarch/trace-events | 2 ++ 3 files changed, 27 insertions(+) diff --git a/target/loongarch/cpu.h b/target

[PATCH v4 9/9] target/loongarch: Add loongarch kvm into meson build

2024-01-05 Thread Tianrui Zhao
Add kvm.c into meson.build to compile it when kvm is configed. Meanwhile in meson.build, we set the kvm_targets to loongarch64-softmmu when the cpu is loongarch. And fix the compiling error when config is enable-kvm,disable-tcg. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li Reviewed

[PATCH v4 7/9] target/loongarch: Implement kvm_arch_handle_exit

2024-01-05 Thread Tianrui Zhao
Implement kvm_arch_handle_exit for loongarch. In this function, the KVM_EXIT_LOONGARCH_IOCSR is handled, we read or write the iocsr address space by the addr, length and is_write argument in kvm_run. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li Reviewed-by: Richard Henderson Reviewed

[PATCH v4 3/9] target/loongarch: Supplement vcpu env initial when vcpu reset

2024-01-05 Thread Tianrui Zhao
Supplement vcpu env initial when vcpu reset, including init vcpu CSR_CPUID,CSR_TID to cpu->cpu_index. The two regs will be used in kvm_get/set_csr_ioctl. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li Reviewed-by: Song Gao --- target/loongarch/cpu.c | 2 ++ target/loongarch/cpu.h

[PATCH v4 8/9] target/loongarch: Implement set vcpu intr for kvm

2024-01-05 Thread Tianrui Zhao
Implement loongarch kvm set vcpu interrupt interface, when a irq is set in vcpu, we use the KVM_INTERRUPT ioctl to set intr into kvm. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li Reviewed-by: Song Gao --- target/loongarch/cpu.c | 34 +--- target

[PATCH v4 4/9] target/loongarch: Implement kvm get/set registers

2024-01-05 Thread Tianrui Zhao
Implement kvm_arch_get/set_registers interfaces, many regs can be get/set in the function, such as core regs, csr regs, fpu regs, mp state, etc. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li Reviewed-by: Song Gao Change-Id: Ia8fc48fe08b1768853f7729e77d37cdf270031e4 --- meson.build

[PATCH v3 8/9] target/loongarch: Implement set vcpu intr for kvm

2023-12-28 Thread Tianrui Zhao
Implement loongarch kvm set vcpu interrupt interface, when a irq is set in vcpu, we use the KVM_INTERRUPT ioctl to set intr into kvm. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li --- target/loongarch/cpu.c | 32 +++- target/loongarch/kvm.c

[PATCH v3 3/9] target/loongarch: Supplement vcpu env initial when vcpu reset

2023-12-28 Thread Tianrui Zhao
Supplement vcpu env initial when vcpu reset, including init vcpu CSR_CPUID,CSR_TID to cpu->cpu_index. The two regs will be used in kvm_get/set_csr_ioctl. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li --- target/loongarch/cpu.c | 2 ++ target/loongarch/cpu.h | 2 +- 2 files changed

[PATCH v3 1/9] linux-headers: Synchronize linux headers from linux v6.7.0-rc7

2023-12-28 Thread Tianrui Zhao
Use the scripts/update-linux-headers.sh to synchronize linux headers from linux v6.7.0-rc7. We mainly want to add the loongarch linux headers and then add the loongarch kvm support based on it. Signed-off-by: Tianrui Zhao --- include/standard-headers/drm/drm_fourcc.h | 2 + include

[PATCH v3 6/9] target/loongarch: Implement kvm_arch_init_vcpu

2023-12-28 Thread Tianrui Zhao
. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li --- target/loongarch/cpu.h| 2 ++ target/loongarch/kvm.c| 23 +++ target/loongarch/trace-events | 2 ++ 3 files changed, 27 insertions(+) diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h index

[PATCH v3 7/9] target/loongarch: Implement kvm_arch_handle_exit

2023-12-28 Thread Tianrui Zhao
Implement kvm_arch_handle_exit for loongarch. In this function, the KVM_EXIT_LOONGARCH_IOCSR is handled, we read or write the iocsr address space by the addr, length and is_write argument in kvm_run. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li Reviewed-by: Richard Henderson

[PATCH v3 0/9] Add loongarch kvm accel support

2023-12-28 Thread Tianrui Zhao
kvm_get/set_one_reg to replace it. 3. Resolve the compiling errors when LoongArch is built by other archs. Tianrui Zhao (9): linux-headers: Synchronize linux headers from linux v6.7.0-rc7 target/loongarch: Define some kvm_arch interfaces target/loongarch: Supplement vcpu env initial when

[PATCH v3 4/9] target/loongarch: Implement kvm get/set registers

2023-12-28 Thread Tianrui Zhao
Implement kvm_arch_get/set_registers interfaces, many regs can be get/set in the function, such as core regs, csr regs, fpu regs, mp state, etc. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li --- meson.build | 1 + target/loongarch/cpu.c| 3 + target

[PATCH v3 5/9] target/loongarch: Implement kvm_arch_init function

2023-12-28 Thread Tianrui Zhao
Implement the kvm_arch_init of loongarch, in the function, the KVM_CAP_MP_STATE cap is checked by kvm ioctl. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li Reviewed-by: Richard Henderson --- target/loongarch/kvm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/loongarch

[PATCH v3 2/9] target/loongarch: Define some kvm_arch interfaces

2023-12-28 Thread Tianrui Zhao
Define some functions in target/loongarch/kvm.c, such as kvm_arch_put_registers, kvm_arch_get_registers and kvm_arch_handle_exit, etc. which are needed by kvm/kvm-all.c. Now the most functions has no content and they will be implemented in the next patches. Signed-off-by: Tianrui Zhao Signed-off

[PATCH v3 9/9] target/loongarch: Add loongarch kvm into meson build

2023-12-28 Thread Tianrui Zhao
Add kvm.c into meson.build to compile it when kvm is configed. Meanwhile in meson.build, we set the kvm_targets to loongarch64-softmmu when the cpu is loongarch. And fix the compiling error when config is enable-kvm,disable-tcg. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li Reviewed

[PATCH v2 3/9] target/loongarch: Supplement vcpu env initial when vcpu reset

2023-12-19 Thread Tianrui Zhao
Supplement vcpu env initial when vcpu reset, including init vcpu CSR_CPUID,CSR_TID to cpu->cpu_index. The two regs will be used in kvm_get/set_csr_ioctl. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li --- target/loongarch/cpu.c | 2 ++ target/loongarch/cpu.h | 2 +- 2 files changed

[PATCH v2 1/9] linux-headers: Synchronize linux headers from linux v6.7.0-rc6

2023-12-19 Thread Tianrui Zhao
Use the scripts/update-linux-headers.sh to synchronize linux headers from linux v6.7.0-rc6. We mainly want to add the loongarch linux headers and then add the loongarch kvm support based on it. Signed-off-by: Tianrui Zhao --- include/standard-headers/drm/drm_fourcc.h | 2 + include

[PATCH v2 5/9] target/loongarch: Implement kvm_arch_init function

2023-12-19 Thread Tianrui Zhao
Implement the kvm_arch_init of loongarch, in the function, the KVM_CAP_MP_STATE cap is checked by kvm ioctl. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li Reviewed-by: Richard Henderson --- target/loongarch/kvm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/loongarch

[PATCH v2 7/9] target/loongarch: Implement kvm_arch_handle_exit

2023-12-19 Thread Tianrui Zhao
Implement kvm_arch_handle_exit for loongarch. In this function, the KVM_EXIT_LOONGARCH_IOCSR is handled, we read or write the iocsr address space by the addr, length and is_write argument in kvm_run. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li Reviewed-by: Richard Henderson

[PATCH v2 0/9] Add loongarch kvm accel support

2023-12-19 Thread Tianrui Zhao
KVM patch series are accepted. 2. Remove the DPRINTF macro in kvm.c and use trace events to replace it, we add some trace functions such as trace_kvm_handle_exit, trace_kvm_set_intr, trace_kvm_failed_get_csr, etc. 3. Remove the unused functions in kvm_stub.c and move stub function into the suitable p

[PATCH v2 4/9] target/loongarch: Implement kvm get/set registers

2023-12-19 Thread Tianrui Zhao
Implement kvm_arch_get/set_registers interfaces, many regs can be get/set in the function, such as core regs, csr regs, fpu regs, mp state, etc. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li --- meson.build | 1 + target/loongarch/cpu.c| 3 + target

[PATCH v2 9/9] target/loongarch: Add loongarch kvm into meson build

2023-12-19 Thread Tianrui Zhao
Add kvm.c into meson.build to compile it when kvm is configed. Meanwhile in meson.build, we set the kvm_targets to loongarch64-softmmu when the cpu is loongarch. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li Reviewed-by: Richard Henderson --- meson.build | 2

[PATCH v2 2/9] target/loongarch: Define some kvm_arch interfaces

2023-12-19 Thread Tianrui Zhao
Define some functions in target/loongarch/kvm.c, such as kvm_arch_put_registers, kvm_arch_get_registers and kvm_arch_handle_exit, etc. which are needed by kvm/kvm-all.c. Now the most functions has no content and they will be implemented in the next patches. Signed-off-by: Tianrui Zhao Signed-off

[PATCH v2 8/9] target/loongarch: Implement set vcpu intr for kvm

2023-12-19 Thread Tianrui Zhao
Implement loongarch kvm set vcpu interrupt interface, when a irq is set in vcpu, we use the KVM_INTERRUPT ioctl to set intr into kvm. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li --- target/loongarch/cpu.c | 18 +- target/loongarch/kvm.c | 15

[PATCH v2 6/9] target/loongarch: Implement kvm_arch_init_vcpu

2023-12-19 Thread Tianrui Zhao
. Signed-off-by: Tianrui Zhao Signed-off-by: xianglai li --- target/loongarch/cpu.h| 2 ++ target/loongarch/kvm.c| 23 +++ target/loongarch/trace-events | 2 ++ 3 files changed, 27 insertions(+) diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h index

[PATCH] linux-headers: Synchronize linux headers from linux v6.7.0-rc1

2023-11-13 Thread Tianrui Zhao
Use the scripts/update-linux-headers.sh to synchronize linux headers from linux v6.7.0-rc1. We mainly want to add the loongarch linux headers and then add the loongarch kvm support based on it. Signed-off-by: Tianrui Zhao --- include/standard-headers/drm/drm_fourcc.h | 2 + include

[PATCH v3] hw/loongarch: Add virtio-mmio bus support

2023-09-11 Thread Tianrui Zhao
Add virtio-mmio bus support for LoongArch, so that devices could be added in the virtio-mmio bus. Signed-off-by: Tianrui Zhao Change-Id: Ib882005106562e0dfe74122a7fa2430fa081bfb2 --- hw/loongarch/Kconfig | 1 + hw/loongarch/acpi-build.c | 25 + hw/loongarch

[PATCH v2] hw/loongarch: Add virtio-mmio bus support

2023-09-07 Thread Tianrui Zhao
Add virtio-mmio bus support for LoongArch, so that devices could be added in the virtio-mmio bus. And add it's address info and interrupt number into fdt and dsdt. Signed-off-by: Tianrui Zhao --- hw/loongarch/Kconfig | 1 + hw/loongarch/acpi-build.c | 20 hw

[PATCH] hw/loongarch: Add virtio-mmio bus support

2023-09-05 Thread Tianrui Zhao
Add virtio-mmio bus support for LoongArch, so that devices could be added in the virtio-mmio bus. Signed-off-by: Tianrui Zhao --- hw/loongarch/Kconfig | 1 + hw/loongarch/virt.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/hw/loongarch/Kconfig b/hw/loongarch/Kconfig index 1e7c5b43c5

[PATCH] hw/loongarch: Supplement cpu topology arguments

2023-06-13 Thread Tianrui Zhao
Supplement LoongArch cpu topology arguments, including support socket and threads per core. Base-on: https://patchew.org/QEMU/20230613122613.2471743-1-zhaotian...@loongson.cn/ Signed-off-by: Song Gao Signed-off-by: Tianrui Zhao --- hw/loongarch/acpi-build.c | 4 hw/loongarch/virt.c

[PATCH v2] hw/loongarch: Add numa support

2023-06-13 Thread Tianrui Zhao
From: Song Gao 1. Implement some functions for LoongArch numa support; 2. Implement fdt_add_memory_node() for fdt; 3. build_srat() fills node_id and adds build numa memory. Base-on: https://patchew.org/QEMU/20230613120552.2471420-1-zhaotian...@loongson.cn/ Signed-off-by: Tianrui Zhao Signed

[PATCH v2 1/2] hw/loongarch/virt: Add cpu arch_id support

2023-06-13 Thread Tianrui Zhao
With acpi madt table, there is cpu physical coreid, which may be different with logical id in qemu. This patch adds cpu arch_id support, and fill madt table with arch_id. For the present cpu arch_id is still equal to logical id. Signed-off-by: Tianrui Zhao Signed-off-by: Song Gao --- hw

[PATCH v2 2/2] hw/intc: Set physical cpuid route for LoongArch ipi device

2023-06-13 Thread Tianrui Zhao
LoongArch ipi device uses physical cpuid to route to different vcpus rather logical cpuid, and the physical cpuid is the same with cpuid in acpi dsdt and srat table. Signed-off-by: Tianrui Zhao Signed-off-by: Song Gao --- hw/intc/loongarch_ipi.c | 44

[PATCH v2 0/2] Add LoongArch cpu arch_id support

2023-06-13 Thread Tianrui Zhao
This patch add cpu arch_id for LoongArch: 1. Add LoongArch cpu arch_id support; 2. Fill Acpi table with arch_id; 3. set physical cpuid route for LoongArch ipi device. changes for v2: 1. Fix core_id calculation in ms->possible_cpus, it should be (n % smp.cores) Tianrui Zhao (2): hw/loonga

Re: [PATCH] hw/smbios: fix thead count field in type 4 table

2023-05-31 Thread Tianrui Zhao
在 2023年05月31日 16:42, Zhao Liu 写道: On Tue, May 30, 2023 at 08:20:34PM +0800, Tianrui Zhao wrote: Date: Tue, 30 May 2023 20:20:34 +0800 From: Tianrui Zhao Subject: [PATCH] hw/smbios: fix thead count field in type 4 table X-Mailer: git-send-email 2.39.1 The thread_count value in smbios type_4

[PATCH] hw/loongarch: Supplement cpu topology arguments

2023-05-30 Thread Tianrui Zhao
Supplement LoongArch cpu topology arguments, including support socket and threads per core. Based-on: <20230518014115.117869-1-gaos...@loongson.cn> Signed-off-by: Tianrui Zhao --- hw/loongarch/acpi-build.c | 4 hw/loongarch/virt.c | 9 - 2 files changed, 12 insertions

[PATCH] hw/smbios: fix thead count field in type 4 table

2023-05-30 Thread Tianrui Zhao
Characteristics: None Signed-off-by: Tianrui Zhao --- hw/smbios/smbios.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index d2007e70fb..56aeaa069d 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -713,6 +713,7 @@ s

Re: [PATCH v1 1/2] hw/loongarch/virt: Add cpu arch_id support

2023-05-30 Thread Tianrui Zhao
+ms->possible_cpus->cpus[n].type = ms->cpu_type; +ms->possible_cpus->cpus[n].arch_id = n; +ms->possible_cpus->cpus[n].props.has_core_id = true; +ms->possible_cpus->cpus[n].props.core_id = n; Should this be core_id = (n / ms->smp.threads

Re: [PATCH v1] hw/loongarch: Add numa support

2023-05-28 Thread Tianrui Zhao
em", + +memory_region_add_subregion(address_space_mem, 0, machine->ram); Hi gaosong Why need we add machine->ram into address_space_mem at 0 addr ? I think it may break the previous system memory space and the address of high_ram is VIRT_HIGHMEM_BASE, so it may should not add the whole ram i

[PATCH RFC v3 1/9] linux-headers: Add KVM headers for loongarch

2023-05-05 Thread Tianrui Zhao
This patch is only a placeholder now, which is used to show some kvm structures and macros for reviewers. And it will be replaced by using update-linux-headers.sh when the linux loongarch kvm patches are accepted. Signed-off-by: Tianrui Zhao --- linux-headers/asm-loongarch/kvm.h | 99

[PATCH RFC v3 4/9] target/loongarch: Implement kvm get/set registers

2023-05-05 Thread Tianrui Zhao
Implement kvm_arch_get/set_registers interfaces, many regs can be get/set in the function, such as core regs, csr regs, fpu regs, mp state, etc. Signed-off-by: Tianrui Zhao Reviewed-by: Richard Henderson --- meson.build | 1 + target/loongarch/cpu.c| 3 + target

[PATCH RFC v3 8/9] target/loongarch: Implement set vcpu intr for kvm

2023-05-05 Thread Tianrui Zhao
Implement loongarch kvm set vcpu interrupt interface, when a irq is set in vcpu, we use the KVM_INTERRUPT ioctl to set intr into kvm. Signed-off-by: Tianrui Zhao --- target/loongarch/cpu.c | 18 +- target/loongarch/kvm-stub.c | 11 +++ target/loongarch

[PATCH RFC v3 9/9] target/loongarch: Add loongarch kvm into meson build

2023-05-05 Thread Tianrui Zhao
Add kvm.c and kvm-stub.c into meson.build to compile it when kvm is configed. Meanwhile in meson.build, we set the kvm_targets to loongarch64-softmmu when the cpu is loongarch. Signed-off-by: Tianrui Zhao Reviewed-by: Richard Henderson --- meson.build | 2 ++ target/loongarch

[PATCH RFC v3 7/9] target/loongarch: Implement kvm_arch_handle_exit

2023-05-05 Thread Tianrui Zhao
Implement kvm_arch_handle_exit for loongarch. In this function, the KVM_EXIT_LOONGARCH_IOCSR is handled, we read or write the iocsr address space by the addr, length and is_write argument in kvm_run. Signed-off-by: Tianrui Zhao Reviewed-by: Richard Henderson --- target/loongarch/kvm.c

[PATCH RFC v3 0/9] Add loongarch kvm accel support

2023-05-05 Thread Tianrui Zhao
such as trace_kvm_handle_exit, trace_kvm_set_intr, trace_kvm_failed_get_csr, etc. 3. Remove the unused functions in kvm_stub.c and move stub function into the suitable patch. Tianrui Zhao (9): linux-headers: Add KVM headers for loongarch target/loongarch: Define some kvm_arch interfaces target/loongarc

[PATCH RFC v3 3/9] target/loongarch: Supplement vcpu env initial when vcpu reset

2023-05-05 Thread Tianrui Zhao
Supplement vcpu env initial when vcpu reset, including init vcpu CSR_CPUID,CSR_TID to cpu->cpu_index. The two regs will be used in kvm_get/set_csr_ioctl. Signed-off-by: Tianrui Zhao --- target/loongarch/cpu.c | 2 ++ target/loongarch/cpu.h | 1 + 2 files changed, 3 insertions(+) diff --

[PATCH RFC v3 5/9] target/loongarch: Implement kvm_arch_init function

2023-05-05 Thread Tianrui Zhao
Implement the kvm_arch_init of loongarch, in the function, the KVM_CAP_MP_STATE cap is checked by kvm ioctl. Signed-off-by: Tianrui Zhao Reviewed-by: Richard Henderson --- target/loongarch/kvm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/loongarch/kvm.c b/target/loongarch/kvm.c

[PATCH RFC v3 6/9] target/loongarch: Implement kvm_arch_init_vcpu

2023-05-05 Thread Tianrui Zhao
. Signed-off-by: Tianrui Zhao --- target/loongarch/cpu.h| 2 ++ target/loongarch/kvm.c| 23 +++ target/loongarch/trace-events | 2 ++ 3 files changed, 27 insertions(+) diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h index cf3fce4577..beb070de25 100644

[PATCH RFC v3 2/9] target/loongarch: Define some kvm_arch interfaces

2023-05-05 Thread Tianrui Zhao
Define some functions in target/loongarch/kvm.c, such as kvm_arch_put_registers, kvm_arch_get_registers and kvm_arch_handle_exit, etc. which are needed by kvm/kvm-all.c. Now the most functions has no content and they will be implemented in the next patches. Signed-off-by: Tianrui Zhao Reviewed

Re: [PATCH RFC v2 6/9] target/loongarch: Implement kvm_arch_init_vcpu

2023-05-03 Thread Tianrui Zhao
在 2023年05月02日 19:32, Richard Henderson 写道: On 4/27/23 08:26, Tianrui Zhao wrote: +static void kvm_loongarch_vm_stage_change(void *opaque, bool running, Typo: state +uint64_t counter_value; I know naming is hard, but this is so generic it is difficult

Re: [PATCH RFC v2 4/9] target/loongarch: Implement kvm get/set registers

2023-05-03 Thread Tianrui Zhao
在 2023年05月02日 19:24, Richard Henderson 写道: On 4/27/23 08:26, Tianrui Zhao wrote: Implement kvm_arch_get/set_registers interfaces, many regs can be get/set in the function, such as core regs, csr regs, fpu regs, mp state, etc. Signed-off-by: Tianrui Zhao --- meson.build

Re: [PATCH RFC v2 3/9] target/loongarch: Supplement vcpu env initial when vcpu reset

2023-05-03 Thread Tianrui Zhao
在 2023年05月02日 19:04, Richard Henderson 写道: On 4/27/23 08:26, Tianrui Zhao wrote: Supplement vcpu env initial when vcpu reset, including init vcpu mp_state value to KVM_MP_STATE_RUNNABLE and init vcpu CSR_CPUID,CSR_TID to cpu->cpu_index. Signed-off-by: Tianrui Zhao --- target/loonga

[PATCH RFC v2 4/9] target/loongarch: Implement kvm get/set registers

2023-04-27 Thread Tianrui Zhao
Implement kvm_arch_get/set_registers interfaces, many regs can be get/set in the function, such as core regs, csr regs, fpu regs, mp state, etc. Signed-off-by: Tianrui Zhao --- meson.build | 1 + target/loongarch/kvm.c| 356 +- target

[PATCH RFC v2 6/9] target/loongarch: Implement kvm_arch_init_vcpu

2023-04-27 Thread Tianrui Zhao
. Signed-off-by: Tianrui Zhao --- target/loongarch/cpu.h| 1 + target/loongarch/kvm.c| 23 +++ target/loongarch/trace-events | 2 ++ 3 files changed, 26 insertions(+) diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h index 86b9f26d60..473d9986f3 100644

[PATCH RFC v2 3/9] target/loongarch: Supplement vcpu env initial when vcpu reset

2023-04-27 Thread Tianrui Zhao
Supplement vcpu env initial when vcpu reset, including init vcpu mp_state value to KVM_MP_STATE_RUNNABLE and init vcpu CSR_CPUID,CSR_TID to cpu->cpu_index. Signed-off-by: Tianrui Zhao --- target/loongarch/cpu.c | 3 +++ target/loongarch/cpu.h | 2 ++ 2 files changed, 5 insertions(+) diff --

[PATCH RFC v2 2/9] target/loongarch: Define some kvm_arch interfaces

2023-04-27 Thread Tianrui Zhao
Define some functions in target/loongarch/kvm.c, such as kvm_arch_put_registers, kvm_arch_get_registers and kvm_arch_handle_exit, etc. which are needed by kvm/kvm-all.c. Now the most functions has no content and they will be implemented in the next patches. Signed-off-by: Tianrui Zhao

[PATCH RFC v2 7/9] target/loongarch: Implement kvm_arch_handle_exit

2023-04-27 Thread Tianrui Zhao
Implement kvm_arch_handle_exit for loongarch. In this function, the KVM_EXIT_LOONGARCH_IOCSR is handled, we read or write the iocsr address space by the addr, length and is_write argument in kvm_run. Signed-off-by: Tianrui Zhao --- target/loongarch/kvm.c| 24

[PATCH RFC v2 8/9] target/loongarch: Implement set vcpu intr for kvm

2023-04-27 Thread Tianrui Zhao
Implement loongarch kvm set vcpu interrupt interface, when a irq is set in vcpu, we use the KVM_INTERRUPT ioctl to set intr into kvm. Signed-off-by: Tianrui Zhao --- target/loongarch/cpu.c | 18 +- target/loongarch/kvm-stub.c | 11 +++ target/loongarch

[PATCH RFC v2 0/9] Add loongarch kvm accel support

2023-04-27 Thread Tianrui Zhao
_stub.c and move stub function into the suitable patch. Tianrui Zhao (9): linux-headers: Add KVM headers for loongarch target/loongarch: Define some kvm_arch interfaces target/loongarch: Supplement vcpu env initial when vcpu reset target/loongarch: Implement kvm get/set registers target/loon

[PATCH RFC v2 9/9] target/loongarch: Add loongarch kvm into meson build

2023-04-27 Thread Tianrui Zhao
Add kvm.c and kvm-stub.c into meson.build to compile it when kvm is configed. Meanwhile in meson.build, we set the kvm_targets to loongarch64-softmmu when the cpu is loongarch. Signed-off-by: Tianrui Zhao --- meson.build | 2 ++ target/loongarch/meson.build | 1 + 2 files

[PATCH RFC v2 1/9] linux-headers: Add KVM headers for loongarch

2023-04-27 Thread Tianrui Zhao
This patch is only a placeholder now, which is used to show some kvm structures and macros for reviewers. And it will be replaced by using update-linux-headers.sh when the linux loongarch kvm patches are accepted. Signed-off-by: Tianrui Zhao --- linux-headers/asm-loongarch/kvm.h | 99

[PATCH RFC v2 5/9] target/loongarch: Implement kvm_arch_init function

2023-04-27 Thread Tianrui Zhao
Implement the kvm_arch_init of loongarch, in the function, the KVM_CAP_MP_STATE cap is checked by kvm ioctl. Signed-off-by: Tianrui Zhao --- target/loongarch/kvm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/loongarch/kvm.c b/target/loongarch/kvm.c index 50662fd3fb..8dea294930

Re: [PATCH RFC v1 01/10] linux-headers: Add KVM headers for loongarch

2023-04-23 Thread Tianrui Zhao
在 2023年04月20日 20:59, Tianrui Zhao 写道: 在 2023年04月20日 17:49, Cornelia Huck 写道: On Thu, Apr 20 2023, Tianrui Zhao wrote: Add asm-loongarch/kvm.h for loongarch KVM, and update the linux/kvm.h about loongarch part. The structures in the header are used as kvm_ioctl arguments. Just

Re: [PATCH RFC v1 01/10] linux-headers: Add KVM headers for loongarch

2023-04-20 Thread Tianrui Zhao
在 2023年04月20日 17:49, Cornelia Huck 写道: On Thu, Apr 20 2023, Tianrui Zhao wrote: Add asm-loongarch/kvm.h for loongarch KVM, and update the linux/kvm.h about loongarch part. The structures in the header are used as kvm_ioctl arguments. Just a procedural note: It's probably best

Re: [PATCH RFC v1 09/10] target/loongarch: Add kvm-stub.c

2023-04-20 Thread Tianrui Zhao
在 2023年04月20日 18:04, Philippe Mathieu-Daudé 写道: On 20/4/23 11:36, Tianrui Zhao wrote: Add kvm-stub.c for loongarch, there are two stub functions: kvm_loongarch_reset_vcpu and kvm_loongarch_set_interrupt. Signed-off-by: Tianrui Zhao --- target/loongarch/kvm-stub.c | 17

Re: [PATCH RFC v1 07/10] target/loongarch: Implement kvm_arch_handle_exit

2023-04-20 Thread Tianrui Zhao
在 2023年04月20日 18:00, Philippe Mathieu-Daudé 写道: On 20/4/23 11:36, Tianrui Zhao wrote: Implement kvm_arch_handle_exit for loongarch. In this function, the KVM_EXIT_LOONGARCH_IOCSR is handled, we read or write the iocsr address space by the addr, length and is_write argument in kvm_run

[PATCH RFC v1 02/10] target/loongarch: Define some kvm_arch interfaces

2023-04-20 Thread Tianrui Zhao
Define some functions in target/loongarch/kvm.c, such as kvm_arch_put_registers, kvm_arch_get_registers and kvm_arch_handle_exit, etc. which are needed by kvm/kvm-all.c. Now the most functions has no content and they will be implemented in the next patches. Signed-off-by: Tianrui Zhao

[PATCH RFC v1 05/10] target/loongarch: Implement kvm_arch_init function

2023-04-20 Thread Tianrui Zhao
Implement the kvm_arch_init of loongarch, in the function, the KVM_CAP_MP_STATE cap is checked by kvm ioctl. Signed-off-by: Tianrui Zhao --- target/loongarch/kvm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/loongarch/kvm.c b/target/loongarch/kvm.c index 74d499b675..53f495a588

[PATCH RFC v1 07/10] target/loongarch: Implement kvm_arch_handle_exit

2023-04-20 Thread Tianrui Zhao
Implement kvm_arch_handle_exit for loongarch. In this function, the KVM_EXIT_LOONGARCH_IOCSR is handled, we read or write the iocsr address space by the addr, length and is_write argument in kvm_run. Signed-off-by: Tianrui Zhao --- target/loongarch/kvm.c | 24 +++- 1 file

[PATCH RFC v1 08/10] target/loongarch: Implement set vcpu intr for kvm

2023-04-20 Thread Tianrui Zhao
Implement loongarch kvm set vcpu interrupt interface, when a irq is set in vcpu, we use the KVM_INTERRUPT ioctl to set intr into kvm. Signed-off-by: Tianrui Zhao --- target/loongarch/cpu.c | 18 +- target/loongarch/kvm.c | 16 target

[PATCH RFC v1 04/10] target/loongarch: Implement kvm get/set registers

2023-04-20 Thread Tianrui Zhao
Implement kvm_arch_get/set_registers interfaces, many regs can be get/set in the function, such as core regs, csr regs, fpu regs, mp state, etc. Signed-off-by: Tianrui Zhao --- target/loongarch/kvm.c | 353 - 1 file changed, 351 insertions(+), 2 deletions

[PATCH RFC v1 09/10] target/loongarch: Add kvm-stub.c

2023-04-20 Thread Tianrui Zhao
Add kvm-stub.c for loongarch, there are two stub functions: kvm_loongarch_reset_vcpu and kvm_loongarch_set_interrupt. Signed-off-by: Tianrui Zhao --- target/loongarch/kvm-stub.c | 17 + target/loongarch/kvm_loongarch.h | 1 + 2 files changed, 18 insertions(+) create mode

[PATCH RFC v1 06/10] target/loongarch: Implement kvm_arch_init_vcpu

2023-04-20 Thread Tianrui Zhao
. Signed-off-by: Tianrui Zhao --- target/loongarch/cpu.h | 1 + target/loongarch/kvm.c | 23 +++ 2 files changed, 24 insertions(+) diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h index 86b9f26d60..473d9986f3 100644 --- a/target/loongarch/cpu.h +++ b/target/loongarch

[PATCH RFC v1 01/10] linux-headers: Add KVM headers for loongarch

2023-04-20 Thread Tianrui Zhao
Add asm-loongarch/kvm.h for loongarch KVM, and update the linux/kvm.h about loongarch part. The structures in the header are used as kvm_ioctl arguments. Signed-off-by: Tianrui Zhao --- linux-headers/asm-loongarch/kvm.h | 99 +++ linux-headers/linux/kvm.h

[PATCH RFC v1 03/10] target/loongarch: Supplement vcpu env initial when vcpu reset

2023-04-20 Thread Tianrui Zhao
Supplement vcpu env initial when vcpu reset, including init vcpu mp_state value to KVM_MP_STATE_RUNNABLE and init vcpu CSR_CPUID,CSR_TID to cpu->cpu_index. Signed-off-by: Tianrui Zhao --- target/loongarch/cpu.c | 3 +++ target/loongarch/cpu.h | 2 ++ 2 files changed, 5 insertions(+) diff --

[PATCH RFC v1 00/10] Add loongarch kvm accel support

2023-04-20 Thread Tianrui Zhao
rial stdio -monitor telnet:localhost:4495,server,nowait \ -append "root=/dev/ram rdinit=/sbin/init console=ttyS0,115200" \ --nographic Tianrui Zhao (10): linux-headers: Add KVM headers for loongarch target/loongarch: Define some kvm_arch interfaces target/loongarch: Supplement v

[PATCH RFC v1 10/10] target/loongarch: Add kvm file into meson build

2023-04-20 Thread Tianrui Zhao
Add kvm.c and kvm-stub.c into meson.build to compile it when kvm is configed. Meanwhile in meson.build, we set the kvm_targets to loongarch64-softmmu when the cpu is loongarch. Signed-off-by: Tianrui Zhao --- meson.build | 2 ++ target/loongarch/meson.build | 1 + 2 files

Re: [PATCH] target/loongarch: Add CSR_CPUID reg in cpu_env

2023-04-19 Thread Tianrui Zhao
在 2023年04月18日 20:45, Tianrui Zhao 写道: 在 2023年04月18日 20:40, Song Gao 写道: Hi, Tianrui 在 2023/4/18 下午8:20, Tianrui Zhao 写道: Add CSR_CPUID register in cpu_env to save the cpu_index value. Why do we need to do this? For tcg mode, it is enough to use cpu_index. You need to explain

Re: [PATCH] target/loongarch: Add CSR_CPUID reg in cpu_env

2023-04-18 Thread Tianrui Zhao
在 2023年04月18日 20:40, Song Gao 写道: Hi, Tianrui 在 2023/4/18 下午8:20, Tianrui Zhao 写道: Add CSR_CPUID register in cpu_env to save the cpu_index value. Why do we need to do this? For tcg mode, it is enough to use cpu_index. You need to explain the reason. Thank. Song Gao We prepare to add

[PATCH] target/loongarch: Add CSR_CPUID reg in cpu_env

2023-04-18 Thread Tianrui Zhao
Add CSR_CPUID register in cpu_env to save the cpu_index value. Signed-off-by: Tianrui Zhao --- target/loongarch/cpu.c | 1 + target/loongarch/cpu.h | 1 + target/loongarch/insn_trans/trans_privileged.c.inc | 8 +--- 3 files changed, 3

[PATCH] hw/loongarch/virt: Fix virt_to_phys_addr function

2023-03-27 Thread Tianrui Zhao
The virt addr should mask TARGET_PHYS_ADDR_SPACE_BITS to get the phys addr, and this is used by loading kernel elf. Signed-off-by: Tianrui Zhao --- hw/loongarch/virt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index b702c3f51e

[PATCH v5 1/3] hw/intc/loongarch_pch_msi: add irq number property

2023-01-03 Thread Tianrui Zhao
This patch adds irq number property for loongarch msi interrupt controller, and remove hard coding irq number macro. Signed-off-by: Tianrui Zhao Reviewed-by: Philippe Mathieu-Daud?? --- hw/intc/loongarch_pch_msi.c | 29 ++--- hw/loongarch/virt.c

[PATCH v5 3/3] hw/intc/loongarch_pch: Change default irq number of pch irq controller

2023-01-03 Thread Tianrui Zhao
Change the default irq number of pch pic to 32, so that the irq number of pch msi is 224(256 - 32), and move the 'PCH_PIC_IRQ_NUM' macro to pci-host/ls7a.h and add prefix 'VIRT' on it to keep standard format. Signed-off-by: Tianrui Zhao Reviewed-by: Philippe Mathieu-Daud?? --- hw/intc

[PATCH v5 2/3] hw/intc/loongarch_pch_pic: add irq number property

2023-01-03 Thread Tianrui Zhao
With loongarch 7A1000 manual, irq number supported can be set in PCH_PIC_INT_ID_HI register. This patch adds irq number property for loongarch_pch_pic, so that virt machine can set different irq number when pch_pic intc is added. Signed-off-by: Tianrui Zhao --- hw/intc/loongarch_pch_pic.c

[PATCH v5 0/3] Add irq number property for loongarch pch interrupt controller

2023-01-03 Thread Tianrui Zhao
. Tianrui Zhao (3): hw/intc/loongarch_pch_msi: add irq number property hw/intc/loongarch_pch_pic: add irq number property hw/intc/loongarch_pch: Change default irq number of pch irq controller hw/intc/loongarch_pch_msi.c | 29 +--- hw/intc/loongarch_pch_pic.c

[PATCH v4 2/3] hw/intc/loongarch_pch_pic: add irq number property

2022-12-30 Thread Tianrui Zhao
With loongarch 7A1000 manual, irq number supported can be set in PCH_PIC_INT_ID_HI register. This patch adds irq number property for loongarch_pch_pic, so that virt machine can set different irq number when pch_pic intc is added. Signed-off-by: Tianrui Zhao --- hw/intc/loongarch_pch_pic.c

[PATCH v4 3/3] hw/intc/loongarch_pch: Change default irq number of pch irq controller

2022-12-30 Thread Tianrui Zhao
Change the default irq number of pch pic to 32, so that the irq number of pch msi is 224(256 - 32), and move the 'PCH_PIC_IRQ_NUM' macro to pci-host/ls7a.h and add prefix 'VIRT' on it to keep standard format. Signed-off-by: Tianrui Zhao --- hw/intc/loongarch_pch_pic.c | 3 ++- hw

[PATCH v4 0/3] Add irq number property for loongarch pch interrupt controller

2022-12-30 Thread Tianrui Zhao
pch_msi_irq array in pch_msi_unrealize(). Changes for v1: (1) Add irq number property for loongarch_pch_msi. (2) Add irq number property for loongarch_pch_pic. Tianrui Zhao (3): hw/intc/loongarch_pch_msi: add irq number property hw/intc/loongarch_pch_pic: add irq number property hw/intc

[PATCH v4 1/3] hw/intc/loongarch_pch_msi: add irq number property

2022-12-30 Thread Tianrui Zhao
This patch adds irq number property for loongarch msi interrupt controller, and remove hard coding irq number macro. Signed-off-by: Tianrui Zhao --- hw/intc/loongarch_pch_msi.c | 33 ++--- hw/loongarch/virt.c | 13 +++- include/hw/intc

[PATCH v3 2/2] hw/intc/loongarch_pch_pic: add irq number property

2022-12-23 Thread Tianrui Zhao
With loongarch 7A1000 manual, irq number supported can be set in PCH_PIC_INT_ID_HI register. This patch adds irq number property for loongarch_pch_pic, so that virt machine can set different irq number when pch_pic intc is added. Signed-off-by: Tianrui Zhao --- hw/intc/loongarch_pch_pic.c

[PATCH v3 1/2] hw/intc/loongarch_pch_msi: add irq number property

2022-12-23 Thread Tianrui Zhao
This patch adds irq number property for loongarch msi interrupt controller, and remove hard coding irq number macro. Signed-off-by: Tianrui Zhao --- hw/intc/loongarch_pch_msi.c | 33 ++--- hw/loongarch/virt.c | 13 +++- include/hw/intc

[PATCH v3 0/2] Add irq number property for loongarch pch interrupt controller

2022-12-23 Thread Tianrui Zhao
to replace the 256 irq number. Changes for v2: (1) Free pch_msi_irq array in pch_msi_unrealize(). Changes for v1: (1) Add irq number property for loongarch_pch_msi. (2) Add irq number property for loongarch_pch_pic. Tianrui Zhao (2): hw/intc/loongarch_pch_msi: add irq number property hw/intc

[PATCH v2 1/2] hw/intc/loongarch_pch_msi: add irq number property

2022-12-23 Thread Tianrui Zhao
This patch adds irq number property for loongarch msi interrupt controller, and remove hard coding irq number macro. Signed-off-by: Tianrui Zhao --- hw/intc/loongarch_pch_msi.c | 30 ++--- hw/loongarch/virt.c | 11 +++ include/hw/intc

[PATCH v2 0/2] Add irq number property for loongarch pch interrupt controller

2022-12-23 Thread Tianrui Zhao
This series add irq number property for loongarch pch_msi and pch_pic interrupt controller. Changes for v2: (1) Free pch_msi_irq array in pch_msi_unrealize(). Changes for v1: (1) Add irq number property for loongarch_pch_msi. (2) Add irq number property for loongarch_pch_pic. Tianrui Zhao (2

[PATCH v2 2/2] hw/intc/loongarch_pch_pic: add irq number property

2022-12-23 Thread Tianrui Zhao
With loongarch 7A1000 manual, irq number supported can be set in PCH_PIC_INT_ID_HI register. This patch adds irq number property for loongarch_pch_pic, so that virt machine can set different irq number when pch_pic intc is added. Signed-off-by: Tianrui Zhao --- hw/intc/loongarch_pch_pic.c

  1   2   >