All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too
@ 2016-10-18 20:46 Thomas Huth
  2016-10-18 20:46 ` [Qemu-devel] [PATCH 1/5] nvram: Introduce helper functions for CHRP "system" and "free space" partitions Thomas Huth
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Thomas Huth @ 2016-10-18 20:46 UTC (permalink / raw)
  To: David Gibson, Alexander Graf, qemu-ppc, Mark Cave-Ayland
  Cc: qemu-devel, Artyom Tarasenko

The OpenBIOS NVRAM set-up is based on the layout defined in the CHRP
(Common Hardware Reference Platform) specification. This is the same
layout that is also used by the PAPR specification and thus by the SLOF
firmware of the pseries machine. By refactoring the NVRAM code from
mac_nvram.c, we can use the same functions for setting up the NVRAM
for both, OpenBIOS and SLOF. This way we can support the "-prom-env"
parameter of QEMU for SLOF, too, which is very useful to influence
the firmware boot process.

Thomas Huth (5):
  nvram: Introduce helper functions for CHRP "system" and "free space"
    partitions
  sparc: Use the new common NVRAM functions for system and free space
    partition
  spapr_nvram: Pre-initialize the NVRAM to support the -prom-env
    parameter
  nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch]
  nvram: Rename openbios_firmware_abi.h into sun_nvram.h

 hw/nvram/Makefile.objs                             |  1 +
 hw/nvram/chrp_nvram.c                              | 85 ++++++++++++++++++++++
 hw/nvram/mac_nvram.c                               | 49 +++----------
 hw/nvram/spapr_nvram.c                             |  6 ++
 hw/sparc/sun4m.c                                   | 35 ++-------
 hw/sparc64/sun4u.c                                 | 35 ++-------
 include/hw/nvram/chrp_nvram.h                      | 54 ++++++++++++++
 .../nvram/{openbios_firmware_abi.h => sun_nvram.h} | 47 +-----------
 tests/postcopy-test.c                              |  8 +-
 9 files changed, 179 insertions(+), 141 deletions(-)
 create mode 100644 hw/nvram/chrp_nvram.c
 create mode 100644 include/hw/nvram/chrp_nvram.h
 rename include/hw/nvram/{openbios_firmware_abi.h => sun_nvram.h} (50%)

-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 1/5] nvram: Introduce helper functions for CHRP "system" and "free space" partitions
  2016-10-18 20:46 [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too Thomas Huth
@ 2016-10-18 20:46 ` Thomas Huth
  2016-10-18 20:46 ` [Qemu-devel] [PATCH 2/5] sparc: Use the new common NVRAM functions for system and free space partition Thomas Huth
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Thomas Huth @ 2016-10-18 20:46 UTC (permalink / raw)
  To: David Gibson, Alexander Graf, qemu-ppc, Mark Cave-Ayland
  Cc: qemu-devel, Artyom Tarasenko

The "system partition" and "free space" partition layouts are
defined by the CHRP and LoPAPR specification, and used by
OpenBIOS and SLOF. We can re-use this code for other machines
that use OpenBIOS and SLOF, too. So let's make this code independent
from the MAC NVRAM environment and put it into two proper helper
functions.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/nvram/Makefile.objs        |  1 +
 hw/nvram/chrp_nvram.c         | 76 +++++++++++++++++++++++++++++++++++++++++++
 hw/nvram/mac_nvram.c          | 40 +++++------------------
 include/hw/nvram/chrp_nvram.h | 24 ++++++++++++++
 4 files changed, 109 insertions(+), 32 deletions(-)
 create mode 100644 hw/nvram/chrp_nvram.c
 create mode 100644 include/hw/nvram/chrp_nvram.h

diff --git a/hw/nvram/Makefile.objs b/hw/nvram/Makefile.objs
index e9a6694..c018f6b 100644
--- a/hw/nvram/Makefile.objs
+++ b/hw/nvram/Makefile.objs
@@ -1,5 +1,6 @@
 common-obj-$(CONFIG_DS1225Y) += ds1225y.o
 common-obj-y += eeprom93xx.o
 common-obj-y += fw_cfg.o
+common-obj-y += chrp_nvram.o
 common-obj-$(CONFIG_MAC_NVRAM) += mac_nvram.o
 obj-$(CONFIG_PSERIES) += spapr_nvram.o
diff --git a/hw/nvram/chrp_nvram.c b/hw/nvram/chrp_nvram.c
new file mode 100644
index 0000000..f6183ed
--- /dev/null
+++ b/hw/nvram/chrp_nvram.c
@@ -0,0 +1,76 @@
+/*
+ * Common Hardware Reference Platform NVRAM helper functions.
+ *
+ * The CHRP NVRAM layout is used by OpenBIOS and SLOF. See CHRP
+ * specification, chapter 8, or the LoPAPR specification for details
+ * about the NVRAM layout.
+ *
+ * This code is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/cutils.h"
+#include "hw/hw.h"
+#include "hw/nvram/chrp_nvram.h"
+#include "hw/nvram/openbios_firmware_abi.h"
+#include "sysemu/sysemu.h"
+
+/**
+ * Create a "system partition", used for the Open Firmware
+ * environment variables.
+ */
+int chrp_nvram_create_system_partition(uint8_t *data, int min_len)
+{
+    struct OpenBIOS_nvpart_v1 *part_header;
+    unsigned int i;
+    int end;
+
+    part_header = (struct OpenBIOS_nvpart_v1 *)data;
+    part_header->signature = OPENBIOS_PART_SYSTEM;
+    pstrcpy(part_header->name, sizeof(part_header->name), "system");
+
+    end = sizeof(struct OpenBIOS_nvpart_v1);
+    for (i = 0; i < nb_prom_envs; i++) {
+        end = OpenBIOS_set_var(data, end, prom_envs[i]);
+    }
+
+    /* End marker */
+    data[end++] = '\0';
+
+    end = (end + 15) & ~15;
+    /* XXX: OpenBIOS is not able to grow up a partition. Leave some space for
+       new variables. */
+    if (end < min_len) {
+        end = min_len;
+    }
+    OpenBIOS_finish_partition(part_header, end);
+
+    return end;
+}
+
+/**
+ * Create a "free space" partition
+ */
+int chrp_nvram_create_free_partition(uint8_t *data, int len)
+{
+    struct OpenBIOS_nvpart_v1 *part_header;
+
+    part_header = (struct OpenBIOS_nvpart_v1 *)data;
+    part_header->signature = OPENBIOS_PART_FREE;
+    pstrcpy(part_header->name, sizeof(part_header->name), "free");
+
+    OpenBIOS_finish_partition(part_header, len);
+
+    return len;
+}
diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c
index 24f6121..c0e62a5 100644
--- a/hw/nvram/mac_nvram.c
+++ b/hw/nvram/mac_nvram.c
@@ -25,7 +25,7 @@
 #include "qemu/osdep.h"
 #include "hw/hw.h"
 #include "hw/nvram/openbios_firmware_abi.h"
-#include "sysemu/sysemu.h"
+#include "hw/nvram/chrp_nvram.h"
 #include "hw/ppc/mac.h"
 #include "qemu/cutils.h"
 #include <zlib.h>
@@ -146,38 +146,14 @@ static void macio_nvram_register_types(void)
 static void pmac_format_nvram_partition_of(MacIONVRAMState *nvr, int off,
                                            int len)
 {
-    unsigned int i;
-    uint32_t start = off, end;
-    struct OpenBIOS_nvpart_v1 *part_header;
+    int sysp_end;
+
+    /* OpenBIOS nvram variables partition */
+    sysp_end = chrp_nvram_create_system_partition(&nvr->data[off],
+                                                  DEF_SYSTEM_SIZE) + off;
 
-    // OpenBIOS nvram variables
-    // Variable partition
-    part_header = (struct OpenBIOS_nvpart_v1 *)&nvr->data[start];
-    part_header->signature = OPENBIOS_PART_SYSTEM;
-    pstrcpy(part_header->name, sizeof(part_header->name), "system");
-
-    end = start + sizeof(struct OpenBIOS_nvpart_v1);
-    for (i = 0; i < nb_prom_envs; i++)
-        end = OpenBIOS_set_var(nvr->data, end, prom_envs[i]);
-
-    // End marker
-    nvr->data[end++] = '\0';
-
-    end = start + ((end - start + 15) & ~15);
-    /* XXX: OpenBIOS is not able to grow up a partition. Leave some space for
-       new variables. */
-    if (end < DEF_SYSTEM_SIZE)
-        end = DEF_SYSTEM_SIZE;
-    OpenBIOS_finish_partition(part_header, end - start);
-
-    // free partition
-    start = end;
-    part_header = (struct OpenBIOS_nvpart_v1 *)&nvr->data[start];
-    part_header->signature = OPENBIOS_PART_FREE;
-    pstrcpy(part_header->name, sizeof(part_header->name), "free");
-
-    end = len;
-    OpenBIOS_finish_partition(part_header, end - start);
+    /* Free space partition */
+    chrp_nvram_create_free_partition(&nvr->data[sysp_end], len - sysp_end);
 }
 
 #define OSX_NVRAM_SIGNATURE     (0x5A)
diff --git a/include/hw/nvram/chrp_nvram.h b/include/hw/nvram/chrp_nvram.h
new file mode 100644
index 0000000..18d1976
--- /dev/null
+++ b/include/hw/nvram/chrp_nvram.h
@@ -0,0 +1,24 @@
+/*
+ * Common Hardware Reference Platform NVRAM functions.
+ *
+ * This code is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef CHRP_NVRAM_H
+#define CHRP_NVRAM_H
+
+int chrp_nvram_create_system_partition(uint8_t *data, int min_len);
+int chrp_nvram_create_free_partition(uint8_t *data, int len);
+
+#endif
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 2/5] sparc: Use the new common NVRAM functions for system and free space partition
  2016-10-18 20:46 [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too Thomas Huth
  2016-10-18 20:46 ` [Qemu-devel] [PATCH 1/5] nvram: Introduce helper functions for CHRP "system" and "free space" partitions Thomas Huth
@ 2016-10-18 20:46 ` Thomas Huth
  2016-10-18 20:46 ` [Qemu-devel] [PATCH 3/5] spapr_nvram: Pre-initialize the NVRAM to support the -prom-env parameter Thomas Huth
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Thomas Huth @ 2016-10-18 20:46 UTC (permalink / raw)
  To: David Gibson, Alexander Graf, qemu-ppc, Mark Cave-Ayland
  Cc: qemu-devel, Artyom Tarasenko

The system and free space NVRAM partitions (for OpenBIOS) are created
in exactly the same way as the Mac-style CHRP NVRAM partitions, so we
can use the new common helper functions to do this job here, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/sparc/sun4m.c   | 33 ++++++---------------------------
 hw/sparc64/sun4u.c | 33 ++++++---------------------------
 2 files changed, 12 insertions(+), 54 deletions(-)

diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index b3915e4..1b8d172 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -39,6 +39,7 @@
 #include "hw/scsi/esp.h"
 #include "hw/i386/pc.h"
 #include "hw/isa/isa.h"
+#include "hw/nvram/chrp_nvram.h"
 #include "hw/nvram/fw_cfg.h"
 #include "hw/char/escc.h"
 #include "hw/empty_slot.h"
@@ -117,39 +118,17 @@ static void nvram_init(Nvram *nvram, uint8_t *macaddr,
                        int nvram_machine_id, const char *arch)
 {
     unsigned int i;
-    uint32_t start, end;
+    int sysp_end;
     uint8_t image[0x1ff0];
-    struct OpenBIOS_nvpart_v1 *part_header;
     NvramClass *k = NVRAM_GET_CLASS(nvram);
 
     memset(image, '\0', sizeof(image));
 
-    start = 0;
+    /* OpenBIOS nvram variables partition */
+    sysp_end = chrp_nvram_create_system_partition(image, 0);
 
-    // OpenBIOS nvram variables
-    // Variable partition
-    part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
-    part_header->signature = OPENBIOS_PART_SYSTEM;
-    pstrcpy(part_header->name, sizeof(part_header->name), "system");
-
-    end = start + sizeof(struct OpenBIOS_nvpart_v1);
-    for (i = 0; i < nb_prom_envs; i++)
-        end = OpenBIOS_set_var(image, end, prom_envs[i]);
-
-    // End marker
-    image[end++] = '\0';
-
-    end = start + ((end - start + 15) & ~15);
-    OpenBIOS_finish_partition(part_header, end - start);
-
-    // free partition
-    start = end;
-    part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
-    part_header->signature = OPENBIOS_PART_FREE;
-    pstrcpy(part_header->name, sizeof(part_header->name), "free");
-
-    end = 0x1fd0;
-    OpenBIOS_finish_partition(part_header, end - start);
+    /* Free space partition */
+    chrp_nvram_create_free_partition(&image[sysp_end], 0x1fd0 - sysp_end);
 
     Sun_init_header((struct Sun_nvram *)&image[0x1fd8], macaddr,
                     nvram_machine_id);
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 3165e18..aabb30a 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -37,6 +37,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/boards.h"
 #include "hw/nvram/openbios_firmware_abi.h"
+#include "hw/nvram/chrp_nvram.h"
 #include "hw/nvram/fw_cfg.h"
 #include "hw/sysbus.h"
 #include "hw/ide.h"
@@ -124,39 +125,17 @@ static int sun4u_NVRAM_set_params(Nvram *nvram, uint16_t NVRAM_size,
                                   const uint8_t *macaddr)
 {
     unsigned int i;
-    uint32_t start, end;
+    int sysp_end;
     uint8_t image[0x1ff0];
-    struct OpenBIOS_nvpart_v1 *part_header;
     NvramClass *k = NVRAM_GET_CLASS(nvram);
 
     memset(image, '\0', sizeof(image));
 
-    start = 0;
+    /* OpenBIOS nvram variables partition */
+    sysp_end = chrp_nvram_create_system_partition(image, 0);
 
-    // OpenBIOS nvram variables
-    // Variable partition
-    part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
-    part_header->signature = OPENBIOS_PART_SYSTEM;
-    pstrcpy(part_header->name, sizeof(part_header->name), "system");
-
-    end = start + sizeof(struct OpenBIOS_nvpart_v1);
-    for (i = 0; i < nb_prom_envs; i++)
-        end = OpenBIOS_set_var(image, end, prom_envs[i]);
-
-    // End marker
-    image[end++] = '\0';
-
-    end = start + ((end - start + 15) & ~15);
-    OpenBIOS_finish_partition(part_header, end - start);
-
-    // free partition
-    start = end;
-    part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
-    part_header->signature = OPENBIOS_PART_FREE;
-    pstrcpy(part_header->name, sizeof(part_header->name), "free");
-
-    end = 0x1fd0;
-    OpenBIOS_finish_partition(part_header, end - start);
+    /* Free space partition */
+    chrp_nvram_create_free_partition(&image[sysp_end], 0x1fd0 - sysp_end);
 
     Sun_init_header((struct Sun_nvram *)&image[0x1fd8], macaddr, 0x80);
 
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 3/5] spapr_nvram: Pre-initialize the NVRAM to support the -prom-env parameter
  2016-10-18 20:46 [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too Thomas Huth
  2016-10-18 20:46 ` [Qemu-devel] [PATCH 1/5] nvram: Introduce helper functions for CHRP "system" and "free space" partitions Thomas Huth
  2016-10-18 20:46 ` [Qemu-devel] [PATCH 2/5] sparc: Use the new common NVRAM functions for system and free space partition Thomas Huth
@ 2016-10-18 20:46 ` Thomas Huth
  2016-10-18 20:46 ` [Qemu-devel] [PATCH 4/5] nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch] Thomas Huth
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Thomas Huth @ 2016-10-18 20:46 UTC (permalink / raw)
  To: David Gibson, Alexander Graf, qemu-ppc, Mark Cave-Ayland
  Cc: qemu-devel, Artyom Tarasenko

In case we do not load the NVRAM contents from a file, use the new
CHRP NVRAM helper functions to pre-initialize the NVRAM partitions.
This way we can support the "-prom-env" parameter of QEMU on the
pseries machine, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/nvram/spapr_nvram.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/nvram/spapr_nvram.c b/hw/nvram/spapr_nvram.c
index 4de5f70..36a9188 100644
--- a/hw/nvram/spapr_nvram.c
+++ b/hw/nvram/spapr_nvram.c
@@ -31,6 +31,7 @@
 #include "sysemu/block-backend.h"
 #include "sysemu/device_tree.h"
 #include "hw/sysbus.h"
+#include "hw/nvram/chrp_nvram.h"
 #include "hw/ppc/spapr.h"
 #include "hw/ppc/spapr_vio.h"
 
@@ -162,6 +163,11 @@ static void spapr_nvram_realize(VIOsPAPRDevice *dev, Error **errp)
             error_setg(errp, "can't read spapr-nvram contents");
             return;
         }
+    } else {
+        /* Create a system partition to pass the -prom-env variables */
+        chrp_nvram_create_system_partition(nvram->buf, MIN_NVRAM_SIZE / 4);
+        chrp_nvram_create_free_partition(&nvram->buf[MIN_NVRAM_SIZE / 4],
+                                         nvram->size - MIN_NVRAM_SIZE / 4);
     }
 
     spapr_rtas_register(RTAS_NVRAM_FETCH, "nvram-fetch", rtas_nvram_fetch);
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 4/5] nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch]
  2016-10-18 20:46 [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too Thomas Huth
                   ` (2 preceding siblings ...)
  2016-10-18 20:46 ` [Qemu-devel] [PATCH 3/5] spapr_nvram: Pre-initialize the NVRAM to support the -prom-env parameter Thomas Huth
@ 2016-10-18 20:46 ` Thomas Huth
  2016-10-18 20:46 ` [Qemu-devel] [PATCH 5/5] nvram: Rename openbios_firmware_abi.h into sun_nvram.h Thomas Huth
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Thomas Huth @ 2016-10-18 20:46 UTC (permalink / raw)
  To: David Gibson, Alexander Graf, qemu-ppc, Mark Cave-Ayland
  Cc: qemu-devel, Artyom Tarasenko

Everything that is related to CHRP NVRAM should rather reside in
chrp_nvram.c / chrp_nvram.h instead of openbios_firmware_abi.h.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/nvram/chrp_nvram.c                    | 31 +++++++++++++++---------
 hw/nvram/mac_nvram.c                     |  7 +++---
 include/hw/nvram/chrp_nvram.h            | 30 +++++++++++++++++++++++
 include/hw/nvram/openbios_firmware_abi.h | 41 --------------------------------
 tests/postcopy-test.c                    |  8 +++----
 5 files changed, 57 insertions(+), 60 deletions(-)

diff --git a/hw/nvram/chrp_nvram.c b/hw/nvram/chrp_nvram.c
index f6183ed..3837510 100644
--- a/hw/nvram/chrp_nvram.c
+++ b/hw/nvram/chrp_nvram.c
@@ -23,26 +23,35 @@
 #include "qemu/cutils.h"
 #include "hw/hw.h"
 #include "hw/nvram/chrp_nvram.h"
-#include "hw/nvram/openbios_firmware_abi.h"
 #include "sysemu/sysemu.h"
 
+static int chrp_nvram_set_var(uint8_t *nvram, int addr, const char *str)
+{
+    int len;
+
+    len = strlen(str) + 1;
+    memcpy(&nvram[addr], str, len);
+
+    return addr + len;
+}
+
 /**
  * Create a "system partition", used for the Open Firmware
  * environment variables.
  */
 int chrp_nvram_create_system_partition(uint8_t *data, int min_len)
 {
-    struct OpenBIOS_nvpart_v1 *part_header;
+    ChrpNvramPartHdr *part_header;
     unsigned int i;
     int end;
 
-    part_header = (struct OpenBIOS_nvpart_v1 *)data;
-    part_header->signature = OPENBIOS_PART_SYSTEM;
+    part_header = (ChrpNvramPartHdr *)data;
+    part_header->signature = CHRP_NVPART_SYSTEM;
     pstrcpy(part_header->name, sizeof(part_header->name), "system");
 
-    end = sizeof(struct OpenBIOS_nvpart_v1);
+    end = sizeof(ChrpNvramPartHdr);
     for (i = 0; i < nb_prom_envs; i++) {
-        end = OpenBIOS_set_var(data, end, prom_envs[i]);
+        end = chrp_nvram_set_var(data, end, prom_envs[i]);
     }
 
     /* End marker */
@@ -54,7 +63,7 @@ int chrp_nvram_create_system_partition(uint8_t *data, int min_len)
     if (end < min_len) {
         end = min_len;
     }
-    OpenBIOS_finish_partition(part_header, end);
+    chrp_nvram_finish_partition(part_header, end);
 
     return end;
 }
@@ -64,13 +73,13 @@ int chrp_nvram_create_system_partition(uint8_t *data, int min_len)
  */
 int chrp_nvram_create_free_partition(uint8_t *data, int len)
 {
-    struct OpenBIOS_nvpart_v1 *part_header;
+    ChrpNvramPartHdr *part_header;
 
-    part_header = (struct OpenBIOS_nvpart_v1 *)data;
-    part_header->signature = OPENBIOS_PART_FREE;
+    part_header = (ChrpNvramPartHdr *)data;
+    part_header->signature = CHRP_NVPART_FREE;
     pstrcpy(part_header->name, sizeof(part_header->name), "free");
 
-    OpenBIOS_finish_partition(part_header, len);
+    chrp_nvram_finish_partition(part_header, len);
 
     return len;
 }
diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c
index c0e62a5..63f9ed1 100644
--- a/hw/nvram/mac_nvram.c
+++ b/hw/nvram/mac_nvram.c
@@ -24,7 +24,6 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/nvram/openbios_firmware_abi.h"
 #include "hw/nvram/chrp_nvram.h"
 #include "hw/ppc/mac.h"
 #include "qemu/cutils.h"
@@ -163,15 +162,15 @@ static void pmac_format_nvram_partition_osx(MacIONVRAMState *nvr, int off,
                                             int len)
 {
     uint32_t start = off;
-    struct OpenBIOS_nvpart_v1 *part_header;
+    ChrpNvramPartHdr *part_header;
     unsigned char *data = &nvr->data[start];
 
     /* empty partition */
-    part_header = (struct OpenBIOS_nvpart_v1 *)data;
+    part_header = (ChrpNvramPartHdr *)data;
     part_header->signature = OSX_NVRAM_SIGNATURE;
     pstrcpy(part_header->name, sizeof(part_header->name), "wwwwwwwwwwww");
 
-    OpenBIOS_finish_partition(part_header, len);
+    chrp_nvram_finish_partition(part_header, len);
 
     /* Generation */
     stl_be_p(&data[20], 2);
diff --git a/include/hw/nvram/chrp_nvram.h b/include/hw/nvram/chrp_nvram.h
index 18d1976..b4f5b2b 100644
--- a/include/hw/nvram/chrp_nvram.h
+++ b/include/hw/nvram/chrp_nvram.h
@@ -18,6 +18,36 @@
 #ifndef CHRP_NVRAM_H
 #define CHRP_NVRAM_H
 
+/* OpenBIOS NVRAM partition */
+typedef struct {
+    uint8_t signature;
+    uint8_t checksum;
+    uint16_t len;       /* Big endian, length divided by 16 */
+    char name[12];
+} ChrpNvramPartHdr;
+
+#define CHRP_NVPART_SYSTEM 0x70
+#define CHRP_NVPART_FREE 0x7f
+
+static inline void
+chrp_nvram_finish_partition(ChrpNvramPartHdr *header, uint32_t size)
+{
+    unsigned int i, sum;
+    uint8_t *tmpptr;
+
+    /* Length divided by 16 */
+    header->len = cpu_to_be16(size >> 4);
+
+    /* Checksum */
+    tmpptr = (uint8_t *)header;
+    sum = *tmpptr;
+    for (i = 0; i < 14; i++) {
+        sum += tmpptr[2 + i];
+        sum = (sum + ((sum & 0xff00) >> 8)) & 0xff;
+    }
+    header->checksum = sum & 0xff;
+}
+
 int chrp_nvram_create_system_partition(uint8_t *data, int min_len);
 int chrp_nvram_create_free_partition(uint8_t *data, int len);
 
diff --git a/include/hw/nvram/openbios_firmware_abi.h b/include/hw/nvram/openbios_firmware_abi.h
index 74cfd56..27ce9f4 100644
--- a/include/hw/nvram/openbios_firmware_abi.h
+++ b/include/hw/nvram/openbios_firmware_abi.h
@@ -1,47 +1,6 @@
 #ifndef OPENBIOS_FIRMWARE_ABI_H
 #define OPENBIOS_FIRMWARE_ABI_H
 
-/* OpenBIOS NVRAM partition */
-struct OpenBIOS_nvpart_v1 {
-    uint8_t signature;
-    uint8_t checksum;
-    uint16_t len; // BE, length divided by 16
-    char name[12];
-};
-
-#define OPENBIOS_PART_SYSTEM 0x70
-#define OPENBIOS_PART_FREE 0x7f
-
-static inline void
-OpenBIOS_finish_partition(struct OpenBIOS_nvpart_v1 *header, uint32_t size)
-{
-    unsigned int i, sum;
-    uint8_t *tmpptr;
-
-    // Length divided by 16
-    header->len = cpu_to_be16(size >> 4);
-
-    // Checksum
-    tmpptr = (uint8_t *)header;
-    sum = *tmpptr;
-    for (i = 0; i < 14; i++) {
-        sum += tmpptr[2 + i];
-        sum = (sum + ((sum & 0xff00) >> 8)) & 0xff;
-    }
-    header->checksum = sum & 0xff;
-}
-
-static inline uint32_t
-OpenBIOS_set_var(uint8_t *nvram, uint32_t addr, const char *str)
-{
-    uint32_t len;
-
-    len = strlen(str) + 1;
-    memcpy(&nvram[addr], str, len);
-
-    return addr + len;
-}
-
 /* Sun IDPROM structure at the end of NVRAM */
 /* from http://www.squirrel.com/squirrel/sun-nvram-hostid.faq.html */
 struct Sun_nvram {
diff --git a/tests/postcopy-test.c b/tests/postcopy-test.c
index 41ed1a9..d6613c5 100644
--- a/tests/postcopy-test.c
+++ b/tests/postcopy-test.c
@@ -18,7 +18,7 @@
 #include "qemu/sockets.h"
 #include "sysemu/char.h"
 #include "sysemu/sysemu.h"
-#include "hw/nvram/openbios_firmware_abi.h"
+#include "hw/nvram/chrp_nvram.h"
 
 #define MIN_NVRAM_SIZE 8192 /* from spapr_nvram.c */
 
@@ -137,15 +137,15 @@ static void init_bootfile_ppc(const char *bootpath)
 {
     FILE *bootfile;
     char buf[MIN_NVRAM_SIZE];
-    struct OpenBIOS_nvpart_v1 *header = (struct OpenBIOS_nvpart_v1 *)buf;
+    ChrpNvramPartHdr *header = (ChrpNvramPartHdr *)buf;
 
     memset(buf, 0, MIN_NVRAM_SIZE);
 
     /* Create a "common" partition in nvram to store boot-command property */
 
-    header->signature = OPENBIOS_PART_SYSTEM;
+    header->signature = CHRP_NVPART_SYSTEM;
     memcpy(header->name, "common", 6);
-    OpenBIOS_finish_partition(header, MIN_NVRAM_SIZE);
+    chrp_nvram_finish_partition(header, MIN_NVRAM_SIZE);
 
     /* FW_MAX_SIZE is 4MB, but slof.bin is only 900KB,
      * so let's modify memory between 1MB and 100MB
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 5/5] nvram: Rename openbios_firmware_abi.h into sun_nvram.h
  2016-10-18 20:46 [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too Thomas Huth
                   ` (3 preceding siblings ...)
  2016-10-18 20:46 ` [Qemu-devel] [PATCH 4/5] nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch] Thomas Huth
@ 2016-10-18 20:46 ` Thomas Huth
  2016-10-19  2:16 ` [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too David Gibson
  2016-10-23 15:19 ` [Qemu-devel] " Mark Cave-Ayland
  6 siblings, 0 replies; 14+ messages in thread
From: Thomas Huth @ 2016-10-18 20:46 UTC (permalink / raw)
  To: David Gibson, Alexander Graf, qemu-ppc, Mark Cave-Ayland
  Cc: qemu-devel, Artyom Tarasenko

The header now only contains inline functions related to the
Sun NVRAM, so the a name like sun_nvram.h seems to be more
appropriate now.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/sparc/sun4m.c                                          | 2 +-
 hw/sparc64/sun4u.c                                        | 2 +-
 include/hw/nvram/{openbios_firmware_abi.h => sun_nvram.h} | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)
 rename include/hw/nvram/{openbios_firmware_abi.h => sun_nvram.h} (90%)

diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 1b8d172..6224288 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -35,10 +35,10 @@
 #include "sysemu/sysemu.h"
 #include "net/net.h"
 #include "hw/boards.h"
-#include "hw/nvram/openbios_firmware_abi.h"
 #include "hw/scsi/esp.h"
 #include "hw/i386/pc.h"
 #include "hw/isa/isa.h"
+#include "hw/nvram/sun_nvram.h"
 #include "hw/nvram/chrp_nvram.h"
 #include "hw/nvram/fw_cfg.h"
 #include "hw/char/escc.h"
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index aabb30a..3708be2 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -36,7 +36,7 @@
 #include "qemu/timer.h"
 #include "sysemu/sysemu.h"
 #include "hw/boards.h"
-#include "hw/nvram/openbios_firmware_abi.h"
+#include "hw/nvram/sun_nvram.h"
 #include "hw/nvram/chrp_nvram.h"
 #include "hw/nvram/fw_cfg.h"
 #include "hw/sysbus.h"
diff --git a/include/hw/nvram/openbios_firmware_abi.h b/include/hw/nvram/sun_nvram.h
similarity index 90%
rename from include/hw/nvram/openbios_firmware_abi.h
rename to include/hw/nvram/sun_nvram.h
index 27ce9f4..68eaa60 100644
--- a/include/hw/nvram/openbios_firmware_abi.h
+++ b/include/hw/nvram/sun_nvram.h
@@ -1,5 +1,5 @@
-#ifndef OPENBIOS_FIRMWARE_ABI_H
-#define OPENBIOS_FIRMWARE_ABI_H
+#ifndef SUN_NVRAM_H
+#define SUN_NVRAM_H
 
 /* Sun IDPROM structure at the end of NVRAM */
 /* from http://www.squirrel.com/squirrel/sun-nvram-hostid.faq.html */
@@ -31,4 +31,4 @@ Sun_init_header(struct Sun_nvram *header, const uint8_t *macaddr, int machine_id
 
     header->checksum = tmp;
 }
-#endif /* OPENBIOS_FIRMWARE_ABI_H */
+#endif /* SUN_NVRAM_H */
-- 
1.8.3.1

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

* Re: [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too
  2016-10-18 20:46 [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too Thomas Huth
                   ` (4 preceding siblings ...)
  2016-10-18 20:46 ` [Qemu-devel] [PATCH 5/5] nvram: Rename openbios_firmware_abi.h into sun_nvram.h Thomas Huth
@ 2016-10-19  2:16 ` David Gibson
  2016-10-24 10:22   ` Bharata B Rao
  2016-10-23 15:19 ` [Qemu-devel] " Mark Cave-Ayland
  6 siblings, 1 reply; 14+ messages in thread
From: David Gibson @ 2016-10-19  2:16 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Alexander Graf, qemu-ppc, Mark Cave-Ayland, qemu-devel, Artyom Tarasenko

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

On Tue, Oct 18, 2016 at 10:46:39PM +0200, Thomas Huth wrote:
> The OpenBIOS NVRAM set-up is based on the layout defined in the CHRP
> (Common Hardware Reference Platform) specification. This is the same
> layout that is also used by the PAPR specification and thus by the SLOF
> firmware of the pseries machine. By refactoring the NVRAM code from
> mac_nvram.c, we can use the same functions for setting up the NVRAM
> for both, OpenBIOS and SLOF. This way we can support the "-prom-env"
> parameter of QEMU for SLOF, too, which is very useful to influence
> the firmware boot process.
> 
> Thomas Huth (5):
>   nvram: Introduce helper functions for CHRP "system" and "free space"
>     partitions
>   sparc: Use the new common NVRAM functions for system and free space
>     partition
>   spapr_nvram: Pre-initialize the NVRAM to support the -prom-env
>     parameter
>   nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch]
>   nvram: Rename openbios_firmware_abi.h into sun_nvram.h
> 
>  hw/nvram/Makefile.objs                             |  1 +
>  hw/nvram/chrp_nvram.c                              | 85 ++++++++++++++++++++++
>  hw/nvram/mac_nvram.c                               | 49 +++----------
>  hw/nvram/spapr_nvram.c                             |  6 ++
>  hw/sparc/sun4m.c                                   | 35 ++-------
>  hw/sparc64/sun4u.c                                 | 35 ++-------
>  include/hw/nvram/chrp_nvram.h                      | 54 ++++++++++++++
>  .../nvram/{openbios_firmware_abi.h => sun_nvram.h} | 47 +-----------
>  tests/postcopy-test.c                              |  8 +-
>  9 files changed, 179 insertions(+), 141 deletions(-)
>  create mode 100644 hw/nvram/chrp_nvram.c
>  create mode 100644 include/hw/nvram/chrp_nvram.h
>  rename include/hw/nvram/{openbios_firmware_abi.h => sun_nvram.h} (50%)

Series,

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

I've put it into ppc-for-2.8 tentatively.  However I'd like to get an
Acked-by from Mark for the Sparc bits before I send my next pull request.

-- 
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: 819 bytes --]

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

* Re: [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too
  2016-10-18 20:46 [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too Thomas Huth
                   ` (5 preceding siblings ...)
  2016-10-19  2:16 ` [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too David Gibson
@ 2016-10-23 15:19 ` Mark Cave-Ayland
  6 siblings, 0 replies; 14+ messages in thread
From: Mark Cave-Ayland @ 2016-10-23 15:19 UTC (permalink / raw)
  To: Thomas Huth, David Gibson, Alexander Graf, qemu-ppc
  Cc: qemu-devel, Artyom Tarasenko

On 18/10/16 21:46, Thomas Huth wrote:

> The OpenBIOS NVRAM set-up is based on the layout defined in the CHRP
> (Common Hardware Reference Platform) specification. This is the same
> layout that is also used by the PAPR specification and thus by the SLOF
> firmware of the pseries machine. By refactoring the NVRAM code from
> mac_nvram.c, we can use the same functions for setting up the NVRAM
> for both, OpenBIOS and SLOF. This way we can support the "-prom-env"
> parameter of QEMU for SLOF, too, which is very useful to influence
> the firmware boot process.
> 
> Thomas Huth (5):
>   nvram: Introduce helper functions for CHRP "system" and "free space"
>     partitions
>   sparc: Use the new common NVRAM functions for system and free space
>     partition
>   spapr_nvram: Pre-initialize the NVRAM to support the -prom-env
>     parameter
>   nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch]
>   nvram: Rename openbios_firmware_abi.h into sun_nvram.h
> 
>  hw/nvram/Makefile.objs                             |  1 +
>  hw/nvram/chrp_nvram.c                              | 85 ++++++++++++++++++++++
>  hw/nvram/mac_nvram.c                               | 49 +++----------
>  hw/nvram/spapr_nvram.c                             |  6 ++
>  hw/sparc/sun4m.c                                   | 35 ++-------
>  hw/sparc64/sun4u.c                                 | 35 ++-------
>  include/hw/nvram/chrp_nvram.h                      | 54 ++++++++++++++
>  .../nvram/{openbios_firmware_abi.h => sun_nvram.h} | 47 +-----------
>  tests/postcopy-test.c                              |  8 +-
>  9 files changed, 179 insertions(+), 141 deletions(-)
>  create mode 100644 hw/nvram/chrp_nvram.c
>  create mode 100644 include/hw/nvram/chrp_nvram.h
>  rename include/hw/nvram/{openbios_firmware_abi.h => sun_nvram.h} (50%)

Hi Thomas,

This is a great patchset! I've given it a spin here with
qemu-system-sparc/qemu-system-sparc64 and it looks good here with no
regressions for me so:

Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


ATB,

Mark.

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

* Re: [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too
  2016-10-19  2:16 ` [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too David Gibson
@ 2016-10-24 10:22   ` Bharata B Rao
  2016-10-24 10:36     ` Thomas Huth
  0 siblings, 1 reply; 14+ messages in thread
From: Bharata B Rao @ 2016-10-24 10:22 UTC (permalink / raw)
  To: David Gibson
  Cc: Thomas Huth, Mark Cave-Ayland, qemu-ppc, Alexander Graf,
	Artyom Tarasenko, qemu-devel

On Wed, Oct 19, 2016 at 7:46 AM, David Gibson <david@gibson.dropbear.id.au>
wrote:

> On Tue, Oct 18, 2016 at 10:46:39PM +0200, Thomas Huth wrote:
> > The OpenBIOS NVRAM set-up is based on the layout defined in the CHRP
> > (Common Hardware Reference Platform) specification. This is the same
> > layout that is also used by the PAPR specification and thus by the SLOF
> > firmware of the pseries machine. By refactoring the NVRAM code from
> > mac_nvram.c, we can use the same functions for setting up the NVRAM
> > for both, OpenBIOS and SLOF. This way we can support the "-prom-env"
> > parameter of QEMU for SLOF, too, which is very useful to influence
> > the firmware boot process.
> >
> > Thomas Huth (5):
> >   nvram: Introduce helper functions for CHRP "system" and "free space"
> >     partitions
> >   sparc: Use the new common NVRAM functions for system and free space
> >     partition
> >   spapr_nvram: Pre-initialize the NVRAM to support the -prom-env
> >     parameter
> >   nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch]
> >   nvram: Rename openbios_firmware_abi.h into sun_nvram.h
> >
> >  hw/nvram/Makefile.objs                             |  1 +
> >  hw/nvram/chrp_nvram.c                              | 85
> ++++++++++++++++++++++
> >  hw/nvram/mac_nvram.c                               | 49 +++----------
> >  hw/nvram/spapr_nvram.c                             |  6 ++
> >  hw/sparc/sun4m.c                                   | 35 ++-------
> >  hw/sparc64/sun4u.c                                 | 35 ++-------
> >  include/hw/nvram/chrp_nvram.h                      | 54 ++++++++++++++
> >  .../nvram/{openbios_firmware_abi.h => sun_nvram.h} | 47 +-----------
> >  tests/postcopy-test.c                              |  8 +-
> >  9 files changed, 179 insertions(+), 141 deletions(-)
> >  create mode 100644 hw/nvram/chrp_nvram.c
> >  create mode 100644 include/hw/nvram/chrp_nvram.h
> >  rename include/hw/nvram/{openbios_firmware_abi.h => sun_nvram.h} (50%)
>
> Series,
>
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
>
> I've put it into ppc-for-2.8 tentatively.  However I'd like to get an
> Acked-by from Mark for the Sparc bits before I send my next pull request.
>

I observe an early boot failure in SLOF with a commit from this patchset on
ppc-for-2.8 branch.

4e1257ed41bce16baa8a010 - spapr_nvram: Pre-initialize the NVRAM to support
the -prom-env parameter

SLOF **********************************************************************
QEMU Starting
 Build Date = Oct 19 2016 09:58:38
 FW Version = git-efd65f49929d7db7
 Press "s" to enter Open Firmware.

Populating /vdevice methods
Populating /vdevice/vty@71000000
Populating /vdevice/nvram@71000001
Populating /vdevice/v-scsi@71000002
       SCSI: Looking for devices
          8200000000000000 CD-ROM   : "QEMU     QEMU CD-ROM      2.5+"
Populating /pci@800000020000000
                     00 1000 (D) : 1033 0194    serial bus [ usb-xhci ]
                     00 0800 (D) : 1af4 1001    virtio [ block ]
                     00 0000 (D) : 1af4 1000    virtio [ net ]
Scanning USB
  XHCI: Initializing
Using default console: /vdevice/vty@71000000

  Welcome to Open Firmware

  Copyright (c) 2004, 2011 IBM Corporation All rights reserved.
  This program and the accompanying materials are made available
  under the terms of the BSD License available at
  http://www.opensource.org/licenses/bsd-license.php


Trying to load:  from: /pci@800000020000000/scsi@1 ...   Successfully loaded
error: out of memory.
out of memory
Aborted. Press any key to exit.

Regards,
Bharata.

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

* Re: [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too
  2016-10-24 10:22   ` Bharata B Rao
@ 2016-10-24 10:36     ` Thomas Huth
  2016-10-24 12:04       ` David Gibson
  0 siblings, 1 reply; 14+ messages in thread
From: Thomas Huth @ 2016-10-24 10:36 UTC (permalink / raw)
  To: Bharata B Rao, David Gibson
  Cc: Mark Cave-Ayland, qemu-ppc, Alexander Graf, Artyom Tarasenko, qemu-devel

On 24.10.2016 12:22, Bharata B Rao wrote:
> 
> On Wed, Oct 19, 2016 at 7:46 AM, David Gibson
> <david@gibson.dropbear.id.au <mailto:david@gibson.dropbear.id.au>> wrote:
> 
>     On Tue, Oct 18, 2016 at 10:46:39PM +0200, Thomas Huth wrote:
>     > The OpenBIOS NVRAM set-up is based on the layout defined in the CHRP
>     > (Common Hardware Reference Platform) specification. This is the same
>     > layout that is also used by the PAPR specification and thus by the
>     SLOF
>     > firmware of the pseries machine. By refactoring the NVRAM code from
>     > mac_nvram.c, we can use the same functions for setting up the NVRAM
>     > for both, OpenBIOS and SLOF. This way we can support the "-prom-env"
>     > parameter of QEMU for SLOF, too, which is very useful to influence
>     > the firmware boot process.
>     >
>     > Thomas Huth (5):
>     >   nvram: Introduce helper functions for CHRP "system" and "free space"
>     >     partitions
>     >   sparc: Use the new common NVRAM functions for system and free space
>     >     partition
>     >   spapr_nvram: Pre-initialize the NVRAM to support the -prom-env
>     >     parameter
>     >   nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch]
>     >   nvram: Rename openbios_firmware_abi.h into sun_nvram.h
>     >
>     >  hw/nvram/Makefile.objs                             |  1 +
>     >  hw/nvram/chrp_nvram.c                              | 85
>     ++++++++++++++++++++++
>     >  hw/nvram/mac_nvram.c                               | 49 +++----------
>     >  hw/nvram/spapr_nvram.c                             |  6 ++
>     >  hw/sparc/sun4m.c                                   | 35 ++-------
>     >  hw/sparc64/sun4u.c                                 | 35 ++-------
>     >  include/hw/nvram/chrp_nvram.h                      | 54
>     ++++++++++++++
>     >  .../nvram/{openbios_firmware_abi.h => sun_nvram.h} | 47 +-----------
>     >  tests/postcopy-test.c                              |  8 +-
>     >  9 files changed, 179 insertions(+), 141 deletions(-)
>     >  create mode 100644 hw/nvram/chrp_nvram.c
>     >  create mode 100644 include/hw/nvram/chrp_nvram.h
>     >  rename include/hw/nvram/{openbios_firmware_abi.h => sun_nvram.h}
>     (50%)
> 
>     Series,
> 
>     Reviewed-by: David Gibson <david@gibson.dropbear.id.au
>     <mailto:david@gibson.dropbear.id.au>>
> 
>     I've put it into ppc-for-2.8 tentatively.  However I'd like to get an
>     Acked-by from Mark for the Sparc bits before I send my next pull
>     request.
> 
> 
> I observe an early boot failure in SLOF with a commit from this patchset
> on ppc-for-2.8 branch.
> 
> 4e1257ed41bce16baa8a010 - spapr_nvram: Pre-initialize the NVRAM to
> support the -prom-env parameter
> 
> SLOF **********************************************************************
> QEMU Starting
>  Build Date = Oct 19 2016 09:58:38
>  FW Version = git-efd65f49929d7db7
>  Press "s" to enter Open Firmware.
> 
> Populating /vdevice methods
> Populating /vdevice/vty@71000000
> Populating /vdevice/nvram@71000001
> Populating /vdevice/v-scsi@71000002
>        SCSI: Looking for devices
>           8200000000000000 CD-ROM   : "QEMU     QEMU CD-ROM      2.5+"
> Populating /pci@800000020000000
>                      00 1000 (D) : 1033 0194    serial bus [ usb-xhci ]
>                      00 0800 (D) : 1af4 1001    virtio [ block ]
>                      00 0000 (D) : 1af4 1000    virtio [ net ]
> Scanning USB
>   XHCI: Initializing
> Using default console: /vdevice/vty@71000000
>     
>   Welcome to Open Firmware
> 
>   Copyright (c) 2004, 2011 IBM Corporation All rights reserved.
>   This program and the accompanying materials are made available
>   under the terms of the BSD License available at
>   http://www.opensource.org/licenses/bsd-license.php
> 
> 
> Trying to load:  from: /pci@800000020000000/scsi@1 ...   Successfully loaded
> error: out of memory.
> out of memory
> Aborted. Press any key to exit.

Yuck. Confirmed. Sorry for the inconvenience. Seems like SLOF does not
create the properties in the /options device tree node anymore in this case.

David, could you please unqueue the "spapr_nvram: Pre-initialize the
NVRAM to support the -prom-env parameter" patch from the ppc-for-2.8
branch until I figure out a fix for this problem? Thanks!

 Thomas

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

* Re: [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too
  2016-10-24 10:36     ` Thomas Huth
@ 2016-10-24 12:04       ` David Gibson
  2016-10-25 12:22         ` [Qemu-devel] [Qemu-ppc] " Thomas Huth
  0 siblings, 1 reply; 14+ messages in thread
From: David Gibson @ 2016-10-24 12:04 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Bharata B Rao, Mark Cave-Ayland, qemu-ppc, Alexander Graf,
	Artyom Tarasenko, qemu-devel

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

On Mon, Oct 24, 2016 at 12:36:05PM +0200, Thomas Huth wrote:
> On 24.10.2016 12:22, Bharata B Rao wrote:
> > 
> > On Wed, Oct 19, 2016 at 7:46 AM, David Gibson
> > <david@gibson.dropbear.id.au <mailto:david@gibson.dropbear.id.au>> wrote:
> > 
> >     On Tue, Oct 18, 2016 at 10:46:39PM +0200, Thomas Huth wrote:
> >     > The OpenBIOS NVRAM set-up is based on the layout defined in the CHRP
> >     > (Common Hardware Reference Platform) specification. This is the same
> >     > layout that is also used by the PAPR specification and thus by the
> >     SLOF
> >     > firmware of the pseries machine. By refactoring the NVRAM code from
> >     > mac_nvram.c, we can use the same functions for setting up the NVRAM
> >     > for both, OpenBIOS and SLOF. This way we can support the "-prom-env"
> >     > parameter of QEMU for SLOF, too, which is very useful to influence
> >     > the firmware boot process.
> >     >
> >     > Thomas Huth (5):
> >     >   nvram: Introduce helper functions for CHRP "system" and "free space"
> >     >     partitions
> >     >   sparc: Use the new common NVRAM functions for system and free space
> >     >     partition
> >     >   spapr_nvram: Pre-initialize the NVRAM to support the -prom-env
> >     >     parameter
> >     >   nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch]
> >     >   nvram: Rename openbios_firmware_abi.h into sun_nvram.h
> >     >
> >     >  hw/nvram/Makefile.objs                             |  1 +
> >     >  hw/nvram/chrp_nvram.c                              | 85
> >     ++++++++++++++++++++++
> >     >  hw/nvram/mac_nvram.c                               | 49 +++----------
> >     >  hw/nvram/spapr_nvram.c                             |  6 ++
> >     >  hw/sparc/sun4m.c                                   | 35 ++-------
> >     >  hw/sparc64/sun4u.c                                 | 35 ++-------
> >     >  include/hw/nvram/chrp_nvram.h                      | 54
> >     ++++++++++++++
> >     >  .../nvram/{openbios_firmware_abi.h => sun_nvram.h} | 47 +-----------
> >     >  tests/postcopy-test.c                              |  8 +-
> >     >  9 files changed, 179 insertions(+), 141 deletions(-)
> >     >  create mode 100644 hw/nvram/chrp_nvram.c
> >     >  create mode 100644 include/hw/nvram/chrp_nvram.h
> >     >  rename include/hw/nvram/{openbios_firmware_abi.h => sun_nvram.h}
> >     (50%)
> > 
> >     Series,
> > 
> >     Reviewed-by: David Gibson <david@gibson.dropbear.id.au
> >     <mailto:david@gibson.dropbear.id.au>>
> > 
> >     I've put it into ppc-for-2.8 tentatively.  However I'd like to get an
> >     Acked-by from Mark for the Sparc bits before I send my next pull
> >     request.
> > 
> > 
> > I observe an early boot failure in SLOF with a commit from this patchset
> > on ppc-for-2.8 branch.
> > 
> > 4e1257ed41bce16baa8a010 - spapr_nvram: Pre-initialize the NVRAM to
> > support the -prom-env parameter
> > 
> > SLOF **********************************************************************
> > QEMU Starting
> >  Build Date = Oct 19 2016 09:58:38
> >  FW Version = git-efd65f49929d7db7
> >  Press "s" to enter Open Firmware.
> > 
> > Populating /vdevice methods
> > Populating /vdevice/vty@71000000
> > Populating /vdevice/nvram@71000001
> > Populating /vdevice/v-scsi@71000002
> >        SCSI: Looking for devices
> >           8200000000000000 CD-ROM   : "QEMU     QEMU CD-ROM      2.5+"
> > Populating /pci@800000020000000
> >                      00 1000 (D) : 1033 0194    serial bus [ usb-xhci ]
> >                      00 0800 (D) : 1af4 1001    virtio [ block ]
> >                      00 0000 (D) : 1af4 1000    virtio [ net ]
> > Scanning USB
> >   XHCI: Initializing
> > Using default console: /vdevice/vty@71000000
> >     
> >   Welcome to Open Firmware
> > 
> >   Copyright (c) 2004, 2011 IBM Corporation All rights reserved.
> >   This program and the accompanying materials are made available
> >   under the terms of the BSD License available at
> >   http://www.opensource.org/licenses/bsd-license.php
> > 
> > 
> > Trying to load:  from: /pci@800000020000000/scsi@1 ...   Successfully loaded
> > error: out of memory.
> > out of memory
> > Aborted. Press any key to exit.
> 
> Yuck. Confirmed. Sorry for the inconvenience. Seems like SLOF does not
> create the properties in the /options device tree node anymore in this case.
> 
> David, could you please unqueue the "spapr_nvram: Pre-initialize the
> NVRAM to support the -prom-env parameter" patch from the ppc-for-2.8
> branch until I figure out a fix for this problem? Thanks!

Done.

-- 
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: 819 bytes --]

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

* Re: [Qemu-devel] [Qemu-ppc] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too
  2016-10-24 12:04       ` David Gibson
@ 2016-10-25 12:22         ` Thomas Huth
  2016-10-26  0:03           ` David Gibson
  0 siblings, 1 reply; 14+ messages in thread
From: Thomas Huth @ 2016-10-25 12:22 UTC (permalink / raw)
  To: David Gibson; +Cc: qemu-devel, qemu-ppc, Bharata B Rao, Artyom Tarasenko

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

On 24.10.2016 14:04, David Gibson wrote:
> On Mon, Oct 24, 2016 at 12:36:05PM +0200, Thomas Huth wrote:
>> On 24.10.2016 12:22, Bharata B Rao wrote:
>>>
>>> On Wed, Oct 19, 2016 at 7:46 AM, David Gibson
>>> <david@gibson.dropbear.id.au <mailto:david@gibson.dropbear.id.au>> wrote:
>>>
>>>     On Tue, Oct 18, 2016 at 10:46:39PM +0200, Thomas Huth wrote:
>>>     > The OpenBIOS NVRAM set-up is based on the layout defined in the CHRP
>>>     > (Common Hardware Reference Platform) specification. This is the same
>>>     > layout that is also used by the PAPR specification and thus by the
>>>     SLOF
>>>     > firmware of the pseries machine. By refactoring the NVRAM code from
>>>     > mac_nvram.c, we can use the same functions for setting up the NVRAM
>>>     > for both, OpenBIOS and SLOF. This way we can support the "-prom-env"
>>>     > parameter of QEMU for SLOF, too, which is very useful to influence
>>>     > the firmware boot process.
>>>     >
>>>     > Thomas Huth (5):
>>>     >   nvram: Introduce helper functions for CHRP "system" and "free space"
>>>     >     partitions
>>>     >   sparc: Use the new common NVRAM functions for system and free space
>>>     >     partition
>>>     >   spapr_nvram: Pre-initialize the NVRAM to support the -prom-env
>>>     >     parameter
>>>     >   nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch]
>>>     >   nvram: Rename openbios_firmware_abi.h into sun_nvram.h
>>>     >
>>>     >  hw/nvram/Makefile.objs                             |  1 +
>>>     >  hw/nvram/chrp_nvram.c                              | 85
>>>     ++++++++++++++++++++++
>>>     >  hw/nvram/mac_nvram.c                               | 49 +++----------
>>>     >  hw/nvram/spapr_nvram.c                             |  6 ++
>>>     >  hw/sparc/sun4m.c                                   | 35 ++-------
>>>     >  hw/sparc64/sun4u.c                                 | 35 ++-------
>>>     >  include/hw/nvram/chrp_nvram.h                      | 54
>>>     ++++++++++++++
>>>     >  .../nvram/{openbios_firmware_abi.h => sun_nvram.h} | 47 +-----------
>>>     >  tests/postcopy-test.c                              |  8 +-
>>>     >  9 files changed, 179 insertions(+), 141 deletions(-)
>>>     >  create mode 100644 hw/nvram/chrp_nvram.c
>>>     >  create mode 100644 include/hw/nvram/chrp_nvram.h
>>>     >  rename include/hw/nvram/{openbios_firmware_abi.h => sun_nvram.h}
>>>     (50%)
>>>
>>>     Series,
>>>
>>>     Reviewed-by: David Gibson <david@gibson.dropbear.id.au
>>>     <mailto:david@gibson.dropbear.id.au>>
>>>
>>>     I've put it into ppc-for-2.8 tentatively.  However I'd like to get an
>>>     Acked-by from Mark for the Sparc bits before I send my next pull
>>>     request.
>>>
>>>
>>> I observe an early boot failure in SLOF with a commit from this patchset
>>> on ppc-for-2.8 branch.
>>>
>>> 4e1257ed41bce16baa8a010 - spapr_nvram: Pre-initialize the NVRAM to
>>> support the -prom-env parameter
>>>
>>> SLOF **********************************************************************
>>> QEMU Starting
>>>  Build Date = Oct 19 2016 09:58:38
>>>  FW Version = git-efd65f49929d7db7
>>>  Press "s" to enter Open Firmware.
>>>
>>> Populating /vdevice methods
>>> Populating /vdevice/vty@71000000
>>> Populating /vdevice/nvram@71000001
>>> Populating /vdevice/v-scsi@71000002
>>>        SCSI: Looking for devices
>>>           8200000000000000 CD-ROM   : "QEMU     QEMU CD-ROM      2.5+"
>>> Populating /pci@800000020000000
>>>                      00 1000 (D) : 1033 0194    serial bus [ usb-xhci ]
>>>                      00 0800 (D) : 1af4 1001    virtio [ block ]
>>>                      00 0000 (D) : 1af4 1000    virtio [ net ]
>>> Scanning USB
>>>   XHCI: Initializing
>>> Using default console: /vdevice/vty@71000000
>>>     
>>>   Welcome to Open Firmware
>>>
>>>   Copyright (c) 2004, 2011 IBM Corporation All rights reserved.
>>>   This program and the accompanying materials are made available
>>>   under the terms of the BSD License available at
>>>   http://www.opensource.org/licenses/bsd-license.php
>>>
>>>
>>> Trying to load:  from: /pci@800000020000000/scsi@1 ...   Successfully loaded
>>> error: out of memory.
>>> out of memory
>>> Aborted. Press any key to exit.
>>
>> Yuck. Confirmed. Sorry for the inconvenience. Seems like SLOF does not
>> create the properties in the /options device tree node anymore in this case.
>>
>> David, could you please unqueue the "spapr_nvram: Pre-initialize the
>> NVRAM to support the -prom-env parameter" patch from the ppc-for-2.8
>> branch until I figure out a fix for this problem? Thanks!
> 
> Done.

FYI, SLOF patch to fix this issue is on the way:
https://patchwork.ozlabs.org/patch/686426/

 Thomas



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [Qemu-devel] [Qemu-ppc] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too
  2016-10-25 12:22         ` [Qemu-devel] [Qemu-ppc] " Thomas Huth
@ 2016-10-26  0:03           ` David Gibson
  2016-10-26  6:35             ` Thomas Huth
  0 siblings, 1 reply; 14+ messages in thread
From: David Gibson @ 2016-10-26  0:03 UTC (permalink / raw)
  To: Thomas Huth; +Cc: qemu-devel, qemu-ppc, Bharata B Rao, Artyom Tarasenko

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

On Tue, Oct 25, 2016 at 02:22:08PM +0200, Thomas Huth wrote:
> On 24.10.2016 14:04, David Gibson wrote:
> > On Mon, Oct 24, 2016 at 12:36:05PM +0200, Thomas Huth wrote:
> >> On 24.10.2016 12:22, Bharata B Rao wrote:
> >>>
> >>> On Wed, Oct 19, 2016 at 7:46 AM, David Gibson
> >>> <david@gibson.dropbear.id.au <mailto:david@gibson.dropbear.id.au>> wrote:
> >>>
> >>>     On Tue, Oct 18, 2016 at 10:46:39PM +0200, Thomas Huth wrote:
> >>>     > The OpenBIOS NVRAM set-up is based on the layout defined in the CHRP
> >>>     > (Common Hardware Reference Platform) specification. This is the same
> >>>     > layout that is also used by the PAPR specification and thus by the
> >>>     SLOF
> >>>     > firmware of the pseries machine. By refactoring the NVRAM code from
> >>>     > mac_nvram.c, we can use the same functions for setting up the NVRAM
> >>>     > for both, OpenBIOS and SLOF. This way we can support the "-prom-env"
> >>>     > parameter of QEMU for SLOF, too, which is very useful to influence
> >>>     > the firmware boot process.
> >>>     >
> >>>     > Thomas Huth (5):
> >>>     >   nvram: Introduce helper functions for CHRP "system" and "free space"
> >>>     >     partitions
> >>>     >   sparc: Use the new common NVRAM functions for system and free space
> >>>     >     partition
> >>>     >   spapr_nvram: Pre-initialize the NVRAM to support the -prom-env
> >>>     >     parameter
> >>>     >   nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch]
> >>>     >   nvram: Rename openbios_firmware_abi.h into sun_nvram.h
> >>>     >
> >>>     >  hw/nvram/Makefile.objs                             |  1 +
> >>>     >  hw/nvram/chrp_nvram.c                              | 85
> >>>     ++++++++++++++++++++++
> >>>     >  hw/nvram/mac_nvram.c                               | 49 +++----------
> >>>     >  hw/nvram/spapr_nvram.c                             |  6 ++
> >>>     >  hw/sparc/sun4m.c                                   | 35 ++-------
> >>>     >  hw/sparc64/sun4u.c                                 | 35 ++-------
> >>>     >  include/hw/nvram/chrp_nvram.h                      | 54
> >>>     ++++++++++++++
> >>>     >  .../nvram/{openbios_firmware_abi.h => sun_nvram.h} | 47 +-----------
> >>>     >  tests/postcopy-test.c                              |  8 +-
> >>>     >  9 files changed, 179 insertions(+), 141 deletions(-)
> >>>     >  create mode 100644 hw/nvram/chrp_nvram.c
> >>>     >  create mode 100644 include/hw/nvram/chrp_nvram.h
> >>>     >  rename include/hw/nvram/{openbios_firmware_abi.h => sun_nvram.h}
> >>>     (50%)
> >>>
> >>>     Series,
> >>>
> >>>     Reviewed-by: David Gibson <david@gibson.dropbear.id.au
> >>>     <mailto:david@gibson.dropbear.id.au>>
> >>>
> >>>     I've put it into ppc-for-2.8 tentatively.  However I'd like to get an
> >>>     Acked-by from Mark for the Sparc bits before I send my next pull
> >>>     request.
> >>>
> >>>
> >>> I observe an early boot failure in SLOF with a commit from this patchset
> >>> on ppc-for-2.8 branch.
> >>>
> >>> 4e1257ed41bce16baa8a010 - spapr_nvram: Pre-initialize the NVRAM to
> >>> support the -prom-env parameter
> >>>
> >>> SLOF **********************************************************************
> >>> QEMU Starting
> >>>  Build Date = Oct 19 2016 09:58:38
> >>>  FW Version = git-efd65f49929d7db7
> >>>  Press "s" to enter Open Firmware.
> >>>
> >>> Populating /vdevice methods
> >>> Populating /vdevice/vty@71000000
> >>> Populating /vdevice/nvram@71000001
> >>> Populating /vdevice/v-scsi@71000002
> >>>        SCSI: Looking for devices
> >>>           8200000000000000 CD-ROM   : "QEMU     QEMU CD-ROM      2.5+"
> >>> Populating /pci@800000020000000
> >>>                      00 1000 (D) : 1033 0194    serial bus [ usb-xhci ]
> >>>                      00 0800 (D) : 1af4 1001    virtio [ block ]
> >>>                      00 0000 (D) : 1af4 1000    virtio [ net ]
> >>> Scanning USB
> >>>   XHCI: Initializing
> >>> Using default console: /vdevice/vty@71000000
> >>>     
> >>>   Welcome to Open Firmware
> >>>
> >>>   Copyright (c) 2004, 2011 IBM Corporation All rights reserved.
> >>>   This program and the accompanying materials are made available
> >>>   under the terms of the BSD License available at
> >>>   http://www.opensource.org/licenses/bsd-license.php
> >>>
> >>>
> >>> Trying to load:  from: /pci@800000020000000/scsi@1 ...   Successfully loaded
> >>> error: out of memory.
> >>> out of memory
> >>> Aborted. Press any key to exit.
> >>
> >> Yuck. Confirmed. Sorry for the inconvenience. Seems like SLOF does not
> >> create the properties in the /options device tree node anymore in this case.
> >>
> >> David, could you please unqueue the "spapr_nvram: Pre-initialize the
> >> NVRAM to support the -prom-env parameter" patch from the ppc-for-2.8
> >> branch until I figure out a fix for this problem? Thanks!
> > 
> > Done.
> 
> FYI, SLOF patch to fix this issue is on the way:
> https://patchwork.ozlabs.org/patch/686426/

Ok.  So it was a matter of this change exposing a bug in SLOF, rather
than being buggy of itself?

-- 
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: 819 bytes --]

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

* Re: [Qemu-devel] [Qemu-ppc] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too
  2016-10-26  0:03           ` David Gibson
@ 2016-10-26  6:35             ` Thomas Huth
  0 siblings, 0 replies; 14+ messages in thread
From: Thomas Huth @ 2016-10-26  6:35 UTC (permalink / raw)
  To: David Gibson; +Cc: qemu-devel, qemu-ppc, Bharata B Rao, Artyom Tarasenko

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

On 26.10.2016 02:03, David Gibson wrote:
> On Tue, Oct 25, 2016 at 02:22:08PM +0200, Thomas Huth wrote:
>> On 24.10.2016 14:04, David Gibson wrote:
>>> On Mon, Oct 24, 2016 at 12:36:05PM +0200, Thomas Huth wrote:
>>>> On 24.10.2016 12:22, Bharata B Rao wrote:
>>>>>
>>>>> On Wed, Oct 19, 2016 at 7:46 AM, David Gibson
>>>>> <david@gibson.dropbear.id.au <mailto:david@gibson.dropbear.id.au>> wrote:
>>>>>
>>>>>     On Tue, Oct 18, 2016 at 10:46:39PM +0200, Thomas Huth wrote:
>>>>>     > The OpenBIOS NVRAM set-up is based on the layout defined in the CHRP
>>>>>     > (Common Hardware Reference Platform) specification. This is the same
>>>>>     > layout that is also used by the PAPR specification and thus by the
>>>>>     SLOF
>>>>>     > firmware of the pseries machine. By refactoring the NVRAM code from
>>>>>     > mac_nvram.c, we can use the same functions for setting up the NVRAM
>>>>>     > for both, OpenBIOS and SLOF. This way we can support the "-prom-env"
>>>>>     > parameter of QEMU for SLOF, too, which is very useful to influence
>>>>>     > the firmware boot process.
>>>>>     >
>>>>>     > Thomas Huth (5):
>>>>>     >   nvram: Introduce helper functions for CHRP "system" and "free space"
>>>>>     >     partitions
>>>>>     >   sparc: Use the new common NVRAM functions for system and free space
>>>>>     >     partition
>>>>>     >   spapr_nvram: Pre-initialize the NVRAM to support the -prom-env
>>>>>     >     parameter
>>>>>     >   nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch]
>>>>>     >   nvram: Rename openbios_firmware_abi.h into sun_nvram.h
>>>>>     >
>>>>>     >  hw/nvram/Makefile.objs                             |  1 +
>>>>>     >  hw/nvram/chrp_nvram.c                              | 85
>>>>>     ++++++++++++++++++++++
>>>>>     >  hw/nvram/mac_nvram.c                               | 49 +++----------
>>>>>     >  hw/nvram/spapr_nvram.c                             |  6 ++
>>>>>     >  hw/sparc/sun4m.c                                   | 35 ++-------
>>>>>     >  hw/sparc64/sun4u.c                                 | 35 ++-------
>>>>>     >  include/hw/nvram/chrp_nvram.h                      | 54
>>>>>     ++++++++++++++
>>>>>     >  .../nvram/{openbios_firmware_abi.h => sun_nvram.h} | 47 +-----------
>>>>>     >  tests/postcopy-test.c                              |  8 +-
>>>>>     >  9 files changed, 179 insertions(+), 141 deletions(-)
>>>>>     >  create mode 100644 hw/nvram/chrp_nvram.c
>>>>>     >  create mode 100644 include/hw/nvram/chrp_nvram.h
>>>>>     >  rename include/hw/nvram/{openbios_firmware_abi.h => sun_nvram.h}
>>>>>     (50%)
>>>>>
>>>>>     Series,
>>>>>
>>>>>     Reviewed-by: David Gibson <david@gibson.dropbear.id.au
>>>>>     <mailto:david@gibson.dropbear.id.au>>
>>>>>
>>>>>     I've put it into ppc-for-2.8 tentatively.  However I'd like to get an
>>>>>     Acked-by from Mark for the Sparc bits before I send my next pull
>>>>>     request.
>>>>>
>>>>>
>>>>> I observe an early boot failure in SLOF with a commit from this patchset
>>>>> on ppc-for-2.8 branch.
>>>>>
>>>>> 4e1257ed41bce16baa8a010 - spapr_nvram: Pre-initialize the NVRAM to
>>>>> support the -prom-env parameter
>>>>>
>>>>> SLOF **********************************************************************
>>>>> QEMU Starting
>>>>>  Build Date = Oct 19 2016 09:58:38
>>>>>  FW Version = git-efd65f49929d7db7
>>>>>  Press "s" to enter Open Firmware.
>>>>>
>>>>> Populating /vdevice methods
>>>>> Populating /vdevice/vty@71000000
>>>>> Populating /vdevice/nvram@71000001
>>>>> Populating /vdevice/v-scsi@71000002
>>>>>        SCSI: Looking for devices
>>>>>           8200000000000000 CD-ROM   : "QEMU     QEMU CD-ROM      2.5+"
>>>>> Populating /pci@800000020000000
>>>>>                      00 1000 (D) : 1033 0194    serial bus [ usb-xhci ]
>>>>>                      00 0800 (D) : 1af4 1001    virtio [ block ]
>>>>>                      00 0000 (D) : 1af4 1000    virtio [ net ]
>>>>> Scanning USB
>>>>>   XHCI: Initializing
>>>>> Using default console: /vdevice/vty@71000000
>>>>>     
>>>>>   Welcome to Open Firmware
>>>>>
>>>>>   Copyright (c) 2004, 2011 IBM Corporation All rights reserved.
>>>>>   This program and the accompanying materials are made available
>>>>>   under the terms of the BSD License available at
>>>>>   http://www.opensource.org/licenses/bsd-license.php
>>>>>
>>>>>
>>>>> Trying to load:  from: /pci@800000020000000/scsi@1 ...   Successfully loaded
>>>>> error: out of memory.
>>>>> out of memory
>>>>> Aborted. Press any key to exit.
>>>>
>>>> Yuck. Confirmed. Sorry for the inconvenience. Seems like SLOF does not
>>>> create the properties in the /options device tree node anymore in this case.
>>>>
>>>> David, could you please unqueue the "spapr_nvram: Pre-initialize the
>>>> NVRAM to support the -prom-env parameter" patch from the ppc-for-2.8
>>>> branch until I figure out a fix for this problem? Thanks!
>>>
>>> Done.
>>
>> FYI, SLOF patch to fix this issue is on the way:
>> https://patchwork.ozlabs.org/patch/686426/
> 
> Ok.  So it was a matter of this change exposing a bug in SLOF, rather
> than being buggy of itself?

Yes. SLOF should always keep the /options device tree node populated and
up to date, no matter whether a variable is available in the NVRAM
partition or not. (Well, not sure, but it could maybe also have exposed
a bug in grub2 since that simply does not seem to work if the variable
"real-mode?" is not there ... but grub2 seems to work fine if it's
there, no matter if I use -prom-env "real-mode?=false" or -prom-env
"real-mode?=true" ...)

Anyway, I think it might also be better to change this QEMU patch here a
little bit, so that the NVRAM only gets pre-initialized if the user
specified a "-prom-env" parameter. That means, for the normal use-case,
the behavior will stay the same, and we do not have to pull in another
SLOF update to fix this issue. I'll rework my patch and post a new
version when it's ready.

 Thomas



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2016-10-26  6:36 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-18 20:46 [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too Thomas Huth
2016-10-18 20:46 ` [Qemu-devel] [PATCH 1/5] nvram: Introduce helper functions for CHRP "system" and "free space" partitions Thomas Huth
2016-10-18 20:46 ` [Qemu-devel] [PATCH 2/5] sparc: Use the new common NVRAM functions for system and free space partition Thomas Huth
2016-10-18 20:46 ` [Qemu-devel] [PATCH 3/5] spapr_nvram: Pre-initialize the NVRAM to support the -prom-env parameter Thomas Huth
2016-10-18 20:46 ` [Qemu-devel] [PATCH 4/5] nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch] Thomas Huth
2016-10-18 20:46 ` [Qemu-devel] [PATCH 5/5] nvram: Rename openbios_firmware_abi.h into sun_nvram.h Thomas Huth
2016-10-19  2:16 ` [Qemu-devel] [PATCH 0/5] nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too David Gibson
2016-10-24 10:22   ` Bharata B Rao
2016-10-24 10:36     ` Thomas Huth
2016-10-24 12:04       ` David Gibson
2016-10-25 12:22         ` [Qemu-devel] [Qemu-ppc] " Thomas Huth
2016-10-26  0:03           ` David Gibson
2016-10-26  6:35             ` Thomas Huth
2016-10-23 15:19 ` [Qemu-devel] " Mark Cave-Ayland

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.