From nobody Sat Apr 27 22:36:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528374258476470.18241765395135; Thu, 7 Jun 2018 05:24:18 -0700 (PDT) Received: from localhost ([::1]:57496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQtxh-0000aX-Q3 for importer@patchew.org; Thu, 07 Jun 2018 08:24:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQtw9-00088h-EX for qemu-devel@nongnu.org; Thu, 07 Jun 2018 08:22:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQtw8-0003qK-H6 for qemu-devel@nongnu.org; Thu, 07 Jun 2018 08:22:41 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38260 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQtw8-0003pc-C6; Thu, 07 Jun 2018 08:22:40 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA9F9401EF06; Thu, 7 Jun 2018 12:22:39 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-84.ams2.redhat.com [10.36.116.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 61DD0111AF2D; Thu, 7 Jun 2018 12:22:38 +0000 (UTC) From: Thomas Huth To: Christian Borntraeger , qemu-s390x@nongnu.org, Viktor Mihajlovski Date: Thu, 7 Jun 2018 14:22:31 +0200 Message-Id: <1528374154-14680-2-git-send-email-thuth@redhat.com> In-Reply-To: <1528374154-14680-1-git-send-email-thuth@redhat.com> References: <1528374154-14680-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 07 Jun 2018 12:22:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 07 Jun 2018 12:22:40 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 1/4] roms: Update SLOF submodule to current status X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Farhan Ali , Collin Walling , Cornelia Huck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We need the latest version of SLOF's libnet for adding pxelinux.cfg support in the s390-ccw bios, too. Signed-off-by: Thomas Huth Acked-by: Christian Borntraeger Tested-by: Viktor Mihajlovski --- I assume that Alexey will send a SLOF update soon, too, which supplies the SLOF.bin file for these changes. roms/SLOF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roms/SLOF b/roms/SLOF index fa98132..2317427 160000 --- a/roms/SLOF +++ b/roms/SLOF @@ -1 +1 @@ -Subproject commit fa981320a1e0968d6fc1b8de319723ff8212b337 +Subproject commit 2317427ce76006723f7ae103a6998ab41dd79c68 --=20 1.8.3.1 From nobody Sat Apr 27 22:36:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528374391827934.5555306865265; Thu, 7 Jun 2018 05:26:31 -0700 (PDT) Received: from localhost ([::1]:57513 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQtzn-0003Bl-4Q for importer@patchew.org; Thu, 07 Jun 2018 08:26:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQtwC-0008AP-6I for qemu-devel@nongnu.org; Thu, 07 Jun 2018 08:22:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQtwA-0003rs-Sb for qemu-devel@nongnu.org; Thu, 07 Jun 2018 08:22:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55410 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQtwA-0003rV-N2; Thu, 07 Jun 2018 08:22:42 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 39B8B402315A; Thu, 7 Jun 2018 12:22:42 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-84.ams2.redhat.com [10.36.116.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 549A2111AF2D; Thu, 7 Jun 2018 12:22:40 +0000 (UTC) From: Thomas Huth To: Christian Borntraeger , qemu-s390x@nongnu.org, Viktor Mihajlovski Date: Thu, 7 Jun 2018 14:22:32 +0200 Message-Id: <1528374154-14680-3-git-send-email-thuth@redhat.com> In-Reply-To: <1528374154-14680-1-git-send-email-thuth@redhat.com> References: <1528374154-14680-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 07 Jun 2018 12:22:42 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 07 Jun 2018 12:22:42 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 2/4] pc-bios/s390-ccw/net: Update code for the latest changes in SLOF X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Farhan Ali , Collin Walling , Cornelia Huck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The ip_version information now has to be stored in the filename_ip_t structure, and there is now a common function called tftp_get_error_info() which can be used to get the error string for a TFTP error code. We can also get rid of some superfluous "(char *)" casts now. Signed-off-by: Thomas Huth Acked-by: Christian Borntraeger Tested-by: Viktor Mihajlovski --- pc-bios/s390-ccw/netboot.mak | 2 +- pc-bios/s390-ccw/netmain.c | 86 +++++++++-------------------------------= ---- 2 files changed, 18 insertions(+), 70 deletions(-) diff --git a/pc-bios/s390-ccw/netboot.mak b/pc-bios/s390-ccw/netboot.mak index 4f64128..a73be36 100644 --- a/pc-bios/s390-ccw/netboot.mak +++ b/pc-bios/s390-ccw/netboot.mak @@ -34,7 +34,7 @@ STDLIB_OBJS =3D atoi.o atol.o strtoul.o strtol.o rand.o m= alloc.o free.o %.o : $(SLOF_DIR)/lib/libc/stdlib/%.c $(call quiet-command,$(CC) $(LIBC_CFLAGS) -c -o $@ $<,"CC","$(TARGET_DIR)= $@") =20 -STDIO_OBJS =3D sprintf.o vfprintf.o vsnprintf.o vsprintf.o fprintf.o \ +STDIO_OBJS =3D sprintf.o snprintf.o vfprintf.o vsnprintf.o vsprintf.o fpri= ntf.o \ printf.o putc.o puts.o putchar.o stdchnls.o fileno.o %.o : $(SLOF_DIR)/lib/libc/stdio/%.c $(call quiet-command,$(CC) $(LIBC_CFLAGS) -c -o $@ $<,"CC","$(TARGET_DIR)= $@") diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c index 6000241..d007fb7 100644 --- a/pc-bios/s390-ccw/netmain.c +++ b/pc-bios/s390-ccw/netmain.c @@ -47,7 +47,6 @@ IplParameterBlock iplb __attribute__((aligned(PAGE_SIZE))= ); static char cfgbuf[2048]; =20 static SubChannelId net_schid =3D { .one =3D 1 }; -static int ip_version =3D 4; static uint64_t dest_timer; =20 static uint64_t get_timer_ms(void) @@ -100,10 +99,10 @@ static int dhcp(struct filename_ip *fn_ip, int retries) printf("\nGiving up after %d DHCP requests\n", retries); return -1; } - ip_version =3D 4; + fn_ip->ip_version =3D 4; rc =3D dhcpv4(NULL, fn_ip); if (rc =3D=3D -1) { - ip_version =3D 6; + fn_ip->ip_version =3D 6; set_ipv6_address(fn_ip->fd, 0); rc =3D dhcpv6(NULL, fn_ip); if (rc =3D=3D 0) { @@ -137,8 +136,7 @@ static int tftp_load(filename_ip_t *fnip, void *buffer,= int len) tftp_err_t tftp_err; int rc; =20 - rc =3D tftp(fnip, buffer, len, DEFAULT_TFTP_RETRIES, &tftp_err, 1, 142= 8, - ip_version); + rc =3D tftp(fnip, buffer, len, DEFAULT_TFTP_RETRIES, &tftp_err); =20 if (rc < 0) { /* Make sure that error messages are put into a new line */ @@ -149,61 +147,11 @@ static int tftp_load(filename_ip_t *fnip, void *buffe= r, int len) printf(" TFTP: Received %s (%d KBytes)\n", fnip->filename, rc / 1= 024); } else if (rc > 0) { printf(" TFTP: Received %s (%d Bytes)\n", fnip->filename, rc); - } else if (rc =3D=3D -1) { - puts("unknown TFTP error"); - } else if (rc =3D=3D -2) { - printf("TFTP buffer of %d bytes is too small for %s\n", - len, fnip->filename); - } else if (rc =3D=3D -3) { - printf("file not found: %s\n", fnip->filename); - } else if (rc =3D=3D -4) { - puts("TFTP access violation"); - } else if (rc =3D=3D -5) { - puts("illegal TFTP operation"); - } else if (rc =3D=3D -6) { - puts("unknown TFTP transfer ID"); - } else if (rc =3D=3D -7) { - puts("no such TFTP user"); - } else if (rc =3D=3D -8) { - puts("TFTP blocksize negotiation failed"); - } else if (rc =3D=3D -9) { - puts("file exceeds maximum TFTP transfer size"); - } else if (rc <=3D -10 && rc >=3D -15) { - const char *icmp_err_str; - switch (rc) { - case -ICMP_NET_UNREACHABLE - 10: - icmp_err_str =3D "net unreachable"; - break; - case -ICMP_HOST_UNREACHABLE - 10: - icmp_err_str =3D "host unreachable"; - break; - case -ICMP_PROTOCOL_UNREACHABLE - 10: - icmp_err_str =3D "protocol unreachable"; - break; - case -ICMP_PORT_UNREACHABLE - 10: - icmp_err_str =3D "port unreachable"; - break; - case -ICMP_FRAGMENTATION_NEEDED - 10: - icmp_err_str =3D "fragmentation needed and DF set"; - break; - case -ICMP_SOURCE_ROUTE_FAILED - 10: - icmp_err_str =3D "source route failed"; - break; - default: - icmp_err_str =3D " UNKNOWN"; - break; - } - printf("ICMP ERROR \"%s\"\n", icmp_err_str); - } else if (rc =3D=3D -40) { - printf("TFTP error occurred after %d bad packets received", - tftp_err.bad_tftp_packets); - } else if (rc =3D=3D -41) { - printf("TFTP error occurred after missing %d responses", - tftp_err.no_packets); - } else if (rc =3D=3D -42) { - printf("TFTP error missing block %d, expected block was %d", - tftp_err.blocks_missed, - tftp_err.blocks_received); + } else { + const char *errstr =3D NULL; + int ecode; + tftp_get_error_info(fnip, &tftp_err, rc, &errstr, &ecode); + printf("TFTP error: %s\n", errstr ? errstr : "unknown error"); } =20 return rc; @@ -231,7 +179,7 @@ static int net_init(filename_ip_t *fn_ip) =20 rc =3D dhcp(fn_ip, DEFAULT_BOOT_RETRIES); if (rc >=3D 0) { - if (ip_version =3D=3D 4) { + if (fn_ip->ip_version =3D=3D 4) { set_ipv4_address(fn_ip->own_ip); } } else { @@ -239,11 +187,11 @@ static int net_init(filename_ip_t *fn_ip) return -101; } =20 - if (ip_version =3D=3D 4) { + if (fn_ip->ip_version =3D=3D 4) { printf(" Using IPv4 address: %d.%d.%d.%d\n", (fn_ip->own_ip >> 24) & 0xFF, (fn_ip->own_ip >> 16) & 0xFF, (fn_ip->own_ip >> 8) & 0xFF, fn_ip->own_ip & 0xFF); - } else if (ip_version =3D=3D 6) { + } else if (fn_ip->ip_version =3D=3D 6) { char ip6_str[40]; ipv6_to_str(fn_ip->own_ip6.addr, ip6_str); printf(" Using IPv6 address: %s\n", ip6_str); @@ -261,17 +209,17 @@ static int net_init(filename_ip_t *fn_ip) } =20 printf(" Using TFTP server: "); - if (ip_version =3D=3D 4) { + if (fn_ip->ip_version =3D=3D 4) { printf("%d.%d.%d.%d\n", (fn_ip->server_ip >> 24) & 0xFF, (fn_ip->server_ip >> 16) &= 0xFF, (fn_ip->server_ip >> 8) & 0xFF, fn_ip->server_ip & 0xFF); - } else if (ip_version =3D=3D 6) { + } else if (fn_ip->ip_version =3D=3D 6) { char ip6_str[40]; ipv6_to_str(fn_ip->server_ip6.addr, ip6_str); printf("%s\n", ip6_str); } =20 - if (strlen((char *)fn_ip->filename) > 0) { + if (strlen(fn_ip->filename) > 0) { printf(" Bootfile name: '%s'\n", fn_ip->filename); } =20 @@ -280,7 +228,7 @@ static int net_init(filename_ip_t *fn_ip) =20 static void net_release(filename_ip_t *fn_ip) { - if (ip_version =3D=3D 4) { + if (fn_ip->ip_version =3D=3D 4) { dhcp_send_release(fn_ip->fd); } } @@ -322,7 +270,7 @@ static int handle_ins_cfg(filename_ip_t *fn_ip, char *c= fg, int cfgsize) return -1; } *ptr =3D 0; - strncpy((char *)fn_ip->filename, insbuf, sizeof(fn_ip->filename)); + strncpy(fn_ip->filename, insbuf, sizeof(fn_ip->filename)); destaddr =3D (char *)atol(ptr + 1); rc =3D tftp_load(fn_ip, destaddr, (long)_start - (long)destaddr); if (rc <=3D 0) { @@ -455,7 +403,7 @@ void main(void) panic("Network initialization failed. Halting.\n"); } =20 - fnlen =3D strlen((char *)fn_ip.filename); + fnlen =3D strlen(fn_ip.filename); if (fnlen > 0 && fn_ip.filename[fnlen - 1] !=3D '/') { rc =3D net_try_direct_tftp_load(&fn_ip); } --=20 1.8.3.1 From nobody Sat Apr 27 22:36:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528374388468128.45087172102262; Thu, 7 Jun 2018 05:26:28 -0700 (PDT) Received: from localhost ([::1]:57512 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQtzn-0003Be-Js for importer@patchew.org; Thu, 07 Jun 2018 08:26:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQtwE-0008Bj-P8 for qemu-devel@nongnu.org; Thu, 07 Jun 2018 08:22:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQtwC-0003tU-VL for qemu-devel@nongnu.org; Thu, 07 Jun 2018 08:22:46 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57476 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQtwC-0003tB-Mo; Thu, 07 Jun 2018 08:22:44 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A3624070481; Thu, 7 Jun 2018 12:22:44 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-84.ams2.redhat.com [10.36.116.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6EC56111AF2D; Thu, 7 Jun 2018 12:22:42 +0000 (UTC) From: Thomas Huth To: Christian Borntraeger , qemu-s390x@nongnu.org, Viktor Mihajlovski Date: Thu, 7 Jun 2018 14:22:33 +0200 Message-Id: <1528374154-14680-4-git-send-email-thuth@redhat.com> In-Reply-To: <1528374154-14680-1-git-send-email-thuth@redhat.com> References: <1528374154-14680-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 07 Jun 2018 12:22:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 07 Jun 2018 12:22:44 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 3/4] pc-bios/s390-ccw/net: Add support for pxelinux-style config files X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Farhan Ali , Collin Walling , Cornelia Huck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Since it is quite cumbersome to manually create a combined kernel with initrd image for network booting, we now support loading via pxelinux configuration files, too. In these files, the kernel, initrd and command line parameters can be specified seperately, and the firmware then takes care of glueing everything together in memory after the files have been downloaded. See this URL for details about the config file layout: https://www.syslinux.org/wiki/index.php?title=3DPXELINUX The user can either specify a config file directly as bootfile via DHCP (but in this case, the file has to start with the magic "# pxelinux" comment so we can distinguish it from binary kernels), or a folder (i.e. the bootfile name must end with "/") where the firmware should look for the typical pxelinux.cfg file names, e.g. based on MAC or IP address. We also support the pxelinux.cfg DHCP options 209 and 210 from RFC 5071. Signed-off-by: Thomas Huth Acked-by: Christian Borntraeger Tested-by: Viktor Mihajlovski --- pc-bios/s390-ccw/netboot.mak | 7 ++-- pc-bios/s390-ccw/netmain.c | 86 ++++++++++++++++++++++++++++++++++++++++= +++- 2 files changed, 89 insertions(+), 4 deletions(-) diff --git a/pc-bios/s390-ccw/netboot.mak b/pc-bios/s390-ccw/netboot.mak index a73be36..8af0cfd 100644 --- a/pc-bios/s390-ccw/netboot.mak +++ b/pc-bios/s390-ccw/netboot.mak @@ -25,8 +25,9 @@ CTYPE_OBJS =3D isdigit.o isxdigit.o toupper.o %.o : $(SLOF_DIR)/lib/libc/ctype/%.c $(call quiet-command,$(CC) $(LIBC_CFLAGS) -c -o $@ $<,"CC","$(TARGET_DIR)= $@") =20 -STRING_OBJS =3D strcat.o strchr.o strcmp.o strcpy.o strlen.o strncmp.o str= ncpy.o \ - strstr.o memset.o memcpy.o memmove.o memcmp.o +STRING_OBJS =3D strcat.o strchr.o strrchr.o strcpy.o strlen.o strncpy.o \ + strcmp.o strncmp.o strcasecmp.o strncasecmp.o strstr.o \ + memset.o memcpy.o memmove.o memcmp.o %.o : $(SLOF_DIR)/lib/libc/string/%.c $(call quiet-command,$(CC) $(LIBC_CFLAGS) -c -o $@ $<,"CC","$(TARGET_DIR)= $@") =20 @@ -50,7 +51,7 @@ libc.a: $(LIBCOBJS) # libnet files: =20 LIBNETOBJS :=3D 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 + dhcpv6.o ethernet.o ipv4.o ndp.o tftp.o pxelinux.o LIBNETCFLAGS :=3D $(QEMU_CFLAGS) -DDHCPARCH=3D0x1F $(LIBC_INC) $(LIBNET_IN= C) =20 %.o : $(SLOF_DIR)/lib/libnet/%.c diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c index d007fb7..c059546 100644 --- a/pc-bios/s390-ccw/netmain.c +++ b/pc-bios/s390-ccw/netmain.c @@ -30,6 +30,7 @@ #include #include #include +#include =20 #include "s390-ccw.h" #include "virtio.h" @@ -41,12 +42,14 @@ extern char _start[]; =20 #define KERNEL_ADDR ((void *)0L) #define KERNEL_MAX_SIZE ((long)_start) +#define ARCH_COMMAND_LINE_SIZE 896 /* Taken from Linux kerne= l */ =20 char stack[PAGE_SIZE * 8] __attribute__((aligned(PAGE_SIZE))); IplParameterBlock iplb __attribute__((aligned(PAGE_SIZE))); static char cfgbuf[2048]; =20 static SubChannelId net_schid =3D { .one =3D 1 }; +static uint8_t mac[6]; static uint64_t dest_timer; =20 static uint64_t get_timer_ms(void) @@ -159,7 +162,6 @@ static int tftp_load(filename_ip_t *fnip, void *buffer,= int len) =20 static int net_init(filename_ip_t *fn_ip) { - uint8_t mac[6]; int rc; =20 memset(fn_ip, 0, sizeof(filename_ip_t)); @@ -234,6 +236,66 @@ static void net_release(filename_ip_t *fn_ip) } =20 /** + * Load a kernel with initrd (i.e. with the information that we've got from + * a pxelinux.cfg config file) + */ +static int load_kernel_with_initrd(filename_ip_t *fn_ip, + struct pl_cfg_entry *entry) +{ + int rc; + + printf("Loading pxelinux.cfg entry '%s'\n", entry->label); + + if (!entry->kernel) { + printf("Kernel entry is missing!\n"); + return -1; + } + + strncpy(fn_ip->filename, entry->kernel, sizeof(fn_ip->filename)); + rc =3D tftp_load(fn_ip, KERNEL_ADDR, KERNEL_MAX_SIZE); + if (rc < 0) { + return rc; + } + + if (entry->initrd) { + uint64_t iaddr =3D (rc + 0xfff) & ~0xfffUL; + + strncpy(fn_ip->filename, entry->initrd, sizeof(fn_ip->filename)); + rc =3D tftp_load(fn_ip, (void *)iaddr, KERNEL_MAX_SIZE - iaddr); + if (rc < 0) { + return rc; + } + /* Patch location and size: */ + *(uint64_t *)0x10408 =3D iaddr; + *(uint64_t *)0x10410 =3D rc; + rc +=3D iaddr; + } + + if (entry->append) { + strncpy((char *)0x10480, entry->append, ARCH_COMMAND_LINE_SIZE); + } + + return rc; +} + +#define MAX_PXELINUX_ENTRIES 16 + +static int net_try_pxelinux_cfg(filename_ip_t *fn_ip) +{ + struct pl_cfg_entry entries[MAX_PXELINUX_ENTRIES]; + int num_ent, def_ent =3D 0; + + num_ent =3D pxelinux_load_parse_cfg(fn_ip, mac, NULL, DEFAULT_TFTP_RET= RIES, + cfgbuf, sizeof(cfgbuf), + entries, MAX_PXELINUX_ENTRIES, &def_= ent); + if (num_ent > 0) { + return load_kernel_with_initrd(fn_ip, &entries[def_ent]); + } + + return -1; +} + +/** * Load via information from a .INS file (which can be found on CD-ROMs * for example) */ @@ -302,6 +364,25 @@ static int net_try_direct_tftp_load(filename_ip_t *fn_= ip) if (!strncmp("* ", cfgbuf, 2)) { return handle_ins_cfg(fn_ip, cfgbuf, rc); } + /* + * pxelinux.cfg support via bootfile name is just here for develop= ers' + * convenience (it eases testing with the built-in DHCP server of = QEMU + * that does not support RFC 5071). The official way to configure a + * pxelinux.cfg file name is to use DHCP options 209 and 210 inste= ad. + * So only use the pxelinux.cfg parser here for files that start w= ith + * a magic comment string. + */ + if (!strncasecmp("# pxelinux", cfgbuf, 10)) { + struct pl_cfg_entry entries[MAX_PXELINUX_ENTRIES]; + int num_ent, def_ent =3D 0; + + num_ent =3D pxelinux_parse_cfg(cfgbuf, sizeof(cfgbuf), entries, + MAX_PXELINUX_ENTRIES, &def_ent); + if (num_ent <=3D 0) { + return -1; + } + return load_kernel_with_initrd(fn_ip, &entries[def_ent]); + } } =20 /* Move kernel to right location */ @@ -407,6 +488,9 @@ void main(void) if (fnlen > 0 && fn_ip.filename[fnlen - 1] !=3D '/') { rc =3D net_try_direct_tftp_load(&fn_ip); } + if (rc <=3D 0) { + rc =3D net_try_pxelinux_cfg(&fn_ip); + } =20 net_release(&fn_ip); =20 --=20 1.8.3.1 From nobody Sat Apr 27 22:36:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 152837453752589.93146303525589; Thu, 7 Jun 2018 05:28:57 -0700 (PDT) Received: from localhost ([::1]:57527 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQu2C-0005R7-SR for importer@patchew.org; Thu, 07 Jun 2018 08:28:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQtwK-0008H8-Pb for qemu-devel@nongnu.org; Thu, 07 Jun 2018 08:22:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQtwE-0003uu-Rz for qemu-devel@nongnu.org; Thu, 07 Jun 2018 08:22:52 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59118 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQtwE-0003uP-Lq; Thu, 07 Jun 2018 08:22:46 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3EF51859B5; Thu, 7 Jun 2018 12:22:46 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-84.ams2.redhat.com [10.36.116.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 854CE111AF2D; Thu, 7 Jun 2018 12:22:44 +0000 (UTC) From: Thomas Huth To: Christian Borntraeger , qemu-s390x@nongnu.org, Viktor Mihajlovski Date: Thu, 7 Jun 2018 14:22:34 +0200 Message-Id: <1528374154-14680-5-git-send-email-thuth@redhat.com> In-Reply-To: <1528374154-14680-1-git-send-email-thuth@redhat.com> References: <1528374154-14680-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 07 Jun 2018 12:22:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 07 Jun 2018 12:22:46 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 4/4] pc-bios/s390-ccw/net: Try to load pxelinux.cfg file accoring to the UUID X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Farhan Ali , Collin Walling , Cornelia Huck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" With the STSI instruction, we can get the UUID of the current VM instance, so we can support loading pxelinux config files via UUID in the file name, too. Signed-off-by: Thomas Huth Acked-by: Christian Borntraeger Tested-by: Viktor Mihajlovski --- pc-bios/s390-ccw/netmain.c | 56 ++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c index c059546..0392131 100644 --- a/pc-bios/s390-ccw/netmain.c +++ b/pc-bios/s390-ccw/netmain.c @@ -44,6 +44,9 @@ extern char _start[]; #define KERNEL_MAX_SIZE ((long)_start) #define ARCH_COMMAND_LINE_SIZE 896 /* Taken from Linux kerne= l */ =20 +/* STSI 3.2.2 offset of first vmdb + offset of uuid inside vmdb */ +#define STSI322_VMDB_UUID_OFFSET ((8 + 12) * 4) + char stack[PAGE_SIZE * 8] __attribute__((aligned(PAGE_SIZE))); IplParameterBlock iplb __attribute__((aligned(PAGE_SIZE))); static char cfgbuf[2048]; @@ -236,6 +239,56 @@ static void net_release(filename_ip_t *fn_ip) } =20 /** + * Retrieve the Universally Unique Identifier of the VM. + * @return UUID string, or NULL in case of errors + */ +static const char *get_uuid(void) +{ + register int r0 asm("0"); + register int r1 asm("1"); + uint8_t *mem, *buf, uuid[16]; + int i, cc, chk =3D 0; + static char uuid_str[37]; + + mem =3D malloc(2 * PAGE_SIZE); + if (!mem) { + puts("Out of memory ... can not get UUID."); + return NULL; + } + buf =3D (uint8_t *)(((uint64_t)mem + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)= ); + memset(buf, 0, PAGE_SIZE); + + /* Get SYSIB 3.2.2 */ + r0 =3D (3 << 28) | 2; + r1 =3D 2; + asm volatile(" stsi 0(%[addr])\n" + " ipm %[cc]\n" + " srl %[cc],28\n" + : [cc] "=3Dd" (cc) + : "d" (r0), "d" (r1), [addr] "a" (buf) + : "cc", "memory"); + if (cc) { + return NULL; + } + + for (i =3D 0; i < 16; i++) { + uuid[i] =3D buf[STSI322_VMDB_UUID_OFFSET + i]; + chk |=3D uuid[i]; + } + free(mem); + if (!chk) { + return NULL; + } + + sprintf(uuid_str, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" + "%02x%02x%02x%02x%02x%02x", uuid[0], uuid[1], uuid[2], uuid[3], + uuid[4], uuid[5], uuid[6], uuid[7], uuid[8], uuid[9], uuid[10], + uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]); + + return uuid_str; +} + +/** * Load a kernel with initrd (i.e. with the information that we've got from * a pxelinux.cfg config file) */ @@ -285,7 +338,8 @@ static int net_try_pxelinux_cfg(filename_ip_t *fn_ip) struct pl_cfg_entry entries[MAX_PXELINUX_ENTRIES]; int num_ent, def_ent =3D 0; =20 - num_ent =3D pxelinux_load_parse_cfg(fn_ip, mac, NULL, DEFAULT_TFTP_RET= RIES, + num_ent =3D pxelinux_load_parse_cfg(fn_ip, mac, get_uuid(), + DEFAULT_TFTP_RETRIES, cfgbuf, sizeof(cfgbuf), entries, MAX_PXELINUX_ENTRIES, &def_= ent); if (num_ent > 0) { --=20 1.8.3.1