PPC: e5500 emulation
v2 cover PPC: e5500 emulation
This patch set adds support to emulate an e5500 based virtual machine. We don't have a machine model for that one yet, but with this patch set applied we can fake the compatibility property of the MPC8544DS model into P5020DS, which gets guest kernels working for me.
The patch set is based on my recent dynamic device tree work. For a ready to use git tree, please check here:
git://repo.or.cz/qemu/agraf.git ppc-e5500
To use the code, grab yourself an e5500 kernel and run:
$ qemu-system-ppc64 -M mpc8544ds -cpu e5500 -nographic -kernel uImage \
-machine dt_compatible=fsl,,P5020DSThis should get you a working kernel. Everything after that works just the same as with e500v2 or e500mc.
v1 -> v2:
- remove reset msr vector
- clean up ivpr_mask code
- make MAS2 64bit aware
Alex
Alexander Graf (11):
dt: make setprop argument static
PPC: e500: allow users to set the /compatible property via -machine
uImage: increase the gzip load size
PPC: Add some booke SPR defines
PPC: Add support for MSR_CM
PPC: BookE: Implement EPR SPR
PPC: BookE: Make ivpr selectable by CPU type
PPC: Add e5500 CPU target
PPC: Extract SPR dump generation into its own function
PPC: BookE: Support 32 and 64 bit wide MAS2
PPC: BookE206: Bump MAS2 to 64bit
device_tree.c | 2 +- device_tree.h | 2 +- hw/loader.c | 4 +- hw/ppce500_mpc8544ds.c | 13 +++- qemu-config.c | 4 + target-ppc/Makefile.objs | 1 + target-ppc/cpu.h | 34 +++++++++- target-ppc/excp_helper.c | 9 ++- target-ppc/helper.h | 1 + target-ppc/mem_helper.c | 2 +- target-ppc/mpic_helper.c | 35 ++++++++++ target-ppc/translate.c | 2 +- target-ppc/translate_init.c | 154 +++++++++++++++++++++++++++++++++++++------ 13 files changed, 229 insertions(+), 34 deletions(-) create mode 100644 target-ppc/mpic_helper.c
PATCH v2 1/11 dt: make setprop argument static
Whatever we pass in to qemu_devtree_setprop to put into the device tree will not get modified by that function, so it can easily be declared const.
--- device_tree.c | 2 +- device_tree.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
device_tree.c +1 -1
@@ -127,7 +127,7 @@ static int findnode_nofail(void *fdt, const char *node_path) }int qemu_devtree_setprop (void *fdt,const char *node_path, -const char *property,void *val_array,int size) +const char *property,const void *val_array,int size) {int r;
device_tree.h +1 -1
@@ -18,7 +18,7 @@ void *create_device_tree(int *sizep);void *load_device_tree (const char *filename_path,int *sizep);int qemu_devtree_setprop (void *fdt,const char *node_path, -const char *property,void *val_array,int size); +const char *property,const void *val_array,int size);int qemu_devtree_setprop_cell (void *fdt,const char *node_path,const char *property,uint32_t val); int qemu_devtree_setprop_u64(void *fdt, const char *node_path,
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v2 01/11] dt: make setprop argument static
Quoted 4 lines · Alexander Graf
Whatever we pass in to
qemu_devtree_setpropto put into the device tree will not get modified by that function, so it can easily be declared const.Signed-off-by Alexander Graf <[email protected]>
Quoted 35 lines
---
device_tree.c | 2 +-
device_tree.h | 2 +-2 files changed, 2 insertions(+), 2 deletions(-)device_tree.c +1
-1@@ -127,7 +127,7 @@ static int findnode_nofail(void *fdt, const char *node_path) } int qemu_devtree_setprop(void *fdt, const char *node_path, - const char *property, void *val_array, int size) + const char *property, const void *val_array, int size) { int r;device_tree.h +1
-2@@ -18,7 +18,7 @@ void *create_device_tree(int *sizep); void *load_device_tree(const char *filename_path, int *sizep); int qemu_devtree_setprop(void *fdt, const char *node_path, - const char *property, void *val_array, int size); + const char *property, const void *val_array, int size); int qemu_devtree_setprop_cell(void *fdt, const char *node_path, const char *property, uint32_t val); int qemu_devtree_setprop_u64(void *fdt, const char *node_path, --1.6.0.2
PATCH v2 2/11 PPC: e500: allow users to set the /compatible property via -machine
In reply to Alexander GrafDevice trees usually have a node /compatible, which indicate which machine type we're looking at. For quick prototyping, it can be very useful to change the contents of that node via the command line.
Thus, introduce a new option to -machine called dt_compatible, which when set changes the /compatible contents to its value.
--- hw/ppce500_mpc8544ds.c | 12 +++++++++--- qemu-config.c | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-)
hw/ppce500_mpc8544ds.c +9 -3
@@ -119,7 +119,8 @@ static int mpc8544_load_device_tree(CPUPPCState *env,uint32_t clock_freq =400000000 ;uint32_t tb_freq =400000000 ;int i; -char compatible[] ="MPC8544DS\0MPC85xxDS" ; +const char *compatible ="MPC8544DS\0MPC85xxDS" ; +int compatible_len =sizeof ("MPC8544DS\0MPC85xxDS" );char compatible_sb[] ="fsl,mpc8544-immr\0simple-bus" ;char model[] ="MPC8544DS" ;char soc[128 ];
@@ -144,8 +145,14 @@ static int mpc8544_load_device_tree(CPUPPCState *env, machine_opts =qemu_opts_find (qemu_find_opts ("machine" ),0 );if (machine_opts) { +const char *tmp; dumpdtb =qemu_opt_get (machine_opts,"dumpdtb" ); dtb_file =qemu_opt_get (machine_opts,"dtb" ); + tmp =qemu_opt_get (machine_opts,"dt_compatible" ); +if (tmp) { + compatible = tmp; + compatible_len =strlen (compatible) +1 ; + } }if (dtb_file) {
@@ -169,8 +176,7 @@ static int mpc8544_load_device_tree(CPUPPCState *env,/* Manipulate device tree in memory. */ qemu_devtree_setprop_string (fdt,"/" ,"model" , model); -qemu_devtree_setprop (fdt,"/" ,"compatible" , compatible, -sizeof (compatible)); +qemu_devtree_setprop (fdt,"/" ,"compatible" , compatible, compatible_len);qemu_devtree_setprop_cell (fdt,"/" ,"#address-cells" ,2 );qemu_devtree_setprop_cell (fdt,"/" ,"#size-cells" ,2 );
qemu-config.c +4 -0
@@ -591,6 +591,10 @@ static QemuOptsList qemu_machine_opts = { .name = "phandle_start", .type = QEMU_OPT_STRING, .help = "The first phandle ID we may generate dynamically", + }, { + .name = "dt_compatible", + .type = QEMU_OPT_STRING, + .help = "Overrides the \"compatible\" property of the dt root node", }, {/* End of list */ } },
Signature · 1 line
1.6.0.2
PATCH v2 3/11 uImage: increase the gzip load size
In reply to Alexander GrafRecent u-boot has different defines for its gzip extract buffer, but the common ground seems to be 64MB. So let's bump it up to that, enabling me to load my test image again ;).
--- hw/loader.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
hw/loader.c +2 -2
@@ -377,9 +377,9 @@ static void zfree(void *x, void *addr)#define DEFLATED 8 -/* This is the maximum in uboot, so if a uImage overflows this, it would +/* This is the usual maximum in uboot, so if a uImage overflows this, it would * overflow on real hardware too. */ -#define UBOOT_MAX_GUNZIP_BYTES 0x800000 +#define UBOOT_MAX_GUNZIP_BYTES (64 << 20)static ssize_t gunzip (void *dst,size_t dstlen,uint8_t *src,size_t srclen)
Signature · 1 line
1.6.0.2
PATCH v2 4/11 PPC: Add some booke SPR defines
In reply to Alexander GrafThe number of SPRs avaiable in different PowerPC chip is still increasing. Add definitions for the MAS7_MAS3 SPR and all currently known bits in EPCR.
--- target-ppc/cpu.h | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-)
target-ppc/cpu.h +22 -0
@@ -1395,6 +1395,7 @@ static inline void cpu_clone_regs(CPUPPCState *env, target_ulong newsp)#define SPR_BOOKE_TLB1PS (0x159)#define SPR_BOOKE_TLB2PS (0x15A)#define SPR_BOOKE_TLB3PS (0x15B) +#define SPR_BOOKE_MAS7_MAS3 (0x174)#define SPR_BOOKE_IVOR0 (0x190)#define SPR_BOOKE_IVOR1 (0x191)#define SPR_BOOKE_IVOR2 (0x192)
@@ -1762,6 +1763,27 @@ static inline void cpu_clone_regs(CPUPPCState *env, target_ulong newsp)#define SPR_604_HID15 (0x3FF)#define SPR_E500_SVR (0x3FF) +/* Disable MAS Interrupt Updates for Hypervisor */ +#define EPCR_DMIUH (1 << 22) +/* Disable Guest TLB Management Instructions */ +#define EPCR_DGTMI (1 << 23) +/* Guest Interrupt Computation Mode */ +#define EPCR_GICM (1 << 24) +/* Interrupt Computation Mode */ +#define EPCR_ICM (1 << 25) +/* Disable Embedded Hypervisor Debug */ +#define EPCR_DUVD (1 << 26) +/* Instruction Storage Interrupt Directed to Guest State */ +#define EPCR_ISIGS (1 << 27) +/* Data Storage Interrupt Directed to Guest State */ +#define EPCR_DSIGS (1 << 28) +/* Instruction TLB Error Interrupt Directed to Guest State */ +#define EPCR_ITLBGS (1 << 29) +/* Data TLB Error Interrupt Directed to Guest State */ +#define EPCR_DTLBGS (1 << 30) +/* External Input Interrupt Directed to Guest State */ +#define EPCR_EXTGS (1 << 31) +/*****************************************************************************/ /* PowerPC Instructions types definitions */ enum {
Signature · 1 line
1.6.0.2
PATCH v2 5/11 PPC: Add support for MSR_CM
In reply to Alexander GrafThe BookE variant of MSR_SF is MSR_CM. Implement everything it takes in TCG to support running 64bit code with MSR_CM set.
--- target-ppc/cpu.h | 9 +++++++++ target-ppc/excp_helper.c | 9 +++++---- target-ppc/mem_helper.c | 2 +- target-ppc/translate.c | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-)
target-ppc/cpu.h +9 -0
@@ -2212,6 +2212,15 @@ static inline uint32_t booke206_tlbnps(CPUPPCState *env, const int tlbn)#endif +static inline bool msr_is_64bit (CPUPPCState *env,target_ulong msr) +{ +if (env->mmu_model ==POWERPC_MMU_BOOKE206 ) { +return msr & (1ULL <<MSR_CM ); + } + +return msr & (1ULL <<MSR_SF ); +} +extern void (*cpu_ppc_hypercall)(CPUPPCState *);static inline bool cpu_has_work (CPUPPCState *env)
target-ppc/excp_helper.c +5 -4
@@ -608,10 +608,11 @@ static inline void powerpc_excp(CPUPPCState *env, int excp_model, int excp) vector |= env->excp_prefix;#if defined(TARGET_PPC64 )if (excp_model ==POWERPC_EXCP_BOOKE ) { -if (!msr_icm) { - vector = (uint32_t )vector; - }else { +if (env->spr[SPR_BOOKE_EPCR ] &EPCR_ICM ) { +/* Cat.64-bit: EPCR.ICM is copied to MSR.CM */ new_msr |= (target_ulong )1 <<MSR_CM ; + }else { + vector = (uint32_t )vector; } }else {if (!msr_isf && !(env->mmu_model &POWERPC_MMU_64 )) {
@@ -803,7 +804,7 @@ static inline void do_rfi(CPUPPCState *env, target_ulong nip, target_ulong msr, target_ulong msrm, int keep_msrh) {#if defined(TARGET_PPC64 ) -if (msr & (1ULL <<MSR_SF )) { +if (msr_is_64bit (env, msr)) { nip = (uint64_t )nip; msr &= (uint64_t )msrm; }else {
target-ppc/mem_helper.c +1 -1
@@ -35,7 +35,7 @@ static inline target_ulong addr_add(CPUPPCState *env, target_ulong addr, target_long arg) {#if defined(TARGET_PPC64 ) -if (!msr_sf) { +if (!msr_is_64bit (env, env->msr)) {return (uint32_t )(addr + arg); } else#endif
target-ppc/translate.c +1 -1
@@ -9626,7 +9626,7 @@ static inline void gen_intermediate_code_internal(CPUPPCState *env, ctx.access_type =-1 ; ctx.le_mode = env->hflags & (1 <<MSR_LE ) ?1 :0 ;#if defined(TARGET_PPC64 ) - ctx.sf_mode = msr_sf; + ctx.sf_mode =msr_is_64bit (env, env->msr); ctx.has_cfar = !!(env->flags &POWERPC_FLAG_CFAR );#endif ctx.fpu_enabled = msr_fp;
Signature · 1 line
1.6.0.2
PATCH v2 6/11 PPC: BookE: Implement EPR SPR
In reply to Alexander GrafOn the e500 series, accessing SPR_EPR magically turns into an access at that CPU's IACK register on the MPIC. Implement that logic to get kernels that make use of that feature work.
--- hw/ppce500_mpc8544ds.c | 1 + target-ppc/Makefile.objs | 1 + target-ppc/cpu.h | 1 + target-ppc/helper.h | 1 + target-ppc/mpic_helper.c | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 39 insertions(+), 0 deletions(-) create mode 100644 target-ppc/mpic_helper.c
hw/ppce500_mpc8544ds.c +1 -0
@@ -469,6 +469,7 @@ static void mpc8544ds_init(ram_addr_t ram_size, irqs[i][OPENPIC_OUTPUT_INT ] = input[PPCE500_INPUT_INT ]; irqs[i][OPENPIC_OUTPUT_CINT ] = input[PPCE500_INPUT_CINT ]; env->spr[SPR_BOOKE_PIR ] = env->cpu_index = i; + env->mpic_cpu_base =MPC8544_MPIC_REGS_BASE +0x20000 ;ppc_booke_timers_init (env,400000000 ,PPC_TIMER_E500 );
target-ppc/Makefile.objs +1 -0
@@ -9,3 +9,4 @@ obj-y += mmu_helper.o obj-y += timebase_helper.o obj-y += misc_helper.o obj-y += mem_helper.o +obj-y += mpic_helper.o
target-ppc/cpu.h +1 -0
@@ -1066,6 +1066,7 @@ struct CPUPPCState {target_ulong ivor_mask;target_ulong ivpr_mask;target_ulong hreset_vector; +target_phys_addr_t mpic_cpu_base;#endif /* Those resources are used only during code translation */
target-ppc/helper.h +1 -0
@@ -405,6 +405,7 @@ DEF_HELPER_2(store_40x_dbcr0, void, env, tl) DEF_HELPER_2(store_40x_sler, void, env, tl) DEF_HELPER_2(store_booke_tcr, void, env, tl) DEF_HELPER_2(store_booke_tsr, void, env, tl) +DEF_HELPER_1(load_epr, tl, env) DEF_HELPER_3(store_ibatl, void, env, i32, tl) DEF_HELPER_3(store_ibatu, void, env, i32, tl)DEF_HELPER_3 (store_dbatl, void, env, i32, tl)
target-ppc/mpic_helper.c new file +35 -0
@@ -0,0 +1,35 @@ +/* +* PowerPC emulation helpers for QEMU. +* +* Copyright (c) 2003-2007 Jocelyn Mayer +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* 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/>. +*/ +#include "cpu.h" +#include "helper.h" + +/*****************************************************************************/ +/* SPR accesses */ + +#if !defined(CONFIG_USER_ONLY ) +/* +* This is an ugly helper for EPR, which is basically the same as accessing +* the IACK (PIAC) register on the MPIC. Because we model the MPIC as a device +* that can only talk to the CPU through MMIO, let's access it that way! +*/ +target_ulong helper_load_epr (CPUPPCState *env) +{ +return ldl_phys (env->mpic_cpu_base +0xA0 ); +} +#endif
Signature · 1 line
1.6.0.2
PATCH v2 7/11 PPC: BookE: Make ivpr selectable by CPU type
In reply to Alexander GrafIVPR can either hold 32 or 64 bit addresses, depending on the CPU type. Let the CPU initialization function pass in its mask itself, so we can easily extend it.
--- target-ppc/translate_init.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
target-ppc/translate_init.c +5 -4
@@ -2804,7 +2804,7 @@ static void init_excp_G2 (CPUPPCState *env)#endif } -static void init_excp_e200 (CPUPPCState *env) +static void init_excp_e200 (CPUPPCState *env,target_ulong ivpr_mask) {#if !defined(CONFIG_USER_ONLY ) env->excp_vectors[POWERPC_EXCP_RESET ] =0x00000FFC ;
@@ -2829,7 +2829,7 @@ static void init_excp_e200 (CPUPPCState *env) env->excp_vectors[POWERPC_EXCP_EFPRI ] =0x00000000 ; env->hreset_excp_prefix =0x00000000UL ; env->ivor_mask =0x0000FFF7UL ; - env->ivpr_mask =0xFFFF0000UL ; + env->ivpr_mask = ivpr_mask;/* Hardware reset vector */ env->hreset_vector =0xFFFFFFFCUL ;#endif
@@ -4307,7 +4307,7 @@ static void init_proc_e200 (CPUPPCState *env) env->id_tlbs =0 ; env->tlb_type =TLB_EMB ;#endif -init_excp_e200 (env); +init_excp_e200 (env,0xFFFF0000UL ); env->dcache_line_size =32 ; env->icache_line_size =32 ;/* XXX: TODO: allocate internal IRQ controller */
@@ -4434,6 +4434,7 @@ static void init_proc_e500 (CPUPPCState *env, int version) {uint32_t tlbncfg[2 ];uint64_t ivor_mask =0x0000000F0000FFFFULL ; +uint64_t ivpr_mask =0xFFFF0000ULL ;uint32_t l1cfg0 =0x3800 /* 8 ways */ |0x0020 ;/* 32 kb */ #if !defined(CONFIG_USER_ONLY )
@@ -4575,7 +4576,7 @@ static void init_proc_e500 (CPUPPCState *env, int version) }#endif -init_excp_e200 (env); +init_excp_e200 (env, ivpr_mask);/* Allocate hardware IRQ controller */ ppce500_irq_init (env); }
Signature · 1 line
1.6.0.2
PATCH v2 8/11 PPC: Add e5500 CPU target
In reply to Alexander GrafThis patch adds e5500's CPU initialization to the TCG CPU initialization code.
---
v1 -> v2:
- remove reset msr vector
- clean up ivpr_mask code
--- target-ppc/translate_init.c | 96 +++++++++++++++++++++++++++++++++++++++++- 1 files changed, 93 insertions(+), 3 deletions(-)
target-ppc/translate_init.c +93 -3
@@ -4424,16 +4424,69 @@ static void init_proc_e300 (CPUPPCState *env)#define check_pow_e500mc check_pow_none#define init_proc_e500mc init_proc_e500mc +/* e5500 core */ +#define POWERPC_INSNS_e5500 (PPC_INSNS_BASE | PPC_ISEL | \ + PPC_WRTEE | PPC_RFDI | PPC_RFMCI | \ + PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | \ + PPC_CACHE_DCBZ | PPC_CACHE_DCBA | \ + PPC_FLOAT | PPC_FLOAT_FRES | \ + PPC_FLOAT_FRSQRTE | PPC_FLOAT_FSEL | \ + PPC_FLOAT_STFIWX | PPC_WAIT | \ + PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC | \ + PPC_64B | PPC_POPCNTB | PPC_POPCNTWD) +#define POWERPC_INSNS2_e5500 (PPC2_BOOKE206 | PPC2_PRCNTL) +#define POWERPC_MSRM_e5500 (0x000000009402FB36ULL) +#define POWERPC_MMU_e5500 (POWERPC_MMU_BOOKE206) +#define POWERPC_EXCP_e5500 (POWERPC_EXCP_BOOKE) +#define POWERPC_INPUT_e5500 (PPC_FLAGS_INPUT_BookE) +/* Fixme: figure out the correct flag for e5500 */ +#define POWERPC_BFDM_e5500 (bfd_mach_ppc_e500) +#define POWERPC_FLAG_e5500 (POWERPC_FLAG_CE | POWERPC_FLAG_DE | \ + POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK) +#define check_pow_e5500 check_pow_none +#define init_proc_e5500 init_proc_e5500 + +#if !defined(CONFIG_USER_ONLY ) +static void spr_write_mas73 (void *opaque,int sprn,int gprn) +{ +TCGv val =tcg_temp_new (); +tcg_gen_ext32u_tl (val, cpu_gpr[gprn]); +gen_store_spr (SPR_BOOKE_MAS3 , val); +tcg_gen_shri_tl (val, gprn,32 ); +gen_store_spr (SPR_BOOKE_MAS7 , val); +tcg_temp_free (val); +} + +static void spr_read_mas73 (void *opaque,int gprn,int sprn) +{ +TCGv mas7 =tcg_temp_new (); +TCGv mas3 =tcg_temp_new (); +gen_load_spr (mas7,SPR_BOOKE_MAS7 ); +tcg_gen_shli_tl (mas7, mas7,32 ); +gen_load_spr (mas3,SPR_BOOKE_MAS3 ); +tcg_gen_or_tl (cpu_gpr[gprn], mas3, mas7); +tcg_temp_free (mas3); +tcg_temp_free (mas7); +} + +static void spr_load_epr (void *opaque,int gprn,int sprn) +{ +gen_helper_load_epr (cpu_gpr[gprn], cpu_env); +} + +#endif +enum fsl_e500_version { fsl_e500v1, fsl_e500v2, fsl_e500mc, + fsl_e5500, };static void init_proc_e500 (CPUPPCState *env,int version) {uint32_t tlbncfg[2 ]; -uint64_t ivor_mask =0x0000000F0000FFFFULL ; +uint64_t ivor_mask;uint64_t ivpr_mask =0xFFFF0000ULL ;uint32_t l1cfg0 =0x3800 /* 8 ways */ |0x0020 ;/* 32 kb */
@@ -4448,8 +4501,16 @@ static void init_proc_e500 (CPUPPCState *env, int version)* complain when accessing them. * gen_spr_BookE(env, 0x0000000F0000FD7FULL); */ -if (version == fsl_e500mc) { - ivor_mask =0x000003FE0000FFFFULL ; +switch (version) { +case fsl_e500v1: +case fsl_e500v2: +default : + ivor_mask =0x0000000F0000FFFFULL ; +break ; +case fsl_e500mc: +case fsl_e5500: + ivor_mask =0x000003FE0000FFFFULL ; +break ; }gen_spr_BookE (env, ivor_mask);/* Processor identification */
@@ -4477,6 +4538,7 @@ static void init_proc_e500 (CPUPPCState *env, int version) tlbncfg[1 ] =gen_tlbncfg (16 ,1 ,12 , TLBnCFG_AVAIL | TLBnCFG_IPROT,16 );break ;case fsl_e500mc: +case fsl_e5500: tlbncfg[0 ] =gen_tlbncfg (4 ,1 ,1 ,0 ,512 ); tlbncfg[1 ] =gen_tlbncfg (64 ,1 ,12 , TLBnCFG_AVAIL | TLBnCFG_IPROT,64 );break ;
@@ -4492,6 +4554,7 @@ static void init_proc_e500 (CPUPPCState *env, int version) env->icache_line_size =32 ;break ;case fsl_e500mc: +case fsl_e5500: env->dcache_line_size =64 ; env->icache_line_size =64 ; l1cfg0 |=0x1000000 ;/* 64 byte cache block size */
@@ -4567,6 +4630,22 @@ static void init_proc_e500 (CPUPPCState *env, int version)SPR_NOACCESS ,SPR_NOACCESS , &spr_read_generic, &spr_write_booke206_mmucsr0, 0x00000000); +spr_register (env,SPR_BOOKE_EPR ,"EPR" , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_load_epr,SPR_NOACCESS , +0x00000000 ); +/* XXX better abstract into Emb.xxx features */ +if (version == fsl_e5500) { +spr_register (env,SPR_BOOKE_EPCR ,"EPCR" , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_read_generic, &spr_write_generic, +0x00000000 ); +spr_register (env,SPR_BOOKE_MAS7_MAS3 ,"MAS7_MAS3" , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_read_mas73, &spr_write_mas73, +0x00000000 ); + ivpr_mask = (target_ulong )~0xFFFFULL ; + }#if !defined(CONFIG_USER_ONLY ) env->nb_tlb =0 ;
@@ -4596,6 +4675,13 @@ static void init_proc_e500mc(CPUPPCState *env)init_proc_e500 (env, fsl_e500mc); } +#ifdef TARGET_PPC64 +static void init_proc_e5500 (CPUPPCState *env) +{ +init_proc_e500 (env, fsl_e5500); +} +#endif +/* Non-embedded PowerPC */ /* POWER : same as 601, without mfmsr, mfsr */
@@ -7134,6 +7220,7 @@ enum { CPU_POWERPC_e500v2_v22 = 0x80210022, CPU_POWERPC_e500v2_v30 = 0x80210030, CPU_POWERPC_e500mc = 0x80230020, + CPU_POWERPC_e5500 = 0x80240020,/* MPC85xx microcontrollers */ #define CPU_POWERPC_MPC8533 CPU_POWERPC_MPC8533_v11#define CPU_POWERPC_MPC8533_v10 CPU_POWERPC_e500v2_v21
@@ -8528,6 +8615,9 @@ static const ppc_def_t ppc_defs[] = {/* PowerPC e500v2 v3.0 core */ POWERPC_DEF ("e500v2_v30" , CPU_POWERPC_e500v2_v30, e500v2),POWERPC_DEF ("e500mc" , CPU_POWERPC_e500mc, e500mc), +#ifdef TARGET_PPC64 +POWERPC_DEF ("e5500" , CPU_POWERPC_e5500, e5500), +#endif/* PowerPC e500 microcontrollers */ /* MPC8533 */ POWERPC_DEF_SVR("MPC8533",
Signature · 1 line
1.6.0.2
PATCH v2 9/11 PPC: Extract SPR dump generation into its own function
In reply to Alexander GrafThis patch moves the debug #ifdef'ed SPR trace generation into its own function, so we can call it from multiple places.
--- target-ppc/translate_init.c | 30 ++++++++++++++++++------------ 1 files changed, 18 insertions(+), 12 deletions(-)
target-ppc/translate_init.c +18 -12
@@ -55,28 +55,34 @@ PPC_IRQ_INIT_FN(e500);/* Generic callbacks: * do nothing but store/retrieve spr value */ +static void spr_load_dump_spr (int sprn) +{ +#ifdef PPC_DUMP_SPR_ACCESSES +TCGv_i32 t0 =tcg_const_i32 (sprn); +gen_helper_load_dump_spr (t0); +tcg_temp_free_i32 (t0); +#endif +} +static void spr_read_generic (void *opaque,int gprn,int sprn) {gen_load_spr (cpu_gpr[gprn], sprn); +spr_load_dump_spr (sprn); +} + +static void spr_store_dump_spr (int sprn) +{#ifdef PPC_DUMP_SPR_ACCESSES - { -TCGv_i32 t0 =tcg_const_i32 (sprn); -gen_helper_load_dump_spr (t0); -tcg_temp_free_i32 (t0); - } +TCGv_i32 t0 =tcg_const_i32 (sprn); +gen_helper_store_dump_spr (t0); +tcg_temp_free_i32 (t0);#endif }static void spr_write_generic (void *opaque,int sprn,int gprn) {gen_store_spr (sprn, cpu_gpr[gprn]); -#ifdef PPC_DUMP_SPR_ACCESSES - { -TCGv_i32 t0 =tcg_const_i32 (sprn); -gen_helper_store_dump_spr (t0); -tcg_temp_free_i32 (t0); - } -#endif +spr_store_dump_spr (sprn); }#if !defined(CONFIG_USER_ONLY )
Signature · 1 line
1.6.0.2
PATCH v2 10/11 PPC: BookE: Support 32 and 64 bit wide MAS2
In reply to Alexander GrafThe MAS registers on BookE are all 32 bit wide, except for MAS2, which can hold up to 64 bit on 64 bit capable CPUs. Reflect this in the SPR setting code, so that the guest can never write invalid values in them.
--- target-ppc/translate_init.c | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-)
target-ppc/translate_init.c +18 -1
@@ -86,6 +86,19 @@ static void spr_write_generic (void *opaque, int sprn, int gprn) }#if !defined(CONFIG_USER_ONLY ) +static void spr_write_generic32 (void *opaque,int sprn,int gprn) +{ +#ifdef TARGET_PPC64 +TCGv t0 =tcg_temp_new (); +tcg_gen_ext32u_tl (t0, cpu_gpr[gprn]); +gen_store_spr (sprn, t0); +tcg_temp_free (t0); +spr_store_dump_spr (sprn); +#else +spr_write_generic (opaque, sprn, gprn); +#endif +} +static void spr_write_clear (void *opaque,int sprn,int gprn) {TCGv t0 =tcg_temp_new ();
@@ -1597,10 +1610,14 @@ static void gen_spr_BookE206(CPUPPCState *env, uint32_t mas_mask,/* TLB assist registers */ /* XXX : not implemented */ for (i =0 ; i <8 ; i++) { +void (*uea_write)(void *o,int sprn,int gprn) = &spr_write_generic32; +if (i ==2 && (mas_mask & (1 << i)) && (env->insns_flags &PPC_64B )) { + uea_write = &spr_write_generic; + }if (mas_mask & (1 << i)) {spr_register (env, mas_sprn[i], mas_names[i],SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, + &spr_read_generic, uea_write,0x00000000 ); } }
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v2 10/11] PPC: BookE: Support 32 and 64 bit wide MAS2
Quoted 38 lines · Alexander Graf
The MAS registers on BookE are all 32 bit wide, except for MAS2, which can hold up to 64 bit on 64 bit capable CPUs. Reflect this in the SPR setting code, so that the guest can never write invalid values in them.
Signed-off-by Alexander Graf <[email protected]>--- target-ppc/translate_init.c | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-)target-ppc/translate_init.c +14
-0@@ -86,6 +86,19 @@ static void spr_write_generic (void *opaque, int sprn, int gprn) }#if !defined(CONFIG_USER_ONLY ) +static void spr_write_generic32 (void *opaque,int sprn,int gprn) +{ +#ifdef TARGET_PPC64 +TCGv t0 =tcg_temp_new (); +tcg_gen_ext32u_tl (t0, cpu_gpr[gprn]); +gen_store_spr (sprn, t0); +tcg_temp_free (t0); +spr_store_dump_spr (sprn); +#else +spr_write_generic (opaque, sprn, gprn); +#endif +} +static void spr_write_clear (void *opaque,int sprn,int gprn) {TCGv t0 =tcg_temp_new ();@@ -1597,10 +1610,14 @@ static void gen_spr_BookE206(CPUPPCState *env, uint32_t mas_mask,/* TLB assist registers */ /* XXX : not implemented */ for (i =0 ; i <8 ; i++) { +void (*uea_write)(void *o,int sprn,int gprn) = &spr_write_generic32;
target-ppc/translate_init.c static void gen_spr_BookE206(CPUPPCState *env, uint32_t mas_mask, · line 1622
Quoted 10 lines
target-ppc/translate_init.c +4
-1+if (i ==2 && (mas_mask & (1 << i)) && (env->insns_flags &PPC_64B )) { + uea_write = &spr_write_generic; + }if (mas_mask & (1 << i)) {spr_register (env, mas_sprn[i], mas_names[i],SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, + &spr_read_generic, uea_write,0x00000000 ); }
What does "uea" mean?
-Scott
Re: [Qemu-devel] [PATCH v2 10/11] PPC: BookE: Support 32 and 64 bit wide MAS2
Quoted 43 lines · Scott Wood
Quoted 42 lines · Alexander Graf
The MAS registers on BookE are all 32 bit wide, except for MAS2, which can hold up to 64 bit on 64 bit capable CPUs. Reflect this in the SPR setting code, so that the guest can never write invalid values in them.
Signed-off-by Alexander Graf <[email protected]>---
target-ppc/translate_init.c| 19 ++++++++++++++++++-1 files changed, 18 insertions(+), 1 deletions(-)target-ppc/translate_init.c +17
-0@@ -86,6 +86,19 @@ static void spr_write_generic (void *opaque, int sprn, int gprn) }#if !defined(CONFIG_USER_ONLY ) +static void spr_write_generic32 (void *opaque,int sprn,int gprn) +{ +#ifdef TARGET_PPC64 +TCGv t0 =tcg_temp_new (); +tcg_gen_ext32u_tl (t0, cpu_gpr[gprn]); +gen_store_spr (sprn, t0); +tcg_temp_free (t0); +spr_store_dump_spr (sprn); +#else +spr_write_generic (opaque, sprn, gprn); +#endif +} +static void spr_write_clear (void *opaque,int sprn,int gprn) {TCGv t0 =tcg_temp_new ();@@ -1597,10 +1610,14 @@ static void gen_spr_BookE206(CPUPPCState *env, uint32_t mas_mask,/* TLB assist registers */ /* XXX : not implemented */ for (i =0 ; i <8 ; i++) { +void (*uea_write)(void *o,int sprn,int gprn) = &spr_write_generic32; +if (i ==2 && (mas_mask & (1 << i)) && (env->insns_flags &PPC_64B )) { + uea_write = &spr_write_generic; + }if (mas_mask & (1 << i)) {
Quoted 8 lines
target-ppc/translate_init.c static void gen_spr_BookE206(CPUPPCState *env, uint32_t mas_mask, · line 1622
Quoted 6 lines
target-ppc/translate_init.c +1
-1spr_register (env, mas_sprn[i], mas_names[i],SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, + &spr_read_generic, uea_write,0x00000000 ); }What does "uea" mean?
Not sure - it's the same definition as what spr_register takes in as parameter.
Alex
PATCH v2 11/11 PPC: BookE206: Bump MAS2 to 64bit
In reply to Alexander GrafOn 64bit capable systems, MAS2 can actually hold a 64bit virtual page address. So increase the mask for its EPN.
--- target-ppc/cpu.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
target-ppc/cpu.h +1 -1
@@ -693,7 +693,7 @@ enum {#define MAS1_VALID 0x80000000#define MAS2_EPN_SHIFT 12 -#define MAS2_EPN_MASK (0xfffff << MAS2_EPN_SHIFT) +#define MAS2_EPN_MASK (~0ULL << MAS2_EPN_SHIFT)#define MAS2_ACM_SHIFT 6#define MAS2_ACM (1 << MAS2_ACM_SHIFT)
Signature · 1 line
1.6.0.2