target/arm: Correctly bound length in sve_zcr_get_valid_len
[qemu.git] / trace / mem.h
blob2f27e7bdf0d33f04501a4a66b9fce639b6317c25
1 /*
2 * Helper functions for guest memory tracing
4 * Copyright (C) 2016 LluĂ­s Vilanova <vilanova@ac.upc.edu>
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */
10 #ifndef TRACE__MEM_H
11 #define TRACE__MEM_H
13 #include "tcg/tcg.h"
15 #define TRACE_MEM_SZ_SHIFT_MASK 0xf /* size shift mask */
16 #define TRACE_MEM_SE (1ULL << 4) /* sign extended (y/n) */
17 #define TRACE_MEM_BE (1ULL << 5) /* big endian (y/n) */
18 #define TRACE_MEM_ST (1ULL << 6) /* store (y/n) */
19 #define TRACE_MEM_MMU_SHIFT 8 /* mmu idx */
21 /**
22 * trace_mem_build_info:
24 * Return a value for the 'info' argument in guest memory access traces.
26 static inline uint16_t trace_mem_build_info(int size_shift, bool sign_extend,
27 MemOp endianness, bool store,
28 unsigned int mmu_idx)
30 uint16_t res;
32 res = size_shift & TRACE_MEM_SZ_SHIFT_MASK;
33 if (sign_extend) {
34 res |= TRACE_MEM_SE;
36 if (endianness == MO_BE) {
37 res |= TRACE_MEM_BE;
39 if (store) {
40 res |= TRACE_MEM_ST;
42 #ifdef CONFIG_SOFTMMU
43 res |= mmu_idx << TRACE_MEM_MMU_SHIFT;
44 #endif
45 return res;
49 /**
50 * trace_mem_get_info:
52 * Return a value for the 'info' argument in guest memory access traces.
54 static inline uint16_t trace_mem_get_info(MemOp op,
55 unsigned int mmu_idx,
56 bool store)
58 return trace_mem_build_info(op & MO_SIZE, !!(op & MO_SIGN),
59 op & MO_BSWAP, store,
60 mmu_idx);
63 #endif /* TRACE__MEM_H */