From nobody Thu Apr 25 21:31:18 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584604061; cv=none; d=zohomail.com; s=zohoarc; b=X/FtesJNMy8mxDYeE9niscm2sbnppoPboBWG/PsyTbGrE2Pry1GW2E/wbFBGOguZNJAZuZe0oFPefDoSmE0/EAXEBcPW4GejtbLlA0X5odmAp2kLR3JJIscaYuR/895fvO+cd3aov87YMR61kZrvV5gRpbVH6BqrEn45lS3XN/o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584604061; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=pMRMVEQ9O7v/yExDKowNWz4UO2Lj9x6r0NzW3X18+5E=; b=Q49moRI5qMoDT5CQXBbTrvrrVp2vDWwDrQ6hEAaCBWNWR0uztNZI5gIWSqA+OF3XOSWAmiNoUBLnbFYsMleMOwao7lJRw6H0HqaDX4N5Z/MNywgJp5rmwsEOMkH9cnbJy1StI0/F14X2UkwpFoexIZYiNAyY+xILQcK+h1t/joM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1584604061284623.9017845528194; Thu, 19 Mar 2020 00:47:41 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 14AA1B01B48; Thu, 19 Mar 2020 07:47:37 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 98519B01B2A for ; Thu, 19 Mar 2020 07:46:08 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-385-3yxMaEeGPHaNvZt_BL5iXg-1; Thu, 19 Mar 2020 03:39:44 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4AF86107ACC4 for ; Thu, 19 Mar 2020 07:39:43 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6D6462673; Thu, 19 Mar 2020 07:39:40 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id 011E031F24; Thu, 19 Mar 2020 08:39:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584603967; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nwCMvnfD2vvjf58AakGhK1xD4pi3sQOMgItIdE+Du34=; b=a4w1iWYBOrgthySA7GRVfen6/Kl34rBQHNtTcVmwuDoFKogP5+pXv7L2+A0WFLJG/nMOoL IoR1M5UIaDwFM3VC3n19PKCkD33A6lCNAPdr2zqTSdYWa98WGrZLm8SoqvKpOU5VBf02we 2qxu6qClklNGmU/rtAZenViYLRdeJMI= X-MC-Unique: 3yxMaEeGPHaNvZt_BL5iXg-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Thu, 19 Mar 2020 08:39:33 +0100 Message-Id: <20200319073937.5561-3-kraxel@redhat.com> In-Reply-To: <20200319073937.5561-1-kraxel@redhat.com> References: <20200319073937.5561-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Level: ***** Message-ID-Hash: QO7LKOELXOBA5TJADIPG243BBN77IJUC X-Message-ID-Hash: QO7LKOELXOBA5TJADIPG243BBN77IJUC X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Gerd Hoffmann X-Mailman-Version: 3.3.1 Precedence: list Subject: [SeaBIOS] [PATCH 2/6] paravirt/qemu: virtio-mmio device discovery List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: / X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Use bootorder fw_cfg file to find bootable virtio-mmio devices. Also add a new virtio-mmio.c source file, providing a function to register virtio-mmio devices. Signed-off-by: Gerd Hoffmann --- Makefile | 2 +- src/hw/virtio-mmio.h | 6 ++++++ src/fw/paravirt.c | 24 ++++++++++++++++++++++++ src/hw/virtio-mmio.c | 30 ++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 src/hw/virtio-mmio.h create mode 100644 src/hw/virtio-mmio.c diff --git a/Makefile b/Makefile index 5f7d5370198a..985ef591a13b 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ SRC32FLAT=3D$(SRCBOTH) post.c e820map.c malloc.c romfile.= c x86.c optionroms.c \ fw/coreboot.c fw/lzmadecode.c fw/multiboot.c fw/csm.c fw/biostables.c \ fw/paravirt.c fw/shadow.c fw/pciinit.c fw/smm.c fw/smp.c fw/mtrr.c fw/= xen.c \ fw/acpi.c fw/mptable.c fw/pirtable.c fw/smbios.c fw/romfile_loader.c \ - hw/virtio-ring.c hw/virtio-pci.c hw/virtio-blk.c hw/virtio-scsi.c \ + hw/virtio-ring.c hw/virtio-pci.c hw/virtio-mmio.c hw/virtio-blk.c hw/v= irtio-scsi.c \ hw/tpm_drivers.c hw/nvme.c SRC32SEG=3Dstring.c output.c pcibios.c apm.c stacks.c hw/pci.c hw/serialio= .c DIRS=3Dsrc src/hw src/fw vgasrc diff --git a/src/hw/virtio-mmio.h b/src/hw/virtio-mmio.h new file mode 100644 index 000000000000..751984241f49 --- /dev/null +++ b/src/hw/virtio-mmio.h @@ -0,0 +1,6 @@ +#ifndef _VIRTIO_MMIO_H +#define _VIRTIO_MMIO_H + +void virtio_mmio_register(u64 mmio); + +#endif /* _VIRTIO_MMIO_H */ diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c index 119280c574fd..aaaf8b8dad31 100644 --- a/src/fw/paravirt.c +++ b/src/fw/paravirt.c @@ -15,6 +15,7 @@ #include "hw/pcidevice.h" // pci_probe_devices #include "hw/pci_regs.h" // PCI_DEVICE_ID #include "hw/serialio.h" // PORT_SERIAL1 +#include "hw/virtio-mmio.h" // virtio_mmio_register #include "hw/rtc.h" // CMOS_* #include "malloc.h" // malloc_tmp #include "output.h" // dprintf @@ -192,6 +193,27 @@ static void msr_feature_control_setup(void) wrmsr_smp(MSR_IA32_FEATURE_CONTROL, feature_control_bits); } =20 +static void qemu_probe_virtio_mmio(void) +{ + char *data, *next; + int size; + u64 mmio; + + data =3D romfile_loadfile("bootorder", &size); + while (data) { + next =3D strchr(data, '\n'); + if (next) { + *next =3D '\0'; + next++; + } + if (memcmp("/virtio-mmio@", data, 13) =3D=3D 0) { + mmio =3D strtol(data+13, 16); + virtio_mmio_register(mmio); + } + data =3D next; + } +} + void qemu_platform_setup(void) { @@ -217,6 +239,8 @@ qemu_platform_setup(void) msr_feature_control_setup(); smp_setup(); =20 + qemu_probe_virtio_mmio(); + // Create bios tables if (MaxCountCPUs <=3D 255) { pirtable_setup(); diff --git a/src/hw/virtio-mmio.c b/src/hw/virtio-mmio.c new file mode 100644 index 000000000000..0f320921df30 --- /dev/null +++ b/src/hw/virtio-mmio.c @@ -0,0 +1,30 @@ +#include "config.h" // CONFIG_DEBUG_LEVEL +#include "malloc.h" // free +#include "output.h" // dprintf +#include "virtio-pci.h" +#include "virtio-ring.h" + +/* qemu microvm supports 8 virtio-mmio devices */ +static u64 devs[8]; + +void virtio_mmio_register(u64 mmio) +{ + int i; + + for (i =3D 0; i < ARRAY_SIZE(devs); i++) { + if (devs[i] =3D=3D mmio) { + /* + * This can happen in case we have multiple scsi devices + * attached to a single virtio-scsi controller + */ + dprintf(3, "virtio-mmio: duplicate device at 0x%llx, ignoring\= n", mmio); + return; + } + if (devs[i] =3D=3D 0) { + dprintf(1, "virtio-mmio: device at 0x%llx\n", mmio); + devs[i] =3D mmio; + return; + } + } + dprintf(1, "virtio-mmio: device list full\n"); +} --=20 2.18.2 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org