target/s390x: Compile crypto_helper.c as common unit
In order do build crypto_helper.c as a common unit we need to replace: "accel/tcg/cpu-ldst.h" -> "accel/tcg/cpu-ldst-common.h" and update the cpu_ld/st_be_data_ra() API by cpu_ld/st_mmu() one. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com> Message-Id: <20260423135035.50126-9-philmd@linaro.org>
Philippe Mathieu-Daudé committed
Apr 23, 2026 at 12:23 UTC
de96db79aa589fd10142379384b8aec6ac7d24bb
2 files changed
+22
-19
target/s390x/tcg/crypto_helper.c
+21
-18
@@ -17,7 +17,7 @@
17
#include "s390x-internal.h"
18
#include "tcg_s390x.h"
19
#include "exec/helper-proto.h"
20
-#include "accel/tcg/cpu-ldst.h"
20
+#include "accel/tcg/cpu-ldst-common.h"
21
#include "accel/tcg/cpu-mmu-index.h"
22
23
static uint64_t R(uint64_t x, int c)
@@ -123,44 +123,44 @@ static void sha512_bda_be64(uint64_t a[8], uint64_t w[16])
123
static void sha512_read_icv(CPUS390XState *env, const int mmu_idx,
124
uint64_t addr, uint64_t a[8], uintptr_t ra)
125
{
126
- int i;
126
+ const MemOpIdx oi = make_memop_idx(MO_BE | MO_64 | MO_UNALN, mmu_idx);
127
128
- for (i = 0; i < 8; i++, addr += 8) {
128
+ for (int i = 0; i < 8; i++, addr += 8) {
129
addr = wrap_address(env, addr);
130
- a[i] = cpu_ldq_be_data_ra(env, addr, ra);
130
+ a[i] = cpu_ldq_mmu(env, addr, oi, ra);
131
}
132
}
133
134
static void sha512_write_ocv(CPUS390XState *env, const int mmu_idx,
135
uint64_t addr, uint64_t a[8], uintptr_t ra)
136
{
137
- int i;
137
+ const MemOpIdx oi = make_memop_idx(MO_BE | MO_64 | MO_UNALN, mmu_idx);
138
139
- for (i = 0; i < 8; i++, addr += 8) {
139
+ for (int i = 0; i < 8; i++, addr += 8) {
140
addr = wrap_address(env, addr);
141
- cpu_stq_be_data_ra(env, addr, a[i], ra);
141
+ cpu_stq_mmu(env, addr, a[i], oi, ra);
142
}
143
}
144
145
static void sha512_read_block(CPUS390XState *env, const int mmu_idx,
146
uint64_t addr, uint64_t a[16], uintptr_t ra)
147
{
148
- int i;
148
+ const MemOpIdx oi = make_memop_idx(MO_BE | MO_64 | MO_UNALN, mmu_idx);
149
150
- for (i = 0; i < 16; i++, addr += 8) {
150
+ for (int i = 0; i < 16; i++, addr += 8) {
151
addr = wrap_address(env, addr);
152
- a[i] = cpu_ldq_be_data_ra(env, addr, ra);
152
+ a[i] = cpu_ldq_mmu(env, addr, oi, ra);
153
}
154
}
155
156
static void sha512_read_mbl_be64(CPUS390XState *env, const int mmu_idx,
157
uint64_t addr, uint8_t a[16], uintptr_t ra)
158
{
159
- int i;
159
+ const MemOpIdx oi = make_memop_idx(MO_8, mmu_idx);
160
161
- for (i = 0; i < 16; i++, addr += 1) {
161
+ for (int i = 0; i < 16; i++, addr += 1) {
162
addr = wrap_address(env, addr);
163
- a[i] = cpu_ldub_data_ra(env, addr, ra);
163
+ a[i] = cpu_ldb_mmu(env, addr, oi, ra);
164
}
165
}
166
@@ -200,13 +200,14 @@ static int cpacf_sha512(CPUS390XState *env, const int mmu_idx, uintptr_t ra,
200
201
/* KLMD: Process partial/empty block last. */
202
if (type == S390_FEAT_TYPE_KLMD && len < 128) {
203
+ const MemOpIdx oi = make_memop_idx(MO_8, mmu_idx);
204
uint8_t x[128];
205
206
/* Read the remainder of the message byte-per-byte. */
207
for (i = 0; i < len; i++) {
208
uint64_t addr = wrap_address(env, *message_reg + processed + i);
209
209
- x[i] = cpu_ldub_data_ra(env, addr, ra);
210
+ x[i] = cpu_ldb_mmu(env, addr, oi, ra);
211
}
212
/* Pad the remainder with zero and set the top bit. */
213
memset(x + len, 0, 128 - len);
@@ -248,6 +249,7 @@ static int cpacf_sha512(CPUS390XState *env, const int mmu_idx, uintptr_t ra,
249
static void fill_buf_random(CPUS390XState *env, const int mmu_idx, uintptr_t ra,
250
uint64_t *buf_reg, uint64_t *len_reg)
251
{
252
+ const MemOpIdx oi = make_memop_idx(MO_8, mmu_idx);
253
uint8_t tmp[256];
254
uint64_t len = *len_reg;
255
int buf_reg_len = 64;
@@ -262,7 +264,7 @@ static void fill_buf_random(CPUS390XState *env, const int mmu_idx, uintptr_t ra,
264
265
qemu_guest_getrandom_nofail(tmp, block);
266
for (size_t i = 0; i < block; ++i) {
265
- cpu_stb_data_ra(env, wrap_address(env, *buf_reg), tmp[i], ra);
267
+ cpu_stb_mmu(env, wrap_address(env, *buf_reg), tmp[i], oi, ra);
268
*buf_reg = deposit64(*buf_reg, 0, buf_reg_len, *buf_reg + 1);
269
--*len_reg;
270
}
@@ -279,7 +281,7 @@ uint32_t HELPER(msa)(CPUS390XState *env, uint32_t r1, uint32_t r2, uint32_t r3,
281
const uint8_t fc = env->regs[0] & 0x7fULL;
282
uint8_t subfunc[16] = { 0 };
283
uint64_t param_addr;
282
- int i;
284
+ MemOpIdx oi;
285
286
switch (type) {
287
case S390_FEAT_TYPE_KMAC:
@@ -300,9 +302,10 @@ uint32_t HELPER(msa)(CPUS390XState *env, uint32_t r1, uint32_t r2, uint32_t r3,
302
303
switch (fc) {
304
case 0: /* query subfunction */
303
- for (i = 0; i < 16; i++) {
305
+ oi = make_memop_idx(MO_8, mmu_idx);
306
+ for (int i = 0; i < 16; i++) {
307
param_addr = wrap_address(env, env->regs[1] + i);
305
- cpu_stb_data_ra(env, param_addr, subfunc[i], ra);
308
+ cpu_stb_mmu(env, param_addr, subfunc[i], oi, ra);
309
}
310
break;
311
case 3: /* CPACF_*_SHA_512 */
target/s390x/tcg/meson.build
+1
-1
@@ -1,11 +1,11 @@
1
s390x_ss.add(when: 'CONFIG_TCG', if_true: files(
2
- 'crypto_helper.c',
2
'int_helper.c',
3
'mem_helper.c',
4
'misc_helper.c',
5
))
6
s390x_common_ss.add(when: 'CONFIG_TCG', if_true: files(
7
'cc_helper.c',
8
+ 'crypto_helper.c',
9
'excp_helper.c',
10
'fpu_helper.c',
11
'translate.c',