在 2026/6/5 下午4:25, Bibo Mao 写道:
> Here new structure CPUSysState is added in CPULoongArchState, CSR
> registers are moved to CPUSysState, qemu timer will be moved to this
> structure in future. With incoming LVZ supported, there will be two copied
> of CSR registers, so it is simply to add CPUSysState array.
>
> Also new field sys_state is added which points to CPUSysState at
> beginning, and it can be changed during VM exit/enter entry. There is no
> function change, all is code movement or variable rename.
>
> ---
> v2 ... v3:
> 1. Modify the spell issue in the comments.
> 2. Change type as unsigned int with return value of function
> get_csr_offset().
> 2. Split patch 13 into two smaller version, macro CPU_CSR_OFFSET is
> added special for user mode rdtime emulation in one patch.
>
> v1 ... v2:
> 1. Rename get_current_state with env_sys, variable name cur with sys,
> since cur/get_current_state is misleading.
> 2. Add modification with files in directory linux-user/loongarch64/
> ---
> Bibo Mao (14):
> target/loongarch: Add new field curState in CPULoongArchState
> target/loongarch: Use sys_state in cpu.c when accessing CSR registers
> target/loongarch: Use sys_state in cpu_helper.c when accessing CSR
> registers
> target/loongarch: Use sys_state in file arch_dump.c when accessing CSR
> registers
> target/loongarch: Use sys_state in kvm.c when accessing CSR registers
> target/loongarch: Use sys_state in tlb_helper.c when accessing CSR
> registers
> target/loongarch: Use sys_state in tcg_cpu.c when accessing CSR
> registers
> target/loongarch: Use sys_state in csr_helper.c when accessing CSR
> registers
> target/loongarch: Use sys_state in op_helper.c when accessing CSR
> registers
> linux-user/loongarch64: Use sys_state when accessing CSR registers
> target/loongarch: Add default CSRFL_BASIC info with flags field
> target/loongarch: Add wrapper function get_csr_offset()
> target/loongarch: Add macro CSR_OFFSET and CPU_CSR_OFFSET
> target/loongarch: Add new structure CPUSysState
>
> hw/intc/loongarch_dintc.c | 4 +-
> linux-user/loongarch64/cpu_loop.c | 5 +-
> linux-user/loongarch64/elfload.c | 4 +-
> linux-user/loongarch64/signal.c | 16 +-
> target/loongarch/arch_dump.c | 5 +-
> target/loongarch/cpu-mmu.h | 4 +-
> target/loongarch/cpu.c | 120 ++++-----
> target/loongarch/cpu.h | 49 ++--
> target/loongarch/cpu_helper.c | 41 ++--
> target/loongarch/csr.c | 10 +-
> target/loongarch/csr.h | 10 +
> target/loongarch/gdbstub.c | 3 +-
> target/loongarch/kvm/kvm.c | 228 +++++++++---------
> target/loongarch/machine.c | 118 ++++-----
> target/loongarch/tcg/constant_timer.c | 10 +-
> target/loongarch/tcg/csr_helper.c | 55 +++--
> .../tcg/insn_trans/trans_extra.c.inc | 6 +-
> .../tcg/insn_trans/trans_privileged.c.inc | 16 +-
> target/loongarch/tcg/op_helper.c | 45 ++--
> target/loongarch/tcg/tcg_cpu.c | 107 ++++----
> target/loongarch/tcg/tlb_helper.c | 137 ++++++-----
> 21 files changed, 549 insertions(+), 444 deletions(-)
>
>
> base-commit: 5611a9268dae7b7ff99d478ed134052a9fc7e9f7
Tested-by: Song Gao <gaosong@loongson.cn>
Applied to loongarch-next.
Thanks.
Song Gao