Skip to contentSkip to conversation

target/ppc/kvm: set vcpu as online/offline

PATCH Superseded Nikunj A Dadhania 2 participants 3 messages Sep 4, 2018

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 target/ppc/kvm: set vcpu as online/offline

Set the newly added register(KVM_REG_PPC_ONLINE) to indicate if the vcpu is online(1) or offline(0)

KVM will use this information to set the RWMR register, which controls the PURR and SPURR accumulation.

---
 hw/ppc/spapr_cpu_core.c | 1 +
 hw/ppc/spapr_rtas.c     | 3 +++
 target/ppc/kvm.c        | 9 +++++++++
 target/ppc/kvm_ppc.h    | 6 ++++++
 4 files changed, 19 insertions(+)
hw/ppc/spapr_cpu_core.c +1 -0
index 876f0b3d9d..9863221756 100644
@@ -90,6 +90,7 @@ void spapr_cpu_set_entry_state(PowerPCCPU *cpu, target_ulong nip, target_ulong r
 
     env->nip = nip;
     env->gpr[3] = r3;
+    kvmppc_set_reg_ppc_online(cpu, 1);
     CPU(cpu)->halted = 0;
     /* Enable Power-saving mode Exit Cause exceptions */
     ppc_store_lpcr(cpu, env->spr[SPR_LPCR] | pcc->lpcr_pm);
hw/ppc/spapr_rtas.c +3 -0
index 4ac96bc94b..ce8072689b 100644
@@ -33,6 +33,7 @@
 #include "sysemu/device_tree.h"
 #include "sysemu/cpus.h"
 #include "sysemu/hw_accel.h"
+#include "kvm_ppc.h"
 
 #include "hw/ppc/spapr.h"
 #include "hw/ppc/spapr_vio.h"
@@ -187,6 +188,7 @@ static void rtas_start_cpu(PowerPCCPU *callcpu, sPAPRMachineState *spapr,
     newcpu->env.tb_env->tb_offset = callcpu->env.tb_env->tb_offset;
 
     spapr_cpu_set_entry_state(newcpu, start, r3);
+    kvmppc_set_reg_ppc_online(newcpu, 1);
 
     qemu_cpu_kick(CPU(newcpu));
 
@@ -207,6 +209,7 @@ static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachineState *spapr,
      * guest */
     ppc_store_lpcr(cpu, env->spr[SPR_LPCR] & ~pcc->lpcr_pm);
     cs->halted = 1;
+    kvmppc_set_reg_ppc_online(cpu, 0);
     qemu_cpu_kick(cs);
 }
 
target/ppc/kvm.c +9 -0
index 9211ee2ee1..7be8081968 100644
@@ -2785,3 +2785,12 @@ bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu)
 
     return !kvmppc_is_pr(cs->kvm_state);
 }
+
+void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, unsigned int online)
+{
+    CPUState *cs = CPU(cpu);
+
+    if (kvm_enabled()) {
+        kvm_set_one_reg(cs, KVM_REG_PPC_ONLINE, &online);
+    }
+}
target/ppc/kvm_ppc.h +6 -0
index 657582bb32..d635032bd9 100644
@@ -72,6 +72,7 @@ bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu);
 
 bool kvmppc_hpt_needs_host_contiguous_pages(void);
 void kvm_check_mmu(PowerPCCPU *cpu, Error **errp);
+void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, unsigned int online);
 
 #else
 
@@ -187,6 +188,11 @@ static inline target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu,
     return 0;
 }
 
+static inline void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, unsigned int online)
+{
+    return;
+}
+
 #ifndef CONFIG_USER_ONLY
 static inline bool kvmppc_spapr_use_multitce(void)
 {
Signature · 1 line
2.14.4
#1 lore raw
Quoted 40 lines · Nikunj A Dadhania

Set the newly added register(KVM_REG_PPC_ONLINE) to indicate if the vcpu is online(1) or offline(0)

KVM will use this information to set the RWMR register, which controls the PURR and SPURR accumulation.

---
 hw/ppc/spapr_cpu_core.c | 1 +
 hw/ppc/spapr_rtas.c     | 3 +++
 target/ppc/kvm.c        | 9 +++++++++
 target/ppc/kvm_ppc.h    | 6 ++++++
 4 files changed, 19 insertions(+)
hw/ppc/spapr_cpu_core.c +1 -0
index 876f0b3d9d..9863221756 100644
@@ -90,6 +90,7 @@ void spapr_cpu_set_entry_state(PowerPCCPU *cpu, target_ulong nip, target_ulong r
 
     env->nip = nip;
     env->gpr[3] = r3;
+    kvmppc_set_reg_ppc_online(cpu, 1);
     CPU(cpu)->halted = 0;
     /* Enable Power-saving mode Exit Cause exceptions */
     ppc_store_lpcr(cpu, env->spr[SPR_LPCR] | pcc->lpcr_pm);
hw/ppc/spapr_rtas.c +1 -0
index 4ac96bc94b..ce8072689b 100644
@@ -33,6 +33,7 @@
 #include "sysemu/device_tree.h"
 #include "sysemu/cpus.h"
 #include "sysemu/hw_accel.h"
+#include "kvm_ppc.h"
 
 #include "hw/ppc/spapr.h"
 #include "hw/ppc/spapr_vio.h"

hw/ppc/spapr_rtas.c static void rtas_start_cpu(PowerPCCPU *callcpu, sPAPRMachineState *spapr, · line 191

Quoted 4 lines
hw/ppc/spapr_rtas.c +1 -0
@@ -187,6 +188,7 @@ static void rtas_start_cpu(PowerPCCPU *callcpu, sPAPRMachineState *spapr,
     newcpu->env.tb_env->tb_offset = callcpu->env.tb_env->tb_offset;
 
     spapr_cpu_set_entry_state(newcpu, start, r3);
+    kvmppc_set_reg_ppc_online(newcpu, 1);

You're setting online in spapr_cpu_set_entry_state() called immediately above, so you don't need it here as well.

Quoted 52 lines
hw/ppc/spapr_rtas.c +1 -0
     qemu_cpu_kick(CPU(newcpu));
 
@@ -207,6 +209,7 @@ static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachineState *spapr,
      * guest */
     ppc_store_lpcr(cpu, env->spr[SPR_LPCR] & ~pcc->lpcr_pm);
     cs->halted = 1;
+    kvmppc_set_reg_ppc_online(cpu, 0);
     qemu_cpu_kick(cs);
 }
 
target/ppc/kvm.c +9 -0
index 9211ee2ee1..7be8081968 100644
@@ -2785,3 +2785,12 @@ bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu)
 
     return !kvmppc_is_pr(cs->kvm_state);
 }
+
+void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, unsigned int online)
+{
+    CPUState *cs = CPU(cpu);
+
+    if (kvm_enabled()) {
+        kvm_set_one_reg(cs, KVM_REG_PPC_ONLINE, &online);
+    }
+}
target/ppc/kvm_ppc.h +6 -0
index 657582bb32..d635032bd9 100644
@@ -72,6 +72,7 @@ bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu);
 
 bool kvmppc_hpt_needs_host_contiguous_pages(void);
 void kvm_check_mmu(PowerPCCPU *cpu, Error **errp);
+void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, unsigned int online);
 
 #else
 
@@ -187,6 +188,11 @@ static inline target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu,
     return 0;
 }
 
+static inline void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, unsigned int online)
+{
+    return;
+}
+
 #ifndef CONFIG_USER_ONLY
 static inline bool kvmppc_spapr_use_multitce(void)
 {
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#2 lore raw
Quoted 43 lines · David Gibson
Quoted 42 lines · Nikunj A Dadhania

Set the newly added register(KVM_REG_PPC_ONLINE) to indicate if the vcpu is online(1) or offline(0)

KVM will use this information to set the RWMR register, which controls the PURR and SPURR accumulation.

---
 hw/ppc/spapr_cpu_core.c | 1 +
 hw/ppc/spapr_rtas.c     | 3 +++
 target/ppc/kvm.c        | 9 +++++++++
 target/ppc/kvm_ppc.h    | 6 ++++++
 4 files changed, 19 insertions(+)
hw/ppc/spapr_cpu_core.c +1 -0
index 876f0b3d9d..9863221756 100644
@@ -90,6 +90,7 @@ void spapr_cpu_set_entry_state(PowerPCCPU *cpu, target_ulong nip, target_ulong r
 
     env->nip = nip;
     env->gpr[3] = r3;
+    kvmppc_set_reg_ppc_online(cpu, 1);
     CPU(cpu)->halted = 0;
     /* Enable Power-saving mode Exit Cause exceptions */
     ppc_store_lpcr(cpu, env->spr[SPR_LPCR] | pcc->lpcr_pm);
hw/ppc/spapr_rtas.c +1 -0
index 4ac96bc94b..ce8072689b 100644
@@ -33,6 +33,7 @@
 #include "sysemu/device_tree.h"
 #include "sysemu/cpus.h"
 #include "sysemu/hw_accel.h"
+#include "kvm_ppc.h"
 
 #include "hw/ppc/spapr.h"
 #include "hw/ppc/spapr_vio.h"
@@ -187,6 +188,7 @@ static void rtas_start_cpu(PowerPCCPU *callcpu, sPAPRMachineState *spapr,
     newcpu->env.tb_env->tb_offset = callcpu->env.tb_env->tb_offset;
 
Quoted 5 lines

hw/ppc/spapr_rtas.c static void rtas_start_cpu(PowerPCCPU *callcpu, sPAPRMachineState *spapr, · line 191

Quoted 2 lines
hw/ppc/spapr_rtas.c +1 -0
     spapr_cpu_set_entry_state(newcpu, start, r3);
+    kvmppc_set_reg_ppc_online(newcpu, 1);

You're setting online in spapr_cpu_set_entry_state() called immediately above, so you don't need it here as well.

Ah right, I missed it. Will send a respin.

Regards
Nikunj