Merge tag 'pull-loongarch-20241016' of https://gitlab.com/gaosong/qemu into staging
[qemu/armbru.git] / tests / tcg / ppc64 / test-aes.c
blob1d2be488e944408a09465e4e2c4612c2f05e1349
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include "../multiarch/test-aes-main.c.inc"
5 #undef BIG_ENDIAN
6 #define BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
8 static unsigned char bswap_le[16] __attribute__((aligned(16))) = {
9 8,9,10,11,12,13,14,15,
10 0,1,2,3,4,5,6,7
13 bool test_SB_SR(uint8_t *o, const uint8_t *i)
15 /* vcipherlast also adds round key, so supply zero. */
16 if (BIG_ENDIAN) {
17 asm("lxvd2x 32,0,%1\n\t"
18 "vspltisb 1,0\n\t"
19 "vcipherlast 0,0,1\n\t"
20 "stxvd2x 32,0,%0"
21 : : "r"(o), "r"(i) : "memory", "v0", "v1");
22 } else {
23 asm("lxvd2x 32,0,%1\n\t"
24 "lxvd2x 34,0,%2\n\t"
25 "vspltisb 1,0\n\t"
26 "vperm 0,0,0,2\n\t"
27 "vcipherlast 0,0,1\n\t"
28 "vperm 0,0,0,2\n\t"
29 "stxvd2x 32,0,%0"
30 : : "r"(o), "r"(i), "r"(bswap_le) : "memory", "v0", "v1", "v2");
32 return true;
35 bool test_MC(uint8_t *o, const uint8_t *i)
37 return false;
40 bool test_SB_SR_MC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k)
42 if (BIG_ENDIAN) {
43 asm("lxvd2x 32,0,%1\n\t"
44 "lxvd2x 33,0,%2\n\t"
45 "vcipher 0,0,1\n\t"
46 "stxvd2x 32,0,%0"
47 : : "r"(o), "r"(i), "r"(k) : "memory", "v0", "v1");
48 } else {
49 asm("lxvd2x 32,0,%1\n\t"
50 "lxvd2x 33,0,%2\n\t"
51 "lxvd2x 34,0,%3\n\t"
52 "vperm 0,0,0,2\n\t"
53 "vperm 1,1,1,2\n\t"
54 "vcipher 0,0,1\n\t"
55 "vperm 0,0,0,2\n\t"
56 "stxvd2x 32,0,%0"
57 : : "r"(o), "r"(i), "r"(k), "r"(bswap_le)
58 : "memory", "v0", "v1", "v2");
60 return true;
63 bool test_ISB_ISR(uint8_t *o, const uint8_t *i)
65 /* vcipherlast also adds round key, so supply zero. */
66 if (BIG_ENDIAN) {
67 asm("lxvd2x 32,0,%1\n\t"
68 "vspltisb 1,0\n\t"
69 "vncipherlast 0,0,1\n\t"
70 "stxvd2x 32,0,%0"
71 : : "r"(o), "r"(i) : "memory", "v0", "v1");
72 } else {
73 asm("lxvd2x 32,0,%1\n\t"
74 "lxvd2x 34,0,%2\n\t"
75 "vspltisb 1,0\n\t"
76 "vperm 0,0,0,2\n\t"
77 "vncipherlast 0,0,1\n\t"
78 "vperm 0,0,0,2\n\t"
79 "stxvd2x 32,0,%0"
80 : : "r"(o), "r"(i), "r"(bswap_le) : "memory", "v0", "v1", "v2");
82 return true;
85 bool test_IMC(uint8_t *o, const uint8_t *i)
87 return false;
90 bool test_ISB_ISR_AK_IMC(uint8_t *o, const uint8_t *i, const uint8_t *k)
92 if (BIG_ENDIAN) {
93 asm("lxvd2x 32,0,%1\n\t"
94 "lxvd2x 33,0,%2\n\t"
95 "vncipher 0,0,1\n\t"
96 "stxvd2x 32,0,%0"
97 : : "r"(o), "r"(i), "r"(k) : "memory", "v0", "v1");
98 } else {
99 asm("lxvd2x 32,0,%1\n\t"
100 "lxvd2x 33,0,%2\n\t"
101 "lxvd2x 34,0,%3\n\t"
102 "vperm 0,0,0,2\n\t"
103 "vperm 1,1,1,2\n\t"
104 "vncipher 0,0,1\n\t"
105 "vperm 0,0,0,2\n\t"
106 "stxvd2x 32,0,%0"
107 : : "r"(o), "r"(i), "r"(k), "r"(bswap_le)
108 : "memory", "v0", "v1", "v2");
110 return true;
113 bool test_ISB_ISR_IMC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k)
115 return false;