From nobody Mon Apr 29 14:04:35 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) client-ip=80.81.252.135; envelope-from=seabios-bounces@seabios.org; helo=mail.coreboot.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) by mx.zohomail.com with SMTPS id 1509637887767650.7819570948907; Thu, 2 Nov 2017 08:51:27 -0700 (PDT) Received: from [127.0.0.1] (helo=ra.coreboot.org) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1eAHlx-0007p9-FD; Thu, 02 Nov 2017 16:51:13 +0100 Received: from mx1.redhat.com ([209.132.183.28]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1eAHlh-0007m8-OG for seabios@seabios.org; Thu, 02 Nov 2017 16:51:12 +0100 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0D84BC04AC4E; Thu, 2 Nov 2017 15:50:55 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B1D960C9F; Thu, 2 Nov 2017 15:50:52 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 79EDD3F13B; Thu, 2 Nov 2017 16:50:51 +0100 (CET) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0D84BC04AC4E Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: seabios@seabios.org, kvm@vger.kernel.org Date: Thu, 2 Nov 2017 16:50:29 +0100 Message-Id: <20171102155031.17454-2-kraxel@redhat.com> In-Reply-To: <20171102155031.17454-1-kraxel@redhat.com> References: <20171102155031.17454-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 02 Nov 2017 15:50:55 +0000 (UTC) X-Spam-Score: -6.5 (------) Subject: [SeaBIOS] [PATCH seabios 1/3] kvmtool: initial support X-BeenThere: seabios@seabios.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SeaBIOS mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: seabios-bounces@seabios.org Sender: "SeaBIOS" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add CONFIG_KVMTOOL config option. kvmtool supports virtio only, so disable drivers for all kinds of qemu emulated hardware and leave only virtio-blk and virtio-scsi enabled. Set rom default size to 128k. Enable serial console for kvmtool. Add ram detection. Add pci devices scan. Signed-off-by: Gerd Hoffmann --- Makefile | 1 + src/fw/paravirt.h | 3 +++ src/fw/paravirt.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ src/post.c | 4 +++- src/sercon.c | 2 ++ src/Kconfig | 23 +++++++++++++++++++++-- 6 files changed, 78 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index eb8ad583ae..6ea8e19ee7 100644 --- a/Makefile +++ b/Makefile @@ -92,6 +92,7 @@ endif =20 target-y :=3D target-$(CONFIG_QEMU) +=3D $(OUT)bios.bin +target-$(CONFIG_KVMTOOL) +=3D $(OUT)bios.bin target-$(CONFIG_CSM) +=3D $(OUT)Csm16.bin target-$(CONFIG_COREBOOT) +=3D $(OUT)bios.bin.elf target-$(CONFIG_BUILD_VGABIOS) +=3D $(OUT)vgabios.bin diff --git a/src/fw/paravirt.h b/src/fw/paravirt.h index a14d83e101..57ee0cfc4d 100644 --- a/src/fw/paravirt.h +++ b/src/fw/paravirt.h @@ -60,4 +60,7 @@ int qemu_cfg_write_file(void *src, struct romfile_s *file= , u32 offset, u32 len); int qemu_cfg_write_file_simple(void *src, u16 key, u32 offset, u32 len); u16 qemu_get_romfile_key(struct romfile_s *file); =20 +void kvmtool_preinit(void); +void kvmtool_platform_setup(void); + #endif diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c index 9674ab8ba8..0d4855e2e2 100644 --- a/src/fw/paravirt.c +++ b/src/fw/paravirt.c @@ -621,3 +621,51 @@ void qemu_cfg_init(void) dprintf(1, "Moving pm_base to 0x%x\n", acpi_pm_base); } } + +void +kvmtool_platform_setup(void) +{ + if (!CONFIG_KVMTOOL) + return; + + pci_probe_devices(); +} + +void +kvmtool_preinit(void) +{ + /* + * When started without firmware kvmtool creates a e820 map for + * the guest kernel. When started with "--firmware $file" it + * doesn't, so we have to figure. + * + * Detects only memory below 4G for now as we run in 32bit mode. + * For memory above 4G we would have to: + * (1) get hints from kvmtool somehow, or + * (2) enable paging, or + * (3) enter long mode. + * + * There is a 768M memory hole for I/O, + * see x86/include/kvm/kvm-arch.h in kvmtool. + */ + static const u32 max_mb_32bit =3D 4096 - 768; + u32 mb, *ptr; + + if (!CONFIG_KVMTOOL) + return; + + for (mb =3D 16; mb < max_mb_32bit; mb++) { + ptr =3D (void*)(mb * 1024 * 1024 - 4); + *ptr =3D mb; + } + for (mb =3D 16; mb < max_mb_32bit; mb++) { + ptr =3D (void*)(mb * 1024 * 1024 - 4); + if (*ptr !=3D mb) + break; + RamSize =3D mb * 1024 * 1024; + } + + dprintf(1,"kvmtool: probed %d MB low RAM.\n", + RamSize / (1024 * 1024)); + e820_add(0, RamSize, E820_RAM); +} diff --git a/src/post.c b/src/post.c index f93106a1c9..f7268ecb8f 100644 --- a/src/post.c +++ b/src/post.c @@ -147,6 +147,7 @@ platform_hardware_setup(void) =20 // Platform specific setup qemu_platform_setup(); + kvmtool_platform_setup(); coreboot_platform_setup(); =20 // Setup timers and periodic clock interrupt @@ -307,6 +308,7 @@ dopost(void) =20 // Detect ram and setup internal malloc. qemu_preinit(); + kvmtool_preinit(); coreboot_preinit(); malloc_preinit(); =20 @@ -320,7 +322,7 @@ dopost(void) void VISIBLE32FLAT handle_post(void) { - if (!CONFIG_QEMU && !CONFIG_COREBOOT) + if (!CONFIG_QEMU && !CONFIG_COREBOOT && !CONFIG_KVMTOOL) return; =20 serial_debug_preinit(); diff --git a/src/sercon.c b/src/sercon.c index 5d27051efb..0b7722ec08 100644 --- a/src/sercon.c +++ b/src/sercon.c @@ -517,6 +517,8 @@ void sercon_setup(void) u16 addr; =20 addr =3D romfile_loadint("etc/sercon-port", 0); + if (!addr && CONFIG_KVMTOOL) + addr =3D 0x3f8; if (!addr) return; dprintf(1, "sercon: using ioport 0x%x\n", addr); diff --git a/src/Kconfig b/src/Kconfig index 00108057d7..985594c51b 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -25,6 +25,11 @@ choice Configure to be used by EFI firmware as Compatibility Support module (CSM) to provide legacy BIOS services. =20 + config KVMTOOL + bool "Build for kvmtool" + help + Configure for an emulated machine (kvmtool). + endchoice =20 config QEMU_HARDWARE @@ -61,6 +66,7 @@ endchoice Support an interactive boot menu at end of post. config BOOTSPLASH depends on BOOTMENU + depends on !KVMTOOL bool "Graphical boot splash screen" default y help @@ -124,6 +130,7 @@ endchoice =20 config ROM_SIZE int "ROM size (in KB)" + default 128 if KVMTOOL default 0 help Set the ROM size. Say '0' here to make seabios figure the @@ -138,6 +145,7 @@ endmenu menu "Hardware support" config ATA depends on DRIVES + depends on !KVMTOOL bool "ATA controllers" default y help @@ -156,24 +164,26 @@ menu "Hardware support" Use 32bit PIO accesses on ATA (minor optimization on PCI trans= fers). config AHCI depends on DRIVES + depends on !KVMTOOL bool "AHCI controllers" default y help Support for AHCI disk code. config SDCARD depends on DRIVES + depends on !KVMTOOL bool "SD controllers" default y help Support for SD cards on PCI host controllers. config VIRTIO_BLK - depends on DRIVES && QEMU_HARDWARE + depends on DRIVES && (QEMU_HARDWARE || KVMTOOL) bool "virtio-blk controllers" default y help Support boot from virtio-blk storage. config VIRTIO_SCSI - depends on DRIVES && QEMU_HARDWARE + depends on DRIVES && (QEMU_HARDWARE || KVMTOOL) bool "virtio-scsi controllers" default y help @@ -204,6 +214,7 @@ menu "Hardware support" Support boot from qemu-emulated lsi53c895a scsi storage. config MEGASAS depends on DRIVES + depends on !KVMTOOL bool "LSI MegaRAID SAS controllers" default y help @@ -216,6 +227,7 @@ menu "Hardware support" Support boot from LSI MPT Fusion scsi storage. config FLOPPY depends on DRIVES && HARDWARE_IRQ + depends on !KVMTOOL bool "Floppy controller" default y help @@ -229,6 +241,7 @@ menu "Hardware support" QEMU fw_cfg. config NVME depends on DRIVES + depends on !KVMTOOL bool "NVMe controllers" default y help @@ -236,6 +249,7 @@ menu "Hardware support" =20 config PS2PORT depends on KEYBOARD || MOUSE + depends on !KVMTOOL bool "PS/2 port" default y help @@ -243,6 +257,7 @@ menu "Hardware support" =20 config USB bool "USB" + depends on !KVMTOOL default y help Support USB devices. @@ -355,6 +370,7 @@ menu "Hardware support" Initialize the Memory Type Range Registers (on emulators). config PMTIMER bool "Support ACPI timer" + depends on !KVMTOOL default y help Detect and use the ACPI timer for timekeeping. @@ -404,6 +420,7 @@ menu "BIOS interfaces" config OPTIONROMS bool "Option ROMS" default y + depends on !KVMTOOL help Support finding and running option roms during POST. config PMM @@ -466,6 +483,7 @@ menu "BIOS interfaces" =20 config TCGBIOS depends on S3_RESUME + depends on !KVMTOOL bool "TPM support and TCG BIOS extensions" default y help @@ -493,6 +511,7 @@ menu "BIOS Tables" sometimes called DMI. config ACPI bool "ACPI" + depends on !KVMTOOL default y help Support generation of ACPI tables. --=20 2.9.3 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios From nobody Mon Apr 29 14:04:35 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) client-ip=80.81.252.135; envelope-from=seabios-bounces@seabios.org; helo=mail.coreboot.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) by mx.zohomail.com with SMTPS id 1509637882535688.6273775279209; Thu, 2 Nov 2017 08:51:22 -0700 (PDT) Received: from [127.0.0.1] (helo=ra.coreboot.org) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1eAHls-0007nw-QG; Thu, 02 Nov 2017 16:51:08 +0100 Received: from mx1.redhat.com ([209.132.183.28]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1eAHlh-0007m7-Cz for seabios@seabios.org; Thu, 02 Nov 2017 16:51:07 +0100 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B9BB8369C4; Thu, 2 Nov 2017 15:50:54 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A15660BE5; Thu, 2 Nov 2017 15:50:52 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 7C4113FB91; Thu, 2 Nov 2017 16:50:51 +0100 (CET) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B9BB8369C4 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: seabios@seabios.org, kvm@vger.kernel.org Date: Thu, 2 Nov 2017 16:50:30 +0100 Message-Id: <20171102155031.17454-3-kraxel@redhat.com> In-Reply-To: <20171102155031.17454-1-kraxel@redhat.com> References: <20171102155031.17454-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 02 Nov 2017 15:50:54 +0000 (UTC) X-Spam-Score: -3.0 (---) Subject: [SeaBIOS] [PATCH seabios 2/3] kvmtool: allow mmio for legacy bar 0 X-BeenThere: seabios@seabios.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SeaBIOS mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: seabios-bounces@seabios.org Sender: "SeaBIOS" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" kvmtool uses MMIO not IO bar for legacy virtio. Doesn't match spec. But easy to handle given we have the code anyway for virtio 1.0 which allows both MMIO and IO. Signed-off-by: Gerd Hoffmann --- src/hw/virtio-pci.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/hw/virtio-pci.c b/src/hw/virtio-pci.c index 96f9c6b012..1a3acc9962 100644 --- a/src/hw/virtio-pci.c +++ b/src/hw/virtio-pci.c @@ -488,10 +488,18 @@ void vp_init_simple(struct vp_device *vp, struct pci_= device *pci) } else { dprintf(1, "pci dev %pP using legacy (0.9.5) virtio mode\n", pci); vp->legacy.bar =3D 0; - vp->legacy.ioaddr =3D pci_enable_iobar(pci, PCI_BASE_ADDRESS_0); - if (!vp->legacy.ioaddr) - return; - vp->legacy.mode =3D VP_ACCESS_IO; + addr =3D pci_config_readl(pci->bdf, PCI_BASE_ADDRESS_0); + if (addr & PCI_BASE_ADDRESS_SPACE_IO) { + vp->legacy.ioaddr =3D addr & PCI_BASE_ADDRESS_IO_MASK; + if (!vp->legacy.ioaddr) + return; + vp->legacy.mode =3D VP_ACCESS_IO; + } else { + vp->legacy.ioaddr =3D addr & PCI_BASE_ADDRESS_MEM_MASK; + if (!vp->legacy.ioaddr) + return; + vp->legacy.mode =3D VP_ACCESS_MMIO; + } } =20 vp_reset(vp); --=20 2.9.3 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios From nobody Mon Apr 29 14:04:35 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) client-ip=80.81.252.135; envelope-from=seabios-bounces@seabios.org; helo=mail.coreboot.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) by mx.zohomail.com with SMTPS id 1509637902810501.1880667867341; Thu, 2 Nov 2017 08:51:42 -0700 (PDT) Received: from [127.0.0.1] (helo=ra.coreboot.org) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1eAHm2-0007uf-Ka; Thu, 02 Nov 2017 16:51:18 +0100 Received: from mx1.redhat.com ([209.132.183.28]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1eAHli-0007mL-12 for seabios@seabios.org; Thu, 02 Nov 2017 16:51:16 +0100 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 606E1A63E8; Thu, 2 Nov 2017 15:50:55 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 217FF5D757; Thu, 2 Nov 2017 15:50:52 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 7E84D3FB9C; Thu, 2 Nov 2017 16:50:51 +0100 (CET) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 606E1A63E8 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: seabios@seabios.org, kvm@vger.kernel.org Date: Thu, 2 Nov 2017 16:50:31 +0100 Message-Id: <20171102155031.17454-4-kraxel@redhat.com> In-Reply-To: <20171102155031.17454-1-kraxel@redhat.com> References: <20171102155031.17454-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 02 Nov 2017 15:50:55 +0000 (UTC) X-Spam-Score: -6.2 (------) Subject: [SeaBIOS] [PATCH seabios 3/3] kvmtool: support larger virtio queues X-BeenThere: seabios@seabios.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SeaBIOS mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: seabios-bounces@seabios.org Sender: "SeaBIOS" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Queues have 256 entries on kvmtool, support that. Needs more memory for virtqueues now. But with the move to 32bit drivers for virtio this should not be much of an issue any more. Known problems (probably kvmtool bugs): * Must bump to 260 entries to make things actually work, otherwise kvmtool segfaults. Oops. * Linux kernel doesn't find virtio-blk devices after seabios initialized them. virtio device reset not working properly? Signed-off-by: Gerd Hoffmann --- src/hw/virtio-ring.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hw/virtio-ring.h b/src/hw/virtio-ring.h index 8604a01140..cb8da89cab 100644 --- a/src/hw/virtio-ring.h +++ b/src/hw/virtio-ring.h @@ -20,7 +20,7 @@ #define VIRTIO_F_VERSION_1 32 #define VIRTIO_F_IOMMU_PLATFORM 33 =20 -#define MAX_QUEUE_NUM (128) +#define MAX_QUEUE_NUM (260) =20 #define VRING_DESC_F_NEXT 1 #define VRING_DESC_F_WRITE 2 --=20 2.9.3 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios