]> git.proxmox.com Git - mirror_qemu.git/blame - trace/mem.h
Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into staging
[mirror_qemu.git] / trace / mem.h
CommitLineData
dcdaadb6
LV
1/*
2 * Helper functions for guest memory tracing
3 *
4 * Copyright (C) 2016 Lluís Vilanova <vilanova@ac.upc.edu>
5 *
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 */
9
10#ifndef TRACE__MEM_H
11#define TRACE__MEM_H
12
13#include "tcg/tcg.h"
14
785ea711
RH
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 */
dcdaadb6
LV
20
21/**
785ea711 22 * trace_mem_build_info:
dcdaadb6
LV
23 *
24 * Return a value for the 'info' argument in guest memory access traces.
25 */
785ea711
RH
26static inline uint16_t trace_mem_build_info(int size_shift, bool sign_extend,
27 MemOp endianness, bool store,
28 unsigned int mmu_idx)
29{
30 uint16_t res;
31
32 res = size_shift & TRACE_MEM_SZ_SHIFT_MASK;
33 if (sign_extend) {
34 res |= TRACE_MEM_SE;
35 }
36 if (endianness == MO_BE) {
37 res |= TRACE_MEM_BE;
38 }
39 if (store) {
40 res |= TRACE_MEM_ST;
41 }
42#ifdef CONFIG_SOFTMMU
43 res |= mmu_idx << TRACE_MEM_MMU_SHIFT;
44#endif
45 return res;
46}
47
dcdaadb6
LV
48
49/**
785ea711 50 * trace_mem_get_info:
dcdaadb6
LV
51 *
52 * Return a value for the 'info' argument in guest memory access traces.
53 */
785ea711
RH
54static inline uint16_t trace_mem_get_info(MemOp op,
55 unsigned int mmu_idx,
56 bool store)
57{
58 return trace_mem_build_info(op & MO_SIZE, !!(op & MO_SIGN),
59 op & MO_BSWAP, store,
60 mmu_idx);
61}
dcdaadb6 62
175de524 63#endif /* TRACE__MEM_H */