Skip to contentSkip to conversation

monitor: add PPC BookE SPRs

PATCH In review Scott Wood 2 participants 6 messages Apr 30, 2011 – May 3, 2011

lore
Share & tools
lore

Scott Wood

author
#0 lore raw

PATCH v2 1/1 monitor: add PPC BookE SPRs

Read them via KVM_GET_SREGS in kvm_arch_get_registers(), and display them in "info registers".

Also get CR and PID from the existing KVM_GET_REGS.

---
v2: fix a couple style oversights, and cache kvm caps as requested

This version depends on http://patchwork.ozlabs.org/patch/90688/
as code it adds is converted to use the cached capability.

 hw/ppc.c               |   12 ++++
 monitor.c              |   71 ++++++++++++++++++++++++-
 target-ppc/cpu.h       |    1 +
 target-ppc/kvm.c       |  137 ++++++++++++++++++++++++++++++++++++++++++++++--
 target-ppc/translate.c |   82 +++++++++++++++++++++++++++-
 5 files changed, 294 insertions(+), 9 deletions(-)
hw/ppc.c +12 -0
index 1873328..9157719 100644
@@ -452,6 +452,10 @@ uint64_t cpu_ppc_load_tbl (CPUState *env)
     ppc_tb_t *tb_env = env->tb_env;
     uint64_t tb;
 
+    if (kvm_enabled()) {
+        return env->spr[SPR_TBL];
+    }
+
     tb = cpu_ppc_get_tb(tb_env, qemu_get_clock_ns(vm_clock), tb_env->tb_offset);
     LOG_TB("%s: tb %016" PRIx64 "\n", __func__, tb);
 
@@ -471,6 +475,10 @@ static inline uint32_t _cpu_ppc_load_tbu(CPUState *env)
 
 uint32_t cpu_ppc_load_tbu (CPUState *env)
 {
+    if (kvm_enabled()) {
+        return env->spr[SPR_TBU];
+    }
+
     return _cpu_ppc_load_tbu(env);
 }
 
@@ -616,6 +624,10 @@ uint32_t cpu_ppc_load_decr (CPUState *env)
 {
     ppc_tb_t *tb_env = env->tb_env;
 
+    if (kvm_enabled()) {
+        return env->spr[SPR_DECR];
+    }
+
     return _cpu_ppc_load_decr(env, tb_env->decr_next);
 }
 
monitor.c +70 -1

77 lines not on this page · raw message

target-ppc/cpu.h +1 -0
index 04b1259..303f8ce 100644
@@ -1016,6 +1016,7 @@ static inline void cpu_clone_regs(CPUState *env, target_ulong newsp)
 #define SPR_HSPRG1            (0x131)
 #define SPR_HDSISR            (0x132)
 #define SPR_HDAR              (0x133)
+#define SPR_BOOKE_EPCR        (0x133)
 #define SPR_SPURR             (0x134)
 #define SPR_BOOKE_DBCR0       (0x134)
 #define SPR_IBCR              (0x135)
target-ppc/kvm.c +132 -5

189 lines not on this page · raw message

target-ppc/translate.c +79 -3

94 lines not on this page · raw message

Signature · 1 line
1.7.1
#1 lore raw
Quoted 6 lines · Scott Wood

Read them via KVM_GET_SREGS in kvm_arch_get_registers(), and display them in "info registers".

Also get CR and PID from the existing KVM_GET_REGS.

Nice patch :)

Alex

#2 lore raw
In reply to Scott Wood
Quoted 6 lines · Scott Wood

Read them via KVM_GET_SREGS in kvm_arch_get_registers(), and display them in "info registers".

Also get CR and PID from the existing KVM_GET_REGS.

cc1: warnings being treated as errors /home/agraf/release/qemu/target-ppc/kvm.c:48: error: ‘cap_booke_sregs’ defined but not used

I'll wrap the cap with an #ifdef.

Alex

#3 lore raw
In reply to Scott Wood
Quoted 8 lines · Scott Wood

Read them via KVM_GET_SREGS in kvm_arch_get_registers(), and display them in "info registers".

Also get CR and PID from the existing KVM_GET_REGS.

---
v2: fix a couple style oversights, and cache kvm caps as requested

In fact, I'll just squash this patch with yours, if that's ok for you:

target-ppc/kvm.c +2 -4
index a4ec4bc..5a1b6cb 100644
@@ -45,7 +45,9 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
 static int cap_interrupt_unset = false;
 static int cap_interrupt_level = false;
 static int cap_segstate;
+#ifdef KVM_CAP_PPC_BOOKE_SREGS
 static int cap_booke_sregs;
+#endif
 
 /* XXX We have a race condition where we actually have a level triggered
  *     interrupt, but the infrastructure can't expose that yet, so the guest
@@ -94,13 +96,9 @@ static int kvm_arch_sync_sregs(CPUState *cenv)
     if (cenv->excp_model == POWERPC_EXCP_BOOKE) {
         return 0;
     } else {
-#ifdef KVM_CAP_PPC_SEGSTATE
         if (!cap_segstate) {
             return 0;
         }
-#else
-        return 0;
-#endif
     }
 
     ret = kvm_vcpu_ioctl(cenv, KVM_GET_SREGS, &sregs);
author
#4 lore raw
Quoted 6 lines · On Tue, 3 May 2011 13:02:40 +0200 Alexander Graf <[email protected]> wrote:
Quoted 3 lines · Scott Wood

Read them via KVM_GET_SREGS in kvm_arch_get_registers(), and display them in "info registers".

Quoted 7 lines
Quoted 5 lines

Also get CR and PID from the existing KVM_GET_REGS.

---
v2: fix a couple style oversights, and cache kvm caps as requested

In fact, I'll just squash this patch with yours, if that's ok for you:

OK.

Quoted 15 lines
target-ppc/kvm.c +2 -0
index a4ec4bc..5a1b6cb 100644
@@ -45,7 +45,9 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
 static int cap_interrupt_unset = false;
 static int cap_interrupt_level = false;
 static int cap_segstate;
+#ifdef KVM_CAP_PPC_BOOKE_SREGS
 static int cap_booke_sregs;
+#endif
 
 /* XXX We have a race condition where we actually have a level triggered
  *     interrupt, but the infrastructure can't expose that yet, so the guest

target-ppc/kvm.c static int kvm_arch_sync_sregs(CPUState *cenv) · line 103

Quoted 10 lines
target-ppc/kvm.c +0 -4
@@ -94,13 +96,9 @@ static int kvm_arch_sync_sregs(CPUState *cenv)
     if (cenv->excp_model == POWERPC_EXCP_BOOKE) {
         return 0;
     } else {
-#ifdef KVM_CAP_PPC_SEGSTATE
         if (!cap_segstate) {
             return 0;
         }
-#else
-        return 0;
-#endif

So there are no headers out there that we need to support building with that don't have KVM_CAP_PPC_SEGSTATE?

-Scott

#5 lore raw
Quoted 31 lines · Scott Wood
Quoted 6 lines · On Tue, 3 May 2011 13:02:40 +0200 Alexander Graf <[email protected]> wrote:
Quoted 3 lines · Scott Wood

Read them via KVM_GET_SREGS in kvm_arch_get_registers(), and display them in "info registers".

Quoted 7 lines
Quoted 5 lines

Also get CR and PID from the existing KVM_GET_REGS.

---
v2: fix a couple style oversights, and cache kvm caps as requested

In fact, I'll just squash this patch with yours, if that's ok for you:

OK.

Quoted 12 lines
target-ppc/kvm.c +2 -0
index a4ec4bc..5a1b6cb 100644
@@ -45,7 +45,9 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
 static int cap_interrupt_unset = false;
 static int cap_interrupt_level = false;
 static int cap_segstate;
+#ifdef KVM_CAP_PPC_BOOKE_SREGS
 static int cap_booke_sregs;
+#endif
 
Quoted 16 lines

target-ppc/kvm.c static int kvm_arch_sync_sregs(CPUState *cenv) · line 103

Quoted 13 lines
target-ppc/kvm.c +0 -4
 /* XXX We have a race condition where we actually have a level triggered
 *     interrupt, but the infrastructure can't expose that yet, so the guest
@@ -94,13 +96,9 @@ static int kvm_arch_sync_sregs(CPUState *cenv)
    if (cenv->excp_model == POWERPC_EXCP_BOOKE) {
        return 0;
    } else {
-#ifdef KVM_CAP_PPC_SEGSTATE
        if (!cap_segstate) {
            return 0;
        }
-#else
-        return 0;
-#endif

So there are no headers out there that we need to support building with that don't have KVM_CAP_PPC_SEGSTATE?

We need to support the headers, but not be able to run there (for Book3S). I have another patch on top of yours, enabling building with old headers. See "[Qemu-devel] [PATCH] kvm: ppc: detect old headers" for it :).

The change above is functionally identical. cap_segstate is false by default.

Alex