在 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 <zhaotianrui@xxxxxxxxxxx>
---
meson.build | 1 +
target/loongarch/kvm.c | 356 +++++++++++++++++++++++++++++++++-
target/loongarch/trace-events | 11 ++
target/loongarch/trace.h | 1 +
4 files changed, 367 insertions(+), 2 deletions(-)
create mode 100644 target/loongarch/trace-events
create mode 100644 target/loongarch/trace.h
diff --git a/meson.build b/meson.build
index 29f8644d6d..b1b29299da 100644
--- a/meson.build
+++ b/meson.build
@@ -3039,6 +3039,7 @@ if have_system or have_user
'target/s390x',
'target/s390x/kvm',
'target/sparc',
+ 'target/loongarch',
]
Sort before mips to keep alphabetic ordering.
Thanks, I will move it to the suitable place.
Thanks
Tianrui Zhao
+static int kvm_loongarch_get_regs_core(CPUState *cs)
+{
+ int ret = 0;
+ int i;
+ struct kvm_regs regs;
+ LoongArchCPU *cpu = LOONGARCH_CPU(cs);
+ CPULoongArchState *env = &cpu->env;
+
+ /* Get the current register set as KVM seems it */
+ ret = kvm_vcpu_ioctl(cs, KVM_GET_REGS, ®s);
+ if (ret < 0) {
+ trace_kvm_failed_get_regs_core(strerror(errno));
+ return ret;
+ }
+
+ for (i = 0; i < 32; i++) {
+ env->gpr[i] = regs.gpr[i];
For i = 1; register 0 is 0...
Thanks, I will fix it.
Thanks
Tianrui Zhao
+static inline int kvm_larch_getq(CPUState *cs, uint64_t reg_id,
+ uint64_t *addr)
+{
+ struct kvm_one_reg csrreg = {
+ .id = reg_id,
+ .addr = (uintptr_t)addr
+ };
+
+ return kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &csrreg);
+}
Drop inline marker and let the compiler choose.
Thanks , I will drop the inline statement.
Thanks
Tianrui Zhao
+static inline int kvm_larch_putq(CPUState *cs, uint64_t reg_id,
+ uint64_t *addr)
Likewise.
Otherwise,
Reviewed-by: Richard Henderson <richard.henderson@xxxxxxxxxx>
r~