From patchwork Thu Jun 14 14:53:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 929496 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41668P3yGdz9s2g for ; Fri, 15 Jun 2018 00:54:13 +1000 (AEST) Received: from localhost ([::1]:41090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTTda-0006y3-Pl for incoming@patchwork.ozlabs.org; Thu, 14 Jun 2018 10:54:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTTcy-0006xI-Iy for qemu-devel@nongnu.org; Thu, 14 Jun 2018 10:53:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTTcw-0006Qf-4X for qemu-devel@nongnu.org; Thu, 14 Jun 2018 10:53:32 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:46552 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 1fTTcv-0006QT-VE; Thu, 14 Jun 2018 10:53:30 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7193940122D8; Thu, 14 Jun 2018 14:53:29 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-79.ams2.redhat.com [10.36.116.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC8111C5AD; Thu, 14 Jun 2018 14:53:26 +0000 (UTC) From: Thomas Huth To: Cornelia Huck , qemu-s390x@nongnu.org Date: Thu, 14 Jun 2018 16:53:17 +0200 Message-Id: <1528988003-21855-2-git-send-email-thuth@redhat.com> In-Reply-To: <1528988003-21855-1-git-send-email-thuth@redhat.com> References: <1528988003-21855-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 14 Jun 2018 14:53:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 14 Jun 2018 14:53:29 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL SUBSYSTEM s390x 1/7] pc-bios/s390-ccw: define loadparm length 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: Alexey Kardashevskiy , Christian Borntraeger , Collin Walling , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Collin Walling Loadparm is defined by the s390 architecture to be 8 bytes in length. Let's define this size in the s390-ccw bios. Suggested-by: Laszlo Ersek Signed-off-by: Collin Walling Reviewed-by: Laszlo Ersek Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth --- pc-bios/s390-ccw/iplb.h | 4 +++- pc-bios/s390-ccw/main.c | 8 ++++---- pc-bios/s390-ccw/sclp.c | 2 +- pc-bios/s390-ccw/sclp.h | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pc-bios/s390-ccw/iplb.h b/pc-bios/s390-ccw/iplb.h index ded20c8..772d5c5 100644 --- a/pc-bios/s390-ccw/iplb.h +++ b/pc-bios/s390-ccw/iplb.h @@ -12,6 +12,8 @@ #ifndef IPLB_H #define IPLB_H +#define LOADPARM_LEN 8 + struct IplBlockCcw { uint8_t reserved0[85]; uint8_t ssid; @@ -61,7 +63,7 @@ struct IplParameterBlock { uint8_t pbt; uint8_t flags; uint16_t reserved01; - uint8_t loadparm[8]; + uint8_t loadparm[LOADPARM_LEN]; union { IplBlockCcw ccw; IplBlockFcp fcp; diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index 26f9adf..544851d 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -15,7 +15,7 @@ char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE))); static SubChannelId blk_schid = { .one = 1 }; IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE))); -static char loadparm_str[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static char loadparm_str[LOADPARM_LEN + 1] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; QemuIplParameters qipl; #define LOADPARM_PROMPT "PROMPT " @@ -80,13 +80,13 @@ static bool find_dev(Schib *schib, int dev_no) static void menu_setup(void) { - if (memcmp(loadparm_str, LOADPARM_PROMPT, 8) == 0) { + if (memcmp(loadparm_str, LOADPARM_PROMPT, LOADPARM_LEN) == 0) { menu_set_parms(QIPL_FLAG_BM_OPTS_CMD, 0); return; } /* If loadparm was set to any other value, then do not enable menu */ - if (memcmp(loadparm_str, LOADPARM_EMPTY, 8) != 0) { + if (memcmp(loadparm_str, LOADPARM_EMPTY, LOADPARM_LEN) != 0) { return; } @@ -117,7 +117,7 @@ static void virtio_setup(void) enable_mss_facility(); sclp_get_loadparm_ascii(loadparm_str); - memcpy(ldp + 10, loadparm_str, 8); + memcpy(ldp + 10, loadparm_str, LOADPARM_LEN); sclp_print(ldp); memcpy(&qipl, early_qipl, sizeof(QemuIplParameters)); diff --git a/pc-bios/s390-ccw/sclp.c b/pc-bios/s390-ccw/sclp.c index 3836cb4..c0223fa 100644 --- a/pc-bios/s390-ccw/sclp.c +++ b/pc-bios/s390-ccw/sclp.c @@ -114,7 +114,7 @@ void sclp_get_loadparm_ascii(char *loadparm) memset((char *)_sccb, 0, sizeof(ReadInfo)); sccb->h.length = sizeof(ReadInfo); if (!sclp_service_call(SCLP_CMDW_READ_SCP_INFO, sccb)) { - ebcdic_to_ascii((char *) sccb->loadparm, loadparm, 8); + ebcdic_to_ascii((char *) sccb->loadparm, loadparm, LOADPARM_LEN); } } diff --git a/pc-bios/s390-ccw/sclp.h b/pc-bios/s390-ccw/sclp.h index 0dd987f..8450161 100644 --- a/pc-bios/s390-ccw/sclp.h +++ b/pc-bios/s390-ccw/sclp.h @@ -56,7 +56,7 @@ typedef struct ReadInfo { uint16_t rnmax; uint8_t rnsize; uint8_t reserved[13]; - uint8_t loadparm[8]; + uint8_t loadparm[LOADPARM_LEN]; } __attribute__((packed)) ReadInfo; typedef struct SCCB { From patchwork Thu Jun 14 14:53:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 929498 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41668S42mtz9s2g for ; Fri, 15 Jun 2018 00:54:16 +1000 (AEST) Received: from localhost ([::1]:41093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTTde-00072C-7L for incoming@patchwork.ozlabs.org; Thu, 14 Jun 2018 10:54:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39909) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTTcy-0006xL-Nd for qemu-devel@nongnu.org; Thu, 14 Jun 2018 10:53:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTTcy-0006RN-52 for qemu-devel@nongnu.org; Thu, 14 Jun 2018 10:53:32 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42934 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 1fTTcy-0006Qy-0l; Thu, 14 Jun 2018 10:53:32 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7C281818BAFD; Thu, 14 Jun 2018 14:53:31 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-79.ams2.redhat.com [10.36.116.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0F0C1C707; Thu, 14 Jun 2018 14:53:29 +0000 (UTC) From: Thomas Huth To: Cornelia Huck , qemu-s390x@nongnu.org Date: Thu, 14 Jun 2018 16:53:18 +0200 Message-Id: <1528988003-21855-3-git-send-email-thuth@redhat.com> In-Reply-To: <1528988003-21855-1-git-send-email-thuth@redhat.com> References: <1528988003-21855-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 14 Jun 2018 14:53:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 14 Jun 2018 14:53:31 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL SUBSYSTEM s390x 2/7] 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: Alexey Kardashevskiy , Christian Borntraeger , Collin Walling , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 From patchwork Thu Jun 14 14:53:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 929500 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4166Cj13YGz9s19 for ; Fri, 15 Jun 2018 00:57:03 +1000 (AEST) Received: from localhost ([::1]:41109 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTTgK-0001D4-Uf for incoming@patchwork.ozlabs.org; Thu, 14 Jun 2018 10:57:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTTd1-00070k-Ha for qemu-devel@nongnu.org; Thu, 14 Jun 2018 10:53:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTTd0-0006SX-2N for qemu-devel@nongnu.org; Thu, 14 Jun 2018 10:53:35 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53980 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 1fTTcz-0006Rz-UH; Thu, 14 Jun 2018 10:53:34 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6FFA98886E; Thu, 14 Jun 2018 14:53:33 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-79.ams2.redhat.com [10.36.116.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB5381C5AD; Thu, 14 Jun 2018 14:53:31 +0000 (UTC) From: Thomas Huth To: Cornelia Huck , qemu-s390x@nongnu.org Date: Thu, 14 Jun 2018 16:53:19 +0200 Message-Id: <1528988003-21855-4-git-send-email-thuth@redhat.com> In-Reply-To: <1528988003-21855-1-git-send-email-thuth@redhat.com> References: <1528988003-21855-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 14 Jun 2018 14:53:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 14 Jun 2018 14:53:33 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL SUBSYSTEM s390x 3/7] 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: Alexey Kardashevskiy , Christian Borntraeger , Collin Walling , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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. Acked-by: Christian Borntraeger Tested-by: Viktor Mihajlovski Signed-off-by: Thomas Huth --- 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 = atoi.o atol.o strtoul.o strtol.o rand.o malloc.o free.o %.o : $(SLOF_DIR)/lib/libc/stdlib/%.c $(call quiet-command,$(CC) $(LIBC_CFLAGS) -c -o $@ $<,"CC","$(TARGET_DIR)$@") -STDIO_OBJS = sprintf.o vfprintf.o vsnprintf.o vsprintf.o fprintf.o \ +STDIO_OBJS = sprintf.o snprintf.o vfprintf.o vsnprintf.o vsprintf.o fprintf.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]; static SubChannelId net_schid = { .one = 1 }; -static int ip_version = 4; static uint64_t dest_timer; 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 = 4; + fn_ip->ip_version = 4; rc = dhcpv4(NULL, fn_ip); if (rc == -1) { - ip_version = 6; + fn_ip->ip_version = 6; set_ipv6_address(fn_ip->fd, 0); rc = dhcpv6(NULL, fn_ip); if (rc == 0) { @@ -137,8 +136,7 @@ static int tftp_load(filename_ip_t *fnip, void *buffer, int len) tftp_err_t tftp_err; int rc; - rc = tftp(fnip, buffer, len, DEFAULT_TFTP_RETRIES, &tftp_err, 1, 1428, - ip_version); + rc = tftp(fnip, buffer, len, DEFAULT_TFTP_RETRIES, &tftp_err); 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 *buffer, int len) printf(" TFTP: Received %s (%d KBytes)\n", fnip->filename, rc / 1024); } else if (rc > 0) { printf(" TFTP: Received %s (%d Bytes)\n", fnip->filename, rc); - } else if (rc == -1) { - puts("unknown TFTP error"); - } else if (rc == -2) { - printf("TFTP buffer of %d bytes is too small for %s\n", - len, fnip->filename); - } else if (rc == -3) { - printf("file not found: %s\n", fnip->filename); - } else if (rc == -4) { - puts("TFTP access violation"); - } else if (rc == -5) { - puts("illegal TFTP operation"); - } else if (rc == -6) { - puts("unknown TFTP transfer ID"); - } else if (rc == -7) { - puts("no such TFTP user"); - } else if (rc == -8) { - puts("TFTP blocksize negotiation failed"); - } else if (rc == -9) { - puts("file exceeds maximum TFTP transfer size"); - } else if (rc <= -10 && rc >= -15) { - const char *icmp_err_str; - switch (rc) { - case -ICMP_NET_UNREACHABLE - 10: - icmp_err_str = "net unreachable"; - break; - case -ICMP_HOST_UNREACHABLE - 10: - icmp_err_str = "host unreachable"; - break; - case -ICMP_PROTOCOL_UNREACHABLE - 10: - icmp_err_str = "protocol unreachable"; - break; - case -ICMP_PORT_UNREACHABLE - 10: - icmp_err_str = "port unreachable"; - break; - case -ICMP_FRAGMENTATION_NEEDED - 10: - icmp_err_str = "fragmentation needed and DF set"; - break; - case -ICMP_SOURCE_ROUTE_FAILED - 10: - icmp_err_str = "source route failed"; - break; - default: - icmp_err_str = " UNKNOWN"; - break; - } - printf("ICMP ERROR \"%s\"\n", icmp_err_str); - } else if (rc == -40) { - printf("TFTP error occurred after %d bad packets received", - tftp_err.bad_tftp_packets); - } else if (rc == -41) { - printf("TFTP error occurred after missing %d responses", - tftp_err.no_packets); - } else if (rc == -42) { - printf("TFTP error missing block %d, expected block was %d", - tftp_err.blocks_missed, - tftp_err.blocks_received); + } else { + const char *errstr = NULL; + int ecode; + tftp_get_error_info(fnip, &tftp_err, rc, &errstr, &ecode); + printf("TFTP error: %s\n", errstr ? errstr : "unknown error"); } return rc; @@ -231,7 +179,7 @@ static int net_init(filename_ip_t *fn_ip) rc = dhcp(fn_ip, DEFAULT_BOOT_RETRIES); if (rc >= 0) { - if (ip_version == 4) { + if (fn_ip->ip_version == 4) { set_ipv4_address(fn_ip->own_ip); } } else { @@ -239,11 +187,11 @@ static int net_init(filename_ip_t *fn_ip) return -101; } - if (ip_version == 4) { + if (fn_ip->ip_version == 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 == 6) { + } else if (fn_ip->ip_version == 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) } printf(" Using TFTP server: "); - if (ip_version == 4) { + if (fn_ip->ip_version == 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 == 6) { + } else if (fn_ip->ip_version == 6) { char ip6_str[40]; ipv6_to_str(fn_ip->server_ip6.addr, ip6_str); printf("%s\n", ip6_str); } - if (strlen((char *)fn_ip->filename) > 0) { + if (strlen(fn_ip->filename) > 0) { printf(" Bootfile name: '%s'\n", fn_ip->filename); } @@ -280,7 +228,7 @@ static int net_init(filename_ip_t *fn_ip) static void net_release(filename_ip_t *fn_ip) { - if (ip_version == 4) { + if (fn_ip->ip_version == 4) { dhcp_send_release(fn_ip->fd); } } @@ -322,7 +270,7 @@ static int handle_ins_cfg(filename_ip_t *fn_ip, char *cfg, int cfgsize) return -1; } *ptr = 0; - strncpy((char *)fn_ip->filename, insbuf, sizeof(fn_ip->filename)); + strncpy(fn_ip->filename, insbuf, sizeof(fn_ip->filename)); destaddr = (char *)atol(ptr + 1); rc = tftp_load(fn_ip, destaddr, (long)_start - (long)destaddr); if (rc <= 0) { @@ -455,7 +403,7 @@ void main(void) panic("Network initialization failed. Halting.\n"); } - fnlen = strlen((char *)fn_ip.filename); + fnlen = strlen(fn_ip.filename); if (fnlen > 0 && fn_ip.filename[fnlen - 1] != '/') { rc = net_try_direct_tftp_load(&fn_ip); } From patchwork Thu Jun 14 14:53:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 929501 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4166G46x74z9s19 for ; Fri, 15 Jun 2018 00:59:08 +1000 (AEST) Received: from localhost ([::1]:41126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTTiM-0003DZ-P3 for incoming@patchwork.ozlabs.org; Thu, 14 Jun 2018 10:59:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTTd3-00073C-Cm for qemu-devel@nongnu.org; Thu, 14 Jun 2018 10:53:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTTd2-0006TT-0Y for qemu-devel@nongnu.org; Thu, 14 Jun 2018 10:53:37 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42942 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 1fTTd1-0006TF-QI; Thu, 14 Jun 2018 10:53:35 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49D88818BAFD; Thu, 14 Jun 2018 14:53:35 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-79.ams2.redhat.com [10.36.116.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8E571C5AD; Thu, 14 Jun 2018 14:53:33 +0000 (UTC) From: Thomas Huth To: Cornelia Huck , qemu-s390x@nongnu.org Date: Thu, 14 Jun 2018 16:53:20 +0200 Message-Id: <1528988003-21855-5-git-send-email-thuth@redhat.com> In-Reply-To: <1528988003-21855-1-git-send-email-thuth@redhat.com> References: <1528988003-21855-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 14 Jun 2018 14:53:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 14 Jun 2018 14:53:35 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL SUBSYSTEM s390x 4/7] 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: Alexey Kardashevskiy , Christian Borntraeger , Collin Walling , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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=PXELINUX The user can either specify a config file directly as bootfile via DHCP (but in this case, the file has to start either with "default" or a "#" 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. Acked-by: Christian Borntraeger Tested-by: Viktor Mihajlovski Signed-off-by: Thomas Huth --- 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 = isdigit.o isxdigit.o toupper.o %.o : $(SLOF_DIR)/lib/libc/ctype/%.c $(call quiet-command,$(CC) $(LIBC_CFLAGS) -c -o $@ $<,"CC","$(TARGET_DIR)$@") -STRING_OBJS = strcat.o strchr.o strcmp.o strcpy.o strlen.o strncmp.o strncpy.o \ - strstr.o memset.o memcpy.o memmove.o memcmp.o +STRING_OBJS = 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)$@") @@ -50,7 +51,7 @@ libc.a: $(LIBCOBJS) # libnet files: 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 + dhcpv6.o ethernet.o ipv4.o ndp.o tftp.o pxelinux.o LIBNETCFLAGS := $(QEMU_CFLAGS) -DDHCPARCH=0x1F $(LIBC_INC) $(LIBNET_INC) %.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 #include "s390-ccw.h" #include "virtio.h" @@ -41,12 +42,14 @@ extern char _start[]; #define KERNEL_ADDR ((void *)0L) #define KERNEL_MAX_SIZE ((long)_start) +#define ARCH_COMMAND_LINE_SIZE 896 /* Taken from Linux kernel */ char stack[PAGE_SIZE * 8] __attribute__((aligned(PAGE_SIZE))); IplParameterBlock iplb __attribute__((aligned(PAGE_SIZE))); static char cfgbuf[2048]; static SubChannelId net_schid = { .one = 1 }; +static uint8_t mac[6]; static uint64_t dest_timer; static uint64_t get_timer_ms(void) @@ -159,7 +162,6 @@ static int tftp_load(filename_ip_t *fnip, void *buffer, int len) static int net_init(filename_ip_t *fn_ip) { - uint8_t mac[6]; int rc; memset(fn_ip, 0, sizeof(filename_ip_t)); @@ -234,6 +236,66 @@ static void net_release(filename_ip_t *fn_ip) } /** + * 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 = tftp_load(fn_ip, KERNEL_ADDR, KERNEL_MAX_SIZE); + if (rc < 0) { + return rc; + } + + if (entry->initrd) { + uint64_t iaddr = (rc + 0xfff) & ~0xfffUL; + + strncpy(fn_ip->filename, entry->initrd, sizeof(fn_ip->filename)); + rc = tftp_load(fn_ip, (void *)iaddr, KERNEL_MAX_SIZE - iaddr); + if (rc < 0) { + return rc; + } + /* Patch location and size: */ + *(uint64_t *)0x10408 = iaddr; + *(uint64_t *)0x10410 = rc; + rc += 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 = 0; + + num_ent = pxelinux_load_parse_cfg(fn_ip, mac, NULL, DEFAULT_TFTP_RETRIES, + 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 developers' + * 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 instead. + * So only use the pxelinux.cfg parser here for files that start with + * a magic comment string. + */ + if (!strncasecmp("# pxelinux", cfgbuf, 10)) { + struct pl_cfg_entry entries[MAX_PXELINUX_ENTRIES]; + int num_ent, def_ent = 0; + + num_ent = pxelinux_parse_cfg(cfgbuf, sizeof(cfgbuf), entries, + MAX_PXELINUX_ENTRIES, &def_ent); + if (num_ent <= 0) { + return -1; + } + return load_kernel_with_initrd(fn_ip, &entries[def_ent]); + } } /* Move kernel to right location */ @@ -407,6 +488,9 @@ void main(void) if (fnlen > 0 && fn_ip.filename[fnlen - 1] != '/') { rc = net_try_direct_tftp_load(&fn_ip); } + if (rc <= 0) { + rc = net_try_pxelinux_cfg(&fn_ip); + } net_release(&fn_ip); From patchwork Thu Jun 14 14:53:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 929502 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4166HP6Tbzz9s19 for ; Fri, 15 Jun 2018 01:00:17 +1000 (AEST) Received: from localhost ([::1]:41134 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTTjT-0004FJ-KD for incoming@patchwork.ozlabs.org; Thu, 14 Jun 2018 11:00:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40013) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTTd4-000751-RD for qemu-devel@nongnu.org; Thu, 14 Jun 2018 10:53:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTTd3-0006UE-SO for qemu-devel@nongnu.org; Thu, 14 Jun 2018 10:53:38 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42950 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 1fTTd3-0006Ts-Mn; Thu, 14 Jun 2018 10:53:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B127818BAFD; Thu, 14 Jun 2018 14:53:37 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-79.ams2.redhat.com [10.36.116.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id A83241C5AD; Thu, 14 Jun 2018 14:53:35 +0000 (UTC) From: Thomas Huth To: Cornelia Huck , qemu-s390x@nongnu.org Date: Thu, 14 Jun 2018 16:53:21 +0200 Message-Id: <1528988003-21855-6-git-send-email-thuth@redhat.com> In-Reply-To: <1528988003-21855-1-git-send-email-thuth@redhat.com> References: <1528988003-21855-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 14 Jun 2018 14:53:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 14 Jun 2018 14:53:37 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL SUBSYSTEM s390x 5/7] 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: Alexey Kardashevskiy , Christian Borntraeger , Collin Walling , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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. Acked-by: Christian Borntraeger Tested-by: Viktor Mihajlovski Signed-off-by: Thomas Huth --- 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 kernel */ +/* 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) } /** + * 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 = 0; + static char uuid_str[37]; + + mem = malloc(2 * PAGE_SIZE); + if (!mem) { + puts("Out of memory ... can not get UUID."); + return NULL; + } + buf = (uint8_t *)(((uint64_t)mem + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)); + memset(buf, 0, PAGE_SIZE); + + /* Get SYSIB 3.2.2 */ + r0 = (3 << 28) | 2; + r1 = 2; + asm volatile(" stsi 0(%[addr])\n" + " ipm %[cc]\n" + " srl %[cc],28\n" + : [cc] "=d" (cc) + : "d" (r0), "d" (r1), [addr] "a" (buf) + : "cc", "memory"); + if (cc) { + return NULL; + } + + for (i = 0; i < 16; i++) { + uuid[i] = buf[STSI322_VMDB_UUID_OFFSET + i]; + chk |= 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 = 0; - num_ent = pxelinux_load_parse_cfg(fn_ip, mac, NULL, DEFAULT_TFTP_RETRIES, + num_ent = 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) { From patchwork Thu Jun 14 14:53:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 929503 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4166KK6Plzz9s19 for ; Fri, 15 Jun 2018 01:01:57 +1000 (AEST) Received: from localhost ([::1]:41147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTTl5-00052Z-Hw for incoming@patchwork.ozlabs.org; Thu, 14 Jun 2018 11:01:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTTd9-0007AW-SO for qemu-devel@nongnu.org; Thu, 14 Jun 2018 10:53:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTTd5-0006W3-Pz for qemu-devel@nongnu.org; Thu, 14 Jun 2018 10:53:43 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53984 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 1fTTd5-0006Uv-Lo; Thu, 14 Jun 2018 10:53:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2F9A58886E; Thu, 14 Jun 2018 14:53:39 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-79.ams2.redhat.com [10.36.116.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B01A7C44; Thu, 14 Jun 2018 14:53:37 +0000 (UTC) From: Thomas Huth To: Cornelia Huck , qemu-s390x@nongnu.org Date: Thu, 14 Jun 2018 16:53:22 +0200 Message-Id: <1528988003-21855-7-git-send-email-thuth@redhat.com> In-Reply-To: <1528988003-21855-1-git-send-email-thuth@redhat.com> References: <1528988003-21855-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 14 Jun 2018 14:53:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 14 Jun 2018 14:53:39 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL SUBSYSTEM s390x 6/7] pc-bios/s390-ccw: Optimize the s390-netboot.img for size 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: Alexey Kardashevskiy , Christian Borntraeger , Collin Walling , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The -O2 optimization flag is passed via CFLAGS to the firmware Makefile, but in netbook.mak, we've got some rules that only use QEMU_CFLAGS for compiling the libc and libnet from SLOF, so these files get compiled without optimization so far. Use CFLAGS here, too, to create faster and smaller code. We can additionally save some more bytes in the firmware images by compi- ling the code with -fno-asynchronous-unwind-tables. This will omit some ELF sections (used for stack unwinding for example) from the image that we do not need in the firmware. Acked-by: Christian Borntraeger Signed-off-by: Thomas Huth --- pc-bios/s390-ccw/Makefile | 1 + pc-bios/s390-ccw/netboot.mak | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile index 439e3cc..1eb316b 100644 --- a/pc-bios/s390-ccw/Makefile +++ b/pc-bios/s390-ccw/Makefile @@ -15,6 +15,7 @@ OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.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 +QEMU_CFLAGS += -fno-asynchronous-unwind-tables QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector) LDFLAGS += -Wl,-pie -nostdlib diff --git a/pc-bios/s390-ccw/netboot.mak b/pc-bios/s390-ccw/netboot.mak index 8af0cfd..14e96b2 100644 --- a/pc-bios/s390-ccw/netboot.mak +++ b/pc-bios/s390-ccw/netboot.mak @@ -19,7 +19,7 @@ s390-netboot.img: s390-netboot.elf # libc files: -LIBC_CFLAGS := $(QEMU_CFLAGS) $(LIBC_INC) $(LIBNET_INC) +LIBC_CFLAGS := $(QEMU_CFLAGS) $(CFLAGS) $(LIBC_INC) $(LIBNET_INC) CTYPE_OBJS = isdigit.o isxdigit.o toupper.o %.o : $(SLOF_DIR)/lib/libc/ctype/%.c @@ -52,7 +52,7 @@ libc.a: $(LIBCOBJS) 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 pxelinux.o -LIBNETCFLAGS := $(QEMU_CFLAGS) -DDHCPARCH=0x1F $(LIBC_INC) $(LIBNET_INC) +LIBNETCFLAGS := $(QEMU_CFLAGS) $(CFLAGS) -DDHCPARCH=0x1F $(LIBC_INC) $(LIBNET_INC) %.o : $(SLOF_DIR)/lib/libnet/%.c $(call quiet-command,$(CC) $(LIBNETCFLAGS) -c -o $@ $<,"CC","$(TARGET_DIR)$@")