[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 01/15] hw/nvram/fw_cfg: Add trace events
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-ppc] [PULL 01/15] hw/nvram/fw_cfg: Add trace events |
Date: |
Thu, 23 May 2019 14:43:06 +0200 |
Add trace events to dump the key content.
Reviewed-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Laszlo Ersek <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
hw/nvram/fw_cfg.c | 63 ++++++++++++++++++++++++++++++++++++++++++-
hw/nvram/trace-events | 7 ++++-
2 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 5c3a46ce6f..d374a970fe 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -60,6 +60,62 @@ struct FWCfgEntry {
FWCfgWriteCallback write_cb;
};
+/**
+ * key_name:
+ *
+ * @key: The uint16 selector key.
+ *
+ * Returns: The stringified name if the selector refers to a well-known
+ * numerically defined item, or NULL on key lookup failure.
+ */
+static const char *key_name(uint16_t key)
+{
+ static const char *fw_cfg_wellknown_keys[FW_CFG_FILE_FIRST] = {
+ [FW_CFG_SIGNATURE] = "signature",
+ [FW_CFG_ID] = "id",
+ [FW_CFG_UUID] = "uuid",
+ [FW_CFG_RAM_SIZE] = "ram_size",
+ [FW_CFG_NOGRAPHIC] = "nographic",
+ [FW_CFG_NB_CPUS] = "nb_cpus",
+ [FW_CFG_MACHINE_ID] = "machine_id",
+ [FW_CFG_KERNEL_ADDR] = "kernel_addr",
+ [FW_CFG_KERNEL_SIZE] = "kernel_size",
+ [FW_CFG_KERNEL_CMDLINE] = "kernel_cmdline",
+ [FW_CFG_INITRD_ADDR] = "initrd_addr",
+ [FW_CFG_INITRD_SIZE] = "initdr_size",
+ [FW_CFG_BOOT_DEVICE] = "boot_device",
+ [FW_CFG_NUMA] = "numa",
+ [FW_CFG_BOOT_MENU] = "boot_menu",
+ [FW_CFG_MAX_CPUS] = "max_cpus",
+ [FW_CFG_KERNEL_ENTRY] = "kernel_entry",
+ [FW_CFG_KERNEL_DATA] = "kernel_data",
+ [FW_CFG_INITRD_DATA] = "initrd_data",
+ [FW_CFG_CMDLINE_ADDR] = "cmdline_addr",
+ [FW_CFG_CMDLINE_SIZE] = "cmdline_size",
+ [FW_CFG_CMDLINE_DATA] = "cmdline_data",
+ [FW_CFG_SETUP_ADDR] = "setup_addr",
+ [FW_CFG_SETUP_SIZE] = "setup_size",
+ [FW_CFG_SETUP_DATA] = "setup_data",
+ [FW_CFG_FILE_DIR] = "file_dir",
+ };
+
+ if (key & FW_CFG_ARCH_LOCAL) {
+ return NULL;
+ }
+ if (key < FW_CFG_FILE_FIRST) {
+ return fw_cfg_wellknown_keys[key];
+ }
+
+ return NULL;
+}
+
+static inline const char *trace_key_name(uint16_t key)
+{
+ const char *name = key_name(key);
+
+ return name ? name : "unknown";
+}
+
#define JPG_FILE 0
#define BMP_FILE 1
@@ -233,7 +289,7 @@ static int fw_cfg_select(FWCfgState *s, uint16_t key)
}
}
- trace_fw_cfg_select(s, key, ret);
+ trace_fw_cfg_select(s, key, trace_key_name(key), ret);
return ret;
}
@@ -616,6 +672,7 @@ static void *fw_cfg_modify_bytes_read(FWCfgState *s,
uint16_t key,
void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len)
{
+ trace_fw_cfg_add_bytes(key, trace_key_name(key), len);
fw_cfg_add_bytes_callback(s, key, NULL, NULL, NULL, data, len, true);
}
@@ -623,6 +680,7 @@ void fw_cfg_add_string(FWCfgState *s, uint16_t key, const
char *value)
{
size_t sz = strlen(value) + 1;
+ trace_fw_cfg_add_string(key, trace_key_name(key), value);
fw_cfg_add_bytes(s, key, g_memdup(value, sz), sz);
}
@@ -632,6 +690,7 @@ void fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t
value)
copy = g_malloc(sizeof(value));
*copy = cpu_to_le16(value);
+ trace_fw_cfg_add_i16(key, trace_key_name(key), value);
fw_cfg_add_bytes(s, key, copy, sizeof(value));
}
@@ -651,6 +710,7 @@ void fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t
value)
copy = g_malloc(sizeof(value));
*copy = cpu_to_le32(value);
+ trace_fw_cfg_add_i32(key, trace_key_name(key), value);
fw_cfg_add_bytes(s, key, copy, sizeof(value));
}
@@ -660,6 +720,7 @@ void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t
value)
copy = g_malloc(sizeof(value));
*copy = cpu_to_le64(value);
+ trace_fw_cfg_add_i64(key, trace_key_name(key), value);
fw_cfg_add_bytes(s, key, copy, sizeof(value));
}
diff --git a/hw/nvram/trace-events b/hw/nvram/trace-events
index e191991e2a..0dea9260ce 100644
--- a/hw/nvram/trace-events
+++ b/hw/nvram/trace-events
@@ -5,6 +5,11 @@ nvram_read(uint32_t addr, uint32_t ret) "read addr %d: 0x%02x"
nvram_write(uint32_t addr, uint32_t old, uint32_t val) "write addr %d: 0x%02x
-> 0x%02x"
# fw_cfg.c
-fw_cfg_select(void *s, uint16_t key, int ret) "%p key %d = %d"
+fw_cfg_select(void *s, uint16_t key_value, const char *key_name, int ret) "%p
key 0x%04" PRIx16 " '%s', ret: %d"
fw_cfg_read(void *s, uint64_t ret) "%p = 0x%"PRIx64
+fw_cfg_add_bytes(uint16_t key_value, const char *key_name, size_t len) "key
0x%04" PRIx16 " '%s', %zu bytes"
fw_cfg_add_file(void *s, int index, char *name, size_t len) "%p #%d: %s (%zd
bytes)"
+fw_cfg_add_string(uint16_t key_value, const char *key_name, const char *value)
"key 0x%04" PRIx16 " '%s', value '%s'"
+fw_cfg_add_i16(uint16_t key_value, const char *key_name, uint16_t value) "key
0x%04" PRIx16 " '%s', value 0x%" PRIx16
+fw_cfg_add_i32(uint16_t key_value, const char *key_name, uint32_t value) "key
0x%04" PRIx16 " '%s', value 0x%" PRIx32
+fw_cfg_add_i64(uint16_t key_value, const char *key_name, uint64_t value) "key
0x%04" PRIx16 " '%s', value 0x%" PRIx64
--
2.20.1
- [Qemu-ppc] [PULL 00/15] Fw cfg 20190523 patches, Philippe Mathieu-Daudé, 2019/05/23
- [Qemu-ppc] [PULL 15/15] tests: fw_cfg: add 'splash-time' test case, Philippe Mathieu-Daudé, 2019/05/23
- [Qemu-ppc] [PULL 10/15] tests/fw_cfg: Free QFWCFG object after qtest has run, Philippe Mathieu-Daudé, 2019/05/23
- [Qemu-ppc] [PULL 14/15] tests: fw_cfg: add 'reboot-timeout' test case, Philippe Mathieu-Daudé, 2019/05/23
- [Qemu-ppc] [PULL 13/15] hw/nvram/fw_cfg: Store 'reboot-timeout' as little endian, Philippe Mathieu-Daudé, 2019/05/23
- [Qemu-ppc] [PULL 12/15] tests: fw_cfg: add a function to get the fw_cfg file, Philippe Mathieu-Daudé, 2019/05/23
- [Qemu-ppc] [PULL 11/15] tests: refactor fw_cfg_test, Philippe Mathieu-Daudé, 2019/05/23
- [Qemu-ppc] [PULL 07/15] hw/sparc64: Implement fw_cfg_arch_key_name(), Philippe Mathieu-Daudé, 2019/05/23
- [Qemu-ppc] [PULL 09/15] tests/libqos: Add pc_fw_cfg_uninit() and use it, Philippe Mathieu-Daudé, 2019/05/23
- [Qemu-ppc] [PULL 08/15] tests/libqos: Add io_fw_cfg_uninit() and mm_fw_cfg_uninit(), Philippe Mathieu-Daudé, 2019/05/23
- [Qemu-ppc] [PULL 01/15] hw/nvram/fw_cfg: Add trace events,
Philippe Mathieu-Daudé <=
- [Qemu-ppc] [PULL 02/15] hw/nvram/fw_cfg: Add fw_cfg_arch_key_name(), Philippe Mathieu-Daudé, 2019/05/23
- [Qemu-ppc] [PULL 06/15] hw/sparc: Implement fw_cfg_arch_key_name(), Philippe Mathieu-Daudé, 2019/05/23
- [Qemu-ppc] [PULL 04/15] hw/i386: Implement fw_cfg_arch_key_name(), Philippe Mathieu-Daudé, 2019/05/23
- [Qemu-ppc] [PULL 05/15] hw/ppc: Implement fw_cfg_arch_key_name(), Philippe Mathieu-Daudé, 2019/05/23
- [Qemu-ppc] [PULL 03/15] hw/i386: Extract fw_cfg definitions to local "fw_cfg.h", Philippe Mathieu-Daudé, 2019/05/23
- Re: [Qemu-ppc] [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches, Peter Maydell, 2019/05/23