qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 07/11] target/ppc: added KVM fallback to fpscr manipulation


From: Bruno Larsen (billionai)
Subject: [PATCH 07/11] target/ppc: added KVM fallback to fpscr manipulation
Date: Wed, 12 May 2021 11:08:09 -0300

some common code needs to store information in fpscr, but this function
relies on TCG cde to work. This patch adds a kvm way to do it, and a
transparent way to call it when TCG is not compiled

Signed-off-by: Bruno Larsen (billionai) <bruno.larsen@eldorado.org.br>
---
 target/ppc/gdbstub.c |  1 +
 target/ppc/kvm.c     | 14 ++++++++++++++
 target/ppc/kvm_ppc.h |  6 ++++++
 3 files changed, 21 insertions(+)

diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c
index 17e41fc113..65759e0c1c 100644
--- a/target/ppc/gdbstub.c
+++ b/target/ppc/gdbstub.c
@@ -23,6 +23,7 @@
 #include "exec/helper-proto.h"
 #include "internal.h"
 #include "helper_regs.h"
+#include "kvm_ppc.h"
 
 static int ppc_gdb_register_len_apple(int n)
 {
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 104a308abb..a8a720eb48 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -2947,3 +2947,17 @@ bool kvm_arch_cpu_check_are_resettable(void)
 {
     return true;
 }
+
+void kvmppc_store_fpscr(CPUPPCState *env, uint64_t arg, uint32_t mask)
+{
+    CPUState *cs = env_cpu(env);
+    struct kvm_one_reg reg;
+    int ret;
+    reg.id = KVM_REG_PPC_FPSCR;
+    reg.addr = (uintptr_t) &env->fpscr;
+    ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
+    if (ret < 0)
+    {
+        fprintf(stderr, "Unable to set FPSCR to KVM: %s", strerror(errno));
+    }
+}
diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
index 989f61ace0..ff365e57a6 100644
--- a/target/ppc/kvm_ppc.h
+++ b/target/ppc/kvm_ppc.h
@@ -86,6 +86,12 @@ void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t 
tb_offset);
 
 int kvm_handle_nmi(PowerPCCPU *cpu, struct kvm_run *run);
 
+#ifndef CONFIG_TCG
+# define store_fpscr kvmppc_store_fpscr
+#endif
+void kvmppc_store_fpscr(CPUPPCState *env, uint64_t arg, uint32_t mask);
+
+
 #else
 
 static inline uint32_t kvmppc_get_tbfreq(void)
-- 
2.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]