Message ID | 20190624055812.3906-1-sjitindarsingh@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [QEMU-PPC,1/2] ppc/spapr: Add implementation of hcall H_PURR | expand |
On Mon, Jun 24, 2019 at 03:58:11PM +1000, Suraj Jitindar Singh wrote: > The hcall H_PURR is used by a guest to read the PURR (processor > utilisation of resources register). A guest expects that this register > will count at a rate of timebase scaled by the number of guest vcpus > present in the vcore. That is the per vcpu purr will count at a rate of > timebase / # vcpus per vcore. > > Implement a handler for the H_PURR hcall and return the purr value > divided by smp_threads so that the sum of the purr deltas across the > vcpus of a vcore equals the timebase delta > > Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> Does this need something new advertised in the hypertas DT entry? > --- > hw/ppc/spapr_hcall.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c > index aae9fd2b3e..88b3343f04 100644 > --- a/hw/ppc/spapr_hcall.c > +++ b/hw/ppc/spapr_hcall.c > @@ -1819,6 +1819,27 @@ static target_ulong h_update_dt(PowerPCCPU *cpu, SpaprMachineState *spapr, > return H_SUCCESS; > } > > +static target_ulong h_purr(PowerPCCPU *cpu, SpaprMachineState *spapr, > + target_ulong opcode, target_ulong *args) > +{ > + CPUPPCState *env = &cpu->env; > + target_ulong purr; > + > + if (kvm_enabled()) { > + cpu_synchronize_state(CPU(cpu)); > + /* > + * Divide by smp_threads so that the sum of the purr deltas across the > + * vcpus of a vcore equal the timebase delta. > + */ > + purr = env->spr[SPR_PURR] / smp_threads; > + } else { > + purr = cpu_ppc_load_purr(env); > + } > + args[0] = purr; > + > + return H_SUCCESS; > +} > + > static spapr_hcall_fn papr_hypercall_table[(MAX_HCALL_OPCODE / 4) + 1]; > static spapr_hcall_fn kvmppc_hypercall_table[KVMPPC_HCALL_MAX - KVMPPC_HCALL_BASE + 1]; > > @@ -1915,6 +1936,9 @@ static void hypercall_register_types(void) > spapr_register_hypercall(H_LOGICAL_DCBF, h_logical_dcbf); > spapr_register_hypercall(KVMPPC_H_LOGICAL_MEMOP, h_logical_memop); > > + /* hcall-purr */ > + spapr_register_hypercall(H_PURR, h_purr); > + > /* qemu/KVM-PPC specific hcalls */ > spapr_register_hypercall(KVMPPC_H_RTAS, h_rtas); >
On Fri, 2019-06-28 at 19:29 +1000, David Gibson wrote: > On Mon, Jun 24, 2019 at 03:58:11PM +1000, Suraj Jitindar Singh wrote: > > The hcall H_PURR is used by a guest to read the PURR (processor > > utilisation of resources register). A guest expects that this > > register > > will count at a rate of timebase scaled by the number of guest > > vcpus > > present in the vcore. That is the per vcpu purr will count at a > > rate of > > timebase / # vcpus per vcore. > > > > Implement a handler for the H_PURR hcall and return the purr value > > divided by smp_threads so that the sum of the purr deltas across > > the > > vcpus of a vcore equals the timebase delta > > > > Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> > > Does this need something new advertised in the hypertas DT entry? Hi David, There doesn't seem to be a concensus on what the return value from the H_PURR hcall should be, whether it just returns the hardware value or does some adjusting of the value based on guest smt mode as I've implemented in the patch below. As such please drop this patch series. The guest can just read the purr register directly anyway and then interpret the values as it pleases. Kind Regards, Suraj > > > --- > > hw/ppc/spapr_hcall.c | 24 ++++++++++++++++++++++++ > > 1 file changed, 24 insertions(+) > > > > diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c > > index aae9fd2b3e..88b3343f04 100644 > > --- a/hw/ppc/spapr_hcall.c > > +++ b/hw/ppc/spapr_hcall.c > > @@ -1819,6 +1819,27 @@ static target_ulong h_update_dt(PowerPCCPU > > *cpu, SpaprMachineState *spapr, > > return H_SUCCESS; > > } > > > > +static target_ulong h_purr(PowerPCCPU *cpu, SpaprMachineState > > *spapr, > > + target_ulong opcode, target_ulong > > *args) > > +{ > > + CPUPPCState *env = &cpu->env; > > + target_ulong purr; > > + > > + if (kvm_enabled()) { > > + cpu_synchronize_state(CPU(cpu)); > > + /* > > + * Divide by smp_threads so that the sum of the purr > > deltas across the > > + * vcpus of a vcore equal the timebase delta. > > + */ > > + purr = env->spr[SPR_PURR] / smp_threads; > > + } else { > > + purr = cpu_ppc_load_purr(env); > > + } > > + args[0] = purr; > > + > > + return H_SUCCESS; > > +} > > + > > static spapr_hcall_fn papr_hypercall_table[(MAX_HCALL_OPCODE / 4) > > + 1]; > > static spapr_hcall_fn kvmppc_hypercall_table[KVMPPC_HCALL_MAX - > > KVMPPC_HCALL_BASE + 1]; > > > > @@ -1915,6 +1936,9 @@ static void hypercall_register_types(void) > > spapr_register_hypercall(H_LOGICAL_DCBF, h_logical_dcbf); > > spapr_register_hypercall(KVMPPC_H_LOGICAL_MEMOP, > > h_logical_memop); > > > > + /* hcall-purr */ > > + spapr_register_hypercall(H_PURR, h_purr); > > + > > /* qemu/KVM-PPC specific hcalls */ > > spapr_register_hypercall(KVMPPC_H_RTAS, h_rtas); > > > >
On Mon, Jul 01, 2019 at 02:23:21PM +1000, Suraj Jitindar Singh wrote: > On Fri, 2019-06-28 at 19:29 +1000, David Gibson wrote: > > On Mon, Jun 24, 2019 at 03:58:11PM +1000, Suraj Jitindar Singh wrote: > > > The hcall H_PURR is used by a guest to read the PURR (processor > > > utilisation of resources register). A guest expects that this > > > register > > > will count at a rate of timebase scaled by the number of guest > > > vcpus > > > present in the vcore. That is the per vcpu purr will count at a > > > rate of > > > timebase / # vcpus per vcore. > > > > > > Implement a handler for the H_PURR hcall and return the purr value > > > divided by smp_threads so that the sum of the purr deltas across > > > the > > > vcpus of a vcore equals the timebase delta > > > > > > Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> > > > > Does this need something new advertised in the hypertas DT entry? > > Hi David, > > There doesn't seem to be a concensus on what the return value from the > H_PURR hcall should be, whether it just returns the hardware value or > does some adjusting of the value based on guest smt mode as I've > implemented in the patch below. *eyeroll*. Lack of forethought in PAPR strikes again. > As such please drop this patch series. Ok, will do. > > The guest can just read the purr register directly anyway and then > interpret the values as it pleases. > > Kind Regards, > Suraj > > > > > > --- > > > hw/ppc/spapr_hcall.c | 24 ++++++++++++++++++++++++ > > > 1 file changed, 24 insertions(+) > > > > > > diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c > > > index aae9fd2b3e..88b3343f04 100644 > > > --- a/hw/ppc/spapr_hcall.c > > > +++ b/hw/ppc/spapr_hcall.c > > > @@ -1819,6 +1819,27 @@ static target_ulong h_update_dt(PowerPCCPU > > > *cpu, SpaprMachineState *spapr, > > > return H_SUCCESS; > > > } > > > > > > +static target_ulong h_purr(PowerPCCPU *cpu, SpaprMachineState > > > *spapr, > > > + target_ulong opcode, target_ulong > > > *args) > > > +{ > > > + CPUPPCState *env = &cpu->env; > > > + target_ulong purr; > > > + > > > + if (kvm_enabled()) { > > > + cpu_synchronize_state(CPU(cpu)); > > > + /* > > > + * Divide by smp_threads so that the sum of the purr > > > deltas across the > > > + * vcpus of a vcore equal the timebase delta. > > > + */ > > > + purr = env->spr[SPR_PURR] / smp_threads; > > > + } else { > > > + purr = cpu_ppc_load_purr(env); > > > + } > > > + args[0] = purr; > > > + > > > + return H_SUCCESS; > > > +} > > > + > > > static spapr_hcall_fn papr_hypercall_table[(MAX_HCALL_OPCODE / 4) > > > + 1]; > > > static spapr_hcall_fn kvmppc_hypercall_table[KVMPPC_HCALL_MAX - > > > KVMPPC_HCALL_BASE + 1]; > > > > > > @@ -1915,6 +1936,9 @@ static void hypercall_register_types(void) > > > spapr_register_hypercall(H_LOGICAL_DCBF, h_logical_dcbf); > > > spapr_register_hypercall(KVMPPC_H_LOGICAL_MEMOP, > > > h_logical_memop); > > > > > > + /* hcall-purr */ > > > + spapr_register_hypercall(H_PURR, h_purr); > > > + > > > /* qemu/KVM-PPC specific hcalls */ > > > spapr_register_hypercall(KVMPPC_H_RTAS, h_rtas); > > > > > > > >
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index aae9fd2b3e..88b3343f04 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1819,6 +1819,27 @@ static target_ulong h_update_dt(PowerPCCPU *cpu, SpaprMachineState *spapr, return H_SUCCESS; } +static target_ulong h_purr(PowerPCCPU *cpu, SpaprMachineState *spapr, + target_ulong opcode, target_ulong *args) +{ + CPUPPCState *env = &cpu->env; + target_ulong purr; + + if (kvm_enabled()) { + cpu_synchronize_state(CPU(cpu)); + /* + * Divide by smp_threads so that the sum of the purr deltas across the + * vcpus of a vcore equal the timebase delta. + */ + purr = env->spr[SPR_PURR] / smp_threads; + } else { + purr = cpu_ppc_load_purr(env); + } + args[0] = purr; + + return H_SUCCESS; +} + static spapr_hcall_fn papr_hypercall_table[(MAX_HCALL_OPCODE / 4) + 1]; static spapr_hcall_fn kvmppc_hypercall_table[KVMPPC_HCALL_MAX - KVMPPC_HCALL_BASE + 1]; @@ -1915,6 +1936,9 @@ static void hypercall_register_types(void) spapr_register_hypercall(H_LOGICAL_DCBF, h_logical_dcbf); spapr_register_hypercall(KVMPPC_H_LOGICAL_MEMOP, h_logical_memop); + /* hcall-purr */ + spapr_register_hypercall(H_PURR, h_purr); + /* qemu/KVM-PPC specific hcalls */ spapr_register_hypercall(KVMPPC_H_RTAS, h_rtas);
The hcall H_PURR is used by a guest to read the PURR (processor utilisation of resources register). A guest expects that this register will count at a rate of timebase scaled by the number of guest vcpus present in the vcore. That is the per vcpu purr will count at a rate of timebase / # vcpus per vcore. Implement a handler for the H_PURR hcall and return the purr value divided by smp_threads so that the sum of the purr deltas across the vcpus of a vcore equals the timebase delta Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> --- hw/ppc/spapr_hcall.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)