Further ppc & pseries updates
cover Further ppc & pseries updates
Here are several more updates for the ppc target and the pseries machine in particular. This obsoletes the earlier copies of the first two patches I sent today.
The first patch more correctly handles CPU features which are present on some CPUs we know about, but which are not yet emulated in TCG. The second adds limited PCI support to the pseries machine (this copy fixes a compile bug in the previous version that hits with some compilers). The third adds support for the "info tlb" monitor command on Book3S ppc cpus.
PATCH 1/3 ppc: Alter CPU state to mask out TCG unimplemented instructions as appropriate
The CPU state contains two bitmaps, initialized from the CPU spec which describes which instructions are implemented on the CPU. A couple of bits are defined which cover instructions (VSX and DFP) which are not currently implemented in TCG. So far, these are only used to handle the case of -cpu host because a KVM guest can use the instructions when the host CPU supports them.
However, it's a mild layering violation to simply not include those bits in the CPU descriptions for those CPUs that do support them, just because we can't handle them in TCG. This patch corrects the situation, so that the instruction bits _are_ shown correctly in the cpu spec table, but are masked out from the cpu state in the non-KVM case.
--- target-ppc/cpu.h | 26 ++++++++++++++++++++++++++ target-ppc/translate_init.c | 20 +++++++++++++++++--- 2 files changed, 43 insertions(+), 3 deletions(-)
target-ppc/cpu.h +26 -0
@@ -1856,6 +1856,30 @@ enum {/* popcntw and popcntd instructions */ PPC_POPCNTWD =0x8000000000000000ULL , +#define PPC_TCG_INSNS (PPC_INSNS_BASE | PPC_POWER | PPC_POWER2 \ + |PPC_POWER_RTC |PPC_POWER_BR |PPC_64B \ + |PPC_64BX |PPC_64H |PPC_WAIT |PPC_MFTB \ + |PPC_602_SPEC |PPC_ISEL |PPC_POPCNTB \ + |PPC_STRING |PPC_FLOAT |PPC_FLOAT_EXT \ + |PPC_FLOAT_FSQRT |PPC_FLOAT_FRES \ + |PPC_FLOAT_FRSQRTE |PPC_FLOAT_FRSQRTES \ + |PPC_FLOAT_FSEL |PPC_FLOAT_STFIWX \ + |PPC_ALTIVEC |PPC_SPE |PPC_SPE_SINGLE \ + |PPC_SPE_DOUBLE |PPC_MEM_TLBIA \ + |PPC_MEM_TLBIE |PPC_MEM_TLBSYNC \ + |PPC_MEM_SYNC |PPC_MEM_EIEIO \ + |PPC_CACHE |PPC_CACHE_ICBI \ + |PPC_CACHE_DCBZ |PPC_CACHE_DCBZT \ + |PPC_CACHE_DCBA |PPC_CACHE_LOCK \ + |PPC_EXTERN |PPC_SEGMENT | PPC_6xx_TLB \ + | PPC_74xx_TLB | PPC_40x_TLB |PPC_SEGMENT_64B \ + |PPC_SLBI |PPC_WRTEE | PPC_40x_EXCP \ + |PPC_405_MAC |PPC_440_SPEC |PPC_BOOKE \ + |PPC_MFAPIDI |PPC_TLBIVA |PPC_TLBIVAX \ + | PPC_4xx_COMMON | PPC_40x_ICBT |PPC_RFMCI \ + |PPC_RFDI |PPC_DCR |PPC_DCRX |PPC_DCRUX \ + |PPC_POPCNTWD ) +/* extended type values */ /* BookE 2.06 PowerPC specification */
@@ -1864,6 +1888,8 @@ enum {PPC2_VSX =0x0000000000000002ULL ,/* Decimal Floating Point (DFP) */ PPC2_DFP =0x0000000000000004ULL , + +#define PPC_TCG_INSNS2 (PPC2_BOOKE206) };/*****************************************************************************/
target-ppc/translate_init.c +17 -3
@@ -6519,9 +6519,7 @@ static void init_proc_970MP (CPUPPCState *env) PPC_64B | PPC_ALTIVEC | \ PPC_SEGMENT_64B | PPC_SLBI | \ PPC_POPCNTB | PPC_POPCNTWD) -/* FIXME: Should also have PPC2_VSX and PPC2_DFP, but we don't -* implement those in TCG yet */ -#define POWERPC_INSNS2_POWER7 (PPC_NONE) +#define POWERPC_INSNS2_POWER7 (PPC2_VSX | PPC2_DFP)#define POWERPC_MSRM_POWER7 (0x800000000204FF36ULL)#define POWERPC_MMU_POWER7 (POWERPC_MMU_2_06)#define POWERPC_EXCP_POWER7 (POWERPC_EXCP_POWER7)
@@ -9848,6 +9846,22 @@ int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def) env->bus_model = def->bus_model; env->insns_flags = def->insns_flags; env->insns_flags2 = def->insns_flags2; +if (!kvm_enabled ()) { +/* TCG doesn't (yet) emulate some groups of instructions that +* are implemented on some otherwise supported CPUs (e.g. VSX +* and decimal floating point instructions on POWER7). We +* remove unsupported instruction groups from the cpu state's +* instruction masks and hope the guest can cope. For at +* least the pseries machine, the unavailability of these +* instructions can be advertise to the guest via the device +* tree. +* +* FIXME: we should have a similar masking for CPU features +* not accessible under KVM, but so far, there aren't any of +* those. */ + env->insns_flags &=PPC_TCG_INSNS ; + env->insns_flags2 &=PPC_TCG_INSNS2 ; + } env->flags = def->flags; env->bfd_mach = def->bfd_mach; env->check_pow = def->check_pow;
Signature · 1 line
1.7.7
Alexander Graf
AppliedRe: [Qemu-devel] [PATCH 1/3] ppc: Alter CPU state to mask out TCG unimplemented instructions as appropriate
Quoted 7 lines · David Gibson
The CPU state contains two bitmaps, initialized from the CPU spec which describes which instructions are implemented on the CPU. A couple of bits are defined which cover instructions (VSX and DFP) which are not currently implemented in TCG. So far, these are only used to handle the case of -cpu host because a KVM guest can use the instructions when the host CPU supports them.
Quoted 8 lines
However, it's a mild layering violation to simply not include those bits in the CPU descriptions for those CPUs that do support them, just because we can't handle them in TCG. This patch corrects the situation, so that the instruction bits _are_ shown correctly in the cpu spec table, but are masked out from the cpu state in the non-KVM case.
Signed-off-by David Gibson <[email protected]>
Thanks, applied.
Alex
PATCH 2/3 pseries: Add partial support for PCI
In reply to David GibsonThis patch adds a PCI bus to the pseries machine. This instantiates the qemu generic PCI bus code, advertises a PCI host bridge in the guest's device tree and implements the RTAS methods specified by PAPR to access PCI config space. It also sets up the memory regions we need to provide windows into the PCI memory and IO space, and advertises those to the guest.
However, because qemu can't yet emulate an IOMMU, which is mandatory on pseries, PCI devices which use DMA (i.e. most of them) will not work with this code alone. Still, this is enough to support the virtio_pci device (which probably _should_ use emulated PCI DMA, but is specced to use direct hypervisor access to guest physical memory instead).
--- Makefile.target | 1 + hw/spapr.c | 36 ++++- hw/spapr.h | 2 + hw/spapr_pci.c | 508 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/spapr_pci.h | 59 +++++++ 5 files changed, 602 insertions(+), 4 deletions(-) create mode 100644 hw/spapr_pci.c create mode 100644 hw/spapr_pci.h
Makefile.target +1 -0
@@ -248,6 +248,7 @@ obj-ppc-y += ppc_newworld.o # IBM pSeries (sPAPR) obj-ppc-$(CONFIG_PSERIES) += spapr.o spapr_hcall.o spapr_rtas.o spapr_vio.o obj-ppc-$(CONFIG_PSERIES) += xics.o spapr_vty.o spapr_llan.o spapr_vscsi.o +obj-ppc-$(CONFIG_PSERIES) += spapr_pci.o device-hotplug.o pci-hotplug.o # PowerPC 4xx boards obj-ppc-y += ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o obj-ppc-y += ppc440.o ppc440_bamboo.o
hw/spapr.c +32 -4
@@ -39,10 +39,12 @@#include "hw/spapr.h" #include "hw/spapr_vio.h" +#include "hw/spapr_pci.h" #include "hw/xics.h" #include "kvm.h" #include "kvm_ppc.h" +#include "pci.h" #include "exec-memory.h"
@@ -62,6 +64,11 @@#define MAX_CPUS 256#define XICS_IRQS 1024 +#define SPAPR_PCI_BUID 0x800000020000001ULL +#define SPAPR_PCI_MEM_WIN_ADDR (0x10000000000ULL + 0xA0000000) +#define SPAPR_PCI_MEM_WIN_SIZE 0x20000000 +#define SPAPR_PCI_IO_WIN_ADDR (0x10000000000ULL + 0x80000000) +#define PHANDLE_XICP 0x00001111sPAPREnvironment *spapr;
@@ -146,6 +153,14 @@ static void *spapr_create_fdt_skel(const char *cpu_model, &end_prop, sizeof(end_prop))));_FDT ((fdt_property_string (fdt,"qemu,boot-device" , boot_device))); +/* +* Because we don't always invoke any firmware, we can't rely on +* that to do BAR allocation. Long term, we should probably do +* that ourselves, but for now, this setting (plus advertising the +* current BARs as 0) causes sufficiently recent kernels to to the +* BAR assignment themselves */ +_FDT ((fdt_property_cell (fdt,"linux,pci-probe-only" ,0 ))); +_FDT ((fdt_end_node (fdt)));/* memory node(s) */
@@ -308,6 +323,7 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr, {int ret;void *fdt; +sPAPRPHBState *phb; fdt =g_malloc (FDT_MAX_SIZE );
@@ -320,6 +336,15 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr,exit (1 ); } + QLIST_FOREACH(phb, &spapr->phbs, list) { + ret =spapr_populate_pci_devices (phb,PHANDLE_XICP , fdt); + } + +if (ret <0 ) { +fprintf (stderr,"couldn't setup PCI devices in fdt\n" ); +exit (1 ); + } +/* RTAS */ ret =spapr_rtas_device_tree_setup (fdt, rtas_addr, rtas_size);if (ret <0 ) {
@@ -478,6 +503,12 @@ static void ppc_spapr_init(ram_addr_t ram_size, } } +/* Set up PCI */ +spapr_create_phb (spapr,"pci" ,SPAPR_PCI_BUID , +SPAPR_PCI_MEM_WIN_ADDR , +SPAPR_PCI_MEM_WIN_SIZE , +SPAPR_PCI_IO_WIN_ADDR ); +for (i =0 ; i < nb_nics; i++) {NICInfo *nd = &nd_table[i];
@@ -488,10 +519,7 @@ static void ppc_spapr_init(ram_addr_t ram_size,if (strcmp (nd->model,"ibmveth" ) ==0 ) {spapr_vlan_create (spapr->vio_bus,0x1000 + i, nd); }else { -fprintf (stderr,"pSeries (sPAPR) platform does not support " -"NIC model '%s' (only ibmveth is supported)\n" , - nd->model); -exit (1 ); +pci_nic_init_nofail (&nd_table[i], nd->model,NULL ); } }
hw/spapr.h +2 -0
@@ -4,10 +4,12 @@#include "hw/xics.h" struct VIOsPAPRBus ; +struct sPAPRPHBState ;struct icp_state ; typedef struct sPAPREnvironment { struct VIOsPAPRBus *vio_bus; + QLIST_HEAD(, sPAPRPHBState) phbs; struct icp_state *icp; target_phys_addr_t ram_limit;
hw/spapr_pci.c new file +508 -0
508 lines not on this page · raw message
hw/spapr_pci.h new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
1.7.7
Re: [Qemu-devel] [PATCH 2/3] pseries: Add partial support for PCI
Quoted 7 lines · David Gibson
This patch adds a PCI bus to the pseries machine. This instantiates the qemu generic PCI bus code, advertises a PCI host bridge in the guest's device tree and implements the RTAS methods specified by PAPR to access PCI config space. It also sets up the memory regions we need to provide windows into the PCI memory and IO space, and advertises those to the guest.
Quoted 8 lines
However, because qemu can't yet emulate an IOMMU, which is mandatory on pseries, PCI devices which use DMA (i.e. most of them) will not work with this code alone. Still, this is enough to support the
virtio_pcidevice (which probably _should_ use emulated PCI DMA, but is specced to use direct hypervisor access to guest physical memory instead).Signed-off-by Alexey Kardashevskiy <[email protected]>Signed-off-by David Gibson <[email protected]>
Applied with the following patch folded in:
hw/spapr_pci.h +4 -2
@@ -16,14 +16,16 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ +#if !defined(__HW_SPAPR_H__) +#error Please include spapr.h before this file! +#endif + #if !defined(__HW_SPAPR_PCI_H__) #define __HW_SPAPR_PCI_H__ #include "hw/pci_host.h" #include "hw/xics.h" -typedef struct sPAPREnvironment sPAPREnvironment; - #define SPAPR_PCI_NUM_LSI 16 typedef struct sPAPRPHBState {
Alex
PATCH 3/3 monitor: add ability to dump SLB entries
In reply to David GibsonFrom: Nishanth Aravamudan <[email protected]>
When run with a PPC Book3S (server) CPU Currently 'info tlb' in the qemu monitor reports "dump_mmu: unimplemented". However, during bringup work, it can be quite handy to have the SLB entries, which are available in the CPUPPCState. This patch adds an implementation of info tlb for book3s, which dumps the SLB.
--- target-ppc/helper.c | 32 +++++++++++++++++++++++++++----- 1 files changed, 27 insertions(+), 5 deletions(-)
target-ppc/helper.c +27 -5
@@ -1545,14 +1545,36 @@ static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, } } +static void mmubooks_dump_mmu (FILE *f,fprintf_function cpu_fprintf, +CPUState *env) +{ +int i; +uint64_t slbe, slbv; + +cpu_synchronize_state (env); + +cpu_fprintf (f,"SLB\tESID\t\t\tVSID\n" ); +for (i =0 ; i < env->slb_nr; i++) { + slbe = env->slb[i].esid; + slbv = env->slb[i].vsid; +if (slbe ==0 && slbv ==0 ) { +continue ; + } +cpu_fprintf (f,"%d\t0x%016" PRIx64"\t0x%016" PRIx64"\n" , + i, slbe, slbv); + } +} +void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUState *env) { -switch (env->mmu_model) { -case POWERPC_MMU_BOOKE206 : +if (env->mmu_model ==POWERPC_MMU_BOOKE206 ) {mmubooke206_dump_mmu (f, cpu_fprintf, env); -break ; -default : -cpu_fprintf (f,"%s: unimplemented\n" , __func__); + }else { +if ((env->mmu_model &POWERPC_MMU_64B ) !=0 ) { +mmubooks_dump_mmu (f, cpu_fprintf, env); + }else { +cpu_fprintf (f,"%s: unimplemented\n" , __func__); + } } }
Signature · 1 line
1.7.7
Re: [Qemu-devel] [PATCH 3/3] monitor: add ability to dump SLB entries
Quoted 24 lines · David Gibson
From: Nishanth Aravamudan <[email protected]>
When run with a PPC Book3S (server) CPU Currently 'info tlb' in the qemu monitor reports "
dump_mmu: unimplemented". However, during bringup work, it can be quite handy to have the SLB entries, which are available in the CPUPPCState. This patch adds an implementation of info tlb for book3s, which dumps the SLB.Signed-off-by Nishanth Aravamudan <[email protected]>Signed-off-by David Gibson <[email protected]>---
target-ppc/helper.c| 32 +++++++++++++++++++++++++++-----1 files changed, 27 insertions(+), 5 deletions(-)target-ppc/helper.c +2
-0@@ -1545,14 +1545,36 @@ static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, } } +static void mmubooks_dump_mmu (FILE *f,fprintf_function cpu_fprintf, +CPUState *env)
target-ppc/helper.c static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, · line 1559
Quoted 10 lines
target-ppc/helper.c +10
-0+{ +int i; +uint64_t slbe, slbv; + +cpu_synchronize_state (env); + +cpu_fprintf (f,"SLB\tESID\t\t\tVSID\n" ); +for (i =0 ; i < env->slb_nr; i++) { + slbe = env->slb[i].esid; + slbv = env->slb[i].vsid;
From cpu.h:
#if defined(TARGET_PPC64)
/* Address space register */
target_ulong asr;
/* PowerPC 64 SLB area */
ppc_slb_t slb[64];
int slb_nr;#endif
Quoted 9 lines
target-ppc/helper.c +8
-0+if (slbe ==0 && slbv ==0 ) { +continue ; + } +cpu_fprintf (f,"%d\t0x%016" PRIx64"\t0x%016" PRIx64"\n" , + i, slbe, slbv); + } +} +void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUState *env)
target-ppc/helper.c static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, · line 1573
Quoted 10 lines
target-ppc/helper.c +3
-5{ -switch (env->mmu_model) { -case POWERPC_MMU_BOOKE206 : +if (env->mmu_model ==POWERPC_MMU_BOOKE206 ) {mmubooke206_dump_mmu (f, cpu_fprintf, env); -break ; -default : -cpu_fprintf (f,"%s: unimplemented\n" , __func__); + }else { +if ((env->mmu_model &POWERPC_MMU_64B ) !=0 ) {
I would actually prefer to explicitly keep the switch and match on all implementations explicitly. Also, have you verified this works without CONFIG_PPC64 set? In cpu.h I see the following:
#if defined(TARGET_PPC64)
#define POWERPC_MMU_64 0x00010000
#define POWERPC_MMU_1TSEG 0x00020000
/* 64 bits PowerPC MMU */
POWERPC_MMU_64B = POWERPC_MMU_64 | 0x00000001,
/* 620 variant (no segment exceptions) */
POWERPC_MMU_620 = POWERPC_MMU_64 | 0x00000002,
/* Architecture 2.06 variant */
POWERPC_MMU_2_06 = POWERPC_MMU_64 | POWERPC_MMU_1TSEG | 0x00000003,#endif /* defined(TARGET_PPC64) */
So POWERPC_MMU_64B shouldn't be defined for qemu-system-ppc.
Alex
Re: [Qemu-devel] [PATCH 3/3] monitor: add ability to dump SLB entries
Good points below. I forgot to CC Nish, the original patch author on my post, so I've added him to the list now.
Nish, can you correct these problems and resend the patch please?
Quoted 87 lines · Alexander Graf
Quoted 24 lines · David Gibson
From: Nishanth Aravamudan <[email protected]>
When run with a PPC Book3S (server) CPU Currently 'info tlb' in the qemu monitor reports "
dump_mmu: unimplemented". However, during bringup work, it can be quite handy to have the SLB entries, which are available in the CPUPPCState. This patch adds an implementation of info tlb for book3s, which dumps the SLB.Signed-off-by Nishanth Aravamudan <[email protected]>Signed-off-by David Gibson <[email protected]>---
target-ppc/helper.c| 32 +++++++++++++++++++++++++++-----1 files changed, 27 insertions(+), 5 deletions(-)target-ppc/helper.c +2
-0@@ -1545,14 +1545,36 @@ static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, } } +static void mmubooks_dump_mmu (FILE *f,fprintf_function cpu_fprintf, +CPUState *env)target-ppc/helper.c static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, · line 1559
Quoted 10 lines
target-ppc/helper.c +10
-0+{ +int i; +uint64_t slbe, slbv; + +cpu_synchronize_state (env); + +cpu_fprintf (f,"SLB\tESID\t\t\tVSID\n" ); +for (i =0 ; i < env->slb_nr; i++) { + slbe = env->slb[i].esid; + slbv = env->slb[i].vsid;From
cpu.h:#if defined(TARGET_PPC64) /* Address space register */ target_ulong asr; /* PowerPC 64 SLB area */ ppc_slb_t slb[64]; int slb_nr;#endif
Quoted 9 lines
target-ppc/helper.c +8
-0+if (slbe ==0 && slbv ==0 ) { +continue ; + } +cpu_fprintf (f,"%d\t0x%016" PRIx64"\t0x%016" PRIx64"\n" , + i, slbe, slbv); + } +} +void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUState *env)target-ppc/helper.c static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, · line 1573
Quoted 10 lines
target-ppc/helper.c +3
-5{ -switch (env->mmu_model) { -case POWERPC_MMU_BOOKE206 : +if (env->mmu_model ==POWERPC_MMU_BOOKE206 ) {mmubooke206_dump_mmu (f, cpu_fprintf, env); -break ; -default : -cpu_fprintf (f,"%s: unimplemented\n" , __func__); + }else { +if ((env->mmu_model &POWERPC_MMU_64B ) !=0 ) {I would actually prefer to explicitly keep the switch and match on all implementations explicitly. Also, have you verified this works without
CONFIG_PPC64set? Incpu.hI see the following:#if
defined(TARGET_PPC64)
#definePOWERPC_MMU_640x00010000#define POWERPC_MMU_1TSEG 0x00020000 /* 64 bits PowerPC MMU */ POWERPC_MMU_64B = POWERPC_MMU_64 | 0x00000001, /* 620 variant (no segment exceptions) */ POWERPC_MMU_620 = POWERPC_MMU_64 | 0x00000002, /* Architecture 2.06 variant */ POWERPC_MMU_2_06 = POWERPC_MMU_64 | POWERPC_MMU_1TSEG | 0x00000003,#endif /*
defined(TARGET_PPC64)*/So
POWERPC_MMU_64Bshouldn't be defined for qemu-system-ppc.Alex
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
Re: [Qemu-devel] [PATCH 3/3] monitor: add ability to dump SLB entries
Quoted 4 lines · David Gibson
Good points below. I forgot to CC Nish, the original patch author on my post, so I've added him to the list now.
Nish, can you correct these problems and resend the patch please?
Yep, I'll work on this shortly.
Quoted 41 lines · Alexander Graf
Quoted 40 lines · David Gibson
Quoted 25 lines
From: Nishanth Aravamudan <[email protected]>
When run with a PPC Book3S (server) CPU Currently 'info tlb' in the qemu monitor reports "
dump_mmu: unimplemented". However, during bringup work, it can be quite handy to have the SLB entries, which are available in the CPUPPCState. This patch adds an implementation of info tlb for book3s, which dumps the SLB.Signed-off-by Nishanth Aravamudan <[email protected]>Signed-off-by David Gibson <[email protected]>---
target-ppc/helper.c| 32 +++++++++++++++++++++++++++-----1 files changed, 27 insertions(+), 5 deletions(-)target-ppc/helper.c +2
-0@@ -1545,14 +1545,36 @@ static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, } } +static void mmubooks_dump_mmu (FILE *f,fprintf_function cpu_fprintf, +CPUState *env)target-ppc/helper.c static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, · line 1559
Quoted 10 lines
target-ppc/helper.c +10
-0+{ +int i; +uint64_t slbe, slbv; + +cpu_synchronize_state (env); + +cpu_fprintf (f,"SLB\tESID\t\t\tVSID\n" ); +for (i =0 ; i < env->slb_nr; i++) { + slbe = env->slb[i].esid; + slbv = env->slb[i].vsid;From
cpu.h:
Quoted 7 lines
Quoted 7 lines
#if defined(TARGET_PPC64) /* Address space register */ target_ulong asr; /* PowerPC 64 SLB area */ ppc_slb_t slb[64]; int slb_nr;#endif
Being unfamiliar with qemu's coding style (and not immediately seeing it in CODING_STYLE), would the right approach be to wrap this definition in an #if defined(TARGET_PPC64)?
Quoted 35 lines
Quoted 35 lines
Quoted 9 lines
target-ppc/helper.c +8
-0+if (slbe ==0 && slbv ==0 ) { +continue ; + } +cpu_fprintf (f,"%d\t0x%016" PRIx64"\t0x%016" PRIx64"\n" , + i, slbe, slbv); + } +} +void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUState *env)target-ppc/helper.c static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, · line 1573
Quoted 10 lines
target-ppc/helper.c +3
-5{ -switch (env->mmu_model) { -case POWERPC_MMU_BOOKE206 : +if (env->mmu_model ==POWERPC_MMU_BOOKE206 ) {mmubooke206_dump_mmu (f, cpu_fprintf, env); -break ; -default : -cpu_fprintf (f,"%s: unimplemented\n" , __func__); + }else { +if ((env->mmu_model &POWERPC_MMU_64B ) !=0 ) {I would actually prefer to explicitly keep the switch and match on all implementations explicitly. Also, have you verified this works without
CONFIG_PPC64set? Incpu.hI see the following:#if
defined(TARGET_PPC64)
#definePOWERPC_MMU_640x00010000#define POWERPC_MMU_1TSEG 0x00020000 /* 64 bits PowerPC MMU */ POWERPC_MMU_64B = POWERPC_MMU_64 | 0x00000001, /* 620 variant (no segment exceptions) */ POWERPC_MMU_620 = POWERPC_MMU_64 | 0x00000002, /* Architecture 2.06 variant */ POWERPC_MMU_2_06 = POWERPC_MMU_64 | POWERPC_MMU_1TSEG | 0x00000003,#endif /*
defined(TARGET_PPC64)*/
Quoted 1 line
Quoted 1 line
So
POWERPC_MMU_64Bshouldn't be defined for qemu-system-ppc.
And similarly here, only have the MMU_2_06 and MMU_64B cases in the switch be defined #if defined(TARGET_PPC64)?
Basically, asking if #ifdefs in the middle of functions are ok :)
Thanks,
Nish
Signature · 2 lines
Nishanth Aravamudan <[email protected]> IBM Linux Technology Center
Re: [Qemu-devel] [PATCH 3/3] monitor: add ability to dump SLB entries
Quoted 57 lines · Nishanth Aravamudan
Quoted 4 lines · David Gibson
Good points below. I forgot to CC Nish, the original patch author on my post, so I've added him to the list now.
Nish, can you correct these problems and resend the patch please?
Yep, I'll work on this shortly.
Quoted 41 lines · Alexander Graf
Quoted 40 lines · David Gibson
Quoted 25 lines
From: Nishanth Aravamudan <[email protected]>
When run with a PPC Book3S (server) CPU Currently 'info tlb' in the qemu monitor reports "
dump_mmu: unimplemented". However, during bringup work, it can be quite handy to have the SLB entries, which are available in the CPUPPCState. This patch adds an implementation of info tlb for book3s, which dumps the SLB.Signed-off-by Nishanth Aravamudan <[email protected]>Signed-off-by David Gibson <[email protected]>---
target-ppc/helper.c| 32 +++++++++++++++++++++++++++-----1 files changed, 27 insertions(+), 5 deletions(-)target-ppc/helper.c +2
-0@@ -1545,14 +1545,36 @@ static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, } } +static void mmubooks_dump_mmu (FILE *f,fprintf_function cpu_fprintf, +CPUState *env)target-ppc/helper.c static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, · line 1559
Quoted 10 lines
target-ppc/helper.c +10
-0+{ +int i; +uint64_t slbe, slbv; + +cpu_synchronize_state (env); + +cpu_fprintf (f,"SLB\tESID\t\t\tVSID\n" ); +for (i =0 ; i < env->slb_nr; i++) { + slbe = env->slb[i].esid; + slbv = env->slb[i].vsid;From
cpu.h:Quoted 7 lines
Quoted 7 lines
#if defined(TARGET_PPC64) /* Address space register */ target_ulong asr; /* PowerPC 64 SLB area */ ppc_slb_t slb[64]; int slb_nr;#endif
Quoted 3 lines
Being unfamiliar with qemu's coding style (and not immediately seeing it in
CODING_STYLE), would the right approach be to wrap this definition in an #ifdefined(TARGET_PPC64)?
It's the only way to make it compile :)
Quoted 36 lines
Quoted 36 lines
Quoted 36 lines
Quoted 10 lines
target-ppc/helper.c +8
-0+if (slbe ==0 && slbv ==0 ) { +continue ; + } +cpu_fprintf (f,"%d\t0x%016" PRIx64"\t0x%016" PRIx64"\n" , + i, slbe, slbv); + } +} +void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUState *env)target-ppc/helper.c static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, · line 1573
Quoted 10 lines
target-ppc/helper.c +3
-5{ -switch (env->mmu_model) { -case POWERPC_MMU_BOOKE206 : +if (env->mmu_model ==POWERPC_MMU_BOOKE206 ) {mmubooke206_dump_mmu (f, cpu_fprintf, env); -break ; -default : -cpu_fprintf (f,"%s: unimplemented\n" , __func__); + }else { +if ((env->mmu_model &POWERPC_MMU_64B ) !=0 ) {I would actually prefer to explicitly keep the switch and match on all implementations explicitly. Also, have you verified this works without
CONFIG_PPC64set? Incpu.hI see the following:#if
defined(TARGET_PPC64)
#definePOWERPC_MMU_640x00010000#define POWERPC_MMU_1TSEG 0x00020000 /* 64 bits PowerPC MMU */ POWERPC_MMU_64B = POWERPC_MMU_64 | 0x00000001, /* 620 variant (no segment exceptions) */ POWERPC_MMU_620 = POWERPC_MMU_64 | 0x00000002, /* Architecture 2.06 variant */ POWERPC_MMU_2_06 = POWERPC_MMU_64 | POWERPC_MMU_1TSEG | 0x00000003,#endif /*
defined(TARGET_PPC64)*/
Quoted 4 lines
Quoted 1 line
Quoted 1 line
So
POWERPC_MMU_64Bshouldn't be defined for qemu-system-ppc.And similarly here, only have the
MMU_2_06andMMU_64Bcases in the switch be defined #ifdefined(TARGET_PPC64)?
Yup :).
Quoted 1 line
Basically, asking if #ifdefs in the middle of functions are ok :)
It's the only valid way of making it work, yes. The alternative would be to drop all the TARGET_PPC64 ifdefery, but let's keep that for later.
Alex
Re: [Qemu-devel] [PATCH 3/3] monitor: add ability to dump SLB entries
Quoted 107 lines · Alexander Graf
Quoted 57 lines · Nishanth Aravamudan
Quoted 4 lines · David Gibson
Good points below. I forgot to CC Nish, the original patch author on my post, so I've added him to the list now.
Nish, can you correct these problems and resend the patch please?
Yep, I'll work on this shortly.
Quoted 41 lines · Alexander Graf
Quoted 40 lines · David Gibson
Quoted 25 lines
From: Nishanth Aravamudan <[email protected]>
When run with a PPC Book3S (server) CPU Currently 'info tlb' in the qemu monitor reports "
dump_mmu: unimplemented". However, during bringup work, it can be quite handy to have the SLB entries, which are available in the CPUPPCState. This patch adds an implementation of info tlb for book3s, which dumps the SLB.Signed-off-by Nishanth Aravamudan <[email protected]>Signed-off-by David Gibson <[email protected]>---
target-ppc/helper.c| 32 +++++++++++++++++++++++++++-----1 files changed, 27 insertions(+), 5 deletions(-)target-ppc/helper.c +2
-0@@ -1545,14 +1545,36 @@ static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, } } +static void mmubooks_dump_mmu (FILE *f,fprintf_function cpu_fprintf, +CPUState *env)target-ppc/helper.c static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, · line 1559
Quoted 10 lines
target-ppc/helper.c +10
-0+{ +int i; +uint64_t slbe, slbv; + +cpu_synchronize_state (env); + +cpu_fprintf (f,"SLB\tESID\t\t\tVSID\n" ); +for (i =0 ; i < env->slb_nr; i++) { + slbe = env->slb[i].esid; + slbv = env->slb[i].vsid;From
cpu.h:Quoted 7 lines
Quoted 7 lines
#if defined(TARGET_PPC64) /* Address space register */ target_ulong asr; /* PowerPC 64 SLB area */ ppc_slb_t slb[64]; int slb_nr;#endif
Quoted 3 lines
Being unfamiliar with qemu's coding style (and not immediately seeing it in
CODING_STYLE), would the right approach be to wrap this definition in an #ifdefined(TARGET_PPC64)?It's the only way to make it compile :)
Quoted 36 lines
Quoted 36 lines
Quoted 36 lines
Quoted 10 lines
target-ppc/helper.c +8
-0+if (slbe ==0 && slbv ==0 ) { +continue ; + } +cpu_fprintf (f,"%d\t0x%016" PRIx64"\t0x%016" PRIx64"\n" , + i, slbe, slbv); + } +} +void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUState *env)target-ppc/helper.c static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, · line 1573
Quoted 10 lines
target-ppc/helper.c +3
-5{ -switch (env->mmu_model) { -case POWERPC_MMU_BOOKE206 : +if (env->mmu_model ==POWERPC_MMU_BOOKE206 ) {mmubooke206_dump_mmu (f, cpu_fprintf, env); -break ; -default : -cpu_fprintf (f,"%s: unimplemented\n" , __func__); + }else { +if ((env->mmu_model &POWERPC_MMU_64B ) !=0 ) {I would actually prefer to explicitly keep the switch and match on all implementations explicitly. Also, have you verified this works without
CONFIG_PPC64set? Incpu.hI see the following:#if
defined(TARGET_PPC64)
#definePOWERPC_MMU_640x00010000#define POWERPC_MMU_1TSEG 0x00020000 /* 64 bits PowerPC MMU */ POWERPC_MMU_64B = POWERPC_MMU_64 | 0x00000001, /* 620 variant (no segment exceptions) */ POWERPC_MMU_620 = POWERPC_MMU_64 | 0x00000002, /* Architecture 2.06 variant */ POWERPC_MMU_2_06 = POWERPC_MMU_64 | POWERPC_MMU_1TSEG | 0x00000003,#endif /*
defined(TARGET_PPC64)*/Quoted 4 lines
Quoted 1 line
Quoted 1 line
So
POWERPC_MMU_64Bshouldn't be defined for qemu-system-ppc.And similarly here, only have the
MMU_2_06andMMU_64Bcases in the switch be defined #ifdefined(TARGET_PPC64)?
Quoted 7 lines
Yup :).
Quoted 1 line
Basically, asking if #ifdefs in the middle of functions are ok :)
It's the only valid way of making it work, yes. The alternative would be to drop all the
TARGET_PPC64ifdefery, but let's keep that for later.
Great, thanks for the confirmation.
-Nish
Signature · 2 lines
Nishanth Aravamudan <[email protected]> IBM Linux Technology Center
PATCH v2 1/1 monitor: add ability to dump SLB entries
In reply to David GibsonQuoted 4 lines · David Gibson
Good points below. I forgot to CC Nish, the original patch author on my post, so I've added him to the list now.
Nish, can you correct these problems and resend the patch please?
When run with a PPC Book3S (server) CPU Currently 'info tlb' in the qemu monitor reports "dump_mmu: unimplemented". However, during bringup work, it can be quite handy to have the SLB entries, which are available in the CPUPPCState. This patch adds an implementation of info tlb for book3s, which dumps the SLB.
---
v2: Update to build on PPC and PPC64 via suggestion from AGraf.
target-ppc/helper.c +28 -0
@@ -1545,12 +1545,40 @@ static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, } } +#if defined(TARGET_PPC64 ) +static void mmubooks_dump_mmu (FILE *f,fprintf_function cpu_fprintf, +CPUState *env) +{ +int i; +uint64_t slbe, slbv; + +cpu_synchronize_state (env); + +cpu_fprintf (f,"SLB\tESID\t\t\tVSID\n" ); +for (i =0 ; i < env->slb_nr; i++) { + slbe = env->slb[i].esid; + slbv = env->slb[i].vsid; +if (slbe ==0 && slbv ==0 ) { +continue ; + } +cpu_fprintf (f,"%d\t0x%016" PRIx64"\t0x%016" PRIx64"\n" , + i, slbe, slbv); + } +} +#endif +void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUState *env) {switch (env->mmu_model) {case POWERPC_MMU_BOOKE206 :mmubooke206_dump_mmu (f, cpu_fprintf, env);break ; +#if defined(TARGET_PPC64 ) +case POWERPC_MMU_64B : +case POWERPC_MMU_2_06 : +mmubooks_dump_mmu (f, cpu_fprintf, env); +break ; +#endif default :cpu_fprintf (f,"%s: unimplemented\n" , __func__); }
Signature · 2 lines
Nishanth Aravamudan <[email protected]> IBM Linux Technology Center
Alexander Graf
AppliedRe: [Qemu-devel] [PATCH v2] monitor: add ability to dump SLB entries
Quoted 5 lines · Nishanth Aravamudan
Quoted 4 lines · David Gibson
Good points below. I forgot to CC Nish, the original patch author on my post, so I've added him to the list now.
Nish, can you correct these problems and resend the patch please?
Quoted 8 lines
When run with a PPC Book3S (server) CPU Currently 'info tlb' in the qemu monitor reports "
dump_mmu: unimplemented". However, during bringup work, it can be quite handy to have the SLB entries, which are available in the CPUPPCState. This patch adds an implementation of info tlb for book3s, which dumps the SLB.Signed-off-by Nishanth Aravamudan<[email protected]>Signed-off-by David Gibson<[email protected]>
Thanks, applied to ppc-next.
Alex
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2] monitor: add ability to dump SLB entries
Quoted 12 lines · Alexander Graf
Quoted 11 lines · Nishanth Aravamudan
Quoted 4 lines · David Gibson
Good points below. I forgot to CC Nish, the original patch author on my post, so I've added him to the list now.
Nish, can you correct these problems and resend the patch please?
When run with a PPC Book3S (server) CPU Currently 'info tlb' in the qemu monitor reports "
dump_mmu: unimplemented". However, during bringup work, it can be quite handy to have the SLB entries, which are available in the CPUPPCState. This patch adds an implementation of info tlb for book3s, which dumps the SLB.
Quoted 4 lines
Quoted 2 lines
Signed-off-by Nishanth Aravamudan<[email protected]>Signed-off-by David Gibson<[email protected]>Thanks, applied to ppc-next.
I'm guessing that ppc-next is now the branch destined for post 1.0. Is that right?
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
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2] monitor: add ability to dump SLB entries
Quoted 13 lines · David Gibson
Quoted 12 lines · Alexander Graf
Quoted 11 lines · Nishanth Aravamudan
Quoted 4 lines · David Gibson
Good points below. I forgot to CC Nish, the original patch author on my post, so I've added him to the list now.
Nish, can you correct these problems and resend the patch please?
When run with a PPC Book3S (server) CPU Currently 'info tlb' in the qemu monitor reports "
dump_mmu: unimplemented". However, during bringup work, it can be quite handy to have the SLB entries, which are available in the CPUPPCState. This patch adds an implementation of info tlb for book3s, which dumps the SLB.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Nishanth Aravamudan<[email protected]>Signed-off-by David Gibson<[email protected]>Thanks, applied to ppc-next.
I'm guessing that ppc-next is now the branch destined for post 1.0. Is that right?
Yes :). Please mark 1.0 patches as such so I can cherry-pick them there.
Alex
Quoted 7 lines
Signature · 5 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