target-ppc: CPU device tree id
v5 cover target-ppc: CPU device tree id
Hi!
This is some cleanup. Please, comment. Thanks!
Changes:
v5:
* cleanup
* removed cpustate::kvm_cpu_id
* split into 2 patches - new PPC API and the usage of the API
Alexey Kardashevskiy (2):
target-ppc: add PowerPCCPU::cpu_dt_id
target-ppc: spapr: e500: fix to use cpu_dt_id
hw/intc/openpic_kvm.c | 2 +- hw/intc/xics.c | 15 +++++++++++++-- hw/intc/xics_kvm.c | 10 +++++----- hw/ppc/e500.c | 7 +++++-- hw/ppc/ppc.c | 33 +++++++++++++++++++++++++++++++++ hw/ppc/spapr.c | 9 +++++---- hw/ppc/spapr_hcall.c | 6 +++--- hw/ppc/spapr_rtas.c | 14 +++++++------- target-ppc/cpu-qom.h | 2 ++ target-ppc/cpu.h | 27 +++++++++++++++++++++++++++ target-ppc/kvm.c | 10 +--------- target-ppc/translate_init.c | 2 ++ 12 files changed, 104 insertions(+), 33 deletions(-)
Signature · 1 line
1.8.4.rc4
PATCH v5 1/2 target-ppc: add PowerPCCPU::cpu_dt_id
Normally CPUState::cpu_index is used to pick the right CPU for various operations. However default consecutive numbering does not always work for POWERPC.
These indexes are reflected in /proc/device-tree/cpus/PowerPC,POWER7@XX and used to call KVM VCPU's ioctls. In order to achieve this, kvmppc_fixup_cpu() was introduced. Roughly speaking, it multiplies cpu_index by the number of threads per core.
This approach has disadvantages such as:
1. NUMA configuration stays broken after the fixup;
2. CPU-targeted commands from the QEMU Monitor do not work properly as CPU indexes have been fixed and there is no clear way for the user to know what the new CPU indexes are.
This introduces a @cpu_dt_id field in the CPUPPCState struct which is initialized from @cpu_index by default and can be fixed later to meet the device tree requirements.
This adds an API to handle @cpu_dt_id.
This will be used later in machine code.
--- hw/ppc/ppc.c | 33 +++++++++++++++++++++++++++++++++ target-ppc/cpu-qom.h | 2 ++ target-ppc/cpu.h | 27 +++++++++++++++++++++++++++ 3 files changed, 62 insertions(+)
hw/ppc/ppc.c +33 -0
@@ -26,6 +26,7 @@#include "hw/ppc/ppc_e500.h" #include "qemu/timer.h" #include "sysemu/sysemu.h" +#include "sysemu/cpus.h" #include "hw/timer/m48t59.h" #include "qemu/log.h" #include "hw/loader.h"
@@ -1362,3 +1363,35 @@ int PPC_NVRAM_set_params (nvram_t *nvram, uint16_t NVRAM_size,return 0 ; } + +/* CPU device-tree ID helpers */ +int ppc_get_vcpu_dt_id (PowerPCCPU *cpu) +{ +return cpu->cpu_dt_id; +} + +PowerPCCPU *ppc_get_vcpu_by_dt_id (int cpu_dt_id) +{ +CPUState *cs; + +CPU_FOREACH (cs) { +PowerPCCPU *cpu =POWERPC_CPU (cs); + +if (cpu->cpu_dt_id == cpu_dt_id) { +return cpu; + } + } + +return NULL ; +} + +void ppc_fixup_cpu_dt_id (PowerPCCPU *cpu) +{ +CPUState *cs =CPU (cpu); +int smt; + +/* Adjust cpu index for SMT */ + smt =kvmppc_smt_threads (); + cpu->cpu_dt_id = (cs->cpu_index / smp_threads) * smt + + (cs->cpu_index % smp_threads); +}
target-ppc/cpu-qom.h +2 -0
@@ -79,6 +79,7 @@ typedef struct PowerPCCPUClass {/** * PowerPCCPU: * @env: #CPUPPCState +* @cpu_dt_id: CPU index used in the device tree. KVM uses this index too * * A PowerPC CPU. */
@@ -88,6 +89,7 @@ typedef struct PowerPCCPU {/*< public >*/ CPUPPCState env; +int cpu_dt_id; } PowerPCCPU;static inline PowerPCCPU *ppc_env_get_cpu (CPUPPCState *env)
target-ppc/cpu.h +27 -0
@@ -2154,4 +2154,31 @@ static inline bool cpu_has_work(CPUState *cpu)void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUPPCState *env); +/** +* ppc_get_vcpu_dt_id: +* @cs: a PowerPCCPU struct. +* +* Returns a device-tree ID for a CPU. +*/ +int ppc_get_vcpu_dt_id (PowerPCCPU *cpu); + +/** +* ppc_get_vcpu_by_dt_id: +* @cpu_dt_id: a device tree id +* +* Searches for a CPU by @cpu_dt_id. +* +* Returns: a PowerPCCPU struct +*/ +PowerPCCPU *ppc_get_vcpu_by_dt_id (int cpu_dt_id); + +/** +* ppc_fixup_cpu_dt_id: +* @cpu: a PowerPCCPU struct. +* +* Fixes the device-tree ID to align CPU core indexes to +* the threads-per-core number supported by the host hardware. +*/ +void ppc_fixup_cpu_dt_id (PowerPCCPU *cpu); +#endif /* !defined (__CPU_PPC_H__) */
Signature · 1 line
1.8.4.rc4
PATCH v5 2/2 target-ppc: spapr: e500: fix to use cpu_dt_id
In reply to Alexey KardashevskiyThis makes use of @cpu_dt_id and related API in:
1. emulated XICS hypercall handlers as they receive fixed CPU indexes;
2. XICS-KVM to enable in-kernel XICS on right CPU;
3. device-tree renderer.
This removes @cpu_index fixup as @cpu_dt_id is used instead so QEMU monitor can accept command-line CPU indexes again.
This changes kvm_arch_vcpu_id() to use ppc_get_vcpu_dt_id() as at the moment KVM CPU id and device tree ID are calculated using the same algorithm.
--- hw/intc/openpic_kvm.c | 2 +- hw/intc/xics.c | 15 +++++++++++++-- hw/intc/xics_kvm.c | 10 +++++----- hw/ppc/e500.c | 7 +++++-- hw/ppc/spapr.c | 9 +++++---- hw/ppc/spapr_hcall.c | 6 +++--- hw/ppc/spapr_rtas.c | 14 +++++++------- target-ppc/kvm.c | 10 +--------- target-ppc/translate_init.c | 2 ++ 9 files changed, 42 insertions(+), 33 deletions(-)
hw/intc/openpic_kvm.c +1 -1
@@ -228,7 +228,7 @@ int kvm_openpic_connect_vcpu(DeviceState *d, CPUState *cs) encap.cap =KVM_CAP_IRQ_MPIC ; encap.args[0 ] = opp->fd; - encap.args[1 ] = cs->cpu_index; + encap.args[1 ] =kvm_arch_vcpu_id (cs);return kvm_vcpu_ioctl (cs,KVM_ENABLE_CAP , &encap); }
hw/intc/xics.c +13 -2
@@ -33,6 +33,17 @@#include "qemu/error-report.h" #include "qapi/visitor.h" +static int get_cpu_index_by_dt_id (int cpu_dt_id) +{ +PowerPCCPU *cpu =ppc_get_vcpu_by_dt_id (cpu_dt_id); + +if (cpu) { +return cpu->parent_obj.cpu_index; + } + +return -1 ; +} +void xics_cpu_setup (XICSState *icp,PowerPCCPU *cpu) {CPUState *cs =CPU (cpu);
@@ -659,7 +670,7 @@ static target_ulong h_cppr(PowerPCCPU *cpu, sPAPREnvironment *spapr,static target_ulong h_ipi (PowerPCCPU *cpu,sPAPREnvironment *spapr,target_ulong opcode,target_ulong *args) { -target_ulong server = args[0 ]; +target_ulong server =get_cpu_index_by_dt_id (args[0 ]);target_ulong mfrr = args[1 ];if (server >= spapr->icp->nr_servers) {
@@ -728,7 +739,7 @@ static void rtas_set_xive(PowerPCCPU *cpu, sPAPREnvironment *spapr, } nr =rtas_ld (args,0 ); - server =rtas_ld (args,1 ); + server =get_cpu_index_by_dt_id (rtas_ld (args,1 )); priority =rtas_ld (args,2 ); if (!ics_valid_irq(ics, nr) || (server >= ics->icp->nr_servers)
hw/intc/xics_kvm.c +5 -5
@@ -65,7 +65,7 @@ static void icp_get_kvm_state(ICPState *ss) ret =kvm_vcpu_ioctl (ss->cs,KVM_GET_ONE_REG , ®);if (ret !=0 ) {error_report ("Unable to retrieve KVM interrupt controller state" -" for CPU %d: %s" , ss->cs->cpu_index,strerror (errno)); +" for CPU %ld: %s" ,kvm_arch_vcpu_id (ss->cs),strerror (errno));exit (1 ); }
@@ -97,7 +97,7 @@ static int icp_set_kvm_state(ICPState *ss, int version_id) ret =kvm_vcpu_ioctl (ss->cs,KVM_SET_ONE_REG , ®);if (ret !=0 ) {error_report ("Unable to restore KVM interrupt controller state (0x%" - PRIx64") for CPU %d: %s" , state, ss->cs->cpu_index, + PRIx64") for CPU %ld: %s" , state,kvm_arch_vcpu_id (ss->cs),strerror (errno));return ret; }
@@ -325,15 +325,15 @@ static void xics_kvm_cpu_setup(XICSState *icp, PowerPCCPU *cpu)struct kvm_enable_cap xics_enable_cap = { .cap =KVM_CAP_IRQ_XICS , .flags =0 , - .args = {icpkvm->kernel_xics_fd, cs->cpu_index,0 ,0 }, + .args = {icpkvm->kernel_xics_fd,kvm_arch_vcpu_id (cs),0 ,0 }, }; ss->cs = cs; ret =kvm_vcpu_ioctl (ss->cs,KVM_ENABLE_CAP , &xics_enable_cap);if (ret <0 ) { -error_report ("Unable to connect CPU%d to kernel XICS: %s" , - cs->cpu_index,strerror (errno)); +error_report ("Unable to connect CPU%ld to kernel XICS: %s" , +kvm_arch_vcpu_id (cs),strerror (errno));exit (1 ); } }
hw/ppc/e500.c +5 -2
@@ -238,6 +238,7 @@ static int ppce500_load_device_tree(QEMUMachineInitArgs *args,the first node as boot node and be happy */ for (i = smp_cpus -1 ; i >=0 ; i--) {CPUState *cpu; +PowerPCCPU *pcpu;char cpu_name[128 ];uint64_t cpu_release_addr =MPC8544_SPIN_BASE + (i *0x20 );
@@ -246,14 +247,16 @@ static int ppce500_load_device_tree(QEMUMachineInitArgs *args,continue ; } env = cpu->env_ptr; + pcpu =POWERPC_CPU (cpu);snprintf (cpu_name,sizeof (cpu_name),"/cpus/PowerPC,8544@%x" , - cpu->cpu_index); +ppc_get_vcpu_dt_id (pcpu));qemu_devtree_add_subnode (fdt, cpu_name);qemu_devtree_setprop_cell (fdt, cpu_name,"clock-frequency" , clock_freq);qemu_devtree_setprop_cell (fdt, cpu_name,"timebase-frequency" , tb_freq);qemu_devtree_setprop_string (fdt, cpu_name,"device_type" ,"cpu" ); -qemu_devtree_setprop_cell (fdt, cpu_name,"reg" , cpu->cpu_index); +qemu_devtree_setprop_cell (fdt, cpu_name,"reg" , +ppc_get_vcpu_dt_id (pcpu));qemu_devtree_setprop_cell (fdt, cpu_name,"d-cache-line-size" , env->dcache_line_size); qemu_devtree_setprop_cell(fdt, cpu_name, "i-cache-line-size",
hw/ppc/spapr.c +5 -4
@@ -206,19 +206,20 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment *spapr)CPU_FOREACH (cpu) {DeviceClass *dc =DEVICE_GET_CLASS (cpu); +int index =ppc_get_vcpu_dt_id (POWERPC_CPU (cpu));uint32_t associativity[] = {cpu_to_be32 (0x5 ),cpu_to_be32 (0x0 ),cpu_to_be32 (0x0 ),cpu_to_be32 (0x0 ),cpu_to_be32 (cpu->numa_node), -cpu_to_be32 (cpu->cpu_index)}; +cpu_to_be32 (index)}; -if ((cpu->cpu_index % smt) !=0 ) { +if ((index % smt) !=0 ) {continue ; }snprintf (cpu_model,32 ,"/cpus/%s@%x" , dc->fw_name, - cpu->cpu_index); + index); offset =fdt_path_offset (fdt, cpu_model);if (offset <0 ) {
@@ -367,7 +368,7 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,CPUPPCState *env = &cpu->env;DeviceClass *dc =DEVICE_GET_CLASS (cs);PowerPCCPUClass *pcc =POWERPC_CPU_GET_CLASS (cs); -int index = cs->cpu_index; +int index =ppc_get_vcpu_dt_id (cpu);uint32_t servers_prop[smp_threads];uint32_t gservers_prop[smp_threads *2 ];char *nodename;
hw/ppc/spapr_hcall.c +3 -3
@@ -464,13 +464,13 @@ static target_ulong h_register_vpa(PowerPCCPU *cpu, sPAPREnvironment *spapr,target_ulong vpa = args[2 ];target_ulong ret =H_PARAMETER ;CPUPPCState *tenv; -CPUState *tcpu; +PowerPCCPU *tcpu; - tcpu =qemu_get_cpu (procno); + tcpu =ppc_get_vcpu_by_dt_id (procno);if (!tcpu) {return H_PARAMETER ; } - tenv = tcpu->env_ptr; + tenv = &tcpu->env;switch (flags) {case FLAGS_REGISTER_VPA :
hw/ppc/spapr_rtas.c +7 -7
@@ -131,7 +131,7 @@ static void rtas_query_cpu_stopped_state(PowerPCCPU *cpu_, uint32_t nret, target_ulong rets) {target_ulong id; -CPUState *cpu; +PowerPCCPU *cpu;if (nargs !=1 || nret !=2 ) {rtas_st (rets,0 ,RTAS_OUT_PARAM_ERROR );
@@ -139,9 +139,9 @@ static void rtas_query_cpu_stopped_state(PowerPCCPU *cpu_, } id =rtas_ld (args,0 ); - cpu =qemu_get_cpu (id); + cpu =ppc_get_vcpu_by_dt_id (id);if (cpu !=NULL ) { -if (cpu->halted) { +if (cpu->parent_obj.halted) {rtas_st (rets,1 ,0 ); }else {rtas_st (rets,1 ,2 );
@@ -161,7 +161,7 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPREnvironment *spapr, uint32_t nret, target_ulong rets) {target_ulong id, start, r3; -CPUState *cs; +PowerPCCPU *cpu;if (nargs !=3 || nret !=1 ) {rtas_st (rets,0 ,RTAS_OUT_PARAM_ERROR );
@@ -172,9 +172,9 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPREnvironment *spapr, start =rtas_ld (args,1 ); r3 =rtas_ld (args,2 ); - cs =qemu_get_cpu (id); -if (cs !=NULL ) { -PowerPCCPU *cpu =POWERPC_CPU (cs); + cpu =ppc_get_vcpu_by_dt_id (id); +if (cpu !=NULL ) { +CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;if (!cs->halted) {
target-ppc/kvm.c +1 -9
@@ -401,7 +401,7 @@ static inline void kvm_fixup_page_sizes(PowerPCCPU *cpu)unsigned long kvm_arch_vcpu_id (CPUState *cpu) { -return cpu->cpu_index; +return ppc_get_vcpu_dt_id (POWERPC_CPU (cpu)); }int kvm_arch_init_vcpu (CPUState *cs)
@@ -1768,14 +1768,6 @@ static void kvmppc_host_cpu_class_init(ObjectClass *oc, void *data)int kvmppc_fixup_cpu (PowerPCCPU *cpu) { -CPUState *cs =CPU (cpu); -int smt; - -/* Adjust cpu index for SMT */ - smt =kvmppc_smt_threads (); - cs->cpu_index = (cs->cpu_index / smp_threads) * smt - + (cs->cpu_index % smp_threads); -return 0 ; }
target-ppc/translate_init.c +2 -0
@@ -7976,6 +7976,7 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp) max_smt, kvm_enabled() ? "KVM" : "TCG"); return; } +ppc_fixup_cpu_dt_id (cpu);#endif if (kvm_enabled ()) {
@@ -8598,6 +8599,7 @@ static void ppc_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (env); + cpu->cpu_dt_id = cs->cpu_index; env->msr_mask = pcc->msr_mask; env->mmu_model = pcc->mmu_model;
Signature · 1 line
1.8.4.rc4
Re: [Qemu-devel] [Qemu-ppc] [PATCH v5 2/2] target-ppc: spapr: e500: fix to use cpu_dt_id
Quoted 268 lines · Alexey Kardashevskiy
This makes use of @cpu_dt_id and related API in:
1. emulated XICS hypercall handlers as they receive fixed CPU indexes;
2. XICS-KVM to enable in-kernel XICS on right CPU;
3. device-tree renderer.This removes @cpu_index fixup as @cpu_dt_id is used instead so QEMU monitor can accept command-line CPU indexes again.
This changes
kvm_arch_vcpu_id()to useppc_get_vcpu_dt_id()as at the moment KVM CPU id and device tree ID are calculated using the same algorithm.Signed-off-by Alexey Kardashevskiy <[email protected]>---
hw/intc/openpic_kvm.c | 2 +- hw/intc/xics.c | 15 +++++++++++++-- hw/intc/xics_kvm.c | 10 +++++----- hw/ppc/e500.c | 7 +++++-- hw/ppc/spapr.c | 9 +++++---- hw/ppc/spapr_hcall.c | 6 +++--- hw/ppc/spapr_rtas.c | 14 +++++++------- target-ppc/kvm.c | 10 +--------- target-ppc/translate_init.c | 2 ++ 9 files changed, 42 insertions(+), 33 deletions(-)hw/intc/openpic_kvm.c +1
-1@@ -228,7 +228,7 @@ int kvm_openpic_connect_vcpu(DeviceState *d, CPUState *cs) encap.cap =KVM_CAP_IRQ_MPIC ; encap.args[0 ] = opp->fd; - encap.args[1 ] = cs->cpu_index; + encap.args[1 ] =kvm_arch_vcpu_id (cs);return kvm_vcpu_ioctl (cs,KVM_ENABLE_CAP , &encap); }hw/intc/xics.c +13
-2@@ -33,6 +33,17 @@#include "qemu/error-report.h" #include "qapi/visitor.h" +static int get_cpu_index_by_dt_id (int cpu_dt_id) +{ +PowerPCCPU *cpu =ppc_get_vcpu_by_dt_id (cpu_dt_id); + +if (cpu) { +return cpu->parent_obj.cpu_index; + } + +return -1 ; +} +void xics_cpu_setup (XICSState *icp,PowerPCCPU *cpu) {CPUState *cs =CPU (cpu);@@ -659,7 +670,7 @@ static target_ulong h_cppr(PowerPCCPU *cpu, sPAPREnvironment *spapr,static target_ulong h_ipi (PowerPCCPU *cpu,sPAPREnvironment *spapr,target_ulong opcode,target_ulong *args) { -target_ulong server = args[0 ]; +target_ulong server =get_cpu_index_by_dt_id (args[0 ]);target_ulong mfrr = args[1 ];if (server >= spapr->icp->nr_servers) {@@ -728,7 +739,7 @@ static void rtas_set_xive(PowerPCCPU *cpu, sPAPREnvironment *spapr, } nr =rtas_ld (args,0 ); - server =rtas_ld (args,1 ); + server =get_cpu_index_by_dt_id (rtas_ld (args,1 )); priority =rtas_ld (args,2 ); if (!ics_valid_irq(ics, nr) || (server >= ics->icp->nr_servers)hw/intc/xics_kvm.c +5
-5@@ -65,7 +65,7 @@ static void icp_get_kvm_state(ICPState *ss) ret =kvm_vcpu_ioctl (ss->cs,KVM_GET_ONE_REG , ®);if (ret !=0 ) {error_report ("Unable to retrieve KVM interrupt controller state" -" for CPU %d: %s" , ss->cs->cpu_index,strerror (errno)); +" for CPU %ld: %s" ,kvm_arch_vcpu_id (ss->cs),strerror (errno));exit (1 ); }@@ -97,7 +97,7 @@ static int icp_set_kvm_state(ICPState *ss, int version_id) ret =kvm_vcpu_ioctl (ss->cs,KVM_SET_ONE_REG , ®);if (ret !=0 ) {error_report ("Unable to restore KVM interrupt controller state (0x%" - PRIx64") for CPU %d: %s" , state, ss->cs->cpu_index, + PRIx64") for CPU %ld: %s" , state,kvm_arch_vcpu_id (ss->cs),strerror (errno));return ret; }@@ -325,15 +325,15 @@ static void xics_kvm_cpu_setup(XICSState *icp, PowerPCCPU *cpu)struct kvm_enable_cap xics_enable_cap = { .cap =KVM_CAP_IRQ_XICS , .flags =0 , - .args = {icpkvm->kernel_xics_fd, cs->cpu_index,0 ,0 }, + .args = {icpkvm->kernel_xics_fd,kvm_arch_vcpu_id (cs),0 ,0 }, }; ss->cs = cs; ret =kvm_vcpu_ioctl (ss->cs,KVM_ENABLE_CAP , &xics_enable_cap);if (ret <0 ) { -error_report ("Unable to connect CPU%d to kernel XICS: %s" , - cs->cpu_index,strerror (errno)); +error_report ("Unable to connect CPU%ld to kernel XICS: %s" , +kvm_arch_vcpu_id (cs),strerror (errno));exit (1 ); } }hw/ppc/e500.c +5
-2@@ -238,6 +238,7 @@ static int ppce500_load_device_tree(QEMUMachineInitArgs *args,the first node as boot node and be happy */ for (i = smp_cpus -1 ; i >=0 ; i--) {CPUState *cpu; +PowerPCCPU *pcpu;char cpu_name[128 ];uint64_t cpu_release_addr =MPC8544_SPIN_BASE + (i *0x20 );@@ -246,14 +247,16 @@ static int ppce500_load_device_tree(QEMUMachineInitArgs *args,continue ; } env = cpu->env_ptr; + pcpu =POWERPC_CPU (cpu);snprintf (cpu_name,sizeof (cpu_name),"/cpus/PowerPC,8544@%x" , - cpu->cpu_index); +ppc_get_vcpu_dt_id (pcpu));qemu_devtree_add_subnode (fdt, cpu_name);qemu_devtree_setprop_cell (fdt, cpu_name,"clock-frequency" , clock_freq);qemu_devtree_setprop_cell (fdt, cpu_name,"timebase-frequency" , tb_freq);qemu_devtree_setprop_string (fdt, cpu_name,"device_type" ,"cpu" ); -qemu_devtree_setprop_cell (fdt, cpu_name,"reg" , cpu->cpu_index); +qemu_devtree_setprop_cell (fdt, cpu_name,"reg" , +ppc_get_vcpu_dt_id (pcpu));qemu_devtree_setprop_cell (fdt, cpu_name,"d-cache-line-size" , env->dcache_line_size); qemu_devtree_setprop_cell(fdt, cpu_name, "i-cache-line-size",hw/ppc/spapr.c +5
-4@@ -206,19 +206,20 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment *spapr)CPU_FOREACH (cpu) {DeviceClass *dc =DEVICE_GET_CLASS (cpu); +int index =ppc_get_vcpu_dt_id (POWERPC_CPU (cpu));uint32_t associativity[] = {cpu_to_be32 (0x5 ),cpu_to_be32 (0x0 ),cpu_to_be32 (0x0 ),cpu_to_be32 (0x0 ),cpu_to_be32 (cpu->numa_node), -cpu_to_be32 (cpu->cpu_index)}; +cpu_to_be32 (index)}; -if ((cpu->cpu_index % smt) !=0 ) { +if ((index % smt) !=0 ) {continue ; }snprintf (cpu_model,32 ,"/cpus/%s@%x" , dc->fw_name, - cpu->cpu_index); + index); offset =fdt_path_offset (fdt, cpu_model);if (offset <0 ) {@@ -367,7 +368,7 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,CPUPPCState *env = &cpu->env;DeviceClass *dc =DEVICE_GET_CLASS (cs);PowerPCCPUClass *pcc =POWERPC_CPU_GET_CLASS (cs); -int index = cs->cpu_index; +int index =ppc_get_vcpu_dt_id (cpu);uint32_t servers_prop[smp_threads];uint32_t gservers_prop[smp_threads *2 ];char *nodename;hw/ppc/spapr_hcall.c +3
-3@@ -464,13 +464,13 @@ static target_ulong h_register_vpa(PowerPCCPU *cpu, sPAPREnvironment *spapr,target_ulong vpa = args[2 ];target_ulong ret =H_PARAMETER ;CPUPPCState *tenv; -CPUState *tcpu; +PowerPCCPU *tcpu; - tcpu =qemu_get_cpu (procno); + tcpu =ppc_get_vcpu_by_dt_id (procno);if (!tcpu) {return H_PARAMETER ; } - tenv = tcpu->env_ptr; + tenv = &tcpu->env;switch (flags) {case FLAGS_REGISTER_VPA :hw/ppc/spapr_rtas.c +7
-7@@ -131,7 +131,7 @@ static void rtas_query_cpu_stopped_state(PowerPCCPU *cpu_, uint32_t nret, target_ulong rets) {target_ulong id; -CPUState *cpu; +PowerPCCPU *cpu;if (nargs !=1 || nret !=2 ) {rtas_st (rets,0 ,RTAS_OUT_PARAM_ERROR );@@ -139,9 +139,9 @@ static void rtas_query_cpu_stopped_state(PowerPCCPU *cpu_, } id =rtas_ld (args,0 ); - cpu =qemu_get_cpu (id); + cpu =ppc_get_vcpu_by_dt_id (id);if (cpu !=NULL ) { -if (cpu->halted) { +if (cpu->parent_obj.halted) {rtas_st (rets,1 ,0 ); }else {rtas_st (rets,1 ,2 );@@ -161,7 +161,7 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPREnvironment *spapr, uint32_t nret, target_ulong rets) {target_ulong id, start, r3; -CPUState *cs; +PowerPCCPU *cpu;if (nargs !=3 || nret !=1 ) {rtas_st (rets,0 ,RTAS_OUT_PARAM_ERROR );@@ -172,9 +172,9 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPREnvironment *spapr, start =rtas_ld (args,1 ); r3 =rtas_ld (args,2 ); - cs =qemu_get_cpu (id); -if (cs !=NULL ) { -PowerPCCPU *cpu =POWERPC_CPU (cs); + cpu =ppc_get_vcpu_by_dt_id (id); +if (cpu !=NULL ) { +CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;if (!cs->halted) {target-ppc/kvm.c +1
-1@@ -401,7 +401,7 @@ static inline void kvm_fixup_page_sizes(PowerPCCPU *cpu)unsigned long kvm_arch_vcpu_id (CPUState *cpu) { -return cpu->cpu_index; +return ppc_get_vcpu_dt_id (POWERPC_CPU (cpu)); }int kvm_arch_init_vcpu (CPUState *cs)
target-ppc/kvm.c static void kvmppc_host_cpu_class_init(ObjectClass *oc, void *data) · line 1769
Quoted 2 lines
target-ppc/kvm.c +0
-0@@ -1768,14 +1768,6 @@ static void kvmppc_host_cpu_class_init(ObjectClass *oc, void *data)int kvmppc_fixup_cpu (PowerPCCPU *cpu)
This function is not needed anymore now, no? Just remove it and all of its callers.
Quoted 17 lines
target-ppc/kvm.c +0
-8{ -CPUState *cs =CPU (cpu); -int smt; - -/* Adjust cpu index for SMT */ - smt =kvmppc_smt_threads (); - cs->cpu_index = (cs->cpu_index / smp_threads) * smt - + (cs->cpu_index % smp_threads); -return 0 ; }target-ppc/translate_init.c +0
-0
target-ppc/translate_init.c static void ppc_cpu_realizefn(DeviceState *dev, Error **errp) · line 7979
Quoted 4 lines
target-ppc/translate_init.c +1
-0@@ -7976,6 +7976,7 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp) max_smt, kvm_enabled() ? "KVM" : "TCG");return ; } +ppc_fixup_cpu_dt_id (cpu);
It's not a fixup. It's more of a sync or a populate. In fact, it should probably be inlined.
Alex
Quoted 15 lines
target-ppc/translate_init.c +1
-0#endif if (kvm_enabled ()) {@@ -8598,6 +8599,7 @@ static void ppc_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (env); + cpu->cpu_dt_id = cs->cpu_index; env->msr_mask = pcc->msr_mask; env->mmu_model = pcc->mmu_model;Signature · 1 line
1.8.4.rc4
Quoted 3 lines · Alexey Kardashevskiy
Hi!
This is some cleanup. Please, comment. Thanks!
Ping, anyone?
Quoted 24 lines
Changes:
v5:
* cleanup
* removedcpustate::kvm_cpu_id
* split into 2 patches - new PPC API and the usage of the APIAlexey Kardashevskiy (2):
target-ppc: addPowerPCCPU::cpu_dt_id
target-ppc: spapr: e500: fix to usecpu_dt_idhw/intc/openpic_kvm.c | 2 +- hw/intc/xics.c | 15 +++++++++++++-- hw/intc/xics_kvm.c | 10 +++++----- hw/ppc/e500.c | 7 +++++-- hw/ppc/ppc.c | 33 +++++++++++++++++++++++++++++++++ hw/ppc/spapr.c | 9 +++++---- hw/ppc/spapr_hcall.c | 6 +++--- hw/ppc/spapr_rtas.c | 14 +++++++------- target-ppc/cpu-qom.h | 2 ++ target-ppc/cpu.h | 27 +++++++++++++++++++++++++++ target-ppc/kvm.c | 10 +--------- target-ppc/translate_init.c | 2 ++ 12 files changed, 104 insertions(+), 33 deletions(-)
Signature · 1 line
Alexey
Quoted 7 lines · Alexey Kardashevskiy
Quoted 3 lines · Alexey Kardashevskiy
Hi!
This is some cleanup. Please, comment. Thanks!
Ping, anyone?
Ping?
Quoted 28 lines
Quoted 26 lines
Changes:
v5:
* cleanup
* removedcpustate::kvm_cpu_id
* split into 2 patches - new PPC API and the usage of the APIAlexey Kardashevskiy (2):
target-ppc: addPowerPCCPU::cpu_dt_id
target-ppc: spapr: e500: fix to usecpu_dt_idhw/intc/openpic_kvm.c | 2 +- hw/intc/xics.c | 15 +++++++++++++-- hw/intc/xics_kvm.c | 10 +++++----- hw/ppc/e500.c | 7 +++++-- hw/ppc/ppc.c | 33 +++++++++++++++++++++++++++++++++ hw/ppc/spapr.c | 9 +++++---- hw/ppc/spapr_hcall.c | 6 +++--- hw/ppc/spapr_rtas.c | 14 +++++++------- target-ppc/cpu-qom.h | 2 ++ target-ppc/cpu.h | 27 +++++++++++++++++++++++++++ target-ppc/kvm.c | 10 +--------- target-ppc/translate_init.c | 2 ++ 12 files changed, 104 insertions(+), 33 deletions(-)
Signature · 1 line
Alexey
Quoted 11 lines · Alexey Kardashevskiy
Quoted 7 lines · Alexey Kardashevskiy
Quoted 3 lines · Alexey Kardashevskiy
Hi!
This is some cleanup. Please, comment. Thanks!
Ping, anyone?
Ping?
Ping, anyone?
Quoted 30 lines
Quoted 28 lines
Quoted 26 lines
Changes:
v5:
* cleanup
* removedcpustate::kvm_cpu_id
* split into 2 patches - new PPC API and the usage of the APIAlexey Kardashevskiy (2):
target-ppc: addPowerPCCPU::cpu_dt_id
target-ppc: spapr: e500: fix to usecpu_dt_idhw/intc/openpic_kvm.c | 2 +- hw/intc/xics.c | 15 +++++++++++++-- hw/intc/xics_kvm.c | 10 +++++----- hw/ppc/e500.c | 7 +++++-- hw/ppc/ppc.c | 33 +++++++++++++++++++++++++++++++++ hw/ppc/spapr.c | 9 +++++---- hw/ppc/spapr_hcall.c | 6 +++--- hw/ppc/spapr_rtas.c | 14 +++++++------- target-ppc/cpu-qom.h | 2 ++ target-ppc/cpu.h | 27 +++++++++++++++++++++++++++ target-ppc/kvm.c | 10 +--------- target-ppc/translate_init.c | 2 ++ 12 files changed, 104 insertions(+), 33 deletions(-)
Signature · 1 line
Alexey
Quoted 8 lines · Alexey Kardashevskiy
Quoted 7 lines · Alexey Kardashevskiy
Quoted 6 lines · Alexey Kardashevskiy
Quoted 3 lines · Alexey Kardashevskiy
Hi!
This is some cleanup. Please, comment. Thanks!
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Ping, anyone?
Ping?
Ping, anyone?
Ping, anyone?
Quoted 35 lines
Quoted 33 lines
Quoted 31 lines
Quoted 29 lines
Changes:
v5:
* cleanup
* removedcpustate::kvm_cpu_id
* split into 2 patches - new PPC API and the usage of the APIAlexey Kardashevskiy (2):
target-ppc: addPowerPCCPU::cpu_dt_id
target-ppc: spapr: e500: fix to usecpu_dt_idhw/intc/openpic_kvm.c | 2 +- hw/intc/xics.c | 15 +++++++++++++-- hw/intc/xics_kvm.c | 10 +++++----- hw/ppc/e500.c | 7 +++++-- hw/ppc/ppc.c | 33 +++++++++++++++++++++++++++++++++ hw/ppc/spapr.c | 9 +++++---- hw/ppc/spapr_hcall.c | 6 +++--- hw/ppc/spapr_rtas.c | 14 +++++++------- target-ppc/cpu-qom.h | 2 ++ target-ppc/cpu.h | 27 +++++++++++++++++++++++++++ target-ppc/kvm.c | 10 +--------- target-ppc/translate_init.c | 2 ++ 12 files changed, 104 insertions(+), 33 deletions(-)
Signature · 1 line
Alexey
Quoted 12 lines · Alexey Kardashevskiy
Quoted 11 lines · Alexey Kardashevskiy
Quoted 10 lines · Alexey Kardashevskiy
Quoted 7 lines · Alexey Kardashevskiy
Quoted 3 lines · Alexey Kardashevskiy
Hi!
This is some cleanup. Please, comment. Thanks!
Ping, anyone?
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Ping?
Ping, anyone?
Ping, anyone?
Please, anybody, say something.
Quoted 39 lines
Quoted 37 lines
Quoted 35 lines
Quoted 33 lines
Quoted 31 lines
Changes:
v5:
* cleanup
* removedcpustate::kvm_cpu_id
* split into 2 patches - new PPC API and the usage of the APIAlexey Kardashevskiy (2):
target-ppc: addPowerPCCPU::cpu_dt_id
target-ppc: spapr: e500: fix to usecpu_dt_idhw/intc/openpic_kvm.c | 2 +- hw/intc/xics.c | 15 +++++++++++++-- hw/intc/xics_kvm.c | 10 +++++----- hw/ppc/e500.c | 7 +++++-- hw/ppc/ppc.c | 33 +++++++++++++++++++++++++++++++++ hw/ppc/spapr.c | 9 +++++---- hw/ppc/spapr_hcall.c | 6 +++--- hw/ppc/spapr_rtas.c | 14 +++++++------- target-ppc/cpu-qom.h | 2 ++ target-ppc/cpu.h | 27 +++++++++++++++++++++++++++ target-ppc/kvm.c | 10 +--------- target-ppc/translate_init.c | 2 ++ 12 files changed, 104 insertions(+), 33 deletions(-)
Signature · 1 line
Alexey
Quoted 17 lines · On Fri, 31 Jan 2014 17:07:36 +1100 Alexey Kardashevskiy <[email protected]> wrote:
Quoted 16 lines · Alexey Kardashevskiy
Quoted 15 lines · Alexey Kardashevskiy
Quoted 11 lines · Alexey Kardashevskiy
Quoted 7 lines · Alexey Kardashevskiy
Quoted 3 lines · Alexey Kardashevskiy
Hi!
This is some cleanup. Please, comment. Thanks!
Ping, anyone?
Ping?
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Ping, anyone?
Ping, anyone?
Please, anybody, say something.
Maybe poke the maintainers on IRC?
Thomas
Am 31.01.2014 07:07, schrieb Alexey Kardashevskiy:
Quoted 17 lines · Alexey Kardashevskiy
Quoted 16 lines · Alexey Kardashevskiy
Quoted 15 lines · Alexey Kardashevskiy
Quoted 11 lines · Alexey Kardashevskiy
Quoted 7 lines · Alexey Kardashevskiy
Quoted 3 lines
Hi!
This is some cleanup. Please, comment. Thanks!
Ping, anyone?
Ping?
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Ping, anyone?
Ping, anyone?
Please, anybody, say something.
No objection from my side, but I'm not really familiar with the topic, so leaving that to Alex et al.
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg