On 07/11/2017 03:56 PM, Thomas Huth wrote: > 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 >
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