Skip to contentSkip to conversation

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

PATCH In review Nikunj A Dadhania 2 participants 3 messages Apr 23, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---

http://patchwork.ozlabs.org/patch/901897/

---
 hw/ppc/spapr.c                  | 1 +
 hw/ppc/spapr_rtas.c             | 4 ++++
 linux-headers/asm-powerpc/kvm.h | 1 +
 target/ppc/kvm.c                | 9 +++++++++
 target/ppc/kvm_ppc.h            | 6 ++++++
 5 files changed, 21 insertions(+)
hw/ppc/spapr.c +1 -0
index a81570e7c8..48bafe3765 100644
@@ -1549,6 +1549,7 @@ static void spapr_machine_reset(void)
     first_ppc_cpu->env.gpr[5] = 0;
     first_cpu->halted = 0;
     first_ppc_cpu->env.nip = SPAPR_ENTRY_POINT;
+    kvmppc_set_reg_ppc_online(first_ppc_cpu, 1);
 
     spapr->cas_reboot = false;
 }
hw/ppc/spapr_rtas.c +4 -0
index 0ec5fa4cfe..0874a746dd 100644
@@ -33,6 +33,7 @@
 #include "sysemu/device_tree.h"
 #include "sysemu/cpus.h"
 #include "sysemu/kvm.h"
+#include "kvm_ppc.h"
 
 #include "hw/ppc/spapr.h"
 #include "hw/ppc/spapr_vio.h"
@@ -184,6 +185,8 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPRMachineState *spapr,
         spapr_cpu_set_endianness(cpu);
         spapr_cpu_update_tb_offset(cpu);
 
+        kvmppc_set_reg_ppc_online(cpu, 1);
+
         qemu_cpu_kick(cs);
 
         rtas_st(rets, 0, RTAS_OUT_SUCCESS);
@@ -204,6 +207,7 @@ static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachineState *spapr,
     PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
 
     cs->halted = 1;
+    kvmppc_set_reg_ppc_online(cpu, 0);
     qemu_cpu_kick(cs);
 
     /* Disable Power-saving mode Exit Cause exceptions for the CPU.
linux-headers/asm-powerpc/kvm.h +1 -0
index 833ed9a16a..1b32b56a03 100644
@@ -633,6 +633,7 @@ struct kvm_ppc_cpu_char {
 #define KVM_REG_PPC_PSSCR	(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbd)
 
 #define KVM_REG_PPC_DEC_EXPIRY	(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbe)
+#define KVM_REG_PPC_ONLINE	(KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xbf)
 
 /* Transactional Memory checkpointed state:
  * This is all GPRs, all VSX regs and a subset of SPRs
target/ppc/kvm.c +9 -0
index 79a436a384..32a146f838 100644
@@ -2877,3 +2877,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 4d2789eef6..7a915fe422 100644
@@ -72,6 +72,7 @@ int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, target_ulong flags, int shift);
 bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu);
 
 bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path);
+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 off_t kvmppc_alloc_rma(void **rma)
 {
Signature · 1 line
2.14.3
#1 lore raw
Quoted 9 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.

Quoted 7 lines

---

http://patchwork.ozlabs.org/patch/901897/

---
 hw/ppc/spapr.c                  | 1 +
 hw/ppc/spapr_rtas.c             | 4 ++++
 linux-headers/asm-powerpc/kvm.h | 1 +

The usual convention is to send updates to the imported headers, as a general update to a specific kernel SHA, rather than folding just the necessary parts into the patches that use them.

This will need to wait for 2.13.

Quoted 98 lines
 target/ppc/kvm.c                | 9 +++++++++
 target/ppc/kvm_ppc.h            | 6 ++++++
 5 files changed, 21 insertions(+)
hw/ppc/spapr.c +1 -0
index a81570e7c8..48bafe3765 100644
@@ -1549,6 +1549,7 @@ static void spapr_machine_reset(void)
     first_ppc_cpu->env.gpr[5] = 0;
     first_cpu->halted = 0;
     first_ppc_cpu->env.nip = SPAPR_ENTRY_POINT;
+    kvmppc_set_reg_ppc_online(first_ppc_cpu, 1);
 
     spapr->cas_reboot = false;
 }
hw/ppc/spapr_rtas.c +4 -0
index 0ec5fa4cfe..0874a746dd 100644
@@ -33,6 +33,7 @@
 #include "sysemu/device_tree.h"
 #include "sysemu/cpus.h"
 #include "sysemu/kvm.h"
+#include "kvm_ppc.h"
 
 #include "hw/ppc/spapr.h"
 #include "hw/ppc/spapr_vio.h"
@@ -184,6 +185,8 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPRMachineState *spapr,
         spapr_cpu_set_endianness(cpu);
         spapr_cpu_update_tb_offset(cpu);
 
+        kvmppc_set_reg_ppc_online(cpu, 1);
+
         qemu_cpu_kick(cs);
 
         rtas_st(rets, 0, RTAS_OUT_SUCCESS);
@@ -204,6 +207,7 @@ static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachineState *spapr,
     PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
 
     cs->halted = 1;
+    kvmppc_set_reg_ppc_online(cpu, 0);
     qemu_cpu_kick(cs);
 
     /* Disable Power-saving mode Exit Cause exceptions for the CPU.
linux-headers/asm-powerpc/kvm.h +1 -0
index 833ed9a16a..1b32b56a03 100644
@@ -633,6 +633,7 @@ struct kvm_ppc_cpu_char {
 #define KVM_REG_PPC_PSSCR	(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbd)
 
 #define KVM_REG_PPC_DEC_EXPIRY	(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbe)
+#define KVM_REG_PPC_ONLINE	(KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xbf)
 
 /* Transactional Memory checkpointed state:
  * This is all GPRs, all VSX regs and a subset of SPRs
target/ppc/kvm.c +9 -0
index 79a436a384..32a146f838 100644
@@ -2877,3 +2877,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 4d2789eef6..7a915fe422 100644
@@ -72,6 +72,7 @@ int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, target_ulong flags, int shift);
 bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu);
 
 bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path);
+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 off_t kvmppc_alloc_rma(void **rma)
 {
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 18 lines · David Gibson
Quoted 9 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.

Quoted 7 lines

---

http://patchwork.ozlabs.org/patch/901897/

---
 hw/ppc/spapr.c                  | 1 +
 hw/ppc/spapr_rtas.c             | 4 ++++
 linux-headers/asm-powerpc/kvm.h | 1 +
Quoted 3 lines

The usual convention is to send updates to the imported headers, as a general update to a specific kernel SHA, rather than folding just the necessary parts into the patches that use them.

Sure, we need to wait until Paul's patch is pulled in.

Quoted 1 line

This will need to wait for 2.13.

Yes, that is fine.

Regards
Nikunj