aboutsummaryrefslogtreecommitdiff
path: root/trace/mem-internal.h
blob: 0a32aa22ca03d5559ecb8992127175074fb3d0d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * Helper functions for guest memory tracing
 *
 * Copyright (C) 2016 LluĂ­s Vilanova <vilanova@ac.upc.edu>
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 * See the COPYING file in the top-level directory.
 */

#ifndef TRACE__MEM_INTERNAL_H
#define TRACE__MEM_INTERNAL_H

#define TRACE_MEM_SZ_SHIFT_MASK 0xf /* size shift mask */
#define TRACE_MEM_SE (1ULL << 4)    /* sign extended (y/n) */
#define TRACE_MEM_BE (1ULL << 5)    /* big endian (y/n) */
#define TRACE_MEM_ST (1ULL << 6)    /* store (y/n) */
#define TRACE_MEM_MMU_SHIFT 8       /* mmu idx */

static inline uint16_t trace_mem_build_info(
    int size_shift, bool sign_extend, MemOp endianness,
    bool store, unsigned int mmu_idx)
{
    uint16_t res;

    res = size_shift & TRACE_MEM_SZ_SHIFT_MASK;
    if (sign_extend) {
        res |= TRACE_MEM_SE;
    }
    if (endianness == MO_BE) {
        res |= TRACE_MEM_BE;
    }
    if (store) {
        res |= TRACE_MEM_ST;
    }
#ifdef CONFIG_SOFTMMU
    res |= mmu_idx << TRACE_MEM_MMU_SHIFT;
#endif
    return res;
}

static inline uint16_t trace_mem_get_info(MemOp op,
                                          unsigned int mmu_idx,
                                          bool store)
{
    return trace_mem_build_info(op & MO_SIZE, !!(op & MO_SIGN),
                                op & MO_BSWAP, store,
                                mmu_idx);
}

/* Used by the atomic helpers */
static inline
uint16_t trace_mem_build_info_no_se_be(int size_shift, bool store,
                                       TCGMemOpIdx oi)
{
    return trace_mem_build_info(size_shift, false, MO_BE, store,
                                get_mmuidx(oi));
}

static inline
uint16_t trace_mem_build_info_no_se_le(int size_shift, bool store,
                                       TCGMemOpIdx oi)
{
    return trace_mem_build_info(size_shift, false, MO_LE, store,
                                get_mmuidx(oi));
}

#endif /* TRACE__MEM_INTERNAL_H */