From nobody Wed May 14 14:25:42 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152638163781044.347940959307266; Tue, 15 May 2018 03:53:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF9F43180717; Tue, 15 May 2018 10:53:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AEAC5177BA; Tue, 15 May 2018 10:53:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 55B86180124B; Tue, 15 May 2018 10:53:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4FArk7g009458 for ; Tue, 15 May 2018 06:53:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0743D201634D; Tue, 15 May 2018 10:53:46 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1BA2201634E for ; Tue, 15 May 2018 10:53:43 +0000 (UTC) Received: from shell.v3.sk (shell.v3.sk [92.60.52.57]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 62510ED3EA for ; Tue, 15 May 2018 10:53:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id F3695AC107 for ; Tue, 15 May 2018 12:53:39 +0200 (CEST) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id tLqX5rN0AqZe; Tue, 15 May 2018 12:53:18 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 8546CAC0FD; Tue, 15 May 2018 12:53:17 +0200 (CEST) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id bpRxOvzuN4n5; Tue, 15 May 2018 12:53:15 +0200 (CEST) Received: from belphegor.brq.redhat.com (nat-pool-brq-t.redhat.com [213.175.37.10]) by zimbra.v3.sk (Postfix) with ESMTPSA id 1E983AC10D; Tue, 15 May 2018 12:53:15 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.v3.sk From: Lubomir Rintel To: libvir-list@redhat.com Date: Tue, 15 May 2018 12:53:06 +0200 Message-Id: <20180515105311.1981339-5-lkundrak@v3.sk> In-Reply-To: <20180515105311.1981339-1-lkundrak@v3.sk> References: <20180515105311.1981339-1-lkundrak@v3.sk> X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 15 May 2018 10:53:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 15 May 2018 10:53:41 +0000 (UTC) for IP:'92.60.52.57' DOMAIN:'shell.v3.sk' HELO:'shell.v3.sk' FROM:'lkundrak@v3.sk' RCPT:'' X-RedHat-Spam-Score: -0.001 (SPF_PASS) 92.60.52.57 shell.v3.sk 92.60.52.57 shell.v3.sk X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: libvir-list@redhat.com Cc: Lubomir Rintel Subject: [libvirt] [PATCH 4/9] util: add RISC-V support X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 15 May 2018 10:53:56 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" What works, with images from [1]: virt-install \ --import --name riscv64 \ --arch riscv64 --machine virt \ --memory 2048 \ --rng /dev/urandom \ --disk /var/lib/libvirt/images/stage4-disk.img,bus=3Dvirtio \ --boot kernel=3D/var/lib/libvirt/images/bbl,kernel_args=3D"console=3Dtt= yS0 ro root=3D/dev/vda" [1] https://fedorapeople.org/groups/risc-v/disk-images/ Signed-off-by: Lubomir Rintel --- docs/schemas/basictypes.rng | 2 ++ src/qemu/qemu_command.c | 15 ++++++++------- src/qemu/qemu_domain.c | 18 +++++++++++++++--- src/qemu/qemu_domain_address.c | 21 +++++++++++---------- src/util/virarch.c | 3 +++ src/util/virarch.h | 6 ++++++ 6 files changed, 45 insertions(+), 20 deletions(-) diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng index 1a18cd31b1..14a3670e5c 100644 --- a/docs/schemas/basictypes.rng +++ b/docs/schemas/basictypes.rng @@ -398,6 +398,8 @@ ppc64 ppc64le ppcemb + riscv32 + riscv64 s390 s390x sh4 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f91d3ae5ac..12f90521d4 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8940,14 +8940,15 @@ static bool qemuChrIsPlatformDevice(const virDomainDef *def, virDomainChrDefPtr chr) { - if (def->os.arch =3D=3D VIR_ARCH_ARMV7L || def->os.arch =3D=3D VIR_ARC= H_AARCH64) { - - /* pl011 (used on mach-virt) is a platform device */ - if (chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && - chr->targetType =3D=3D VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTE= M && - chr->targetModel =3D=3D VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL0= 11) { + if (chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && + chr->targetType =3D=3D VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM) { + if ((def->os.arch =3D=3D VIR_ARCH_ARMV7L || def->os.arch =3D=3D VI= R_ARCH_AARCH64) && + chr->targetModel =3D=3D VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL0= 11) + return true; + if (ARCH_IS_RISCV(def->os.arch) && + qemuDomainIsVirt(def) && + chr->targetModel =3D=3D VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NS1= 6550A) return true; - } } =20 /* If we got all the way here and we're still stuck with the default diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index db73f45204..20d05da9c4 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2914,6 +2914,14 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, case VIR_ARCH_PARISC: case VIR_ARCH_PARISC64: case VIR_ARCH_PPCLE: + break; + + case VIR_ARCH_RISCV32: + case VIR_ARCH_RISCV64: + addDefaultUSB =3D false; + addDefaultMemballoon =3D false; + break; + case VIR_ARCH_UNICORE32: case VIR_ARCH_XTENSA: case VIR_ARCH_XTENSAEB: @@ -5138,7 +5146,7 @@ static const char * qemuDomainDefaultNetModel(const virDomainDef *def, virQEMUCapsPtr qemuCaps) { - if (ARCH_IS_S390(def->os.arch)) + if (ARCH_IS_S390(def->os.arch) || ARCH_IS_RISCV(def->os.arch)) return "virtio"; =20 if (def->os.arch =3D=3D VIR_ARCH_ARMV7L || @@ -5470,7 +5478,10 @@ qemuDomainChrDefPostParse(virDomainChrDefPtr chr, chr->targetModel =3D VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_= VTY; break; case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM: - chr->targetModel =3D VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011; + if (ARCH_IS_RISCV(def->os.arch)) + chr->targetModel =3D VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NS= 16550A; + else + chr->targetModel =3D VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL= 011; break; case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP: chr->targetModel =3D VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCO= NSOLE; @@ -8449,7 +8460,8 @@ qemuDomainMachineIsVirt(const char *machine, const virArch arch) { if (arch !=3D VIR_ARCH_ARMV7L && - arch !=3D VIR_ARCH_AARCH64) + arch !=3D VIR_ARCH_AARCH64 && + !ARCH_IS_RISCV(arch)) return false; =20 if (STRNEQ(machine, "virt") && diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 87e1dc3bd2..5d9a073d25 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -480,13 +480,13 @@ static void qemuDomainAssignVirtioMMIOAddresses(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) { - if (def->os.arch !=3D VIR_ARCH_ARMV7L && - def->os.arch !=3D VIR_ARCH_AARCH64) - return; - - if (!(STRPREFIX(def->os.machine, "vexpress-") || - qemuDomainIsVirt(def))) + if (def->os.arch =3D=3D VIR_ARCH_ARMV7L || def->os.arch =3D=3D VIR_ARC= H_AARCH64) { + if (!(STRPREFIX(def->os.machine, "vexpress-") || + qemuDomainIsVirt(def))) + return; + } else if (!ARCH_IS_RISCV(def->os.arch)) { return; + } =20 /* We use virtio-mmio by default on mach-virt guests only if they alre= ady * have at least one virtio-mmio device: in all other cases, we prefer @@ -2163,11 +2163,12 @@ static bool qemuDomainSupportsPCI(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) { - if ((def->os.arch !=3D VIR_ARCH_ARMV7L) && (def->os.arch !=3D VIR_ARCH= _AARCH64)) - return true; - - if (STREQ(def->os.machine, "versatilepb")) + if (def->os.arch =3D=3D VIR_ARCH_ARMV7L) { + if (STREQ(def->os.machine, "versatilepb")) + return true; + } else if (!(def->os.arch !=3D VIR_ARCH_AARCH64 || ARCH_IS_RISCV(def->= os.arch))) { return true; + } =20 if (qemuDomainIsVirt(def) && virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_GPEX)) diff --git a/src/util/virarch.c b/src/util/virarch.c index be48bcfb89..77b893b0ac 100644 --- a/src/util/virarch.c +++ b/src/util/virarch.c @@ -65,6 +65,9 @@ static const struct virArchData { { "ppc64le", 64, VIR_ARCH_LITTLE_ENDIAN }, { "ppcemb", 32, VIR_ARCH_BIG_ENDIAN }, =20 + { "riscv32", 32, VIR_ARCH_LITTLE_ENDIAN }, + { "riscv64", 64, VIR_ARCH_LITTLE_ENDIAN }, + { "s390", 32, VIR_ARCH_BIG_ENDIAN }, { "s390x", 64, VIR_ARCH_BIG_ENDIAN }, { "sh4", 32, VIR_ARCH_LITTLE_ENDIAN }, diff --git a/src/util/virarch.h b/src/util/virarch.h index af5ff83528..806a23fade 100644 --- a/src/util/virarch.h +++ b/src/util/virarch.h @@ -55,6 +55,9 @@ typedef enum { VIR_ARCH_PPC64LE, /* PowerPC 64 LE http://en.wikipedia.org/wi= ki/PowerPC */ VIR_ARCH_PPCEMB, /* PowerPC 32 BE http://en.wikipedia.org/wi= ki/PowerPC */ =20 + VIR_ARCH_RISCV32, /* RISC-V 64 LE http://en.wikipedia.org/wik= i/RISC-V */ + VIR_ARCH_RISCV64, /* RISC-V 32 BE http://en.wikipedia.org/wik= i/RISC-V */ + VIR_ARCH_S390, /* S390 32 BE http://en.wikipedia.org/wi= ki/S390 */ VIR_ARCH_S390X, /* S390 64 BE http://en.wikipedia.org/wi= ki/S390x */ VIR_ARCH_SH4, /* SuperH4 32 LE http://en.wikipedia.org/wi= ki/SuperH */ @@ -87,6 +90,9 @@ typedef enum { (arch) =3D=3D VIR_ARCH_ARMV7B ||\ (arch) =3D=3D VIR_ARCH_AARCH64) =20 +# define ARCH_IS_RISCV(arch) ((arch) =3D=3D VIR_ARCH_RISCV32 ||\ + (arch) =3D=3D VIR_ARCH_RISCV64) + # define ARCH_IS_S390(arch) ((arch) =3D=3D VIR_ARCH_S390 ||\ (arch) =3D=3D VIR_ARCH_S390X) =20 --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list