Skip to contentSkip to conversation

nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too

PATCH In review Thomas Huth 4 participants 14 messages Oct 18, 2016 – Oct 26, 2016

lore
Share & tools
lore
#0 lore raw

cover nvram: Refactor OpenBIOS NVRAM code to support -prom-env on pseries, too

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%)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/5 nvram: Introduce helper functions for CHRP "system" and "free space" partitions

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.

---
 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
hw/nvram/Makefile.objs +1 -0
index e9a6694..c018f6b 100644
@@ -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
hw/nvram/chrp_nvram.c new file +76 -0

76 lines not on this page · raw message

hw/nvram/mac_nvram.c +8 -32
index 24f6121..c0e62a5 100644
@@ -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)
include/hw/nvram/chrp_nvram.h new file +24 -0
new file mode 100644
index 0000000..18d1976
@@ -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
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/5 sparc: Use the new common NVRAM functions for system and free space partition

In reply to Thomas Huth

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.

---
 hw/sparc/sun4m.c   | 33 ++++++---------------------------
 hw/sparc64/sun4u.c | 33 ++++++---------------------------
 2 files changed, 12 insertions(+), 54 deletions(-)
hw/sparc/sun4m.c +6 -27
index b3915e4..1b8d172 100644
@@ -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);
hw/sparc64/sun4u.c +6 -27
index 3165e18..aabb30a 100644
@@ -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);
 
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 3/5 spapr_nvram: Pre-initialize the NVRAM to support the -prom-env parameter

In reply to Thomas Huth

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.

---
 hw/nvram/spapr_nvram.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/nvram/spapr_nvram.c +6 -0
index 4de5f70..36a9188 100644
@@ -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);
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH 4/5 nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch]

In reply to Thomas Huth

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

---
 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(-)
hw/nvram/chrp_nvram.c +20 -11
index f6183ed..3837510 100644
@@ -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;
 }
hw/nvram/mac_nvram.c +3 -4
index c0e62a5..63f9ed1 100644
@@ -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);
include/hw/nvram/chrp_nvram.h +30 -0
index 18d1976..b4f5b2b 100644
@@ -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);
 
include/hw/nvram/openbios_firmware_abi.h +0 -41

47 lines not on this page · raw message

tests/postcopy-test.c +4 -4
index 41ed1a9..d6613c5 100644
@@ -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
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH 5/5 nvram: Rename openbios_firmware_abi.h into sun_nvram.h

In reply to Thomas Huth

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.

---
 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%)
hw/sparc/sun4m.c +1 -1
index 1b8d172..6224288 100644
@@ -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"
hw/sparc64/sun4u.c +1 -1
index aabb30a..3708be2 100644
@@ -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"
include/hw/nvram/sun_nvram.h renamed from include/hw/nvram/openbios_firmware_abi.h +3 -3
similarity index 90%
rename from include/hw/nvram/openbios_firmware_abi.h
rename to include/hw/nvram/sun_nvram.h
index 27ce9f4..68eaa60 100644
@@ -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 */
Signature · 1 line
1.8.3.1
Reviewed-by on the v1 series
#6 lore raw
In reply to Thomas Huth
Quoted 19 lines · Thomas Huth

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

Quoted 13 lines
 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,

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.

Signature · 4 lines
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
#7 lore raw
Quoted 35 lines · David Gibson
Quoted 19 lines · Thomas Huth

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

Quoted 2 lines
 hw/nvram/Makefile.objs                             |  1 +
 hw/nvram/chrp_nvram.c                              | 85

++++++++++++++++++++++

Quoted 11 lines
 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%)
Quoted 7 lines

Series,

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.

#8 lore raw
Quoted 86 lines · Bharata B Rao

On Wed, Oct 19, 2016 at 7:46 AM, David Gibson <[email protected] <mailto:[email protected]>> 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,

<mailto:[email protected]>>

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

Quoted 4 lines

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

#9 lore raw
Quoted 92 lines · Thomas Huth
Quoted 86 lines · Bharata B Rao

On Wed, Oct 19, 2016 at 7:46 AM, David Gibson <[email protected] <mailto:[email protected]>> 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,

<mailto:[email protected]>>

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

Quoted 4 lines

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

Quoted 6 lines

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.

Signature · 4 lines
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
#10 lore raw
Quoted 93 lines · David Gibson
Quoted 92 lines · Thomas Huth
Quoted 90 lines · Bharata B Rao

On Wed, Oct 19, 2016 at 7:46 AM, David Gibson <[email protected] <mailto:[email protected]>> 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,

<mailto:[email protected]>>

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.

Quoted 8 lines
Quoted 6 lines

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

#11 lore raw
Quoted 97 lines · Thomas Huth
Quoted 96 lines · David Gibson
Quoted 95 lines · Thomas Huth
Quoted 86 lines · Bharata B Rao

On Wed, Oct 19, 2016 at 7:46 AM, David Gibson <[email protected] <mailto:[email protected]>> 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,

<mailto:[email protected]>>

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

Quoted 4 lines

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.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

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?

Signature · 4 lines
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
#12 lore raw
Quoted 102 lines · David Gibson
Quoted 101 lines · Thomas Huth
Quoted 100 lines · David Gibson
Quoted 98 lines · Thomas Huth
Quoted 86 lines · Bharata B Rao

On Wed, Oct 19, 2016 at 7:46 AM, David Gibson <[email protected] <mailto:[email protected]>> 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,

<mailto:[email protected]>>

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

Quoted 4 lines

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!

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

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

Tested-by on the v1 series
#13 lore raw
In reply to Thomas Huth
Quoted 19 lines · Thomas Huth

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

Quoted 13 lines
 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:

ATB,

Mark.