Files
qemu-reims-vgpu/linux-user/riscv/target_cpu.h
T
wangyang 5089493e45 linux-user/riscv: invalidate reservations after stores
In linux-user parallel execution, AMO and ordinary integer stores do not
invalidate load reservations held by another hart. A store that preserves
the numeric value can therefore leave the reservation intact and allow a
later SC to succeed.

Use the existing EXCP_ATOMIC path to re-execute LR, SC, AMO, and ordinary
integer store instructions in a serial context. The completed store and
reservation invalidation then cannot be interleaved with another guest
hart. Track the LR access size and invalidate every other-hart reservation
whose byte range overlaps the completed store. A successful SC uses the
same invalidation helper.

Clear the reservation when cloning a new linux-user RISC-V hart so that a
child cannot inherit the parent's reservation state.

The change is limited to linux-user TCG and the base scalar integer/
A-extension translator paths.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4149

Signed-off-by: wangyang <wangyang25@otcaix.iscas.ac.cn>
Signed-off-by: Helge Deller <deller@gmx.de>
2026-09-18 22:18:32 +02:00

30 lines
618 B
C

#ifndef RISCV_TARGET_CPU_H
#define RISCV_TARGET_CPU_H
static inline void cpu_clone_regs_child(CPURISCVState *env, target_ulong newsp,
unsigned flags)
{
if (newsp) {
env->gpr[xSP] = newsp;
}
env->gpr[xA0] = 0;
env->load_res = -1;
env->load_res_size = 0;
}
static inline void cpu_clone_regs_parent(CPURISCVState *env, unsigned flags)
{
}
static inline void cpu_set_tls(CPURISCVState *env, target_ulong newtls)
{
env->gpr[xTP] = newtls;
}
static inline abi_ulong get_sp_from_cpustate(CPURISCVState *state)
{
return state->gpr[xSP];
}
#endif