Skip to content

Commit 10eab96

Browse files
committed
Merge tag 'pull-tcg-20240202-2' of https://gitlab.com/rth7680/qemu into staging
tests/tcg: Fix multiarch/gdbstub/prot-none.py hw/core: Convert cpu_mmu_index to a CPUClass hook tcg/loongarch64: Set vector registers call clobbered target/sparc: floating-point cleanup linux-user/aarch64: Add padding before __kernel_rt_sigreturn # -----BEGIN PGP SIGNATURE----- # # iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmW95WkdHHJpY2hhcmQu # aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV/p+Qf/eVmh5q0pZqcur7ft # 8FO0wlIz55OfhaA9MIpH7LEIHRKY37Ybebw2K6SPnx4FmPhLkaj4KXPPjT2nzdXw # J2nQM+TOyxOd18GG8P80qFQ1a72dj8VSIRVAl9T46KuPXS5B7luArImfBlUk/GwV # Qr/XkOPwVTp05E/ccMJ8PMlcVZw9osHVLqsaFVbsUv/FylTmstzA9c5Gw7/FTfkG # T2rk+7go+F4IXs/9uQuuFMOpQOZngXE621hnro+qle7j9oarEUVJloAgVn06o59O # fUjuoKO0aMCr2iQqNJTH7Dnqp5OIzzxUoXiNTOj0EimwWfAcUKthoFO2LGcy1/ew # wWNR/Q== # =e3J3 # -----END PGP SIGNATURE----- # gpg: Signature made Sat 03 Feb 2024 07:04:09 GMT # gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F # gpg: issuer "[email protected]" # gpg: Good signature from "Richard Henderson <[email protected]>" [full] # Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A 05C0 64DF 38E8 AF7E 215F * tag 'pull-tcg-20240202-2' of https://gitlab.com/rth7680/qemu: (58 commits) linux-user/aarch64: Add padding before __kernel_rt_sigreturn target/sparc: Remove FSR_FTT_NMASK, FSR_FTT_CEXC_NMASK target/sparc: Split fcc out of env->fsr target/sparc: Remove cpu_fsr target/sparc: Split cexc and ftt from env->fsr target/sparc: Merge check_ieee_exceptions with FPop helpers target/sparc: Clear cexc and ftt in do_check_ieee_exceptions target/sparc: Split ver from env->fsr target/sparc: Introduce cpu_get_fsr, cpu_put_fsr target/sparc: Remove qt0, qt1 temporaries target/sparc: Use i128 for Fdmulq target/sparc: Use i128 for FdTOq, FxTOq target/sparc: Use i128 for FsTOq, FiTOq target/sparc: Use i128 for FCMPq, FCMPEq target/sparc: Use i128 for FqTOd, FqTOx target/sparc: Use i128 for FqTOs, FqTOi target/sparc: Use i128 for FADDq, FSUBq, FMULq, FDIVq target/sparc: Use i128 for FSQRTq target/sparc: Inline FNEG, FABS target/sparc: Introduce gen_{load,store}_fpr_Q ... Signed-off-by: Peter Maydell <[email protected]>
2 parents 4f2fdb1 + 6400be0 commit 10eab96

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1048
-1175
lines changed

accel/tcg/cputlb.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,7 @@ tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, vaddr addr,
16011601
void *p;
16021602

16031603
(void)probe_access_internal(env_cpu(env), addr, 1, MMU_INST_FETCH,
1604-
cpu_mmu_index(env, true), false,
1604+
cpu_mmu_index(env_cpu(env), true), false,
16051605
&p, &full, 0, false);
16061606
if (p == NULL) {
16071607
return -1;
@@ -2959,26 +2959,30 @@ static void do_st16_mmu(CPUState *cpu, vaddr addr, Int128 val,
29592959

29602960
uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr addr)
29612961
{
2962-
MemOpIdx oi = make_memop_idx(MO_UB, cpu_mmu_index(env, true));
2963-
return do_ld1_mmu(env_cpu(env), addr, oi, 0, MMU_INST_FETCH);
2962+
CPUState *cs = env_cpu(env);
2963+
MemOpIdx oi = make_memop_idx(MO_UB, cpu_mmu_index(cs, true));
2964+
return do_ld1_mmu(cs, addr, oi, 0, MMU_INST_FETCH);
29642965
}
29652966

29662967
uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr)
29672968
{
2968-
MemOpIdx oi = make_memop_idx(MO_TEUW, cpu_mmu_index(env, true));
2969-
return do_ld2_mmu(env_cpu(env), addr, oi, 0, MMU_INST_FETCH);
2969+
CPUState *cs = env_cpu(env);
2970+
MemOpIdx oi = make_memop_idx(MO_TEUW, cpu_mmu_index(cs, true));
2971+
return do_ld2_mmu(cs, addr, oi, 0, MMU_INST_FETCH);
29702972
}
29712973

29722974
uint32_t cpu_ldl_code(CPUArchState *env, abi_ptr addr)
29732975
{
2974-
MemOpIdx oi = make_memop_idx(MO_TEUL, cpu_mmu_index(env, true));
2975-
return do_ld4_mmu(env_cpu(env), addr, oi, 0, MMU_INST_FETCH);
2976+
CPUState *cs = env_cpu(env);
2977+
MemOpIdx oi = make_memop_idx(MO_TEUL, cpu_mmu_index(cs, true));
2978+
return do_ld4_mmu(cs, addr, oi, 0, MMU_INST_FETCH);
29762979
}
29772980

29782981
uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr addr)
29792982
{
2980-
MemOpIdx oi = make_memop_idx(MO_TEUQ, cpu_mmu_index(env, true));
2981-
return do_ld8_mmu(env_cpu(env), addr, oi, 0, MMU_INST_FETCH);
2983+
CPUState *cs = env_cpu(env);
2984+
MemOpIdx oi = make_memop_idx(MO_TEUQ, cpu_mmu_index(cs, true));
2985+
return do_ld8_mmu(cs, addr, oi, 0, MMU_INST_FETCH);
29822986
}
29832987

29842988
uint8_t cpu_ldb_code_mmu(CPUArchState *env, abi_ptr addr,

accel/tcg/ldst_common.c.inc

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ void cpu_stq_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
354354

355355
uint32_t cpu_ldub_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
356356
{
357-
return cpu_ldub_mmuidx_ra(env, addr, cpu_mmu_index(env, false), ra);
357+
int mmu_index = cpu_mmu_index(env_cpu(env), false);
358+
return cpu_ldub_mmuidx_ra(env, addr, mmu_index, ra);
358359
}
359360

360361
int cpu_ldsb_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
@@ -364,7 +365,8 @@ int cpu_ldsb_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
364365

365366
uint32_t cpu_lduw_be_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
366367
{
367-
return cpu_lduw_be_mmuidx_ra(env, addr, cpu_mmu_index(env, false), ra);
368+
int mmu_index = cpu_mmu_index(env_cpu(env), false);
369+
return cpu_lduw_be_mmuidx_ra(env, addr, mmu_index, ra);
368370
}
369371

370372
int cpu_ldsw_be_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
@@ -374,17 +376,20 @@ int cpu_ldsw_be_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
374376

375377
uint32_t cpu_ldl_be_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
376378
{
377-
return cpu_ldl_be_mmuidx_ra(env, addr, cpu_mmu_index(env, false), ra);
379+
int mmu_index = cpu_mmu_index(env_cpu(env), false);
380+
return cpu_ldl_be_mmuidx_ra(env, addr, mmu_index, ra);
378381
}
379382

380383
uint64_t cpu_ldq_be_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
381384
{
382-
return cpu_ldq_be_mmuidx_ra(env, addr, cpu_mmu_index(env, false), ra);
385+
int mmu_index = cpu_mmu_index(env_cpu(env), false);
386+
return cpu_ldq_be_mmuidx_ra(env, addr, mmu_index, ra);
383387
}
384388

385389
uint32_t cpu_lduw_le_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
386390
{
387-
return cpu_lduw_le_mmuidx_ra(env, addr, cpu_mmu_index(env, false), ra);
391+
int mmu_index = cpu_mmu_index(env_cpu(env), false);
392+
return cpu_lduw_le_mmuidx_ra(env, addr, mmu_index, ra);
388393
}
389394

390395
int cpu_ldsw_le_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
@@ -394,54 +399,63 @@ int cpu_ldsw_le_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
394399

395400
uint32_t cpu_ldl_le_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
396401
{
397-
return cpu_ldl_le_mmuidx_ra(env, addr, cpu_mmu_index(env, false), ra);
402+
int mmu_index = cpu_mmu_index(env_cpu(env), false);
403+
return cpu_ldl_le_mmuidx_ra(env, addr, mmu_index, ra);
398404
}
399405

400406
uint64_t cpu_ldq_le_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
401407
{
402-
return cpu_ldq_le_mmuidx_ra(env, addr, cpu_mmu_index(env, false), ra);
408+
int mmu_index = cpu_mmu_index(env_cpu(env), false);
409+
return cpu_ldq_le_mmuidx_ra(env, addr, mmu_index, ra);
403410
}
404411

405412
void cpu_stb_data_ra(CPUArchState *env, abi_ptr addr,
406413
uint32_t val, uintptr_t ra)
407414
{
408-
cpu_stb_mmuidx_ra(env, addr, val, cpu_mmu_index(env, false), ra);
415+
int mmu_index = cpu_mmu_index(env_cpu(env), false);
416+
cpu_stb_mmuidx_ra(env, addr, val, mmu_index, ra);
409417
}
410418

411419
void cpu_stw_be_data_ra(CPUArchState *env, abi_ptr addr,
412420
uint32_t val, uintptr_t ra)
413421
{
414-
cpu_stw_be_mmuidx_ra(env, addr, val, cpu_mmu_index(env, false), ra);
422+
int mmu_index = cpu_mmu_index(env_cpu(env), false);
423+
cpu_stw_be_mmuidx_ra(env, addr, val, mmu_index, ra);
415424
}
416425

417426
void cpu_stl_be_data_ra(CPUArchState *env, abi_ptr addr,
418427
uint32_t val, uintptr_t ra)
419428
{
420-
cpu_stl_be_mmuidx_ra(env, addr, val, cpu_mmu_index(env, false), ra);
429+
int mmu_index = cpu_mmu_index(env_cpu(env), false);
430+
cpu_stl_be_mmuidx_ra(env, addr, val, mmu_index, ra);
421431
}
422432

423433
void cpu_stq_be_data_ra(CPUArchState *env, abi_ptr addr,
424434
uint64_t val, uintptr_t ra)
425435
{
426-
cpu_stq_be_mmuidx_ra(env, addr, val, cpu_mmu_index(env, false), ra);
436+
int mmu_index = cpu_mmu_index(env_cpu(env), false);
437+
cpu_stq_be_mmuidx_ra(env, addr, val, mmu_index, ra);
427438
}
428439

429440
void cpu_stw_le_data_ra(CPUArchState *env, abi_ptr addr,
430441
uint32_t val, uintptr_t ra)
431442
{
432-
cpu_stw_le_mmuidx_ra(env, addr, val, cpu_mmu_index(env, false), ra);
443+
int mmu_index = cpu_mmu_index(env_cpu(env), false);
444+
cpu_stw_le_mmuidx_ra(env, addr, val, mmu_index, ra);
433445
}
434446

435447
void cpu_stl_le_data_ra(CPUArchState *env, abi_ptr addr,
436448
uint32_t val, uintptr_t ra)
437449
{
438-
cpu_stl_le_mmuidx_ra(env, addr, val, cpu_mmu_index(env, false), ra);
450+
int mmu_index = cpu_mmu_index(env_cpu(env), false);
451+
cpu_stl_le_mmuidx_ra(env, addr, val, mmu_index, ra);
439452
}
440453

441454
void cpu_stq_le_data_ra(CPUArchState *env, abi_ptr addr,
442455
uint64_t val, uintptr_t ra)
443456
{
444-
cpu_stq_le_mmuidx_ra(env, addr, val, cpu_mmu_index(env, false), ra);
457+
int mmu_index = cpu_mmu_index(env_cpu(env), false);
458+
cpu_stq_le_mmuidx_ra(env, addr, val, mmu_index, ra);
445459
}
446460

447461
/*--------------------------*/

include/exec/cpu-all.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ CPUArchState *cpu_copy(CPUArchState *env);
311311
#define TLB_MMIO (1 << (TARGET_PAGE_BITS_MIN - 2))
312312
#define TLB_WATCHPOINT 0
313313

314+
static inline int cpu_mmu_index(CPUState *cs, bool ifetch)
315+
{
316+
return MMU_USER_IDX;
317+
}
314318
#else
315319

316320
/*

include/exec/cpu-common.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "exec/hwaddr.h"
99
#endif
1010
#include "hw/core/cpu.h"
11+
#include "tcg/debug-assert.h"
1112

1213
#define EXCP_INTERRUPT 0x10000 /* async interruption */
1314
#define EXCP_HLT 0x10001 /* hlt instruction reached */
@@ -262,4 +263,24 @@ static inline CPUState *env_cpu(CPUArchState *env)
262263
return (void *)env - sizeof(CPUState);
263264
}
264265

266+
#ifndef CONFIG_USER_ONLY
267+
/**
268+
* cpu_mmu_index:
269+
* @env: The cpu environment
270+
* @ifetch: True for code access, false for data access.
271+
*
272+
* Return the core mmu index for the current translation regime.
273+
* This function is used by generic TCG code paths.
274+
*
275+
* The user-only version of this function is inline in cpu-all.h,
276+
* where it always returns MMU_USER_IDX.
277+
*/
278+
static inline int cpu_mmu_index(CPUState *cs, bool ifetch)
279+
{
280+
int ret = cs->cc->mmu_index(cs, ifetch);
281+
tcg_debug_assert(ret >= 0 && ret < NB_MMU_MODES);
282+
return ret;
283+
}
284+
#endif /* !CONFIG_USER_ONLY */
285+
265286
#endif /* CPU_COMMON_H */

include/hw/core/cpu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ struct SysemuCPUOps;
103103
* @parse_features: Callback to parse command line arguments.
104104
* @reset_dump_flags: #CPUDumpFlags to use for reset logging.
105105
* @has_work: Callback for checking if there is work to do.
106+
* @mmu_index: Callback for choosing softmmu mmu index;
107+
* may be used internally by memory_rw_debug without TCG.
106108
* @memory_rw_debug: Callback for GDB memory access.
107109
* @dump_state: Callback for dumping state.
108110
* @query_cpu_fast:
@@ -150,6 +152,7 @@ struct CPUClass {
150152
void (*parse_features)(const char *typename, char *str, Error **errp);
151153

152154
bool (*has_work)(CPUState *cpu);
155+
int (*mmu_index)(CPUState *cpu, bool ifetch);
153156
int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
154157
uint8_t *buf, int len, bool is_write);
155158
void (*dump_state)(CPUState *cpu, FILE *, int flags);

linux-user/aarch64/vdso-be.so

8 Bytes
Binary file not shown.

linux-user/aarch64/vdso-le.so

8 Bytes
Binary file not shown.

linux-user/aarch64/vdso.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ vdso_syscall __kernel_clock_getres, __NR_clock_getres
6363
* For now, elide the unwind info for __kernel_rt_sigreturn and rely on
6464
* the libgcc fallback routine as we have always done. This requires
6565
* that the code sequence used be exact.
66+
*
67+
* Add a nop as a spacer to ensure that unwind does not pick up the
68+
* unwind info from the preceding syscall.
6669
*/
70+
nop
6771
__kernel_rt_sigreturn:
6872
/* No BTI C insn here -- we arrive via RET. */
6973
mov x8, #__NR_rt_sigreturn

linux-user/sparc/cpu_loop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ void cpu_loop (CPUSPARCState *env)
293293
case TT_FP_EXCP:
294294
{
295295
int code = TARGET_FPE_FLTUNK;
296-
target_ulong fsr = env->fsr;
296+
target_ulong fsr = cpu_get_fsr(env);
297297

298298
if ((fsr & FSR_FTT_MASK) == FSR_FTT_IEEE_EXCP) {
299299
if (fsr & FSR_NVC) {

linux-user/sparc/signal.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,20 +199,21 @@ static void save_fpu(struct target_siginfo_fpu *fpu, CPUSPARCState *env)
199199
for (i = 0; i < 32; ++i) {
200200
__put_user(env->fpr[i].ll, &fpu->si_double_regs[i]);
201201
}
202-
__put_user(env->fsr, &fpu->si_fsr);
202+
__put_user(cpu_get_fsr(env), &fpu->si_fsr);
203203
__put_user(env->gsr, &fpu->si_gsr);
204204
__put_user(env->fprs, &fpu->si_fprs);
205205
#else
206206
for (i = 0; i < 16; ++i) {
207207
__put_user(env->fpr[i].ll, &fpu->si_double_regs[i]);
208208
}
209-
__put_user(env->fsr, &fpu->si_fsr);
209+
__put_user(cpu_get_fsr(env), &fpu->si_fsr);
210210
__put_user(0, &fpu->si_fpqdepth);
211211
#endif
212212
}
213213

214214
static void restore_fpu(struct target_siginfo_fpu *fpu, CPUSPARCState *env)
215215
{
216+
target_ulong fsr;
216217
int i;
217218

218219
#ifdef TARGET_SPARC64
@@ -230,15 +231,16 @@ static void restore_fpu(struct target_siginfo_fpu *fpu, CPUSPARCState *env)
230231
__get_user(env->fpr[i].ll, &fpu->si_double_regs[i]);
231232
}
232233
}
233-
__get_user(env->fsr, &fpu->si_fsr);
234234
__get_user(env->gsr, &fpu->si_gsr);
235235
env->fprs |= fprs;
236236
#else
237237
for (i = 0; i < 16; ++i) {
238238
__get_user(env->fpr[i].ll, &fpu->si_double_regs[i]);
239239
}
240-
__get_user(env->fsr, &fpu->si_fsr);
241240
#endif
241+
242+
__get_user(fsr, &fpu->si_fsr);
243+
cpu_put_fsr(env, fsr);
242244
}
243245

244246
#ifdef TARGET_ARCH_HAS_SETUP_FRAME
@@ -662,6 +664,7 @@ void sparc64_set_context(CPUSPARCState *env)
662664
__get_user(fenab, &(fpup->mcfpu_enab));
663665
if (fenab) {
664666
abi_ulong fprs;
667+
abi_ulong fsr;
665668

666669
/*
667670
* We use the FPRS from the guest only in deciding whether
@@ -690,7 +693,8 @@ void sparc64_set_context(CPUSPARCState *env)
690693
__get_user(env->fpr[i].ll, &(fpup->mcfpu_fregs.dregs[i]));
691694
}
692695
}
693-
__get_user(env->fsr, &(fpup->mcfpu_fsr));
696+
__get_user(fsr, &(fpup->mcfpu_fsr));
697+
cpu_put_fsr(env, fsr);
694698
__get_user(env->gsr, &(fpup->mcfpu_gsr));
695699
}
696700
unlock_user_struct(ucp, ucp_addr, 0);

0 commit comments

Comments
 (0)