trace/mem: Pass MemOpIdx to trace_mem_get_info

We (will) often have the complete MemOpIdx handy, so use that.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson
2021-07-25 12:44:12 -10:00
parent abe2e23eb7
commit b0702c91c6
5 changed files with 49 additions and 51 deletions
+10 -22
View File
@@ -10,7 +10,7 @@
#ifndef TRACE__MEM_H
#define TRACE__MEM_H
#include "tcg/tcg.h"
#include "exec/memopidx.h"
#define TRACE_MEM_SZ_SHIFT_MASK 0xf /* size shift mask */
#define TRACE_MEM_SE (1ULL << 4) /* sign extended (y/n) */
@@ -19,45 +19,33 @@
#define TRACE_MEM_MMU_SHIFT 8 /* mmu idx */
/**
* trace_mem_build_info:
* trace_mem_get_info:
*
* Return a value for the 'info' argument in guest memory access traces.
*/
static inline uint16_t trace_mem_build_info(int size_shift, bool sign_extend,
MemOp endianness, bool store,
unsigned int mmu_idx)
static inline uint16_t trace_mem_get_info(MemOpIdx oi, bool store)
{
MemOp op = get_memop(oi);
uint32_t size_shift = op & MO_SIZE;
bool sign_extend = op & MO_SIGN;
bool big_endian = (op & MO_BSWAP) == MO_BE;
uint16_t res;
res = size_shift & TRACE_MEM_SZ_SHIFT_MASK;
if (sign_extend) {
res |= TRACE_MEM_SE;
}
if (endianness == MO_BE) {
if (big_endian) {
res |= TRACE_MEM_BE;
}
if (store) {
res |= TRACE_MEM_ST;
}
#ifdef CONFIG_SOFTMMU
res |= mmu_idx << TRACE_MEM_MMU_SHIFT;
res |= get_mmuidx(oi) << TRACE_MEM_MMU_SHIFT;
#endif
return res;
}
/**
* trace_mem_get_info:
*
* Return a value for the 'info' argument in guest memory access traces.
*/
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);
}
#endif /* TRACE__MEM_H */