target/mips: add missing Octeon user-mode support
v10 cover target/mips: add missing Octeon user-mode support
This series updates MIPS linux-user unaligned-access behavior and fills in missing Octeon user-mode instruction support used by existing Octeon binaries.
The first patches model the Linux/MIPS sysmips ABI pieces needed by linux-user, including MIPS_FLUSH_CACHE, MIPS_ATOMIC_SET, and the MIPS_FIXADE policy used to control unaligned scalar access fixups. User-mode unaligned scalar accesses default to software fixups and sysmips(MIPS_FIXADE) can toggle SIGBUS/BUS_ADRALN behavior.
Richard Henderson's v7.5 multiplier/QMAC rework is incorporated directly as nine patches: two TCG preparatory patches and seven Octeon multiplier/QMAC patches. The Octeon multiplier and QMAC translations now expand inline in TCG.
The remaining Octeon patches add integer, indexed memory, atomic, COP2 crypto, CHORD, LLM, and CvmCount RDHWR support. The COP2 work is split into state, helper plumbing, per-engine helper patches, explicit selector decode, CHORD/LLM, and smoke-test coverage, with each functional block isolated. The series also adds a small mips64/mips64el TCG guest test covering representative Octeon integer, fixed-point, multiplier, RDHWR, and COP2 selector paths. The final patch corrects the Octeon68XX CP1 feature bits and FCR defaults.
Changes since v1:
- Split BADDU/DMUL destination fixes into a separate patch.
- Split the SEQ/SNE decode refactoring into a separate patch.
- Moved Octeon multiplier state to uint64_t arrays and updated VMState.
- Switched Octeon helper ABIs to i64/uint64_t where applicable.
- Moved COP2 selector decode/support logic into octeon_translate.c.
- Added in-tree TCG tests for mips64 and mips64el linux-user.
- Used switch ranges and g_assert_not_reached() for SHA3/ZUC shared selector handling.
- Dropped Octeon prefixes from generic Camellia helper routines.
- Reworked GFM helpers to keep the architectural 128-bit state and direct RESINP XOR paths.
- Moved the Octeon68XX CP1 CPU-model correction to the end of the series.
- Added migration coverage for Octeon COP2 crypto and LLM sparse state.
- Split COP2 helper implementation by functional subcategory and added helper.h declarations alongside the side-effecting selector operations.
- Removed the shared COP2 selector enum; selectors are now either decoded by decodetree or kept as helper-local constants for shared register-window arithmetic.
- Used signed 32-bit DMFC2 direct loads for 32-bit COP2 register readback.
---
Changes in v10:
- Split the explicit Octeon COP2 selector decode patch into register,
CRC/GFM, HSH/SHA3, stream-cipher, block-cipher, and CHORD/LLM
patches.
- Added Philippe's Reviewed-by tag and local MemOp cleanup for ZCB/ZCBT.
- Added Philippe's Tested-by tags for VMULU, VMM0, and Octeon68XX CP1.
- Restored the original constant-fold output ordering in the TCG mul[us]2
optimization patch.
- Kept Octeon COP2 crypto state architectural by dropping shared-mode and
AES, GFM, SHA3, ZUC, and SNOW3G shadow state.
- Ordered Octeon COP2 crypto CPU state and VMState fields by architectural
selector groups.
- Reworked GFM reflected helpers around the full 128-bit architectural state
and direct RESINP XOR operations.
- Preserved the 64-bit UIA2 GFM reduction path used by SNOW3G F9.
- Added Richard's Reviewed-by tag for the CRC COP2 helpers and masked
variable-length CRC writes to CRCLEN<3:0>.
- Link to v9: https://lore.kernel.org/qemu-devel/20260519-mips-octeon-missing-insns-v2-v9-0-d7dd735ecddd@gmail.com
Changes in v9:
- Used MO_ATOM_NONE for the 128-bit ZCB/ZCBT zero stores.
- Reused octeon_zero_partial_product_state() in the VMM0 translator.
- Removed the shared MIPSOcteonCop2Sel enum from CPU state headers.
- Replaced generic selector-dispatch COP2 helpers with per-operation
helper functions.
- Split COP2 helper implementation into smaller functional subcategory
patches: plumbing, CRC, GFM, SHA3, ZUC, SNOW3G, AES, SMS4, 3DES/KASUMI,
Camellia, HSH, and CHORD/LLM.
- Added COP2 helper declarations to helper.h alongside the per-engine
helper implementation commits.
- Used signed 32-bit DMFC2 direct loads for 32-bit COP2 register
readback.
- Documented the AESRESINP direct register-transfer handling in the translator.
- Combined COP2 selector readback with QMAC/CvmCount smoke coverage.
- Link to v8: https://lore.kernel.org/qemu-devel/20260517-mips-octeon-missing-insns-v2-v8-0-206151ee77ec@gmail.com
Changes in v8:
- Incorporated Richard Henderson's v7.5 9-patch multiplier/QMAC rework
directly into the stack rather than as a follow-up cleanup.
- Added the two v7.5 TCG prep patches as standalone patches:
tcg_gen_addN_i64 and mul[us]2 zero/one optimization.
- Replaced the helper-backed Octeon multiplier/QMAC sequence with the
seven v7.5-shaped patches: multiplier state, MTM, MTP, VMULU, VMM0,
V3MULU, and QMAC.
- Split Octeon COP2 crypto core support into state/migration, helper
implementation, explicit selector decode, and selector readback test
patches.
- Decoded Octeon COP2 selectors explicitly in decodetree and used direct
TCG loads/stores for simple COP2 register moves.
- Kept COP2 helper calls for operation selectors and shared-window state
that require side effects.
- Folded ZCB/ZCBT into one patch so the decodetree wildcard is
introduced in final form.
- Added new Reviewed-by tags from Richard Henderson for MTM/MTP, LA*,
CvmCount, and QMAC/CvmCount test patches.
- Link to v7: https://lore.kernel.org/qemu-devel/20260514-mips-octeon-missing-insns-v2-v7-0-226686be4ce1@gmail.com
Changes in v7:
- Rebased on current qemu.git staging (edcc429e9e).
- Reordered the zero-register cleanup after the BADDU/DMUL destination fix
and moved the multiplier-state patch next to the MTM/MTP instruction
patches.
- Applied Philippe's MIPS_FIXADE TB-flag readability tweak.
- Used explicit MO_32/MO_64 MemOps for SAA/SAAD atomic transaction sizes.
- Folded ZCB/ZCBT decode with a decodetree wildcard and zero the cache
block with 128-bit stores.
- Added new Reviewed-by tags from Philippe Mathieu-Daudé and Richard
Henderson.
- Link to v6: https://lore.kernel.org/qemu-devel/20260511-mips-octeon-missing-insns-v2-v6-0-5062889c4d3c@gmail.com
Changes in v6:
- Added Octeon QMAC/QMACS fixed-point accumulator support and smoke
coverage.
- Added Octeon RDHWR $31/CvmCount support and smoke coverage.
- Clarified MTM0/VMM0 reset behavior against the CN71XX
register-state tables.
- Fixed MTP0 to zero P1 per the CN71XX register-state table and added
smoke coverage.
- Fixed VMM0 MPL1 reset handling and added smoke coverage for MPL1.
- Cleaned up internal VMUL, LA*, COP2 payload/state, and COP2 selector
naming to better match hardware register/selector terminology.
- Renamed the MIPS_FIXADE TB flag, HSH register word-packing helpers,
and sparse LLM backing fields to match ABI and hardware terminology.
- Link to v5: https://lore.kernel.org/qemu-devel/20260510-mips-octeon-missing-insns-v2-v5-0-d5d2668d15ab@gmail.com
Changes in v5:
- Added Richard Henderson's Reviewed-by tags for LBX, LHUX, LWUX, SAA,
and SAAD, plus Acked-by tags for ZCB and ZCBT.
- Dropped the separate Octeon+ feature bit; QEMU has a single Octeon CPU
model today, so SAA/SAAD stay under the existing Octeon feature bucket.
- Folded ZCBT into the ZCB decodetree entry with a selector comment.
- Link to v4: https://lore.kernel.org/qemu-devel/20260509-mips-octeon-missing-insns-v2-v4-0-d669dcd05c2f@gmail.com
Changes in v4:
- Added Richard Henderson's Reviewed-by tags to the reviewed sysmips and
Octeon translator cleanup patches.
- Kept the Octeon3 MPL3-MPL5/P3-P5 high-lane multiplier state
documented by Cavium SDK/toolchain sources.
- Documented the Octeon3 two-source MTM/MTP forms and preserved the rt
high-lane operands while legacy one-source encodings use rt == $zero.
- Simplified SAA/SAAD translation to use the i64 TCG atomic add path for
both word and doubleword sizes.
- Marked SAA/SAAD as Octeon+ instructions and gated them behind a
separate Octeon+ feature bit.
- Simplified LA* translation to use i64 TCG atomic helpers for word and
doubleword operations, with MO_SL selecting word result sign-extension.
- Link to v3: https://lore.kernel.org/qemu-devel/20260508-mips-octeon-missing-insns-v2-v3-0-bcbec96357d9@gmail.com
Changes in v3:
- Rebased on current qemu.git master.
- Split sysmips support into separate MIPS_FLUSH_CACHE, MIPS_ATOMIC_SET,
and MIPS_FIXADE patches.
- Made MIPS_ATOMIC_SET always use the MIPS separate error-result register
path for successful returns.
- Removed redundant Octeon MIPS64 checks and target-long guards from the
translator paths.
- Removed zero-register fast paths where gen_store_gpr() already handles
discarded writes.
- Reworked SEQ/SNE decode and LA* translator helpers as requested.
- Split the Octeon arithmetic/memory patch into narrower state, indexed
load, SAA/SAAD, ZCB/ZCBT, multiplier, and test patches.
- Reworked Octeon multiplier limb accumulation as requested.
- Link to v2: https://lore.kernel.org/qemu-devel/20260421-mips-octeon-missing-insns-v2-v2-0-a0791df188c9@gmail.com
To: [email protected]
Cc: Laurent Vivier <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: Pierrick Bouvier <[email protected]>
Cc: Philippe Mathieu-Daudé <[email protected]>
Cc: Jiaxun Yang <[email protected]>
Cc: Aurelien Jarno <[email protected]>
Cc: Aleksandar Rikalo <[email protected]>
Cc: Huacai Chen <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Paolo Bonzini <[email protected]>
---
James Hilliard (43):
linux-user/mips: implement sysmips(MIPS_FLUSH_CACHE) linux-user/mips: implement sysmips(MIPS_ATOMIC_SET) linux-user/mips, target/mips: honor MIPS_FIXADE for unaligned accesses target/mips: fix Octeon arithmetic destination handling target/mips: drop Octeon zero-register fast paths target/mips: split Octeon SEQ/SNE decode
target/mips: add Octeon LBX instruction
target/mips: add Octeon LHUX instruction
target/mips: add Octeon LWUX instruction
target/mips: add Octeon SAA instruction
target/mips: add Octeon SAAD instruction
target/mips: add Octeon ZCB and ZCBT instructions target/mips: add Octeon multiplier state
target/mips: add Octeon MTM instructions
target/mips: add Octeon MTP instructions
target/mips: add Octeon VMULU instruction
target/mips: add Octeon VMM0 instruction
target/mips: add Octeon V3MULU instruction
target/mips: add Octeon QMAC instructions
tests/tcg/mips: add Octeon instruction smoke test target/mips: add Octeon LA* atomic instructions target/mips: add Octeon COP2 crypto state
target/mips: add Octeon COP2 crypto helper plumbing target/mips: add Octeon CRC COP2 helpers
target/mips: add Octeon GFM COP2 helpers
target/mips: add Octeon SHA3 COP2 helpers
target/mips: add Octeon ZUC COP2 helpers
target/mips: add Octeon SNOW3G COP2 helpers
target/mips: add Octeon AES COP2 helpers
target/mips: add Octeon SMS4 COP2 helpers
target/mips: add Octeon 3DES and KASUMI COP2 helpers target/mips: add Octeon Camellia COP2 helpers
target/mips: add Octeon HSH COP2 helpers
target/mips: add Octeon CHORD and LLM COP2 helpers target/mips: decode Octeon COP2 register selectors target/mips: decode Octeon CRC and GFM COP2 selectors target/mips: decode Octeon HSH and SHA3 COP2 selectors target/mips: decode Octeon ZUC and SNOW3G COP2 selectors target/mips: decode Octeon block-cipher COP2 selectors target/mips: decode Octeon CHORD and LLM COP2 selectors target/mips: add Octeon CvmCount RDHWR support tests/tcg/mips: cover Octeon COP2, QMAC and CvmCount target/mips: expose Octeon68XX floating-point support
Richard Henderson (2):
tcg: Introduce tcg_gen_addN_i64
tcg: Optimize INDEX_op_mul[us]2 for 0 and 1
include/tcg/tcg-op-common.h | 1 + linux-user/mips/cpu_loop.c | 5 + linux-user/mips/target_syscall.h | 3 + linux-user/mips64/target_syscall.h | 3 + linux-user/syscall.c | 56 + target/mips/cpu-defs.c.inc | 10 +- target/mips/cpu.c | 78 +- target/mips/cpu.h | 44 + target/mips/helper.h | 125 ++ target/mips/internal.h | 3 + target/mips/system/machine.c | 129 ++ target/mips/tcg/meson.build | 1 + target/mips/tcg/octeon.decode | 259 ++- target/mips/tcg/octeon_crypto.c | 2503 +++++++++++++++++++++++++ target/mips/tcg/octeon_translate.c | 745 +++++++- target/mips/tcg/op_helper.c | 19 +- target/mips/tcg/translate.c | 43 +- target/mips/tcg/translate.h | 2 + tcg/optimize.c | 92 +- tcg/tcg-op.c | 42 + tests/tcg/mips/user/isa/octeon/octeon-insns.c | 332 ++++ tests/tcg/mips64/Makefile.target | 20 + tests/tcg/mips64el/Makefile.target | 8 + 23 files changed, 4431 insertions(+), 92 deletions(-)
---
base-commit: 6d17fd91f6cf88df5cb2205e578640d72605cc43
change-id: 20260420-mips-octeon-missing-insns-v2-5e693770cf2c
Best regards,
Signature · 1 line
James Hilliard <[email protected]>
PATCH v10 1/45 linux-user/mips: implement sysmips(MIPS_FLUSH_CACHE)
Add the target sysmips dispatcher and implement MIPS_FLUSH_CACHE as a successful no-op for linux-user.
Self-modifying code is handled by QEMU's normal user-mode translation invalidation machinery, so the target ABI only needs the syscall command to be accepted.
---
Changes v2 -> v3:
- Split MIPS_FLUSH_CACHE out of the combined sysmips/MIPS_FIXADE patch. (suggested by Richard Henderson)
--- linux-user/mips/target_syscall.h | 1 + linux-user/mips64/target_syscall.h | 1 + linux-user/syscall.c | 17 +++++++++++++++++ 3 files changed, 19 insertions(+)
linux-user/mips/target_syscall.h +1 -0
@@ -10,6 +10,7 @@#define TARGET_MCL_ONFAULT 4#define TARGET_FORCE_SHMLBA +#define TARGET_SYSMIPS_FLUSH_CACHE 3static inline abi_ulong target_shmlba (CPUMIPSState *env) {
linux-user/mips64/target_syscall.h +1 -0
@@ -10,6 +10,7 @@#define TARGET_MCL_ONFAULT 4#define TARGET_FORCE_SHMLBA +#define TARGET_SYSMIPS_FLUSH_CACHE 3static inline abi_ulong target_shmlba (CPUMIPSState *env) {
linux-user/syscall.c +17 -0
@@ -6630,6 +6630,19 @@ static abi_long do_prctl_syscall_user_dispatch(CPUArchState *env, } } +#ifdef TARGET_NR_sysmips +static abi_long do_sysmips (CPUArchState *env,abi_long cmd,abi_long arg1, +abi_long arg2) +{ +switch (cmd) { +case TARGET_SYSMIPS_FLUSH_CACHE : +return 0 ; +default : +return -TARGET_EINVAL ; + } +} +#endif +static abi_long do_prctl (CPUArchState *env,abi_long option,abi_long arg2,abi_long arg3,abi_long arg4,abi_long arg5) {
@@ -12102,6 +12115,10 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,case TARGET_NR_prctl:return do_prctl (cpu_env, arg1, arg2, arg3, arg4, arg5);break ; +#ifdef TARGET_NR_sysmips +case TARGET_NR_sysmips: +return do_sysmips (cpu_env, arg1, arg2, arg3); +#endif #ifdef TARGET_NR_arch_prctlcase TARGET_NR_arch_prctl:return do_arch_prctl (cpu_env, arg1, arg2);
Signature · 1 line
2.54.0
PATCH v10 2/45 linux-user/mips: implement sysmips(MIPS_ATOMIC_SET)
In reply to James HilliardImplement the MIPS_ATOMIC_SET sysmips command as an aligned 32-bit atomic exchange in target memory.
MIPS reports syscall errors through a separate register, so successful old values can overlap the errno range. Write the return value and error flag directly and return -QEMU_ESIGRETURN so the common syscall path leaves the registers unchanged.
---
Changes v2 -> v3:
- Split MIPS_ATOMIC_SET out of the combined sysmips/MIPS_FIXADE patch. (suggested by Richard Henderson)
- Always use the explicit MIPS return-register path for successful atomic_set results. (suggested by Richard Henderson)
--- linux-user/mips/target_syscall.h | 1 + linux-user/mips64/target_syscall.h | 1 + linux-user/syscall.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+)
linux-user/mips/target_syscall.h +1 -0
@@ -11,6 +11,7 @@#define TARGET_FORCE_SHMLBA #define TARGET_SYSMIPS_FLUSH_CACHE 3 +#define TARGET_SYSMIPS_ATOMIC_SET 2001static inline abi_ulong target_shmlba (CPUMIPSState *env) {
linux-user/mips64/target_syscall.h +1 -0
@@ -11,6 +11,7 @@#define TARGET_FORCE_SHMLBA #define TARGET_SYSMIPS_FLUSH_CACHE 3 +#define TARGET_SYSMIPS_ATOMIC_SET 2001static inline abi_ulong target_shmlba (CPUMIPSState *env) {
linux-user/syscall.c +31 -0
@@ -6631,10 +6631,41 @@ static abi_long do_prctl_syscall_user_dispatch(CPUArchState *env, }#ifdef TARGET_NR_sysmips +static abi_long do_sysmips_atomic_set (CPUArchState *env,abi_ulong addr, +abi_long value) +{ +uint32_t *ptr; +abi_long old; + +if (addr &3 ) { +return -TARGET_EINVAL ; + } + + ptr =lock_user (VERIFY_WRITE , addr,sizeof (*ptr), true); +if (!ptr) { +return -TARGET_EINVAL ; + } + + old =tswap32 (qatomic_xchg (ptr,tswap32 ((uint32_t )value))); +unlock_user (ptr, addr,sizeof (*ptr)); + +/* +* MIPS uses a separate error flag, but the common linux-user syscall +* path infers that flag from the return value. Successful atomic_set +* results can overlap the target errno range, so write the result +* registers here and ask the CPU loop to leave them alone. +*/ + env->active_tc.gpr[2 ] = old; + env->active_tc.gpr[7 ] =0 ; +return -QEMU_ESIGRETURN ; +} +static abi_long do_sysmips (CPUArchState *env,abi_long cmd,abi_long arg1,abi_long arg2) {switch (cmd) { +case TARGET_SYSMIPS_ATOMIC_SET : +return do_sysmips_atomic_set (env, arg1, arg2);case TARGET_SYSMIPS_FLUSH_CACHE :return 0 ;default :
Signature · 1 line
2.54.0
PATCH v10 3/45 linux-user/mips, target/mips: honor MIPS_FIXADE for unaligned accesses
In reply to James HilliardLinux/MIPS enables software fixups for user-mode unaligned scalar accesses by default through MIPS_FIXADE/TIF_FIXADE. QEMU linux-user did not model that ABI, so MIPS guests took fatal AdEL/AdES exceptions unless translation was forced to use unaligned host accesses.
Key MIPS translation blocks on the linux-user unaligned policy, implement sysmips(MIPS_FIXADE) to toggle that policy, and raise SIGBUS/BUS_ADRALN when fixups are disabled.
---
Changes v6 -> v7:
- Replace the compact TB_FLAG_MIPS_FIXADE multiplication with an explicit conditional branch for readability. (suggested by Philippe Mathieu-Daudé)
Changes v5 -> v6:
- Rename the TB flag from TB_FLAG_UNALIGN to TB_FLAG_MIPS_FIXADE to match the MIPS_FIXADE ABI policy.
Changes v2 -> v3:
- Split MIPS_FLUSH_CACHE and MIPS_ATOMIC_SET into preparatory sysmips patches. (suggested by Richard Henderson)
--- linux-user/mips/cpu_loop.c | 5 +++++ linux-user/mips/target_syscall.h | 1 + linux-user/mips64/target_syscall.h | 1 + linux-user/syscall.c | 8 ++++++++ target/mips/cpu.c | 10 ++++++++-- target/mips/cpu.h | 4 ++++ target/mips/tcg/translate.c | 6 +++++- 7 files changed, 32 insertions(+), 3 deletions(-)
linux-user/mips/cpu_loop.c +5 -0
@@ -161,6 +161,11 @@ done_syscall:case EXCP_DSPDIS :force_sig (TARGET_SIGILL );break ; +case EXCP_AdEL: +case EXCP_AdES: +force_sig_fault (TARGET_SIGBUS ,TARGET_BUS_ADRALN , + env->CP0_BadVAddr); +break ;case EXCP_INTERRUPT :/* just indicate that signals should be handled asap */ break ;
linux-user/mips/target_syscall.h +1 -0
@@ -11,6 +11,7 @@#define TARGET_FORCE_SHMLBA #define TARGET_SYSMIPS_FLUSH_CACHE 3 +#define TARGET_SYSMIPS_FIXADE 7#define TARGET_SYSMIPS_ATOMIC_SET 2001static inline abi_ulong target_shmlba (CPUMIPSState *env)
linux-user/mips64/target_syscall.h +1 -0
@@ -11,6 +11,7 @@#define TARGET_FORCE_SHMLBA #define TARGET_SYSMIPS_FLUSH_CACHE 3 +#define TARGET_SYSMIPS_FIXADE 7#define TARGET_SYSMIPS_ATOMIC_SET 2001static inline abi_ulong target_shmlba (CPUMIPSState *env)
linux-user/syscall.c +8 -0
@@ -6663,9 +6663,17 @@ static abi_long do_sysmips_atomic_set(CPUArchState *env, abi_ulong addr,static abi_long do_sysmips (CPUArchState *env,abi_long cmd,abi_long arg1,abi_long arg2) { +CPUState *cs =env_cpu (env); +switch (cmd) {case TARGET_SYSMIPS_ATOMIC_SET :return do_sysmips_atomic_set (env, arg1, arg2); +case TARGET_SYSMIPS_FIXADE : +if (arg1 & ~3 ) { +return -TARGET_EINVAL ; + } + cs->prctl_unalign_sigbus = !(arg1 &1 ); +return 0 ;case TARGET_SYSMIPS_FLUSH_CACHE :return 0 ;default :
target/mips/cpu.c +8 -2
@@ -565,11 +565,17 @@ static int mips_cpu_mmu_index(CPUState *cs, bool ifunc)static TCGTBCPUState mips_get_tb_cpu_state (CPUState *cs) {CPUMIPSState *env =cpu_env (cs); +uint32_t flags = env->hflags &MIPS_HFLAG_TB_MASK ; + +#ifdef CONFIG_USER_ONLY +if (!cs->prctl_unalign_sigbus) { + flags |=TB_FLAG_MIPS_FIXADE ; + } +#endif return (TCGTBCPUState ){ .pc = env->active_tc.PC, - .flags = env->hflags & (MIPS_HFLAG_TMASK |MIPS_HFLAG_BMASK | -MIPS_HFLAG_HWRENA_ULR ), + .flags = flags, }; }
target/mips/cpu.h +4 -0
@@ -1161,6 +1161,10 @@ typedef struct CPUArchState {#define MIPS_HFLAG_ELPA 0x4000000#define MIPS_HFLAG_ITC_CACHE 0x8000000/* CACHE instr. operates on ITC tag */ #define MIPS_HFLAG_ERL 0x10000000/* error level flag */ +#define MIPS_HFLAG_TB_MASK (MIPS_HFLAG_TMASK | MIPS_HFLAG_BMASK | \ + MIPS_HFLAG_HWRENA_ULR) + +#define TB_FLAG_MIPS_FIXADE 0x40000000target_ulong btarget;/* Jump / branch target */ target_ulong bcond;/* Branch condition (if needed) */
target/mips/tcg/translate.c +5 -1
@@ -15070,6 +15070,7 @@ static void mips_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) {DisasContext *ctx =container_of (dcbase, DisasContext, base);CPUMIPSState *env =cpu_env (cs); +uint32_t tb_flags = ctx->base.tb->flags; ctx->page_start = ctx->base.pc_first &TARGET_PAGE_MASK ; ctx->saved_pc =-1 ;
@@ -15092,7 +15093,7 @@ static void mips_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->CP0_LLAddr_shift = env->CP0_LLAddr_shift; ctx->cmgcr = (env->CP0_Config3 >>CP0C3_CMGCR ) &1 ;/* Restore delay slot state from the tb context. */ - ctx->hflags = (uint32_t )ctx->base.tb->flags;/* FIXME: maybe use 64 bits? */ + ctx->hflags = tb_flags &MIPS_HFLAG_TB_MASK ; ctx->ulri = (env->CP0_Config3 >>CP0C3_ULRI ) &1 ; ctx->ps = ((env->active_fpu.fcr0 >>FCR0_PS ) &1 ) || (env->insn_flags & (INSN_LOONGSON2E |INSN_LOONGSON2F ));
@@ -15112,6 +15113,9 @@ static void mips_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->default_tcg_memop_mask = (!(ctx->insn_flags &ISA_NANOMIPS32 ) && (ctx->insn_flags & (ISA_MIPS_R6 |INSN_LOONGSON3A ))) ?MO_UNALN :MO_ALIGN ; +if (tb_flags &TB_FLAG_MIPS_FIXADE ) { + ctx->default_tcg_memop_mask =MO_UNALN ; + }/* * Execute a branch and its delay slot as a single instruction.
Signature · 1 line
2.54.0
PATCH v10 4/45 target/mips: fix Octeon arithmetic destination handling
In reply to James HilliardBADDU and DMUL write their results to rd, not rt. Route writes through gen_store_gpr() so rd == $zero is handled consistently.
---
Changes v1 -> v2:
- Split the BADDU/DMUL destination handling fix out of the Octeon arithmetic instruction patch. (suggested by Philippe Mathieu-Daudé)
Changes v2 -> v3:
- Remove the rd == $zero fast paths and let gen_store_gpr() discard writes to $zero. (suggested by Richard Henderson)
--- target/mips/tcg/octeon_translate.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
target/mips/tcg/octeon_translate.c +4 -12
@@ -45,18 +45,14 @@ static bool trans_BADDU(DisasContext *ctx, arg_BADDU *a) {TCGv_i64 t0, t1; -if (a->rt ==0 ) { -/* nop */ -return true; - } - t0 =tcg_temp_new_i64 (); t1 =tcg_temp_new_i64 ();gen_load_gpr (t0, a->rs);gen_load_gpr (t1, a->rt);tcg_gen_add_i64 (t0, t0, t1); -tcg_gen_andi_i64 (cpu_gpr[a->rd], t0,0xff ); +tcg_gen_andi_i64 (t0, t0,0xff ); +gen_store_gpr (t0, a->rd);return true; }
@@ -64,17 +60,13 @@ static bool trans_DMUL(DisasContext *ctx, arg_DMUL *a) {TCGv_i64 t0, t1; -if (a->rt ==0 ) { -/* nop */ -return true; - } - t0 =tcg_temp_new_i64 (); t1 =tcg_temp_new_i64 ();gen_load_gpr (t0, a->rs);gen_load_gpr (t1, a->rt); -tcg_gen_mul_i64 (cpu_gpr[a->rd], t0, t1); +tcg_gen_mul_i64 (t0, t0, t1); +gen_store_gpr (t0, a->rd);return true; }
Signature · 1 line
2.54.0
PATCH v10 5/45 target/mips: drop Octeon zero-register fast paths
In reply to James HilliardEXTS, CINS, and POP route their destination writes through gen_store_gpr(), which already discards writes to $zero. Remove the remaining translator fast paths for destination $zero so these Octeon instructions follow the same shape as BADDU/DMUL and the generic MIPS translator helpers.
---
Changes v2 -> v3:
- Remove the remaining destination $zero fast paths and let gen_store_gpr() discard writes to $zero. (suggested by Richard Henderson)
--- target/mips/tcg/octeon_translate.c | 15 --------------- 1 file changed, 15 deletions(-)
target/mips/tcg/octeon_translate.c +0 -15
@@ -74,11 +74,6 @@ static bool trans_EXTS(DisasContext *ctx, arg_EXTS *a) {TCGv_i64 t0; -if (a->rt ==0 ) { -/* nop */ -return true; - } - t0 =tcg_temp_new_i64 ();gen_load_gpr (t0, a->rs);tcg_gen_sextract_i64 (t0, t0, a->p, a->lenm1 +1 );
@@ -90,11 +85,6 @@ static bool trans_CINS(DisasContext *ctx, arg_CINS *a) {TCGv_i64 t0; -if (a->rt ==0 ) { -/* nop */ -return true; - } - t0 =tcg_temp_new_i64 ();gen_load_gpr (t0, a->rs);tcg_gen_deposit_z_i64 (t0, t0, a->p, a->lenm1 +1 );
@@ -106,11 +96,6 @@ static bool trans_POP(DisasContext *ctx, arg_POP *a) {TCGv_i64 t0; -if (a->rd ==0 ) { -/* nop */ -return true; - } - t0 =tcg_temp_new_i64 ();gen_load_gpr (t0, a->rs);if (!a->dw) {
Signature · 1 line
2.54.0
PATCH v10 6/45 target/mips: split Octeon SEQ/SNE decode
In reply to James HilliardDecode the equality and inequality forms as explicit SEQ/SNE and SEQI/SNEI instructions rather than using shared generated SEQNE/SEQNEI entries.
The explicit decoder names match the architectural mnemonics, which makes the translator entry points and trace/debug output easier to correlate with the instruction set.
---
Changes v1 -> v2:
- Split the SEQ/SNE decode cleanup out of the Octeon arithmetic instruction patch. (suggested by Philippe Mathieu-Daudé)
Changes v2 -> v3:
- Remove the decoded ne field now that the instructions are split.
- Reuse @r3 for SEQ/SNE and pass the TCG condition into a shared translator helper. (suggested by Richard Henderson)
--- target/mips/tcg/octeon.decode | 7 +++-- target/mips/tcg/octeon_translate.c | 52 ++++++++++++++++++++------------------ 2 files changed, 32 insertions(+), 27 deletions(-)
target/mips/tcg/octeon.decode +5 -2
@@ -30,6 +30,7 @@ BBIT 11 set:1 . 10 rs:5 ..... offset:s16 p=%bbit_p # SNEI rt, rs, immediate @r3 ...... rs:5 rt:5 rd:5 ..... ...... +&cmpi rs rt imm %bitfield_p 0:1 6:5 @bitfield ...... rs:5 rt:5 lenm1:5 ..... ..... . p=%bitfield_p
@@ -38,8 +39,10 @@ DMUL 011100 ..... ..... ..... 00000 000011 @r3 EXTS 011100 ..... ..... ..... ..... 11101 . @bitfield CINS 011100 ..... ..... ..... ..... 11001 . @bitfield POP 011100 rs:5 00000 rd:5 00000 10110 dw:1 -SEQNE 011100 rs:5 rt:5 rd:5 00000 10101 ne:1 -SEQNEI 011100 rs:5 rt:5 imm:s10 10111 ne:1 +SEQ 011100 ..... ..... ..... 00000 101010 @r3 +SNE 011100 ..... ..... ..... 00000 101011 @r3 +SEQI 011100 rs:5 rt:5 imm:s10 101110 &cmpi +SNEI 011100 rs:5 rt:5 imm:s10 101111 &cmpi &lx base index rd @lx ...... base:5 index:5 rd:5 ...... ..... &lx
target/mips/tcg/octeon_translate.c +27 -25
79 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v10 7/45 target/mips: add Octeon LBX instruction
In reply to James HilliardLBX performs an indexed signed byte load from base + index and writes the sign-extended result to rd.
Wire the existing indexed-load helper to MO_SB so Octeon user-mode binaries can use the signed byte variant alongside the existing LBUX path.
---
Changes v2 -> v3:
- Split LBX out of the combined Octeon arithmetic and memory instruction patch. (requested by Richard Henderson)
--- target/mips/tcg/octeon.decode | 1 + target/mips/tcg/octeon_translate.c | 1 + 2 files changed, 2 insertions(+)
target/mips/tcg/octeon.decode +1 -0
@@ -49,4 +49,5 @@ SNEI 011100 rs:5 rt:5 imm:s10 101111 &cmpi LWX 011111 ..... ..... ..... 00000 001010 @lx LHX 011111 ..... ..... ..... 00100 001010 @lx LBUX 011111 ..... ..... ..... 00110 001010 @lx +LBX 011111 ..... ..... ..... 10110 001010 @lx LDX 011111 ..... ..... ..... 01000 001010 @lx
target/mips/tcg/octeon_translate.c +1 -0
@@ -161,6 +161,7 @@ static bool trans_lx(DisasContext *ctx, arg_lx *a, MemOp mop)return true; } +TRANS (LBX , trans_lx,MO_SB );TRANS (LBUX , trans_lx,MO_UB );TRANS (LHX , trans_lx,MO_SW );TRANS (LWX , trans_lx,MO_SL );
Signature · 1 line
2.54.0
PATCH v10 8/45 target/mips: add Octeon LHUX instruction
In reply to James HilliardLHUX performs an indexed unsigned halfword load from base + index and zero-extends the result into rd.
Add the decode entry and reuse the common indexed-load translator with MO_UW.
---
Changes v2 -> v3:
- Split LHUX out of the combined Octeon arithmetic and memory instruction patch. (requested by Richard Henderson)
--- target/mips/tcg/octeon.decode | 1 + target/mips/tcg/octeon_translate.c | 1 + 2 files changed, 2 insertions(+)
target/mips/tcg/octeon.decode +1 -0
@@ -48,6 +48,7 @@ SNEI 011100 rs:5 rt:5 imm:s10 101111 &cmpi @lx ...... base:5 index:5 rd:5 ...... ..... &lx LWX 011111 ..... ..... ..... 00000 001010 @lx LHX 011111 ..... ..... ..... 00100 001010 @lx +LHUX 011111 ..... ..... ..... 10100 001010 @lx LBUX 011111 ..... ..... ..... 00110 001010 @lx LBX 011111 ..... ..... ..... 10110 001010 @lx LDX 011111 ..... ..... ..... 01000 001010 @lx
target/mips/tcg/octeon_translate.c +1 -0
@@ -164,5 +164,6 @@ static bool trans_lx(DisasContext *ctx, arg_lx *a, MemOp mop)TRANS (LBX , trans_lx,MO_SB );TRANS (LBUX , trans_lx,MO_UB );TRANS (LHX , trans_lx,MO_SW ); +TRANS (LHUX , trans_lx,MO_UW );TRANS (LWX , trans_lx,MO_SL );TRANS (LDX , trans_lx,MO_UQ );
Signature · 1 line
2.54.0
PATCH v10 9/45 target/mips: add Octeon LWUX instruction
In reply to James HilliardLWUX performs an indexed unsigned word load from base + index and zero-extends the result into rd.
Add the decode entry and route it through the common indexed-load translator with MO_UL.
---
Changes v2 -> v3:
- Split LWUX out of the combined Octeon arithmetic and memory instruction patch. (requested by Richard Henderson)
--- target/mips/tcg/octeon.decode | 1 + target/mips/tcg/octeon_translate.c | 1 + 2 files changed, 2 insertions(+)
target/mips/tcg/octeon.decode +1 -0
@@ -50,5 +50,6 @@ LWX 011111 ..... ..... ..... 00000 001010 @lx LHX 011111 ..... ..... ..... 00100 001010 @lx LHUX 011111 ..... ..... ..... 10100 001010 @lx LBUX 011111 ..... ..... ..... 00110 001010 @lx +LWUX 011111 ..... ..... ..... 10000 001010 @lx LBX 011111 ..... ..... ..... 10110 001010 @lx LDX 011111 ..... ..... ..... 01000 001010 @lx
target/mips/tcg/octeon_translate.c +1 -0
@@ -166,4 +166,5 @@ TRANS(LBUX, trans_lx, MO_UB);TRANS (LHX , trans_lx,MO_SW );TRANS (LHUX , trans_lx,MO_UW );TRANS (LWX , trans_lx,MO_SL ); +TRANS (LWUX , trans_lx,MO_UL );TRANS (LDX , trans_lx,MO_UQ );
Signature · 1 line
2.54.0
PATCH v10 10/45 target/mips: add Octeon SAA instruction
In reply to James HilliardSAA atomically adds rt to the naturally aligned 32-bit word at base and discards the old memory value.
Implement the common SAA/SAAD translator with TCG atomic_fetch_add_i64. The MemOp selects the word or doubleword transaction size. QEMU only has one Octeon CPU model today, so keep SAA/SAAD under the existing Octeon instruction feature bucket instead of adding a finer-grained Octeon+ feature bit.
---
Changes v6 -> v7:
- Use MO_32 for the word-size atomic transaction; the signedness bits are irrelevant for a discarded fetch-add result. (suggested by Philippe Mathieu-Daudé)
Changes v2 -> v3:
- Split SAA out of the combined Octeon arithmetic and memory instruction patch. (requested by Richard Henderson)
Changes v3 -> v4:
- Gate SAA/SAAD behind an Octeon+ feature bit. (reported by Richard Henderson)
- Use the i64 TCG atomic add path for both word and doubleword sizes. (suggested by Richard Henderson)
Changes v4 -> v5:
- Drop the separate Octeon+ feature bit; QEMU only has one Octeon CPU model today. (comment by Richard Henderson)
--- target/mips/tcg/octeon.decode | 4 ++++ target/mips/tcg/octeon_translate.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+)
target/mips/tcg/octeon.decode +4 -0
@@ -44,6 +44,10 @@ SNE 011100 ..... ..... ..... 00000 101011 @r3 SEQI 011100 rs:5 rt:5 imm:s10 101110 &cmpi SNEI 011100 rs:5 rt:5 imm:s10 101111 &cmpi +&saa base rt +@saa ...... base:5 rt:5 ................ &saa +SAA 011100 ..... ..... 00000 00000 011000 @saa + &lx base index rd @lx ...... base:5 index:5 rd:5 ...... ..... &lx LWX 011111 ..... ..... ..... 00000 001010 @lx
target/mips/tcg/octeon_translate.c +14 -0
@@ -161,6 +161,20 @@ static bool trans_lx(DisasContext *ctx, arg_lx *a, MemOp mop)return true; } +static bool trans_saa (DisasContext *ctx,arg_saa *a,MemOp mop) +{ +TCGv_i64 addr =tcg_temp_new_i64 (); +TCGv_i64 value =tcg_temp_new_i64 (); +TCGv_i64 old =tcg_temp_new_i64 (); +MemOp amo =mo_endian (ctx) | mop |MO_ALIGN ; + +gen_base_offset_addr (ctx, addr, a->base,0 ); +gen_load_gpr (value, a->rt); +tcg_gen_atomic_fetch_add_i64 (old, addr, value, ctx->mem_idx, amo); +return true; +} + +TRANS (SAA , trans_saa,MO_32 );TRANS (LBX , trans_lx,MO_SB );TRANS (LBUX , trans_lx,MO_UB );TRANS (LHX , trans_lx,MO_SW );
Signature · 1 line
2.54.0
PATCH v10 11/45 target/mips: add Octeon SAAD instruction
In reply to James HilliardSAAD is the doubleword form of SAA: it atomically adds rt to the naturally aligned 64-bit doubleword at base and discards the old memory value.
Route it through the common SAA/SAAD translator so the MemOp selects the aligned doubleword transaction size.
---
Changes v6 -> v7:
- Use MO_64 for the doubleword atomic transaction; the signedness bits are irrelevant for a discarded fetch-add result. (suggested by Philippe Mathieu-Daudé)
Changes v2 -> v3:
- Split SAAD out of the combined Octeon arithmetic and memory instruction patch. (requested by Richard Henderson)
Changes v3 -> v4:
- Note that SAAD shares the Octeon+ gated SAA translator path.
Changes v4 -> v5:
- Drop the Octeon+ gated wording/path and keep SAAD under the existing Octeon feature bucket.
--- target/mips/tcg/octeon.decode | 1 + target/mips/tcg/octeon_translate.c | 1 + 2 files changed, 2 insertions(+)
target/mips/tcg/octeon.decode +1 -0
@@ -47,6 +47,7 @@ SNEI 011100 rs:5 rt:5 imm:s10 101111 &cmpi &saa base rt @saa ...... base:5 rt:5 ................ &saa SAA 011100 ..... ..... 00000 00000 011000 @saa +SAAD 011100 ..... ..... 00000 00000 011001 @saa &lx base index rd @lx ...... base:5 index:5 rd:5 ...... ..... &lx
target/mips/tcg/octeon_translate.c +1 -0
@@ -175,6 +175,7 @@ static bool trans_saa(DisasContext *ctx, arg_saa *a, MemOp mop) }TRANS (SAA , trans_saa,MO_32 ); +TRANS (SAAD , trans_saa,MO_64 );TRANS (LBX , trans_lx,MO_SB );TRANS (LBUX , trans_lx,MO_UB );TRANS (LHX , trans_lx,MO_SW );
Signature · 1 line
2.54.0
PATCH v10 12/45 target/mips: add Octeon ZCB and ZCBT instructions
In reply to James HilliardZCB zeros the 128-byte cache block containing the base address. ZCBT has the same user-mode-visible memory effect for QEMU purposes.
Model both forms with a single decodetree wildcard entry, align the address down to a 128-byte line, and store eight zero 128-bit chunks to guest memory.
---
Changes v9 -> v10:
- Hoist the zero-store MemOp into a local constant.
- Add Philippe's Reviewed-by tag.
Changes v8 -> v9:
- Use MO_ATOM_NONE for the 128-bit zero stores so TCG does not require unavailable 128-bit atomic stores on hosts that lack them.
Changes v7 -> v8:
- Fold the ZCBT wildcard decode into the ZCB patch so the series does not add a ZCB-only decode and rewrite it in the next patch.
Changes v6 -> v7:
- Use 128-bit zero stores with MO_128 instead of sixteen 64-bit stores. (suggested by Philippe Mathieu-Daudé)
- Fold ZCB and ZCBT into a single decodetree wildcard entry instead of using a duplicate entry with a selector comment. (suggested by Philippe Mathieu-Daudé)
Changes v2 -> v3:
- Split ZCB/ZCBT out of the combined Octeon arithmetic and memory instruction patch. (requested by Richard Henderson)
--- target/mips/tcg/octeon.decode | 3 +++ target/mips/tcg/octeon_translate.c | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+)
target/mips/tcg/octeon.decode +3 -0
@@ -49,6 +49,9 @@ SNEI 011100 rs:5 rt:5 imm:s10 101111 &cmpi SAA 011100 ..... ..... 00000 00000 011000 @saa SAAD 011100 ..... ..... 00000 00000 011001 @saa +&zcb base +ZCB 011100 base:5 00000 00000 1110- 011111 &zcb + &lx base index rd @lx ...... base:5 index:5 rd:5 ...... ..... &lx LWX 011111 ..... ..... ..... 00000 001010 @lx
target/mips/tcg/octeon_translate.c +27 -0
@@ -176,6 +176,33 @@ static bool trans_saa(DisasContext *ctx, arg_saa *a, MemOp mop)TRANS (SAA , trans_saa,MO_32 );TRANS (SAAD , trans_saa,MO_64 ); + +static bool trans_ZCB (DisasContext *ctx,arg_ZCB *a) +{ +TCGv_i64 addr =tcg_temp_new_i64 (); +TCGv_i64 line =tcg_temp_new_i64 (); +TCGv_i64 zero64 =tcg_constant_i64 (0 ); +TCGv_i128 zero128 =tcg_temp_new_i128 (); +const MemOp mop =mo_endian (ctx) |MO_128 |MO_ATOM_NONE ; + +gen_base_offset_addr (ctx, addr, a->base,0 ); +tcg_gen_concat_i64_i128 (zero128, zero64, zero64); + +/* +* QEMU models ZCB/ZCBT as zeroing the containing 128-byte cache line +* in guest memory. +*/ +tcg_gen_andi_i64 (line, addr, ~0x7fULL ); + +for (int i =0 ; i <8 ; i++) { +TCGv_i64 slot =tcg_temp_new_i64 (); + +tcg_gen_addi_i64 (slot, line, i *16 ); +tcg_gen_qemu_st_i128 (zero128, slot, ctx->mem_idx, mop); + } + +return true; +}TRANS (LBX , trans_lx,MO_SB );TRANS (LBUX , trans_lx,MO_UB );TRANS (LHX , trans_lx,MO_SW );
Signature · 1 line
2.54.0
PATCH v10 13/45 tcg: Introduce tcg_gen_addN_i64
In reply to James HilliardFrom: Richard Henderson <[email protected]>
Add a helper for multi-limb 64-bit addition. The helper emits native carry-chain TCG ops when they are available and falls back to explicit carry propagation otherwise.
This lets target translators build wider integer accumulators inline without open-coding the same add-with-carry sequence at each use site.
---
Changes v7 -> v8:
- New patch from Richard Henderson's v7.5 multiplier rework.
--- include/tcg/tcg-op-common.h | 1 + tcg/tcg-op.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+)
include/tcg/tcg-op-common.h +1 -0
@@ -251,6 +251,7 @@ void tcg_gen_sub2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 al, TCGv_i64 ah, TCGv_i64 bl, TCGv_i64 bh);void tcg_gen_addcio_i64 (TCGv_i64 r,TCGv_i64 co,TCGv_i64 a,TCGv_i64 b,TCGv_i64 ci); +void tcg_gen_addN_i64 (int n,TCGv_i64 *r,TCGv_i64 *a,TCGv_i64 *b);void tcg_gen_mulu2_i64 (TCGv_i64 rl,TCGv_i64 rh,TCGv_i64 arg1,TCGv_i64 arg2);void tcg_gen_muls2_i64 (TCGv_i64 rl,TCGv_i64 rh,TCGv_i64 arg1,TCGv_i64 arg2);void tcg_gen_mulsu2_i64 (TCGv_i64 rl,TCGv_i64 rh,TCGv_i64 arg1,TCGv_i64 arg2);
tcg/tcg-op.c +42 -0
48 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v10 14/45 tcg: Optimize INDEX_op_mul[us]2 for 0 and 1
In reply to James HilliardFrom: Richard Henderson <[email protected]>
Zero operands produce a zero high and low product. One operands produce a copy of the other operand and a zero or sign extension in the high half.
Fold those cases during TCG optimization so wide-multiply idioms used by target translators can collapse before code generation.
---
Changes v9 -> v10:
- Restore the original constant-fold output ordering.
Changes v7 -> v8:
- New patch from Richard Henderson's v7.5 multiplier rework.
--- tcg/optimize.c | 92 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 32 deletions(-)
tcg/optimize.c +60 -32
@@ -2173,45 +2173,73 @@ static bool fold_multiply2(OptContext *ctx, TCGOp *op) {swap_commutative (op->args[0 ], &op->args[2 ], &op->args[3 ]); -if (arg_is_const (op->args[2 ]) &&arg_is_const (op->args[3 ])) { -uint64_t a =arg_const_val (op->args[2 ]); +if (arg_is_const (op->args[3 ])) {uint64_t b =arg_const_val (op->args[3 ]); -uint64_t h, l; -TCGArg rl, rh; +TCGArg rl = op->args[0 ]; +TCGArg rh = op->args[1 ];TCGOp *op2; -switch (op->opc) { -case INDEX_op_mulu2: -if (ctx->type ==TCG_TYPE_I32 ) { - l = (uint64_t )(uint32_t )a * (uint32_t )b; - h = (int32_t )(l >>32 ); - l = (int32_t )l; - }else { -mulu64 (&l, &h, a, b); - } -break ; -case INDEX_op_muls2: -if (ctx->type ==TCG_TYPE_I32 ) { - l = (int64_t )(int32_t )a * (int32_t )b; - h = l >>32 ; - l = (int32_t )l; - }else { -muls64 (&l, &h, a, b); +if (arg_is_const (op->args[2 ])) { +uint64_t a =arg_const_val (op->args[2 ]); +uint64_t h, l; + +switch (op->opc) { +case INDEX_op_mulu2: +if (ctx->type ==TCG_TYPE_I32 ) { + l = (uint64_t )(uint32_t )a * (uint32_t )b; + h = (int32_t )(l >>32 ); + l = (int32_t )l; + }else { +mulu64 (&l, &h, a, b); + } +break ; +case INDEX_op_muls2: +if (ctx->type ==TCG_TYPE_I32 ) { + l = (int64_t )(int32_t )a * (int32_t )b; + h = l >>32 ; + l = (int32_t )l; + }else { +muls64 (&l, &h, a, b); + } +break ; +default : +g_assert_not_reached (); } -break ; -default : -g_assert_not_reached (); - } - rl = op->args[0 ]; - rh = op->args[1 ]; +/* The proper opcode is supplied by tcg_opt_gen_mov. */ + op2 =opt_insert_before (ctx, op,0 ,2 ); +tcg_opt_gen_movi (ctx, op, rl, l); +tcg_opt_gen_movi (ctx, op2, rh, h); +return true; + } -/* The proper opcode is supplied by tcg_opt_gen_mov. */ - op2 =opt_insert_before (ctx, op,0 ,2 ); +if (b ==0 ) { + op2 =opt_insert_before (ctx, op,0 ,2 ); +tcg_opt_gen_movi (ctx, op2, rl,0 ); +tcg_opt_gen_movi (ctx, op, rh,0 ); +return true; + } +if (b ==1 ) { + op2 =opt_insert_before (ctx, op,0 ,2 ); +tcg_opt_gen_mov (ctx, op2, rl, op->args[2 ]); + +switch (op->opc) { +case INDEX_op_mulu2: +tcg_opt_gen_movi (ctx, op, rh,0 ); +break ; +case INDEX_op_muls2: + op->opc = INDEX_op_sar; + op->args[0 ] = rh; + op->args[1 ] = rl; + op->args[2 ] = +arg_new_constant (ctx,tcg_type_size (ctx->type) *8 -1 ); +break ; +default : +g_assert_not_reached (); + } -tcg_opt_gen_movi (ctx, op, rl, l); -tcg_opt_gen_movi (ctx, op2, rh, h); -return true; +return true; + } }return finish_folding (ctx, op); }
Signature · 1 line
2.54.0
PATCH v10 15/45 target/mips: add Octeon multiplier state
In reply to James HilliardAdd per-thread Octeon multiplier state for the MPL and P limb banks used by the VMULU/VMM0/V3MULU instruction family.
Octeon3 extends the older MPL0-MPL2/P0-P2 state with high lanes MPL3-MPL5/P3-P5, programmed by the two-source MTM/MTP forms. Represent both banks as uint64_t arrays so the TC state matches the architected 64-bit limb layout used by Octeon68XX user-mode code.
Expose MPL/P as global TCG variables so the multiplier translators can expand inline without helper calls.
Migrate the multiplier registers in an Octeon-only subsection so non-Octeon CPU models do not grow migration state.
---
Changes v2 -> v3:
- Split the multiplier state out of the combined Octeon arithmetic and memory instruction patch. (requested by Richard Henderson)
Changes v3 -> v4:
- Document and keep the Octeon3 MPL3-MPL5/P3-P5 high-lane state used by the two-source MTM/MTP forms.
Changes v7 -> v8:
- Incorporate Richard Henderson's v7.5 global TCG variable setup for inline multiplier translation.
--- target/mips/cpu.h | 12 ++++++++++++ target/mips/system/machine.c | 33 +++++++++++++++++++++++++++++++++ target/mips/tcg/translate.c | 18 ++++++++++++++++++ target/mips/tcg/translate.h | 2 ++ 4 files changed, 65 insertions(+)
target/mips/cpu.h +12 -0
@@ -459,6 +459,14 @@ typedef struct mips_def_t mips_def_t;typedef struct TCState TCState ; + +/* +* Octeon3 adds a second bank of multiplier/product limbs used by the +* two-source MTM/MTP forms: MPL0..2/P0..2 from rs and MPL3..5/P3..5 from rt. +*/ +#define OCTEON_MULTIPLIER_LANES 3 +#define OCTEON_MULTIPLIER_REGS (2 * OCTEON_MULTIPLIER_LANES) +struct TCState {target_ulong gpr[32 ];#if defined(TARGET_MIPS64 )
@@ -497,6 +505,10 @@ struct TCState {target_ulong CP0_TCScheFBack;int32_t CP0_Debug_tcstatus;target_ulong CP0_UserLocal; +struct { +uint64_t MPL[OCTEON_MULTIPLIER_REGS ]; +uint64_t P[OCTEON_MULTIPLIER_REGS ]; + } octeon;int32_t msacsr;
target/mips/system/machine.c +33 -0
@@ -120,6 +120,17 @@ static const VMStateDescription vmstate_inactive_tc = { .fields = vmstate_tc_fields }; +static const VMStateDescription vmstate_octeon_multiplier_tc = { + .name ="cpu/tc/octeon_multiplier" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (const VMStateField []) { +VMSTATE_UINT64_ARRAY (octeon.MPL, TCState,OCTEON_MULTIPLIER_REGS ), +VMSTATE_UINT64_ARRAY (octeon.P, TCState,OCTEON_MULTIPLIER_REGS ), +VMSTATE_END_OF_LIST () + } +}; +/* MVP state */ static const VMStateDescription vmstate_mvp = {
@@ -247,6 +258,27 @@ static const VMStateDescription mips_vmstate_timer = { } }; +static bool mips_octeon_needed (void *opaque) +{ +MIPSCPU *cpu = opaque; + +return cpu->env.insn_flags &INSN_OCTEON ; +} + +static const VMStateDescription mips_vmstate_octeon_multiplier = { + .name ="cpu/octeon_multiplier" , + .version_id =1 , + .minimum_version_id =1 , + .needed = mips_octeon_needed, + .fields = (const VMStateField []) { +VMSTATE_STRUCT (env.active_tc,MIPSCPU ,1 , + vmstate_octeon_multiplier_tc, TCState), +VMSTATE_STRUCT_ARRAY (env.tcs,MIPSCPU ,MIPS_SHADOW_SET_MAX ,1 , + vmstate_octeon_multiplier_tc, TCState), +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_mips_cpu = { .name ="cpu" , .version_id =21 ,
@@ -363,6 +395,7 @@ const VMStateDescription vmstate_mips_cpu = { }, .subsections = (const VMStateDescription * const []) { &mips_vmstate_timer, + &mips_vmstate_octeon_multiplier,NULL } };
target/mips/tcg/translate.c +18 -0
@@ -1179,6 +1179,8 @@ static TCGv cpu_lladdr, cpu_llval;static TCGv_i32 hflags;TCGv_i32 fpu_fcr0, fpu_fcr31;TCGv_i64 fpu_f64[32 ]; +TCGv_i64 oct_mpl[OCTEON_MULTIPLIER_REGS ]; +TCGv_i64 oct_p[OCTEON_MULTIPLIER_REGS ];static const char regnames_HI[][4 ] = {"HI0" ,"HI1" ,"HI2" ,"HI3" ,
@@ -15276,6 +15278,22 @@ void mips_tcg_init(void) active_tc.gpr_hi[i]), rname); } + +for (unsigned i =0 ; i <OCTEON_MULTIPLIER_REGS ; ++i) { +static const char mpl_names[OCTEON_MULTIPLIER_REGS ][5 ] = { +"MPL0" ,"MPL1" ,"MPL2" ,"MPL3" ,"MPL4" ,"MPL5" , + }; +static const char p_names[OCTEON_MULTIPLIER_REGS ][3 ] = { +"P0" ,"P1" ,"P2" ,"P3" ,"P4" ,"P5" , + }; + + oct_mpl[i] =tcg_global_mem_new_i64 ( + tcg_env, offsetof(CPUMIPSState, active_tc.octeon.MPL[i]), + mpl_names[i]); + oct_p[i] =tcg_global_mem_new_i64 ( + tcg_env, offsetof(CPUMIPSState, active_tc.octeon.P[i]), + p_names[i]); + }#endif /* !TARGET_MIPS64 */ for (unsigned i =0 ; i <32 ; i++) { int off = offsetof(CPUMIPSState, active_fpu.fpr[i].wr.d[0]);
target/mips/tcg/translate.h +2 -0
@@ -189,6 +189,8 @@ void gen_crc32(DisasContext *ctx, int rd, int rs, int rt, int sz, int crc32c);extern TCGv cpu_gpr[32 ], cpu_PC;#if defined(TARGET_MIPS64 )extern TCGv_i64 cpu_gpr_hi[32 ]; +extern TCGv_i64 oct_mpl[OCTEON_MULTIPLIER_REGS ]; +extern TCGv_i64 oct_p[OCTEON_MULTIPLIER_REGS ];#endif extern TCGv cpu_HI[MIPS_DSP_ACC ], cpu_LO[MIPS_DSP_ACC ];extern TCGv_i32 fpu_fcr0, fpu_fcr31;
Signature · 1 line
2.54.0
PATCH v10 16/45 target/mips: add Octeon MTM instructions
In reply to James HilliardAdd the MTM0, MTM1, and MTM2 forms that load the Octeon3 multiplier operand pair from rs/rt into MPL[x] and MPL[x+3], then clear the partial products. For MPL0, also set MPL[1] to zero for backward compatibility with Octeon2 VMULU.
Legacy single-source encodings have rt encoded as $zero, so the same translator path also preserves the older Octeon behavior.
---
Changes v2 -> v3:
- Split MTM0 out of the combined Octeon arithmetic and memory instruction patch. (requested by Richard Henderson)
Changes v3 -> v4:
- Keep the Octeon3 two-source rt high-lane operand and document that
legacy one-source MTM encodings use rt == $zero.
Changes v5 -> v6:
- Clarify the CN71XX-defined MPL1 zeroing after checking the register-state table and description.
Changes v7 -> v8:
- Combine MTM0/MTM1/MTM2 in the v7.5 inline TCG translator form from Richard Henderson.
--- target/mips/tcg/octeon.decode | 7 +++++++ target/mips/tcg/octeon_translate.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+)
target/mips/tcg/octeon.decode +7 -0
@@ -44,6 +44,13 @@ SNE 011100 ..... ..... ..... 00000 101011 @r3 SEQI 011100 rs:5 rt:5 imm:s10 101110 &cmpi SNEI 011100 rs:5 rt:5 imm:s10 101111 &cmpi +&r2 rs rt +@r2 ...... rs:5 rt:5 ..... ..... ...... &r2 + +MTM0 011100 ..... ..... 00000 00000 001000 @r2 +MTM1 011100 ..... ..... 00000 00000 001100 @r2 +MTM2 011100 ..... ..... 00000 00000 001101 @r2 + &saa base rt @saa ...... base:5 rt:5 ................ &saa SAA 011100 ..... ..... 00000 00000 011000 @saa
target/mips/tcg/octeon_translate.c +32 -0
@@ -210,3 +210,35 @@ TRANS(LHUX, trans_lx, MO_UW);TRANS (LWX , trans_lx,MO_SL );TRANS (LWUX , trans_lx,MO_UL );TRANS (LDX , trans_lx,MO_UQ ); + +static void octeon_zero_partial_product_state (void ) +{ +for (int i =0 ; i <OCTEON_MULTIPLIER_REGS ; i++) { +tcg_gen_movi_i64 (oct_p[i],0 ); + } +} + +static bool trans_mtm (DisasContext *ctx,arg_r2 *a,unsigned int index) +{ +/* +* Octeon3 two-source MTM forms load lane index from rs and lane index + 3 +* from rt. Legacy one-source forms encode rt as $zero. +*/ +gen_load_gpr (oct_mpl[index], a->rs); +gen_load_gpr (oct_mpl[index +3 ], a->rt); + +/* +* Octeon3 clears MPL1 with MPL0 so that VMULU sequences remain +* backward compatible with Octeon2. +*/ +if (index ==0 ) { +tcg_gen_movi_i64 (oct_mpl[1 ],0 ); + } + +octeon_zero_partial_product_state (); +return true; +} + +TRANS (MTM0 , trans_mtm,0 ); +TRANS (MTM1 , trans_mtm,1 ); +TRANS (MTM2 , trans_mtm,2 );
Signature · 1 line
2.54.0
PATCH v10 17/45 target/mips: add Octeon MTP instructions
In reply to James HilliardAdd the MTP0, MTP1, and MTP2 forms. MTP0 loads the low Octeon3 partial-product pair from rs/rt into P[0]/P[3], MTP1 loads the middle pair into P[1]/P[4], and MTP2 loads the high pair into P[2]/P[5]. For MTP0, also set P[1] to zero for backward compatibility with Octeon2 VMULU.
Legacy single-source encodings have rt encoded as $zero, so the same translator path also preserves the older Octeon behavior.
---
Changes v2 -> v3:
- Split MTP0/MTP1/MTP2 out of the combined Octeon arithmetic and memory instruction patch. (requested by Richard Henderson)
Changes v3 -> v4:
- Keep the Octeon3 two-source rt high-lane operand and document that
legacy one-source MTP encodings use rt == $zero.
Changes v5 -> v6:
- Zero P1 after checking the CN71XX register-state table and description.
Changes v7 -> v8:
- Combine MTP0/MTP1/MTP2 in the v7.5 inline TCG translator form from Richard Henderson.
--- target/mips/tcg/octeon.decode | 4 ++++ target/mips/tcg/octeon_translate.c | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+)
target/mips/tcg/octeon.decode +4 -0
@@ -51,6 +51,10 @@ MTM0 011100 ..... ..... 00000 00000 001000 @r2 MTM1 011100 ..... ..... 00000 00000 001100 @r2 MTM2 011100 ..... ..... 00000 00000 001101 @r2 +MTP0 011100 ..... ..... 00000 00000 001001 @r2 +MTP1 011100 ..... ..... 00000 00000 001010 @r2 +MTP2 011100 ..... ..... 00000 00000 001011 @r2 + &saa base rt @saa ...... base:5 rt:5 ................ &saa SAA 011100 ..... ..... 00000 00000 011000 @saa
target/mips/tcg/octeon_translate.c +23 -0
@@ -242,3 +242,26 @@ static bool trans_mtm(DisasContext *ctx, arg_r2 *a, unsigned int index)TRANS (MTM0 , trans_mtm,0 );TRANS (MTM1 , trans_mtm,1 );TRANS (MTM2 , trans_mtm,2 ); + +static bool trans_mtp (DisasContext *ctx,arg_r2 *a,unsigned int index) +{ +/* +* Octeon3 two-source MTP forms load lane index from rs and lane index + 3 +* from rt. Legacy one-source forms encode rt as $zero. +*/ +gen_load_gpr (oct_p[index], a->rs); +gen_load_gpr (oct_p[index +3 ], a->rt); + +/* +* Octeon3 clears P1 with P0 so that VMULU sequences remain +* backward compatible with Octeon2. +*/ +if (index ==0 ) { +tcg_gen_movi_i64 (oct_p[1 ],0 ); + } +return true; +} + +TRANS (MTP0 , trans_mtp,0 ); +TRANS (MTP1 , trans_mtp,1 ); +TRANS (MTP2 , trans_mtp,2 );
Signature · 1 line
2.54.0
PATCH v10 18/45 target/mips: add Octeon VMULU instruction
In reply to James HilliardVMULU multiplies the active Octeon multiplier state by rs, adds rt and queued partial products, returns the low result, and advances P[0]/P[1] with carry limbs.
Expand the two-limb accumulator operation inline with TCG so the result and partial-product state stay visible to the optimizer.
---
Changes v2 -> v3:
- Split VMULU out of the combined Octeon arithmetic and memory instruction patch. (requested by Richard Henderson)
Changes v5 -> v6:
- Rename the translator helper callback typedef for clarity.
Changes v7 -> v8:
- Use Richard Henderson's v7.5 inline TCG translator with
tcg_gen_addN_i64. --- target/mips/tcg/octeon.decode | 2 ++ target/mips/tcg/octeon_translate.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+)
target/mips/tcg/octeon.decode +2 -0
@@ -55,6 +55,8 @@ MTP0 011100 ..... ..... 00000 00000 001001 @r2 MTP1 011100 ..... ..... 00000 00000 001010 @r2 MTP2 011100 ..... ..... 00000 00000 001011 @r2 +VMULU 011100 ..... ..... ..... 00000 001111 @r3 + &saa base rt @saa ...... base:5 rt:5 ................ &saa SAA 011100 ..... ..... 00000 00000 011000 @saa
target/mips/tcg/octeon_translate.c +35 -0
@@ -265,3 +265,38 @@ static bool trans_mtp(DisasContext *ctx, arg_r2 *a, unsigned int index)TRANS (MTP0 , trans_mtp,0 );TRANS (MTP1 , trans_mtp,1 );TRANS (MTP2 , trans_mtp,2 ); + +static bool trans_VMULU (DisasContext *ctx,arg_VMULU *a) +{ +TCGv_i64 x[3 ], y[3 ], z[3 ]; +TCGv_i64 tmp =tcg_temp_new_i64 (); +TCGv_i64 zero =tcg_constant_i64 (0 ); + + z[0 ] = y[0 ] =tcg_temp_new_i64 (); + z[1 ] = y[1 ] =tcg_temp_new_i64 (); + z[2 ] = y[2 ] =tcg_temp_new_i64 (); + x[0 ] =tcg_temp_new_i64 (); + x[1 ] =tcg_temp_new_i64 (); + x[2 ] = zero; + +/* Z = rs * (mpl1 : mpl0) + rt */ +gen_load_gpr (tmp, a->rs); +gen_load_gpr (y[0 ], a->rt); +tcg_gen_mulu2_i64 (x[0 ], x[1 ], tmp, oct_mpl[0 ]); +tcg_gen_mulu2_i64 (y[1 ], y[2 ], tmp, oct_mpl[1 ]); +tcg_gen_addN_i64 (3 , z, y, x); + +/* X == (0 : p1 : p0) */ + x[0 ] = oct_p[0 ]; + x[1 ] = oct_p[1 ]; + +/* Y == (p1 : p0 : tmp) */ + y[0 ] = tmp; + y[1 ] = oct_p[0 ]; + y[2 ] = oct_p[1 ]; + +/* (p1 : p0 : rd) = Z + (0 : p1 : p0) */ +tcg_gen_addN_i64 (3 , y, z, x); +gen_store_gpr (tmp, a->rd); +return true; +}
Signature · 1 line
2.54.0
PATCH v10 19/45 target/mips: add Octeon VMM0 instruction
In reply to James HilliardVMM0 multiplies MPL[0] by rs, adds rt and the queued P[0] partial product, returns the low result, and feeds that result back into MPL[0]. It sets MPL[1] to zero and clears partial products.
---
Changes v8 -> v9:
- Reuse octeon_zero_partial_product_state() for partial-product clearing.
Changes v2 -> v3:
- Split VMM0 out of the combined Octeon arithmetic and memory instruction patch. (requested by Richard Henderson)
Changes v3 -> v4:
- Document the Octeon3 chain update behavior.
Changes v5 -> v6:
- Zero MPL1 after checking the CN71XX VMM0 definition and add MPL1 smoke coverage.
Changes v7 -> v8:
- Use Richard Henderson's v7.5 inline TCG translator, which keeps only the architecturally defined MPL1 and partial-product clearing.
--- target/mips/tcg/octeon.decode | 1 + target/mips/tcg/octeon_translate.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+)
target/mips/tcg/octeon.decode +1 -0
@@ -56,6 +56,7 @@ MTP1 011100 ..... ..... 00000 00000 001010 @r2 MTP2 011100 ..... ..... 00000 00000 001011 @r2 VMULU 011100 ..... ..... ..... 00000 001111 @r3 +VMM0 011100 ..... ..... ..... 00000 010000 @r3 &saa base rt @saa ...... base:5 rt:5 ................ &saa
target/mips/tcg/octeon_translate.c +16 -0
@@ -300,3 +300,19 @@ static bool trans_VMULU(DisasContext *ctx, arg_VMULU *a)gen_store_gpr (tmp, a->rd);return true; } + +static bool trans_VMM0 (DisasContext *ctx,arg_VMM0 *a) +{ +TCGv_i64 tmp =tcg_temp_new_i64 (); + +gen_load_gpr (tmp, a->rs); +tcg_gen_mul_i64 (oct_mpl[0 ], oct_mpl[0 ], tmp); +gen_load_gpr (tmp, a->rt); +tcg_gen_add_i64 (oct_mpl[0 ], oct_mpl[0 ], tmp); +tcg_gen_add_i64 (oct_mpl[0 ], oct_mpl[0 ], oct_p[0 ]); +gen_store_gpr (oct_mpl[0 ], a->rd); + +tcg_gen_movi_i64 (oct_mpl[1 ],0 ); +octeon_zero_partial_product_state (); +return true; +}
Signature · 1 line
2.54.0
PATCH v10 20/45 target/mips: add Octeon V3MULU instruction
In reply to James HilliardV3MULU extends VMULU across the full Octeon3 multiplier state, adding rt and queued partial products.
Return the low result while shifting the remaining accumulated limbs back into P[0] through P[5].
---
Changes v2 -> v3:
- Split V3MULU out of the combined Octeon arithmetic and memory instruction patch. (requested by Richard Henderson)
Changes v3 -> v4:
- Keep the Octeon3 MPL3-MPL5/P3-P5 high lanes used by the two-source MTM/MTP forms and Cavium SDK/runtime code.
Changes v7 -> v8:
- Use Richard Henderson's v7.5 inline TCG translator with
tcg_gen_addN_i64. --- target/mips/tcg/octeon.decode | 1 + target/mips/tcg/octeon_translate.c | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+)
target/mips/tcg/octeon.decode +1 -0
@@ -57,6 +57,7 @@ MTP2 011100 ..... ..... 00000 00000 001011 @r2 VMULU 011100 ..... ..... ..... 00000 001111 @r3 VMM0 011100 ..... ..... ..... 00000 010000 @r3 +V3MULU 011100 ..... ..... ..... 00000 010001 @r3 &saa base rt @saa ...... base:5 rt:5 ................ &saa
target/mips/tcg/octeon_translate.c +40 -0
@@ -316,3 +316,43 @@ static bool trans_VMM0(DisasContext *ctx, arg_VMM0 *a)octeon_zero_partial_product_state ();return true; } + +static bool trans_V3MULU (DisasContext *ctx,arg_V3MULU *a) +{ +TCGv_i64 x[7 ], y[7 ], z[7 ]; +TCGv_i64 tmp =tcg_temp_new_i64 (); + +for (int i =0 ; i <7 ; ++i) { + z[i] =tcg_temp_new_i64 (); + y[i] =tcg_temp_new_i64 (); + } +memcpy (&x[0 ], z,6 *sizeof (TCGv_i64)); + x[6 ] =tcg_constant_i64 (0 ); + +/* +* Z = rs * mpl -- 64x384->448 bit multiply +* Compute even partial products into X and odd partial products into Y. +* Include RT into the odd partial products, which are 0 in bits [63:0]. +*/ +gen_load_gpr (tmp, a->rs); +gen_load_gpr (y[0 ], a->rt); +for (int i =0 ; i <6 ; i +=2 ) { +tcg_gen_mulu2_i64 (x[i +0 ], x[i +1 ], tmp, oct_mpl[i]); +tcg_gen_mulu2_i64 (y[i +1 ], y[i +2 ], tmp, oct_mpl[i +1 ]); + } + +/* Sum even and odd to produce final product, plus rt. */ +tcg_gen_addN_i64 (7 , z, x, y); + +/* X == (0 : p5 : p4 : p3 : p2 : p1 : p0) -- x[6] is still 0 */ +memcpy (&x[0 ], oct_p,6 *sizeof (TCGv_i64)); + +/* Y == (p5 : p4 : p3 : p2 : p1 : p0 : tmp) */ +memcpy (&y[1 ], oct_p,6 *sizeof (TCGv_i64)); + y[0 ] = tmp; + +/* (p* : rd) = (0 : p*) + (rs * mpl + rt) */ +tcg_gen_addN_i64 (7 , y, x, z); +gen_store_gpr (tmp, a->rd); +return true; +}
Signature · 1 line
2.54.0
PATCH v10 21/45 target/mips: add Octeon QMAC instructions
In reply to James HilliardQMAC.0x and QMACS.0x multiply the selected signed Q15 halfword lane from rs by rt<15:0> and accumulate the Q31 product into the Octeon HI/LO accumulator state.
QMAC updates the full 64-bit HI/LO accumulator. QMACS saturates the 32-bit Q31 result in LO and keeps HI<0> as the sticky saturation flag.
---
Changes v5 -> v6:
- New patch.
Changes v7 -> v8:
- Use Richard Henderson's v7.5 inline TCG translator.
--- target/mips/tcg/octeon.decode | 4 +++ target/mips/tcg/octeon_translate.c | 60 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+)
target/mips/tcg/octeon.decode +4 -0
@@ -28,6 +28,8 @@ BBIT 11 set:1 . 10 rs:5 ..... offset:s16 p=%bbit_p # SEQI rt, rs, immediate # SNE rd, rs, rt # SNEI rt, rs, immediate +# QMAC.0x rs, rt +# QMACS.0x rs, rt @r3 ...... rs:5 rt:5 rd:5 ..... ...... &cmpi rs rt imm
@@ -43,6 +45,8 @@ SEQ 011100 ..... ..... ..... 00000 101010 @r3 SNE 011100 ..... ..... ..... 00000 101011 @r3 SEQI 011100 rs:5 rt:5 imm:s10 101110 &cmpi SNEI 011100 rs:5 rt:5 imm:s10 101111 &cmpi +QMACS 011100 rs:5 rt:5 00000 000 lane:2 010010 +QMAC 011100 rs:5 rt:5 00000 100 lane:2 010010 &r2 rs rt @r2 ...... rs:5 rt:5 ..... ..... ...... &r2
target/mips/tcg/octeon_translate.c +60 -0
63 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v10 22/45 tests/tcg/mips: add Octeon instruction smoke test
In reply to James HilliardAdd a mips64/mips64el linux-user TCG smoke test for representative Octeon integer, comparison, population count, and multiplier instruction paths. Include hardware-backed regression coverage for VMM0 MPL1 zeroing and MTP0 P1 zeroing.
Run the test with -cpu Octeon68XX and share the source between the mips64 and mips64el target directories.
---
Changes v2 -> v3:
- Split the smoke test out of the combined Octeon arithmetic and memory instruction patch. (requested by Richard Henderson)
Changes v5 -> v6:
- Add VMM0/MPL1 and MTP0/P1 reset checks for the CN71XX-defined reset-state behavior.
--- tests/tcg/mips/user/isa/octeon/octeon-insns.c | 204 ++++++++++++++++++++++++++ tests/tcg/mips64/Makefile.target | 20 +++ tests/tcg/mips64el/Makefile.target | 8 + 3 files changed, 232 insertions(+)
tests/tcg/mips/user/isa/octeon/octeon-insns.c new file +204 -0
@@ -0,0 +1,204 @@ +/* +* Test Octeon-specific user-mode instructions. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include <assert.h> +#include <stdint.h> + +static uint64_t octeon_baddu (uint64_t rs,uint64_t rt) +{ +uint64_t rd; + + asmvolatile ( +"move $8, %[rs]\n\t" +"move $9, %[rt]\n\t" +".word 0x71095028\n\t" /* baddu $10, $8, $9 */ +"move %[rd], $10\n\t" + : [rd]"=r" (rd) + : [rs]"r" (rs), [rt]"r" (rt) + :"$8" ,"$9" ,"$10" ); + +return rd; +} + +static uint64_t octeon_dmul (uint64_t rs,uint64_t rt) +{ +uint64_t rd; + + asmvolatile ( +"move $8, %[rs]\n\t" +"move $9, %[rt]\n\t" +".word 0x71095003\n\t" /* dmul $10, $8, $9 */ +"move %[rd], $10\n\t" + : [rd]"=r" (rd) + : [rs]"r" (rs), [rt]"r" (rt) + :"$8" ,"$9" ,"$10" ); + +return rd; +} + +static uint64_t octeon_dpop (uint64_t rs) +{ +uint64_t rd; + + asmvolatile ( +"move $8, %[rs]\n\t" +".word 0x7100502d\n\t" /* dpop $10, $8 */ +"move %[rd], $10\n\t" + : [rd]"=r" (rd) + : [rs]"r" (rs) + :"$8" ,"$10" ); + +return rd; +} + +static uint64_t octeon_seq (uint64_t rs,uint64_t rt) +{ +uint64_t rd; + + asmvolatile ( +"move $8, %[rs]\n\t" +"move $9, %[rt]\n\t" +".word 0x7109502a\n\t" /* seq $10, $8, $9 */ +"move %[rd], $10\n\t" + : [rd]"=r" (rd) + : [rs]"r" (rs), [rt]"r" (rt) + :"$8" ,"$9" ,"$10" ); + +return rd; +} + +static uint64_t octeon_sne (uint64_t rs,uint64_t rt) +{ +uint64_t rd; + + asmvolatile ( +"move $8, %[rs]\n\t" +"move $9, %[rt]\n\t" +".word 0x7109502b\n\t" /* sne $10, $8, $9 */ +"move %[rd], $10\n\t" + : [rd]"=r" (rd) + : [rs]"r" (rs), [rt]"r" (rt) + :"$8" ,"$9" ,"$10" ); + +return rd; +} + +static uint64_t octeon_vmulu (uint64_t mpl0,uint64_t rs,uint64_t rt) +{ +uint64_t rd; + + asmvolatile ( +"move $8, %[mpl0]\n\t" +"move $9, $0\n\t" +".word 0x71090008\n\t" /* mtm0 $8, $9 */ +"move $8, %[rs]\n\t" +"move $9, %[rt]\n\t" +".word 0x7109500f\n\t" /* vmulu $10, $8, $9 */ +"move %[rd], $10\n\t" + : [rd]"=r" (rd) + : [mpl0]"r" (mpl0), [rs]"r" (rs), [rt]"r" (rt) + :"$8" ,"$9" ,"$10" ); + +return rd; +} + +static uint64_t octeon_vmm0 (uint64_t mpl0,uint64_t p0, +uint64_t rs,uint64_t rt) +{ +uint64_t rd; + + asmvolatile ( +"move $8, %[mpl0]\n\t" +"move $9, $0\n\t" +".word 0x71090008\n\t" /* mtm0 $8, $9 */ +"move $8, %[p0]\n\t" +"move $9, $0\n\t" +".word 0x71090009\n\t" /* mtp0 $8, $9 */ +"move $8, %[rs]\n\t" +"move $9, %[rt]\n\t" +".word 0x71095010\n\t" /* vmm0 $10, $8, $9 */ +"move %[rd], $10\n\t" + : [rd]"=r" (rd) + : [mpl0]"r" (mpl0), [p0]"r" (p0), + [rs]"r" (rs), [rt]"r" (rt) + :"$8" ,"$9" ,"$10" ); + +return rd; +} + +static uint64_t octeon_vmm0_zeroes_mpl1 (void ) +{ +uint64_t rd; + + asmvolatile ( +"move $8, %[mpl0]\n\t" +"move $9, $0\n\t" +".word 0x71090008\n\t" /* mtm0 $8, $9 */ +"move $8, %[mpl1]\n\t" +"move $9, $0\n\t" +".word 0x7109000c\n\t" /* mtm1 $8, $9 */ +"move $8, %[vmm0_rs]\n\t" +"move $9, $0\n\t" +".word 0x71095010\n\t" /* vmm0 $10, $8, $9 */ +"move $8, %[vmulu_rs]\n\t" +"move $9, $0\n\t" +".word 0x7109500f\n\t" /* vmulu $10, $8, $9 */ +"move $8, $0\n\t" +"move $9, $0\n\t" +".word 0x7109500f\n\t" /* vmulu $10, $8, $9 */ +"move %[rd], $10\n\t" + : [rd]"=r" (rd) + : [mpl0]"r" (1ULL ), [mpl1]"r" (1ULL ), + [vmm0_rs]"r" (2ULL ), [vmulu_rs]"r" (1ULL ) + :"$8" ,"$9" ,"$10" ); + +return rd; +} + +static uint64_t octeon_mtp0_zeroes_p1 (void ) +{ +uint64_t rd; + + asmvolatile ( +"move $8, %[mpl0]\n\t" +"move $9, $0\n\t" +".word 0x71090008\n\t" /* mtm0 $8, $9 */ +"move $8, %[p1]\n\t" +"move $9, $0\n\t" +".word 0x7109000a\n\t" /* mtp1 $8, $9 */ +"move $8, $0\n\t" +"move $9, $0\n\t" +".word 0x71090009\n\t" /* mtp0 $8, $9 */ +"move $8, $0\n\t" +"move $9, $0\n\t" +".word 0x7109500f\n\t" /* vmulu $10, $8, $9 */ +"move $8, $0\n\t" +"move $9, $0\n\t" +".word 0x7109500f\n\t" /* vmulu $10, $8, $9 */ +"move %[rd], $10\n\t" + : [rd]"=r" (rd) + : [mpl0]"r" (0ULL ), [p1]"r" (1ULL ) + :"$8" ,"$9" ,"$10" ); + +return rd; +} + +int main (void ) +{ +assert (octeon_baddu (0x123 ,0x0f0 ) ==0x13 ); +assert (octeon_dmul (0x12345678 ,0x10 ) ==0x123456780 ); +assert (octeon_dpop (0xf0f0f0f0f0f0f0f0ULL ) ==32 ); +assert (octeon_seq (0xabc ,0xabc ) ==1 ); +assert (octeon_seq (0xabc ,0xdef ) ==0 ); +assert (octeon_sne (0xabc ,0xabc ) ==0 ); +assert (octeon_sne (0xabc ,0xdef ) ==1 ); +assert (octeon_vmulu (5 ,7 ,11 ) ==46 ); +assert (octeon_vmm0 (5 ,13 ,7 ,11 ) ==59 ); +assert (octeon_vmm0_zeroes_mpl1 () ==0 ); +assert (octeon_mtp0_zeroes_p1 () ==0 ); + +return 0 ; +}
tests/tcg/mips64/Makefile.target new file +20 -0
@@ -0,0 +1,20 @@ +# -*- Mode: makefile -*- +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +# MIPS64 - included from tests/tcg/Makefile.target +# + +MIPS64_SRC=$(SRC_PATH)/tests/tcg/mips64 +MIPS_OCTEON_SRC=$(SRC_PATH)/tests/tcg/mips/user/isa/octeon + +# Set search path for all sources +VPATH += $(MIPS64_SRC) $(MIPS_OCTEON_SRC) + +MIPS64_TESTS=octeon-insns + +TESTS += $(MIPS64_TESTS) + +$(MIPS64_TESTS): CFLAGS+=-mabi=64 + +run-octeon-insns: QEMU_OPTS+=-cpu Octeon68XX
tests/tcg/mips64el/Makefile.target new file +8 -0
@@ -0,0 +1,8 @@ +# -*- Mode: makefile -*- +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +# MIPS64 little-endian - included from tests/tcg/Makefile.target +# + +include $(SRC_PATH)/tests/tcg/mips64/Makefile.target
Signature · 1 line
2.54.0
PATCH v10 23/45 target/mips: add Octeon LA* atomic instructions
In reply to James HilliardImplement the Octeon LA* read-modify-write atomic instruction family:
LAI/LAID, LAD/LADD, LAA/LAAD, LAS/LASD, LAC/LACD, and LAW/LAWD.
These operations are architecturally distinct from SAA/SAAD and are used by existing Octeon user-mode code for atomic counters, bit operations, and exchange-style updates.
---
Changes v1 -> v2:
- Keep LA* atomics naturally aligned per Octeon L2 transaction semantics.
- Use explicit i64 TCG ops in the LA* translator paths. (suggested by Philippe Mathieu-Daudé)
Changes v2 -> v3:
- Drop redundant TARGET_LONG_BITS guards from doubleword atomic paths. (suggested by Richard Henderson)
- Group LA* translator wrappers by argument shape instead of adding one wrapper per instruction. (suggested by Richard Henderson)
Changes v3 -> v4:
- Use i64 atomic helpers for both word and doubleword paths and select word sign-extension through MO_SL. (suggested by Richard Henderson)
Changes v5 -> v6:
- Rename the shared translator helpers to distinguish fetch-add and exchange operations.
--- target/mips/tcg/octeon.decode | 17 +++++++++ target/mips/tcg/octeon_translate.c | 75 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+)
target/mips/tcg/octeon.decode +17 -0
@@ -68,6 +68,23 @@ V3MULU 011100 ..... ..... ..... 00000 010001 @r3 SAA 011100 ..... ..... 00000 00000 011000 @saa SAAD 011100 ..... ..... 00000 00000 011001 @saa +&la base rd +&laa base add rd +@la ...... base:5 ..... rd:5 ........... &la +@laa ...... base:5 add:5 rd:5 ........... &laa +LAI 011100 ..... 00000 ..... 00010 011111 @la +LAID 011100 ..... 00000 ..... 00011 011111 @la +LAD 011100 ..... 00000 ..... 00110 011111 @la +LADD 011100 ..... 00000 ..... 00111 011111 @la +LAA 011100 ..... ..... ..... 10010 011111 @laa +LAAD 011100 ..... ..... ..... 10011 011111 @laa +LAS 011100 ..... 00000 ..... 01010 011111 @la +LASD 011100 ..... 00000 ..... 01011 011111 @la +LAC 011100 ..... 00000 ..... 01110 011111 @la +LACD 011100 ..... 00000 ..... 01111 011111 @la +LAW 011100 ..... ..... ..... 10110 011111 @laa +LAWD 011100 ..... ..... ..... 10111 011111 @laa + &zcb base ZCB 011100 base:5 00000 00000 1110- 011111 &zcb
target/mips/tcg/octeon_translate.c +75 -0
84 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v10 24/45 target/mips: add Octeon COP2 crypto state
In reply to James HilliardAdd the common architectural state needed by Octeon's selector-driven COP2 crypto interfaces. This includes storage for the base hash, AES, CRC, GFM, 3DES, KASUMI, and overlapping HSH/SHA512/SHA3/SNOW3G/ZUC selector windows.
Keep selector values and helper-local aliasing logic out of the CPU state header so the state definition remains limited to architectural storage. Helper code uses the same register banks instead of adding non-architectural shadow state.
Migrate the state in an Octeon-only subsection so non-Octeon CPU models do not grow migration data.
---
Changes v9 -> v10:
- Drop non-architectural shared-mode, AES input/result split, GFM XOR, and ZUC/SNOW3G shadow state.
- Model HSH/SHA512/SHA3/SNOW3G/ZUC overlap with the architectural HSH DAT/IV register banks.
- Store CRCLEN as the architectural 4-bit state.
Changes v8 -> v9:
- Remove the MIPSOcteonCop2Sel enum; selector values are decoded by decodetree or kept local to helper plumbing.
- Leave only COP2 state and migration data in this patch.
Changes v7 -> v8:
- Split COP2 crypto state and migration coverage out of the combined COP2 crypto core patch.
--- target/mips/cpu.h | 23 +++++++++++++++++++++++ target/mips/system/machine.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+)
target/mips/cpu.h +23 -0
@@ -537,6 +537,27 @@ struct TCState { };struct MIPSITUState ; +typedef struct MIPSOcteonCryptoState { +uint64_t hsh_dat[16 ]; +uint64_t hsh_iv[8 ]; +uint64_t sha3_dat24; +uint64_t gfm_reflect_mul[2 ]; +uint64_t gfm_reflect_resinp[2 ]; +uint64_t des3_key[3 ]; +uint64_t des3_iv; +uint64_t des3_result; +uint64_t aes_resinp[2 ]; +uint64_t aes_iv[2 ]; +uint64_t aes_key[4 ]; +uint32_t crc_poly; +uint32_t crc_iv; +uint64_t gfm_mul[2 ]; +uint64_t gfm_resinp[2 ]; +uint16_t gfm_poly; +uint8_t aes_keylen; +uint8_t crc_len; +}MIPSOcteonCryptoState ; + typedef struct CPUArchState { TCState active_tc; CPUMIPSFPUContext active_fpu;
@@ -558,6 +579,8 @@ typedef struct CPUArchState {#define MSAIR_ProcID 8#define MSAIR_Rev 0 +MIPSOcteonCryptoState octeon_crypto; +/* * CP0 Register 0 */
target/mips/system/machine.c +29 -0
@@ -279,6 +279,34 @@ static const VMStateDescription mips_vmstate_octeon_multiplier = { } }; +static const VMStateDescription mips_vmstate_octeon_crypto = { + .name ="cpu/octeon_crypto" , + .version_id =1 , + .minimum_version_id =1 , + .needed = mips_octeon_needed, + .fields = (const VMStateField []) { +VMSTATE_UINT64_ARRAY (env.octeon_crypto.hsh_dat,MIPSCPU ,16 ), +VMSTATE_UINT64_ARRAY (env.octeon_crypto.hsh_iv,MIPSCPU ,8 ), +VMSTATE_UINT64 (env.octeon_crypto.sha3_dat24,MIPSCPU ), +VMSTATE_UINT64_ARRAY (env.octeon_crypto.gfm_reflect_mul,MIPSCPU ,2 ), +VMSTATE_UINT64_ARRAY (env.octeon_crypto.gfm_reflect_resinp,MIPSCPU ,2 ), +VMSTATE_UINT64_ARRAY (env.octeon_crypto.des3_key,MIPSCPU ,3 ), +VMSTATE_UINT64 (env.octeon_crypto.des3_iv,MIPSCPU ), +VMSTATE_UINT64 (env.octeon_crypto.des3_result,MIPSCPU ), +VMSTATE_UINT64_ARRAY (env.octeon_crypto.aes_resinp,MIPSCPU ,2 ), +VMSTATE_UINT64_ARRAY (env.octeon_crypto.aes_iv,MIPSCPU ,2 ), +VMSTATE_UINT64_ARRAY (env.octeon_crypto.aes_key,MIPSCPU ,4 ), +VMSTATE_UINT32 (env.octeon_crypto.crc_poly,MIPSCPU ), +VMSTATE_UINT32 (env.octeon_crypto.crc_iv,MIPSCPU ), +VMSTATE_UINT64_ARRAY (env.octeon_crypto.gfm_mul,MIPSCPU ,2 ), +VMSTATE_UINT64_ARRAY (env.octeon_crypto.gfm_resinp,MIPSCPU ,2 ), +VMSTATE_UINT16 (env.octeon_crypto.gfm_poly,MIPSCPU ), +VMSTATE_UINT8 (env.octeon_crypto.aes_keylen,MIPSCPU ), +VMSTATE_UINT8 (env.octeon_crypto.crc_len,MIPSCPU ), +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_mips_cpu = { .name ="cpu" , .version_id =21 ,
@@ -396,6 +424,7 @@ const VMStateDescription vmstate_mips_cpu = { .subsections = (const VMStateDescription * const []) { &mips_vmstate_timer, &mips_vmstate_octeon_multiplier, + &mips_vmstate_octeon_crypto,NULL } };
Signature · 1 line
2.54.0
PATCH v10 25/45 target/mips: add Octeon COP2 crypto helper plumbing
In reply to James HilliardAdd the Octeon COP2 crypto helper source file and build it with the MIPS TCG target. This provides the common compilation unit for the COP2 engine helpers.
The instruction dispatch itself remains fully decoded by decodetree, and operation selectors call per-operation helpers rather than a common selector-dispatch helper.
---
Changes v9 -> v10:
- Remove shared-window selector constants and the shared-mode setter.
Changes v8 -> v9:
- Split helper plumbing out of the former monolithic COP2 helper patch.
- Keep shared-window selector arithmetic local to octeon_crypto.c.
--- target/mips/tcg/meson.build | 1 + target/mips/tcg/octeon_crypto.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+)
target/mips/tcg/meson.build +1 -0
@@ -18,6 +18,7 @@ mips_ss.add(files( 'lmmi_helper.c', 'msa_helper.c', 'msa_translate.c', + 'octeon_crypto.c', 'op_helper.c', 'rel6_translate.c', 'translate.c',
target/mips/tcg/octeon_crypto.c new file +16 -0
@@ -0,0 +1,16 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* MIPS Octeon crypto emulation helpers. +* +* Copyright (c) 2026 James Hilliard +*/ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "internal.h" +#include "exec/helper-proto.h" +#include "crypto/aes.h" +#include "crypto/sm4.h" +#include "qemu/bitops.h" +#include "qemu/host-utils.h"
Signature · 1 line
2.54.0
PATCH v10 26/45 target/mips: add Octeon CRC COP2 helpers
In reply to James HilliardAdd helper support for the Octeon COP2 CRC register interface. This covers normal and reflected CRC state handling, byte/halfword/word/ doubleword/variable-width update selectors, and the reflected IV readback operation.
Register moves that can be represented as direct TCG loads/stores do not need helpers. Add only the side-effecting CRC helper implementation here.
---
Changes v9 -> v10:
- Mask variable-length CRC writes to CRCLEN<3:0>.
- Add Richard's Reviewed-by tag.
Changes v8 -> v9:
- Split CRC selector operations into their own COP2 helper patch.
- Expose per-operation helpers instead of a generic selector helper.
- Add matching helper.h declarations with the helper implementation.
--- target/mips/helper.h | 14 +++++ target/mips/tcg/octeon_crypto.c | 131 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+)
target/mips/helper.h +14 -0
@@ -25,6 +25,20 @@ DEF_HELPER_3(crc32, tl, tl, tl, i32) DEF_HELPER_3(crc32c, tl, tl, tl, i32)DEF_HELPER_FLAGS_4 (rotx,TCG_CALL_NO_RWG_SE , tl, tl, i32, i32, i32) +/* Octeon COP2 selector operation helpers. */ +DEF_HELPER_1(octeon_cp2_mf_crc_iv_reflect, i64, env) +DEF_HELPER_2(octeon_cp2_mt_crc_write_iv_reflect, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_crc_write_byte, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_crc_write_half, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_crc_write_word, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_crc_write_byte_reflect, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_crc_write_half_reflect, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_crc_write_word_reflect, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_crc_write_dword, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_crc_write_var, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_crc_write_dword_reflect, void, env, i64) +DEF_HELPER_2 (octeon_cp2_mt_crc_write_var_reflect, void, env, i64) + /* microMIPS functions */ DEF_HELPER_4(lwm, void, env, tl, tl, i32)DEF_HELPER_4 (swm, void, env, tl, tl, i32)
target/mips/tcg/octeon_crypto.c +131 -0
134 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v10 27/45 target/mips: add Octeon GFM COP2 helpers
In reply to James HilliardAdd helper support for the Octeon GFM carryless multiply selectors. This models the normal and reflected multiplication paths, including the XOR-and-multiply forms that update the result/input state used by Octeon crypto code.
Implement the reflected path with the same architectural 128-bit state model as the normal GFM helpers, avoiding target-local shadow state or a 64-bit reflected shortcut.
---
Changes v9 -> v10:
- Preserve the 64-bit UIA2 GFM reduction path used by SNOW3G F9.
- Rework reflected GFM helpers around the full 128-bit architectural state.
- Use direct RESINP XOR operations instead of target-local XOR shadow state.
Changes v8 -> v9:
- Split GFM selector operations into their own COP2 helper patch.
- Expose per-operation helpers instead of a generic selector helper.
- Add matching helper.h declarations with the helper implementation.
--- target/mips/helper.h | 4 ++ target/mips/tcg/octeon_crypto.c | 125 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+)
target/mips/helper.h +4 -0
@@ -38,6 +38,10 @@ DEF_HELPER_2(octeon_cp2_mt_crc_write_dword, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_crc_write_var, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_crc_write_dword_reflect, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_crc_write_var_reflect, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_gfm_xor0_reflect, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_gfm_xor0, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_gfm_xormul1_reflect, void, env, i64) +DEF_HELPER_2 (octeon_cp2_mt_gfm_xormul1, void, env, i64) /* microMIPS functions */DEF_HELPER_4 (lwm, void, env, tl, tl, i32)
target/mips/tcg/octeon_crypto.c +125 -0
142 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v10 28/45 target/mips: add Octeon SHA3 COP2 helpers
In reply to James HilliardAdd the Octeon SHA3 register-window state and helper operations. Keep the shared HSH/SHA3/SHA512 write path coherent, model the dedicated 25-lane Keccak state, and implement the Keccak-f[1600] permutation for the STARTOP selector.
The shared selector window still uses explicit selector-position arithmetic internally because multiple COP2 engines alias the same numeric window. Individual DMFC2/DMTC2 instruction decode stays outside the helper implementation.
---
Changes v8 -> v9:
- Split SHA3 selector operations into their own COP2 helper patch.
- Replace generic selector dispatch with per-operation SHA3 helpers.
- Use helper-local selector constants for shared-window position logic.
- Add matching helper.h declarations with the helper implementation.
Changes v1 -> v2:
- Use switch ranges and g_assert_not_reached() for SHA3 selector position decoding. (suggested by Philippe Mathieu-Daudé)
- Add selector dispatch updates in octeon_translate.c after moving COP2 decode out of translate.c. (suggested by Philippe Mathieu-Daudé)
Changes v5 -> v6:
- Rename SHA3 DAT15 selector aliases with MF/MT direction suffixes.
--- target/mips/helper.h | 22 +++++ target/mips/tcg/octeon_crypto.c | 172 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 194 insertions(+)
target/mips/helper.h +22 -0
@@ -27,6 +27,7 @@ DEF_HELPER_FLAGS_4(rotx, TCG_CALL_NO_RWG_SE, tl, tl, i32, i32, i32)/* Octeon COP2 selector operation helpers. */ DEF_HELPER_1(octeon_cp2_mf_crc_iv_reflect, i64, env) +DEF_HELPER_1(octeon_cp2_mf_sha3_dat24, i64, env) DEF_HELPER_2(octeon_cp2_mt_crc_write_iv_reflect, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_crc_write_byte, void, env, i64)DEF_HELPER_2 (octeon_cp2_mt_crc_write_half, void, env, i64)
@@ -42,6 +43,27 @@ DEF_HELPER_2(octeon_cp2_mt_gfm_xor0_reflect, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_gfm_xor0, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_gfm_xormul1_reflect, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_gfm_xormul1, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_dat24, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_dat15, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat0, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat1, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat2, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat3, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat4, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat5, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat6, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat7, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat8, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat9, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat10, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat11, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat12, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat13, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat14, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat15, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat16, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sha3_xordat17, void, env, i64) +DEF_HELPER_2 (octeon_cp2_mt_sha3_startop, void, env, i64) /* microMIPS functions */DEF_HELPER_4 (lwm, void, env, tl, tl, i32)
target/mips/tcg/octeon_crypto.c +172 -0
195 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v10 29/45 target/mips: add Octeon ZUC COP2 helpers
In reply to James HilliardAdd the Octeon ZUC START and MORE helper operations and model the shared state window used by the hardware interface. This covers the keystream and MAC engine state, including the save-and-restore view that overlaps the HSH/SHA3 bank.
Shared-window writes also update the SHA512/SHA3 backing state so guests can switch between engines without stale register contents.
---
Changes v8 -> v9:
- Split ZUC selector operations into their own COP2 helper patch.
- Replace generic selector dispatch with per-operation ZUC helpers.
- Use helper-local selector constants for shared-window position logic.
- Add matching helper.h declarations with the helper implementation.
Changes v1 -> v2:
- Add shared-window selector predicates and assert on unreachable ZUC selector switches. (suggested by Philippe Mathieu-Daudé)
- Preserve aliased HSH/SHA3/SHA512 backing state during ZUC shared-window writes.
- Add selector dispatch updates in octeon_translate.c after moving COP2 decode out of translate.c. (suggested by Philippe Mathieu-Daudé)
Changes v5 -> v6:
- Use the manual-aligned HSH_DATW field and shared HSH window helper names introduced by the COP2 crypto core patch.
--- target/mips/helper.h | 2 + target/mips/tcg/octeon_crypto.c | 369 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 371 insertions(+)
target/mips/helper.h +2 -0
@@ -64,6 +64,8 @@ DEF_HELPER_2(octeon_cp2_mt_sha3_xordat15, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_sha3_xordat16, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_sha3_xordat17, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_sha3_startop, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_zuc_start, void, env, i64) +DEF_HELPER_2 (octeon_cp2_mt_zuc_more, void, env, i64) /* microMIPS functions */DEF_HELPER_4 (lwm, void, env, tl, tl, i32)
target/mips/tcg/octeon_crypto.c +369 -0
375 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v10 30/45 target/mips: add Octeon SNOW3G COP2 helpers
In reply to James HilliardAdd helper support for the Octeon SNOW3G START and MORE selectors. The engine state and result are represented through the architectural HSH IV and DAT register banks that SNOW3G aliases for save and restore.
---
Changes v9 -> v10:
- Drop non-architectural SNOW3G shadow state and shared-mode tracking.
- Use the architectural HSH IV/DAT register banks for aliased state.
Changes v8 -> v9:
- Split SNOW3G selector operations into their own COP2 helper patch.
- Replace generic selector dispatch with per-operation SNOW3G helpers.
- Add matching helper.h declarations with the helper implementation.
--- target/mips/helper.h | 2 + target/mips/tcg/octeon_crypto.c | 275 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 277 insertions(+)
target/mips/helper.h +2 -0
@@ -66,6 +66,8 @@ DEF_HELPER_2(octeon_cp2_mt_sha3_xordat17, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_sha3_startop, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_zuc_start, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_zuc_more, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_snow3g_start, void, env, i64) +DEF_HELPER_2 (octeon_cp2_mt_snow3g_more, void, env, i64) /* microMIPS functions */DEF_HELPER_4 (lwm, void, env, tl, tl, i32)
target/mips/tcg/octeon_crypto.c +275 -0
281 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v10 31/45 target/mips: add Octeon AES COP2 helpers
In reply to James HilliardAdd helper support for the Octeon AES operation selectors. Direct register-transfer selectors do not need helpers; the ECB/CBC encrypt and decrypt operations consume the AES input, key, IV, and key-length state.
AESRESINP is modeled as one architectural register bank; operation helpers consume the current AESRESINP block and write the result back to the same bank.
---
Changes v9 -> v10:
- Drop the non-architectural AES input/result split.
- Model AESRESINP as a single architectural input/result bank.
Changes v8 -> v9:
- Split AES operation selectors into their own COP2 helper patch.
- Replace generic selector dispatch with per-operation AES helpers.
- Add matching helper.h declarations with the helper implementation.
--- target/mips/helper.h | 4 ++ target/mips/tcg/octeon_crypto.c | 145 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+)
target/mips/helper.h +4 -0
@@ -68,6 +68,10 @@ DEF_HELPER_2(octeon_cp2_mt_zuc_start, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_zuc_more, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_snow3g_start, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_snow3g_more, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_aes_enc_cbc1, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_aes_enc1, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_aes_dec_cbc1, void, env, i64) +DEF_HELPER_2 (octeon_cp2_mt_aes_dec1, void, env, i64) /* microMIPS functions */DEF_HELPER_4 (lwm, void, env, tl, tl, i32)
target/mips/tcg/octeon_crypto.c +145 -0
151 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v10 32/45 target/mips: add Octeon SMS4 COP2 helpers
In reply to James HilliardAdd helper support for the Octeon SMS4 operation selectors. SMS4 reuses the AES RESINP, IV, and key banks, so the helpers share the existing AES state while implementing the SMS4 ECB/CBC encrypt and decrypt operations.
---
Changes v8 -> v9:
- Split SMS4 operation selectors into their own COP2 helper patch.
- Replace generic selector dispatch with per-operation SMS4 helpers.
- Add matching helper.h declarations with the helper implementation.
Changes v1 -> v2:
- Add selector dispatch updates in octeon_translate.c after moving COP2 decode out of translate.c. (suggested by Philippe Mathieu-Daudé)
Changes v5 -> v6:
- Use RESINP wording for the SMS4 shared selector aliases.
--- target/mips/helper.h | 4 ++ target/mips/tcg/octeon_crypto.c | 124 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+)
target/mips/helper.h +4 -0
@@ -72,6 +72,10 @@ DEF_HELPER_2(octeon_cp2_mt_aes_enc_cbc1, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_aes_enc1, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_aes_dec_cbc1, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_aes_dec1, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sms4_enc_cbc1, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sms4_enc1, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_sms4_dec_cbc1, void, env, i64) +DEF_HELPER_2 (octeon_cp2_mt_sms4_dec1, void, env, i64) /* microMIPS functions */DEF_HELPER_4 (lwm, void, env, tl, tl, i32)
target/mips/tcg/octeon_crypto.c +124 -0
130 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v10 33/45 target/mips: add Octeon 3DES and KASUMI COP2 helpers
In reply to James HilliardAdd helper support for the Octeon 3DES and KASUMI operation selectors. The 3DES helpers implement ECB and CBC encrypt/decrypt over the shared 3DES key, IV, and result bank. KASUMI reuses the same register bank and adds its own encrypt selectors.
Only the operation selectors require helper code. Simple key, IV, and result register transfers are handled by direct selector decode.
---
Changes v8 -> v9:
- Split 3DES/KASUMI operation selectors into their own COP2 helper patch.
- Replace generic selector dispatch with per-operation 3DES/KASUMI helpers.
- Add matching helper.h declarations with the helper implementation.
--- target/mips/helper.h | 6 + target/mips/tcg/octeon_crypto.c | 458 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 464 insertions(+)
target/mips/helper.h +6 -0
@@ -76,6 +76,12 @@ DEF_HELPER_2(octeon_cp2_mt_sms4_enc_cbc1, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_sms4_enc1, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_sms4_dec_cbc1, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_sms4_dec1, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_des3_enc_cbc, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_kas_enc_cbc, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_des3_enc, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_kas_enc, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_des3_dec_cbc, void, env, i64) +DEF_HELPER_2 (octeon_cp2_mt_des3_dec, void, env, i64) /* microMIPS functions */DEF_HELPER_4 (lwm, void, env, tl, tl, i32)
target/mips/tcg/octeon_crypto.c +458 -0
464 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v10 34/45 target/mips: add Octeon Camellia COP2 helpers
In reply to James HilliardAdd helper support for the Octeon Camellia ROUND, FL, and FLINV selectors. The engine reuses the AES RESINP bank, and guest-managed key schedules drive the Camellia F-function and FL layers through these COP2 operations.
Implement the Camellia F-function and FL layers directly from RFC 3713.
---
Changes v8 -> v9:
- Split Camellia operation selectors into their own COP2 helper patch.
- Replace generic selector dispatch with per-operation Camellia helpers.
- Add matching helper.h declarations with the helper implementation.
Changes v1 -> v2:
- Drop the Octeon prefix from generic Camellia helper routines. (suggested by Philippe Mathieu-Daudé)
- Add selector dispatch updates in octeon_translate.c after moving COP2 decode out of translate.c. (suggested by Philippe Mathieu-Daudé)
Changes v5 -> v6:
- Use RESINP wording for the Camellia shared selector aliases.
--- target/mips/helper.h | 3 + target/mips/tcg/octeon_crypto.c | 126 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+)
target/mips/helper.h +3 -0
@@ -82,6 +82,9 @@ DEF_HELPER_2(octeon_cp2_mt_des3_enc, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_kas_enc, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_des3_dec_cbc, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_des3_dec, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_camellia_fl, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_camellia_flinv, void, env, i64) +DEF_HELPER_2 (octeon_cp2_mt_camellia_round, void, env, i64) /* microMIPS functions */DEF_HELPER_4 (lwm, void, env, tl, tl, i32)
target/mips/tcg/octeon_crypto.c +126 -0
132 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v10 35/45 target/mips: add Octeon HSH COP2 helpers
In reply to James HilliardAdd helper support for the Octeon HSH hash selectors. This includes the base HSH data/IV windows, MD5, SHA1, SHA256, and SHA512 transform paths, and the shared HSH/SHA512 register-window readback and write operations.
The SHA512 path shares the wide HSH register bank with SHA3, SNOW3G, and ZUC. Keep the aliased readback and write paths centralized so selector decode can route register accesses through these helpers when side effects are required.
---
Changes v9 -> v10:
- Remove references to shared-mode tracking; aliased state is kept in the architectural HSH register banks.
Changes v8 -> v9:
- Split HSH/SHA helpers into their own COP2 helper patch.
- Replace generic selector dispatch with per-operation HSH helpers.
- Keep shared-window readback and write helpers grouped with HSH.
- Add matching helper.h declarations with the helper implementation.
--- target/mips/helper.h | 53 +++++ target/mips/tcg/octeon_crypto.c | 486 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 539 insertions(+)
target/mips/helper.h +53 -0
@@ -28,6 +28,30 @@ DEF_HELPER_FLAGS_4(rotx, TCG_CALL_NO_RWG_SE, tl, tl, i32, i32, i32)/* Octeon COP2 selector operation helpers. */ DEF_HELPER_1(octeon_cp2_mf_crc_iv_reflect, i64, env) DEF_HELPER_1(octeon_cp2_mf_sha3_dat24, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_dat0, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_dat1, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_dat2, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_dat3, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_dat4, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_dat5, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_dat6, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_dat7, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_dat8, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_dat9, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_dat10, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_dat11, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_dat12, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_dat13, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_dat14, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_dat15, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_iv0, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_iv1, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_iv2, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_iv3, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_iv4, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_iv5, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_iv6, i64, env) +DEF_HELPER_1(octeon_cp2_mf_hsh_iv7, i64, env) DEF_HELPER_2(octeon_cp2_mt_crc_write_iv_reflect, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_crc_write_byte, void, env, i64)DEF_HELPER_2 (octeon_cp2_mt_crc_write_half, void, env, i64)
@@ -85,6 +109,35 @@ DEF_HELPER_2(octeon_cp2_mt_des3_dec, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_camellia_fl, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_camellia_flinv, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_camellia_round, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_startsha_compat, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_dat0, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_dat1, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_dat2, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_dat3, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_dat4, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_dat5, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_dat6, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_dat7, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_dat8, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_dat9, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_dat10, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_dat11, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_dat12, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_dat13, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_dat14, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_dat15, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_iv0, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_iv1, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_iv2, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_iv3, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_iv4, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_iv5, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_iv6, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_iv7, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_startmd5, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_startsha256, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_hsh_startsha, void, env, i64) +DEF_HELPER_2 (octeon_cp2_mt_hsh_startsha512, void, env, i64) /* microMIPS functions */DEF_HELPER_4 (lwm, void, env, tl, tl, i32)
target/mips/tcg/octeon_crypto.c +486 -0
498 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v10 36/45 target/mips: add Octeon CHORD and LLM COP2 helpers
In reply to James HilliardAdd the Octeon CHORD hardware register access path and the LLM 36-bit and 64-bit read and write windows. Model both CHORD access forms, including the RDHWR $30 path and the legacy DMFC2 alias.
Implement sparse backing storage for the two LLM sets so user-mode code can save, restore, and probe the architectural state without allocating a full hardware-sized backing array.
---
Changes v9 -> v10:
- Keep shared crypto helper routines in their final order after the COP2 helper split.
Changes v8 -> v9:
- Split CHORD and LLM helpers into their own COP2 helper patch.
- Replace generic selector dispatch with per-operation LLM helpers.
- Add matching helper.h declarations with the helper implementation.
Changes v1 -> v2:
- Use neutral selector-slot wording for the LLM/CHORD alias comment.
- Add selector dispatch updates in octeon_translate.c after moving COP2 decode out of translate.c. (suggested by Philippe Mathieu-Daudé)
Changes v5 -> v6:
- Rename sparse LLM backing fields from llm_narrow/llm_wide to llm36/llm64 to match the 36-bit and 64-bit selector windows.
--- target/mips/cpu.c | 67 +++ target/mips/cpu.h | 9 +- target/mips/helper.h | 9 + target/mips/internal.h | 3 + target/mips/system/machine.c | 71 ++- target/mips/tcg/octeon_crypto.c | 932 ++++++++++++++++++++++------------------ target/mips/tcg/op_helper.c | 6 + target/mips/tcg/translate.c | 8 + 8 files changed, 673 insertions(+), 432 deletions(-)
target/mips/cpu.c +67 -0
@@ -27,6 +27,7 @@#include "internal.h" #include "kvm_mips.h" #include "qemu/module.h" +#include "qemu/qtree.h" #include "system/kvm.h" #include "system/qtest.h" #include "hw/core/qdev-properties.h"
@@ -183,6 +184,57 @@ static bool mips_cpu_has_work(CPUState *cs)#include "cpu-defs.c.inc" +static gint mips_octeon_u64_tree_compare (gconstpointer a,gconstpointer b, +gpointer user_data) +{ +uint64_t av = *(const uint64_t *)a; +uint64_t bv = *(const uint64_t *)b; + +return (av > bv) - (av < bv); +} + +QTree *mips_octeon_llm_tree_new (void ) +{ +return q_tree_new_full (mips_octeon_u64_tree_compare, +NULL , g_free, g_free); +} + +uint64_t mips_octeon_llm_load (QTree *tree,uint64_t addr) +{ +uint64_t key = addr; +uint64_t *value = tree ?q_tree_lookup (tree, &key) :NULL ; + +return value ? *value :0 ; +} + +void mips_octeon_llm_store (QTree **treep,uint64_t addr,uint64_t value) +{ +uint64_t *key; +uint64_t *stored; + +if (!*treep) { + *treep =mips_octeon_llm_tree_new (); + } + + key =g_new (uint64_t,1 ); + stored =g_new (uint64_t,1 ); + *key = addr; + *stored = value; +q_tree_replace (*treep, key, stored); +} + +static void mips_octeon_destroy_llm_state (MIPSOcteonCryptoState *crypto) +{ +if (crypto->llm36) { +q_tree_destroy (crypto->llm36); + crypto->llm36 =NULL ; + } +if (crypto->llm64) { +q_tree_destroy (crypto->llm64); + crypto->llm64 =NULL ; + } +} +static void mips_cpu_reset_hold (Object *obj,ResetType type) {CPUState *cs =CPU (obj);
@@ -194,6 +246,7 @@ static void mips_cpu_reset_hold(Object *obj, ResetType type) mcc->parent_phases.hold (obj, type); } +mips_octeon_destroy_llm_state (&env->octeon_crypto);memset (env,0 , offsetof(CPUMIPSState , end_reset_fields));/* Reset registers to their default values */
@@ -248,6 +301,9 @@ static void mips_cpu_reset_hold(Object *obj, ResetType type) env->active_fpu.fcr31 = env->cpu_model->CP1_fcr31; env->msair = env->cpu_model->MSAIR; env->insn_flags = env->cpu_model->insn_flags; +if (env->insn_flags &INSN_OCTEON ) { + env->octeon_crypto.chord =1 ; + }#if defined(CONFIG_USER_ONLY ) env->CP0_Status = (MIPS_HFLAG_UM << CP0St_KSU);
@@ -264,6 +320,9 @@ static void mips_cpu_reset_hold(Object *obj, ResetType type)* hardware registers. */ env->CP0_HWREna |=0x0000000F ; +if (env->insn_flags &INSN_OCTEON ) { + env->CP0_HWREna |=0x40000000u ; + }if (env->CP0_Config1 & (1 <<CP0C1_FP )) { env->CP0_Status |= (1 << CP0St_CU1); }
@@ -422,6 +481,13 @@ static void mips_cpu_reset_hold(Object *obj, ResetType type)#endif } +static void mips_cpu_finalize (Object *obj) +{ +MIPSCPU *cpu =MIPS_CPU (obj); + +mips_octeon_destroy_llm_state (&cpu->env.octeon_crypto); +} +static void mips_cpu_disas_set_info (const CPUState *cs,disassemble_info *info) {const MIPSCPU *cpu =MIPS_CPU (cs);
@@ -650,6 +716,7 @@ static const TypeInfo mips_cpu_type_info = { .instance_size = sizeof(MIPSCPU), .instance_align = __alignof(MIPSCPU), .instance_init = mips_cpu_initfn, + .instance_finalize = mips_cpu_finalize, .abstract = true, .class_size = sizeof(MIPSCPUClass), .class_init = mips_cpu_class_init,
target/mips/cpu.h +7 -2
@@ -11,6 +11,7 @@#include "fpu/softfloat-types.h" #include "hw/core/clock.h" #include "mips-defs.h" +#include "qemu/qtree.h" typedef struct CPUMIPSTLBContext CPUMIPSTLBContext ;
@@ -549,13 +550,17 @@ typedef struct MIPSOcteonCryptoState {uint64_t aes_resinp[2 ];uint64_t aes_iv[2 ];uint64_t aes_key[4 ]; +uint8_t aes_keylen;uint32_t crc_poly;uint32_t crc_iv; +uint8_t crc_len;uint64_t gfm_mul[2 ];uint64_t gfm_resinp[2 ];uint16_t gfm_poly; -uint8_t aes_keylen; -uint8_t crc_len; +uint64_t chord; +uint64_t llm_data[2 ]; +QTree *llm36; +QTree *llm64; } MIPSOcteonCryptoState; typedef struct CPUArchState {
target/mips/helper.h +9 -0
@@ -138,6 +138,14 @@ DEF_HELPER_2(octeon_cp2_mt_hsh_startmd5, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_hsh_startsha256, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_hsh_startsha, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_hsh_startsha512, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_llm_read_addr0, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_llm_write_addr0, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_llm_read64_addr0, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_llm_write64_addr0, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_llm_read_addr1, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_llm_write_addr1, void, env, i64) +DEF_HELPER_2(octeon_cp2_mt_llm_read64_addr1, void, env, i64) +DEF_HELPER_2 (octeon_cp2_mt_llm_write64_addr1, void, env, i64) /* microMIPS functions */DEF_HELPER_4 (lwm, void, env, tl, tl, i32)
@@ -309,6 +317,7 @@ DEF_HELPER_1(rdhwr_cc, tl, env) DEF_HELPER_1(rdhwr_ccres, tl, env) DEF_HELPER_1(rdhwr_performance, tl, env) DEF_HELPER_1(rdhwr_xnp, tl, env) +DEF_HELPER_1(rdhwr_chord, tl, env) DEF_HELPER_2(pmon, void, env, int)DEF_HELPER_1 (wait, void, env)
target/mips/internal.h +3 -0
@@ -93,6 +93,9 @@ extern const int mips_defs_number;int mips_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int mips_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); +QTree *mips_octeon_llm_tree_new (void ); +uint64_t mips_octeon_llm_load (QTree *tree,uint64_t addr); +void mips_octeon_llm_store (QTree **treep,uint64_t addr,uint64_t value);#define USEG_LIMIT ((target_ulong)(int32_t)0x7FFFFFFFUL)#define KSEG0_BASE ((target_ulong)(int32_t)0x80000000UL)
target/mips/system/machine.c +69 -2
88 lines not on this page · raw message
target/mips/tcg/octeon_crypto.c +504 -428
1,043 lines not on this page · raw message
target/mips/tcg/op_helper.c +6 -0
@@ -255,6 +255,12 @@ target_ulong helper_rdhwr_xnp(CPUMIPSState *env)return (env->CP0_Config5 >>CP0C5_XNP ) &1 ; } +target_ulong helper_rdhwr_chord (CPUMIPSState *env) +{ +check_hwrena (env,30 ,GETPC ()); +return env->octeon_crypto.chord; +} +void helper_pmon (CPUMIPSState *env,int function) { function /=2 ;
target/mips/tcg/translate.c +8 -0
@@ -10925,6 +10925,14 @@ void gen_rdhwr(DisasContext *ctx, int rt, int rd, int sel) }break ;#endif +case 30 : +if (!(ctx->insn_flags &INSN_OCTEON )) { +gen_reserved_instruction (ctx); +break ; + } +gen_helper_rdhwr_chord (t0, tcg_env); +gen_store_gpr (t0, rt); +break ;default :/* Invalid */ MIPS_INVAL ("rdhwr" );gen_reserved_instruction (ctx);
Signature · 1 line
2.54.0
PATCH v10 37/45 target/mips: decode Octeon COP2 register selectors
In reply to James HilliardDecode the Octeon COP2 DMFC2/DMTC2 selectors that map directly to architectural COP2 state. These selectors only move values between guest GPRs and Octeon COP2 registers, so emit direct TCG loads and stores instead of routing through a generic selector helper.
Add the common CP2 translator plumbing with the direct register-transfer selectors. Use signed 32-bit DMFC2 readback for the CRC registers to match MIPS register-move semantics, and keep AESRESINP as a single architectural register bank for direct transfers.
--- target/mips/helper.h | 1 + target/mips/tcg/octeon.decode | 79 ++++++++++++++ target/mips/tcg/octeon_translate.c | 210 +++++++++++++++++++++++++++++++++++++ 3 files changed, 290 insertions(+)
target/mips/helper.h +1 -0
@@ -147,6 +147,7 @@ DEF_HELPER_2(octeon_cp2_mt_llm_write_addr1, void, env, i64) DEF_HELPER_2(octeon_cp2_mt_llm_read64_addr1, void, env, i64)DEF_HELPER_2 (octeon_cp2_mt_llm_write64_addr1, void, env, i64) + /* microMIPS functions */ DEF_HELPER_4(lwm, void, env, tl, tl, i32)DEF_HELPER_4 (swm, void, env, tl, tl, i32)
target/mips/tcg/octeon.decode +79 -0
82 lines not on this page · raw message
target/mips/tcg/octeon_translate.c +210 -0
216 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v10 38/45 target/mips: decode Octeon CRC and GFM COP2 selectors
In reply to James HilliardAdd explicit decodetree entries and translator bindings for the Octeon CRC and GFM COP2 operation selectors. Unlike the simple register moves, these selectors update CRC or Galois-field state and therefore remain per-operation helper calls.
Keep CRC/GFM decode next to the helpers that implement these side effects while avoiding a monolithic selector-dispatch helper.
--- target/mips/tcg/octeon.decode | 16 ++++++++++++++++ target/mips/tcg/octeon_translate.c | 17 +++++++++++++++++ 2 files changed, 33 insertions(+)
target/mips/tcg/octeon.decode +16 -0
@@ -129,6 +129,7 @@ LDX 011111 ..... ..... ..... 01000 001010 @lx CVM_MF_CRC_POLYNOMIAL 010010 00001 rt:5 0000 0010 0000 0000 &cp2 CVM_MF_CRC_IV 010010 00001 rt:5 0000 0010 0000 0001 &cp2 CVM_MF_CRC_LEN 010010 00001 rt:5 0000 0010 0000 0010 &cp2 + CVM_MF_CRC_IV_REFLECT 010010 00001 rt:5 0000 0010 0000 0011 &cp2 CVM_MF_GFM_MUL0 010010 00001 rt:5 0000 0010 0101 1000 &cp2 CVM_MF_GFM_MUL1 010010 00001 rt:5 0000 0010 0101 1001 &cp2 CVM_MF_GFM_RESINP0 010010 00001 rt:5 0000 0010 0101 1010 &cp2
@@ -147,6 +148,7 @@ LDX 011111 ..... ..... ..... 01000 001010 @lx CVM_MT_HSH_IV3 010010 00101 rt:5 0000 0000 0100 1011 &cp2 CVM_MT_GFM_MUL_REFLECT0 010010 00101 rt:5 0000 0000 0101 1000 &cp2 CVM_MT_GFM_MUL_REFLECT1 010010 00101 rt:5 0000 0000 0101 1001 &cp2 + CVM_MT_GFM_XOR0_REFLECT 010010 00101 rt:5 0000 0000 0101 1100 &cp2 CVM_MT_3DES_KEY0 010010 00101 rt:5 0000 0000 1000 0000 &cp2 CVM_MT_3DES_KEY1 010010 00101 rt:5 0000 0000 1000 0001 &cp2 CVM_MT_3DES_KEY2 010010 00101 rt:5 0000 0000 1000 0010 &cp2
@@ -166,13 +168,27 @@ LDX 011111 ..... ..... ..... 01000 001010 @lx CVM_MT_AES_DEC0 010010 00101 rt:5 0000 0001 0000 1110 &cp2 CVM_MT_AES_KEYLENGTH 010010 00101 rt:5 0000 0001 0001 0000 &cp2 CVM_MT_CRC_IV 010010 00101 rt:5 0000 0010 0000 0001 &cp2 + CVM_MT_CRC_WRITE_IV_REFLECT 010010 00101 rt:5 0000 0010 0001 0001 &cp2 + CVM_MT_CRC_WRITE_BYTE 010010 00101 rt:5 0000 0010 0000 0100 &cp2 + CVM_MT_CRC_WRITE_HALF 010010 00101 rt:5 0000 0010 0000 0101 &cp2 + CVM_MT_CRC_WRITE_WORD 010010 00101 rt:5 0000 0010 0000 0110 &cp2 + CVM_MT_CRC_WRITE_BYTE_REFLECT 010010 00101 rt:5 0000 0010 0001 0100 &cp2 + CVM_MT_CRC_WRITE_HALF_REFLECT 010010 00101 rt:5 0000 0010 0001 0101 &cp2 + CVM_MT_CRC_WRITE_WORD_REFLECT 010010 00101 rt:5 0000 0010 0001 0110 &cp2 CVM_MT_GFM_MUL0 010010 00101 rt:5 0000 0010 0101 1000 &cp2 CVM_MT_GFM_MUL1 010010 00101 rt:5 0000 0010 0101 1001 &cp2 CVM_MT_GFM_RESINP0 010010 00101 rt:5 0000 0010 0101 1010 &cp2 CVM_MT_GFM_RESINP1 010010 00101 rt:5 0000 0010 0101 1011 &cp2 + CVM_MT_GFM_XOR0 010010 00101 rt:5 0000 0010 0101 1100 &cp2 CVM_MT_GFM_POLY 010010 00101 rt:5 0000 0010 0101 1110 &cp2 CVM_MT_CRC_WRITE_LEN 010010 00101 rt:5 0001 0010 0000 0010 &cp2 + CVM_MT_CRC_WRITE_DWORD 010010 00101 rt:5 0001 0010 0000 0111 &cp2 + CVM_MT_CRC_WRITE_VAR 010010 00101 rt:5 0001 0010 0000 1000 &cp2 + CVM_MT_CRC_WRITE_DWORD_REFLECT 010010 00101 rt:5 0001 0010 0001 0111 &cp2 + CVM_MT_CRC_WRITE_VAR_REFLECT 010010 00101 rt:5 0001 0010 0001 1000 &cp2 + CVM_MT_GFM_XORMUL1_REFLECT 010010 00101 rt:5 0100 0000 0101 1101 &cp2 CVM_MT_CRC_WRITE_POLYNOMIAL 010010 00101 rt:5 0100 0010 0000 0000 &cp2 CVM_MT_CRC_WRITE_POLYNOMIAL_REFLECT 010010 00101 rt:5 0100 0010 0001 0000 &cp2 + CVM_MT_GFM_XORMUL1 010010 00101 rt:5 0100 0010 0101 1101 &cp2 ] }
target/mips/tcg/octeon_translate.c +17 -0
@@ -181,6 +181,7 @@ CP2_MF_I64(CVM_MF_GFM_RESINP0, gfm_resinp[0]);CP2_MF_I64 (CVM_MF_GFM_RESINP1 , gfm_resinp[1 ]);CP2_MF_U16 (CVM_MF_GFM_POLY , gfm_poly); +CP2_MF_HELPER (CVM_MF_CRC_IV_REFLECT , crc_iv_reflect);CP2_MT_I64 (CVM_MT_HSH_DAT0 , hsh_dat[0 ]);CP2_MT_I64 (CVM_MT_HSH_DAT1 , hsh_dat[1 ]);
@@ -195,6 +196,7 @@ CP2_MT_I64(CVM_MT_HSH_IV2, hsh_iv[2]);CP2_MT_I64 (CVM_MT_HSH_IV3 , hsh_iv[3 ]);CP2_MT_I64 (CVM_MT_GFM_MUL_REFLECT0 , gfm_reflect_mul[0 ]);CP2_MT_I64 (CVM_MT_GFM_MUL_REFLECT1 , gfm_reflect_mul[1 ]); +CP2_MT_HELPER (CVM_MT_GFM_XOR0_REFLECT , gfm_xor0_reflect);CP2_MT_I64 (CVM_MT_3DES_KEY0 , des3_key[0 ]);CP2_MT_I64 (CVM_MT_3DES_KEY1 , des3_key[1 ]);CP2_MT_I64 (CVM_MT_3DES_KEY2 , des3_key[2 ]);
@@ -218,11 +220,26 @@ CP2_MT_I64(CVM_MT_GFM_MUL0, gfm_mul[0]);CP2_MT_I64 (CVM_MT_GFM_MUL1 , gfm_mul[1 ]);CP2_MT_I64 (CVM_MT_GFM_RESINP0 , gfm_resinp[0 ]);CP2_MT_I64 (CVM_MT_GFM_RESINP1 , gfm_resinp[1 ]); +CP2_MT_HELPER (CVM_MT_GFM_XOR0 , gfm_xor0);CP2_MT_U16 (CVM_MT_GFM_POLY , gfm_poly);CP2_MT_U8 (CVM_MT_CRC_WRITE_LEN , crc_len);CP2_MT_U32 (CVM_MT_CRC_WRITE_POLYNOMIAL , crc_poly);CP2_MT_U32 (CVM_MT_CRC_WRITE_POLYNOMIAL_REFLECT , crc_poly); +CP2_MT_HELPER (CVM_MT_CRC_WRITE_IV_REFLECT , crc_write_iv_reflect); +CP2_MT_HELPER (CVM_MT_CRC_WRITE_BYTE , crc_write_byte); +CP2_MT_HELPER (CVM_MT_CRC_WRITE_HALF , crc_write_half); +CP2_MT_HELPER (CVM_MT_CRC_WRITE_WORD , crc_write_word); +CP2_MT_HELPER (CVM_MT_CRC_WRITE_BYTE_REFLECT , crc_write_byte_reflect); +CP2_MT_HELPER (CVM_MT_CRC_WRITE_HALF_REFLECT , crc_write_half_reflect); +CP2_MT_HELPER (CVM_MT_CRC_WRITE_WORD_REFLECT , crc_write_word_reflect); +CP2_MT_HELPER (CVM_MT_CRC_WRITE_DWORD , crc_write_dword); +CP2_MT_HELPER (CVM_MT_CRC_WRITE_VAR , crc_write_var); +CP2_MT_HELPER (CVM_MT_CRC_WRITE_DWORD_REFLECT , crc_write_dword_reflect); +CP2_MT_HELPER (CVM_MT_CRC_WRITE_VAR_REFLECT , crc_write_var_reflect); +CP2_MT_HELPER (CVM_MT_GFM_XORMUL1_REFLECT , gfm_xormul1_reflect); +CP2_MT_HELPER (CVM_MT_GFM_XORMUL1 , gfm_xormul1); +static bool trans_BBIT (DisasContext *ctx,arg_BBIT *a) {TCGv_i64 p;
Signature · 1 line
2.54.0
PATCH v10 39/45 target/mips: decode Octeon HSH and SHA3 COP2 selectors
In reply to James HilliardAdd explicit decodetree entries and translator bindings for the Octeon HSH shared-window selectors and SHA3 operation selectors. These paths need helper calls because HSH/SHA3 selectors alias the architectural hash register window and operation selectors have visible side effects.
Keep HSH/SHA3 decode separate from direct register transfers because the shared hash-window aliases require helper-mediated state updates.
--- target/mips/tcg/octeon.decode | 75 ++++++++++++++++++++++++++++++++++++++ target/mips/tcg/octeon_translate.c | 75 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+)
target/mips/tcg/octeon.decode +75 -0
@@ -106,6 +106,7 @@ LDX 011111 ..... ..... ..... 01000 001010 @lx CVM_MF_HSH_IV1 010010 00001 rt:5 0000 0000 0100 1001 &cp2 CVM_MF_HSH_IV2 010010 00001 rt:5 0000 0000 0100 1010 &cp2 CVM_MF_HSH_IV3 010010 00001 rt:5 0000 0000 0100 1011 &cp2 + CVM_MF_SHA3_DAT24 010010 00001 rt:5 0000 0000 0101 0000 &cp2 CVM_MF_GFM_MUL_REFLECT0 010010 00001 rt:5 0000 0000 0101 1000 &cp2 CVM_MF_GFM_MUL_REFLECT1 010010 00001 rt:5 0000 0000 0101 1001 &cp2 CVM_MF_GFM_RESINP_REFLECT0 010010 00001 rt:5 0000 0000 0101 1010 &cp2
@@ -130,6 +131,30 @@ LDX 011111 ..... ..... ..... 01000 001010 @lx CVM_MF_CRC_IV 010010 00001 rt:5 0000 0010 0000 0001 &cp2 CVM_MF_CRC_LEN 010010 00001 rt:5 0000 0010 0000 0010 &cp2 CVM_MF_CRC_IV_REFLECT 010010 00001 rt:5 0000 0010 0000 0011 &cp2 + CVM_MF_HSH_DATW0 010010 00001 rt:5 0000 0010 0100 0000 &cp2 + CVM_MF_HSH_DATW1 010010 00001 rt:5 0000 0010 0100 0001 &cp2 + CVM_MF_HSH_DATW2 010010 00001 rt:5 0000 0010 0100 0010 &cp2 + CVM_MF_HSH_DATW3 010010 00001 rt:5 0000 0010 0100 0011 &cp2 + CVM_MF_HSH_DATW4 010010 00001 rt:5 0000 0010 0100 0100 &cp2 + CVM_MF_HSH_DATW5 010010 00001 rt:5 0000 0010 0100 0101 &cp2 + CVM_MF_HSH_DATW6 010010 00001 rt:5 0000 0010 0100 0110 &cp2 + CVM_MF_HSH_DATW7 010010 00001 rt:5 0000 0010 0100 0111 &cp2 + CVM_MF_HSH_DATW8 010010 00001 rt:5 0000 0010 0100 1000 &cp2 + CVM_MF_HSH_DATW9 010010 00001 rt:5 0000 0010 0100 1001 &cp2 + CVM_MF_HSH_DATW10 010010 00001 rt:5 0000 0010 0100 1010 &cp2 + CVM_MF_HSH_DATW11 010010 00001 rt:5 0000 0010 0100 1011 &cp2 + CVM_MF_HSH_DATW12 010010 00001 rt:5 0000 0010 0100 1100 &cp2 + CVM_MF_HSH_DATW13 010010 00001 rt:5 0000 0010 0100 1101 &cp2 + CVM_MF_HSH_DATW14 010010 00001 rt:5 0000 0010 0100 1110 &cp2 + CVM_MF_HSH_DATW15 010010 00001 rt:5 0000 0010 0100 1111 &cp2 + CVM_MF_HSH_IVW0 010010 00001 rt:5 0000 0010 0101 0000 &cp2 + CVM_MF_HSH_IVW1 010010 00001 rt:5 0000 0010 0101 0001 &cp2 + CVM_MF_HSH_IVW2 010010 00001 rt:5 0000 0010 0101 0010 &cp2 + CVM_MF_HSH_IVW3 010010 00001 rt:5 0000 0010 0101 0011 &cp2 + CVM_MF_HSH_IVW4 010010 00001 rt:5 0000 0010 0101 0100 &cp2 + CVM_MF_HSH_IVW5 010010 00001 rt:5 0000 0010 0101 0101 &cp2 + CVM_MF_HSH_IVW6 010010 00001 rt:5 0000 0010 0101 0110 &cp2 + CVM_MF_HSH_IVW7 010010 00001 rt:5 0000 0010 0101 0111 &cp2 CVM_MF_GFM_MUL0 010010 00001 rt:5 0000 0010 0101 1000 &cp2 CVM_MF_GFM_MUL1 010010 00001 rt:5 0000 0010 0101 1001 &cp2 CVM_MF_GFM_RESINP0 010010 00001 rt:5 0000 0010 0101 1010 &cp2
@@ -146,6 +171,9 @@ LDX 011111 ..... ..... ..... 01000 001010 @lx CVM_MT_HSH_IV1 010010 00101 rt:5 0000 0000 0100 1001 &cp2 CVM_MT_HSH_IV2 010010 00101 rt:5 0000 0000 0100 1010 &cp2 CVM_MT_HSH_IV3 010010 00101 rt:5 0000 0000 0100 1011 &cp2 + CVM_MT_SHA3_DAT24 010010 00101 rt:5 0000 0000 0101 0000 &cp2 + CVM_MT_SHA3_DAT15 010010 00101 rt:5 0000 0000 0101 0001 &cp2 + CVM_MT_HSH_STARTSHA_COMPAT 010010 00101 rt:5 0000 0000 0101 0111 &cp2 CVM_MT_GFM_MUL_REFLECT0 010010 00101 rt:5 0000 0000 0101 1000 &cp2 CVM_MT_GFM_MUL_REFLECT1 010010 00101 rt:5 0000 0000 0101 1001 &cp2 CVM_MT_GFM_XOR0_REFLECT 010010 00101 rt:5 0000 0000 0101 1100 &cp2
@@ -175,20 +203,67 @@ LDX 011111 ..... ..... ..... 01000 001010 @lx CVM_MT_CRC_WRITE_BYTE_REFLECT 010010 00101 rt:5 0000 0010 0001 0100 &cp2 CVM_MT_CRC_WRITE_HALF_REFLECT 010010 00101 rt:5 0000 0010 0001 0101 &cp2 CVM_MT_CRC_WRITE_WORD_REFLECT 010010 00101 rt:5 0000 0010 0001 0110 &cp2 + CVM_MT_HSH_DATW0 010010 00101 rt:5 0000 0010 0100 0000 &cp2 + CVM_MT_HSH_DATW1 010010 00101 rt:5 0000 0010 0100 0001 &cp2 + CVM_MT_HSH_DATW2 010010 00101 rt:5 0000 0010 0100 0010 &cp2 + CVM_MT_HSH_DATW3 010010 00101 rt:5 0000 0010 0100 0011 &cp2 + CVM_MT_HSH_DATW4 010010 00101 rt:5 0000 0010 0100 0100 &cp2 + CVM_MT_HSH_DATW5 010010 00101 rt:5 0000 0010 0100 0101 &cp2 + CVM_MT_HSH_DATW6 010010 00101 rt:5 0000 0010 0100 0110 &cp2 + CVM_MT_HSH_DATW7 010010 00101 rt:5 0000 0010 0100 0111 &cp2 + CVM_MT_HSH_DATW8 010010 00101 rt:5 0000 0010 0100 1000 &cp2 + CVM_MT_HSH_DATW9 010010 00101 rt:5 0000 0010 0100 1001 &cp2 + CVM_MT_HSH_DATW10 010010 00101 rt:5 0000 0010 0100 1010 &cp2 + CVM_MT_HSH_DATW11 010010 00101 rt:5 0000 0010 0100 1011 &cp2 + CVM_MT_HSH_DATW12 010010 00101 rt:5 0000 0010 0100 1100 &cp2 + CVM_MT_HSH_DATW13 010010 00101 rt:5 0000 0010 0100 1101 &cp2 + CVM_MT_HSH_DATW14 010010 00101 rt:5 0000 0010 0100 1110 &cp2 + CVM_MT_HSH_DATW15 010010 00101 rt:5 0000 0010 0100 1111 &cp2 + CVM_MT_HSH_IVW0 010010 00101 rt:5 0000 0010 0101 0000 &cp2 + CVM_MT_HSH_IVW1 010010 00101 rt:5 0000 0010 0101 0001 &cp2 + CVM_MT_HSH_IVW2 010010 00101 rt:5 0000 0010 0101 0010 &cp2 + CVM_MT_HSH_IVW3 010010 00101 rt:5 0000 0010 0101 0011 &cp2 + CVM_MT_HSH_IVW4 010010 00101 rt:5 0000 0010 0101 0100 &cp2 + CVM_MT_HSH_IVW5 010010 00101 rt:5 0000 0010 0101 0101 &cp2 + CVM_MT_HSH_IVW6 010010 00101 rt:5 0000 0010 0101 0110 &cp2 + CVM_MT_HSH_IVW7 010010 00101 rt:5 0000 0010 0101 0111 &cp2 CVM_MT_GFM_MUL0 010010 00101 rt:5 0000 0010 0101 1000 &cp2 CVM_MT_GFM_MUL1 010010 00101 rt:5 0000 0010 0101 1001 &cp2 CVM_MT_GFM_RESINP0 010010 00101 rt:5 0000 0010 0101 1010 &cp2 CVM_MT_GFM_RESINP1 010010 00101 rt:5 0000 0010 0101 1011 &cp2 CVM_MT_GFM_XOR0 010010 00101 rt:5 0000 0010 0101 1100 &cp2 CVM_MT_GFM_POLY 010010 00101 rt:5 0000 0010 0101 1110 &cp2 + CVM_MT_SHA3_XORDAT0 010010 00101 rt:5 0000 0010 1100 0000 &cp2 + CVM_MT_SHA3_XORDAT1 010010 00101 rt:5 0000 0010 1100 0001 &cp2 + CVM_MT_SHA3_XORDAT2 010010 00101 rt:5 0000 0010 1100 0010 &cp2 + CVM_MT_SHA3_XORDAT3 010010 00101 rt:5 0000 0010 1100 0011 &cp2 + CVM_MT_SHA3_XORDAT4 010010 00101 rt:5 0000 0010 1100 0100 &cp2 + CVM_MT_SHA3_XORDAT5 010010 00101 rt:5 0000 0010 1100 0101 &cp2 + CVM_MT_SHA3_XORDAT6 010010 00101 rt:5 0000 0010 1100 0110 &cp2 + CVM_MT_SHA3_XORDAT7 010010 00101 rt:5 0000 0010 1100 0111 &cp2 + CVM_MT_SHA3_XORDAT8 010010 00101 rt:5 0000 0010 1100 1000 &cp2 + CVM_MT_SHA3_XORDAT9 010010 00101 rt:5 0000 0010 1100 1001 &cp2 + CVM_MT_SHA3_XORDAT10 010010 00101 rt:5 0000 0010 1100 1010 &cp2 + CVM_MT_SHA3_XORDAT11 010010 00101 rt:5 0000 0010 1100 1011 &cp2 + CVM_MT_SHA3_XORDAT12 010010 00101 rt:5 0000 0010 1100 1100 &cp2 + CVM_MT_SHA3_XORDAT13 010010 00101 rt:5 0000 0010 1100 1101 &cp2 + CVM_MT_SHA3_XORDAT14 010010 00101 rt:5 0000 0010 1100 1110 &cp2 + CVM_MT_SHA3_XORDAT15 010010 00101 rt:5 0000 0010 1100 1111 &cp2 + CVM_MT_SHA3_XORDAT16 010010 00101 rt:5 0000 0010 1101 0000 &cp2 + CVM_MT_SHA3_XORDAT17 010010 00101 rt:5 0000 0010 1101 0001 &cp2 CVM_MT_CRC_WRITE_LEN 010010 00101 rt:5 0001 0010 0000 0010 &cp2 CVM_MT_CRC_WRITE_DWORD 010010 00101 rt:5 0001 0010 0000 0111 &cp2 CVM_MT_CRC_WRITE_VAR 010010 00101 rt:5 0001 0010 0000 1000 &cp2 CVM_MT_CRC_WRITE_DWORD_REFLECT 010010 00101 rt:5 0001 0010 0001 0111 &cp2 CVM_MT_CRC_WRITE_VAR_REFLECT 010010 00101 rt:5 0001 0010 0001 1000 &cp2 + CVM_MT_HSH_STARTMD5 010010 00101 rt:5 0100 0000 0100 0111 &cp2 + CVM_MT_HSH_STARTSHA256 010010 00101 rt:5 0100 0000 0100 1111 &cp2 + CVM_MT_SHA3_STARTOP 010010 00101 rt:5 0100 0000 0101 0010 &cp2 + CVM_MT_HSH_STARTSHA 010010 00101 rt:5 0100 0000 0101 0111 &cp2 CVM_MT_GFM_XORMUL1_REFLECT 010010 00101 rt:5 0100 0000 0101 1101 &cp2 CVM_MT_CRC_WRITE_POLYNOMIAL 010010 00101 rt:5 0100 0010 0000 0000 &cp2 CVM_MT_CRC_WRITE_POLYNOMIAL_REFLECT 010010 00101 rt:5 0100 0010 0001 0000 &cp2 + CVM_MT_HSH_STARTSHA512 010010 00101 rt:5 0100 0010 0100 1111 &cp2 CVM_MT_GFM_XORMUL1 010010 00101 rt:5 0100 0010 0101 1101 &cp2 ] }
target/mips/tcg/octeon_translate.c +75 -0
87 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v10 40/45 target/mips: decode Octeon ZUC and SNOW3G COP2 selectors
In reply to James HilliardAdd explicit decodetree entries and translator bindings for the Octeon ZUC and SNOW3G COP2 operation selectors. These stream-cipher selectors operate on the shared HSH register window state, so dispatch them through the per-operation helpers added with the corresponding engine support.
Keep stream-cipher decode separate because these selectors share the HSH register window with unrelated engines.
--- target/mips/tcg/octeon.decode | 4 ++++ target/mips/tcg/octeon_translate.c | 4 ++++ 2 files changed, 8 insertions(+)
target/mips/tcg/octeon.decode +4 -0
@@ -257,8 +257,12 @@ LDX 011111 ..... ..... ..... 01000 001010 @lx CVM_MT_CRC_WRITE_DWORD_REFLECT 010010 00101 rt:5 0001 0010 0001 0111 &cp2 CVM_MT_CRC_WRITE_VAR_REFLECT 010010 00101 rt:5 0001 0010 0001 1000 &cp2 CVM_MT_HSH_STARTMD5 010010 00101 rt:5 0100 0000 0100 0111 &cp2 + CVM_MT_SNOW3G_START 010010 00101 rt:5 0100 0000 0100 1101 &cp2 + CVM_MT_SNOW3G_MORE 010010 00101 rt:5 0100 0000 0100 1110 &cp2 CVM_MT_HSH_STARTSHA256 010010 00101 rt:5 0100 0000 0100 1111 &cp2 CVM_MT_SHA3_STARTOP 010010 00101 rt:5 0100 0000 0101 0010 &cp2 + CVM_MT_ZUC_START 010010 00101 rt:5 0100 0000 0101 0101 &cp2 + CVM_MT_ZUC_MORE 010010 00101 rt:5 0100 0000 0101 0110 &cp2 CVM_MT_HSH_STARTSHA 010010 00101 rt:5 0100 0000 0101 0111 &cp2 CVM_MT_GFM_XORMUL1_REFLECT 010010 00101 rt:5 0100 0000 0101 1101 &cp2 CVM_MT_CRC_WRITE_POLYNOMIAL 010010 00101 rt:5 0100 0010 0000 0000 &cp2
target/mips/tcg/octeon_translate.c +4 -0
@@ -285,6 +285,10 @@ CP2_MT_HELPER(CVM_MT_SHA3_XORDAT15, sha3_xordat15);CP2_MT_HELPER (CVM_MT_SHA3_XORDAT16 , sha3_xordat16);CP2_MT_HELPER (CVM_MT_SHA3_XORDAT17 , sha3_xordat17);CP2_MT_HELPER (CVM_MT_SHA3_STARTOP , sha3_startop); +CP2_MT_HELPER (CVM_MT_ZUC_START , zuc_start); +CP2_MT_HELPER (CVM_MT_ZUC_MORE , zuc_more); +CP2_MT_HELPER (CVM_MT_SNOW3G_START , snow3g_start); +CP2_MT_HELPER (CVM_MT_SNOW3G_MORE , snow3g_more);CP2_MT_HELPER (CVM_MT_HSH_STARTSHA_COMPAT , hsh_startsha_compat);CP2_MT_HELPER (CVM_MT_HSH_DATW0 , hsh_dat0);CP2_MT_HELPER (CVM_MT_HSH_DATW1 , hsh_dat1);
Signature · 1 line
2.54.0
PATCH v10 41/45 target/mips: decode Octeon block-cipher COP2 selectors
In reply to James HilliardAdd explicit decodetree entries and translator bindings for the Octeon AES, SMS4, 3DES, KASUMI, and Camellia COP2 operation selectors. These selectors consume or update engine state, so keep them as per-operation helper calls while the simple block-cipher register moves remain direct TCG loads and stores from the earlier register-selector patch.
This completes the block-cipher selector coverage without reintroducing a generic runtime selector dispatch path.
--- target/mips/tcg/octeon.decode | 17 +++++++++++++++++ target/mips/tcg/octeon_translate.c | 17 +++++++++++++++++ 2 files changed, 34 insertions(+)
target/mips/tcg/octeon.decode +17 -0
@@ -195,6 +195,8 @@ LDX 011111 ..... ..... ..... 01000 001010 @lx CVM_MT_AES_DEC_CBC0 010010 00101 rt:5 0000 0001 0000 1100 &cp2 CVM_MT_AES_DEC0 010010 00101 rt:5 0000 0001 0000 1110 &cp2 CVM_MT_AES_KEYLENGTH 010010 00101 rt:5 0000 0001 0001 0000 &cp2 + CVM_MT_CAMELLIA_FL 010010 00101 rt:5 0000 0001 0001 0101 &cp2 + CVM_MT_CAMELLIA_FLINV 010010 00101 rt:5 0000 0001 0001 0110 &cp2 CVM_MT_CRC_IV 010010 00101 rt:5 0000 0010 0000 0001 &cp2 CVM_MT_CRC_WRITE_IV_REFLECT 010010 00101 rt:5 0000 0010 0001 0001 &cp2 CVM_MT_CRC_WRITE_BYTE 010010 00101 rt:5 0000 0010 0000 0100 &cp2
@@ -256,6 +258,15 @@ LDX 011111 ..... ..... ..... 01000 001010 @lx CVM_MT_CRC_WRITE_VAR 010010 00101 rt:5 0001 0010 0000 1000 &cp2 CVM_MT_CRC_WRITE_DWORD_REFLECT 010010 00101 rt:5 0001 0010 0001 0111 &cp2 CVM_MT_CRC_WRITE_VAR_REFLECT 010010 00101 rt:5 0001 0010 0001 1000 &cp2 + CVM_MT_AES_ENC_CBC1 010010 00101 rt:5 0011 0001 0000 1001 &cp2 + CVM_MT_AES_ENC1 010010 00101 rt:5 0011 0001 0000 1011 &cp2 + CVM_MT_AES_DEC_CBC1 010010 00101 rt:5 0011 0001 0000 1101 &cp2 + CVM_MT_AES_DEC1 010010 00101 rt:5 0011 0001 0000 1111 &cp2 + CVM_MT_CAMELLIA_ROUND 010010 00101 rt:5 0011 0001 0001 0100 &cp2 + CVM_MT_SMS4_ENC_CBC1 010010 00101 rt:5 0011 0001 0001 1001 &cp2 + CVM_MT_SMS4_ENC1 010010 00101 rt:5 0011 0001 0001 1011 &cp2 + CVM_MT_SMS4_DEC_CBC1 010010 00101 rt:5 0011 0001 0001 1101 &cp2 + CVM_MT_SMS4_DEC1 010010 00101 rt:5 0011 0001 0001 1111 &cp2 CVM_MT_HSH_STARTMD5 010010 00101 rt:5 0100 0000 0100 0111 &cp2 CVM_MT_SNOW3G_START 010010 00101 rt:5 0100 0000 0100 1101 &cp2 CVM_MT_SNOW3G_MORE 010010 00101 rt:5 0100 0000 0100 1110 &cp2
@@ -265,6 +276,12 @@ LDX 011111 ..... ..... ..... 01000 001010 @lx CVM_MT_ZUC_MORE 010010 00101 rt:5 0100 0000 0101 0110 &cp2 CVM_MT_HSH_STARTSHA 010010 00101 rt:5 0100 0000 0101 0111 &cp2 CVM_MT_GFM_XORMUL1_REFLECT 010010 00101 rt:5 0100 0000 0101 1101 &cp2 + CVM_MT_3DES_ENC_CBC 010010 00101 rt:5 0100 0000 1000 1000 &cp2 + CVM_MT_KAS_ENC_CBC 010010 00101 rt:5 0100 0000 1000 1001 &cp2 + CVM_MT_3DES_ENC 010010 00101 rt:5 0100 0000 1000 1010 &cp2 + CVM_MT_KAS_ENC 010010 00101 rt:5 0100 0000 1000 1011 &cp2 + CVM_MT_3DES_DEC_CBC 010010 00101 rt:5 0100 0000 1000 1100 &cp2 + CVM_MT_3DES_DEC 010010 00101 rt:5 0100 0000 1000 1110 &cp2 CVM_MT_CRC_WRITE_POLYNOMIAL 010010 00101 rt:5 0100 0010 0000 0000 &cp2 CVM_MT_CRC_WRITE_POLYNOMIAL_REFLECT 010010 00101 rt:5 0100 0010 0001 0000 &cp2 CVM_MT_HSH_STARTSHA512 010010 00101 rt:5 0100 0010 0100 1111 &cp2
target/mips/tcg/octeon_translate.c +17 -0
@@ -289,6 +289,23 @@ CP2_MT_HELPER(CVM_MT_ZUC_START, zuc_start);CP2_MT_HELPER (CVM_MT_ZUC_MORE , zuc_more);CP2_MT_HELPER (CVM_MT_SNOW3G_START , snow3g_start);CP2_MT_HELPER (CVM_MT_SNOW3G_MORE , snow3g_more); +CP2_MT_HELPER (CVM_MT_AES_ENC_CBC1 , aes_enc_cbc1); +CP2_MT_HELPER (CVM_MT_AES_ENC1 , aes_enc1); +CP2_MT_HELPER (CVM_MT_AES_DEC_CBC1 , aes_dec_cbc1); +CP2_MT_HELPER (CVM_MT_AES_DEC1 , aes_dec1); +CP2_MT_HELPER (CVM_MT_SMS4_ENC_CBC1 , sms4_enc_cbc1); +CP2_MT_HELPER (CVM_MT_SMS4_ENC1 , sms4_enc1); +CP2_MT_HELPER (CVM_MT_SMS4_DEC_CBC1 , sms4_dec_cbc1); +CP2_MT_HELPER (CVM_MT_SMS4_DEC1 , sms4_dec1); +CP2_MT_HELPER (CVM_MT_3DES_ENC_CBC , des3_enc_cbc); +CP2_MT_HELPER (CVM_MT_KAS_ENC_CBC , kas_enc_cbc); +CP2_MT_HELPER (CVM_MT_3DES_ENC , des3_enc); +CP2_MT_HELPER (CVM_MT_KAS_ENC , kas_enc); +CP2_MT_HELPER (CVM_MT_3DES_DEC_CBC , des3_dec_cbc); +CP2_MT_HELPER (CVM_MT_3DES_DEC , des3_dec); +CP2_MT_HELPER (CVM_MT_CAMELLIA_FL , camellia_fl); +CP2_MT_HELPER (CVM_MT_CAMELLIA_FLINV , camellia_flinv); +CP2_MT_HELPER (CVM_MT_CAMELLIA_ROUND , camellia_round);CP2_MT_HELPER (CVM_MT_HSH_STARTSHA_COMPAT , hsh_startsha_compat);CP2_MT_HELPER (CVM_MT_HSH_DATW0 , hsh_dat0);CP2_MT_HELPER (CVM_MT_HSH_DATW1 , hsh_dat1);
Signature · 1 line
2.54.0
PATCH v10 42/45 target/mips: decode Octeon CHORD and LLM COP2 selectors
In reply to James HilliardAdd explicit decodetree entries and translator bindings for the Octeon CHORD and sparse LLM COP2 selectors. CHORD and LLM use their own COP2 selector window rather than the crypto engine windows covered by the preceding decode patches.
Finish the explicit COP2 selector decode by adding the CP2_Undef fallback so unknown Octeon COP2 selectors raise the expected coprocessor-unusable exception instead of silently taking a generic path.
--- target/mips/tcg/octeon.decode | 14 ++++++++++++++ target/mips/tcg/octeon_translate.c | 13 +++++++++++++ 2 files changed, 27 insertions(+)
target/mips/tcg/octeon.decode +14 -0
@@ -160,6 +160,9 @@ LDX 011111 ..... ..... ..... 01000 001010 @lx CVM_MF_GFM_RESINP0 010010 00001 rt:5 0000 0010 0101 1010 &cp2 CVM_MF_GFM_RESINP1 010010 00001 rt:5 0000 0010 0101 1011 &cp2 CVM_MF_GFM_POLY 010010 00001 rt:5 0000 0010 0101 1110 &cp2 + CVM_MF_CHORD 010010 00001 rt:5 0000 0100 0000 0000 &cp2 + CVM_MF_LLM_DATA0 010010 00001 rt:5 0000 0100 0000 0010 &cp2 + CVM_MF_LLM_DATA1 010010 00001 rt:5 0000 0100 0000 1010 &cp2 CVM_MT_HSH_DAT0 010010 00101 rt:5 0000 0000 0100 0000 &cp2 CVM_MT_HSH_DAT1 010010 00101 rt:5 0000 0000 0100 0001 &cp2 CVM_MT_HSH_DAT2 010010 00101 rt:5 0000 0000 0100 0010 &cp2
@@ -253,6 +256,16 @@ LDX 011111 ..... ..... ..... 01000 001010 @lx CVM_MT_SHA3_XORDAT15 010010 00101 rt:5 0000 0010 1100 1111 &cp2 CVM_MT_SHA3_XORDAT16 010010 00101 rt:5 0000 0010 1101 0000 &cp2 CVM_MT_SHA3_XORDAT17 010010 00101 rt:5 0000 0010 1101 0001 &cp2 + CVM_MT_LLM_READ_ADDR0 010010 00101 rt:5 0000 0100 0000 0000 &cp2 + CVM_MT_LLM_WRITE_ADDR0 010010 00101 rt:5 0000 0100 0000 0001 &cp2 + CVM_MT_LLM_DATA0 010010 00101 rt:5 0000 0100 0000 0010 &cp2 + CVM_MT_LLM_READ64_ADDR0 010010 00101 rt:5 0000 0100 0000 0100 &cp2 + CVM_MT_LLM_WRITE64_ADDR0 010010 00101 rt:5 0000 0100 0000 0101 &cp2 + CVM_MT_LLM_READ_ADDR1 010010 00101 rt:5 0000 0100 0000 1000 &cp2 + CVM_MT_LLM_WRITE_ADDR1 010010 00101 rt:5 0000 0100 0000 1001 &cp2 + CVM_MT_LLM_DATA1 010010 00101 rt:5 0000 0100 0000 1010 &cp2 + CVM_MT_LLM_READ64_ADDR1 010010 00101 rt:5 0000 0100 0000 1100 &cp2 + CVM_MT_LLM_WRITE64_ADDR1 010010 00101 rt:5 0000 0100 0000 1101 &cp2 CVM_MT_CRC_WRITE_LEN 010010 00101 rt:5 0001 0010 0000 0010 &cp2 CVM_MT_CRC_WRITE_DWORD 010010 00101 rt:5 0001 0010 0000 0111 &cp2 CVM_MT_CRC_WRITE_VAR 010010 00101 rt:5 0001 0010 0000 1000 &cp2
@@ -287,4 +300,5 @@ LDX 011111 ..... ..... ..... 01000 001010 @lx CVM_MT_HSH_STARTSHA512 010010 00101 rt:5 0100 0010 0100 1111 &cp2 CVM_MT_GFM_XORMUL1 010010 00101 rt:5 0100 0010 0101 1101 &cp2 ] + CP2_Undef 010010 ----- ----- ---- ---- ---- ---- }
target/mips/tcg/octeon_translate.c +13 -0
@@ -180,6 +180,9 @@ CP2_MF_I64(CVM_MF_GFM_MUL1, gfm_mul[1]);CP2_MF_I64 (CVM_MF_GFM_RESINP0 , gfm_resinp[0 ]);CP2_MF_I64 (CVM_MF_GFM_RESINP1 , gfm_resinp[1 ]);CP2_MF_U16 (CVM_MF_GFM_POLY , gfm_poly); +CP2_MF_I64 (CVM_MF_CHORD , chord); +CP2_MF_I64 (CVM_MF_LLM_DATA0 , llm_data[0 ]); +CP2_MF_I64 (CVM_MF_LLM_DATA1 , llm_data[1 ]);CP2_MF_HELPER (CVM_MF_CRC_IV_REFLECT , crc_iv_reflect);CP2_MF_HELPER (CVM_MF_SHA3_DAT24 , sha3_dat24);
@@ -247,6 +250,8 @@ CP2_MT_I64(CVM_MT_GFM_RESINP0, gfm_resinp[0]);CP2_MT_I64 (CVM_MT_GFM_RESINP1 , gfm_resinp[1 ]);CP2_MT_HELPER (CVM_MT_GFM_XOR0 , gfm_xor0);CP2_MT_U16 (CVM_MT_GFM_POLY , gfm_poly); +CP2_MT_I64 (CVM_MT_LLM_DATA0 , llm_data[0 ]); +CP2_MT_I64 (CVM_MT_LLM_DATA1 , llm_data[1 ]);CP2_MT_U8 (CVM_MT_CRC_WRITE_LEN , crc_len);CP2_MT_U32 (CVM_MT_CRC_WRITE_POLYNOMIAL , crc_poly);CP2_MT_U32 (CVM_MT_CRC_WRITE_POLYNOMIAL_REFLECT , crc_poly);
@@ -335,6 +340,14 @@ CP2_MT_HELPER(CVM_MT_HSH_STARTMD5, hsh_startmd5);CP2_MT_HELPER (CVM_MT_HSH_STARTSHA256 , hsh_startsha256);CP2_MT_HELPER (CVM_MT_HSH_STARTSHA , hsh_startsha);CP2_MT_HELPER (CVM_MT_HSH_STARTSHA512 , hsh_startsha512); +CP2_MT_HELPER (CVM_MT_LLM_READ_ADDR0 , llm_read_addr0); +CP2_MT_HELPER (CVM_MT_LLM_WRITE_ADDR0 , llm_write_addr0); +CP2_MT_HELPER (CVM_MT_LLM_READ64_ADDR0 , llm_read64_addr0); +CP2_MT_HELPER (CVM_MT_LLM_WRITE64_ADDR0 , llm_write64_addr0); +CP2_MT_HELPER (CVM_MT_LLM_READ_ADDR1 , llm_read_addr1); +CP2_MT_HELPER (CVM_MT_LLM_WRITE_ADDR1 , llm_write_addr1); +CP2_MT_HELPER (CVM_MT_LLM_READ64_ADDR1 , llm_read64_addr1); +CP2_MT_HELPER (CVM_MT_LLM_WRITE64_ADDR1 , llm_write64_addr1);static bool trans_BBIT (DisasContext *ctx,arg_BBIT *a) {
Signature · 1 line
2.54.0
PATCH v10 43/45 target/mips: add Octeon CvmCount RDHWR support
In reply to James HilliardOcteon exposes CvmCount through RDHWR register 31. Add the Octeon-only decode path, enable the corresponding HWREna bit for linux-user, and use an unsigned mask when checking HWREna so bit 31 is handled safely.
For user-mode emulation, return host ticks as a monotonic counter source suitable for existing Octeon userspace code. In system mode, fall back to the existing CP0 Count value.
---
Changes v5 -> v6:
- New patch.
--- target/mips/cpu.c | 1 + target/mips/helper.h | 1 + target/mips/tcg/op_helper.c | 13 ++++++++++++- target/mips/tcg/translate.c | 11 +++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-)
target/mips/cpu.c +1 -0
@@ -322,6 +322,7 @@ static void mips_cpu_reset_hold(Object *obj, ResetType type) env->CP0_HWREna |=0x0000000F ;if (env->insn_flags &INSN_OCTEON ) { env->CP0_HWREna |=0x40000000u ; + env->CP0_HWREna |=0x80000000u ; }if (env->CP0_Config1 & (1 <<CP0C1_FP )) { env->CP0_Status |= (1 << CP0St_CU1);
target/mips/helper.h +1 -0
@@ -319,6 +319,7 @@ DEF_HELPER_1(rdhwr_ccres, tl, env) DEF_HELPER_1(rdhwr_performance, tl, env) DEF_HELPER_1(rdhwr_xnp, tl, env) DEF_HELPER_1(rdhwr_chord, tl, env) +DEF_HELPER_1(rdhwr_cvmcount, tl, env) DEF_HELPER_2(pmon, void, env, int)DEF_HELPER_1 (wait, void, env)
target/mips/tcg/op_helper.c +12 -1
@@ -25,6 +25,7 @@#include "exec/memop.h" #include "fpu_helper.h" #include "qemu/crc32c.h" +#include "qemu/timer.h" #include <zlib.h> static inline target_ulong bitswap (target_ulong v)
@@ -209,7 +210,7 @@ target_ulong helper_yield(CPUMIPSState *env, target_ulong arg)static inline void check_hwrena (CPUMIPSState *env,int reg,uintptr_t pc) { -if ((env->hflags &MIPS_HFLAG_CP0 ) || (env->CP0_HWREna & (1 << reg))) { +if ((env->hflags &MIPS_HFLAG_CP0 ) || (env->CP0_HWREna & (1u << reg))) {return ; }do_raise_exception (env,EXCP_RI , pc);
@@ -261,6 +262,16 @@ target_ulong helper_rdhwr_chord(CPUMIPSState *env)return env->octeon_crypto.chord; } +target_ulong helper_rdhwr_cvmcount (CPUMIPSState *env) +{ +check_hwrena (env,31 ,GETPC ()); +#ifdef CONFIG_USER_ONLY +return cpu_get_host_ticks (); +#else +return (uint32_t )cpu_mips_get_count (env); +#endif +} +void helper_pmon (CPUMIPSState *env,int function) { function /=2 ;
target/mips/tcg/translate.c +11 -0
@@ -10933,6 +10933,17 @@ void gen_rdhwr(DisasContext *ctx, int rt, int rd, int sel)gen_helper_rdhwr_chord (t0, tcg_env);gen_store_gpr (t0, rt);break ; +case 31 : +if (!(ctx->insn_flags &INSN_OCTEON )) { +gen_reserved_instruction (ctx); +break ; + } +translator_io_start (&ctx->base); +gen_helper_rdhwr_cvmcount (t0, tcg_env); +gen_store_gpr (t0, rt); +gen_save_pc (ctx->base.pc_next +4 ); + ctx->base.is_jmp =DISAS_EXIT ; +break ;default :/* Invalid */ MIPS_INVAL ("rdhwr" );gen_reserved_instruction (ctx);
Signature · 1 line
2.54.0
PATCH v10 44/45 tests/tcg/mips: cover Octeon COP2, QMAC and CvmCount
In reply to James HilliardExtend the Octeon linux-user smoke test with AES key and key-length DMTC2/DMFC2 readback checks, QMAC/QMACS fixed-point accumulator checks, and an RDHWR $31 monotonicity check.
The COP2 readback cases exercise the explicit COP2 decodetree entries and direct TCG register-transfer paths. The QMAC and CvmCount cases keep the fixed-point accumulator and RDHWR paths covered by the same Octeon smoke binary.
---
Changes v8 -> v9:
- Combine the v8 COP2 selector readback and QMAC/CvmCount test patches.
- Fix the commit message to refer to RDHWR $31.
Changes v7 -> v8:
- Split AES COP2 selector readback coverage out of the COP2 crypto core patch.
Changes v5 -> v6:
- Add QMAC/QMACS and CvmCount smoke coverage.
--- tests/tcg/mips/user/isa/octeon/octeon-insns.c | 128 ++++++++++++++++++++++++++ 1 file changed, 128 insertions(+)
tests/tcg/mips/user/isa/octeon/octeon-insns.c +128 -0
@@ -129,6 +129,59 @@ static uint64_t octeon_vmm0(uint64_t mpl0, uint64_t p0,return rd; } +static uint64_t octeon_qmac_lo (uint64_t rs,uint64_t rt,uint64_t lo) +{ +uint64_t rd; + + asmvolatile ( +"move $8, %[rs]\n\t" +"move $9, %[rt]\n\t" +"mtlo %[lo]\n\t" +"mthi $0\n\t" +".word 0x710904d2\n\t" /* qmac.03 $8, $9 */ +"mflo %[rd]\n\t" + : [rd]"=r" (rd) + : [rs]"r" (rs), [rt]"r" (rt), [lo]"r" (lo) + :"$8" ,"$9" ); + +return rd; +} + +static uint64_t octeon_qmacs_state (uint64_t rs,uint64_t rt,uint64_t lo) +{ +uint64_t hi, rd; + + asmvolatile ( +"move $8, %[rs]\n\t" +"move $9, %[rt]\n\t" +"mtlo %[lo]\n\t" +"mthi $0\n\t" +".word 0x71090012\n\t" /* qmacs.00 $8, $9 */ +"mfhi %[hi]\n\t" +"mflo %[rd]\n\t" + : [hi]"=r" (hi), [rd]"=r" (rd) + : [rs]"r" (rs), [rt]"r" (rt), [lo]"r" (lo) + :"$8" ,"$9" ); + +return ((hi &1 ) <<32 ) | (rd &0xffffffff ); +} + +static uint64_t octeon_rdhwr31_non_decreasing (void ) +{ +uint64_t first, second; + + asmvolatile ( +".word 0x7c08f83b\n\t" /* rdhwr $8, $31 */ +".word 0x7c09f83b\n\t" /* rdhwr $9, $31 */ +"move %[first], $8\n\t" +"move %[second], $9\n\t" + : [first]"=r" (first), [second]"=r" (second) + : + :"$8" ,"$9" ); + +return second >= first; +} +static uint64_t octeon_vmm0_zeroes_mpl1 (void ) {uint64_t rd;
@@ -186,6 +239,70 @@ static uint64_t octeon_mtp0_zeroes_p1(void)return rd; } +static uint64_t octeon_cop2_key0_readback (uint64_t value) +{ +uint64_t rd; + + asmvolatile ( +"move $8, %[value]\n\t" +".word 0x48a80104\n\t" /* dmtc2 $8, AES_KEY0 selector */ +".word 0x482a0104\n\t" /* dmfc2 $10, AES_KEY0 selector */ +"move %[rd], $10\n\t" + : [rd]"=r" (rd) + : [value]"r" (value) + :"$8" ,"$10" ); + +return rd; +} + +static uint64_t octeon_cop2_key2_readback (uint64_t value) +{ +uint64_t rd; + + asmvolatile ( +"move $8, %[value]\n\t" +".word 0x48a80106\n\t" /* dmtc2 $8, AES_KEY2 selector */ +".word 0x482a0106\n\t" /* dmfc2 $10, AES_KEY2 selector */ +"move %[rd], $10\n\t" + : [rd]"=r" (rd) + : [value]"r" (value) + :"$8" ,"$10" ); + +return rd; +} + +static uint64_t octeon_cop2_key3_readback (uint64_t value) +{ +uint64_t rd; + + asmvolatile ( +"move $8, %[value]\n\t" +".word 0x48a80107\n\t" /* dmtc2 $8, AES_KEY3 selector */ +".word 0x482a0107\n\t" /* dmfc2 $10, AES_KEY3 selector */ +"move %[rd], $10\n\t" + : [rd]"=r" (rd) + : [value]"r" (value) + :"$8" ,"$10" ); + +return rd; +} + +static uint64_t octeon_cop2_keylength_readback (uint64_t value) +{ +uint64_t rd; + + asmvolatile ( +"move $8, %[value]\n\t" +".word 0x48a80110\n\t" /* dmtc2 $8, AES_KEYLENGTH selector */ +".word 0x482a0110\n\t" /* dmfc2 $10, AES_KEYLENGTH selector */ +"move %[rd], $10\n\t" + : [rd]"=r" (rd) + : [value]"r" (value) + :"$8" ,"$10" ); + +return rd; +} +int main (void ) {assert (octeon_baddu (0x123 ,0x0f0 ) ==0x13 );
@@ -195,10 +312,21 @@ int main(void)assert (octeon_seq (0xabc ,0xdef ) ==0 );assert (octeon_sne (0xabc ,0xabc ) ==0 );assert (octeon_sne (0xabc ,0xdef ) ==1 ); +assert (octeon_qmac_lo (0x0003000000000000ULL ,2 ,1 ) ==13 ); +assert (octeon_qmacs_state (1 ,1 ,0x7ffffffe ) ==0x17fffffffULL ); +assert (octeon_qmacs_state (0x8000 ,0x8000 ,0 ) ==0x17fffffffULL ); +assert (octeon_rdhwr31_non_decreasing ());assert (octeon_vmulu (5 ,7 ,11 ) ==46 );assert (octeon_vmm0 (5 ,13 ,7 ,11 ) ==59 );assert (octeon_vmm0_zeroes_mpl1 () ==0 );assert (octeon_mtp0_zeroes_p1 () ==0 ); +assert (octeon_cop2_key0_readback (0x1122334455667788ULL ) == +0x1122334455667788ULL ); +assert (octeon_cop2_key2_readback (0x8877665544332211ULL ) == +0x8877665544332211ULL ); +assert (octeon_cop2_key3_readback (0x0102030405060708ULL ) == +0x0102030405060708ULL ); +assert (octeon_cop2_keylength_readback (0xa5 ) ==0xa5 );return 0 ; }
Signature · 1 line
2.54.0
PATCH v10 45/45 target/mips: expose Octeon68XX floating-point support
In reply to James HilliardOcteon68XX cores implement CP1. Advertise that in the CPU definition by setting Config1.FP, enabling the writable Status bits, and providing the FCR0/FCR31 defaults used by this CPU model.
This lets guests observe the expected floating-point feature bits and use CP1 with -cpu Octeon68XX.
---
Changes v1 -> v2:
- Move this CPU-model correction into a separate final patch. (suggested by Philippe Mathieu-Daudé)
--- target/mips/cpu-defs.c.inc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
target/mips/cpu-defs.c.inc +8 -2
@@ -997,7 +997,8 @@ const mips_def_t mips_defs[] = .CP0_PRid = 0x000D9100, .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) | (MMU_TYPE_R4000 << CP0C0_MT), - .CP0_Config1 = MIPS_CONFIG1 | (0x3F << CP0C1_MMU) | + .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | + (0x3F << CP0C1_MMU) | (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) | (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) | (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
@@ -1011,7 +1012,12 @@ const mips_def_t mips_defs[] = .CP0_PageGrain = (1 << CP0PG_ELPA), .SYNCI_Step = 32, .CCRes = 2, - .CP0_Status_rw_bitmask = 0x12F8FFFF, + .CP0_Status_rw_bitmask = 0x36F8FFFF, + .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_3D) | (1 << FCR0_PS) | + (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) | + (1 << FCR0_S) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV), + .CP1_fcr31 = 0, + .CP1_fcr31_rw_bitmask = 0xFF83FFFF, .SEGBITS = 42, .PABITS = 49, .insn_flags = CPU_MIPS64R2 | INSN_OCTEON,
Signature · 1 line
2.54.0
Hi James,
Quoted 15 lines · James Hilliard
This series updates MIPS linux-user unaligned-access behavior and fills in missing Octeon user-mode instruction support used by existing Octeon binaries.
The first patches model the Linux/MIPS sysmips ABI pieces needed by linux-user, including
MIPS_FLUSH_CACHE,MIPS_ATOMIC_SET, and theMIPS_FIXADEpolicy used to control unaligned scalar access fixups. User-mode unaligned scalar accesses default to software fixups andsysmips(MIPS_FIXADE)can toggle SIGBUS/BUS_ADRALN behavior.Richard Henderson's v7.5 multiplier/QMAC rework is incorporated directly as nine patches: two TCG preparatory patches and seven Octeon multiplier/QMAC patches. The Octeon multiplier and QMAC translations now expand inline in TCG.
Quoted 8 lines
The remaining Octeon patches add integer, indexed memory, atomic, COP2 crypto, CHORD, LLM, and CvmCount RDHWR support. The COP2 work is split into state, helper plumbing, per-engine helper patches, explicit selector decode, CHORD/LLM, and smoke-test coverage, with each functional block isolated. The series also adds a small mips64/mips64el TCG guest test covering representative Octeon integer, fixed-point, multiplier, RDHWR, and COP2 selector paths. The final patch corrects the Octeon68XX CP1 feature bits and FCR defaults.
Thanks for this series, I really appreciate your dedication and the quality of your patches. I have been trying to queue it since v7 but you keep respinning :) Since the first half is stable and reviewed, I'll queue that first and send in my next MIPS pull request; less for you to carry over.
Regards,
Phil.
Quoted 70 lines
---
Changes in v10:
- Split the explicit Octeon COP2 selector decode patch into register,
CRC/GFM, HSH/SHA3, stream-cipher, block-cipher, and CHORD/LLM
patches.
- Added Philippe's Reviewed-by tag and local MemOp cleanup for ZCB/ZCBT.
- Added Philippe's Tested-by tags for VMULU, VMM0, and Octeon68XX CP1.
- Restored the original constant-fold output ordering in the TCG mul[us]2
optimization patch.
- Kept Octeon COP2 crypto state architectural by dropping shared-mode and
AES, GFM, SHA3, ZUC, and SNOW3G shadow state.
- Ordered Octeon COP2 crypto CPU state and VMState fields by architectural
selector groups.
- Reworked GFM reflected helpers around the full 128-bit architectural state
and direct RESINP XOR operations.
- Preserved the 64-bit UIA2 GFM reduction path used by SNOW3G F9.
- Added Richard's Reviewed-by tag for the CRC COP2 helpers and masked
variable-length CRC writes to CRCLEN<3:0>.
- Link to v9: https://lore.kernel.org/qemu-devel/20260519-mips-octeon-missing-insns-v2-v9-0-d7dd735ecddd@gmail.comChanges in v9:
- UsedMO_ATOM_NONEfor the 128-bit ZCB/ZCBT zero stores.
- Reusedocteon_zero_partial_product_state()in the VMM0 translator.
- Removed the shared MIPSOcteonCop2Sel enum from CPU state headers.
- Replaced generic selector-dispatch COP2 helpers with per-operation
helper functions.
- Split COP2 helper implementation into smaller functional subcategory
patches: plumbing, CRC, GFM, SHA3, ZUC, SNOW3G, AES, SMS4, 3DES/KASUMI,
Camellia, HSH, and CHORD/LLM.
- Added COP2 helper declarations tohelper.halongside the per-engine
helper implementation commits.
- Used signed 32-bit DMFC2 direct loads for 32-bit COP2 register
readback.
- Documented the AESRESINP direct register-transfer handling in the translator.
- Combined COP2 selector readback with QMAC/CvmCount smoke coverage.
- Link to v8: https://lore.kernel.org/qemu-devel/20260517-mips-octeon-missing-insns-v2-v8-0-206151ee77ec@gmail.comChanges in v8:
- Incorporated Richard Henderson's v7.5 9-patch multiplier/QMAC rework
directly into the stack rather than as a follow-up cleanup.
- Added the two v7.5 TCG prep patches as standalone patches:
tcg_gen_addN_i64and mul[us]2 zero/one optimization.
- Replaced the helper-backed Octeon multiplier/QMAC sequence with the
seven v7.5-shaped patches: multiplier state, MTM, MTP, VMULU, VMM0,
V3MULU, and QMAC.
- Split Octeon COP2 crypto core support into state/migration, helper
implementation, explicit selector decode, and selector readback test
patches.
- Decoded Octeon COP2 selectors explicitly in decodetree and used direct
TCG loads/stores for simple COP2 register moves.
- Kept COP2 helper calls for operation selectors and shared-window state
that require side effects.
- Folded ZCB/ZCBT into one patch so the decodetree wildcard is
introduced in final form.
- Added new Reviewed-by tags from Richard Henderson for MTM/MTP, LA*,
CvmCount, and QMAC/CvmCount test patches.
- Link to v7: https://lore.kernel.org/qemu-devel/20260514-mips-octeon-missing-insns-v2-v7-0-226686be4ce1@gmail.comChanges in v7:
- Rebased on current qemu.git staging (edcc429e9e).
- Reordered the zero-register cleanup after the BADDU/DMUL destination fix
and moved the multiplier-state patch next to the MTM/MTP instruction
patches.
- Applied Philippe'sMIPS_FIXADETB-flag readability tweak.
- Used explicit MO_32/MO_64 MemOps for SAA/SAAD atomic transaction sizes.
- Folded ZCB/ZCBT decode with a decodetree wildcard and zero the cache
block with 128-bit stores.
- Added new Reviewed-by tags from Philippe Mathieu-Daudé and Richard
Henderson.
- Link to v6: https://lore.kernel.org/qemu-devel/20260511-mips-octeon-missing-insns-v2-v6-0-5062889c4d3c@gmail.com
[...]
Quoted 26 lines
---
James Hilliard (43):
linux-user/mips: implementsysmips(MIPS_FLUSH_CACHE)linux-user/mips: implementsysmips(MIPS_ATOMIC_SET)linux-user/mips, target/mips: honorMIPS_FIXADEfor unaligned accesses target/mips: fix Octeon arithmetic destination handling target/mips: drop Octeon zero-register fast paths target/mips: split Octeon SEQ/SNE decode
target/mips: add Octeon LBX instruction
target/mips: add Octeon LHUX instruction
target/mips: add Octeon LWUX instruction
target/mips: add Octeon SAA instruction
target/mips: add Octeon SAAD instruction
target/mips: add Octeon ZCB and ZCBT instructions target/mips: add Octeon multiplier state
target/mips: add Octeon MTM instructions
target/mips: add Octeon MTP instructions
target/mips: add Octeon VMULU instruction
target/mips: add Octeon VMM0 instruction
target/mips: add Octeon V3MULU instruction
target/mips: add Octeon QMAC instructions
tests/tcg/mips: add Octeon instruction smoke test target/mips: add Octeon LA* atomic instructions23 files changed, 4431 insertions(+), 92 deletions(-)
Quoted 28 lines · Philippe Mathieu-Daudé
Hi James,
Quoted 15 lines · James Hilliard
This series updates MIPS linux-user unaligned-access behavior and fills in missing Octeon user-mode instruction support used by existing Octeon binaries.
The first patches model the Linux/MIPS sysmips ABI pieces needed by linux-user, including
MIPS_FLUSH_CACHE,MIPS_ATOMIC_SET, and theMIPS_FIXADEpolicy used to control unaligned scalar access fixups. User-mode unaligned scalar accesses default to software fixups andsysmips(MIPS_FIXADE)can toggle SIGBUS/BUS_ADRALN behavior.Richard Henderson's v7.5 multiplier/QMAC rework is incorporated directly as nine patches: two TCG preparatory patches and seven Octeon multiplier/QMAC patches. The Octeon multiplier and QMAC translations now expand inline in TCG.
Quoted 8 lines
The remaining Octeon patches add integer, indexed memory, atomic, COP2 crypto, CHORD, LLM, and CvmCount RDHWR support. The COP2 work is split into state, helper plumbing, per-engine helper patches, explicit selector decode, CHORD/LLM, and smoke-test coverage, with each functional block isolated. The series also adds a small mips64/mips64el TCG guest test covering representative Octeon integer, fixed-point, multiplier, RDHWR, and COP2 selector paths. The final patch corrects the Octeon68XX CP1 feature bits and FCR defaults.
Quoted 5 lines
Thanks for this series, I really appreciate your dedication and the quality of your patches. I have been trying to queue it since v7 but you keep respinning :) Since the first half is stable and reviewed, I'll queue that first and send in my next MIPS pull request; less for you to carry over.
Now merged as commits e83a42cbf72...006d624b948.
Rebasing the rest shouldn't be too hard (changes are obvious, I also moved the TRANS_LX block around). Tell me if you have an issue rebasing your work and I'll repost the remaining patches.
Regards,
Phil.
Quoted 23 lines
Quoted 23 lines
---
James Hilliard (43):
linux-user/mips: implementsysmips(MIPS_FLUSH_CACHE)linux-user/mips: implementsysmips(MIPS_ATOMIC_SET)linux-user/mips, target/mips: honorMIPS_FIXADEfor unaligned accesses target/mips: fix Octeon arithmetic destination handling target/mips: drop Octeon zero-register fast paths target/mips: split Octeon SEQ/SNE decode
target/mips: add Octeon LBX instruction
target/mips: add Octeon LHUX instruction
target/mips: add Octeon LWUX instruction
target/mips: add Octeon SAA instruction
target/mips: add Octeon SAAD instruction
target/mips: add Octeon ZCB and ZCBT instructions target/mips: add Octeon multiplier state
target/mips: add Octeon MTM instructions
target/mips: add Octeon MTP instructions
target/mips: add Octeon VMULU instruction
target/mips: add Octeon VMM0 instruction
target/mips: add Octeon V3MULU instruction
target/mips: add Octeon QMAC instructions
tests/tcg/mips: add Octeon instruction smoke test target/mips: add Octeon LA* atomic instructions
Quoted 12 lines · Philippe Mathieu-Daudé
Quoted 10 lines · Philippe Mathieu-Daudé
Quoted 3 lines · James Hilliard
This series updates MIPS linux-user unaligned-access behavior and fills in missing Octeon user-mode instruction support used by existing Octeon binaries.
Thanks for this series, I really appreciate your dedication and the quality of your patches. I have been trying to queue it since v7 but you keep respinning :) Since the first half is stable and reviewed, I'll queue that first and send in my next MIPS pull request; less for you to carry over.
Quoted 6 lines
Now merged as commits
e83a42cbf72...006d624b948.Rebasing the rest shouldn't be too hard (changes are obvious, I also moved the
TRANS_LXblock around). Tell me if you have an issue rebasing your work and I'll repost the remaining patches.
And I now notice your v13, this is perfect, I'll follow there, thank you!
https://lore.kernel.org/qemu-devel/20260521-mips-octeon-missing-insns-v2-v13-0-5a4cb8ec9cd3@gmail.com/