xref: /openbmc/qemu/accel/tcg/atomic_common.c.inc (revision 0ed93f4c)
1/*
2 * Common Atomic Helper Functions
3 *
4 * This file should be included before the various instantiations of
5 * the atomic_template.h helpers.
6 *
7 * Copyright (c) 2019 Linaro
8 * Written by Alex Bennée <alex.bennee@linaro.org>
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 *
12 * This work is licensed under the terms of the GNU GPL, version 2 or later.
13 * See the COPYING file in the top-level directory.
14 */
15
16static inline
17void atomic_trace_rmw_pre(CPUArchState *env, target_ulong addr, uint16_t info)
18{
19    CPUState *cpu = env_cpu(env);
20
21    trace_guest_mem_before_exec(cpu, addr, info);
22    trace_guest_mem_before_exec(cpu, addr, info | TRACE_MEM_ST);
23}
24
25static inline void
26atomic_trace_rmw_post(CPUArchState *env, target_ulong addr, uint16_t info)
27{
28    qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, info);
29    qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, info | TRACE_MEM_ST);
30}
31
32static inline
33void atomic_trace_ld_pre(CPUArchState *env, target_ulong addr, uint16_t info)
34{
35    trace_guest_mem_before_exec(env_cpu(env), addr, info);
36}
37
38static inline
39void atomic_trace_ld_post(CPUArchState *env, target_ulong addr, uint16_t info)
40{
41    qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, info);
42}
43
44static inline
45void atomic_trace_st_pre(CPUArchState *env, target_ulong addr, uint16_t info)
46{
47    trace_guest_mem_before_exec(env_cpu(env), addr, info);
48}
49
50static inline
51void atomic_trace_st_post(CPUArchState *env, target_ulong addr, uint16_t info)
52{
53    qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, info);
54}
55