All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches
@ 2019-05-23 12:43 Philippe Mathieu-Daudé
  2019-05-23 12:43 ` [Qemu-devel] [PULL 01/15] hw/nvram/fw_cfg: Add trace events Philippe Mathieu-Daudé
                   ` (15 more replies)
  0 siblings, 16 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-23 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael S. Tsirkin, Laszlo Ersek, Mark Cave-Ayland, qemu-ppc,
	Gerd Hoffmann, Philippe Mathieu-Daudé,
	Artyom Tarasenko, David Gibson

The following changes since commit c4600d5d417ea13e0f1cc047b227a2b5b0e694f5:

  Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-pull-request' into staging (2019-05-23 12:00:37 +0100)

are available in the Git repository at:

  https://gitlab.com/philmd/qemu.git tags/fw_cfg-20190523-pull-request

for you to fetch changes up to 3ae9dd1a304248e1f6ca631cdd43eb44a3e9e7b4:

  tests: fw_cfg: add 'splash-time' test case (2019-05-23 14:10:31 +0200)

----------------------------------------------------------------

fw_cfg patches for 2019-05-23

- Add trace events
- Get rid of globals in fw_cfg-test
- Explicit 'reboot-timeout' is little endian
- Add tests for 'reboot-timeout' and 'splash-time'

----------------------------------------------------------------

Li Qiang (5):
  tests: refactor fw_cfg_test
  tests: fw_cfg: add a function to get the fw_cfg file
  hw/nvram/fw_cfg: Store 'reboot-timeout' as little endian
  tests: fw_cfg: add 'reboot-timeout' test case
  tests: fw_cfg: add 'splash-time' test case

Philippe Mathieu-Daudé (10):
  hw/nvram/fw_cfg: Add trace events
  hw/nvram/fw_cfg: Add fw_cfg_arch_key_name()
  hw/i386: Extract fw_cfg definitions to local "fw_cfg.h"
  hw/i386: Implement fw_cfg_arch_key_name()
  hw/ppc: Implement fw_cfg_arch_key_name()
  hw/sparc: Implement fw_cfg_arch_key_name()
  hw/sparc64: Implement fw_cfg_arch_key_name()
  tests/libqos: Add io_fw_cfg_uninit() and mm_fw_cfg_uninit()
  tests/libqos: Add pc_fw_cfg_uninit() and use it
  tests/fw_cfg: Free QFWCFG object after qtest has run

 MAINTAINERS               |   1 +
 hw/i386/Makefile.objs     |   2 +-
 hw/i386/fw_cfg.c          |  38 ++++++++++++
 hw/i386/fw_cfg.h          |  20 ++++++
 hw/i386/pc.c              |   7 +--
 hw/nvram/fw_cfg.c         |  67 +++++++++++++++++++-
 hw/nvram/trace-events     |   7 ++-
 hw/ppc/Makefile.objs      |   2 +-
 hw/ppc/fw_cfg.c           |  45 ++++++++++++++
 hw/sparc/sun4m.c          |  19 ++++++
 hw/sparc64/sun4u.c        |  19 ++++++
 include/hw/nvram/fw_cfg.h |  14 +++++
 stubs/Makefile.objs       |   1 +
 stubs/fw_cfg.c            |  21 +++++++
 tests/fw_cfg-test.c       | 127 ++++++++++++++++++++++++++++++++++----
 tests/libqos/fw_cfg.c     |  55 +++++++++++++++++
 tests/libqos/fw_cfg.h     |   9 +++
 tests/libqos/malloc-pc.c  |   2 +-
 18 files changed, 433 insertions(+), 23 deletions(-)
 create mode 100644 hw/i386/fw_cfg.c
 create mode 100644 hw/i386/fw_cfg.h
 create mode 100644 hw/ppc/fw_cfg.c
 create mode 100644 stubs/fw_cfg.c

-- 
2.20.1



^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Qemu-devel] [PULL 01/15] hw/nvram/fw_cfg: Add trace events
  2019-05-23 12:43 [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Philippe Mathieu-Daudé
@ 2019-05-23 12:43 ` Philippe Mathieu-Daudé
  2019-05-23 12:43 ` [Qemu-devel] [PULL 02/15] hw/nvram/fw_cfg: Add fw_cfg_arch_key_name() Philippe Mathieu-Daudé
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-23 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael S. Tsirkin, Laszlo Ersek, Mark Cave-Ayland, qemu-ppc,
	Gerd Hoffmann, Philippe Mathieu-Daudé,
	Artyom Tarasenko, David Gibson

Add trace events to dump the key content.

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20190422195020.1494-2-philmd@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 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



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [PULL 02/15] hw/nvram/fw_cfg: Add fw_cfg_arch_key_name()
  2019-05-23 12:43 [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Philippe Mathieu-Daudé
  2019-05-23 12:43 ` [Qemu-devel] [PULL 01/15] hw/nvram/fw_cfg: Add trace events Philippe Mathieu-Daudé
@ 2019-05-23 12:43 ` Philippe Mathieu-Daudé
  2019-05-23 12:43 ` [Qemu-devel] [PULL 03/15] hw/i386: Extract fw_cfg definitions to local "fw_cfg.h" Philippe Mathieu-Daudé
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-23 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael S. Tsirkin, Laszlo Ersek, Mark Cave-Ayland, qemu-ppc,
	Gerd Hoffmann, Paolo Bonzini, Philippe Mathieu-Daudé,
	Artyom Tarasenko, David Gibson

Add fw_cfg_arch_key_name() which returns the name of
an architecture-specific key.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20190422195020.1494-3-philmd@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 MAINTAINERS               |  1 +
 hw/nvram/fw_cfg.c         |  2 +-
 include/hw/nvram/fw_cfg.h | 14 ++++++++++++++
 stubs/Makefile.objs       |  1 +
 stubs/fw_cfg.c            | 21 +++++++++++++++++++++
 5 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 stubs/fw_cfg.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 73a0105082..3cacd751bf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1696,6 +1696,7 @@ R: Gerd Hoffmann <kraxel@redhat.com>
 S: Supported
 F: docs/specs/fw_cfg.txt
 F: hw/nvram/fw_cfg.c
+F: stubs/fw_cfg.c
 F: include/hw/nvram/fw_cfg.h
 F: include/standard-headers/linux/qemu_fw_cfg.h
 F: tests/libqos/fw_cfg.c
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index d374a970fe..b2dc0a80cb 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -100,7 +100,7 @@ static const char *key_name(uint16_t key)
     };
 
     if (key & FW_CFG_ARCH_LOCAL) {
-        return NULL;
+        return fw_cfg_arch_key_name(key);
     }
     if (key < FW_CFG_FILE_FIRST) {
         return fw_cfg_wellknown_keys[key];
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
index f5a6895a74..80e435d303 100644
--- a/include/hw/nvram/fw_cfg.h
+++ b/include/hw/nvram/fw_cfg.h
@@ -226,4 +226,18 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr,
 FWCfgState *fw_cfg_find(void);
 bool fw_cfg_dma_enabled(void *opaque);
 
+/**
+ * fw_cfg_arch_key_name:
+ *
+ * @key: The uint16 selector key.
+ *
+ * The key is architecture-specific (the FW_CFG_ARCH_LOCAL mask is expected
+ * to be set in the key).
+ *
+ * Returns: The stringified architecture-specific name if the selector
+ *          refers to a well-known numerically defined item, or NULL on
+ *          key lookup failure.
+ */
+const char *fw_cfg_arch_key_name(uint16_t key);
+
 #endif
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 269dfa5832..73452ad265 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -39,3 +39,4 @@ stub-obj-y += xen-hvm.o
 stub-obj-y += pci-host-piix.o
 stub-obj-y += ram-block.o
 stub-obj-y += ramfb.o
+stub-obj-y += fw_cfg.o
diff --git a/stubs/fw_cfg.c b/stubs/fw_cfg.c
new file mode 100644
index 0000000000..bb1e3c8aa9
--- /dev/null
+++ b/stubs/fw_cfg.c
@@ -0,0 +1,21 @@
+/*
+ * fw_cfg stubs
+ *
+ * Copyright (c) 2019 Red Hat, Inc.
+ *
+ * Author:
+ *   Philippe Mathieu-Daudé <philmd@redhat.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/nvram/fw_cfg.h"
+
+const char *fw_cfg_arch_key_name(uint16_t key)
+{
+    return NULL;
+}
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [PULL 03/15] hw/i386: Extract fw_cfg definitions to local "fw_cfg.h"
  2019-05-23 12:43 [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Philippe Mathieu-Daudé
  2019-05-23 12:43 ` [Qemu-devel] [PULL 01/15] hw/nvram/fw_cfg: Add trace events Philippe Mathieu-Daudé
  2019-05-23 12:43 ` [Qemu-devel] [PULL 02/15] hw/nvram/fw_cfg: Add fw_cfg_arch_key_name() Philippe Mathieu-Daudé
@ 2019-05-23 12:43 ` Philippe Mathieu-Daudé
  2019-05-23 12:43 ` [Qemu-devel] [PULL 04/15] hw/i386: Implement fw_cfg_arch_key_name() Philippe Mathieu-Daudé
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-23 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Eduardo Habkost, Michael S. Tsirkin, Laszlo Ersek,
	Mark Cave-Ayland, qemu-ppc, Gerd Hoffmann, Paolo Bonzini,
	Richard Henderson, Philippe Mathieu-Daudé,
	Artyom Tarasenko, David Gibson

Extract the architecture-specific fw_cfg definitions to "fw_cfg.h".

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20190422195020.1494-4-philmd@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/i386/fw_cfg.h | 20 ++++++++++++++++++++
 hw/i386/pc.c     |  7 +------
 2 files changed, 21 insertions(+), 6 deletions(-)
 create mode 100644 hw/i386/fw_cfg.h

diff --git a/hw/i386/fw_cfg.h b/hw/i386/fw_cfg.h
new file mode 100644
index 0000000000..17a4bc32f2
--- /dev/null
+++ b/hw/i386/fw_cfg.h
@@ -0,0 +1,20 @@
+/*
+ * QEMU fw_cfg helpers (X86 specific)
+ *
+ * Copyright (c) 2003-2004 Fabrice Bellard
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef HW_I386_FW_CFG_H
+#define HW_I386_FW_CFG_H
+
+#include "hw/nvram/fw_cfg.h"
+
+#define FW_CFG_ACPI_TABLES      (FW_CFG_ARCH_LOCAL + 0)
+#define FW_CFG_SMBIOS_ENTRIES   (FW_CFG_ARCH_LOCAL + 1)
+#define FW_CFG_IRQ0_OVERRIDE    (FW_CFG_ARCH_LOCAL + 2)
+#define FW_CFG_E820_TABLE       (FW_CFG_ARCH_LOCAL + 3)
+#define FW_CFG_HPET             (FW_CFG_ARCH_LOCAL + 4)
+
+#endif
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index d98b737b8f..2632b73f80 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -30,6 +30,7 @@
 #include "hw/char/parallel.h"
 #include "hw/i386/apic.h"
 #include "hw/i386/topology.h"
+#include "hw/i386/fw_cfg.h"
 #include "sysemu/cpus.h"
 #include "hw/block/fdc.h"
 #include "hw/ide.h"
@@ -88,12 +89,6 @@
 #define DPRINTF(fmt, ...)
 #endif
 
-#define FW_CFG_ACPI_TABLES (FW_CFG_ARCH_LOCAL + 0)
-#define FW_CFG_SMBIOS_ENTRIES (FW_CFG_ARCH_LOCAL + 1)
-#define FW_CFG_IRQ0_OVERRIDE (FW_CFG_ARCH_LOCAL + 2)
-#define FW_CFG_E820_TABLE (FW_CFG_ARCH_LOCAL + 3)
-#define FW_CFG_HPET (FW_CFG_ARCH_LOCAL + 4)
-
 #define E820_NR_ENTRIES		16
 
 struct e820_entry {
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [PULL 04/15] hw/i386: Implement fw_cfg_arch_key_name()
  2019-05-23 12:43 [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2019-05-23 12:43 ` [Qemu-devel] [PULL 03/15] hw/i386: Extract fw_cfg definitions to local "fw_cfg.h" Philippe Mathieu-Daudé
@ 2019-05-23 12:43 ` Philippe Mathieu-Daudé
  2019-05-23 12:43 ` [Qemu-devel] [PULL 05/15] hw/ppc: " Philippe Mathieu-Daudé
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-23 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Eduardo Habkost, Michael S. Tsirkin, Laszlo Ersek,
	Mark Cave-Ayland, qemu-ppc, Gerd Hoffmann, Paolo Bonzini,
	Richard Henderson, Philippe Mathieu-Daudé,
	Artyom Tarasenko, David Gibson

Implement fw_cfg_arch_key_name(), which returns the name of a
i386-specific key.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20190422195020.1494-5-philmd@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/i386/Makefile.objs |  2 +-
 hw/i386/fw_cfg.c      | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100644 hw/i386/fw_cfg.c

diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
index 27248a0777..5d9c9efd5f 100644
--- a/hw/i386/Makefile.objs
+++ b/hw/i386/Makefile.objs
@@ -3,7 +3,7 @@ obj-y += multiboot.o
 obj-y += pc.o
 obj-$(CONFIG_I440FX) += pc_piix.o
 obj-$(CONFIG_Q35) += pc_q35.o
-obj-y += pc_sysfw.o
+obj-y += fw_cfg.o pc_sysfw.o
 obj-y += x86-iommu.o
 obj-$(CONFIG_VTD) += intel_iommu.o
 obj-$(CONFIG_AMD_IOMMU) += amd_iommu.o
diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c
new file mode 100644
index 0000000000..380a819230
--- /dev/null
+++ b/hw/i386/fw_cfg.c
@@ -0,0 +1,38 @@
+/*
+ * QEMU fw_cfg helpers (X86 specific)
+ *
+ * Copyright (c) 2019 Red Hat, Inc.
+ *
+ * Author:
+ *   Philippe Mathieu-Daudé <philmd@redhat.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/i386/fw_cfg.h"
+#include "hw/nvram/fw_cfg.h"
+
+const char *fw_cfg_arch_key_name(uint16_t key)
+{
+    static const struct {
+        uint16_t key;
+        const char *name;
+    } fw_cfg_arch_wellknown_keys[] = {
+        {FW_CFG_ACPI_TABLES, "acpi_tables"},
+        {FW_CFG_SMBIOS_ENTRIES, "smbios_entries"},
+        {FW_CFG_IRQ0_OVERRIDE, "irq0_override"},
+        {FW_CFG_E820_TABLE, "e820_table"},
+        {FW_CFG_HPET, "hpet"},
+    };
+
+    for (size_t i = 0; i < ARRAY_SIZE(fw_cfg_arch_wellknown_keys); i++) {
+        if (fw_cfg_arch_wellknown_keys[i].key == key) {
+            return fw_cfg_arch_wellknown_keys[i].name;
+        }
+    }
+    return NULL;
+}
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [PULL 05/15] hw/ppc: Implement fw_cfg_arch_key_name()
  2019-05-23 12:43 [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2019-05-23 12:43 ` [Qemu-devel] [PULL 04/15] hw/i386: Implement fw_cfg_arch_key_name() Philippe Mathieu-Daudé
@ 2019-05-23 12:43 ` Philippe Mathieu-Daudé
  2019-05-24  0:44   ` David Gibson
  2019-05-23 12:43 ` [Qemu-devel] [PULL 06/15] hw/sparc: " Philippe Mathieu-Daudé
                   ` (10 subsequent siblings)
  15 siblings, 1 reply; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-23 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael S. Tsirkin, Laszlo Ersek, Mark Cave-Ayland, qemu-ppc,
	Gerd Hoffmann, Philippe Mathieu-Daudé,
	Artyom Tarasenko, David Gibson

Implement fw_cfg_arch_key_name(), which returns the name of a
ppc-specific key.

The fw_cfg device is used by the machine using OpenBIOS:
- 40p
- mac99 (oldworld)
- g3beige (newworld)

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20190422195020.1494-6-philmd@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/ppc/Makefile.objs |  2 +-
 hw/ppc/fw_cfg.c      | 45 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 hw/ppc/fw_cfg.c

diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
index 636e717f20..9da93af905 100644
--- a/hw/ppc/Makefile.objs
+++ b/hw/ppc/Makefile.objs
@@ -1,5 +1,5 @@
 # shared objects
-obj-y += ppc.o ppc_booke.o fdt.o
+obj-y += ppc.o ppc_booke.o fdt.o fw_cfg.o
 # IBM pSeries (sPAPR)
 obj-$(CONFIG_PSERIES) += spapr.o spapr_caps.o spapr_vio.o spapr_events.o
 obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o
diff --git a/hw/ppc/fw_cfg.c b/hw/ppc/fw_cfg.c
new file mode 100644
index 0000000000..a88b5c4bde
--- /dev/null
+++ b/hw/ppc/fw_cfg.c
@@ -0,0 +1,45 @@
+/*
+ * fw_cfg helpers (PPC specific)
+ *
+ * Copyright (c) 2019 Red Hat, Inc.
+ *
+ * Author:
+ *   Philippe Mathieu-Daudé <philmd@redhat.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/ppc/ppc.h"
+#include "hw/nvram/fw_cfg.h"
+
+const char *fw_cfg_arch_key_name(uint16_t key)
+{
+    static const struct {
+        uint16_t key;
+        const char *name;
+    } fw_cfg_arch_wellknown_keys[] = {
+        {FW_CFG_PPC_WIDTH, "width"},
+        {FW_CFG_PPC_HEIGHT, "height"},
+        {FW_CFG_PPC_DEPTH, "depth"},
+        {FW_CFG_PPC_TBFREQ, "tbfreq"},
+        {FW_CFG_PPC_CLOCKFREQ, "clockfreq"},
+        {FW_CFG_PPC_IS_KVM, "is_kvm"},
+        {FW_CFG_PPC_KVM_HC, "kvm_hc"},
+        {FW_CFG_PPC_KVM_PID, "pid"},
+        {FW_CFG_PPC_NVRAM_ADDR, "nvram_addr"},
+        {FW_CFG_PPC_BUSFREQ, "busfreq"},
+        {FW_CFG_PPC_NVRAM_FLAT, "nvram_flat"},
+        {FW_CFG_PPC_VIACONFIG, "viaconfig"},
+    };
+
+    for (size_t i = 0; i < ARRAY_SIZE(fw_cfg_arch_wellknown_keys); i++) {
+        if (fw_cfg_arch_wellknown_keys[i].key == key) {
+            return fw_cfg_arch_wellknown_keys[i].name;
+        }
+    }
+    return NULL;
+}
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [PULL 06/15] hw/sparc: Implement fw_cfg_arch_key_name()
  2019-05-23 12:43 [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2019-05-23 12:43 ` [Qemu-devel] [PULL 05/15] hw/ppc: " Philippe Mathieu-Daudé
@ 2019-05-23 12:43 ` Philippe Mathieu-Daudé
  2019-05-23 12:43 ` [Qemu-devel] [PULL 07/15] hw/sparc64: " Philippe Mathieu-Daudé
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-23 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael S. Tsirkin, Laszlo Ersek, Mark Cave-Ayland, qemu-ppc,
	Gerd Hoffmann, Philippe Mathieu-Daudé,
	Artyom Tarasenko, David Gibson

Implement fw_cfg_arch_key_name(), which returns the name of a
sparc32-specific key.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20190422195020.1494-7-philmd@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/sparc/sun4m.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 07d126aea8..5151a7202b 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -97,6 +97,25 @@ struct sun4m_hwdef {
     uint8_t nvram_machine_id;
 };
 
+const char *fw_cfg_arch_key_name(uint16_t key)
+{
+    static const struct {
+        uint16_t key;
+        const char *name;
+    } fw_cfg_arch_wellknown_keys[] = {
+        {FW_CFG_SUN4M_DEPTH, "depth"},
+        {FW_CFG_SUN4M_WIDTH, "width"},
+        {FW_CFG_SUN4M_HEIGHT, "height"},
+    };
+
+    for (size_t i = 0; i < ARRAY_SIZE(fw_cfg_arch_wellknown_keys); i++) {
+        if (fw_cfg_arch_wellknown_keys[i].key == key) {
+            return fw_cfg_arch_wellknown_keys[i].name;
+        }
+    }
+    return NULL;
+}
+
 static void fw_cfg_boot_set(void *opaque, const char *boot_device,
                             Error **errp)
 {
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [PULL 07/15] hw/sparc64: Implement fw_cfg_arch_key_name()
  2019-05-23 12:43 [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2019-05-23 12:43 ` [Qemu-devel] [PULL 06/15] hw/sparc: " Philippe Mathieu-Daudé
@ 2019-05-23 12:43 ` Philippe Mathieu-Daudé
  2019-05-23 12:43 ` [Qemu-devel] [PULL 08/15] tests/libqos: Add io_fw_cfg_uninit() and mm_fw_cfg_uninit() Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-23 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael S. Tsirkin, Laszlo Ersek, Mark Cave-Ayland, qemu-ppc,
	Gerd Hoffmann, Philippe Mathieu-Daudé,
	Artyom Tarasenko, David Gibson

Implement fw_cfg_arch_key_name(), which returns the name of a
sparc64-specific key.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20190422195020.1494-8-philmd@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/sparc64/sun4u.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 399f2d73c8..4230b17b87 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -91,6 +91,25 @@ typedef struct EbusState {
 #define TYPE_EBUS "ebus"
 #define EBUS(obj) OBJECT_CHECK(EbusState, (obj), TYPE_EBUS)
 
+const char *fw_cfg_arch_key_name(uint16_t key)
+{
+    static const struct {
+        uint16_t key;
+        const char *name;
+    } fw_cfg_arch_wellknown_keys[] = {
+        {FW_CFG_SPARC64_WIDTH, "width"},
+        {FW_CFG_SPARC64_HEIGHT, "height"},
+        {FW_CFG_SPARC64_DEPTH, "depth"},
+    };
+
+    for (size_t i = 0; i < ARRAY_SIZE(fw_cfg_arch_wellknown_keys); i++) {
+        if (fw_cfg_arch_wellknown_keys[i].key == key) {
+            return fw_cfg_arch_wellknown_keys[i].name;
+        }
+    }
+    return NULL;
+}
+
 static void fw_cfg_boot_set(void *opaque, const char *boot_device,
                             Error **errp)
 {
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [PULL 08/15] tests/libqos: Add io_fw_cfg_uninit() and mm_fw_cfg_uninit()
  2019-05-23 12:43 [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2019-05-23 12:43 ` [Qemu-devel] [PULL 07/15] hw/sparc64: " Philippe Mathieu-Daudé
@ 2019-05-23 12:43 ` Philippe Mathieu-Daudé
  2019-05-23 12:43 ` [Qemu-devel] [PULL 09/15] tests/libqos: Add pc_fw_cfg_uninit() and use it Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-23 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Michael S. Tsirkin, Laszlo Ersek,
	Mark Cave-Ayland, qemu-ppc, Gerd Hoffmann, Li Qiang,
	Paolo Bonzini, Philippe Mathieu-Daudé,
	Artyom Tarasenko, David Gibson

The mm_fw_cfg_init() allocates a QFWCFG object,
add mm_fw_cfg_uninit() to deallocate it.
Similarly with io_fw_cfg_init(), add io_fw_cfg_uninit().

Signed-off-by: Li Qiang <liq3ea@163.com>
Tested-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190424140643.62457-2-liq3ea@163.com>
[PMD: Split patch, filled commit description]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
---
 tests/libqos/fw_cfg.c | 10 ++++++++++
 tests/libqos/fw_cfg.h |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/tests/libqos/fw_cfg.c b/tests/libqos/fw_cfg.c
index d0889d1e22..c6839c53c8 100644
--- a/tests/libqos/fw_cfg.c
+++ b/tests/libqos/fw_cfg.c
@@ -81,6 +81,11 @@ QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base)
     return fw_cfg;
 }
 
+void mm_fw_cfg_uninit(QFWCFG *fw_cfg)
+{
+    g_free(fw_cfg);
+}
+
 static void io_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
 {
     qtest_outw(fw_cfg->qts, fw_cfg->base, key);
@@ -107,3 +112,8 @@ QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base)
 
     return fw_cfg;
 }
+
+void io_fw_cfg_uninit(QFWCFG *fw_cfg)
+{
+    g_free(fw_cfg);
+}
diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h
index 0353416af0..391669031a 100644
--- a/tests/libqos/fw_cfg.h
+++ b/tests/libqos/fw_cfg.h
@@ -33,7 +33,9 @@ uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key);
 uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key);
 
 QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base);
+void mm_fw_cfg_uninit(QFWCFG *fw_cfg);
 QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base);
+void io_fw_cfg_uninit(QFWCFG *fw_cfg);
 
 static inline QFWCFG *pc_fw_cfg_init(QTestState *qts)
 {
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [PULL 09/15] tests/libqos: Add pc_fw_cfg_uninit() and use it
  2019-05-23 12:43 [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2019-05-23 12:43 ` [Qemu-devel] [PULL 08/15] tests/libqos: Add io_fw_cfg_uninit() and mm_fw_cfg_uninit() Philippe Mathieu-Daudé
@ 2019-05-23 12:43 ` Philippe Mathieu-Daudé
  2019-05-23 12:43 ` [Qemu-devel] [PULL 10/15] tests/fw_cfg: Free QFWCFG object after qtest has run Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-23 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Michael S. Tsirkin, Laszlo Ersek,
	Mark Cave-Ayland, qemu-ppc, Gerd Hoffmann, Li Qiang,
	Paolo Bonzini, Philippe Mathieu-Daudé,
	Artyom Tarasenko, David Gibson

The pc_fw_cfg_init() function allocates an IO QFWCFG object.
Add the pc_fw_cfg_uninit() function to deallocate it (and use it).

Signed-off-by: Li Qiang <liq3ea@163.com>
Tested-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20190424140643.62457-2-liq3ea@163.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
[PMD: Split patch, fill commit description, call uninit in malloc-pc.c]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
---
 tests/libqos/fw_cfg.h    | 5 +++++
 tests/libqos/malloc-pc.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h
index 391669031a..60de81e863 100644
--- a/tests/libqos/fw_cfg.h
+++ b/tests/libqos/fw_cfg.h
@@ -42,4 +42,9 @@ static inline QFWCFG *pc_fw_cfg_init(QTestState *qts)
     return io_fw_cfg_init(qts, 0x510);
 }
 
+static inline void pc_fw_cfg_uninit(QFWCFG *fw_cfg)
+{
+    io_fw_cfg_uninit(fw_cfg);
+}
+
 #endif
diff --git a/tests/libqos/malloc-pc.c b/tests/libqos/malloc-pc.c
index 949a99361d..6f92ce4135 100644
--- a/tests/libqos/malloc-pc.c
+++ b/tests/libqos/malloc-pc.c
@@ -29,5 +29,5 @@ void pc_alloc_init(QGuestAllocator *s, QTestState *qts, QAllocOpts flags)
     alloc_init(s, flags, 1 << 20, MIN(ram_size, 0xE0000000), PAGE_SIZE);
 
     /* clean-up */
-    g_free(fw_cfg);
+    pc_fw_cfg_uninit(fw_cfg);
 }
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [PULL 10/15] tests/fw_cfg: Free QFWCFG object after qtest has run
  2019-05-23 12:43 [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2019-05-23 12:43 ` [Qemu-devel] [PULL 09/15] tests/libqos: Add pc_fw_cfg_uninit() and use it Philippe Mathieu-Daudé
@ 2019-05-23 12:43 ` Philippe Mathieu-Daudé
  2019-05-23 12:43 ` [Qemu-devel] [PULL 11/15] tests: refactor fw_cfg_test Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-23 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Michael S. Tsirkin, Laszlo Ersek,
	Mark Cave-Ayland, qemu-ppc, Gerd Hoffmann, Li Qiang,
	Paolo Bonzini, Philippe Mathieu-Daudé,
	Artyom Tarasenko, David Gibson

We allocate the QFWCFG object previous to run the qtests,
free it once we are finished.

Signed-off-by: Li Qiang <liq3ea@163.com>
Message-Id: <20190424140643.62457-2-liq3ea@163.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
[PMD: Split patch, fill commit description]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
---
 tests/fw_cfg-test.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
index 1c5103fe1c..a370ad5667 100644
--- a/tests/fw_cfg-test.c
+++ b/tests/fw_cfg-test.c
@@ -128,6 +128,7 @@ int main(int argc, char **argv)
 
     ret = g_test_run();
 
+    pc_fw_cfg_uninit(fw_cfg);
     qtest_quit(s);
 
     return ret;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [PULL 11/15] tests: refactor fw_cfg_test
  2019-05-23 12:43 [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Philippe Mathieu-Daudé
                   ` (9 preceding siblings ...)
  2019-05-23 12:43 ` [Qemu-devel] [PULL 10/15] tests/fw_cfg: Free QFWCFG object after qtest has run Philippe Mathieu-Daudé
@ 2019-05-23 12:43 ` Philippe Mathieu-Daudé
  2019-05-23 12:43 ` [Qemu-devel] [PULL 12/15] tests: fw_cfg: add a function to get the fw_cfg file Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-23 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Michael S. Tsirkin, Laszlo Ersek,
	Mark Cave-Ayland, qemu-ppc, Gerd Hoffmann, Li Qiang,
	Paolo Bonzini, Philippe Mathieu-Daudé,
	Artyom Tarasenko, David Gibson

From: Li Qiang <liq3ea@163.com>

Currently, fw_cfg_test uses one QTestState for every test case.
This will add all command lines for every test case and
this is unnecessary. This patch split the test cases and for
every test case it uses his own QTestState. This patch does following
things:

1. Get rid of the global 'fw_cfg', this need add a uninit function

2. Convert every test case in a separate QTestState

After this patch, we can add fw_cfg test case freely and will not
have effect on other test cases.

Signed-off-by: Li Qiang <liq3ea@163.com>
Acked-by: Thomas Huth <thuth@redhat.com>
Tested-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190424140643.62457-2-liq3ea@163.com>
[PMD: Removed 'ret' local variable in main()]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/fw_cfg-test.c | 93 +++++++++++++++++++++++++++++++++++++--------
 1 file changed, 78 insertions(+), 15 deletions(-)

diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
index a370ad5667..4597626dd7 100644
--- a/tests/fw_cfg-test.c
+++ b/tests/fw_cfg-test.c
@@ -21,62 +21,127 @@ static uint16_t nb_cpus = 1;
 static uint16_t max_cpus = 1;
 static uint64_t nb_nodes = 0;
 static uint16_t boot_menu = 0;
-static QFWCFG *fw_cfg = NULL;
 
 static void test_fw_cfg_signature(void)
 {
+    QFWCFG *fw_cfg;
+    QTestState *s;
     char buf[5];
 
+    s = qtest_init("");
+    fw_cfg = pc_fw_cfg_init(s);
+
     qfw_cfg_get(fw_cfg, FW_CFG_SIGNATURE, buf, 4);
     buf[4] = 0;
 
     g_assert_cmpstr(buf, ==, "QEMU");
+    pc_fw_cfg_uninit(fw_cfg);
+    qtest_quit(s);
 }
 
 static void test_fw_cfg_id(void)
 {
-    uint32_t id = qfw_cfg_get_u32(fw_cfg, FW_CFG_ID);
+    QFWCFG *fw_cfg;
+    QTestState *s;
+    uint32_t id;
+
+    s = qtest_init("");
+    fw_cfg = pc_fw_cfg_init(s);
+
+    id = qfw_cfg_get_u32(fw_cfg, FW_CFG_ID);
     g_assert((id == 1) ||
              (id == 3));
+    pc_fw_cfg_uninit(fw_cfg);
+    qtest_quit(s);
 }
 
 static void test_fw_cfg_uuid(void)
 {
+    QFWCFG *fw_cfg;
+    QTestState *s;
+
     uint8_t buf[16];
     static const uint8_t uuid[16] = {
         0x46, 0x00, 0xcb, 0x32, 0x38, 0xec, 0x4b, 0x2f,
         0x8a, 0xcb, 0x81, 0xc6, 0xea, 0x54, 0xf2, 0xd8,
     };
 
+    s = qtest_init("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8");
+    fw_cfg = pc_fw_cfg_init(s);
+
     qfw_cfg_get(fw_cfg, FW_CFG_UUID, buf, 16);
     g_assert(memcmp(buf, uuid, sizeof(buf)) == 0);
+
+    pc_fw_cfg_uninit(fw_cfg);
+    qtest_quit(s);
+
 }
 
 static void test_fw_cfg_ram_size(void)
 {
+    QFWCFG *fw_cfg;
+    QTestState *s;
+
+    s = qtest_init("");
+    fw_cfg = pc_fw_cfg_init(s);
+
     g_assert_cmpint(qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE), ==, ram_size);
+
+    pc_fw_cfg_uninit(fw_cfg);
+    qtest_quit(s);
 }
 
 static void test_fw_cfg_nographic(void)
 {
+    QFWCFG *fw_cfg;
+    QTestState *s;
+
+    s = qtest_init("");
+    fw_cfg = pc_fw_cfg_init(s);
+
     g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NOGRAPHIC), ==, 0);
+
+    pc_fw_cfg_uninit(fw_cfg);
+    qtest_quit(s);
 }
 
 static void test_fw_cfg_nb_cpus(void)
 {
+    QFWCFG *fw_cfg;
+    QTestState *s;
+
+    s = qtest_init("");
+    fw_cfg = pc_fw_cfg_init(s);
+
     g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NB_CPUS), ==, nb_cpus);
+
+    pc_fw_cfg_uninit(fw_cfg);
+    qtest_quit(s);
 }
 
 static void test_fw_cfg_max_cpus(void)
 {
+    QFWCFG *fw_cfg;
+    QTestState *s;
+
+    s = qtest_init("");
+    fw_cfg = pc_fw_cfg_init(s);
+
     g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_MAX_CPUS), ==, max_cpus);
+    pc_fw_cfg_uninit(fw_cfg);
+    qtest_quit(s);
 }
 
 static void test_fw_cfg_numa(void)
 {
+    QFWCFG *fw_cfg;
+    QTestState *s;
     uint64_t *cpu_mask;
     uint64_t *node_mask;
 
+    s = qtest_init("");
+    fw_cfg = pc_fw_cfg_init(s);
+
     g_assert_cmpint(qfw_cfg_get_u64(fw_cfg, FW_CFG_NUMA), ==, nb_nodes);
 
     cpu_mask = g_new0(uint64_t, max_cpus);
@@ -92,24 +157,27 @@ static void test_fw_cfg_numa(void)
 
     g_free(node_mask);
     g_free(cpu_mask);
+    pc_fw_cfg_uninit(fw_cfg);
+    qtest_quit(s);
 }
 
 static void test_fw_cfg_boot_menu(void)
 {
+    QFWCFG *fw_cfg;
+    QTestState *s;
+
+    s = qtest_init("");
+    fw_cfg = pc_fw_cfg_init(s);
+
     g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_MENU), ==, boot_menu);
+    pc_fw_cfg_uninit(fw_cfg);
+    qtest_quit(s);
 }
 
 int main(int argc, char **argv)
 {
-    QTestState *s;
-    int ret;
-
     g_test_init(&argc, &argv, NULL);
 
-    s = qtest_init("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8");
-
-    fw_cfg = pc_fw_cfg_init(s);
-
     qtest_add_func("fw_cfg/signature", test_fw_cfg_signature);
     qtest_add_func("fw_cfg/id", test_fw_cfg_id);
     qtest_add_func("fw_cfg/uuid", test_fw_cfg_uuid);
@@ -126,10 +194,5 @@ int main(int argc, char **argv)
     qtest_add_func("fw_cfg/numa", test_fw_cfg_numa);
     qtest_add_func("fw_cfg/boot_menu", test_fw_cfg_boot_menu);
 
-    ret = g_test_run();
-
-    pc_fw_cfg_uninit(fw_cfg);
-    qtest_quit(s);
-
-    return ret;
+    return g_test_run();
 }
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [PULL 12/15] tests: fw_cfg: add a function to get the fw_cfg file
  2019-05-23 12:43 [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Philippe Mathieu-Daudé
                   ` (10 preceding siblings ...)
  2019-05-23 12:43 ` [Qemu-devel] [PULL 11/15] tests: refactor fw_cfg_test Philippe Mathieu-Daudé
@ 2019-05-23 12:43 ` Philippe Mathieu-Daudé
  2019-05-23 12:43 ` [Qemu-devel] [PULL 13/15] hw/nvram/fw_cfg: Store 'reboot-timeout' as little endian Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-23 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Michael S. Tsirkin, Laszlo Ersek,
	Mark Cave-Ayland, qemu-ppc, Gerd Hoffmann, Li Qiang,
	Paolo Bonzini, Philippe Mathieu-Daudé,
	Artyom Tarasenko, David Gibson

From: Li Qiang <liq3ea@163.com>

This is useful to write qtest about fw_cfg file entry.

Signed-off-by: Li Qiang <liq3ea@163.com>
Acked-by: Thomas Huth <thuth@redhat.com>
Tested-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190424140643.62457-3-liq3ea@163.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/libqos/fw_cfg.c | 45 +++++++++++++++++++++++++++++++++++++++++++
 tests/libqos/fw_cfg.h |  2 ++
 2 files changed, 47 insertions(+)

diff --git a/tests/libqos/fw_cfg.c b/tests/libqos/fw_cfg.c
index c6839c53c8..1f46258f96 100644
--- a/tests/libqos/fw_cfg.c
+++ b/tests/libqos/fw_cfg.c
@@ -16,6 +16,7 @@
 #include "libqos/fw_cfg.h"
 #include "libqtest.h"
 #include "qemu/bswap.h"
+#include "hw/nvram/fw_cfg.h"
 
 void qfw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
 {
@@ -59,6 +60,50 @@ static void mm_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
     qtest_writew(fw_cfg->qts, fw_cfg->base, key);
 }
 
+/*
+ * The caller need check the return value. When the return value is
+ * nonzero, it means that some bytes have been transferred.
+ *
+ * If the fw_cfg file in question is smaller than the allocated & passed-in
+ * buffer, then the buffer has been populated only in part.
+ *
+ * If the fw_cfg file in question is larger than the passed-in
+ * buffer, then the return value explains how much room would have been
+ * necessary in total. And, while the caller's buffer has been fully
+ * populated, it has received only a starting slice of the fw_cfg file.
+ */
+size_t qfw_cfg_get_file(QFWCFG *fw_cfg, const char *filename,
+                      void *data, size_t buflen)
+{
+    uint32_t count;
+    uint32_t i;
+    unsigned char *filesbuf = NULL;
+    size_t dsize;
+    FWCfgFile *pdir_entry;
+    size_t filesize = 0;
+
+    qfw_cfg_get(fw_cfg, FW_CFG_FILE_DIR, &count, sizeof(count));
+    count = be32_to_cpu(count);
+    dsize = sizeof(uint32_t) + count * sizeof(struct fw_cfg_file);
+    filesbuf = g_malloc(dsize);
+    qfw_cfg_get(fw_cfg, FW_CFG_FILE_DIR, filesbuf, dsize);
+    pdir_entry = (FWCfgFile *)(filesbuf + sizeof(uint32_t));
+    for (i = 0; i < count; ++i, ++pdir_entry) {
+        if (!strcmp(pdir_entry->name, filename)) {
+            uint32_t len = be32_to_cpu(pdir_entry->size);
+            uint16_t sel = be16_to_cpu(pdir_entry->select);
+            filesize = len;
+            if (len > buflen) {
+                len = buflen;
+            }
+            qfw_cfg_get(fw_cfg, sel, data, len);
+            break;
+        }
+    }
+    g_free(filesbuf);
+    return filesize;
+}
+
 static void mm_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len)
 {
     uint8_t *ptr = data;
diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h
index 60de81e863..13325cc4ff 100644
--- a/tests/libqos/fw_cfg.h
+++ b/tests/libqos/fw_cfg.h
@@ -31,6 +31,8 @@ void qfw_cfg_get(QFWCFG *fw_cfg, uint16_t key, void *data, size_t len);
 uint16_t qfw_cfg_get_u16(QFWCFG *fw_cfg, uint16_t key);
 uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key);
 uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key);
+size_t qfw_cfg_get_file(QFWCFG *fw_cfg, const char *filename,
+                        void *data, size_t buflen);
 
 QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base);
 void mm_fw_cfg_uninit(QFWCFG *fw_cfg);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [PULL 13/15] hw/nvram/fw_cfg: Store 'reboot-timeout' as little endian
  2019-05-23 12:43 [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Philippe Mathieu-Daudé
                   ` (11 preceding siblings ...)
  2019-05-23 12:43 ` [Qemu-devel] [PULL 12/15] tests: fw_cfg: add a function to get the fw_cfg file Philippe Mathieu-Daudé
@ 2019-05-23 12:43 ` Philippe Mathieu-Daudé
  2019-05-23 12:43 ` [Qemu-devel] [PULL 14/15] tests: fw_cfg: add 'reboot-timeout' test case Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-23 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Thomas Huth, Michael S. Tsirkin, Laszlo Ersek, Mark Cave-Ayland,
	qemu-ppc, Gerd Hoffmann, Li Qiang, Philippe Mathieu-Daudé,
	Artyom Tarasenko, David Gibson

From: Li Qiang <liq3ea@163.com>

The current codebase is not specific about the endianess of the
fw_cfg 'file' entry 'reboot-timeout'.

Per docs/specs/fw_cfg.txt:

  === All Other Data Items ===

  Please consult the QEMU source for the most up-to-date
  and authoritative list of selector keys and their respective
  items' purpose, format and writeability.

Checking the git history, this code was introduced in commit
ac05f3492421, very similar to commit 3d3b8303c6f8 for the
'boot-menu-wait' entry, which explicitely use little-endian.

OVMF consumes 'boot-menu-wait' as little-endian, however it does
not consume 'reboot-timeout'.

Regarding the git history and OVMF use, we choose to explicit
'reboot-timeout' endianess as little-endian.

Signed-off-by: Li Qiang <liq3ea@163.com>
Tested-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190424140643.62457-4-liq3ea@163.com>
[PMD: Reword commit description based on review comments]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/nvram/fw_cfg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index b2dc0a80cb..9f7b7789bc 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -234,6 +234,7 @@ static void fw_cfg_reboot(FWCfgState *s)
 {
     const char *reboot_timeout = NULL;
     int64_t rt_val = -1;
+    uint32_t rt_le32;
 
     /* get user configuration */
     QemuOptsList *plist = qemu_find_opts("boot-opts");
@@ -250,7 +251,8 @@ static void fw_cfg_reboot(FWCfgState *s)
         }
     }
 
-    fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&rt_val, 4), 4);
+    rt_le32 = cpu_to_le32(rt_val);
+    fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&rt_le32, 4), 4);
 }
 
 static void fw_cfg_write(FWCfgState *s, uint8_t value)
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [PULL 14/15] tests: fw_cfg: add 'reboot-timeout' test case
  2019-05-23 12:43 [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Philippe Mathieu-Daudé
                   ` (12 preceding siblings ...)
  2019-05-23 12:43 ` [Qemu-devel] [PULL 13/15] hw/nvram/fw_cfg: Store 'reboot-timeout' as little endian Philippe Mathieu-Daudé
@ 2019-05-23 12:43 ` Philippe Mathieu-Daudé
  2019-05-23 12:43 ` [Qemu-devel] [PULL 15/15] tests: fw_cfg: add 'splash-time' " Philippe Mathieu-Daudé
  2019-05-23 15:46 ` [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Peter Maydell
  15 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-23 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Michael S. Tsirkin, Laszlo Ersek,
	Mark Cave-Ayland, qemu-ppc, Gerd Hoffmann, Li Qiang,
	Paolo Bonzini, Philippe Mathieu-Daudé,
	Artyom Tarasenko, David Gibson

From: Li Qiang <liq3ea@163.com>

Signed-off-by: Li Qiang <liq3ea@163.com>
Tested-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190424140643.62457-5-liq3ea@163.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/fw_cfg-test.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
index 4597626dd7..20b1eb75f4 100644
--- a/tests/fw_cfg-test.c
+++ b/tests/fw_cfg-test.c
@@ -15,6 +15,7 @@
 #include "libqtest.h"
 #include "standard-headers/linux/qemu_fw_cfg.h"
 #include "libqos/fw_cfg.h"
+#include "qemu/bswap.h"
 
 static uint64_t ram_size = 128 << 20;
 static uint16_t nb_cpus = 1;
@@ -174,6 +175,25 @@ static void test_fw_cfg_boot_menu(void)
     qtest_quit(s);
 }
 
+static void test_fw_cfg_reboot_timeout(void)
+{
+    QFWCFG *fw_cfg;
+    QTestState *s;
+    uint32_t reboot_timeout = 0;
+    size_t filesize;
+
+    s = qtest_init("-boot reboot-timeout=15");
+    fw_cfg = pc_fw_cfg_init(s);
+
+    filesize = qfw_cfg_get_file(fw_cfg, "etc/boot-fail-wait",
+                                &reboot_timeout, sizeof(reboot_timeout));
+    g_assert_cmpint(filesize, ==, sizeof(reboot_timeout));
+    reboot_timeout = le32_to_cpu(reboot_timeout);
+    g_assert_cmpint(reboot_timeout, ==, 15);
+    pc_fw_cfg_uninit(fw_cfg);
+    qtest_quit(s);
+}
+
 int main(int argc, char **argv)
 {
     g_test_init(&argc, &argv, NULL);
@@ -193,6 +213,7 @@ int main(int argc, char **argv)
     qtest_add_func("fw_cfg/max_cpus", test_fw_cfg_max_cpus);
     qtest_add_func("fw_cfg/numa", test_fw_cfg_numa);
     qtest_add_func("fw_cfg/boot_menu", test_fw_cfg_boot_menu);
+    qtest_add_func("fw_cfg/reboot_timeout", test_fw_cfg_reboot_timeout);
 
     return g_test_run();
 }
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [PULL 15/15] tests: fw_cfg: add 'splash-time' test case
  2019-05-23 12:43 [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Philippe Mathieu-Daudé
                   ` (13 preceding siblings ...)
  2019-05-23 12:43 ` [Qemu-devel] [PULL 14/15] tests: fw_cfg: add 'reboot-timeout' test case Philippe Mathieu-Daudé
@ 2019-05-23 12:43 ` Philippe Mathieu-Daudé
  2019-05-23 15:46 ` [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Peter Maydell
  15 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-23 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Michael S. Tsirkin, Laszlo Ersek,
	Mark Cave-Ayland, qemu-ppc, Gerd Hoffmann, Li Qiang,
	Paolo Bonzini, Philippe Mathieu-Daudé,
	Artyom Tarasenko, David Gibson

From: Li Qiang <liq3ea@163.com>

Signed-off-by: Li Qiang <liq3ea@163.com>
Tested-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190424140643.62457-6-liq3ea@163.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/fw_cfg-test.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
index 20b1eb75f4..1d3147f821 100644
--- a/tests/fw_cfg-test.c
+++ b/tests/fw_cfg-test.c
@@ -194,6 +194,25 @@ static void test_fw_cfg_reboot_timeout(void)
     qtest_quit(s);
 }
 
+static void test_fw_cfg_splash_time(void)
+{
+    QFWCFG *fw_cfg;
+    QTestState *s;
+    uint16_t splash_time = 0;
+    size_t filesize;
+
+    s = qtest_init("-boot splash-time=12");
+    fw_cfg = pc_fw_cfg_init(s);
+
+    filesize = qfw_cfg_get_file(fw_cfg, "etc/boot-menu-wait",
+                                &splash_time, sizeof(splash_time));
+    g_assert_cmpint(filesize, ==, sizeof(splash_time));
+    splash_time = le16_to_cpu(splash_time);
+    g_assert_cmpint(splash_time, ==, 12);
+    pc_fw_cfg_uninit(fw_cfg);
+    qtest_quit(s);
+}
+
 int main(int argc, char **argv)
 {
     g_test_init(&argc, &argv, NULL);
@@ -214,6 +233,7 @@ int main(int argc, char **argv)
     qtest_add_func("fw_cfg/numa", test_fw_cfg_numa);
     qtest_add_func("fw_cfg/boot_menu", test_fw_cfg_boot_menu);
     qtest_add_func("fw_cfg/reboot_timeout", test_fw_cfg_reboot_timeout);
+    qtest_add_func("fw_cfg/splash_time", test_fw_cfg_splash_time);
 
     return g_test_run();
 }
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches
  2019-05-23 12:43 [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Philippe Mathieu-Daudé
                   ` (14 preceding siblings ...)
  2019-05-23 12:43 ` [Qemu-devel] [PULL 15/15] tests: fw_cfg: add 'splash-time' " Philippe Mathieu-Daudé
@ 2019-05-23 15:46 ` Peter Maydell
  15 siblings, 0 replies; 18+ messages in thread
From: Peter Maydell @ 2019-05-23 15:46 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Michael S. Tsirkin, Mark Cave-Ayland, QEMU Developers, qemu-ppc,
	Gerd Hoffmann, Laszlo Ersek, Artyom Tarasenko, David Gibson

On Thu, 23 May 2019 at 14:12, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> The following changes since commit c4600d5d417ea13e0f1cc047b227a2b5b0e694f5:
>
>   Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-pull-request' into staging (2019-05-23 12:00:37 +0100)
>
> are available in the Git repository at:
>
>   https://gitlab.com/philmd/qemu.git tags/fw_cfg-20190523-pull-request
>
> for you to fetch changes up to 3ae9dd1a304248e1f6ca631cdd43eb44a3e9e7b4:
>
>   tests: fw_cfg: add 'splash-time' test case (2019-05-23 14:10:31 +0200)
>
> ----------------------------------------------------------------
>
> fw_cfg patches for 2019-05-23
>
> - Add trace events
> - Get rid of globals in fw_cfg-test
> - Explicit 'reboot-timeout' is little endian
> - Add tests for 'reboot-timeout' and 'splash-time'
>
> ----------------------------------------------------------------
>


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] [PULL 05/15] hw/ppc: Implement fw_cfg_arch_key_name()
  2019-05-23 12:43 ` [Qemu-devel] [PULL 05/15] hw/ppc: " Philippe Mathieu-Daudé
@ 2019-05-24  0:44   ` David Gibson
  0 siblings, 0 replies; 18+ messages in thread
From: David Gibson @ 2019-05-24  0:44 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel, qemu-ppc,
	Gerd Hoffmann, Laszlo Ersek, Artyom Tarasenko

[-- Attachment #1: Type: text/plain, Size: 2999 bytes --]

On Thu, May 23, 2019 at 02:43:10PM +0200, Philippe Mathieu-Daudé wrote:
> Implement fw_cfg_arch_key_name(), which returns the name of a
> ppc-specific key.
> 
> The fw_cfg device is used by the machine using OpenBIOS:
> - 40p
> - mac99 (oldworld)
> - g3beige (newworld)
> 
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
> Message-Id: <20190422195020.1494-6-philmd@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  hw/ppc/Makefile.objs |  2 +-
>  hw/ppc/fw_cfg.c      | 45 ++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 46 insertions(+), 1 deletion(-)
>  create mode 100644 hw/ppc/fw_cfg.c
> 
> diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
> index 636e717f20..9da93af905 100644
> --- a/hw/ppc/Makefile.objs
> +++ b/hw/ppc/Makefile.objs
> @@ -1,5 +1,5 @@
>  # shared objects
> -obj-y += ppc.o ppc_booke.o fdt.o
> +obj-y += ppc.o ppc_booke.o fdt.o fw_cfg.o
>  # IBM pSeries (sPAPR)
>  obj-$(CONFIG_PSERIES) += spapr.o spapr_caps.o spapr_vio.o spapr_events.o
>  obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o
> diff --git a/hw/ppc/fw_cfg.c b/hw/ppc/fw_cfg.c
> new file mode 100644
> index 0000000000..a88b5c4bde
> --- /dev/null
> +++ b/hw/ppc/fw_cfg.c
> @@ -0,0 +1,45 @@
> +/*
> + * fw_cfg helpers (PPC specific)
> + *
> + * Copyright (c) 2019 Red Hat, Inc.
> + *
> + * Author:
> + *   Philippe Mathieu-Daudé <philmd@redhat.com>
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "hw/ppc/ppc.h"
> +#include "hw/nvram/fw_cfg.h"
> +
> +const char *fw_cfg_arch_key_name(uint16_t key)
> +{
> +    static const struct {
> +        uint16_t key;
> +        const char *name;
> +    } fw_cfg_arch_wellknown_keys[] = {
> +        {FW_CFG_PPC_WIDTH, "width"},
> +        {FW_CFG_PPC_HEIGHT, "height"},
> +        {FW_CFG_PPC_DEPTH, "depth"},
> +        {FW_CFG_PPC_TBFREQ, "tbfreq"},
> +        {FW_CFG_PPC_CLOCKFREQ, "clockfreq"},
> +        {FW_CFG_PPC_IS_KVM, "is_kvm"},
> +        {FW_CFG_PPC_KVM_HC, "kvm_hc"},
> +        {FW_CFG_PPC_KVM_PID, "pid"},
> +        {FW_CFG_PPC_NVRAM_ADDR, "nvram_addr"},
> +        {FW_CFG_PPC_BUSFREQ, "busfreq"},
> +        {FW_CFG_PPC_NVRAM_FLAT, "nvram_flat"},
> +        {FW_CFG_PPC_VIACONFIG, "viaconfig"},
> +    };
> +
> +    for (size_t i = 0; i < ARRAY_SIZE(fw_cfg_arch_wellknown_keys); i++) {
> +        if (fw_cfg_arch_wellknown_keys[i].key == key) {
> +            return fw_cfg_arch_wellknown_keys[i].name;
> +        }
> +    }
> +    return NULL;
> +}

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2019-05-24  1:02 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-23 12:43 [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Philippe Mathieu-Daudé
2019-05-23 12:43 ` [Qemu-devel] [PULL 01/15] hw/nvram/fw_cfg: Add trace events Philippe Mathieu-Daudé
2019-05-23 12:43 ` [Qemu-devel] [PULL 02/15] hw/nvram/fw_cfg: Add fw_cfg_arch_key_name() Philippe Mathieu-Daudé
2019-05-23 12:43 ` [Qemu-devel] [PULL 03/15] hw/i386: Extract fw_cfg definitions to local "fw_cfg.h" Philippe Mathieu-Daudé
2019-05-23 12:43 ` [Qemu-devel] [PULL 04/15] hw/i386: Implement fw_cfg_arch_key_name() Philippe Mathieu-Daudé
2019-05-23 12:43 ` [Qemu-devel] [PULL 05/15] hw/ppc: " Philippe Mathieu-Daudé
2019-05-24  0:44   ` David Gibson
2019-05-23 12:43 ` [Qemu-devel] [PULL 06/15] hw/sparc: " Philippe Mathieu-Daudé
2019-05-23 12:43 ` [Qemu-devel] [PULL 07/15] hw/sparc64: " Philippe Mathieu-Daudé
2019-05-23 12:43 ` [Qemu-devel] [PULL 08/15] tests/libqos: Add io_fw_cfg_uninit() and mm_fw_cfg_uninit() Philippe Mathieu-Daudé
2019-05-23 12:43 ` [Qemu-devel] [PULL 09/15] tests/libqos: Add pc_fw_cfg_uninit() and use it Philippe Mathieu-Daudé
2019-05-23 12:43 ` [Qemu-devel] [PULL 10/15] tests/fw_cfg: Free QFWCFG object after qtest has run Philippe Mathieu-Daudé
2019-05-23 12:43 ` [Qemu-devel] [PULL 11/15] tests: refactor fw_cfg_test Philippe Mathieu-Daudé
2019-05-23 12:43 ` [Qemu-devel] [PULL 12/15] tests: fw_cfg: add a function to get the fw_cfg file Philippe Mathieu-Daudé
2019-05-23 12:43 ` [Qemu-devel] [PULL 13/15] hw/nvram/fw_cfg: Store 'reboot-timeout' as little endian Philippe Mathieu-Daudé
2019-05-23 12:43 ` [Qemu-devel] [PULL 14/15] tests: fw_cfg: add 'reboot-timeout' test case Philippe Mathieu-Daudé
2019-05-23 12:43 ` [Qemu-devel] [PULL 15/15] tests: fw_cfg: add 'splash-time' " Philippe Mathieu-Daudé
2019-05-23 15:46 ` [Qemu-devel] [PULL 00/15] Fw cfg 20190523 patches Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.