Skip to contentSkip to conversation

Implement network booting in the s390-ccw BIOS

PATCH Superseded Thomas Huth 5 participants 22 messages Jul 11, 2017 – Jul 12, 2017

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover Implement network booting in the s390-ccw BIOS

It's already possible to do a network boot of an s390x guest with an external netboot image based on a Linux installation, but it would be much more convenient if the s390-ccw firmware supported network booting right out of the box, without the need to assemble such an external image first.

This patch series now introduces a s390-netboot.img that can be used for network booting via DHCP and TFTP by re-using the networking stack from the SLOF firmware (see https://github.com/aik/SLOF/ for details), and adds a driver for virtio-net-ccw devices.

The code can only be built if the roms/SLOF submodule has been checked out (there is a sanity check for this in the Makefile). Once it has been built, you can download a combined kernel + initrd image via TFTP by starting QEMU for example with:

qemu-system-s390x ... -device virtio-net,netdev=n1,bootindex=1 \
-netdev user,id=n1,tftp=/path/to/tftp,bootfile=kernel.img

Note that this version does not support downloading via config files (i.e. pxelinux config files or .INS config files) yet. This will be added later.

v4:
- Cosmetic clean-ups according to the review feedback from v3
- Fixed bug in the find_dev() function (spotted by Cornelia in v3)
- Added an additional patch to remove some unused structs from virtio.h

v3:
- Adressed the review feedback from v2
- The last remaining SLOF patch has now been merged (big thanks to Alexey!), so not sending this as RFC anymore - it is ready now for integration, I think.

v2:
- Put the network boot loader into a separate s390-netboot.img binary instead of linking it directly into the s390-ccw firmware.
- Use the SLOF sources from the roms/SLOF/ submodule instead of copying them into the pc-bios/s390-ccw folder
- Removed the .INS config file loading code for now - only support combined kernel + initrd images in this initial implementation.

Thomas Huth (11):
pc-bios/s390-ccw: Move libc functions to separate header pc-bios/s390-ccw: Move ebc2asc to sclp.c
pc-bios/s390-ccw: Move virtio-block related functions into a separate
file
pc-bios/s390-ccw: Add a write() function for stdio pc-bios/s390-ccw: Move byteswap functions to a separate header pc-bios/s390-ccw: Remove unused structs from virtio.h pc-bios/s390-ccw: Add code for virtio feature negotiation roms/SLOF: Update submodule to latest status pc-bios/s390-ccw: Add core files for the network bootloading program pc-bios/s390-ccw: Add virtio-net driver code pc-bios/s390-ccw: Link libnet into the netboot image and do the TFTP
load

 pc-bios/s390-ccw/Makefile        |  13 +-
 pc-bios/s390-ccw/bootmap.c       |   2 +
 pc-bios/s390-ccw/bootmap.h       |  26 ---
 pc-bios/s390-ccw/bswap.h         |  30 ++++
 pc-bios/s390-ccw/libc.h          |  45 +++++
 pc-bios/s390-ccw/main.c          |  14 +-
 pc-bios/s390-ccw/netboot.mak     |  51 ++++++
 pc-bios/s390-ccw/netmain.c       | 362 +++++++++++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/s390-ccw.h      |  33 +---
 pc-bios/s390-ccw/sclp.c          |  37 ++--
 pc-bios/s390-ccw/virtio-blkdev.c | 296 ++++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/virtio-net.c    | 135 +++++++++++++++
 pc-bios/s390-ccw/virtio-scsi.c   |   1 +
 pc-bios/s390-ccw/virtio.c        | 306 ++++-----------------------------
 pc-bios/s390-ccw/virtio.h        |  46 ++---
 roms/SLOF                        |   2 +-
 16 files changed, 1011 insertions(+), 388 deletions(-)
 create mode 100644 pc-bios/s390-ccw/bswap.h
 create mode 100644 pc-bios/s390-ccw/libc.h
 create mode 100644 pc-bios/s390-ccw/netboot.mak
 create mode 100644 pc-bios/s390-ccw/netmain.c
 create mode 100644 pc-bios/s390-ccw/virtio-blkdev.c
 create mode 100644 pc-bios/s390-ccw/virtio-net.c
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v4 1/11 pc-bios/s390-ccw: Move libc functions to separate header

The upcoming netboot code will use the libc from SLOF. To be able to still use s390-ccw.h there, the libc related functions in this header have to be moved to a different location.
And while we're at it, remove the duplicate memcpy() function from sclp.c.

---
 pc-bios/s390-ccw/bootmap.c     |  1 +
 pc-bios/s390-ccw/libc.h        | 45 ++++++++++++++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/main.c        |  1 +
 pc-bios/s390-ccw/s390-ccw.h    | 29 ---------------------------
 pc-bios/s390-ccw/sclp.c        | 10 ++--------
 pc-bios/s390-ccw/virtio-scsi.c |  1 +
 pc-bios/s390-ccw/virtio.c      |  1 +
 7 files changed, 51 insertions(+), 37 deletions(-)
 create mode 100644 pc-bios/s390-ccw/libc.h
pc-bios/s390-ccw/bootmap.c +1 -0
index 523fa78..458d3da 100644
@@ -8,6 +8,7 @@
  * directory.
  */
 
+#include "libc.h"
 #include "s390-ccw.h"
 #include "bootmap.h"
 #include "virtio.h"
pc-bios/s390-ccw/libc.h new file +45 -0

45 lines not on this page · raw message

pc-bios/s390-ccw/main.c +1 -0
index 1cacc1b..40cba8d 100644
@@ -8,6 +8,7 @@
  * directory.
  */
 
+#include "libc.h"
 #include "s390-ccw.h"
 #include "virtio.h"
 
pc-bios/s390-ccw/s390-ccw.h +0 -29
index 2089274..43e2d42 100644
@@ -18,12 +18,6 @@ typedef unsigned short     u16;
 typedef unsigned int       u32;
 typedef unsigned long long u64;
 typedef unsigned long      ulong;
-typedef long               size_t;
-typedef int                bool;
-typedef unsigned char      uint8_t;
-typedef unsigned short     uint16_t;
-typedef unsigned int       uint32_t;
-typedef unsigned long long uint64_t;
 typedef unsigned char      __u8;
 typedef unsigned short     __u16;
 typedef unsigned int       __u32;
@@ -88,18 +82,6 @@ ulong get_second(void);
 /* bootmap.c */
 void zipl_load(void);
 
-static inline void *memset(void *s, int c, size_t n)
-{
-    int i;
-    unsigned char *p = s;
-
-    for (i = 0; i < n; i++) {
-        p[i] = c;
-    }
-
-    return s;
-}
-
 static inline void fill_hex(char *out, unsigned char val)
 {
     const char hex[] = "0123456789abcdef";
@@ -169,17 +151,6 @@ static inline void sleep(unsigned int seconds)
     }
 }
 
-static inline void *memcpy(void *s1, const void *s2, size_t n)
-{
-    uint8_t *p1 = s1;
-    const uint8_t *p2 = s2;
-
-    while (n--) {
-        p1[n] = p2[n];
-    }
-    return s1;
-}
-
 static inline void IPL_assert(bool term, const char *message)
 {
     if (!term) {
pc-bios/s390-ccw/sclp.c +2 -8
index a1639ba..aa1c862 100644
@@ -8,6 +8,7 @@
  * directory.
  */
 
+#include "libc.h"
 #include "s390-ccw.h"
 #include "sclp.h"
 
@@ -59,13 +60,6 @@ static int _strlen(const char *str)
     return i;
 }
 
-static void _memcpy(char *dest, const char *src, int len)
-{
-    int i;
-    for (i = 0; i < len; i++)
-        dest[i] = src[i];
-}
-
 void sclp_print(const char *str)
 {
     int len = _strlen(str);
@@ -76,7 +70,7 @@ void sclp_print(const char *str)
     sccb->ebh.length = sizeof(EventBufferHeader) + len;
     sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA;
     sccb->ebh.flags = 0;
-    _memcpy(sccb->data, str, len);
+    memcpy(sccb->data, str, len);
 
     sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb);
 }
pc-bios/s390-ccw/virtio-scsi.c +1 -0
index f61ecf0..c92f5d3 100644
@@ -9,6 +9,7 @@
  * directory.
  */
 
+#include "libc.h"
 #include "s390-ccw.h"
 #include "virtio.h"
 #include "scsi.h"
pc-bios/s390-ccw/virtio.c +1 -0
index 6ee93d5..8768331 100644
@@ -8,6 +8,7 @@
  * directory.
  */
 
+#include "libc.h"
 #include "s390-ccw.h"
 #include "virtio.h"
 #include "virtio-scsi.h"
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH v4 2/11 pc-bios/s390-ccw: Move ebc2asc to sclp.c

In reply to Thomas Huth

We will later need this array in a file that we will link to the netboot code, too. Since there is some ebcdic conversion done in sclp_get_loadparm_ascii(), the sclp.c file seems to be a good candidate.

---
 pc-bios/s390-ccw/main.c | 11 -----------
 pc-bios/s390-ccw/sclp.c | 11 +++++++++++
 2 files changed, 11 insertions(+), 11 deletions(-)
pc-bios/s390-ccw/main.c +0 -11
index 40cba8d..0580eac 100644
@@ -17,17 +17,6 @@ static SubChannelId blk_schid = { .one = 1 };
 IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE)));
 static char loadparm[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
 
-const unsigned char ebc2asc[256] =
-      /* 0123456789abcdef0123456789abcdef */
-        "................................" /* 1F */
-        "................................" /* 3F */
-        " ...........<(+|&.........!$*);." /* 5F first.chr.here.is.real.space */
-        "-/.........,%_>?.........`:#@'=\""/* 7F */
-        ".abcdefghi.......jklmnopqr......" /* 9F */
-        "..stuvwxyz......................" /* BF */
-        ".ABCDEFGHI.......JKLMNOPQR......" /* DF */
-        "..STUVWXYZ......0123456789......";/* FF */
-
 /*
  * Priniciples of Operations (SA22-7832-09) chapter 17 requires that
  * a subsystem-identification is at 184-187 and bytes 188-191 are zero
pc-bios/s390-ccw/sclp.c +11 -0
index aa1c862..2ee204a 100644
@@ -14,6 +14,17 @@
 
 static char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096)));
 
+const unsigned char ebc2asc[256] =
+      /* 0123456789abcdef0123456789abcdef */
+        "................................" /* 1F */
+        "................................" /* 3F */
+        " ...........<(+|&.........!$*);." /* 5F first.chr.here.is.real.space */
+        "-/.........,%_>?.........`:#@'=\""/* 7F */
+        ".abcdefghi.......jklmnopqr......" /* 9F */
+        "..stuvwxyz......................" /* BF */
+        ".ABCDEFGHI.......JKLMNOPQR......" /* DF */
+        "..STUVWXYZ......0123456789......";/* FF */
+
 /* Perform service call. Return 0 on success, non-zero otherwise. */
 static int sclp_service_call(unsigned int command, void *sccb)
 {
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH v4 5/11 pc-bios/s390-ccw: Move byteswap functions to a separate header

In reply to Thomas Huth

We'll need them in code that is not related to bootmap.h, so they should reside in an independent header.

---
 pc-bios/s390-ccw/bootmap.c |  1 +
 pc-bios/s390-ccw/bootmap.h | 26 --------------------------
 pc-bios/s390-ccw/bswap.h   | 30 ++++++++++++++++++++++++++++++
 3 files changed, 31 insertions(+), 26 deletions(-)
 create mode 100644 pc-bios/s390-ccw/bswap.h
pc-bios/s390-ccw/bootmap.c +1 -0
index 458d3da..67a6123 100644
@@ -12,6 +12,7 @@
 #include "s390-ccw.h"
 #include "bootmap.h"
 #include "virtio.h"
+#include "bswap.h"
 
 #ifdef DEBUG
 /* #define DEBUG_FALLBACK */
pc-bios/s390-ccw/bootmap.h +0 -26
index 7f36782..cf99a4c 100644
@@ -324,32 +324,6 @@ static inline int _memcmp(const void *s1, const void *s2, size_t n)
     return 0;
 }
 
-/* from include/qemu/bswap.h */
-
-/* El Torito is always little-endian */
-static inline uint16_t bswap16(uint16_t x)
-{
-    return ((x & 0x00ff) << 8) | ((x & 0xff00) >> 8);
-}
-
-static inline uint32_t bswap32(uint32_t x)
-{
-    return ((x & 0x000000ffU) << 24) | ((x & 0x0000ff00U) <<  8) |
-           ((x & 0x00ff0000U) >>  8) | ((x & 0xff000000U) >> 24);
-}
-
-static inline uint64_t bswap64(uint64_t x)
-{
-    return ((x & 0x00000000000000ffULL) << 56) |
-           ((x & 0x000000000000ff00ULL) << 40) |
-           ((x & 0x0000000000ff0000ULL) << 24) |
-           ((x & 0x00000000ff000000ULL) <<  8) |
-           ((x & 0x000000ff00000000ULL) >>  8) |
-           ((x & 0x0000ff0000000000ULL) >> 24) |
-           ((x & 0x00ff000000000000ULL) >> 40) |
-           ((x & 0xff00000000000000ULL) >> 56);
-}
-
 static inline uint32_t iso_733_to_u32(uint64_t x)
 {
     return (uint32_t)x;
pc-bios/s390-ccw/bswap.h new file +30 -0
new file mode 100644
index 0000000..a422604
@@ -0,0 +1,30 @@
+/*
+ * Byte swap functions - taken from include/qemu/bswap.h
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
+ * your option) any later version. See the COPYING file in the top-level
+ * directory.
+ */
+
+static inline uint16_t bswap16(uint16_t x)
+{
+    return ((x & 0x00ff) << 8) | ((x & 0xff00) >> 8);
+}
+
+static inline uint32_t bswap32(uint32_t x)
+{
+    return ((x & 0x000000ffU) << 24) | ((x & 0x0000ff00U) <<  8) |
+           ((x & 0x00ff0000U) >>  8) | ((x & 0xff000000U) >> 24);
+}
+
+static inline uint64_t bswap64(uint64_t x)
+{
+    return ((x & 0x00000000000000ffULL) << 56) |
+           ((x & 0x000000000000ff00ULL) << 40) |
+           ((x & 0x0000000000ff0000ULL) << 24) |
+           ((x & 0x00000000ff000000ULL) <<  8) |
+           ((x & 0x000000ff00000000ULL) >>  8) |
+           ((x & 0x0000ff0000000000ULL) >> 24) |
+           ((x & 0x00ff000000000000ULL) >> 40) |
+           ((x & 0xff00000000000000ULL) >> 56);
+}
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH v4 3/11 pc-bios/s390-ccw: Move virtio-block related functions into a separate file

In reply to Thomas Huth

The netboot code is going to link against the code from virtio.c, too, so we've got to move the virtio-block and -scsi related code out of the way.

---
 pc-bios/s390-ccw/Makefile        |   2 +-
 pc-bios/s390-ccw/main.c          |   2 +-
 pc-bios/s390-ccw/s390-ccw.h      |   2 +-
 pc-bios/s390-ccw/virtio-blkdev.c | 296 +++++++++++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/virtio.c        | 277 +-----------------------------------
 pc-bios/s390-ccw/virtio.h        |   6 +
 6 files changed, 311 insertions(+), 274 deletions(-)
 create mode 100644 pc-bios/s390-ccw/virtio-blkdev.c
pc-bios/s390-ccw/Makefile +1 -1
index fb88c13..82b41ef 100644
@@ -9,7 +9,7 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/s390-ccw)
 
 .PHONY : all clean build-all
 
-OBJECTS = start.o main.o bootmap.o sclp.o virtio.o virtio-scsi.o
+OBJECTS = start.o main.o bootmap.o sclp.o virtio.o virtio-scsi.o virtio-blkdev.o
 QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS))
 QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -msoft-float
 QEMU_CFLAGS += -march=z900 -fPIE -fno-strict-aliasing
pc-bios/s390-ccw/main.c +1 -1
index 0580eac..401e9db 100644
@@ -144,7 +144,7 @@ static void virtio_setup(void)
         sclp_print("Network boot device detected\n");
         vdev->netboot_start_addr = iplb.ccw.netboot_start_addr;
     } else {
-        virtio_setup_device(blk_schid);
+        virtio_blk_setup_device(blk_schid);
 
         IPL_assert(virtio_ipl_disk_is_valid(), "No valid IPL device detected");
     }
pc-bios/s390-ccw/s390-ccw.h +1 -1
index 43e2d42..6fdc858 100644
@@ -74,7 +74,7 @@ void sclp_get_loadparm_ascii(char *loadparm);
 unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2,
                                  ulong subchan_id, void *load_addr);
 bool virtio_is_supported(SubChannelId schid);
-void virtio_setup_device(SubChannelId schid);
+void virtio_blk_setup_device(SubChannelId schid);
 int virtio_read(ulong sector, void *load_addr);
 int enable_mss_facility(void);
 ulong get_second(void);
pc-bios/s390-ccw/virtio-blkdev.c new file +296 -0

296 lines not on this page · raw message

pc-bios/s390-ccw/virtio.c +6 -271

318 lines not on this page · raw message

pc-bios/s390-ccw/virtio.h +6 -0
index 1eaf865..024e9a6 100644
@@ -291,6 +291,12 @@ struct VirtioCmd {
 };
 typedef struct VirtioCmd VirtioCmd;
 
+bool vring_notify(VRing *vr);
+int drain_irqs(SubChannelId schid);
+void vring_send_buf(VRing *vr, void *p, int len, int flags);
+int vr_poll(VRing *vr);
+int vring_wait_reply(void);
 int virtio_run(VDev *vdev, int vqid, VirtioCmd *cmd);
+void virtio_setup_ccw(VDev *vdev);
 
 #endif /* VIRTIO_H */
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH v4 4/11 pc-bios/s390-ccw: Add a write() function for stdio

In reply to Thomas Huth

The stdio functions from the SLOF libc need a write() function for printing text to stdout/stderr. Let's implement this function by refactoring the code from sclp_print().

---
 pc-bios/s390-ccw/sclp.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
pc-bios/s390-ccw/sclp.c +14 -2
index 2ee204a..b1fc8ff 100644
@@ -12,6 +12,8 @@
 #include "s390-ccw.h"
 #include "sclp.h"
 
+long write(int fd, const void *str, size_t len);
+
 static char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096)));
 
 const unsigned char ebc2asc[256] =
@@ -71,11 +73,14 @@ static int _strlen(const char *str)
     return i;
 }
 
-void sclp_print(const char *str)
+long write(int fd, const void *str, size_t len)
 {
-    int len = _strlen(str);
     WriteEventData *sccb = (void *)_sccb;
 
+    if (fd != 1 && fd != 2) {
+        return -EIO;
+    }
+
     sccb->h.length = sizeof(WriteEventData) + len;
     sccb->h.function_code = SCLP_FC_NORMAL_WRITE;
     sccb->ebh.length = sizeof(EventBufferHeader) + len;
@@ -84,6 +89,13 @@ void sclp_print(const char *str)
     memcpy(sccb->data, str, len);
 
     sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb);
+
+    return len;
+}
+
+void sclp_print(const char *str)
+{
+    write(1, str, _strlen(str));
 }
 
 void sclp_get_loadparm_ascii(char *loadparm)
Signature · 1 line
1.8.3.1
#6 lore raw

PATCH v4 6/11 pc-bios/s390-ccw: Remove unused structs from virtio.h

In reply to Thomas Huth

Looks like they have never beend used, so let's simply remove them.

---
 pc-bios/s390-ccw/virtio.h | 27 ---------------------------
 1 file changed, 27 deletions(-)
pc-bios/s390-ccw/virtio.h +0 -27
index 024e9a6..d733780 100644
@@ -32,24 +32,6 @@ enum VirtioDevType {
 };
 typedef enum VirtioDevType VirtioDevType;
 
-struct VirtioDevHeader {
-    VirtioDevType type:8;
-    uint8_t num_vq;
-    uint8_t feature_len;
-    uint8_t config_len;
-    uint8_t status;
-    uint8_t vqconfig[];
-} __attribute__((packed));
-typedef struct VirtioDevHeader VirtioDevHeader;
-
-struct VirtioVqConfig {
-    uint64_t token;
-    uint64_t address;
-    uint16_t num;
-    uint8_t pad[6];
-} __attribute__((packed));
-typedef struct VirtioVqConfig VirtioVqConfig;
-
 struct VqInfo {
     uint64_t queue;
     uint32_t align;
@@ -64,15 +46,6 @@ struct VqConfig {
 } __attribute__((packed));
 typedef struct VqConfig VqConfig;
 
-struct VirtioDev {
-    VirtioDevHeader *header;
-    VirtioVqConfig *vqconfig;
-    char *host_features;
-    char *guest_features;
-    char *config;
-};
-typedef struct VirtioDev VirtioDev;
-
 #define VIRTIO_RING_SIZE            (PAGE_SIZE * 8)
 #define VIRTIO_MAX_VQS              3
 #define KVM_S390_VIRTIO_RING_ALIGN  4096
Signature · 1 line
1.8.3.1
#8 lore raw

PATCH v4 7/11 pc-bios/s390-ccw: Add code for virtio feature negotiation

In reply to Thomas Huth

The upcoming virtio-net driver needs to negotiate some features, so we need the possibility to do this in the core virtio code.

---
 pc-bios/s390-ccw/s390-ccw.h |  2 ++
 pc-bios/s390-ccw/virtio.c   | 23 +++++++++++++++++------
 pc-bios/s390-ccw/virtio.h   |  1 +
 3 files changed, 20 insertions(+), 6 deletions(-)
pc-bios/s390-ccw/s390-ccw.h +2 -0
index 6fdc858..25d4d21 100644
@@ -44,6 +44,8 @@ typedef unsigned long long __u64;
                             ((b) == 0 ? (a) : (MIN(a, b))))
 #endif
 
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+
 #include "cio.h"
 #include "iplb.h"
 
pc-bios/s390-ccw/virtio.c +17 -6
index 9d9e61f..18fc5d1 100644
@@ -12,6 +12,7 @@
 #include "s390-ccw.h"
 #include "virtio.h"
 #include "virtio-scsi.h"
+#include "bswap.h"
 
 #define VRING_WAIT_REPLY_TIMEOUT 3
 
@@ -249,8 +250,12 @@ int virtio_run(VDev *vdev, int vqid, VirtioCmd *cmd)
 
 void virtio_setup_ccw(VDev *vdev)
 {
-    int i, cfg_size = 0;
+    int i, rc, cfg_size = 0;
     unsigned char status = VIRTIO_CONFIG_S_DRIVER_OK;
+    struct VirtioFeatureDesc {
+        uint32_t features;
+        uint8_t index;
+    } __attribute__((packed)) feats;
 
     IPL_assert(virtio_is_supported(vdev->schid), "PE");
     /* device ID has been established now */
@@ -277,11 +282,17 @@ void virtio_setup_ccw(VDev *vdev)
     IPL_assert(run_ccw(vdev, CCW_CMD_READ_CONF, &vdev->config, cfg_size) == 0,
                "Could not get block device configuration");
 
-    /*
-     * Skipping CCW_CMD_READ_FEAT. We're not doing anything fancy, and
-     * we'll just stop dead anyway if anything does not work like we
-     * expect it.
-     */
+    /* Feature negotiation */
+    for (i = 0; i < ARRAY_SIZE(vdev->guest_features); i++) {
+        feats.features = 0;
+        feats.index = i;
+        rc = run_ccw(vdev, CCW_CMD_READ_FEAT, &feats, sizeof(feats));
+        IPL_assert(rc == 0, "Could not get features bits");
+        vdev->guest_features[i] &= bswap32(feats.features);
+        feats.features = bswap32(vdev->guest_features[i]);
+        rc = run_ccw(vdev, CCW_CMD_WRITE_FEAT, &feats, sizeof(feats));
+        IPL_assert(rc == 0, "Could not set features bits");
+    }
 
     for (i = 0; i < vdev->nr_vqs; i++) {
         VqInfo info = {
pc-bios/s390-ccw/virtio.h +1 -0
index d733780..a00a320 100644
@@ -251,6 +251,7 @@ struct VDev {
     ScsiDevice selected_scsi_device;
     uint64_t netboot_start_addr;
     uint32_t max_transfer;
+    uint32_t guest_features[2];
 };
 typedef struct VDev VDev;
 
Signature · 1 line
1.8.3.1
#11 lore raw

PATCH v4 8/11 roms/SLOF: Update submodule to latest status

In reply to Thomas Huth

We need the latest fixes for building the libc and libnet of SLOF for the s390-ccw network bootloader firmware.

---
 roms/SLOF | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
roms/SLOF +1 -1
index 66d250e..834113a 160000
@@ -1 +1 @@
-Subproject commit 66d250ef0fd06bb88b7399b9563b5008201f2d63
+Subproject commit 834113a1c67d6fb53dea153c3313d182238f2d36
Signature · 1 line
1.8.3.1
#12 lore raw

PATCH v4 9/11 pc-bios/s390-ccw: Add core files for the network bootloading program

In reply to Thomas Huth

This is just a preparation for the next steps: Add a makefile and a stripped down copy of pc-bios/s390-ccw/main.c as a basis for the network bootloader program, linked against the libc from SLOF already (which we will need for SLOF's libnet). The networking code is not included yet.

---
 pc-bios/s390-ccw/Makefile    |  11 +++-
 pc-bios/s390-ccw/netboot.mak |  41 +++++++++++++
 pc-bios/s390-ccw/netmain.c   | 137 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 187 insertions(+), 2 deletions(-)
 create mode 100644 pc-bios/s390-ccw/netboot.mak
 create mode 100644 pc-bios/s390-ccw/netmain.c
pc-bios/s390-ccw/Makefile +9 -2
index 82b41ef..cbae745 100644
@@ -16,7 +16,7 @@ QEMU_CFLAGS += -march=z900 -fPIE -fno-strict-aliasing
 QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)
 LDFLAGS += -Wl,-pie -nostdlib
 
-build-all: s390-ccw.img
+build-all: s390-ccw.img s390-netboot.img
 
 s390-ccw.elf: $(OBJECTS)
 	$(call quiet-command,$(CC) $(LDFLAGS) -o $@ $(OBJECTS),"BUILD","$(TARGET_DIR)$@")
@@ -28,5 +28,12 @@ s390-ccw.img: s390-ccw.elf
 
 $(OBJECTS): Makefile
 
+ifneq ($(wildcard $(SRC_PATH)/roms/SLOF/lib/libnet),)
+include $(SRC_PATH)/pc-bios/s390-ccw/netboot.mak
+else
+s390-netboot.img:
+	@echo "s390-netboot.img not built since roms/SLOF/ is not available."
+endif
+
 clean:
-	rm -f *.o *.d *.img *.elf *~
+	$(RM) *.o *.d *.img *.elf *~ *.a
pc-bios/s390-ccw/netboot.mak new file +41 -0

41 lines not on this page · raw message

pc-bios/s390-ccw/netmain.c new file +137 -0

137 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#14 lore raw

PATCH v4 10/11 pc-bios/s390-ccw: Add virtio-net driver code

In reply to Thomas Huth

The driver provides the recv() and send() functions which will be required by SLOF's libnet code for receiving and sending packets.

---
 pc-bios/s390-ccw/netboot.mak  |   2 +-
 pc-bios/s390-ccw/virtio-net.c | 135 ++++++++++++++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/virtio.c     |   5 ++
 pc-bios/s390-ccw/virtio.h     |  12 +++-
 4 files changed, 151 insertions(+), 3 deletions(-)
 create mode 100644 pc-bios/s390-ccw/virtio-net.c
pc-bios/s390-ccw/netboot.mak +1 -1
index 1eaa0d8..dd9119a 100644
@@ -1,7 +1,7 @@
 
 SLOF_DIR := $(SRC_PATH)/roms/SLOF
 
-NETOBJS := start.o sclp.o virtio.o netmain.o sbrk.o libc.a
+NETOBJS := start.o sclp.o virtio.o virtio-net.o netmain.o sbrk.o libc.a
 
 LIBC_INC := -I$(SLOF_DIR)/lib/libc/include
 LIBNET_INC := -I$(SLOF_DIR)/lib/libnet
pc-bios/s390-ccw/virtio-net.c new file +135 -0

135 lines not on this page · raw message

pc-bios/s390-ccw/virtio.c +5 -0
index 18fc5d1..c890a03 100644
@@ -266,6 +266,11 @@ void virtio_setup_ccw(VDev *vdev)
     run_ccw(vdev, CCW_CMD_VDEV_RESET, NULL, 0);
 
     switch (vdev->senseid.cu_model) {
+    case VIRTIO_ID_NET:
+        vdev->nr_vqs = 2;
+        vdev->cmd_vr_idx = 0;
+        cfg_size = sizeof(vdev->config.net);
+        break;
     case VIRTIO_ID_BLOCK:
         vdev->nr_vqs = 1;
         vdev->cmd_vr_idx = 0;
pc-bios/s390-ccw/virtio.h +10 -2
index a00a320..19fceb6 100644
@@ -11,8 +11,6 @@
 #ifndef VIRTIO_H
 #define VIRTIO_H
 
-#include "s390-ccw.h"
-
 /* Status byte for guest to report progress, and synchronize features. */
 /* We have seen device and processed generic fields (VIRTIO_CONFIG_F_VIRTIO) */
 #define VIRTIO_CONFIG_S_ACKNOWLEDGE     1
@@ -227,6 +225,13 @@ struct ScsiDevice {
 };
 typedef struct ScsiDevice ScsiDevice;
 
+struct VirtioNetConfig {
+    uint8_t mac[6];
+    /* uint16_t status; */               /* Only with VIRTIO_NET_F_STATUS */
+    /* uint16_t max_virtqueue_pairs; */  /* Only with VIRTIO_NET_F_MQ */
+};
+typedef struct VirtioNetConfig VirtioNetConfig;
+
 struct VDev {
     int nr_vqs;
     VRing *vrings;
@@ -239,6 +244,7 @@ struct VDev {
     union {
         VirtioBlkConfig blk;
         VirtioScsiConfig scsi;
+        VirtioNetConfig net;
     } config;
     ScsiDevice *scsi_device;
     bool is_cdrom;
@@ -273,4 +279,6 @@ int vring_wait_reply(void);
 int virtio_run(VDev *vdev, int vqid, VirtioCmd *cmd);
 void virtio_setup_ccw(VDev *vdev);
 
+int virtio_net_init(void *mac_addr);
+
 #endif /* VIRTIO_H */
Signature · 1 line
1.8.3.1
#16 lore raw

PATCH v4 11/11 pc-bios/s390-ccw: Link libnet into the netboot image and do the TFTP load

In reply to Thomas Huth

Most of the code has been taken from SLOF's netload.c file. Now we can finally load an image via TFTP and execute the downloaded kernel.

---
 pc-bios/s390-ccw/netboot.mak |  12 ++-
 pc-bios/s390-ccw/netmain.c   | 225 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 236 insertions(+), 1 deletion(-)
pc-bios/s390-ccw/netboot.mak +11 -1
index dd9119a..8c54b05 100644
@@ -1,7 +1,7 @@
 
 SLOF_DIR := $(SRC_PATH)/roms/SLOF
 
-NETOBJS := start.o sclp.o virtio.o virtio-net.o netmain.o sbrk.o libc.a
+NETOBJS := start.o sclp.o virtio.o virtio-net.o netmain.o sbrk.o libnet.a libc.a
 
 LIBC_INC := -I$(SLOF_DIR)/lib/libc/include
 LIBNET_INC := -I$(SLOF_DIR)/lib/libnet
@@ -39,3 +39,13 @@ libc.a: $(LIBCOBJS)
 
 sbrk.o: $(SLOF_DIR)/slof/sbrk.c
 	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(LIBC_INC) -c -o $@ $<,"CC","$(TARGET_DIR)$@")
+
+LIBNETOBJS := args.o dhcp.o dns.o icmpv6.o ipv6.o tcp.o udp.o bootp.o \
+	      dhcpv6.o ethernet.o ipv4.o ndp.o tftp.o
+LIBNETCFLAGS :=  $(QEMU_CFLAGS) $(LIBC_INC) $(LIBNET_INC)
+
+%.o : $(SLOF_DIR)/lib/libnet/%.c
+	$(call quiet-command,$(CC) $(LIBNETCFLAGS) -c -o $@ $<,"CC","$(TARGET_DIR)$@")
+
+libnet.a: $(LIBNETOBJS)
+	$(call quiet-command,$(AR) -rc $@ $^,"AR","$(TARGET_DIR)$@")
pc-bios/s390-ccw/netmain.c +225 -0

264 lines not on this page · raw message

Signature · 1 line
1.8.3.1
Acked-by on v4 6/11
#7 lore raw

Re: [Qemu-devel] [PATCH v4 06/11] pc-bios/s390-ccw: Remove unused structs from virtio.h

In reply to Thomas Huth
Quoted 1 line · On Tue, 11 Jul 2017 15:56:32 +0200 Thomas Huth <[email protected]> wrote:

Looks like they have never beend used, so let's simply remove them.

s/beend/been/

Quoted 5 lines
---
 pc-bios/s390-ccw/virtio.h | 27 ---------------------------
 1 file changed, 27 deletions(-)

Huh. At least their style had been fixed in the past ;)

Reviewed-by on v4 7/11
#9 lore raw

Re: [Qemu-devel] [PATCH v4 07/11] pc-bios/s390-ccw: Add code for virtio feature negotiation

In reply to Thomas Huth
Quoted 16 lines · On Tue, 11 Jul 2017 15:56:33 +0200 Thomas Huth <[email protected]> wrote:

The upcoming virtio-net driver needs to negotiate some features, so we need the possibility to do this in the core virtio code.

---
 pc-bios/s390-ccw/s390-ccw.h |  2 ++
 pc-bios/s390-ccw/virtio.c   | 23 +++++++++++++++++------
 pc-bios/s390-ccw/virtio.h   |  1 +
 3 files changed, 20 insertions(+), 6 deletions(-)
pc-bios/s390-ccw/virtio.h +0 -0
index d733780..a00a320 100644

pc-bios/s390-ccw/virtio.h struct VDev { · line 254

Quoted 4 lines
pc-bios/s390-ccw/virtio.h +1 -0
@@ -251,6 +251,7 @@ struct VDev {
     ScsiDevice selected_scsi_device;
     uint64_t netboot_start_addr;
     uint32_t max_transfer;
+    uint32_t guest_features[2];

Just 'features' might have been a better name, but:

pc-bios/s390-ccw/virtio.h struct VDev { · line 257

Quoted 3 lines
pc-bios/s390-ccw/virtio.h +0 -0
 };
 typedef struct VDev VDev;
 
Reviewed-by on v4 9/11
#13 lore raw

Re: [Qemu-devel] [PATCH v4 09/11] pc-bios/s390-ccw: Add core files for the network bootloading program

In reply to Thomas Huth
Quoted 21 lines · On Tue, 11 Jul 2017 15:56:35 +0200 Thomas Huth <[email protected]> wrote:

This is just a preparation for the next steps: Add a makefile and a stripped down copy of pc-bios/s390-ccw/main.c as a basis for the network bootloader program, linked against the libc from SLOF already (which we will need for SLOF's libnet). The networking code is not included yet.

---
 pc-bios/s390-ccw/Makefile    |  11 +++-
 pc-bios/s390-ccw/netboot.mak |  41 +++++++++++++
 pc-bios/s390-ccw/netmain.c   | 137 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 187 insertions(+), 2 deletions(-)
 create mode 100644 pc-bios/s390-ccw/netboot.mak
 create mode 100644 pc-bios/s390-ccw/netmain.c
pc-bios/s390-ccw/netmain.c new file +0 -0
new file mode 100644
index 0000000..d604623
@@ -0,0 +1,137 @@

(...)

pc-bios/s390-ccw/netmain.c line 40

Quoted 7 lines
pc-bios/s390-ccw/netmain.c new file +7 -0
+static uint64_t get_timer_ms(void)
+{
+    uint64_t clk;
+
+    asm volatile(" stck %0 " : : "Q"(clk) : "memory");
+
+    /* Bit 51 is incrememented each microsecond */

s/incrememented/incremented/

Quoted 2 lines
pc-bios/s390-ccw/netmain.c new file +2 -0
+    return (clk >> (63 - 51)) / 1000;
+}

(...)

Quoted 49 lines
pc-bios/s390-ccw/netmain.c new file +49 -0
+static bool find_net_dev(Schib *schib, int dev_no)
+{
+    int i, r;
+
+    for (i = 0; i < 0x10000; i++) {
+        net_schid.sch_no = i;
+        r = stsch_err(net_schid, schib);
+        if (r == 3 || r == -EIO) {
+            break;
+        }
+        if (!schib->pmcw.dnv) {
+            continue;
+        }
+        if (!virtio_is_supported(net_schid)) {
+            continue;
+        }
+        if (virtio_get_device_type() != VIRTIO_ID_NET) {
+            continue;
+        }
+        if (dev_no < 0 || schib->pmcw.dev == dev_no) {
+            return true;
+        }
+    }
+
+    return false;
+}
+
+static void virtio_setup(void)
+{
+    Schib schib;
+    int ssid;
+    bool found = false;
+    uint16_t dev_no;
+
+    /*
+     * We unconditionally enable mss support. In every sane configuration,
+     * this will succeed; and even if it doesn't, stsch_err() can deal
+     * with the consequences.
+     */
+    enable_mss_facility();
+
+    if (store_iplb(&iplb)) {
+        IPL_assert(iplb.pbt == S390_IPL_TYPE_CCW, "IPL_TYPE_CCW expected");
+        dev_no = iplb.ccw.devno;
+        debug_print_int("device no. ", dev_no);
+        net_schid.ssid = iplb.ccw.ssid & 0x3;
+        debug_print_int("ssid ", net_schid.ssid);
+        found = find_net_dev(&schib, dev_no);
+    } else {

pc-bios/s390-ccw/netmain.c line 125

Quoted 10 lines
pc-bios/s390-ccw/netmain.c new file +10 -0
+        for (ssid = 0; ssid < 0x3; ssid++) {
+            net_schid.ssid = ssid;
+            found = find_net_dev(&schib, -1);
+            if (found) {
+                break;
+            }
+        }
+    }
+
+    IPL_assert(found && virtio_get_device_type() == VIRTIO_ID_NET,

Is found && virtio_get_device_type() != VIRTIO_ID_NET even possible?

pc-bios/s390-ccw/netmain.c

Quoted 2 lines
pc-bios/s390-ccw/netmain.c new file +2 -0
+               "No virtio net device found");
+}

Anyway, otherwise

Reviewed-by on v4 10/11
#15 lore raw

Re: [Qemu-devel] [PATCH v4 10/11] pc-bios/s390-ccw: Add virtio-net driver code

In reply to Thomas Huth
Quoted 4 lines · On Tue, 11 Jul 2017 15:56:36 +0200 Thomas Huth <[email protected]> wrote:

The driver provides the recv() and send() functions which will be required by SLOF's libnet code for receiving and sending packets.

Quoted 8 lines
---
 pc-bios/s390-ccw/netboot.mak  |   2 +-
 pc-bios/s390-ccw/virtio-net.c | 135 ++++++++++++++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/virtio.c     |   5 ++
 pc-bios/s390-ccw/virtio.h     |  12 +++-
 4 files changed, 151 insertions(+), 3 deletions(-)
 create mode 100644 pc-bios/s390-ccw/virtio-net.c
Acked-by on v4 11/11
#17 lore raw

Re: [Qemu-devel] [PATCH v4 11/11] pc-bios/s390-ccw: Link libnet into the netboot image and do the TFTP load

In reply to Thomas Huth
Quoted 8 lines · On Tue, 11 Jul 2017 15:56:37 +0200 Thomas Huth <[email protected]> wrote:

Most of the code has been taken from SLOF's netload.c file. Now we can finally load an image via TFTP and execute the downloaded kernel.

---
 pc-bios/s390-ccw/netboot.mak |  12 ++-
 pc-bios/s390-ccw/netmain.c   | 225 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 236 insertions(+), 1 deletion(-)

Still

#18 lore raw
In reply to Thomas Huth
This series seems to have some coding style problems. See output below for more information:

Hi,

This series seems to have some coding style problems. See output below for more information:

Message-id: [email protected]
Type: series
Subject: [Qemu-devel] [PATCH v4 00/11] Implement network booting in the s390-ccw BIOS

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do

    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))

done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
- [tag update] patchew/[email protected] -> patchew/[email protected]
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
dfcbff7 pc-bios/s390-ccw: Link libnet into the netboot image and do the TFTP load 3d23b53 pc-bios/s390-ccw: Add virtio-net driver code
e902e4d pc-bios/s390-ccw: Add core files for the network bootloading program ef33c9b roms/SLOF: Update submodule to latest status
a50b775 pc-bios/s390-ccw: Add code for virtio feature negotiation 3661080 pc-bios/s390-ccw: Remove unused structs from virtio.h
66831e3 pc-bios/s390-ccw: Move byteswap functions to a separate header 74c52d9 pc-bios/s390-ccw: Add a write() function for stdio
bf18612 pc-bios/s390-ccw: Move virtio-block related functions into a separate file 2e9282c pc-bios/s390-ccw: Move ebc2asc to sclp.c
842b66f pc-bios/s390-ccw: Move libc functions to separate header

=== OUTPUT BEGIN ===
Checking PATCH 1/11: pc-bios/s390-ccw: Move libc functions to separate header... Checking PATCH 2/11: pc-bios/s390-ccw: Move ebc2asc to sclp.c...
Checking PATCH 3/11: pc-bios/s390-ccw: Move virtio-block related functions into a separate file... Checking PATCH 4/11: pc-bios/s390-ccw: Add a write() function for stdio...
ERROR: externs should be avoided in .c files
#23: FILE: pc-bios/s390-ccw/sclp.c:15:
+long write(int fd, const void *str, size_t len);

total: 1 errors, 0 warnings, 37 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

Checking PATCH 5/11: pc-bios/s390-ccw: Move byteswap functions to a separate header... Checking PATCH 6/11: pc-bios/s390-ccw: Remove unused structs from virtio.h... Checking PATCH 7/11: pc-bios/s390-ccw: Add code for virtio feature negotiation... Checking PATCH 8/11: roms/SLOF: Update submodule to latest status...
Checking PATCH 9/11: pc-bios/s390-ccw: Add core files for the network bootloading program...
ERROR: externs should be avoided in .c files
#121: FILE: pc-bios/s390-ccw/netmain.c:26:
+extern char _start[];

ERROR: externs should be avoided in .c files
#124: FILE: pc-bios/s390-ccw/netmain.c:29:
+IplParameterBlock iplb __attribute__((aligned(PAGE_SIZE)));

total: 2 errors, 0 warnings, 199 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

Checking PATCH 10/11: pc-bios/s390-ccw: Add virtio-net driver code...
Checking PATCH 11/11: pc-bios/s390-ccw: Link libnet into the netboot image and do the TFTP load... === OUTPUT END ===

Test command exited with code: 1

---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]

#10 lore raw

Re: [Qemu-devel] [PATCH v4 07/11] pc-bios/s390-ccw: Add code for virtio feature negotiation

In reply to Cornelia Huck
Quoted 14 lines · Cornelia Huck
Quoted 9 lines · On Tue, 11 Jul 2017 15:56:33 +0200 Thomas Huth <[email protected]> wrote:

The upcoming virtio-net driver needs to negotiate some features, so we need the possibility to do this in the core virtio code.

---
 pc-bios/s390-ccw/s390-ccw.h |  2 ++
 pc-bios/s390-ccw/virtio.c   | 23 +++++++++++++++++------
 pc-bios/s390-ccw/virtio.h   |  1 +
 3 files changed, 20 insertions(+), 6 deletions(-)
Quoted 11 lines

pc-bios/s390-ccw/virtio.h struct VDev { · line 254

Quoted 9 lines
pc-bios/s390-ccw/virtio.h +1 -0
index d733780..a00a320 100644
@@ -251,6 +251,7 @@ struct VDev {
     ScsiDevice selected_scsi_device;
     uint64_t netboot_start_addr;
     uint32_t max_transfer;
+    uint32_t guest_features[2];

Just 'features' might have been a better name, but:

I think it's clearer to call it guest_features ... in case we ever want to store the host features, too.

Quoted 5 lines

pc-bios/s390-ccw/virtio.h struct VDev { · line 257

Quoted 3 lines
pc-bios/s390-ccw/virtio.h +0 -0
 };
 typedef struct VDev VDev;
 

Thanks!

Thomas

#19 lore raw
In reply to Thomas Huth
Quoted 73 lines · Thomas Huth

It's already possible to do a network boot of an s390x guest with an external netboot image based on a Linux installation, but it would be much more convenient if the s390-ccw firmware supported network booting right out of the box, without the need to assemble such an external image first.

This patch series now introduces a s390-netboot.img that can be used for network booting via DHCP and TFTP by re-using the networking stack from the SLOF firmware (see https://github.com/aik/SLOF/ for details), and adds a driver for virtio-net-ccw devices.

The code can only be built if the roms/SLOF submodule has been checked out (there is a sanity check for this in the Makefile). Once it has been built, you can download a combined kernel + initrd image via TFTP by starting QEMU for example with:

qemu-system-s390x ... -device virtio-net,netdev=n1,bootindex=1 \
-netdev user,id=n1,tftp=/path/to/tftp,bootfile=kernel.img

Note that this version does not support downloading via config files (i.e. pxelinux config files or .INS config files) yet. This will be added later.

v4:
- Cosmetic clean-ups according to the review feedback from v3
- Fixed bug in the find_dev() function (spotted by Cornelia in v3)
- Added an additional patch to remove some unused structs from virtio.h

v3:
- Adressed the review feedback from v2
- The last remaining SLOF patch has now been merged (big thanks to Alexey!), so not sending this as RFC anymore - it is ready now for integration, I think.

v2:
- Put the network boot loader into a separate s390-netboot.img binary instead of linking it directly into the s390-ccw firmware.
- Use the SLOF sources from the roms/SLOF/ submodule instead of copying them into the pc-bios/s390-ccw folder
- Removed the .INS config file loading code for now - only support combined kernel + initrd images in this initial implementation.

Thomas Huth (11):
pc-bios/s390-ccw: Move libc functions to separate header pc-bios/s390-ccw: Move ebc2asc to sclp.c
pc-bios/s390-ccw: Move virtio-block related functions into a separate
file
pc-bios/s390-ccw: Add a write() function for stdio pc-bios/s390-ccw: Move byteswap functions to a separate header pc-bios/s390-ccw: Remove unused structs from virtio.h pc-bios/s390-ccw: Add code for virtio feature negotiation roms/SLOF: Update submodule to latest status pc-bios/s390-ccw: Add core files for the network bootloading program pc-bios/s390-ccw: Add virtio-net driver code pc-bios/s390-ccw: Link libnet into the netboot image and do the TFTP
load

 pc-bios/s390-ccw/Makefile        |  13 +-
 pc-bios/s390-ccw/bootmap.c       |   2 +
 pc-bios/s390-ccw/bootmap.h       |  26 ---
 pc-bios/s390-ccw/bswap.h         |  30 ++++
 pc-bios/s390-ccw/libc.h          |  45 +++++
 pc-bios/s390-ccw/main.c          |  14 +-
 pc-bios/s390-ccw/netboot.mak     |  51 ++++++
 pc-bios/s390-ccw/netmain.c       | 362 +++++++++++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/s390-ccw.h      |  33 +---
 pc-bios/s390-ccw/sclp.c          |  37 ++--
 pc-bios/s390-ccw/virtio-blkdev.c | 296 ++++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/virtio-net.c    | 135 +++++++++++++++
 pc-bios/s390-ccw/virtio-scsi.c   |   1 +
 pc-bios/s390-ccw/virtio.c        | 306 ++++-----------------------------
 pc-bios/s390-ccw/virtio.h        |  46 ++---
Quoted 9 lines
 roms/SLOF                        |   2 +-
 16 files changed, 1011 insertions(+), 388 deletions(-)
 create mode 100644 pc-bios/s390-ccw/bswap.h
 create mode 100644 pc-bios/s390-ccw/libc.h
 create mode 100644 pc-bios/s390-ccw/netboot.mak
 create mode 100644 pc-bios/s390-ccw/netmain.c
 create mode 100644 pc-bios/s390-ccw/virtio-blkdev.c
 create mode 100644 pc-bios/s390-ccw/virtio-net.c

Was going to apply but then I updated the slof thing but building fails. Not sure yet why.

In file included from /home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/isdigit.c:13:0:
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/isdigit.c:15:17: error: expected ‘)’ before ‘ch’
int isdigit(int ch)

                 ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/isdigit.c:15:5: error: expected expression before ‘)’ token
 int isdigit(int ch)
     ^
In file included from /home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/isprint.c:13:0:
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/isprint.c:15:17: error: expected ‘)’ before ‘ch’
 int isprint(int ch)
                 ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/isprint.c:15:5: error: expected expression before ‘)’ token
 int isprint(int ch)
     ^
In file included from /home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/isxdigit.c:13:0:
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/isxdigit.c:15:18: error: expected ‘)’ before ‘ch’
 int isxdigit(int ch)
                  ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/isxdigit.c:15:5: error: expected expression before ‘)’ token
 int isxdigit(int ch)
     ^
In file included from /home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/tolower.c:13:0:
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/tolower.c:15:5: error: expected identifier or ‘(’ before ‘__extension__’
 int tolower(int c)
     ^

/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/Makefile.inc:20: recipe for target 'isdigit.o' failed make[1]: *** [isdigit.o] Error 1
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/Makefile.inc:20: recipe for target 'isprint.o' failed make[1]: *** [isprint.o] Error 1
In file included from /usr/include/string.h:630:0,
from /home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/string/strncmp.c:13:
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/string/strncmp.c:17:1: error: expected identifier or ‘(’ before ‘__extension__’
strncmp(const char *s1, const char *s2, size_t n)
^
In file included from /home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/isspace.c:13:0:
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/isspace.c:15:17: error: expected ‘)’ before ‘ch’
int isspace(int ch)

                 ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/isspace.c:15:5: error: expected expression before ‘)’ token
 int isspace(int ch)
     ^

/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/Makefile.inc:20: recipe for target 'isxdigit.o' failed make[1]: *** [isxdigit.o] Error 1
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/Makefile.inc:20: recipe for target 'tolower.o' failed make[1]: *** [tolower.o] Error 1
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/string/Makefile.inc:22: recipe for target 'strncmp.o' failed make[1]: *** [strncmp.o] Error 1
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/Makefile.inc:20: recipe for target 'isspace.o' failed make[1]: *** [isspace.o] Error 1
In file included from /usr/include/string.h:630:0,
from /home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/string/strcmp.c:13:
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/string/strcmp.c:17:1: error: expected identifier or ‘(’ before ‘__extension__’
strcmp(const char *s1, const char *s2)
^
In file included from /usr/include/string.h:630:0,
from /home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/string/strchr.c:13:
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/string/strchr.c:16:1: error: expected identifier or ‘(’ before ‘__extension__’
strchr(const char *s, int c)
^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/string/strcmp.c:17:1: error: expected identifier or ‘(’ before ‘)’ token
strcmp(const char *s1, const char *s2)
^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/string/Makefile.inc:22: recipe for target 'strchr.o' failed make[1]: *** [strchr.o] Error 1
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/string/Makefile.inc:22: recipe for target 'strcmp.o' failed make[1]: *** [strcmp.o] Error 1
In file included from /home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/toupper.c:14:0:
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/toupper.c:16:5: error: expected identifier or ‘(’ before ‘__extension__’
int toupper (int cha)

     ^

/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/Makefile.inc:20: recipe for target 'toupper.o' failed make[1]: *** [toupper.o] Error 1
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/fileno.c: In function ‘fileno’:
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/fileno.c:18:15: error: ‘FILE {aka struct _IO_FILE}’ has no member named ‘fd’

  return stream->fd;
               ^~

/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/Makefile.inc:23: recipe for target 'fileno.o' failed make[1]: *** [fileno.o] Error 1
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/putc.c: In function ‘_IO_putc’:
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/putc.c:21:18: error: ‘FILE {aka struct _IO_FILE}’ has no member named ‘fd’
if (write(stream->fd, &outchar, 1) == 1)

                  ^~
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/vfprintf.c: In function ‘vfprintf’:
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/vfprintf.c:23:14: error: ‘FILE {aka struct _IO_FILE}’ has no member named ‘fd’
  write(stream->fd, buffer, count);
              ^~

/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/Makefile.inc:23: recipe for target 'putc.o' failed make[1]: *** [putc.o] Error 1 /home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/Makefile.inc:23: recipe for target 'vfprintf.o' failed make[1]: *** [vfprintf.o] Error 1
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/puts.c: In function ‘puts’:
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/puts.c:24:20: error: ‘struct _IO_FILE’ has no member named ‘fd’

  ret = write(stdout->fd, str, strlen(str));
                    ^~
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/puts.c:25:14: error: ‘struct _IO_FILE’ has no member named ‘fd’
  write(stdout->fd, "\r\n", 2);
              ^~
/home/cborntra/REPOS/qemu/pc-bios/s390-ccw/netmain.c:25:18: fatal error: tftp.h: No such file or directory
 #include <tftp.h>
                  ^
compilation terminated.
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/vsnprintf.c: In function ‘vsnprintf’:
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/vsnprintf.c:283:15: warning: implicit declaration of function ‘va_arg’ [-Wimplicit-function-declaration]
      formstr, va_arg(arg, void *));
               ^~~~~~
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/vsnprintf.c:283:27: error: expected expression before ‘void’
      formstr, va_arg(arg, void *));
                           ^~~~

/home/cborntra/REPOS/qemu/rules.mak:66: recipe for target 'netmain.o' failed
make[1]: *** [netmain.o] Error 1 /home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/Makefile.inc:23: recipe for target 'puts.o' failed make[1]: *** [puts.o] Error 1 /home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/Makefile.inc:23: recipe for target 'vsnprintf.o' failed make[1]: *** [vsnprintf.o] Error 1 /home/cborntra/REPOS/qemu/pc-bios/s390-ccw/virtio-net.c:19:22: fatal error: ethernet.h: No such file or directory

 #include <ethernet.h>
                      ^
compilation terminated.
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:18:21: error: unknown field ‘fd’ specified in initializer
 FILE stdin_data = { .fd = 0, .mode = _IOLBF, .pos = 0,
                     ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:18:30: error: unknown field ‘mode’ specified in initializer
 FILE stdin_data = { .fd = 0, .mode = _IOLBF, .pos = 0,
                              ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:18:38: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
 FILE stdin_data = { .fd = 0, .mode = _IOLBF, .pos = 0,
                                      ^~~~~~
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:18:38: note: (near initialization for ‘stdin_data._IO_read_ptr’)
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:18:46: error: unknown field ‘pos’ specified in initializer
 FILE stdin_data = { .fd = 0, .mode = _IOLBF, .pos = 0,
                                              ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:19:7: error: unknown field ‘buf’ specified in initializer
       .buf = stdin_buffer, .bufsiz = BUFSIZ };
       ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:19:28: error: unknown field ‘bufsiz’ specified in initializer
       .buf = stdin_buffer, .bufsiz = BUFSIZ };
                            ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:19:38: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
       .buf = stdin_buffer, .bufsiz = BUFSIZ };
                                      ^~~~~~
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:19:38: note: (near initialization for ‘stdin_data._IO_write_base’)
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:20:22: error: unknown field ‘fd’ specified in initializer
 FILE stdout_data = { .fd = 1, .mode = _IOLBF, .pos = 0,
                      ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:20:31: error: unknown field ‘mode’ specified in initializer
 FILE stdout_data = { .fd = 1, .mode = _IOLBF, .pos = 0,
                               ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:20:39: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
 FILE stdout_data = { .fd = 1, .mode = _IOLBF, .pos = 0,
                                       ^~~~~~
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:20:39: note: (near initialization for ‘stdout_data._IO_read_ptr’)
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:20:47: error: unknown field ‘pos’ specified in initializer
 FILE stdout_data = { .fd = 1, .mode = _IOLBF, .pos = 0,
                                               ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:21:8: error: unknown field ‘buf’ specified in initializer
        .buf = stdout_buffer, .bufsiz = BUFSIZ };
        ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:21:30: error: unknown field ‘bufsiz’ specified in initializer
        .buf = stdout_buffer, .bufsiz = BUFSIZ };
                              ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:21:40: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
        .buf = stdout_buffer, .bufsiz = BUFSIZ };
                                        ^~~~~~
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:21:40: note: (near initialization for ‘stdout_data._IO_write_base’)
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:22:22: error: unknown field ‘fd’ specified in initializer
 FILE stderr_data = { .fd = 2, .mode = _IONBF, .pos = 0,
                      ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:22:31: error: unknown field ‘mode’ specified in initializer
 FILE stderr_data = { .fd = 2, .mode = _IONBF, .pos = 0,
                               ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:22:39: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
 FILE stderr_data = { .fd = 2, .mode = _IONBF, .pos = 0,
                                       ^~~~~~
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:22:39: note: (near initialization for ‘stderr_data._IO_read_ptr’)
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:22:47: error: unknown field ‘pos’ specified in initializer
 FILE stderr_data = { .fd = 2, .mode = _IONBF, .pos = 0,
                                               ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:23:8: error: unknown field ‘buf’ specified in initializer
        .buf = NULL, .bufsiz = 0 };
        ^
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c:23:21: error: unknown field ‘bufsiz’ specified in initializer
        .buf = NULL, .bufsiz = 0 };
                     ^

/home/cborntra/REPOS/qemu/rules.mak:66: recipe for target 'virtio-net.o' failed

#20 lore raw
Quoted 84 lines · Christian Borntraeger
Quoted 73 lines · Thomas Huth

It's already possible to do a network boot of an s390x guest with an external netboot image based on a Linux installation, but it would be much more convenient if the s390-ccw firmware supported network booting right out of the box, without the need to assemble such an external image first.

This patch series now introduces a s390-netboot.img that can be used for network booting via DHCP and TFTP by re-using the networking stack from the SLOF firmware (see https://github.com/aik/SLOF/ for details), and adds a driver for virtio-net-ccw devices.

The code can only be built if the roms/SLOF submodule has been checked out (there is a sanity check for this in the Makefile). Once it has been built, you can download a combined kernel + initrd image via TFTP by starting QEMU for example with:

qemu-system-s390x ... -device virtio-net,netdev=n1,bootindex=1 \
-netdev user,id=n1,tftp=/path/to/tftp,bootfile=kernel.img

Note that this version does not support downloading via config files (i.e. pxelinux config files or .INS config files) yet. This will be added later.

v4:
- Cosmetic clean-ups according to the review feedback from v3
- Fixed bug in the find_dev() function (spotted by Cornelia in v3)
- Added an additional patch to remove some unused structs from virtio.h

v3:
- Adressed the review feedback from v2
- The last remaining SLOF patch has now been merged (big thanks to Alexey!), so not sending this as RFC anymore - it is ready now for integration, I think.

v2:
- Put the network boot loader into a separate s390-netboot.img binary instead of linking it directly into the s390-ccw firmware.
- Use the SLOF sources from the roms/SLOF/ submodule instead of copying them into the pc-bios/s390-ccw folder
- Removed the .INS config file loading code for now - only support combined kernel + initrd images in this initial implementation.

Thomas Huth (11):
pc-bios/s390-ccw: Move libc functions to separate header pc-bios/s390-ccw: Move ebc2asc to sclp.c
pc-bios/s390-ccw: Move virtio-block related functions into a separate
file
pc-bios/s390-ccw: Add a write() function for stdio pc-bios/s390-ccw: Move byteswap functions to a separate header pc-bios/s390-ccw: Remove unused structs from virtio.h pc-bios/s390-ccw: Add code for virtio feature negotiation roms/SLOF: Update submodule to latest status pc-bios/s390-ccw: Add core files for the network bootloading program pc-bios/s390-ccw: Add virtio-net driver code pc-bios/s390-ccw: Link libnet into the netboot image and do the TFTP
load

 pc-bios/s390-ccw/Makefile        |  13 +-
 pc-bios/s390-ccw/bootmap.c       |   2 +
 pc-bios/s390-ccw/bootmap.h       |  26 ---
 pc-bios/s390-ccw/bswap.h         |  30 ++++
 pc-bios/s390-ccw/libc.h          |  45 +++++
 pc-bios/s390-ccw/main.c          |  14 +-
 pc-bios/s390-ccw/netboot.mak     |  51 ++++++
 pc-bios/s390-ccw/netmain.c       | 362 +++++++++++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/s390-ccw.h      |  33 +---
 pc-bios/s390-ccw/sclp.c          |  37 ++--
 pc-bios/s390-ccw/virtio-blkdev.c | 296 ++++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/virtio-net.c    | 135 +++++++++++++++
 pc-bios/s390-ccw/virtio-scsi.c   |   1 +
 pc-bios/s390-ccw/virtio.c        | 306 ++++-----------------------------
 pc-bios/s390-ccw/virtio.h        |  46 ++---
Quoted 9 lines
 roms/SLOF                        |   2 +-
 16 files changed, 1011 insertions(+), 388 deletions(-)
 create mode 100644 pc-bios/s390-ccw/bswap.h
 create mode 100644 pc-bios/s390-ccw/libc.h
 create mode 100644 pc-bios/s390-ccw/netboot.mak
 create mode 100644 pc-bios/s390-ccw/netmain.c
 create mode 100644 pc-bios/s390-ccw/virtio-blkdev.c
 create mode 100644 pc-bios/s390-ccw/virtio-net.c
Quoted 5 lines

Was going to apply but then I updated the slof thing but building fails. Not sure yet why.

In file included from /home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/isdigit.c:13:0:
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/isdigit.c:15:17: error: expected ‘)’ before ‘ch’
int isdigit(int ch)

What a bummer! Sorry, I've only cross-compiled the s390-ccw BIOS so far, and that worked fine (since s390x machines are a little bit hard to get here), but seems like there is still something ugly going on when you build the code natively ... likely somethings wrong in the Makefile ... I'll try to figure it out ...

Thomas

#21 lore raw
Quoted 91 lines · Thomas Huth
Quoted 84 lines · Christian Borntraeger
Quoted 73 lines · Thomas Huth

It's already possible to do a network boot of an s390x guest with an external netboot image based on a Linux installation, but it would be much more convenient if the s390-ccw firmware supported network booting right out of the box, without the need to assemble such an external image first.

This patch series now introduces a s390-netboot.img that can be used for network booting via DHCP and TFTP by re-using the networking stack from the SLOF firmware (see https://github.com/aik/SLOF/ for details), and adds a driver for virtio-net-ccw devices.

The code can only be built if the roms/SLOF submodule has been checked out (there is a sanity check for this in the Makefile). Once it has been built, you can download a combined kernel + initrd image via TFTP by starting QEMU for example with:

qemu-system-s390x ... -device virtio-net,netdev=n1,bootindex=1 \
-netdev user,id=n1,tftp=/path/to/tftp,bootfile=kernel.img

Note that this version does not support downloading via config files (i.e. pxelinux config files or .INS config files) yet. This will be added later.

v4:
- Cosmetic clean-ups according to the review feedback from v3
- Fixed bug in the find_dev() function (spotted by Cornelia in v3)
- Added an additional patch to remove some unused structs from virtio.h

v3:
- Adressed the review feedback from v2
- The last remaining SLOF patch has now been merged (big thanks to Alexey!), so not sending this as RFC anymore - it is ready now for integration, I think.

v2:
- Put the network boot loader into a separate s390-netboot.img binary instead of linking it directly into the s390-ccw firmware.
- Use the SLOF sources from the roms/SLOF/ submodule instead of copying them into the pc-bios/s390-ccw folder
- Removed the .INS config file loading code for now - only support combined kernel + initrd images in this initial implementation.

Thomas Huth (11):
pc-bios/s390-ccw: Move libc functions to separate header pc-bios/s390-ccw: Move ebc2asc to sclp.c
pc-bios/s390-ccw: Move virtio-block related functions into a separate
file
pc-bios/s390-ccw: Add a write() function for stdio pc-bios/s390-ccw: Move byteswap functions to a separate header pc-bios/s390-ccw: Remove unused structs from virtio.h pc-bios/s390-ccw: Add code for virtio feature negotiation roms/SLOF: Update submodule to latest status pc-bios/s390-ccw: Add core files for the network bootloading program pc-bios/s390-ccw: Add virtio-net driver code pc-bios/s390-ccw: Link libnet into the netboot image and do the TFTP
load

 pc-bios/s390-ccw/Makefile        |  13 +-
 pc-bios/s390-ccw/bootmap.c       |   2 +
 pc-bios/s390-ccw/bootmap.h       |  26 ---
 pc-bios/s390-ccw/bswap.h         |  30 ++++
 pc-bios/s390-ccw/libc.h          |  45 +++++
 pc-bios/s390-ccw/main.c          |  14 +-
 pc-bios/s390-ccw/netboot.mak     |  51 ++++++
 pc-bios/s390-ccw/netmain.c       | 362 +++++++++++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/s390-ccw.h      |  33 +---
 pc-bios/s390-ccw/sclp.c          |  37 ++--
 pc-bios/s390-ccw/virtio-blkdev.c | 296 ++++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/virtio-net.c    | 135 +++++++++++++++
 pc-bios/s390-ccw/virtio-scsi.c   |   1 +
 pc-bios/s390-ccw/virtio.c        | 306 ++++-----------------------------
 pc-bios/s390-ccw/virtio.h        |  46 ++---
Quoted 9 lines
 roms/SLOF                        |   2 +-
 16 files changed, 1011 insertions(+), 388 deletions(-)
 create mode 100644 pc-bios/s390-ccw/bswap.h
 create mode 100644 pc-bios/s390-ccw/libc.h
 create mode 100644 pc-bios/s390-ccw/netboot.mak
 create mode 100644 pc-bios/s390-ccw/netmain.c
 create mode 100644 pc-bios/s390-ccw/virtio-blkdev.c
 create mode 100644 pc-bios/s390-ccw/virtio-net.c
Quoted 5 lines

Was going to apply but then I updated the slof thing but building fails. Not sure yet why.

In file included from /home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/isdigit.c:13:0:
/home/cborntra/REPOS/qemu/roms/SLOF/lib/libc/ctype/isdigit.c:15:17: error: expected ‘)’ before ‘ch’
int isdigit(int ch)

Quoted 8 lines

What a bummer! Sorry, I've only cross-compiled the s390-ccw BIOS so far, and that worked fine (since s390x machines are a little bit hard to get here), but seems like there is still something ugly going on when you build the code natively ... likely somethings wrong in the Makefile ... I'll try to figure it out ...

Thomas

I haven't tried recently, but you could consider using one of these here
https://developer.ibm.com/linuxone/

Signature · 8 lines
Mit freundlichen Grüßen/Kind Regards
   Viktor Mihajlovski

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martina Köderitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294