target/ppc: Correct Freescale Book E CPU models
v3 cover target/ppc: Correct Freescale Book E CPU models
This series corrects SPR access, cache and MMU configuration, and instruction availability in the Freescale Book E CPU models. It also fixes host PVR matching and adds system TCG tests for e500mc, e5500 and e6500.
The patches are grouped as follows:
- patch #1-#3 and #5, bug fixes to PIR write access, the MAS5 SPR number and cache block/line sizes (qemu-stable cc'ed)
- patch #4 and #6, complete e500mc/e5500 L1 cache configuration and remove redundant e6500 cache geometry bits
- patch #7-#11, register the missing cache, MMU-assist and several control SPRs
- patch #12-#14, split the PowerISA 2.05 instructions into integer and floating-point groups, due to differences seen on e500 series cores
- patch #15-#17: Add TCG tests for illegal-instruction exceptions, byte comparison and parity results, and FPSCR field-mask handling
- patch #18-#21, complete the e500 family MMU configuration, correct PID register counts and express MMUCFG/TLBnCFG with named fields
- patch #22-#23, fix EPCR write width and host PVR revision matching for Book E KVM
Changes in v3:
- Cover the new system test directories in MAINTAINERS
- Add the missing SPDX license identifier to the README
- target/ppc: Build e6500 MMUCFG values from field encodings
- target/ppc: Complete MMU configuration for e500 family cores
- target/ppc: Limit e500mc and e5500 to one PID register
- target/ppc: Express e6500 TLB configuration with named fields
- target/ppc: Keep embedded processor control within 32 bits
- target/ppc: Match e500mc/e5500/e6500 host PVR revisions
Changes in v2:
- Group ISA 2.05 features into integer and floating-point flags
- Use the first free bit for the floating-point group
- Align flag definitions and comment endings
- Enable the shared ISA 2.05 integer flag on e5500 and e6500
- Align the FPSCR W/L behavior flag comment ending
- Rebase the PPC64 test entry onto the Meson variable cleanup
Bin Meng (23):
target/ppc: Correct PIR write access on e500 cores target/ppc: Correct the MAS5 SPR number
target/ppc: Correct the e500mc and e5500 cache block size fields target/ppc: Complete e500mc and e5500 L1 cache configuration target/ppc: Correct cache line size for e6500 target/ppc: Drop redundant e6500 L1 cache geometry bits target/ppc: Register L1CSR2 on e500mc/e5500/e6500 cores target/ppc: Register L2CFG0 and L2CSR1 on e500mc and e5500 target/ppc: Register MAS5 and MAS8 on e500mc/e5500/e6500 target/ppc: Register PWRMGTCR0 on e6500
target/ppc: Register IVOR42 on e6500
target/ppc: Split the ISA 2.05 instruction feature group target/ppc: Enable byte comparison and parity on e5500 and e6500 target/ppc: Ignore FPSCR W/L fields on e500mc, e5500 and e6500 tests/tcg/ppc: Add Book E illegal instruction tests tests/tcg/ppc: Test byte comparison and parity on e5500/e6500 tests/tcg/ppc: Test FPSCR W/L handling on e500mc/e5500/e6500 target/ppc: Build e6500 MMUCFG values from field encodings target/ppc: Complete MMU configuration for e500 family cores target/ppc: Limit e500mc and e5500 to one PID register target/ppc: Express e6500 TLB configuration with named fields target/ppc: Keep embedded processor control within 32 bits target/ppc: Match e500mc/e5500/e6500 host PVR revisions
MAINTAINERS | 2 +- target/ppc/cpu.h | 45 ++++++---- target/ppc/cpu_init.h | 3 +- target/ppc/cpu_init.c | 99 +++++++++++++++++----- target/ppc/translate.c | 10 ++- target/ppc/translate/fixedpoint-impl.c.inc | 6 +- target/ppc/translate/fp-impl.c.inc | 14 ++- target/ppc/translate/fp-ops.c.inc | 9 +- meson_options.txt | 4 + scripts/meson-buildoptions.sh | 2 + tests/tcg/meson.build | 1 + tests/tcg/ppc/meson.build | 5 ++ tests/tcg/ppc/system/README | 24 ++++++ tests/tcg/ppc/system/boot.S | 92 ++++++++++++++++++++ tests/tcg/ppc/system/byte-parity.S | 33 ++++++++ tests/tcg/ppc/system/fpscr.S | 75 ++++++++++++++++ tests/tcg/ppc/system/isa.out | 1 + tests/tcg/ppc/system/kernel.ld | 18 ++++ tests/tcg/ppc/system/macros.inc | 56 ++++++++++++ tests/tcg/ppc/system/meson.build | 39 +++++++++ tests/tcg/ppc/system/unsupported.S | 31 +++++++ tests/tcg/ppc64/meson.build | 2 + tests/tcg/ppc64/system/meson.build | 33 ++++++++ 23 files changed, 554 insertions(+), 50 deletions(-) create mode 100644 tests/tcg/ppc/meson.build create mode 100644 tests/tcg/ppc/system/README create mode 100644 tests/tcg/ppc/system/boot.S create mode 100644 tests/tcg/ppc/system/byte-parity.S create mode 100644 tests/tcg/ppc/system/fpscr.S create mode 100644 tests/tcg/ppc/system/isa.out create mode 100644 tests/tcg/ppc/system/kernel.ld create mode 100644 tests/tcg/ppc/system/macros.inc create mode 100644 tests/tcg/ppc/system/meson.build create mode 100644 tests/tcg/ppc/system/unsupported.S create mode 100644 tests/tcg/ppc64/system/meson.build
---
base-commit: f29ccc287a6cfdd51d3a4fd17fbe9af3310a0ac5
branch: ppc-fsl-booke
Signature · 1 line
2.53.0
PATCH v3 1/23 target/ppc: Correct PIR write access on e500 cores
The BookE PIR registration reuses the classic PowerPC 604 write callback, which writes SPR 1023 and masks the value to four bits. BookE PIR is SPR 286; on e500, SPR 1023 is SVR, so a PIR write can corrupt SVR while leaving PIR unchanged.
The e500v1/e500v2 manual defines PIR as read-only. The e500mc, e5500 and e6500 manuals allow hypervisor software to write PIR after reset. Reject writes on e500v1/e500v2 and use the generic 32-bit SPR write callback on the other three cores to update the correct register without the four-bit restriction.
---
Reference:
- E500CORERM (Rev.1), section 2.5.2
https://www.nxp.com/docs/en/reference-manual/E500CORERM.pdf
- E500MCRM (Rev.3), section 2.9.7
https://www.nxp.com/docs/en/reference-manual/E500MCRM.pdf
- E5500RM (Rev.4), section 2.9.7
https://www.nxp.com/webapp/Download?colCode=E5500RM
- E6500RM (Rev.0), section 2.9.8
https://www.nxp.com/docs/en/reference-manual/E6500RM.pdf
(no changes since v1)
target/ppc/cpu_init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
target/ppc/cpu_init.c +3 -1
@@ -2837,7 +2837,9 @@ static void init_proc_e500(CPUPPCState *env, int version)/* Processor identification */ spr_register (env,SPR_BOOKE_PIR ,"PIR" ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_pir, + &spr_read_generic, + (version == fsl_e500v1 || version == fsl_e500v2) ? +SPR_NOACCESS : &spr_write_generic32,0x00000000 ); spr_register(env, SPR_BOOKE_SPEFSCR, "SPEFSCR",
Signature · 1 line
2.53.0
PATCH v3 2/23 target/ppc: Correct the MAS5 SPR number
In reply to Bin MengThe e500mc, e5500 and e6500 core manuals define MAS5 as SPR 339 (0x153), but the existing definition assigns it number 629 (0x275). Correct the number and place the definition in its numeric group.
While we are here, adjust the order of SPR_HEIR so that it is inserted in ascending order.
---
Reference: EREF_RM (Rev.1), section 4.2.2 and 4.12.10.6
https://www.nxp.com/webapp/Download?colCode=EREF_RM
(no changes since v1)
target/ppc/cpu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/ppc/cpu.h +2 -2
@@ -1928,8 +1928,9 @@ void ppc_compat_add_property(Object *obj, const char *name,#define SPR_HMER (0x150)#define SPR_HMEER (0x151)#define SPR_PCR (0x152) -#define SPR_HEIR (0x153)#define SPR_BOOKE_LPIDR (0x152) +#define SPR_HEIR (0x153) +#define SPR_BOOKE_MAS5 (0x153)#define SPR_BOOKE_TCR (0x154)#define SPR_PPE42_TCR (0x154)#define SPR_BOOKE_TLB0PS (0x158)
@@ -2044,7 +2045,6 @@ void ppc_compat_add_property(Object *obj, const char *name,#define SPR_BOOKE_MAS2 (0x272)#define SPR_BOOKE_MAS3 (0x273)#define SPR_BOOKE_MAS4 (0x274) -#define SPR_BOOKE_MAS5 (0x275)#define SPR_BOOKE_MAS6 (0x276)#define SPR_BOOKE_PID1 (0x279)#define SPR_BOOKE_PID2 (0x27A)
Signature · 1 line
2.53.0
PATCH v3 3/23 target/ppc: Correct the e500mc and e5500 cache block size fields
In reply to Bin MengThe L1 configuration registers encode a 64-byte cache block with CBSIZE=1. The models instead set CBSIZE=2, advertising 128 bytes despite using 64 bytes for cache operations.
Use the correct field value for both caches.
---
Reference:
- E500MCRM (Rev.3), sections 2.14.4 and 2.14.5
https://www.nxp.com/docs/en/reference-manual/E500MCRM.pdf
- E5500RM (Rev.4), sections 2.14.4 and 2.14.5
https://www.nxp.com/webapp/Download?colCode=E5500RM
(no changes since v1)
target/ppc/cpu_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/ppc/cpu_init.c +2 -2
@@ -2886,8 +2886,8 @@ static void init_proc_e500(CPUPPCState *env, int version)case fsl_e5500: env->dcache_line_size =64 ; env->icache_line_size =64 ; - l1cfg0 |=0x1000000 ;/* 64 byte cache block size */ - l1cfg1 |=0x1000000 ;/* 64 byte cache block size */ + l1cfg0 |=0x00800000 ;/* 64 byte cache block size */ + l1cfg1 |=0x00800000 ;/* 64 byte cache block size */ break ;case fsl_e6500: env->dcache_line_size =32 ;
Signature · 1 line
2.53.0
PATCH v3 4/23 target/ppc: Complete e500mc and e5500 L1 cache configuration
In reply to Bin MengThe e500mc and e5500 manuals specify pseudo-LRU replacement, cache locking and parity detection for both L1 caches. The reset values describe the block size, associativity and capacity, but leave CREPL/ICREPL, CLA/ICLA and CPA/ICPA clear.
Set those fields to their documented values so both L1CFG0 and L1CFG1 reset to 0x00B83820, including the shared eight-way, 32 KiB cache geometry.
---
Reference:
- E500MCRM (Rev.3), section 2.14.4 and 2.14.5
https://www.nxp.com/docs/en/reference-manual/E500MCRM.pdf
- E5500RM (Rev.4), section 2.14.4 and 2.14.5
https://www.nxp.com/webapp/Download?colCode=E5500RM
(no changes since v1)
target/ppc/cpu_init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
target/ppc/cpu_init.c +3 -2
@@ -2886,8 +2886,9 @@ static void init_proc_e500(CPUPPCState *env, int version)case fsl_e5500: env->dcache_line_size =64 ; env->icache_line_size =64 ; - l1cfg0 |=0x00800000 ;/* 64 byte cache block size */ - l1cfg1 |=0x00800000 ;/* 64 byte cache block size */ +/* 64 byte blocks, pseudo-LRU replacement, cache locking and parity */ + l1cfg0 |=0x00B80000 ; + l1cfg1 |=0x00B80000 ;break ;case fsl_e6500: env->dcache_line_size =32 ;
Signature · 1 line
2.53.0
PATCH v3 5/23 target/ppc: Correct cache line size for e6500
In reply to Bin MengThe e6500 L1 instruction and data caches use 64-byte cache lines. The cache configuration registers already describe this geometry, but the translator used 32-byte lines for cache operations.
Match the line sizes to the hardware so that guest cache management and dcbz agree with the reported configuration.
---
Reference: E6500RM (Rev.0), section 2.11.4 and 2.11.5
https://www.nxp.com/docs/en/reference-manual/E6500RM.pdf
(no changes since v1)
target/ppc/cpu_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/ppc/cpu_init.c +2 -2
@@ -2891,8 +2891,8 @@ static void init_proc_e500(CPUPPCState *env, int version) l1cfg1 |=0x00B80000 ;break ;case fsl_e6500: - env->dcache_line_size =32 ; - env->icache_line_size =32 ; + env->dcache_line_size =64 ; + env->icache_line_size =64 ; l1cfg0 |=0x0F83820 ; l1cfg1 |=0x0B83820 ;break ;
Signature · 1 line
2.53.0
PATCH v3 6/23 target/ppc: Drop redundant e6500 L1 cache geometry bits
In reply to Bin MengThe shared L1CFG0 and L1CFG1 initializers already set 0x3820 for eight ways and 32 KiB. The e6500 masks repeat those same bits. Keep only the e6500-specific upper fields in the masks.
---
Reference: E6500RM (Rev.0), section 2.11.4 and 2.11.5
https://www.nxp.com/docs/en/reference-manual/E6500RM.pdf
(no changes since v1)
target/ppc/cpu_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/ppc/cpu_init.c +2 -2
@@ -2893,8 +2893,8 @@ static void init_proc_e500(CPUPPCState *env, int version)case fsl_e6500: env->dcache_line_size =64 ; env->icache_line_size =64 ; - l1cfg0 |=0x0F83820 ; - l1cfg1 |=0x0B83820 ; + l1cfg0 |=0x00F80000 ; + l1cfg1 |=0x00B80000 ;break ;default : cpu_abort(env_cpu(env), "Unknown CPU: " TARGET_FMT_lx "\n",
Signature · 1 line
2.53.0
PATCH v3 7/23 target/ppc: Register L1CSR2 on e500mc/e5500/e6500 cores
In reply to Bin MengU-Boot programs the L1 data cache stash identifier before entering its C initialization code. The e500mc, e5500 and e6500 core manuals define L1CSR2 as a 32-bit SPR with number 606 (0x25e) and reset value zero.
Expose the register on all three cores, excluding e500v1 and e500v2.
---
Reference:
- E500MCRM (Rev.3), section 2.14.3
https://www.nxp.com/docs/en/reference-manual/E500MCRM.pdf
- E5500RM (Rev.4), section 2.14.3
https://www.nxp.com/webapp/Download?colCode=E5500RM
- E6500RM (Rev.0), section 2.11.3
https://www.nxp.com/docs/en/reference-manual/E6500RM.pdf
(no changes since v1)
target/ppc/cpu.h | 1 + target/ppc/cpu_init.c | 4 ++++ 2 files changed, 5 insertions(+)
target/ppc/cpu.h +1 -0
@@ -2040,6 +2040,7 @@ void ppc_compat_add_property(Object *obj, const char *name,#define SPR_BOOKE_DSRR1 (0x23F)#define SPR_BOOKE_SPRG8 (0x25C)#define SPR_BOOKE_SPRG9 (0x25D) +#define SPR_Exxx_L1CSR2 (0x25E)#define SPR_BOOKE_MAS0 (0x270)#define SPR_BOOKE_MAS1 (0x271)#define SPR_BOOKE_MAS2 (0x272)
target/ppc/cpu_init.c +4 -0
@@ -2965,6 +2965,10 @@ static void init_proc_e500(CPUPPCState *env, int version) &spr_read_generic, &spr_write_e500_l1csr1, 0x00000000);if (version != fsl_e500v1 && version != fsl_e500v2) { +spr_register (env, SPR_Exxx_L1CSR2,"L1CSR2" , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_read_generic, &spr_write_generic32, +0x00000000 ); spr_register(env, SPR_Exxx_L2CSR0, "L2CSR0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_e500_l2csr0,
Signature · 1 line
2.53.0
PATCH v3 8/23 target/ppc: Register L2CFG0 and L2CSR1 on e500mc and e5500
In reply to Bin MengThe e500mc and e5500 core manuals define L2CFG0 as read-only SPR 519 (0x207) and L2CSR1 as writable SPR 1018 (0x3fa). U-Boot reads the former to discover the private L2 cache and programs the latter to select its stash ID. Missing registrations leave cache discovery and stash setup incomplete.
Expose both registers on e500mc and e5500. Use the 128 KiB L2 geometry specified by the e500mc manual and a 256 KiB default for e5500, matching T1040/T1024. Other SoC integrations can override the capacity.
Note the e6500 shared L2 uses memory-mapped registers, hence we do not add these SPRs to that core.
---
Reference:
- E500MCRM (Rev.3), section 2.15.1 and 2.15.3
https://www.nxp.com/docs/en/reference-manual/E500MCRM.pdf
- E5500RM (Rev.4), section 2.15.1 and 2.15.3
https://www.nxp.com/webapp/Download?colCode=E5500RM
- E6500RM (Rev.0), section 2.12.1 and 2.12.3
https://www.nxp.com/docs/en/reference-manual/E6500RM.pdf
(no changes since v1)
target/ppc/cpu.h | 2 ++ target/ppc/cpu_init.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+)
target/ppc/cpu.h +2 -0
@@ -1978,6 +1978,7 @@ void ppc_compat_add_property(Object *obj, const char *name,#define SPR_Exxx_L1CFG0 (0x203)#define SPR_Exxx_L1CFG1 (0x204)#define SPR_Exxx_NPIDR (0x205) +#define SPR_Exxx_L2CFG0 (0x207)#define SPR_ATBL (0x20E)#define SPR_ATBU (0x20F)#define SPR_IBAT0U (0x210)
@@ -2343,6 +2344,7 @@ void ppc_compat_add_property(Object *obj, const char *name,#define SPR_750_TDCH (0x3FA)#define SPR_IABR2 (0x3FA)#define SPR_40x_DCCR (0x3FA) +#define SPR_Exxx_L2CSR1 (0x3FA)#define SPR_ICTC (0x3FB)#define SPR_40x_ICCR (0x3FB)#define SPR_THRM1 (0x3FC)
target/ppc/cpu_init.c +14 -0
@@ -2974,6 +2974,20 @@ static void init_proc_e500(CPUPPCState *env, int version) &spr_read_generic, &spr_write_e500_l2csr0, 0x00000000); } +if (version == fsl_e500mc || version == fsl_e5500) { +/* +* L2CSIZE is in 64 KiB units. Use 128 KiB for e500mc and a +* 256 KiB default for e5500, matching the T1040/T1024 SoCs. +* Other SoC models can override the e5500 capacity. +*/ +spr_register (env, SPR_Exxx_L2CFG0,"L2CFG0" , + &spr_read_generic,SPR_NOACCESS , + &spr_read_generic,SPR_NOACCESS , + version == fsl_e500mc ?0x3cb1c002 :0x3cb1c004 ); +spr_register (env, SPR_Exxx_L2CSR1,"L2CSR1" , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_read_generic, &spr_write_generic32,0 ); + } spr_register(env, SPR_BOOKE_MCSRR0, "MCSRR0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic,
Signature · 1 line
2.53.0
PATCH v3 9/23 target/ppc: Register MAS5 and MAS8 on e500mc/e5500/e6500
In reply to Bin MengThe e500mc, e5500 and e6500 core manuals define MAS5 and MAS8 as SPRs 339 (0x153) and 341 (0x155). MAS5 supplies GS and LPID values for TLB searches and invalidations, while MAS8 holds guest-space and LPID context for TLB entries.
Register both alongside the other BookE MMU assist registers using the existing 32-bit SPR storage. Exclude e500v1 and e500v2, which do not implement MAS5 or MAS8.
---
Reference:
- E500MCRM (Rev.3), section 2.16.6.6 and 2.16.6.9
https://www.nxp.com/docs/en/reference-manual/E500MCRM.pdf
- E5500RM (Rev.4), section 2.16.6.6 and 2.16.6.9
https://www.nxp.com/webapp/Download?colCode=E5500RM
- E6500RM (Rev.0), section 2.13.10.6 and 2.13.10.9
https://www.nxp.com/docs/en/reference-manual/E6500RM.pdf
(no changes since v1)
target/ppc/cpu.h | 1 + target/ppc/cpu_init.c | 8 ++++++++ 2 files changed, 9 insertions(+)
target/ppc/cpu.h +1 -0
@@ -1933,6 +1933,7 @@ void ppc_compat_add_property(Object *obj, const char *name,#define SPR_BOOKE_MAS5 (0x153)#define SPR_BOOKE_TCR (0x154)#define SPR_PPE42_TCR (0x154) +#define SPR_BOOKE_MAS8 (0x155)#define SPR_BOOKE_TLB0PS (0x158)#define SPR_BOOKE_TLB1PS (0x159)#define SPR_BOOKE_TLB2PS (0x15A)
target/ppc/cpu_init.c +8 -0
@@ -2901,6 +2901,14 @@ static void init_proc_e500(CPUPPCState *env, int version) env->spr[SPR_PVR]); }register_BookE206_sprs (env,0x000000DF , tlbncfg, mmucfg); +if (version != fsl_e500v1 && version != fsl_e500v2) { +spr_register (env,SPR_BOOKE_MAS5 ,"MAS5" , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_read_generic, &spr_write_generic32,0 ); +spr_register (env,SPR_BOOKE_MAS8 ,"MAS8" , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_read_generic, &spr_write_generic32,0 ); + }register_usprgh_sprs (env);if (version != fsl_e500v1) {
Signature · 1 line
2.53.0
PATCH v3 10/23 target/ppc: Register PWRMGTCR0 on e6500
In reply to Bin MengThe e6500 core manual defines PWRMGTCR0 as SPR 1019 (0x3fb). QorIQ U-Boot and kernel access its fields during processor power setup.
Define and register PWRMGTCR0 using the existing 32-bit SPR storage to retain the programmed control fields.
---
Reference: E6500RM (Rev.0), section 2.7.7
https://www.nxp.com/docs/en/reference-manual/E6500RM.pdf
(no changes since v1)
target/ppc/cpu.h | 1 + target/ppc/cpu_init.c | 3 +++ 2 files changed, 4 insertions(+)
target/ppc/cpu.h +1 -0
@@ -2348,6 +2348,7 @@ void ppc_compat_add_property(Object *obj, const char *name,#define SPR_Exxx_L2CSR1 (0x3FA)#define SPR_ICTC (0x3FB)#define SPR_40x_ICCR (0x3FB) +#define SPR_Exxx_PWRMGTCR0 (0x3FB)#define SPR_THRM1 (0x3FC)#define SPR_403_PBL1 (0x3FC)#define SPR_SP (0x3FD)
target/ppc/cpu_init.c +3 -0
@@ -3026,6 +3026,9 @@ static void init_proc_e500(CPUPPCState *env, int version) }if (version == fsl_e6500) { +spr_register (env, SPR_Exxx_PWRMGTCR0,"PWRMGTCR0" , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_read_generic, &spr_write_generic32,0 );/* Thread identification */ spr_register(env, SPR_TIR, "TIR", SPR_NOACCESS, SPR_NOACCESS,
Signature · 1 line
2.53.0
PATCH v3 11/23 target/ppc: Register IVOR42 on e6500
In reply to Bin MengThe e6500 core manual defines IVOR42 as the LRAT error interrupt offset register. U-Boot programs it during interrupt setup, but currently the QEMU e6500 IVOR mask excludes bit 42.
Include IVOR42 in the mask so the existing BookE SPR registration exposes its offset. This permits the register accesses without implementing LRAT translation or LRAT exception delivery.
---
Reference: E6500RM (Rev.0), section 2.9.5 and 4.9.22
https://www.nxp.com/docs/en/reference-manual/E6500RM.pdf
Changes in v3:
- Drop the redudent 'currently' in the commit message
target/ppc/cpu_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/cpu_init.c +1 -1
@@ -2824,7 +2824,7 @@ static void init_proc_e500(CPUPPCState *env, int version) ivor_mask =0x000003FE0000FFFFULL ;break ;case fsl_e6500: - ivor_mask =0x000003FF0000FFFFULL ; + ivor_mask =0x000007FF0000FFFFULL ;break ; }register_BookE_sprs (env, ivor_mask);
Signature · 1 line
2.53.0
PATCH v3 12/23 target/ppc: Split the ISA 2.05 instruction feature group
In reply to Bin MengThe ISA 2.05 flag couples integer instructions to floating-point instructions and extended FPSCR access. The e5500 and e6500 implement cmpb and parity instructions but lack these floating-point features, so enabling the entire group cannot describe their hardware.
Split the ISA 2.05 instructions into integer and floating-point groups. Keep the existing capabilities of POWER7 and later models, and include all new flags in the TCG supported instruction mask.
---
(no changes since v2)
Changes in v2:
- Group ISA 2.05 features into integer and floating-point flags
- Use the first free bit for the floating-point group
- Align flag definitions and comment endings
target/ppc/cpu.h | 10 ++++++---- target/ppc/cpu_init.h | 3 ++- target/ppc/cpu_init.c | 6 ++++-- target/ppc/translate.c | 10 ++++++---- target/ppc/translate/fixedpoint-impl.c.inc | 6 +++--- target/ppc/translate/fp-impl.c.inc | 8 ++++---- target/ppc/translate/fp-ops.c.inc | 9 ++++++--- 7 files changed, 31 insertions(+), 21 deletions(-)
target/ppc/cpu.h +6 -4
@@ -2570,8 +2570,8 @@ enum {PPC2_PRCNTL =0x0000000000000008ULL ,/* Byte-reversed, indexed, double-word load and store */ PPC2_DBRX =0x0000000000000010ULL , -/* Book I 2.05 PowerPC specification */ -PPC2_ISA205 =0x0000000000000020ULL , +/* ISA 2.05 integer instructions (cmpb, prtyw and prtyd) */ +PPC2_INT_ISA205 =0x0000000000000020ULL ,/* POWER ISA 2.07 */ PPC2_ISA207 = 0x0000000000000040ULL,/* ISA 2.06B bpermd */
@@ -2604,15 +2604,17 @@ enum {PPC2_PPE42X =0x0000000000100000ULL ,/* PPE42XM instructions */ PPC2_PPE42XM =0x0000000000200000ULL , +/* ISA 2.05 floating-point instructions and extended FPSCR access */ +PPC2_FP_ISA205 =0x0000000000400000ULL , #define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_VSX | PPC2_PRCNTL | PPC2_DBRX | \ -PPC2_ISA205 |PPC2_ISA207 |PPC2_PERM_ISA206 | \ +PPC2_INT_ISA205 |PPC2_ISA207 |PPC2_PERM_ISA206 | \PPC2_DIVE_ISA206 |PPC2_ATOMIC_ISA206 | \PPC2_FP_CVT_ISA206 |PPC2_FP_TST_ISA206 |PPC2_DFP | \PPC2_FP_CVT_S64 |PPC2_TM |PPC2_PM_ISA206 | \PPC2_ISA300 |PPC2_ISA310 |PPC2_MEM_LWSYNC | \PPC2_BCDA_ISA206 |PPC2_PPE42 |PPC2_PPE42X | \ - PPC2_PPE42XM) + PPC2_PPE42XM | PPC2_FP_ISA205) };/*****************************************************************************/
target/ppc/cpu_init.h +2 -1
@@ -17,7 +17,8 @@#define PPC_INSNS_FLAGS2_POWER_COMMON \ (PPC2_VSX | PPC2_ISA207 | PPC2_DFP | PPC2_DBRX | \ PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 | \ - PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | PPC2_ISA205 | \ + PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | \ + PPC2_INT_ISA205 | PPC2_FP_ISA205 | \ PPC2_FP_CVT_S64 | PPC2_ISA300 | PPC2_PRCNTL | \ PPC2_MEM_LWSYNC | PPC2_BCDA_ISA206)
target/ppc/cpu_init.c +4 -2
@@ -6220,7 +6220,8 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, const void *data)PPC_SEGMENT_64B |PPC_SLBI |PPC_POPCNTB |PPC_POPCNTWD |PPC_CILDST ; - pcc->insns_flags2 =PPC2_VSX |PPC2_DFP |PPC2_DBRX |PPC2_ISA205 | + pcc->insns_flags2 =PPC2_VSX |PPC2_DFP |PPC2_DBRX | +PPC2_INT_ISA205 |PPC2_FP_ISA205 |PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 |PPC2_ATOMIC_ISA206 |PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | PPC2_FP_CVT_S64 |
@@ -6381,7 +6382,8 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, const void *data) pcc->insns_flags2 =PPC2_VSX |PPC2_ISA207 |PPC2_DFP |PPC2_DBRX |PPC2_PERM_ISA206 |PPC2_DIVE_ISA206 |PPC2_ATOMIC_ISA206 |PPC2_FP_CVT_ISA206 | -PPC2_FP_TST_ISA206 |PPC2_ISA205 |PPC2_FP_CVT_S64 | +PPC2_FP_TST_ISA206 |PPC2_FP_CVT_S64 | +PPC2_INT_ISA205 |PPC2_FP_ISA205 |PPC2_TM |PPC2_PM_ISA206 |PPC2_MEM_LWSYNC |PPC2_BCDA_ISA206 ; pcc->msr_mask = (1ull << MSR_SF) |
target/ppc/translate.c +6 -4
@@ -4403,7 +4403,7 @@ static bool trans_ICBIEP(DisasContext *ctx, arg_X_ea *a)static void gen_dform39 (DisasContext *ctx) {if ((ctx->opcode &0x3 ) ==0 ) { -if (ctx->insns_flags2 &PPC2_ISA205 ) { +if (ctx->insns_flags2 &PPC2_FP_ISA205 ) {return gen_lfdp (ctx); } }
@@ -4415,7 +4415,7 @@ static void gen_dform3D(DisasContext *ctx) {if ((ctx->opcode &3 ) ==0 ) {/* DS-FORM */ /* stfdp */ -if (ctx->insns_flags2 &PPC2_ISA205 ) { +if (ctx->insns_flags2 &PPC2_FP_ISA205 ) {return gen_stfdp (ctx); } }
@@ -4429,9 +4429,11 @@ GEN_HANDLER_E(cp_abort, 0x1F, 0x06, 0x1A, 0x03FFF801, PPC_NONE, PPC2_ISA300),GEN_HANDLER_E (paste,0x1F ,0x06 ,0x1C ,0x03C00000 ,PPC_NONE ,PPC2_ISA300 ),GEN_HANDLER (rlwnm,0x17 ,0xFF ,0xFF ,0x00000000 ,PPC_INTEGER ),/* handles lfdp, lxsd, lxssp */ -GEN_HANDLER_E (dform39,0x39 ,0xFF ,0xFF ,0x00000000 ,PPC_NONE ,PPC2_ISA205 ), +GEN_HANDLER_E (dform39,0x39 ,0xFF ,0xFF ,0x00000000 , +PPC_NONE ,PPC2_FP_ISA205 ),/* handles stfdp, stxsd, stxssp */ -GEN_HANDLER_E (dform3D,0x3D ,0xFF ,0xFF ,0x00000000 ,PPC_NONE ,PPC2_ISA205 ), +GEN_HANDLER_E (dform3D,0x3D ,0xFF ,0xFF ,0x00000000 , +PPC_NONE ,PPC2_FP_ISA205 ),GEN_HANDLER (mcrxr,0x1F ,0x00 ,0x10 ,0x007FF801 ,PPC_MISC ),GEN_HANDLER (mfspr,0x1F ,0x13 ,0x0A ,0x00000001 ,PPC_MISC ), GEN_HANDLER(mftb, 0x1F, 0x13, 0x0B, 0x00000001, PPC_MFTB),
target/ppc/translate/fixedpoint-impl.c.inc +3 -3
@@ -1545,7 +1545,7 @@ static bool trans_XOR(DisasContext *ctx, arg_XOR *a) static bool trans_CMPB(DisasContext *ctx, arg_CMPB *a) { - REQUIRE_INSNS_FLAGS2(ctx, ISA205); + REQUIRE_INSNS_FLAGS2(ctx, INT_ISA205); gen_helper_CMPB(cpu_gpr[a->ra], cpu_gpr[a->rt], cpu_gpr[a->rb]); return true; }
@@ -1636,7 +1636,7 @@ static bool trans_PRTYW(DisasContext *ctx, arg_PRTYW *a) TCGv rs = cpu_gpr[a->rs]; TCGv t0 = tcg_temp_new(); - REQUIRE_INSNS_FLAGS2(ctx, ISA205); + REQUIRE_INSNS_FLAGS2(ctx, INT_ISA205); tcg_gen_shri_tl(t0, rs, 16); tcg_gen_xor_tl(ra, rs, t0); tcg_gen_shri_tl(t0, ra, 8);
@@ -1652,7 +1652,7 @@ static bool trans_PRTYD(DisasContext *ctx, arg_PRTYD *a) TCGv t0 = tcg_temp_new(); REQUIRE_64BIT(ctx); - REQUIRE_INSNS_FLAGS2(ctx, ISA205); + REQUIRE_INSNS_FLAGS2(ctx, INT_ISA205); tcg_gen_shri_tl(t0, rs, 32); tcg_gen_xor_tl(ra, rs, t0); tcg_gen_shri_tl(t0, ra, 16);
target/ppc/translate/fp-impl.c.inc +4 -4
@@ -324,7 +324,7 @@ TRANS(FNABS, do_move_b, 1ULL << 63, tcg_gen_ori_i64); static bool trans_FCPSGN(DisasContext *ctx, arg_FCPSGN *a) { TCGv_i64 t0, t1, t2; - REQUIRE_INSNS_FLAGS2(ctx, ISA205); + REQUIRE_INSNS_FLAGS2(ctx, FP_ISA205); REQUIRE_FPU(ctx); t0 = tcg_temp_new_i64(); t1 = tcg_temp_new_i64();
@@ -592,13 +592,13 @@ static void gen_mtfsf(DisasContext *ctx) flm = FPFLM(ctx->opcode); l = FPL(ctx->opcode); w = FPW(ctx->opcode); - if (unlikely(w & !(ctx->insns_flags2 & PPC2_ISA205))) { + if (unlikely(w & !(ctx->insns_flags2 & PPC2_FP_ISA205))) { gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); return; } if (!l) { t0 = tcg_constant_i32(flm << (w * 8)); - } else if (ctx->insns_flags2 & PPC2_ISA205) { + } else if (ctx->insns_flags2 & PPC2_FP_ISA205) { t0 = tcg_constant_i32(0xffff); } else { t0 = tcg_constant_i32(0xff);
@@ -627,7 +627,7 @@ static void gen_mtfsfi(DisasContext *ctx) } w = FPW(ctx->opcode); bf = FPBF(ctx->opcode); - if (unlikely(w & !(ctx->insns_flags2 & PPC2_ISA205))) { + if (unlikely(w & !(ctx->insns_flags2 & PPC2_FP_ISA205))) { gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); return; }
target/ppc/translate/fp-ops.c.inc +6 -3
@@ -1,14 +1,17 @@ GEN_HANDLER_E(lfdepx, 0x1F, 0x1F, 0x12, 0x00000001, PPC_NONE, PPC2_BOOKE206), -GEN_HANDLER_E(lfiwax, 0x1f, 0x17, 0x1a, 0x00000001, PPC_NONE, PPC2_ISA205), +GEN_HANDLER_E(lfiwax, 0x1f, 0x17, 0x1a, 0x00000001, + PPC_NONE, PPC2_FP_ISA205), GEN_HANDLER_E(lfiwzx, 0x1f, 0x17, 0x1b, 0x1, PPC_NONE, PPC2_FP_CVT_ISA206), -GEN_HANDLER_E(lfdpx, 0x1F, 0x17, 0x18, 0x00200001, PPC_NONE, PPC2_ISA205), +GEN_HANDLER_E(lfdpx, 0x1F, 0x17, 0x18, 0x00200001, + PPC_NONE, PPC2_FP_ISA205), #define GEN_STXF(name, stop, opc2, opc3, type) \ GEN_HANDLER(name##x, 0x1F, opc2, opc3, 0x00000001, type), GEN_STXF(stfiw, st32fiw, 0x17, 0x1E, PPC_FLOAT_STFIWX) GEN_HANDLER_E(stfdepx, 0x1F, 0x1F, 0x16, 0x00000001, PPC_NONE, PPC2_BOOKE206), -GEN_HANDLER_E(stfdpx, 0x1F, 0x17, 0x1C, 0x00200001, PPC_NONE, PPC2_ISA205), +GEN_HANDLER_E(stfdpx, 0x1F, 0x17, 0x1C, 0x00200001, + PPC_NONE, PPC2_FP_ISA205), GEN_HANDLER(mcrfs, 0x3F, 0x00, 0x02, 0x0063F801, PPC_FLOAT), GEN_HANDLER(mtfsb0, 0x3F, 0x06, 0x02, 0x001FF800, PPC_FLOAT),
Signature · 1 line
2.53.0
PATCH v3 13/23 target/ppc: Enable byte comparison and parity on e5500 and e6500
In reply to Bin MengThe e5500 and e6500 implement cmpb, prtyw and prtyd, as listed in table 3-7 of their reference manuals.
Enable only the integer instruction feature flag on these cores. The e500mc explicitly excludes cmpb and prtyw in table 3-1, so keep this feature disabled there. Unsupported floating-point instructions and extended FPSCR access remain disabled.
---
Reference:
- E500MCRM (Rev.3), section 3.1.1
https://www.nxp.com/docs/en/reference-manual/E500MCRM.pdf
- E5500RM (Rev.4), section 3.1.1 and 3.4.3.1.3
https://www.nxp.com/webapp/Download?colCode=E5500RM
- E6500RM (Rev.0), section 3.1.1 and 3.4.3.1.3
https://www.nxp.com/docs/en/reference-manual/E6500RM.pdf
(no changes since v2)
Changes in v2:
- Enable the shared ISA 2.05 integer flag on e5500 and e6500
target/ppc/cpu_init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
target/ppc/cpu_init.c +3 -2
@@ -3216,7 +3216,7 @@ POWERPC_FAMILY(e5500)(ObjectClass *oc, const void *data)PPC_MEM_TLBSYNC |PPC_TLBIVAX |PPC_MEM_SYNC |PPC_64B |PPC_POPCNTB |PPC_POPCNTWD ; pcc->insns_flags2 =PPC2_BOOKE206 |PPC2_PRCNTL |PPC2_PERM_ISA206 | -PPC2_FP_CVT_S64 ; +PPC2_FP_CVT_S64 |PPC2_INT_ISA205 ; pcc->msr_mask = (1ull <<MSR_CM ) | (1ull <<MSR_GS ) | (1ull << MSR_UCLE) |
@@ -3265,7 +3265,8 @@ POWERPC_FAMILY(e6500)(ObjectClass *oc, const void *data)PPC_MEM_TLBSYNC |PPC_TLBIVAX |PPC_MEM_SYNC |PPC_64B |PPC_POPCNTB |PPC_POPCNTWD |PPC_ALTIVEC ; pcc->insns_flags2 =PPC2_BOOKE206 |PPC2_PRCNTL |PPC2_PERM_ISA206 | -PPC2_FP_CVT_S64 |PPC2_ATOMIC_ISA206 ; +PPC2_FP_CVT_S64 |PPC2_ATOMIC_ISA206 | +PPC2_INT_ISA205 ; pcc->msr_mask = (1ull <<MSR_CM ) | (1ull <<MSR_GS ) | (1ull << MSR_UCLE) |
Signature · 1 line
2.53.0
PATCH v3 14/23 target/ppc: Ignore FPSCR W/L fields on e500mc, e5500 and e6500
In reply to Bin MengTable 3-1 of the e500mc, e5500 and e6500 reference manuals specifies that mtfsfi ignores W and mtfsf ignores W and L, behaving as if these fields were zero. The existing translation rejects W=1 without extended FPSCR support and honors L=1, which does not match these cores.
Add a processor behavior flag to ignore these fields without advertising extended FPSCR support. Keep the ordinary field mask and rounding-mode updates effective.
---
Reference:
- E500MCRM (Rev.3), section 3.1.1
https://www.nxp.com/docs/en/reference-manual/E500MCRM.pdf
- E5500RM (Rev.4), section 3.1.1
https://www.nxp.com/webapp/Download?colCode=E5500RM
- E6500RM (Rev.0), section 3.1.1
https://www.nxp.com/docs/en/reference-manual/E6500RM.pdf
(no changes since v2)
Changes in v2:
- Align the FPSCR W/L behavior flag comment ending
target/ppc/cpu.h | 2 ++ target/ppc/cpu_init.c | 9 ++++++--- target/ppc/translate/fp-impl.c.inc | 6 ++++++ 3 files changed, 14 insertions(+), 3 deletions(-)
target/ppc/cpu.h +2 -0
@@ -846,6 +846,8 @@ enum {POWERPC_FLAG_BHRB =0x01000000 ,/* Use PPE42-specific behavior */ POWERPC_FLAG_PPE42 =0x02000000 , +/* Treat FPSCR instruction W and L fields as zero */ + POWERPC_FLAG_FPSCR_IGNORE_WL = 0x04000000, };/*
target/ppc/cpu_init.c +6 -3
@@ -3188,7 +3188,8 @@ POWERPC_FAMILY(e500mc)(ObjectClass *oc, const void *data)/* FIXME: figure out the correct flag for e500mc */ pcc->bfd_mach = bfd_mach_ppc_e500; pcc->flags =POWERPC_FLAG_CE |POWERPC_FLAG_DE | -POWERPC_FLAG_PMM |POWERPC_FLAG_BUS_CLK ; +POWERPC_FLAG_PMM |POWERPC_FLAG_BUS_CLK | +POWERPC_FLAG_FPSCR_IGNORE_WL ; }#ifdef TARGET_PPC64
@@ -3238,7 +3239,8 @@ POWERPC_FAMILY(e5500)(ObjectClass *oc, const void *data)/* FIXME: figure out the correct flag for e5500 */ pcc->bfd_mach = bfd_mach_ppc_e500; pcc->flags =POWERPC_FLAG_CE |POWERPC_FLAG_DE | -POWERPC_FLAG_PMM |POWERPC_FLAG_BUS_CLK ; +POWERPC_FLAG_PMM |POWERPC_FLAG_BUS_CLK | +POWERPC_FLAG_FPSCR_IGNORE_WL ; }static void init_proc_e6500 (CPUPPCState *env)
@@ -3288,7 +3290,8 @@ POWERPC_FAMILY(e6500)(ObjectClass *oc, const void *data) pcc->bus_model = PPC_FLAGS_INPUT_BookE; pcc->bfd_mach = bfd_mach_ppc_e500; pcc->flags =POWERPC_FLAG_CE |POWERPC_FLAG_DE | - POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_VRE; +POWERPC_FLAG_PMM |POWERPC_FLAG_BUS_CLK |POWERPC_FLAG_VRE | + POWERPC_FLAG_FPSCR_IGNORE_WL; }#endif
target/ppc/translate/fp-impl.c.inc +6 -0
@@ -592,6 +592,9 @@ static void gen_mtfsf(DisasContext *ctx) flm = FPFLM(ctx->opcode); l = FPL(ctx->opcode); w = FPW(ctx->opcode); + if (ctx->flags & POWERPC_FLAG_FPSCR_IGNORE_WL) { + l = w = 0; + } if (unlikely(w & !(ctx->insns_flags2 & PPC2_FP_ISA205))) { gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); return;
@@ -627,6 +630,9 @@ static void gen_mtfsfi(DisasContext *ctx) } w = FPW(ctx->opcode); bf = FPBF(ctx->opcode); + if (ctx->flags & POWERPC_FLAG_FPSCR_IGNORE_WL) { + w = 0; + } if (unlikely(w & !(ctx->insns_flags2 & PPC2_FP_ISA205))) { gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); return;
Signature · 1 line
2.53.0
PATCH v3 15/23 tests/tcg/ppc: Add Book E illegal instruction tests
In reply to Bin MengCheck the instruction subsets of e500mc, e5500 and e6500 through the existing TCG test framework. System emulation allows checking SRR0 and ESR on program exceptions. Run e500mc in 32-bit computation mode and e5500/e6500 in 64-bit computation mode.
Add shared ppce500 startup code, a linker script and assembly helpers. Use the existing UART and GPIO power-off devices to report results and terminate QEMU. Register the system targets in ppc/system and ppc64/system, sharing the assembly sources.
Test that unsupported floating-point instructions raise precise illegal instruction exceptions. Also check cmpb, prtyw and prtyd on e500mc.
---
Changes in v3:
- Cover the new system test directories in MAINTAINERS
- Add the missing SPDX license identifier to the README
Changes in v2:
- Rebase the PPC64 test entry onto the Meson variable cleanup
MAINTAINERS | 2 +- meson_options.txt | 4 ++ scripts/meson-buildoptions.sh | 2 + tests/tcg/meson.build | 1 + tests/tcg/ppc/meson.build | 5 ++ tests/tcg/ppc/system/README | 24 ++++++++ tests/tcg/ppc/system/boot.S | 92 ++++++++++++++++++++++++++++++ tests/tcg/ppc/system/isa.out | 1 + tests/tcg/ppc/system/kernel.ld | 18 ++++++ tests/tcg/ppc/system/macros.inc | 56 ++++++++++++++++++ tests/tcg/ppc/system/meson.build | 39 +++++++++++++ tests/tcg/ppc/system/unsupported.S | 31 ++++++++++ tests/tcg/ppc64/meson.build | 2 + tests/tcg/ppc64/system/meson.build | 32 +++++++++++ 14 files changed, 308 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/ppc/meson.build create mode 100644 tests/tcg/ppc/system/README create mode 100644 tests/tcg/ppc/system/boot.S create mode 100644 tests/tcg/ppc/system/isa.out create mode 100644 tests/tcg/ppc/system/kernel.ld create mode 100644 tests/tcg/ppc/system/macros.inc create mode 100644 tests/tcg/ppc/system/meson.build create mode 100644 tests/tcg/ppc/system/unsupported.S create mode 100644 tests/tcg/ppc64/system/meson.build
MAINTAINERS +1 -1
@@ -358,7 +358,7 @@ F: hw/ppc/trace* F: configs/devices/ppc* F: docs/system/ppc/embedded.rst F: docs/system/target-ppc.rst -F: tests/tcg/ppc*/* +F: tests/tcg/ppc*/ F: tests/functional/ppc*/meson.build F: tests/functional/ppc/test_74xx.py
meson_options.txt +4 -0
@@ -469,6 +469,10 @@ option('tcg_tests_cross_cc_or1k', type: 'string', description: 'cc for or1k tcg tests') option('tcg_tests_cross_cflags_or1k', type: 'string', description: 'cflags for or1k tcg tests') +option('tcg_tests_cross_cc_ppc', type: 'string', + description: 'cc for ppc tcg tests') +option('tcg_tests_cross_cflags_ppc', type: 'string', + description: 'cflags for ppc tcg tests') option('tcg_tests_cross_cc_ppc64', type: 'string', description: 'cc for ppc64 tcg tests') option('tcg_tests_cross_cflags_ppc64', type: 'string',
scripts/meson-buildoptions.sh +2 -0
@@ -546,6 +546,7 @@ _meson_option_parse() { --tcg-tests-cross-cc-mips64r6el=*) quote_sh "-Dtcg_tests_cross_cc_mips64r6el=$2" ;; --tcg-tests-cross-cc-mipsel=*) quote_sh "-Dtcg_tests_cross_cc_mipsel=$2" ;; --tcg-tests-cross-cc-or1k=*) quote_sh "-Dtcg_tests_cross_cc_or1k=$2" ;; + --tcg-tests-cross-cc-ppc=*) quote_sh "-Dtcg_tests_cross_cc_ppc=$2" ;; --tcg-tests-cross-cc-ppc64=*) quote_sh "-Dtcg_tests_cross_cc_ppc64=$2" ;; --tcg-tests-cross-cc-ppc64le=*) quote_sh "-Dtcg_tests_cross_cc_ppc64le=$2" ;; --tcg-tests-cross-cc-riscv32=*) quote_sh "-Dtcg_tests_cross_cc_riscv32=$2" ;;
@@ -574,6 +575,7 @@ _meson_option_parse() { --tcg-tests-cross-cflags-mips64r6el=*) quote_sh "-Dtcg_tests_cross_cflags_mips64r6el=$2" ;; --tcg-tests-cross-cflags-mipsel=*) quote_sh "-Dtcg_tests_cross_cflags_mipsel=$2" ;; --tcg-tests-cross-cflags-or1k=*) quote_sh "-Dtcg_tests_cross_cflags_or1k=$2" ;; + --tcg-tests-cross-cflags-ppc=*) quote_sh "-Dtcg_tests_cross_cflags_ppc=$2" ;; --tcg-tests-cross-cflags-ppc64=*) quote_sh "-Dtcg_tests_cross_cflags_ppc64=$2" ;; --tcg-tests-cross-cflags-ppc64le=*) quote_sh "-Dtcg_tests_cross_cflags_ppc64le=$2" ;; --tcg-tests-cross-cflags-riscv32=*) quote_sh "-Dtcg_tests_cross_cflags_riscv32=$2" ;;
tests/tcg/meson.build +1 -0
@@ -180,6 +180,7 @@ subdir('mipsel') subdir('mips64') subdir('mips64el') subdir('or1k') +subdir('ppc') subdir('ppc64') subdir('ppc64le') subdir('riscv32')
tests/tcg/ppc/meson.build new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (c) 2026 Process Mission + +subdir('system')
tests/tcg/ppc/system/README new file +24 -0
@@ -0,0 +1,24 @@ +SPDX-License-Identifier: GPL-2.0-or-later + +These Book E ISA tests use the generic tests/tcg build and test runner. +They run on ppce500 with e500mc, e5500 and e6500 CPU models. System mode +allows checking SRR0 and ESR on illegal instructions. The ppc target runs +e500mc in 32-bit computation mode; ppc64 runs e5500/e6500 in 64-bit mode. + +The cross compiler builds freestanding ELF32 executables for ppc with +-m32 and ELF64 executables for ppc64 with -m64. No target libc or +multilib runtime is needed. The boot stub uses the initial RAM mapping +provided by ppce500 -kernel, maps the CCSR area, and installs a program +exception handler. Results go to UART0, and the existing GPIO power-off +line terminates QEMU. The standard run_and_diff wrapper compares the +output with isa.out. + +Configure QEMU with ppc-softmmu and/or ppc64-softmmu enabled. Compilers +are found through the usual TCG cross-compiler detection or containers; +--cross-cc-ppc and --cross-cc-ppc64 can select them explicitly. Run with: + + make check-tcg-ppc-softmmu + make check-tcg-ppc64-softmmu + +These targets are generated only when configure finds a usable cross +compiler or container. If missing, check the TCG tests configure summary.
tests/tcg/ppc/system/boot.S new file +92 -0
92 lines not on this page · raw message
tests/tcg/ppc/system/isa.out new file +1 -0
@@ -0,0 +1 @@ +ISA:PASS
tests/tcg/ppc/system/kernel.ld new file +18 -0
@@ -0,0 +1,18 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (c) 2026 Process Mission + */ + +ENTRY(_start) + +SECTIONS +{ + . = 0x100000; + .text : { *(.text.start) *(.text) } + . = ALIGN(0x10000); + .vectors : { *(.vectors) } + .rodata : { *(.rodata) } + .data : { *(.data) } + .bss : { *(.bss) } +}
tests/tcg/ppc/system/macros.inc new file +56 -0
56 lines not on this page · raw message
tests/tcg/ppc/system/meson.build new file +39 -0
@@ -0,0 +1,39 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (c) 2026 Process Mission + +# Shared settings and sources for the ppc and ppc64 system targets +ppc_system_link_script = files('kernel.ld')[0] +ppc_system_boot = files('boot.S')[0] +ppc_system_cflags = ['-nostdlib', '-ffreestanding', '-mcpu=power6', + '-Wa,-mregnames', '-Wa,--noexecstack', + '-Wl,--build-id=none', + '-Wl,-T', ppc_system_link_script, ppc_system_boot] +ppc_system_qemu_args = ['-M', 'ppce500', '-accel', 'tcg', '-display', 'none', + '-serial', 'stdio', '-monitor', 'none', '-nic', 'none'] +ppc_system_sources = ['unsupported.S'] + +tests = [] +foreach src: ppc_system_sources + tests += { + 'system/' + src: { + 'exe_name': fs.stem(src) + '-e500mc-32', + 'cflags': ppc_system_cflags + ['-m32', '-DE500MC'], + 'qemu_args': ppc_system_qemu_args + ['-cpu', 'e500mc', '-kernel'], + 'expected_output': 'system/isa.out', + } + } +endforeach + +if 'qemu-system-ppc' in emulators + tcg_tests += { + 'ppc-softmmu': { + 'cc': 'powerpc-linux-gnu-gcc', + 'cc_dockerfile': 'debian-all-test-cross', + 'folder': 'ppc', + 'gdb_arch': 'ppc', + 'qemu': emulators['qemu-system-ppc'], + 'tests': tests, + } + } +endif
tests/tcg/ppc/system/unsupported.S new file +31 -0
@@ -0,0 +1,31 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (c) 2026 Process Mission + */ + +#include "macros.inc" + + .text + .globl test_main +test_main: + /* Valid memory prevents address faults from hiding decode errors */ + load_addr r4, scratch + check_illegal fcpsgn f0, f0, f0 + check_illegal fcpsgn. f0, f0, f0 + check_illegal lfiwax f0, 0, r4 + check_illegal lfdp f0, 0(r4) + check_illegal lfdpx f0, 0, r4 + check_illegal stfdp f0, 0(r4) + check_illegal stfdpx f0, 0, r4 +#ifdef E500MC + check_illegal cmpb r11, r9, r10 + check_illegal prtyw r11, r9 + check_illegal prtyd r11, r9 +#endif + b pass + + .data + .balign 16 +scratch: + .space 16
tests/tcg/ppc64/meson.build +2 -0
@@ -1,3 +1,5 @@ +subdir('system') + tests = [] # Multi arch tests
tests/tcg/ppc64/system/meson.build new file +32 -0
@@ -0,0 +1,32 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (c) 2026 Process Mission + +ppc64_system_cflags = ppc_system_cflags + ['-m64'] +tests = [] +foreach cpu: ['e5500', 'e6500'] + sources = ppc_system_sources + foreach src: sources + tests += { + '../ppc/system/' + src: { + 'exe_name': fs.stem(src) + '-' + cpu + '-64', + 'cflags': ppc64_system_cflags, + 'qemu_args': ppc_system_qemu_args + ['-cpu', cpu, '-kernel'], + 'expected_output': '../ppc/system/isa.out', + } + } + endforeach +endforeach + +if 'qemu-system-ppc64' in emulators + tcg_tests += { + 'ppc64-softmmu': { + 'cc': 'powerpc64-linux-gnu-gcc', + 'cc_dockerfile': 'debian-all-test-cross', + 'folder': 'ppc64', + 'gdb_arch': 'ppc64', + 'qemu': emulators['qemu-system-ppc64'], + 'tests': tests, + } + } +endif
Signature · 1 line
2.53.0
PATCH v3 16/23 tests/tcg/ppc: Test byte comparison and parity on e5500/e6500
In reply to Bin MengThe e5500 and e6500 implement cmpb, prtyw and prtyd. Check matching-byte masks and parity results, including the separate word results in a 64-bit register and parity based on the low bit of each byte.
Use inputs with odd parity in bits above each byte's low bit to reject implementations that compute parity over all bits.
Add the test to the existing Book E matrix for e5500 and e6500 in 64-bit mode.
---
(no changes since v1)
tests/tcg/ppc/system/byte-parity.S | 33 ++++++++++++++++++++++++++++++ tests/tcg/ppc64/system/meson.build | 1 + 2 files changed, 34 insertions(+) create mode 100644 tests/tcg/ppc/system/byte-parity.S
tests/tcg/ppc/system/byte-parity.S new file +33 -0
@@ -0,0 +1,33 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (c) 2026 Process Mission + */ + +#include "macros.inc" + + .text + .globl test_main +test_main: + load_value r9, 0x1122334455667788 + load_value r10, 0x1122994455660088 + cmpb r11, r9, r10 + check_value r11, 0xffff00ffffff00ff + + .macro parity value, word, doubleword + load_value r9, \value + prtyw r11, r9 + check_value r11, \word +#ifdef _LP64 + prtyd r11, r9 + check_value r11, \doubleword +#endif + .endm + + /* Parity uses the least significant bit of each byte */ + parity 0x0101010100010000, 1, 1 + parity 0x0001010100010000, 0x100000001, 0 + parity 0x8080808002020202, 0, 0 + parity 0x0000000000000080, 0, 0 + parity 0x8000000000000000, 0, 0 + b pass
tests/tcg/ppc64/system/meson.build +1 -0
@@ -6,6 +6,7 @@ ppc64_system_cflags = ppc_system_cflags + ['-m64'] tests = [] foreach cpu: ['e5500', 'e6500'] sources = ppc_system_sources + sources += ['byte-parity.S'] foreach src: sources tests += { '../ppc/system/' + src: {
Signature · 1 line
2.53.0
PATCH v3 17/23 tests/tcg/ppc: Test FPSCR W/L handling on e500mc/e5500/e6500
In reply to Bin MengThe e500mc, e5500 and e6500 ignore W in mtfsfi and W/L in mtfsf. Check that these fields do not select extended FPSCR fields, cause illegal instruction exceptions or override the ordinary field mask.
Test both W values, all W/L combinations and the Rc variants. Seed ZE and RN before each instruction so partial and zero field masks verify that unaffected fields remain intact and selected fields receive the expected values. Ignore the undefined upper word returned by mffs.
Register the test for e500mc in 32-bit mode and for e5500/e6500 in 64-bit mode, using the shared Book E startup and result handling.
---
(no changes since v1)
tests/tcg/ppc/system/fpscr.S | 75 ++++++++++++++++++++++++++++++++ tests/tcg/ppc/system/meson.build | 2 +- 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/ppc/system/fpscr.S
tests/tcg/ppc/system/fpscr.S new file +75 -0
@@ -0,0 +1,75 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (c) 2026 Process Mission + */ + +#include "macros.inc" + + .macro seed_fpscr + mtfsf 255, f2 + mtfsfi 6, 1 /* ZE */ + mtfsfi 7, 2 /* RN */ + .endm + + .macro check_fpscr expected + mffs f1 + stfd f1, 8(r4) + lwz r11, 12(r4) + load32 r12, \expected + cmpw r11, r12 + bne fail + .endm + + .macro test_mtfsfi field, value, w, record, expected + seed_fpscr + .if \record + mtfsfi. \field, \value, \w + .else + mtfsfi \field, \value, \w + .endif + check_fpscr \expected + .endm + + .macro test_mtfsf mask, w, l, record, expected + seed_fpscr + .if \record + mtfsf. \mask, f0, \l, \w + .else + mtfsf \mask, f0, \l, \w + .endif + check_fpscr \expected + .endm + + .text + .globl test_main +test_main: + load_addr r4, scratch + lfd f0, 0(r4) /* Source: upper word 3, lower word 1 */ + lfd f2, 16(r4) /* Zero for a reproducible initial FPSCR */ + + .irp w, 0, 1 + .irp record, 0, 1 + test_mtfsfi 6, 4, \w, \record, 0x42 + test_mtfsfi 7, 1, \w, \record, 0x11 + .endr + .endr + + .irp w, 0, 1 + .irp l, 0, 1 + .irp record, 0, 1 + /* L must not override the ordinary field mask, and W is ignored */ + test_mtfsf 0, \w, \l, \record, 0x12 + test_mtfsf 1, \w, \l, \record, 0x11 + test_mtfsf 2, \w, \l, \record, 0x02 + test_mtfsf 255, \w, \l, \record, 0x01 + .endr + .endr + .endr + b pass + + .data + .balign 8 +scratch: + .long 3, 1 + .space 16
tests/tcg/ppc/system/meson.build +1 -1
@@ -11,7 +11,7 @@ ppc_system_cflags = ['-nostdlib', '-ffreestanding', '-mcpu=power6', '-Wl,-T', ppc_system_link_script, ppc_system_boot] ppc_system_qemu_args = ['-M', 'ppce500', '-accel', 'tcg', '-display', 'none', '-serial', 'stdio', '-monitor', 'none', '-nic', 'none'] -ppc_system_sources = ['unsupported.S'] +ppc_system_sources = ['unsupported.S', 'fpscr.S'] tests = [] foreach src: ppc_system_sources
Signature · 1 line
2.53.0
PATCH v3 18/23 target/ppc: Build e6500 MMUCFG values from field encodings
In reply to Bin MengAdd field encoders for TLB count, PID count, PID width, real address width and LPID width for the MMUCFG register. Compose the e6500 configuration from these encoders. The value remains 0x06510b45.
---
Changes in v3:
- New
target/ppc/cpu.h | 24 +++++++++++++++--------- target/ppc/cpu_init.c | 4 +++- 2 files changed, 18 insertions(+), 10 deletions(-)
target/ppc/cpu.h +15 -9
@@ -1120,15 +1120,21 @@ FIELD(FPSCR, FI, FPSCR_FI, 1)#define MAS8_TLBPID 0x00000fff/* Bit definitions for MMUCFG */ -#define MMUCFG_MAVN 0x00000003/* MMU Architecture Version Number */ -#define MMUCFG_MAVN_V1 0x00000000/* v1.0 */ -#define MMUCFG_MAVN_V2 0x00000001/* v2.0 */ -#define MMUCFG_NTLBS 0x0000000c/* Number of TLBs */ -#define MMUCFG_PIDSIZE 0x000007c0/* PID Reg Size */ -#define MMUCFG_TWC 0x00008000/* TLB Write Conditional (v2.0) */ -#define MMUCFG_LRAT 0x00010000/* LRAT Supported (v2.0) */ -#define MMUCFG_RASIZE 0x00fe0000/* Real Addr Size */ -#define MMUCFG_LPIDSIZE 0x0f000000/* LPID Reg Size */ +#define MMUCFG_MAVN 0x00000003/* MMU Architecture Version Number */ +#define MMUCFG_MAVN_V1 0x00000000/* v1.0 */ +#define MMUCFG_MAVN_V2 0x00000001/* v2.0 */ +#define MMUCFG_NTLBS_MASK 0x0000000c/* Number of TLBs minus one */ +#define MMUCFG_NTLBS (n) (((n) - 1U) << 2) +#define MMUCFG_PIDSIZE_MASK 0x000007c0/* PID width minus one */ +#define MMUCFG_PIDSIZE (n) (((n) - 1U) << 6) +#define MMUCFG_NPIDS_MASK 0x00007800/* Number of PID registers */ +#define MMUCFG_NPIDS (n) ((n) << 11) +#define MMUCFG_TWC 0x00008000/* TLB Write Conditional (v2.0) */ +#define MMUCFG_LRAT 0x00010000/* LRAT Supported (v2.0) */ +#define MMUCFG_RASIZE_MASK 0x00fe0000/* Real address width */ +#define MMUCFG_RASIZE (n) ((n) << 17) +#define MMUCFG_LPIDSIZE_MASK 0x0f000000/* LPID width */ +#define MMUCFG_LPIDSIZE (n) ((n) << 24)/* Bit definitions for MMUCSR0 */ #define MMUCSR0_TLB1FI 0x00000002/* TLB1 Flash invalidate */
target/ppc/cpu_init.c +3 -1
@@ -2865,7 +2865,9 @@ static void init_proc_e500(CPUPPCState *env, int version) tlbncfg[1 ] =register_tlbncfg (64 ,1 ,12 , TLBnCFG_AVAIL | TLBnCFG_IPROT,64 );break ;case fsl_e6500: - mmucfg =0x6510B45 ; + mmucfg =MMUCFG_MAVN_V2 |MMUCFG_NTLBS (2 ) | +MMUCFG_NPIDS (1 ) |MMUCFG_PIDSIZE (14 ) |MMUCFG_LRAT | +MMUCFG_RASIZE (40 ) |MMUCFG_LPIDSIZE (6 ); env->nb_pids =1 ; tlbncfg[0 ] =0x08052400 ; tlbncfg[1 ] =0x40028040 ;
Signature · 1 line
2.53.0
PATCH v3 19/23 target/ppc: Complete MMU configuration for e500 family cores
In reply to Bin MengAdd the missing MMUCFG register initialization for the e500v1, e500v2, e500mc and e5500 models.
For e500v1/v2, use 0x000019c4 from the field definitions in the PowerPC e500 Core Family Reference Manual, revision 1, section 2.12.3. For e500mc and e5500, use the shared 0x064809c4 configuration, which matches the e500mc Core Reference Manual, revision 3, section 2.16.4, and e5500RM revision 4, section 2.16.4.
---
Changes in v3:
- New
target/ppc/cpu_init.c | 7 +++++++ 1 file changed, 7 insertions(+)
target/ppc/cpu_init.c +7 -0
@@ -2852,15 +2852,22 @@ static void init_proc_e500(CPUPPCState *env, int version) env->nb_ways =2 ;switch (version) {case fsl_e500v1: + mmucfg =MMUCFG_MAVN_V1 |MMUCFG_NTLBS (2 ) | +MMUCFG_NPIDS (3 ) |MMUCFG_PIDSIZE (8 ); tlbncfg[0 ] =register_tlbncfg (2 ,1 ,1 ,0 ,256 ); tlbncfg[1 ] =register_tlbncfg (16 ,1 ,9 , TLBnCFG_AVAIL | TLBnCFG_IPROT,16 );break ;case fsl_e500v2: + mmucfg =MMUCFG_MAVN_V1 |MMUCFG_NTLBS (2 ) | +MMUCFG_NPIDS (3 ) |MMUCFG_PIDSIZE (8 ); tlbncfg[0 ] =register_tlbncfg (4 ,1 ,1 ,0 ,512 ); tlbncfg[1 ] =register_tlbncfg (16 ,1 ,12 , TLBnCFG_AVAIL | TLBnCFG_IPROT,16 );break ;case fsl_e500mc:case fsl_e5500: + mmucfg =MMUCFG_MAVN_V1 |MMUCFG_NTLBS (2 ) | +MMUCFG_NPIDS (1 ) |MMUCFG_PIDSIZE (8 ) | +MMUCFG_RASIZE (36 ) |MMUCFG_LPIDSIZE (6 ); tlbncfg[0 ] =register_tlbncfg (4 ,1 ,1 ,0 ,512 ); tlbncfg[1 ] =register_tlbncfg (64 ,1 ,12 , TLBnCFG_AVAIL | TLBnCFG_IPROT,64 );break ;
Signature · 1 line
2.53.0
PATCH v3 20/23 target/ppc: Limit e500mc and e5500 to one PID register
In reply to Bin MengThe e500mc and e5500 implement only PID0, but inherit the default of three PID registers. This incorrectly exposes PID1 and PID2 through register_BookE206_sprs().
Set nb_pids to one in their shared initialization, matching MMUCFG[NPIDS] and the e500mc Core Reference Manual, revision 3, section 2.16.4, and e5500RM revision 4, section 2.16.4.
---
Changes in v3:
- New
target/ppc/cpu_init.c | 1 + 1 file changed, 1 insertion(+)
target/ppc/cpu_init.c +1 -0
@@ -2868,6 +2868,7 @@ static void init_proc_e500(CPUPPCState *env, int version) mmucfg =MMUCFG_MAVN_V1 |MMUCFG_NTLBS (2 ) |MMUCFG_NPIDS (1 ) |MMUCFG_PIDSIZE (8 ) |MMUCFG_RASIZE (36 ) |MMUCFG_LPIDSIZE (6 ); + env->nb_pids =1 ; tlbncfg[0 ] =register_tlbncfg (4 ,1 ,1 ,0 ,512 ); tlbncfg[1 ] =register_tlbncfg (64 ,1 ,12 , TLBnCFG_AVAIL | TLBnCFG_IPROT,64 );break ;
Signature · 1 line
2.53.0
PATCH v3 21/23 target/ppc: Express e6500 TLB configuration with named fields
In reply to Bin MengUse register_tlbncfg() with the existing named flags for better readability. The register values remain 0x08052400 and 0x40028040.
---
Changes in v3:
- New
target/ppc/cpu_init.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
target/ppc/cpu_init.c +6 -2
@@ -2877,8 +2877,12 @@ static void init_proc_e500(CPUPPCState *env, int version)MMUCFG_NPIDS (1 ) |MMUCFG_PIDSIZE (14 ) |MMUCFG_LRAT |MMUCFG_RASIZE (40 ) |MMUCFG_LPIDSIZE (6 ); env->nb_pids =1 ; - tlbncfg[0 ] =0x08052400 ; - tlbncfg[1 ] =0x40028040 ; +/* MMU v2 reports page sizes through TLBnPS */ + tlbncfg[0 ] =register_tlbncfg (8 ,0 ,0 , + TLBnCFG_PT | TLBnCFG_GTWE | TLBnCFG_HES, +1024 ); + tlbncfg[1 ] =register_tlbncfg (64 ,0 ,0 , + TLBnCFG_IND | TLBnCFG_IPROT,64 );break ;default : cpu_abort(env_cpu(env), "Unknown CPU: " TARGET_FMT_lx "\n",
Signature · 1 line
2.53.0
PATCH v3 22/23 target/ppc: Keep embedded processor control within 32 bits
In reply to Bin MengEPCR is a 32-bit register documented in EREF section 4.6.3.
---
Changes in v3:
- New
target/ppc/cpu_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/cpu_init.c +1 -1
@@ -3030,7 +3030,7 @@ static void init_proc_e500(CPUPPCState *env, int version)if ((version == fsl_e5500) || (version == fsl_e6500)) {spr_register (env,SPR_BOOKE_EPCR ,"EPCR" ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_write_generic32,0x00000000 ); spr_register(env, SPR_BOOKE_MAS7_MAS3, "MAS7_MAS3", SPR_NOACCESS, SPR_NOACCESS,
Signature · 1 line
2.53.0
PATCH v3 23/23 target/ppc: Match e500mc/e5500/e6500 host PVR revisions
In reply to Bin MengThe generic models use PVRs 0x80230020, 0x80240020 and 0x80400020. The default PVR callback is an exact comparison, so KVM's fallback lookup fails on various P/T-series SoCs and the VMM cannot register the host CPU type.
Match the architected core-version field in the upper 16 bits for all three families, allowing differences in the revision field.
---
Changes in v3:
- New
target/ppc/cpu_init.c | 9 +++++++++ 1 file changed, 9 insertions(+)
target/ppc/cpu_init.c +9 -0
@@ -3159,6 +3159,12 @@ POWERPC_FAMILY(e500v2)(ObjectClass *oc, const void *data)POWERPC_FLAG_BUS_CLK ; } +static bool ppc_pvr_match_booke (PowerPCCPUClass *pcc,uint32_t pvr,bool best) +{ +/* Match the core version while allowing hardware revision differences */ +return (pvr &0xffff0000 ) == (pcc->pvr &0xffff0000 ); +} +static void init_proc_e500mc (CPUPPCState *env) {init_proc_e500 (env, fsl_e500mc);
@@ -3170,6 +3176,7 @@ POWERPC_FAMILY(e500mc)(ObjectClass *oc, const void *data)PowerPCCPUClass *pcc =POWERPC_CPU_CLASS (oc); dc->desc ="e500mc core" ; + pcc->pvr_match = ppc_pvr_match_booke; pcc->init_proc = init_proc_e500mc; pcc->check_pow = check_pow_none; pcc->check_attn = check_attn_none;
@@ -3218,6 +3225,7 @@ POWERPC_FAMILY(e5500)(ObjectClass *oc, const void *data)PowerPCCPUClass *pcc =POWERPC_CPU_CLASS (oc); dc->desc ="e5500 core" ; + pcc->pvr_match = ppc_pvr_match_booke; pcc->init_proc = init_proc_e5500; pcc->check_pow = check_pow_none; pcc->check_attn = check_attn_none;
@@ -3268,6 +3276,7 @@ POWERPC_FAMILY(e6500)(ObjectClass *oc, const void *data)PowerPCCPUClass *pcc =POWERPC_CPU_CLASS (oc); dc->desc ="e6500 core" ; + pcc->pvr_match = ppc_pvr_match_booke; pcc->init_proc = init_proc_e6500; pcc->check_pow = check_pow_none; pcc->check_attn = check_attn_none;
Signature · 1 line
2.53.0
Re: [PATCH v3 23/23] target/ppc: Match e500mc/e5500/e6500 host PVR revisions
Quoted 24 lines · Bin Meng
The generic models use PVRs
0x80230020,0x80240020and0x80400020. The default PVR callback is an exact comparison, so KVM's fallback lookup fails on various P/T-series SoCs and the VMM cannot register the host CPU type.Match the architected core-version field in the upper 16 bits for all three families, allowing differences in the revision field.
Signed-off-by Bin Meng <[email protected]>---
Changes in v3:
- New
target/ppc/cpu_init.c| 9 +++++++++1 file changed, 9 insertions(+)target/ppc/cpu_init.c +0
-0
target/ppc/cpu_init.c POWERPC_FAMILY(e500v2)(ObjectClass *oc, const void *data) · line 3162
Quoted 4 lines
target/ppc/cpu_init.c +1
-0@@ -3159,6 +3159,12 @@ POWERPC_FAMILY(e500v2)(ObjectClass *oc, const void *data)POWERPC_FLAG_BUS_CLK ; } +static bool ppc_pvr_match_booke (PowerPCCPUClass *pcc,uint32_t pvr,bool best)
Not sure how booke specific is this. Why not call it _match_core if that's what it does? But it's not a big deal so probably does not worth a respin if there are no changes needed otherwise.
Regards,
BALATON Zoltan
Quoted 33 lines
target/ppc/cpu_init.c +8
-0+{ +/* Match the core version while allowing hardware revision differences */ +return (pvr &0xffff0000 ) == (pcc->pvr &0xffff0000 ); +} +static void init_proc_e500mc (CPUPPCState *env) {init_proc_e500 (env, fsl_e500mc);@@ -3170,6 +3176,7 @@ POWERPC_FAMILY(e500mc)(ObjectClass *oc, const void *data)PowerPCCPUClass *pcc =POWERPC_CPU_CLASS (oc); dc->desc ="e500mc core" ; + pcc->pvr_match = ppc_pvr_match_booke; pcc->init_proc = init_proc_e500mc; pcc->check_pow = check_pow_none; pcc->check_attn = check_attn_none;@@ -3218,6 +3225,7 @@ POWERPC_FAMILY(e5500)(ObjectClass *oc, const void *data)PowerPCCPUClass *pcc =POWERPC_CPU_CLASS (oc); dc->desc ="e5500 core" ; + pcc->pvr_match = ppc_pvr_match_booke; pcc->init_proc = init_proc_e5500; pcc->check_pow = check_pow_none; pcc->check_attn = check_attn_none;@@ -3268,6 +3276,7 @@ POWERPC_FAMILY(e6500)(ObjectClass *oc, const void *data)PowerPCCPUClass *pcc =POWERPC_CPU_CLASS (oc); dc->desc ="e6500 core" ; + pcc->pvr_match = ppc_pvr_match_booke; pcc->init_proc = init_proc_e6500; pcc->check_pow = check_pow_none; pcc->check_attn = check_attn_none;
Quoted 102 lines · Bin Meng
This series corrects SPR access, cache and MMU configuration, and instruction availability in the Freescale Book E CPU models. It also fixes host PVR matching and adds system TCG tests for e500mc, e5500 and e6500.
The patches are grouped as follows:
- patch #1-#3 and #5, bug fixes to PIR write access, the MAS5 SPR number and cache block/line sizes (qemu-stable cc'ed)
- patch #4 and #6, complete e500mc/e5500 L1 cache configuration and remove redundant e6500 cache geometry bits
- patch #7-#11, register the missing cache, MMU-assist and several control SPRs
- patch #12-#14, split the PowerISA 2.05 instructions into integer and floating-point groups, due to differences seen on e500 series cores
- patch #15-#17: Add TCG tests for illegal-instruction exceptions, byte comparison and parity results, and FPSCR field-mask handling
- patch #18-#21, complete the e500 family MMU configuration, correct PID register counts and express MMUCFG/TLBnCFG with named fields
- patch #22-#23, fix EPCR write width and host PVR revision matching for Book E KVMChanges in v3:
- Cover the new system test directories inMAINTAINERS
- Add the missing SPDX license identifier to the README
- target/ppc: Build e6500 MMUCFG values from field encodings
- target/ppc: Complete MMU configuration for e500 family cores
- target/ppc: Limit e500mc and e5500 to one PID register
- target/ppc: Express e6500 TLB configuration with named fields
- target/ppc: Keep embedded processor control within 32 bits
- target/ppc: Match e500mc/e5500/e6500 host PVR revisionsChanges in v2:
- Group ISA 2.05 features into integer and floating-point flags
- Use the first free bit for the floating-point group
- Align flag definitions and comment endings
- Enable the shared ISA 2.05 integer flag on e5500 and e6500
- Align the FPSCR W/L behavior flag comment ending
- Rebase the PPC64 test entry onto the Meson variable cleanupBin Meng (23):
target/ppc: Correct PIR write access on e500 cores target/ppc: Correct the MAS5 SPR number
target/ppc: Correct the e500mc and e5500 cache block size fields target/ppc: Complete e500mc and e5500 L1 cache configuration target/ppc: Correct cache line size for e6500 target/ppc: Drop redundant e6500 L1 cache geometry bits target/ppc: Register L1CSR2 on e500mc/e5500/e6500 cores target/ppc: Register L2CFG0 and L2CSR1 on e500mc and e5500 target/ppc: Register MAS5 and MAS8 on e500mc/e5500/e6500 target/ppc: Register PWRMGTCR0 on e6500
target/ppc: Register IVOR42 on e6500
target/ppc: Split the ISA 2.05 instruction feature group target/ppc: Enable byte comparison and parity on e5500 and e6500 target/ppc: Ignore FPSCR W/L fields on e500mc, e5500 and e6500 tests/tcg/ppc: Add Book E illegal instruction tests tests/tcg/ppc: Test byte comparison and parity on e5500/e6500 tests/tcg/ppc: Test FPSCR W/L handling on e500mc/e5500/e6500 target/ppc: Build e6500 MMUCFG values from field encodings target/ppc: Complete MMU configuration for e500 family cores target/ppc: Limit e500mc and e5500 to one PID register target/ppc: Express e6500 TLB configuration with named fields target/ppc: Keep embedded processor control within 32 bits target/ppc: Match e500mc/e5500/e6500 host PVR revisionsMAINTAINERS | 2 +- target/ppc/cpu.h | 45 ++++++---- target/ppc/cpu_init.h | 3 +- target/ppc/cpu_init.c | 99 +++++++++++++++++----- target/ppc/translate.c | 10 ++- target/ppc/translate/fixedpoint-impl.c.inc | 6 +- target/ppc/translate/fp-impl.c.inc | 14 ++- target/ppc/translate/fp-ops.c.inc | 9 +- meson_options.txt | 4 + scripts/meson-buildoptions.sh | 2 + tests/tcg/meson.build | 1 + tests/tcg/ppc/meson.build | 5 ++ tests/tcg/ppc/system/README | 24 ++++++ tests/tcg/ppc/system/boot.S | 92 ++++++++++++++++++++ tests/tcg/ppc/system/byte-parity.S | 33 ++++++++ tests/tcg/ppc/system/fpscr.S | 75 ++++++++++++++++ tests/tcg/ppc/system/isa.out | 1 + tests/tcg/ppc/system/kernel.ld | 18 ++++ tests/tcg/ppc/system/macros.inc | 56 ++++++++++++ tests/tcg/ppc/system/meson.build | 39 +++++++++ tests/tcg/ppc/system/unsupported.S | 31 +++++++ tests/tcg/ppc64/meson.build | 2 + tests/tcg/ppc64/system/meson.build | 33 ++++++++ 23 files changed, 554 insertions(+), 50 deletions(-) create mode 100644 tests/tcg/ppc/meson.build create mode 100644 tests/tcg/ppc/system/README create mode 100644 tests/tcg/ppc/system/boot.S create mode 100644 tests/tcg/ppc/system/byte-parity.S create mode 100644 tests/tcg/ppc/system/fpscr.S create mode 100644 tests/tcg/ppc/system/isa.out create mode 100644 tests/tcg/ppc/system/kernel.ld create mode 100644 tests/tcg/ppc/system/macros.inc create mode 100644 tests/tcg/ppc/system/meson.build create mode 100644 tests/tcg/ppc/system/unsupported.S create mode 100644 tests/tcg/ppc64/system/meson.build
Quoted 1 line
---
Ping for review?
Am 16. November 2026 01:34:29 UTC schrieb Bin Meng <[email protected]>:
Quoted 103 lines · Bin Meng
Quoted 102 lines
This series corrects SPR access, cache and MMU configuration, and instruction availability in the Freescale Book E CPU models. It also fixes host PVR matching and adds system TCG tests for e500mc, e5500 and e6500.
The patches are grouped as follows:
- patch #1-#3 and #5, bug fixes to PIR write access, the MAS5 SPR number and cache block/line sizes (qemu-stable cc'ed)
- patch #4 and #6, complete e500mc/e5500 L1 cache configuration and remove redundant e6500 cache geometry bits
- patch #7-#11, register the missing cache, MMU-assist and several control SPRs
- patch #12-#14, split the PowerISA 2.05 instructions into integer and floating-point groups, due to differences seen on e500 series cores
- patch #15-#17: Add TCG tests for illegal-instruction exceptions, byte comparison and parity results, and FPSCR field-mask handling
- patch #18-#21, complete the e500 family MMU configuration, correct PID register counts and express MMUCFG/TLBnCFG with named fields
- patch #22-#23, fix EPCR write width and host PVR revision matching for Book E KVMChanges in v3:
- Cover the new system test directories inMAINTAINERS
- Add the missing SPDX license identifier to the README
- target/ppc: Build e6500 MMUCFG values from field encodings
- target/ppc: Complete MMU configuration for e500 family cores
- target/ppc: Limit e500mc and e5500 to one PID register
- target/ppc: Express e6500 TLB configuration with named fields
- target/ppc: Keep embedded processor control within 32 bits
- target/ppc: Match e500mc/e5500/e6500 host PVR revisionsChanges in v2:
- Group ISA 2.05 features into integer and floating-point flags
- Use the first free bit for the floating-point group
- Align flag definitions and comment endings
- Enable the shared ISA 2.05 integer flag on e5500 and e6500
- Align the FPSCR W/L behavior flag comment ending
- Rebase the PPC64 test entry onto the Meson variable cleanupBin Meng (23):
target/ppc: Correct PIR write access on e500 cores target/ppc: Correct the MAS5 SPR number
target/ppc: Correct the e500mc and e5500 cache block size fields target/ppc: Complete e500mc and e5500 L1 cache configuration target/ppc: Correct cache line size for e6500 target/ppc: Drop redundant e6500 L1 cache geometry bits target/ppc: Register L1CSR2 on e500mc/e5500/e6500 cores target/ppc: Register L2CFG0 and L2CSR1 on e500mc and e5500 target/ppc: Register MAS5 and MAS8 on e500mc/e5500/e6500 target/ppc: Register PWRMGTCR0 on e6500
target/ppc: Register IVOR42 on e6500
target/ppc: Split the ISA 2.05 instruction feature group target/ppc: Enable byte comparison and parity on e5500 and e6500 target/ppc: Ignore FPSCR W/L fields on e500mc, e5500 and e6500 tests/tcg/ppc: Add Book E illegal instruction tests tests/tcg/ppc: Test byte comparison and parity on e5500/e6500 tests/tcg/ppc: Test FPSCR W/L handling on e500mc/e5500/e6500 target/ppc: Build e6500 MMUCFG values from field encodings target/ppc: Complete MMU configuration for e500 family cores target/ppc: Limit e500mc and e5500 to one PID register target/ppc: Express e6500 TLB configuration with named fields target/ppc: Keep embedded processor control within 32 bits target/ppc: Match e500mc/e5500/e6500 host PVR revisionsMAINTAINERS | 2 +- target/ppc/cpu.h | 45 ++++++---- target/ppc/cpu_init.h | 3 +- target/ppc/cpu_init.c | 99 +++++++++++++++++----- target/ppc/translate.c | 10 ++- target/ppc/translate/fixedpoint-impl.c.inc | 6 +- target/ppc/translate/fp-impl.c.inc | 14 ++- target/ppc/translate/fp-ops.c.inc | 9 +- meson_options.txt | 4 + scripts/meson-buildoptions.sh | 2 + tests/tcg/meson.build | 1 + tests/tcg/ppc/meson.build | 5 ++ tests/tcg/ppc/system/README | 24 ++++++ tests/tcg/ppc/system/boot.S | 92 ++++++++++++++++++++ tests/tcg/ppc/system/byte-parity.S | 33 ++++++++ tests/tcg/ppc/system/fpscr.S | 75 ++++++++++++++++ tests/tcg/ppc/system/isa.out | 1 + tests/tcg/ppc/system/kernel.ld | 18 ++++ tests/tcg/ppc/system/macros.inc | 56 ++++++++++++ tests/tcg/ppc/system/meson.build | 39 +++++++++ tests/tcg/ppc/system/unsupported.S | 31 +++++++ tests/tcg/ppc64/meson.build | 2 + tests/tcg/ppc64/system/meson.build | 33 ++++++++ 23 files changed, 554 insertions(+), 50 deletions(-) create mode 100644 tests/tcg/ppc/meson.build create mode 100644 tests/tcg/ppc/system/README create mode 100644 tests/tcg/ppc/system/boot.S create mode 100644 tests/tcg/ppc/system/byte-parity.S create mode 100644 tests/tcg/ppc/system/fpscr.S create mode 100644 tests/tcg/ppc/system/isa.out create mode 100644 tests/tcg/ppc/system/kernel.ld create mode 100644 tests/tcg/ppc/system/macros.inc create mode 100644 tests/tcg/ppc/system/meson.build create mode 100644 tests/tcg/ppc/system/unsupported.S create mode 100644 tests/tcg/ppc64/system/meson.build
Quoted 3 lines
Quoted 1 line
---
Ping for review?
Hi Bin,
thanks for taking care of the e500 CPU models! Back in the days when I became maintainer of the e500 machines, I deliberately didn't volunteer for the CPUs since I don't have the bandwidth to do it. So go ahead, I'm fine with the changes.
Best regards,
Bernhard
On 11/16/26 17:33, Bernhard Beschow wrote:
<snip>
Quoted 6 lines
Hi Bin,
thanks for taking care of the e500 CPU models! Back in the days when I became maintainer of the e500 machines, I deliberately didn't volunteer for the CPUs since I don't have the bandwidth to do it. So go ahead, I'm fine with the changes.
Best regards,
Bernhard
Hi Bernhard,
Thanks for looking into this. Since you mentioned you are fine with the changes, requesting you to consider giving a Ack-by or Reviewed-by, as you see fit to help merge this series.
Thanks,
Chinmay
Quoted 1 line
<snip>
Am 8. November 2026 11:59:59 UTC schrieb Bin Meng <[email protected]>:
Quoted 101 lines
This series corrects SPR access, cache and MMU configuration, and instruction availability in the Freescale Book E CPU models. It also fixes host PVR matching and adds system TCG tests for e500mc, e5500 and e6500.
The patches are grouped as follows:
- patch #1-#3 and #5, bug fixes to PIR write access, the MAS5 SPR number and cache block/line sizes (qemu-stable cc'ed)
- patch #4 and #6, complete e500mc/e5500 L1 cache configuration and remove redundant e6500 cache geometry bits
- patch #7-#11, register the missing cache, MMU-assist and several control SPRs
- patch #12-#14, split the PowerISA 2.05 instructions into integer and floating-point groups, due to differences seen on e500 series cores
- patch #15-#17: Add TCG tests for illegal-instruction exceptions, byte comparison and parity results, and FPSCR field-mask handling
- patch #18-#21, complete the e500 family MMU configuration, correct PID register counts and express MMUCFG/TLBnCFG with named fields
- patch #22-#23, fix EPCR write width and host PVR revision matching for Book E KVMChanges in v3:
- Cover the new system test directories inMAINTAINERS
- Add the missing SPDX license identifier to the README
- target/ppc: Build e6500 MMUCFG values from field encodings
- target/ppc: Complete MMU configuration for e500 family cores
- target/ppc: Limit e500mc and e5500 to one PID register
- target/ppc: Express e6500 TLB configuration with named fields
- target/ppc: Keep embedded processor control within 32 bits
- target/ppc: Match e500mc/e5500/e6500 host PVR revisionsChanges in v2:
- Group ISA 2.05 features into integer and floating-point flags
- Use the first free bit for the floating-point group
- Align flag definitions and comment endings
- Enable the shared ISA 2.05 integer flag on e5500 and e6500
- Align the FPSCR W/L behavior flag comment ending
- Rebase the PPC64 test entry onto the Meson variable cleanupBin Meng (23):
target/ppc: Correct PIR write access on e500 cores target/ppc: Correct the MAS5 SPR number
target/ppc: Correct the e500mc and e5500 cache block size fields target/ppc: Complete e500mc and e5500 L1 cache configuration target/ppc: Correct cache line size for e6500 target/ppc: Drop redundant e6500 L1 cache geometry bits target/ppc: Register L1CSR2 on e500mc/e5500/e6500 cores target/ppc: Register L2CFG0 and L2CSR1 on e500mc and e5500 target/ppc: Register MAS5 and MAS8 on e500mc/e5500/e6500 target/ppc: Register PWRMGTCR0 on e6500
target/ppc: Register IVOR42 on e6500
target/ppc: Split the ISA 2.05 instruction feature group target/ppc: Enable byte comparison and parity on e5500 and e6500 target/ppc: Ignore FPSCR W/L fields on e500mc, e5500 and e6500 tests/tcg/ppc: Add Book E illegal instruction tests tests/tcg/ppc: Test byte comparison and parity on e5500/e6500 tests/tcg/ppc: Test FPSCR W/L handling on e500mc/e5500/e6500 target/ppc: Build e6500 MMUCFG values from field encodings target/ppc: Complete MMU configuration for e500 family cores target/ppc: Limit e500mc and e5500 to one PID register target/ppc: Express e6500 TLB configuration with named fields target/ppc: Keep embedded processor control within 32 bits target/ppc: Match e500mc/e5500/e6500 host PVR revisionsMAINTAINERS | 2 +- target/ppc/cpu.h | 45 ++++++---- target/ppc/cpu_init.h | 3 +- target/ppc/cpu_init.c | 99 +++++++++++++++++----- target/ppc/translate.c | 10 ++- target/ppc/translate/fixedpoint-impl.c.inc | 6 +- target/ppc/translate/fp-impl.c.inc | 14 ++- target/ppc/translate/fp-ops.c.inc | 9 +- meson_options.txt | 4 + scripts/meson-buildoptions.sh | 2 + tests/tcg/meson.build | 1 + tests/tcg/ppc/meson.build | 5 ++ tests/tcg/ppc/system/README | 24 ++++++ tests/tcg/ppc/system/boot.S | 92 ++++++++++++++++++++ tests/tcg/ppc/system/byte-parity.S | 33 ++++++++ tests/tcg/ppc/system/fpscr.S | 75 ++++++++++++++++ tests/tcg/ppc/system/isa.out | 1 + tests/tcg/ppc/system/kernel.ld | 18 ++++ tests/tcg/ppc/system/macros.inc | 56 ++++++++++++ tests/tcg/ppc/system/meson.build | 39 +++++++++ tests/tcg/ppc/system/unsupported.S | 31 +++++++ tests/tcg/ppc64/meson.build | 2 + tests/tcg/ppc64/system/meson.build | 33 ++++++++ 23 files changed, 554 insertions(+), 50 deletions(-)create mode 100644 tests/tcg/ppc/meson.build create mode 100644 tests/tcg/ppc/system/README create mode 100644
tests/tcg/ppc/system/boot.Screate mode 100644tests/tcg/ppc/system/byte-parity.Screate mode 100644tests/tcg/ppc/system/fpscr.Screate mode 100644 tests/tcg/ppc/system/isa.out create mode 100644 tests/tcg/ppc/system/kernel.ld create mode 100644 tests/tcg/ppc/system/macros.inc create mode 100644 tests/tcg/ppc/system/meson.build create mode 100644tests/tcg/ppc/system/unsupported.Screate mode 100644 tests/tcg/ppc64/system/meson.build
Quoted 4 lines
---
base-commit:f29ccc287a6cfdd51d3a4fd17fbe9af3310a0ac5
branch: ppc-fsl-booke
FWIW: Series: