diff mbox series

[4/6] hw/nvram/fw_cfg: Add trace events

Message ID 20181207170400.5129-5-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series fw_cfg: add HMP 'info fw_cfg' and add_file_from_host() | expand

Commit Message

Philippe Mathieu-Daudé Dec. 7, 2018, 5:03 p.m. UTC
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/nvram/fw_cfg.c     | 5 +++++
 hw/nvram/trace-events | 5 +++++
 2 files changed, 10 insertions(+)

Comments

Michael S. Tsirkin Dec. 7, 2018, 5:44 p.m. UTC | #1
On Fri, Dec 07, 2018 at 06:03:58PM +0100, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Well why not.

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  hw/nvram/fw_cfg.c     | 5 +++++
>  hw/nvram/trace-events | 5 +++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index 3cb726ff68..582653f07e 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -627,6 +627,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, len);
>      fw_cfg_add_bytes_callback(s, key, NULL, NULL, NULL, data, len, true);
>  }
>  
> @@ -634,6 +635,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, value);
>      fw_cfg_add_bytes(s, key, g_memdup(value, sz), sz);
>  }
>  
> @@ -643,6 +645,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, value);
>      fw_cfg_add_bytes(s, key, copy, sizeof(value));
>  }
>  
> @@ -662,6 +665,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, value);
>      fw_cfg_add_bytes(s, key, copy, sizeof(value));
>  }
>  
> @@ -671,6 +675,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, value);
>      fw_cfg_add_bytes(s, key, copy, sizeof(value));
>  }
>  
> diff --git a/hw/nvram/trace-events b/hw/nvram/trace-events
> index 6b55ba7a09..0ee0f8d04a 100644
> --- a/hw/nvram/trace-events
> +++ b/hw/nvram/trace-events
> @@ -7,4 +7,9 @@ nvram_write(uint32_t addr, uint32_t old, uint32_t val) "write addr %d: 0x%02x ->
>  # hw/nvram/fw_cfg.c
>  fw_cfg_select(void *s, uint16_t key, int ret) "%p key %d = %d"
>  fw_cfg_read(void *s, uint64_t ret) "%p = 0x%"PRIx64
> +fw_cfg_add_bytes(uint16_t key, size_t len) "key 0x%04" PRIx16 " (%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, const char *value) "key 0x%04" PRIx16 ", value '%s'"
> +fw_cfg_add_i16(uint16_t key, uint32_t value) "key 0x%04" PRIx16 ", value 0x%" PRIx32
> +fw_cfg_add_i32(uint16_t key, uint32_t value) "key 0x%04" PRIx16 ", value 0x%" PRIx32
> +fw_cfg_add_i64(uint16_t key, uint64_t value) "key 0x%04" PRIx16 ", value 0x%" PRIx64
> -- 
> 2.17.2
Laszlo Ersek Dec. 10, 2018, 4:10 p.m. UTC | #2
On 12/07/18 18:03, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  hw/nvram/fw_cfg.c     | 5 +++++
>  hw/nvram/trace-events | 5 +++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index 3cb726ff68..582653f07e 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -627,6 +627,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, len);
>      fw_cfg_add_bytes_callback(s, key, NULL, NULL, NULL, data, len, true);
>  }
>  
> @@ -634,6 +635,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, value);
>      fw_cfg_add_bytes(s, key, g_memdup(value, sz), sz);
>  }
>  
> @@ -643,6 +645,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, value);
>      fw_cfg_add_bytes(s, key, copy, sizeof(value));
>  }
>  
> @@ -662,6 +665,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, value);
>      fw_cfg_add_bytes(s, key, copy, sizeof(value));
>  }
>  
> @@ -671,6 +675,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, value);
>      fw_cfg_add_bytes(s, key, copy, sizeof(value));
>  }
>  
> diff --git a/hw/nvram/trace-events b/hw/nvram/trace-events
> index 6b55ba7a09..0ee0f8d04a 100644
> --- a/hw/nvram/trace-events
> +++ b/hw/nvram/trace-events
> @@ -7,4 +7,9 @@ nvram_write(uint32_t addr, uint32_t old, uint32_t val) "write addr %d: 0x%02x ->
>  # hw/nvram/fw_cfg.c
>  fw_cfg_select(void *s, uint16_t key, int ret) "%p key %d = %d"
>  fw_cfg_read(void *s, uint64_t ret) "%p = 0x%"PRIx64
> +fw_cfg_add_bytes(uint16_t key, size_t len) "key 0x%04" PRIx16 " (%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, const char *value) "key 0x%04" PRIx16 ", value '%s'"
> +fw_cfg_add_i16(uint16_t key, uint32_t value) "key 0x%04" PRIx16 ", value 0x%" PRIx32

For the "value" parameter, you should use "uint16_t" here (and replace
PRIx32 with PRIx16, as well).

(In practice this will make no difference, but for consistency's sake,
we should do this.)

With the update:

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Thanks
Laszlo

> +fw_cfg_add_i32(uint16_t key, uint32_t value) "key 0x%04" PRIx16 ", value 0x%" PRIx32
> +fw_cfg_add_i64(uint16_t key, uint64_t value) "key 0x%04" PRIx16 ", value 0x%" PRIx64
>
Philippe Mathieu-Daudé Dec. 10, 2018, 4:33 p.m. UTC | #3
On 12/10/18 5:10 PM, Laszlo Ersek wrote:
> On 12/07/18 18:03, Philippe Mathieu-Daudé wrote:
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>>  hw/nvram/fw_cfg.c     | 5 +++++
>>  hw/nvram/trace-events | 5 +++++
>>  2 files changed, 10 insertions(+)
>>
>> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
>> index 3cb726ff68..582653f07e 100644
>> --- a/hw/nvram/fw_cfg.c
>> +++ b/hw/nvram/fw_cfg.c
>> @@ -627,6 +627,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, len);
>>      fw_cfg_add_bytes_callback(s, key, NULL, NULL, NULL, data, len, true);
>>  }
>>  
>> @@ -634,6 +635,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, value);
>>      fw_cfg_add_bytes(s, key, g_memdup(value, sz), sz);
>>  }
>>  
>> @@ -643,6 +645,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, value);
>>      fw_cfg_add_bytes(s, key, copy, sizeof(value));
>>  }
>>  
>> @@ -662,6 +665,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, value);
>>      fw_cfg_add_bytes(s, key, copy, sizeof(value));
>>  }
>>  
>> @@ -671,6 +675,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, value);
>>      fw_cfg_add_bytes(s, key, copy, sizeof(value));
>>  }
>>  
>> diff --git a/hw/nvram/trace-events b/hw/nvram/trace-events
>> index 6b55ba7a09..0ee0f8d04a 100644
>> --- a/hw/nvram/trace-events
>> +++ b/hw/nvram/trace-events
>> @@ -7,4 +7,9 @@ nvram_write(uint32_t addr, uint32_t old, uint32_t val) "write addr %d: 0x%02x ->
>>  # hw/nvram/fw_cfg.c
>>  fw_cfg_select(void *s, uint16_t key, int ret) "%p key %d = %d"
>>  fw_cfg_read(void *s, uint64_t ret) "%p = 0x%"PRIx64
>> +fw_cfg_add_bytes(uint16_t key, size_t len) "key 0x%04" PRIx16 " (%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, const char *value) "key 0x%04" PRIx16 ", value '%s'"
>> +fw_cfg_add_i16(uint16_t key, uint32_t value) "key 0x%04" PRIx16 ", value 0x%" PRIx32
> 
> For the "value" parameter, you should use "uint16_t" here (and replace
> PRIx32 with PRIx16, as well).
> 
> (In practice this will make no difference, but for consistency's sake,
> we should do this.)

You are right :)

> 
> With the update:
> 
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
> 
> Thanks
> Laszlo
> 
>> +fw_cfg_add_i32(uint16_t key, uint32_t value) "key 0x%04" PRIx16 ", value 0x%" PRIx32
>> +fw_cfg_add_i64(uint16_t key, uint64_t value) "key 0x%04" PRIx16 ", value 0x%" PRIx64
>>
>
diff mbox series

Patch

diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 3cb726ff68..582653f07e 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -627,6 +627,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, len);
     fw_cfg_add_bytes_callback(s, key, NULL, NULL, NULL, data, len, true);
 }
 
@@ -634,6 +635,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, value);
     fw_cfg_add_bytes(s, key, g_memdup(value, sz), sz);
 }
 
@@ -643,6 +645,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, value);
     fw_cfg_add_bytes(s, key, copy, sizeof(value));
 }
 
@@ -662,6 +665,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, value);
     fw_cfg_add_bytes(s, key, copy, sizeof(value));
 }
 
@@ -671,6 +675,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, value);
     fw_cfg_add_bytes(s, key, copy, sizeof(value));
 }
 
diff --git a/hw/nvram/trace-events b/hw/nvram/trace-events
index 6b55ba7a09..0ee0f8d04a 100644
--- a/hw/nvram/trace-events
+++ b/hw/nvram/trace-events
@@ -7,4 +7,9 @@  nvram_write(uint32_t addr, uint32_t old, uint32_t val) "write addr %d: 0x%02x ->
 # hw/nvram/fw_cfg.c
 fw_cfg_select(void *s, uint16_t key, int ret) "%p key %d = %d"
 fw_cfg_read(void *s, uint64_t ret) "%p = 0x%"PRIx64
+fw_cfg_add_bytes(uint16_t key, size_t len) "key 0x%04" PRIx16 " (%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, const char *value) "key 0x%04" PRIx16 ", value '%s'"
+fw_cfg_add_i16(uint16_t key, uint32_t value) "key 0x%04" PRIx16 ", value 0x%" PRIx32
+fw_cfg_add_i32(uint16_t key, uint32_t value) "key 0x%04" PRIx16 ", value 0x%" PRIx32
+fw_cfg_add_i64(uint16_t key, uint64_t value) "key 0x%04" PRIx16 ", value 0x%" PRIx64