Skip to content

Commit

Permalink
target/loongarch: Implement kvm get/set registers
Browse files Browse the repository at this point in the history
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 <zhaotianrui@loongson.cn>
Signed-off-by: xianglai li <lixianglai@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
Change-Id: Ia8fc48fe08b1768853f7729e77d37cdf270031e4
Message-Id: <20240105075804.1228596-5-zhaotianrui@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
  • Loading branch information
zhaotianrui-loongson authored and gaosong-loongson committed Jan 11, 2024
1 parent 6278465 commit f844743
Show file tree
Hide file tree
Showing 7 changed files with 599 additions and 3 deletions.
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3329,6 +3329,7 @@ if have_system or have_user
'target/hppa',
'target/i386',
'target/i386/kvm',
'target/loongarch',
'target/mips/tcg',
'target/nios2',
'target/ppc',
Expand Down
3 changes: 3 additions & 0 deletions target/loongarch/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ static void loongarch_cpu_reset_hold(Object *obj)
#ifndef CONFIG_USER_ONLY
env->pc = 0x1c000000;
memset(env->tlb, 0, sizeof(env->tlb));
if (kvm_enabled()) {
kvm_arch_reset_vcpu(env);
}
#endif

restore_fp_status(env);
Expand Down
1 change: 1 addition & 0 deletions target/loongarch/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ typedef struct CPUArchState {
MemoryRegion iocsr_mem;
bool load_elf;
uint64_t elf_address;
uint32_t mp_state;
/* Store ipistate to access from this struct */
DeviceState *ipistate;
#endif
Expand Down
5 changes: 4 additions & 1 deletion target/loongarch/internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ void G_NORETURN do_raise_exception(CPULoongArchState *env,

const char *loongarch_exception_name(int32_t exception);

#ifdef CONFIG_TCG
int ieee_ex_to_loongarch(int xcpt);
void restore_fp_status(CPULoongArchState *env);
#endif

#ifndef CONFIG_USER_ONLY
extern const VMStateDescription vmstate_loongarch_cpu;
Expand All @@ -44,12 +46,13 @@ uint64_t cpu_loongarch_get_constant_timer_counter(LoongArchCPU *cpu);
uint64_t cpu_loongarch_get_constant_timer_ticks(LoongArchCPU *cpu);
void cpu_loongarch_store_constant_timer_config(LoongArchCPU *cpu,
uint64_t value);

#ifdef CONFIG_TCG
bool loongarch_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
MMUAccessType access_type, int mmu_idx,
bool probe, uintptr_t retaddr);

hwaddr loongarch_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
#endif
#endif /* !CONFIG_USER_ONLY */

uint64_t read_fcc(CPULoongArchState *env);
Expand Down

0 comments on commit f844743

Please sign in to comment.