Add the Octeon COP2 crypto helper source file and build it with the MIPS TCG target. The initial file contains the shared selector-window helper constants and mode setter used by later COP2 engine patches.
Keep these selector constants local to the helper implementation. The instruction dispatch itself remains fully decoded by decodetree, and later operation selectors call per-operation helpers rather than a common selector-dispatch helper. Signed-off-by: James Hilliard <[email protected]> --- 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 | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/target/mips/tcg/meson.build b/target/mips/tcg/meson.build index fff9cd6c7f..4ee359874a 100644 --- a/target/mips/tcg/meson.build +++ b/target/mips/tcg/meson.build @@ -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', diff --git a/target/mips/tcg/octeon_crypto.c b/target/mips/tcg/octeon_crypto.c new file mode 100644 index 0000000000..f9b54f7017 --- /dev/null +++ b/target/mips/tcg/octeon_crypto.c @@ -0,0 +1,37 @@ +/* + * 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/clmul.h" +#include "crypto/sm4.h" +#include "qemu/bitops.h" +#include "qemu/host-utils.h" + +/* + * The shared HSH/SHA3/SNOW3G/ZUC register window needs selector-position + * arithmetic. Instruction dispatch itself is still fully decoded by + * decodetree and calls per-operation helpers. + */ +#define OCTEON_HSH_DATW(N) (0x0240u + (N)) +#define OCTEON_HSH_IVW(N) (0x0250u + (N)) +#define OCTEON_SHA3_DAT24_SEL 0x0050u +#define OCTEON_SHA3_DAT15_MT_SEL 0x0051u +#define OCTEON_SHA3_DAT15_MF_SEL OCTEON_HSH_DATW(15) +#define OCTEON_SNOW3G_LFSR(N) OCTEON_HSH_DATW(N) +#define OCTEON_SNOW3G_RESULT_SEL OCTEON_HSH_IVW(0) +#define OCTEON_SNOW3G_FSM(N) OCTEON_HSH_IVW(1 + (N)) + +static inline void octeon_set_shared_mode(MIPSOcteonCryptoState *crypto, + MIPSOcteonSharedMode mode) +{ + crypto->shared_mode = mode; +} -- 2.54.0
