[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/5] trace: simplify trace_mem functions
From: |
Emilio G. Cota |
Subject: |
[Qemu-devel] [PATCH 2/5] trace: simplify trace_mem functions |
Date: |
Tue, 22 May 2018 18:26:49 -0400 |
Add some defines for the mem_info bits, simplify
trace_mem_build_info, and also simplify trace_mem_get_info
by making it a wrapper around trace_mem_build_info.
This paves the way for increasing size_shift by one bit.
Signed-off-by: Emilio G. Cota <address@hidden>
---
trace/mem-internal.h | 40 ++++++++++++++++++----------------------
trace/mem.h | 2 +-
2 files changed, 19 insertions(+), 23 deletions(-)
diff --git a/trace/mem-internal.h b/trace/mem-internal.h
index ddda934..b684e27 100644
--- a/trace/mem-internal.h
+++ b/trace/mem-internal.h
@@ -10,37 +10,33 @@
#ifndef TRACE__MEM_INTERNAL_H
#define TRACE__MEM_INTERNAL_H
-static inline uint8_t trace_mem_get_info(TCGMemOp op, bool store)
+#define TRACE_MEM_SZ_SHIFT_MASK 0x3 /* size shift mask */
+#define TRACE_MEM_SE (1ULL << 2) /* sign extended (y/n) */
+#define TRACE_MEM_BE (1ULL << 3) /* big endian (y/n) */
+#define TRACE_MEM_ST (1ULL << 4) /* store (y/n) */
+
+static inline uint8_t trace_mem_build_info(
+ int size_shift, bool sign_extend, TCGMemOp endianness, bool store)
{
- uint8_t res = op;
- bool be = (op & MO_BSWAP) == MO_BE;
+ uint8_t res;
- /* remove untraced fields */
- res &= (1ULL << 4) - 1;
- /* make endianness absolute */
- res &= ~MO_BSWAP;
- if (be) {
- res |= 1ULL << 3;
+ res = size_shift & TRACE_MEM_SZ_SHIFT_MASK;
+ if (sign_extend) {
+ res |= TRACE_MEM_SE;
+ }
+ if (endianness == MO_BE) {
+ res |= TRACE_MEM_BE;
}
- /* add fields */
if (store) {
- res |= 1ULL << 4;
+ res |= TRACE_MEM_ST;
}
-
return res;
}
-static inline uint8_t trace_mem_build_info(
- TCGMemOp size, bool sign_extend, TCGMemOp endianness, bool store)
+static inline uint8_t trace_mem_get_info(TCGMemOp op, bool store)
{
- uint8_t res = 0;
- res |= size;
- res |= (sign_extend << 2);
- if (endianness == MO_BE) {
- res |= (1ULL << 3);
- }
- res |= (store << 4);
- return res;
+ return trace_mem_build_info(op & MO_SIZE, !!(op & MO_SIGN),
+ op & MO_BSWAP, store);
}
#endif /* TRACE__MEM_INTERNAL_H */
diff --git a/trace/mem.h b/trace/mem.h
index 9c88bcb..2b58196 100644
--- a/trace/mem.h
+++ b/trace/mem.h
@@ -25,7 +25,7 @@ static uint8_t trace_mem_get_info(TCGMemOp op, bool store);
*
* Return a value for the 'info' argument in guest memory access traces.
*/
-static uint8_t trace_mem_build_info(TCGMemOp size, bool sign_extend,
+static uint8_t trace_mem_build_info(int size_shift, bool sign_extend,
TCGMemOp endianness, bool store);
--
2.7.4
- [Qemu-devel] [PATCH 0/5] trace-mem fixes, Emilio G. Cota, 2018/05/22
- [Qemu-devel] [PATCH 1/5] trace: fix misreporting of TCG access sizes for user-space, Emilio G. Cota, 2018/05/22
- [Qemu-devel] [PATCH 2/5] trace: simplify trace_mem functions,
Emilio G. Cota <=
- [Qemu-devel] [PATCH 3/5] trace: expand mem_info:size_shift to 3 bits, Emilio G. Cota, 2018/05/22
- [Qemu-devel] [PATCH 5/5] trace: enable tracing of TCG atomics, Emilio G. Cota, 2018/05/22
- [Qemu-devel] [PATCH 4/5] trace: add trace_mem_build_info_no_se_be/le, Emilio G. Cota, 2018/05/22
- Re: [Qemu-devel] [PATCH 0/5] trace-mem fixes, Stefan Hajnoczi, 2018/05/25