From nobody Fri Mar 29 12:09:25 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502431185889877.1059802156603; Thu, 10 Aug 2017 22:59:45 -0700 (PDT) Received: from localhost ([::1]:40642 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dg2z2-0001FN-Dq for importer@patchew.org; Fri, 11 Aug 2017 01:59:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dg2xT-0000J5-AV for qemu-devel@nongnu.org; Fri, 11 Aug 2017 01:58:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dg2xR-0003ff-SM for qemu-devel@nongnu.org; Fri, 11 Aug 2017 01:58:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33482) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dg2xR-0003fW-Iv for qemu-devel@nongnu.org; Fri, 11 Aug 2017 01:58:05 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E2B46DDB1; Fri, 11 Aug 2017 05:58:04 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD4499866F; Fri, 11 Aug 2017 05:58:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5E2B46DDB1 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=thuth@redhat.com From: Thomas Huth To: qemu-devel@nongnu.org, Cornelia Huck Date: Fri, 11 Aug 2017 07:57:55 +0200 Message-Id: <1502431076-22849-2-git-send-email-thuth@redhat.com> In-Reply-To: <1502431076-22849-1-git-send-email-thuth@redhat.com> References: <1502431076-22849-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 11 Aug 2017 05:58:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 for-2.11 1/2] tests/boot-sector: Do not overwrite the x86 buffer on other architectures 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: Christian Borntraeger , Jason Wang , Victor Kaplansky , "Michael S. Tsirkin" 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" Re-using the boot_sector code buffer from x86 for other architectures is not very nice, especially if we add more architectures later. It's also ugly that the test uses a huge pre-initialized array at all - the size of the executable is very huge due to this array. So let's use a separate buffer for each architecture instead, allocated from the heap, so that we really just use the memory that we need. Suggested-by: Michael Tsirkin Signed-off-by: Thomas Huth Reviewed-by: Cornelia Huck --- tests/boot-sector.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/tests/boot-sector.c b/tests/boot-sector.c index e3880f4..8729562 100644 --- a/tests/boot-sector.c +++ b/tests/boot-sector.c @@ -21,13 +21,12 @@ #define SIGNATURE 0xdead #define SIGNATURE_OFFSET 0x10 #define BOOT_SECTOR_ADDRESS 0x7c00 +#define SIGNATURE_ADDR (BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET) =20 -/* Boot sector code: write SIGNATURE into memory, +/* x86 boot sector code: write SIGNATURE into memory, * then halt. - * Q35 machine requires a minimum 0x7e000 bytes disk. - * (bug or feature?) */ -static uint8_t boot_sector[0x7e000] =3D { +static uint8_t x86_boot_sector[512] =3D { /* The first sector will be placed at RAM address 00007C00, and * the BIOS transfers control to 00007C00 */ @@ -50,8 +49,8 @@ static uint8_t boot_sector[0x7e000] =3D { [0x07] =3D HIGH(SIGNATURE), /* 7c08: mov %ax,0x7c10 */ [0x08] =3D 0xa3, - [0x09] =3D LOW(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET), - [0x0a] =3D HIGH(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET), + [0x09] =3D LOW(SIGNATURE_ADDR), + [0x0a] =3D HIGH(SIGNATURE_ADDR), =20 /* 7c0b cli */ [0x0b] =3D 0xfa, @@ -72,7 +71,9 @@ static uint8_t boot_sector[0x7e000] =3D { int boot_sector_init(char *fname) { int fd, ret; - size_t len =3D sizeof boot_sector; + size_t len; + char *boot_code; + const char *arch =3D qtest_get_arch(); =20 fd =3D mkstemp(fname); if (fd < 0) { @@ -80,16 +81,26 @@ int boot_sector_init(char *fname) return 1; } =20 - /* For Open Firmware based system, we can use a Forth script instead */ - if (strcmp(qtest_get_arch(), "ppc64") =3D=3D 0) { - len =3D sprintf((char *)boot_sector, "\\ Bootscript\n%x %x c! %x %= x c!\n", - LOW(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET, - HIGH(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + = 1); + if (g_str_equal(arch, "i386") || g_str_equal(arch, "x86_64")) { + /* Q35 requires a minimum 0x7e000 bytes disk (bug or feature?) */ + len =3D MAX(0x7e000, sizeof(x86_boot_sector)); + boot_code =3D g_malloc0(len); + memcpy(boot_code, x86_boot_sector, sizeof(x86_boot_sector)); + } else if (g_str_equal(arch, "ppc64")) { + /* For Open Firmware based system, use a Forth script */ + boot_code =3D g_strdup_printf("\\ Bootscript\n%x %x c! %x %x c!\n", + LOW(SIGNATURE), SIGNATURE_ADDR, + HIGH(SIGNATURE), SIGNATURE_ADDR + 1); + len =3D strlen(boot_code); + } else { + g_assert_not_reached(); } =20 - ret =3D write(fd, boot_sector, len); + ret =3D write(fd, boot_code, len); close(fd); =20 + g_free(boot_code); + if (ret !=3D len) { fprintf(stderr, "Could not write \"%s\"", fname); return 1; @@ -115,8 +126,8 @@ void boot_sector_test(void) * instruction. */ for (i =3D 0; i < TEST_CYCLES; ++i) { - signature_low =3D readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET); - signature_high =3D readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + = 1); + signature_low =3D readb(SIGNATURE_ADDR); + signature_high =3D readb(SIGNATURE_ADDR + 1); signature =3D (signature_high << 8) | signature_low; if (signature =3D=3D SIGNATURE) { break; --=20 1.8.3.1 From nobody Fri Mar 29 12:09:25 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502431184551498.71350807314707; Thu, 10 Aug 2017 22:59:44 -0700 (PDT) Received: from localhost ([::1]:40641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dg2z0-0001D6-Ae for importer@patchew.org; Fri, 11 Aug 2017 01:59:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dg2xU-0000JN-VF for qemu-devel@nongnu.org; Fri, 11 Aug 2017 01:58:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dg2xT-0003gB-QV for qemu-devel@nongnu.org; Fri, 11 Aug 2017 01:58:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54344) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dg2xT-0003fp-Hn for qemu-devel@nongnu.org; Fri, 11 Aug 2017 01:58:07 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6A80D23734F; Fri, 11 Aug 2017 05:58:06 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8EFB9866F; Fri, 11 Aug 2017 05:58:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6A80D23734F Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=thuth@redhat.com From: Thomas Huth To: qemu-devel@nongnu.org, Cornelia Huck Date: Fri, 11 Aug 2017 07:57:56 +0200 Message-Id: <1502431076-22849-3-git-send-email-thuth@redhat.com> In-Reply-To: <1502431076-22849-1-git-send-email-thuth@redhat.com> References: <1502431076-22849-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 11 Aug 2017 05:58:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 for-2.11 2/2] tests/pxe: Check virtio-net-ccw on s390x 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: Christian Borntraeger , Jason Wang , Victor Kaplansky , "Michael S. Tsirkin" 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" Now that we've got a firmware that can do TFTP booting on s390x (i.e. the pc-bios/s390-netboot.img), we can enable the PXE tester for this architecture, too. Signed-off-by: Thomas Huth Reviewed-by: Cornelia Huck --- tests/Makefile.include | 1 + tests/boot-sector.c | 20 ++++++++++++++++++++ tests/pxe-test.c | 7 +++++++ 3 files changed, 28 insertions(+) diff --git a/tests/Makefile.include b/tests/Makefile.include index eb4895f..2a238db 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -337,6 +337,7 @@ check-qtest-microblazeel-y =3D $(check-qtest-microblaze= -y) check-qtest-xtensaeb-y =3D $(check-qtest-xtensa-y) =20 check-qtest-s390x-y =3D tests/boot-serial-test$(EXESUF) +check-qtest-s390x-$(CONFIG_SLIRP) +=3D tests/pxe-test$(EXESUF) =20 check-qtest-generic-y +=3D tests/qom-test$(EXESUF) check-qtest-generic-y +=3D tests/test-hmp$(EXESUF) diff --git a/tests/boot-sector.c b/tests/boot-sector.c index 8729562..9ee8537 100644 --- a/tests/boot-sector.c +++ b/tests/boot-sector.c @@ -67,6 +67,21 @@ static uint8_t x86_boot_sector[512] =3D { [0x1FF] =3D 0xAA, }; =20 +/* For s390x, use a mini "kernel" with the appropriate signature */ +static const uint8_t s390x_psw[] =3D { + 0x00, 0x08, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00 +}; +static const uint8_t s390x_code[] =3D { + 0xa7, 0xf4, 0x00, 0x0a, /* j 0x10010 */ + 0x00, 0x00, 0x00, 0x00, + 'S', '3', '9', '0', + 'E', 'P', 0x00, 0x01, + 0xa7, 0x38, HIGH(SIGNATURE_ADDR), LOW(SIGNATURE_ADDR), /* lhi r3,0x7c1= 0 */ + 0xa7, 0x48, LOW(SIGNATURE), HIGH(SIGNATURE), /* lhi r4,0xadd= e */ + 0x40, 0x40, 0x30, 0x00, /* sth r4,0(r3)= */ + 0xa7, 0xf4, 0xff, 0xfa /* j 0x10010 */ +}; + /* Create boot disk file. */ int boot_sector_init(char *fname) { @@ -92,6 +107,11 @@ int boot_sector_init(char *fname) LOW(SIGNATURE), SIGNATURE_ADDR, HIGH(SIGNATURE), SIGNATURE_ADDR + 1); len =3D strlen(boot_code); + } else if (g_str_equal(arch, "s390x")) { + len =3D 0x10000 + sizeof(s390x_code); + boot_code =3D g_malloc0(len); + memcpy(boot_code, s390x_psw, sizeof(s390x_psw)); + memcpy(&boot_code[0x10000], s390x_code, sizeof(s390x_code)); } else { g_assert_not_reached(); } diff --git a/tests/pxe-test.c b/tests/pxe-test.c index cf6e225..0d70afc 100644 --- a/tests/pxe-test.c +++ b/tests/pxe-test.c @@ -51,6 +51,11 @@ static void test_pxe_spapr_vlan(void) test_pxe_one("-device spapr-vlan,netdev=3D" NETNAME, true); } =20 +static void test_pxe_virtio_ccw(void) +{ + test_pxe_one("-device virtio-net-ccw,bootindex=3D1,netdev=3D" NETNAME,= false); +} + int main(int argc, char *argv[]) { int ret; @@ -68,6 +73,8 @@ int main(int argc, char *argv[]) } else if (strcmp(arch, "ppc64") =3D=3D 0) { qtest_add_func("pxe/virtio", test_pxe_virtio_pci); qtest_add_func("pxe/spapr-vlan", test_pxe_spapr_vlan); + } else if (g_str_equal(arch, "s390x")) { + qtest_add_func("pxe/virtio-ccw", test_pxe_virtio_ccw); } ret =3D g_test_run(); boot_sector_cleanup(disk); --=20 1.8.3.1