Extend the Octeon linux-user smoke test with AES key and key-length DMTC2/DMFC2 readback checks. These selectors exercise the explicit COP2 decodetree entries and direct TCG register-transfer paths introduced by the decode split.
Keep the coverage independent from the functional crypto-vector test so the in-tree TCG smoke test catches selector routing regressions quickly. Signed-off-by: James Hilliard <[email protected]> --- Changes v7 -> v8: - Split AES COP2 selector readback coverage out of the COP2 crypto core patch. --- tests/tcg/mips/user/isa/octeon/octeon-insns.c | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/tests/tcg/mips/user/isa/octeon/octeon-insns.c b/tests/tcg/mips/user/isa/octeon/octeon-insns.c index 9153e37e9e..435ccfa347 100644 --- a/tests/tcg/mips/user/isa/octeon/octeon-insns.c +++ b/tests/tcg/mips/user/isa/octeon/octeon-insns.c @@ -186,6 +186,70 @@ static uint64_t octeon_mtp0_zeroes_p1(void) return rd; } +static uint64_t octeon_cop2_key0_readback(uint64_t value) +{ + uint64_t rd; + + asm volatile( + "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; + + asm volatile( + "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; + + asm volatile( + "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; + + asm volatile( + "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); @@ -199,6 +263,13 @@ int main(void) 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; } -- 2.54.0
