From patchwork Thu Mar 19 08:01:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 11446675 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BBF9E13B1 for ; Thu, 19 Mar 2020 08:02:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 92EBF20658 for ; Thu, 19 Mar 2020 08:02:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cRTgJFy9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 92EBF20658 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEq8W-0003BK-JM for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Mar 2020 04:02:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39594) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEq7P-0001T2-Va for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEq7O-0004j7-KC for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:31 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:37344) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEq7O-0004fm-FA for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584604889; 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=aTOl9V1tW+equkBFrFW1bOI3Sc3aPlZ699ReWgCv7Jg=; b=cRTgJFy9/nZHbDyxnrs7Z1S4rugvXr6MIk8+wAHzJNm68pIhkTvpIfOe79vtdp8U6uj2/5 C1ZG03ZyqmbHiWCSYKB23np1Qco8DuIq0WUoPb7mNAJ2f15YTJYTE7XTK8mtj2G2OLX37H d/8H/2LiTmLKYMSGYf4sVgppcFzf9hI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-286-N_2-T-3uPWCOG3V6BrflKQ-1; Thu, 19 Mar 2020 04:01:27 -0400 X-MC-Unique: N_2-T-3uPWCOG3V6BrflKQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 98EEF18B9FC2; Thu, 19 Mar 2020 08:01:26 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D9A01001B07; Thu, 19 Mar 2020 08:01:18 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A645131EAC; Thu, 19 Mar 2020 09:01:17 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 01/13] acpi: make build_madt() more generic. Date: Thu, 19 Mar 2020 09:01:05 +0100 Message-Id: <20200319080117.7725-2-kraxel@redhat.com> In-Reply-To: <20200319080117.7725-1-kraxel@redhat.com> References: <20200319080117.7725-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Sergio Lopez , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Remove PCMachineState dependency from build_madt(). Pass AcpiDeviceIf as separate argument instead of depending on PCMachineState->acpi_dev. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daudé --- hw/i386/acpi-build.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 9a19c14e661b..1b0684c433e3 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -360,14 +360,13 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, } static void -build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) +build_madt(GArray *table_data, BIOSLinker *linker, + X86MachineState *x86ms, AcpiDeviceIf *adev) { - MachineClass *mc = MACHINE_GET_CLASS(pcms); - X86MachineState *x86ms = X86_MACHINE(pcms); - const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(MACHINE(pcms)); + MachineClass *mc = MACHINE_GET_CLASS(x86ms); + const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(MACHINE(x86ms)); int madt_start = table_data->len; - AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(pcms->acpi_dev); - AcpiDeviceIf *adev = ACPI_DEVICE_IF(pcms->acpi_dev); + AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(adev); bool x2apic_mode = false; AcpiMultipleApicTable *madt; @@ -2807,7 +2806,8 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine) aml_len += tables_blob->len - fadt; acpi_add_table(table_offsets, tables_blob); - build_madt(tables_blob, tables->linker, pcms); + build_madt(tables_blob, tables->linker, x86ms, + ACPI_DEVICE_IF(pcms->acpi_dev)); vmgenid_dev = find_vmgenid_dev(); if (vmgenid_dev) { From patchwork Thu Mar 19 08:01:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 11446671 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D24F317E6 for ; Thu, 19 Mar 2020 08:02:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A6E5C20658 for ; Thu, 19 Mar 2020 08:02:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NaSiEtXX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6E5C20658 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEq8V-00038r-Fw for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Mar 2020 04:02:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39606) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEq7Q-0001T5-0R for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEq7O-0004jE-Lb for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:31 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:49280) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEq7O-0004fp-HS for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584604889; 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=wxx+HDP3PblSEYn7hc5uWwJhnLPJ5TFBBPYfzgZ8K7E=; b=NaSiEtXXggPR+JoQbiKxeueIFsWTG+25aSTDCPuLD9rYihUxJ7gG+Txy7j8QMEITUJnoSG leKcdZ6s0WUTWVavCI7lMnGtv34sT+8X36022ez7pTCnwr2QN8ZAfrb54Zwbm+aGUTwZRQ mNsr9626/H6cPORi41l/7yRFvqZmQSA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-143-eHV0_m9IOteX-Ltb8VEB-A-1; Thu, 19 Mar 2020 04:01:27 -0400 X-MC-Unique: eHV0_m9IOteX-Ltb8VEB-A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AC0C61005510; Thu, 19 Mar 2020 08:01:26 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 689F91001938; Thu, 19 Mar 2020 08:01:18 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id AF32231F24; Thu, 19 Mar 2020 09:01:17 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 02/13] acpi: factor out acpi_dsdt_add_fw_cfg() Date: Thu, 19 Mar 2020 09:01:06 +0100 Message-Id: <20200319080117.7725-3-kraxel@redhat.com> In-Reply-To: <20200319080117.7725-1-kraxel@redhat.com> References: <20200319080117.7725-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Sergio Lopez , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Add helper function to add fw_cfg device. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daudé --- hw/i386/acpi-build.c | 50 ++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 1b0684c433e3..9c98b07116cc 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1822,6 +1822,32 @@ static void build_smb0(Aml *table, I2CBus *smbus, int devnr, int func) aml_append(table, scope); } +static void acpi_dsdt_add_fw_cfg(Aml *scope, Object *fw_cfg) +{ + /* + * when using port i/o, the 8-bit data register *always* overlaps + * with half of the 16-bit control register. Hence, the total size + * of the i/o region used is FW_CFG_CTL_SIZE; when using DMA, the + * DMA control register is located at FW_CFG_DMA_IO_BASE + 4 + */ + uint8_t io_size = object_property_get_bool(fw_cfg, "dma_enabled", NULL) ? + ROUND_UP(FW_CFG_CTL_SIZE, 4) + sizeof(dma_addr_t) : + FW_CFG_CTL_SIZE; + Aml *dev = aml_device("FWCF"); + Aml *crs = aml_resource_template(); + + aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002"))); + + /* device present, functioning, decoding, not shown in UI */ + aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); + + aml_append(crs, + aml_io(AML_DECODE16, FW_CFG_IO_BASE, FW_CFG_IO_BASE, 0x01, io_size)); + + aml_append(dev, aml_name_decl("_CRS", crs)); + aml_append(scope, dev); +} + static void build_dsdt(GArray *table_data, BIOSLinker *linker, AcpiPmInfo *pm, AcpiMiscInfo *misc, @@ -2101,30 +2127,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, /* create fw_cfg node, unconditionally */ { - /* when using port i/o, the 8-bit data register *always* overlaps - * with half of the 16-bit control register. Hence, the total size - * of the i/o region used is FW_CFG_CTL_SIZE; when using DMA, the - * DMA control register is located at FW_CFG_DMA_IO_BASE + 4 */ - uint8_t io_size = object_property_get_bool(OBJECT(x86ms->fw_cfg), - "dma_enabled", NULL) ? - ROUND_UP(FW_CFG_CTL_SIZE, 4) + sizeof(dma_addr_t) : - FW_CFG_CTL_SIZE; - scope = aml_scope("\\_SB.PCI0"); - dev = aml_device("FWCF"); - - aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002"))); - - /* device present, functioning, decoding, not shown in UI */ - aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); - - crs = aml_resource_template(); - aml_append(crs, - aml_io(AML_DECODE16, FW_CFG_IO_BASE, FW_CFG_IO_BASE, 0x01, io_size) - ); - aml_append(dev, aml_name_decl("_CRS", crs)); - - aml_append(scope, dev); + acpi_dsdt_add_fw_cfg(scope, OBJECT(x86ms->fw_cfg)); aml_append(dsdt, scope); } From patchwork Thu Mar 19 08:01:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 11446669 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D65B317E6 for ; Thu, 19 Mar 2020 08:02:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AB53220658 for ; Thu, 19 Mar 2020 08:02:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GXI6L1GR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB53220658 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEq8U-000377-Mr for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Mar 2020 04:02:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39603) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEq7Q-0001T4-1j for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEq7O-0004ix-Jg for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:31 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:23126) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEq7O-0004gt-E2 for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584604890; 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=HTYhOkELmHFCgie3ThSBryZcp/TC9L9pIbajWLjOzNU=; b=GXI6L1GRxmBSWqJLwG6DPBY5C8xZIsm/5Ty6rmwEtyI0gGUCFSjSf/ZGOBz8KqOAXzbqMK j2MeRvsBgNWjHEC8q0oKnSqtsTJ6PQNTLiVimyWuHo0Hem0YKVVk61za8gM/6NDicJf4/R SypjSLDCy1XEieQ+BaT7dJ71zt7LJn8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-286-GE7tqcOTPsuVSK6D42K-yw-1; Thu, 19 Mar 2020 04:01:28 -0400 X-MC-Unique: GE7tqcOTPsuVSK6D42K-yw-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0AC65800D54; Thu, 19 Mar 2020 08:01:27 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 665265DA81; Thu, 19 Mar 2020 08:01:18 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B98C731F2D; Thu, 19 Mar 2020 09:01:17 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 03/13] microvm: add isa-acpi device Date: Thu, 19 Mar 2020 09:01:07 +0100 Message-Id: <20200319080117.7725-4-kraxel@redhat.com> In-Reply-To: <20200319080117.7725-1-kraxel@redhat.com> References: <20200319080117.7725-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Sergio Lopez , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Minimal ACPI device for PCI-less machines like microvm. Signed-off-by: Gerd Hoffmann --- hw/acpi/isa-acpi.c | 114 ++++++++++++++++++++++++++++++++++++++++++ hw/acpi/Makefile.objs | 1 + 2 files changed, 115 insertions(+) create mode 100644 hw/acpi/isa-acpi.c diff --git a/hw/acpi/isa-acpi.c b/hw/acpi/isa-acpi.c new file mode 100644 index 000000000000..5d7d770a5c0b --- /dev/null +++ b/hw/acpi/isa-acpi.c @@ -0,0 +1,114 @@ +#include "qemu/osdep.h" +#include "hw/i386/pc.h" +#include "hw/acpi/acpi.h" +#include "sysemu/runstate.h" + +typedef struct ISAACPI { + ISADevice base; + + uint32_t io_base; + uint16_t sci_irq; + uint32_t gpe_base; + uint32_t gpe_len; + + qemu_irq irq; + MemoryRegion io; + ACPIREGS acpi; + Notifier powerdown_req; +} ISAACPI; + +#define TYPE_ISA_ACPI "isa-acpi" +#define ISA_ACPI(obj) \ + OBJECT_CHECK(ISAACPI, (obj), TYPE_ISA_ACPI) + +static void isa_acpi_timer(ACPIREGS *acpi) +{ + ISAACPI *s = container_of(acpi, ISAACPI, acpi); + acpi_update_sci(&s->acpi, s->irq); +} + +static void isa_acpi_init(Object *obj) +{ + ISAACPI *s = ISA_ACPI(obj); + + s->io_base = 0x600; + s->sci_irq = 9; + s->gpe_base = 0x680; + s->gpe_len = 4; +} + +static void isa_acpi_powerdown_req(Notifier *n, void *opaque) +{ + ISAACPI *s = container_of(n, ISAACPI, powerdown_req); + + acpi_pm1_evt_power_down(&s->acpi); +} + +static void isa_acpi_add_propeties(ISAACPI *s) +{ + static const uint8_t zero; + + object_property_add_uint8_ptr(OBJECT(s), ACPI_PM_PROP_ACPI_ENABLE_CMD, + &zero, NULL); + object_property_add_uint8_ptr(OBJECT(s), ACPI_PM_PROP_ACPI_DISABLE_CMD, + &zero, NULL); + object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_GPE0_BLK, + &s->gpe_base, NULL); + object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_GPE0_BLK_LEN, + &s->gpe_len, NULL); + object_property_add_uint16_ptr(OBJECT(s), ACPI_PM_PROP_SCI_INT, + &s->sci_irq, NULL); + object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_PM_IO_BASE, + &s->io_base, NULL); +} + +static void isa_acpi_realize(DeviceState *dev, Error **errp) +{ + ISADevice *isa = ISA_DEVICE(dev); + ISAACPI *s = ISA_ACPI(dev); + + memory_region_init(&s->io, OBJECT(s), "isa-acpi", 64); + memory_region_set_enabled(&s->io, true); + isa_register_ioport(isa, &s->io, s->io_base); + isa_init_irq(isa, &s->irq, s->sci_irq); + + acpi_pm_tmr_init(&s->acpi, isa_acpi_timer, &s->io); + acpi_pm1_evt_init(&s->acpi, isa_acpi_timer, &s->io); + acpi_pm1_cnt_init(&s->acpi, &s->io, true, true, 0); + acpi_gpe_init(&s->acpi, 4); + + s->powerdown_req.notify = isa_acpi_powerdown_req; + qemu_register_powerdown_notifier(&s->powerdown_req); + + isa_acpi_add_propeties(s); +} + +static void isa_acpi_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_CLASS(klass); + + dc->realize = isa_acpi_realize; + dc->user_creatable = false; + dc->hotpluggable = false; + adevc->madt_cpu = pc_madt_cpu_entry; +} + +static const TypeInfo isa_acpi_info = { + .name = TYPE_ISA_ACPI, + .parent = TYPE_ISA_DEVICE, + .instance_size = sizeof(ISAACPI), + .instance_init = isa_acpi_init, + .class_init = isa_acpi_class_init, + .interfaces = (InterfaceInfo[]) { + { TYPE_ACPI_DEVICE_IF }, + { } + } +}; + +static void register_types(void) +{ + type_register_static(&isa_acpi_info); +} + +type_init(register_types) diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs index 777da07f4d70..aae53c73ebbd 100644 --- a/hw/acpi/Makefile.objs +++ b/hw/acpi/Makefile.objs @@ -14,6 +14,7 @@ common-obj-$(call lnot,$(CONFIG_PC)) += acpi-x86-stub.o common-obj-y += acpi_interface.o common-obj-y += bios-linker-loader.o common-obj-y += aml-build.o utils.o +common-obj-$(CONFIG_PC) += isa-acpi.o common-obj-$(CONFIG_ACPI_PCI) += pci.o common-obj-$(CONFIG_TPM) += tpm.o From patchwork Thu Mar 19 08:01:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 11446683 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ACA9F1874 for ; Thu, 19 Mar 2020 08:04:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 83A852072C for ; Thu, 19 Mar 2020 08:04:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="L8j0szI6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83A852072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEqAR-0006eG-NX for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Mar 2020 04:04:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39613) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEq7Q-0001T6-9H for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEq7O-0004j2-Jr for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:32 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:41404) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEq7O-0004h7-FQ for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584604890; 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=NWvxDS7H8AaigA0bd8Nw3S4+C3ckHHyPdHX9C8DG2i8=; b=L8j0szI6xp3Lxa0/KaXpsW0h2IF9h+jUel0FzEX0J9LZmbJa8/l5I4XKXaGiA5Bqe+vOpF DB4eXoCwF0P8wLC36unUJmdKRbMaOK5WE6eb3LoLnOMv2xYwrQ4jIW0wWteqvk+08b+hyX 72xjrwSChumlMbdqwsOODMHvhxUpAA4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-427-JEYTNV1pPdSDumNQOTuXsw-1; Thu, 19 Mar 2020 04:01:28 -0400 X-MC-Unique: JEYTNV1pPdSDumNQOTuXsw-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 02994107ACCC; Thu, 19 Mar 2020 08:01:27 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 703996EFA7; Thu, 19 Mar 2020 08:01:18 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C5C1F31F3B; Thu, 19 Mar 2020 09:01:17 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 04/13] microvm: add minimal acpi support. Date: Thu, 19 Mar 2020 09:01:08 +0100 Message-Id: <20200319080117.7725-5-kraxel@redhat.com> In-Reply-To: <20200319080117.7725-1-kraxel@redhat.com> References: <20200319080117.7725-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-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Sergio Lopez , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" $subject says all. Can be disabled using the usual -no-acpi switch. Signed-off-by: Gerd Hoffmann --- include/hw/i386/microvm.h | 3 + hw/i386/acpi-build.c | 124 +++++++++++++++++++++++++++++++++++--- hw/i386/microvm.c | 14 +++++ 3 files changed, 133 insertions(+), 8 deletions(-) diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h index ba68d1f22bb3..da2852a70195 100644 --- a/include/hw/i386/microvm.h +++ b/include/hw/i386/microvm.h @@ -24,6 +24,7 @@ #include "hw/boards.h" #include "hw/i386/x86.h" +#include "hw/acpi/acpi_dev_interface.h" /* Platform virtio definitions */ #define VIRTIO_MMIO_BASE 0xc0000000 @@ -58,6 +59,8 @@ typedef struct { /* Machine state */ bool kernel_cmdline_fixed; + Notifier machine_done; + AcpiDeviceIf *acpi_dev; } MicrovmMachineState; #define TYPE_MICROVM_MACHINE MACHINE_TYPE_NAME("microvm") diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 9c98b07116cc..0e45a646af56 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -59,6 +59,7 @@ #include "hw/pci/pci_bus.h" #include "hw/pci-host/q35.h" #include "hw/i386/x86-iommu.h" +#include "hw/i386/microvm.h" #include "hw/acpi/aml-build.h" #include "hw/acpi/utils.h" @@ -2749,12 +2750,103 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) return true; } +static void +build_dsdt_microvm(GArray *table_data, BIOSLinker *linker, + MicrovmMachineState *mms) +{ + X86MachineState *x86ms = X86_MACHINE(mms); + Aml *dsdt, *sb_scope, *scope, *pkg; + + dsdt = init_aml_allocator(); + + /* Reserve space for header */ + acpi_data_push(dsdt->buf, sizeof(AcpiTableHeader)); + + build_dbg_aml(dsdt); + + sb_scope = aml_scope("_SB"); + acpi_dsdt_add_fw_cfg(sb_scope, OBJECT(x86ms->fw_cfg)); + aml_append(dsdt, sb_scope); + + scope = aml_scope("\\"); + pkg = aml_package(4); + aml_append(pkg, aml_int(0)); /* PM1a_CNT.SLP_TYP */ + aml_append(pkg, aml_int(0)); /* PM1b_CNT.SLP_TYP not impl. */ + aml_append(pkg, aml_int(0)); /* reserved */ + aml_append(pkg, aml_int(0)); /* reserved */ + aml_append(scope, aml_name_decl("_S5", pkg)); + aml_append(dsdt, scope); + + /* copy AML table into ACPI tables blob and patch header there */ + g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len); + build_header(linker, table_data, + (void *)(table_data->data + table_data->len - dsdt->buf->len), + "DSDT", dsdt->buf->len, 1, NULL, NULL); + free_aml_allocator(); +} + +static +void acpi_build_microvm(AcpiBuildTables *tables, MachineState *machine) +{ + MicrovmMachineState *mms = MICROVM_MACHINE(machine); + GArray *table_offsets; + GArray *tables_blob = tables->table_data; + AcpiFadtData pmfadt; + unsigned facs, dsdt, rsdt; + + init_common_fadt_data(machine, OBJECT(mms->acpi_dev), &pmfadt); + pmfadt.smi_cmd = 0; + + table_offsets = g_array_new(false, true /* clear */, + sizeof(uint32_t)); + bios_linker_loader_alloc(tables->linker, + ACPI_BUILD_TABLE_FILE, tables_blob, + 64 /* Ensure FACS is aligned */, + false /* high memory */); + + facs = tables_blob->len; + build_facs(tables_blob); + + dsdt = tables_blob->len; + build_dsdt_microvm(tables_blob, tables->linker, mms); + + pmfadt.facs_tbl_offset = &facs; + pmfadt.dsdt_tbl_offset = &dsdt; + pmfadt.xdsdt_tbl_offset = &dsdt; + acpi_add_table(table_offsets, tables_blob); + build_fadt(tables_blob, tables->linker, &pmfadt, NULL, NULL); + + acpi_add_table(table_offsets, tables_blob); + build_madt(tables_blob, tables->linker, X86_MACHINE(machine), + mms->acpi_dev); + + rsdt = tables_blob->len; + build_rsdt(tables_blob, tables->linker, table_offsets, NULL, NULL); + + /* RSDP is in FSEG memory, so allocate it separately */ + { + AcpiRsdpData rsdp_data = { + .revision = 0, + .oem_id = ACPI_BUILD_APPNAME6, + .xsdt_tbl_offset = NULL, + .rsdt_tbl_offset = &rsdt, + }; + build_rsdp(tables->rsdp, tables->linker, &rsdp_data); + } + + acpi_align_size(tables_blob, ACPI_BUILD_TABLE_SIZE); + acpi_align_size(tables->linker->cmd_blob, ACPI_BUILD_ALIGN_SIZE); + + /* Cleanup memory that's no longer used. */ + g_array_free(table_offsets, true); +} + static void acpi_build(AcpiBuildTables *tables, MachineState *machine) { - PCMachineState *pcms = PC_MACHINE(machine); - PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); X86MachineState *x86ms = X86_MACHINE(machine); + PCMachineState *pcms; + PCMachineClass *pcmc; GArray *table_offsets; unsigned facs, dsdt, rsdt, fadt; AcpiPmInfo pm; @@ -2767,6 +2859,14 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine) AcpiSlicOem slic_oem = { .id = NULL, .table_id = NULL }; Object *vmgenid_dev; + if (strcmp(object_get_typename(OBJECT(x86ms)), TYPE_MICROVM_MACHINE) == 0) { + acpi_build_microvm(tables, machine); + return; + } else { + pcms = PC_MACHINE(machine); + pcmc = PC_MACHINE_GET_CLASS(pcms); + } + acpi_get_pm_info(machine, &pm); acpi_get_misc_info(&misc); acpi_get_pci_holes(&pci_hole, &pci_hole64); @@ -3009,21 +3109,29 @@ static const VMStateDescription vmstate_acpi_build = { void acpi_setup(void) { - PCMachineState *pcms = PC_MACHINE(qdev_get_machine()); - PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); - X86MachineState *x86ms = X86_MACHINE(pcms); + X86MachineState *x86ms = X86_MACHINE(qdev_get_machine()); + PCMachineState *pcms; + PCMachineClass *pcmc; AcpiBuildTables tables; AcpiBuildState *build_state; Object *vmgenid_dev; TPMIf *tpm; static FwCfgTPMConfig tpm_config; + if (strcmp(object_get_typename(OBJECT(x86ms)), TYPE_MICROVM_MACHINE) == 0) { + pcms = NULL; + pcmc = NULL; + } else { + pcms = PC_MACHINE(x86ms); + pcmc = PC_MACHINE_GET_CLASS(pcms); + } + if (!x86ms->fw_cfg) { ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n"); return; } - if (!pcms->acpi_build_enabled) { + if (pcms && !pcms->acpi_build_enabled) { ACPI_BUILD_DPRINTF("ACPI build disabled. Bailing out.\n"); return; } @@ -3036,7 +3144,7 @@ void acpi_setup(void) build_state = g_malloc0(sizeof *build_state); acpi_build_tables_init(&tables); - acpi_build(&tables, MACHINE(pcms)); + acpi_build(&tables, MACHINE(x86ms)); /* Now expose it all to Guest */ build_state->table_mr = acpi_add_rom_blob(acpi_build_update, @@ -3069,7 +3177,7 @@ void acpi_setup(void) tables.vmgenid); } - if (!pcmc->rsdp_in_ram) { + if (pcmc && !pcmc->rsdp_in_ram) { /* * Keep for compatibility with old machine types. * Though RSDP is small, its contents isn't immutable, so diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index 38d8e5170323..362d513f38e1 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -26,6 +26,7 @@ #include "sysemu/cpus.h" #include "sysemu/numa.h" #include "sysemu/reset.h" +#include "acpi-build.h" #include "hw/loader.h" #include "hw/irq.h" @@ -41,6 +42,7 @@ #include "hw/i386/e820_memory_layout.h" #include "hw/i386/fw_cfg.h" #include "hw/virtio/virtio-mmio.h" +#include "hw/acpi/acpi.h" #include "cpu.h" #include "elf.h" @@ -128,6 +130,10 @@ static void microvm_devices_init(MicrovmMachineState *mms) } /* Optional and legacy devices */ + if (acpi_enabled) { + ISADevice *acpi = isa_create_simple(isa_bus, "isa-acpi" /* FIXME */); + mms->acpi_dev = ACPI_DEVICE_IF(acpi); + } if (mms->pic == ON_OFF_AUTO_ON || mms->pic == ON_OFF_AUTO_AUTO) { qemu_irq *i8259; @@ -468,6 +474,11 @@ static void microvm_machine_set_auto_kernel_cmdline(Object *obj, bool value, mms->auto_kernel_cmdline = value; } +static void microvm_machine_done(Notifier *notifier, void *data) +{ + acpi_setup(); +} + static void microvm_machine_initfn(Object *obj) { MicrovmMachineState *mms = MICROVM_MACHINE(obj); @@ -482,6 +493,9 @@ static void microvm_machine_initfn(Object *obj) /* State */ mms->kernel_cmdline_fixed = false; + + mms->machine_done.notify = microvm_machine_done; + qemu_add_machine_init_done_notifier(&mms->machine_done); } static void microvm_class_init(ObjectClass *oc, void *data) From patchwork Thu Mar 19 08:01:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 11446709 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5130017E6 for ; Thu, 19 Mar 2020 08:10:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 26EE52072C for ; Thu, 19 Mar 2020 08:10:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gvOgjVId" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26EE52072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEqGR-00064z-BY for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Mar 2020 04:10:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39758) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEq7e-0001kU-BK for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEq7Y-0005XZ-Qx for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:43 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:42583) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEq7Y-0005V3-M0 for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584604900; 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=1hIQzOVownPUgeOfpivxGQH7GbNiuNjbqeCCe9FxpM4=; b=gvOgjVIdxgXdS4r6F9DdHY36nt/isWbuYL6/RYWWObw1MYy3EFPLg26ld7O6HzRCUDqS9d aoatdc39+GS/ATPzzY+Pn+XVeN6+K2099C9C9AVmJCp4w5GkkVsoPQ7NsJgmNSUTFswz1k qx5VP4PxCmkeVoWa8GtgJ4vAmWhWFO8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-336-wxmEcOsFPcuNQnXPC_y32w-1; Thu, 19 Mar 2020 04:01:38 -0400 X-MC-Unique: wxmEcOsFPcuNQnXPC_y32w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 10C19107B76A; Thu, 19 Mar 2020 08:01:37 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7843D90812; Thu, 19 Mar 2020 08:01:28 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id CEC9431F48; Thu, 19 Mar 2020 09:01:17 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 05/13] microvm: add acpi_dsdt_add_virtio() for x86 Date: Thu, 19 Mar 2020 09:01:09 +0100 Message-Id: <20200319080117.7725-6-kraxel@redhat.com> In-Reply-To: <20200319080117.7725-1-kraxel@redhat.com> References: <20200319080117.7725-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Sergio Lopez , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Makes x86 linux kernel find virtio-mmio devices automatically. Signed-off-by: Gerd Hoffmann --- hw/i386/acpi-build.c | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 0e45a646af56..80844db24d6b 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -21,6 +21,7 @@ */ #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "qapi/error.h" #include "qapi/qmp/qnum.h" #include "acpi-build.h" @@ -60,6 +61,7 @@ #include "hw/pci-host/q35.h" #include "hw/i386/x86-iommu.h" #include "hw/i386/microvm.h" +#include "hw/virtio/virtio-mmio.h" #include "hw/acpi/aml-build.h" #include "hw/acpi/utils.h" @@ -2750,6 +2752,54 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) return true; } +static void acpi_dsdt_add_virtio(Aml *scope) +{ + gchar *separator; + long int index; + BusState *bus; + BusChild *kid; + + bus = sysbus_get_default(); + QTAILQ_FOREACH(kid, &bus->children, sibling) { + DeviceState *dev = kid->child; + ObjectClass *class = object_get_class(OBJECT(dev)); + + if (class == object_class_by_name(TYPE_VIRTIO_MMIO)) { + VirtIOMMIOProxy *mmio = VIRTIO_MMIO(OBJECT(dev)); + VirtioBusState *mmio_virtio_bus = &mmio->bus; + BusState *mmio_bus = &mmio_virtio_bus->parent_obj; + + if (QTAILQ_EMPTY(&mmio_bus->children)) { + continue; + } + separator = g_strrstr(mmio_bus->name, "."); + if (!separator) { + continue; + } + if (qemu_strtol(separator + 1, NULL, 10, &index) != 0) { + continue; + } + + uint32_t irq = VIRTIO_IRQ_BASE + index; + hwaddr base = VIRTIO_MMIO_BASE + index * 512; + hwaddr size = 512; + + Aml *dev = aml_device("VR%02u", (unsigned)index); + aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0005"))); + aml_append(dev, aml_name_decl("_UID", aml_int(index))); + aml_append(dev, aml_name_decl("_CCA", aml_int(1))); + + Aml *crs = aml_resource_template(); + aml_append(crs, aml_memory32_fixed(base, size, AML_READ_WRITE)); + aml_append(crs, + aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH, + AML_EXCLUSIVE, &irq, 1)); + aml_append(dev, aml_name_decl("_CRS", crs)); + aml_append(scope, dev); + } + } +} + static void build_dsdt_microvm(GArray *table_data, BIOSLinker *linker, MicrovmMachineState *mms) @@ -2766,6 +2816,7 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *linker, sb_scope = aml_scope("_SB"); acpi_dsdt_add_fw_cfg(sb_scope, OBJECT(x86ms->fw_cfg)); + acpi_dsdt_add_virtio(sb_scope); aml_append(dsdt, sb_scope); scope = aml_scope("\\"); From patchwork Thu Mar 19 08:01:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 11446689 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D6B217E6 for ; Thu, 19 Mar 2020 08:08:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3353D2072C for ; Thu, 19 Mar 2020 08:08:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VG2X2c65" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3353D2072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEqDh-0004Cr-BE for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Mar 2020 04:08:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39746) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEq7a-0001k5-25 for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEq7Y-0005YP-VY for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:41 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:57793) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEq7Y-0005W4-Ql for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584604900; 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=ru0ezrnSjCOFrcw7qNzHSdv4vQBpHGBoNyHGfyYxptM=; b=VG2X2c65jo+hbaCPMpHP+dX/tB5wRDrh5QYhz1Ed5nDjpKF1TVnZokGsjx3tqvOCr+u0ei f0c+SYpM8do7nn59S9QH0YXTJVVdxVMKi/WeXjeJhVcwP0S+1TGpxCZlD4p9A5Z/fXB2/r GRDQT6cqmwRLH+1vVdP6+TTJlvGJ80Y= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-62-iwQyjvadPGOwwfTDglbeBw-1; Thu, 19 Mar 2020 04:01:36 -0400 X-MC-Unique: iwQyjvadPGOwwfTDglbeBw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C9BAF800D5B; Thu, 19 Mar 2020 08:01:35 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 89FC85C1D8; Thu, 19 Mar 2020 08:01:27 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D7A3831F62; Thu, 19 Mar 2020 09:01:17 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 06/13] microvm: disable virtio-mmio cmdline hack Date: Thu, 19 Mar 2020 09:01:10 +0100 Message-Id: <20200319080117.7725-7-kraxel@redhat.com> In-Reply-To: <20200319080117.7725-1-kraxel@redhat.com> References: <20200319080117.7725-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Sergio Lopez , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" ... in case we are using ACPI. Signed-off-by: Gerd Hoffmann --- hw/i386/microvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index 362d513f38e1..fd753764fc10 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -361,7 +361,7 @@ static void microvm_machine_reset(MachineState *machine) CPUState *cs; X86CPU *cpu; - if (machine->kernel_filename != NULL && + if (!acpi_enabled && machine->kernel_filename != NULL && mms->auto_kernel_cmdline && !mms->kernel_cmdline_fixed) { microvm_fix_kernel_cmdline(machine); mms->kernel_cmdline_fixed = true; From patchwork Thu Mar 19 08:01:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 11446699 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9517917E6 for ; Thu, 19 Mar 2020 08:09:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6C8162072C for ; Thu, 19 Mar 2020 08:09:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="U0ji4ZJM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C8162072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEqF8-00055G-Gm for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Mar 2020 04:09:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39771) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEq7e-0001mX-F5 for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEq7b-0005gv-9E for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:46 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:20801) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEq7a-0005bU-0C for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584604901; 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=E9hfy3vdBCnyEY97AeX6cPqCQtaybV53wcmgVyMvvIk=; b=U0ji4ZJMexqYUkaDZKltf+D3EFD5AqPstBDBZxQS93RRh3vssNNkfDpLyLPRukLCNYhA9g UsiJrVLwTw3qdmAVBkLXqHJMuJSEGZZrE+9o8Abwh4Pgl/fDDWKUpVA+d7DA79ua4CebPq EridEjULU1KJPTutoPWgVcDTy0YGBsg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-62-XiL95cPsNp6bCCFWkWNjEg-1; Thu, 19 Mar 2020 04:01:36 -0400 X-MC-Unique: XiL95cPsNp6bCCFWkWNjEg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 96C658010C4; Thu, 19 Mar 2020 08:01:35 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8375119756; Thu, 19 Mar 2020 08:01:27 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E00D931FAA; Thu, 19 Mar 2020 09:01:17 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 07/13] [testing] seabios: update submodule to experimental microvm branch Date: Thu, 19 Mar 2020 09:01:11 +0100 Message-Id: <20200319080117.7725-8-kraxel@redhat.com> In-Reply-To: <20200319080117.7725-1-kraxel@redhat.com> References: <20200319080117.7725-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Sergio Lopez , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" https://git.kraxel.org/cgit/seabios/log/?h=microvm Signed-off-by: Gerd Hoffmann --- roms/seabios | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roms/seabios b/roms/seabios index f21b5a4aeb02..81a6f4b87318 160000 --- a/roms/seabios +++ b/roms/seabios @@ -1 +1 @@ -Subproject commit f21b5a4aeb020f2a5e2c6503f906a9349dd2f069 +Subproject commit 81a6f4b87318a945e3a4cd014c2efa89482a0cd0 From patchwork Thu Mar 19 08:01:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 11446681 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 767E217E6 for ; Thu, 19 Mar 2020 08:04:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4D2E12072C for ; Thu, 19 Mar 2020 08:04:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AT+8vAnV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D2E12072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEqAR-0006dq-DT for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Mar 2020 04:04:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39701) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEq7Y-0001fm-2P for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEq7W-0005N0-U8 for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:39 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:24006) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEq7W-0005KC-Oq for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584604898; 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=Ssy9iYBYNdlyaM+qTxCdmrI48NkNzUMw9zb+KooWCBc=; b=AT+8vAnVk8MPy0viq7Mf7tZPAHX48+tBerSzFzc6SO9UNE7mjpaEEKAJtiVp8zGXJhoDIO Yo4JrqBRyQWNM+2XsqEsBEXgiDXKIwgzgr1ewrE0J6rihIyE0t6GtYHhj8URKUDKrwHHuA hRNhfNGDsikPEK40uGAm/wEy0LDrTF4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-259-uo82Brs9O6CaKmy7Sa_LBg-1; Thu, 19 Mar 2020 04:01:36 -0400 X-MC-Unique: uo82Brs9O6CaKmy7Sa_LBg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9174C18B9FC4; Thu, 19 Mar 2020 08:01:35 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D5A719757; Thu, 19 Mar 2020 08:01:28 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id EB5B03EBB9; Thu, 19 Mar 2020 09:01:17 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 08/13] [testing] seabios: update config & build rules Date: Thu, 19 Mar 2020 09:01:12 +0100 Message-Id: <20200319080117.7725-9-kraxel@redhat.com> In-Reply-To: <20200319080117.7725-1-kraxel@redhat.com> References: <20200319080117.7725-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Sergio Lopez , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Gerd Hoffmann --- roms/Makefile | 5 ++++- roms/config.seabios-128k | 2 ++ roms/config.seabios-microvm | 25 +++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 roms/config.seabios-microvm diff --git a/roms/Makefile b/roms/Makefile index f9acf39954dc..c0dde0a063c6 100644 --- a/roms/Makefile +++ b/roms/Makefile @@ -72,9 +72,12 @@ default help: @echo " clean -- delete the files generated by the previous" \ "build targets" -bios: build-seabios-config-seabios-128k build-seabios-config-seabios-256k +bios: build-seabios-config-seabios-128k \ + build-seabios-config-seabios-256k \ + build-seabios-config-seabios-microvm cp seabios/builds/seabios-128k/bios.bin ../pc-bios/bios.bin cp seabios/builds/seabios-256k/bios.bin ../pc-bios/bios-256k.bin + cp seabios/builds/seabios-microvm/bios.bin ../pc-bios/bios-microvm.bin vgabios seavgabios: $(patsubst %,seavgabios-%,$(vgabios_variants)) diff --git a/roms/config.seabios-128k b/roms/config.seabios-128k index c43912bf9de4..bbed77cfc5c5 100644 --- a/roms/config.seabios-128k +++ b/roms/config.seabios-128k @@ -11,6 +11,8 @@ CONFIG_USB_UAS=n CONFIG_SDCARD=n CONFIG_TCGBIOS=n CONFIG_MPT_SCSI=n +CONFIG_ESP_SCSI=n +CONFIG_MEGASAS=n CONFIG_PVSCSI=n CONFIG_NVME=n CONFIG_USE_SMM=n diff --git a/roms/config.seabios-microvm b/roms/config.seabios-microvm new file mode 100644 index 000000000000..46bb019ada68 --- /dev/null +++ b/roms/config.seabios-microvm @@ -0,0 +1,25 @@ +CONFIG_QEMU=y +CONFIG_QEMU_HARDWARE=y +CONFIG_PERMIT_UNALIGNED_PCIROM=y +CONFIG_ROM_SIZE=128 +CONFIG_XEN=n +CONFIG_BOOTSPLASH=n +CONFIG_ATA=n +CONFIG_AHCI=n +CONFIG_SDCARD=n +CONFIG_PVSCSI=n +CONFIG_ESP_SCSI=n +CONFIG_LSI_SCSI=n +CONFIG_MEGASAS=n +CONFIG_MPT_SCSI=n +CONFIG_FLOPPY=n +CONFIG_FLASH_FLOPPY=n +CONFIG_NVME=n +CONFIG_PS2PORT=n +CONFIG_USB=n +CONFIG_LPT=n +CONFIG_RTC_TIMER=n +CONFIG_USE_SMM=n +CONFIG_PMTIMER=n +CONFIG_TCGBIOS=n +CONFIG_HARDWARE_IRQ=n From patchwork Thu Mar 19 08:01:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 11446685 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2CE117E6 for ; Thu, 19 Mar 2020 08:06:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6FB2F2072C for ; Thu, 19 Mar 2020 08:06:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="c50jPleC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6FB2F2072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEqC4-0001FQ-Ik for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Mar 2020 04:06:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39710) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEq7Y-0001gv-Ip for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEq7X-0005QB-Ei for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:40 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:51337) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEq7X-0005Nl-AE for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584604899; 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=hSzTUuBVSD20JGOao/BrW7RhITmYyNs/OHVV6V5t7OQ=; b=c50jPleCtEDhXN1/dqtFHcy7L7yISMY2XLJvtKDqDUffyCDZg11qZx2QvNFYLD0rrHodmc zsw6VWR/HZuSz5n8n8/v7UWeuSeMHf8ZIM5P2gL3gbWHaWPj+eW+Sd6D729i/D9N2tarCD vs2ZIXjWmQAWKGQXWmnBOpaUVhbjUJ0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-288-urE79ladNLuwxfbR1uXmUw-1; Thu, 19 Mar 2020 04:01:36 -0400 X-MC-Unique: urE79ladNLuwxfbR1uXmUw-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 83E6713EA; Thu, 19 Mar 2020 08:01:35 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B2AB196AE; Thu, 19 Mar 2020 08:01:28 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1167B3EC02; Thu, 19 Mar 2020 09:01:18 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 10/13] microvm/acpi: add rtc Date: Thu, 19 Mar 2020 09:01:14 +0100 Message-Id: <20200319080117.7725-11-kraxel@redhat.com> In-Reply-To: <20200319080117.7725-1-kraxel@redhat.com> References: <20200319080117.7725-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Sergio Lopez , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Gerd Hoffmann --- include/hw/i386/microvm.h | 3 +++ hw/i386/acpi-build.c | 3 +++ hw/i386/microvm.c | 5 ++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h index da2852a70195..53b2457db752 100644 --- a/include/hw/i386/microvm.h +++ b/include/hw/i386/microvm.h @@ -57,6 +57,9 @@ typedef struct { bool option_roms; bool auto_kernel_cmdline; + /* built-in devices */ + ISADevice *rtc_state; + /* Machine state */ bool kernel_cmdline_fixed; Notifier machine_done; diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 80844db24d6b..928e0ee2deeb 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2815,6 +2815,9 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *linker, build_dbg_aml(dsdt); sb_scope = aml_scope("_SB"); + if (mms->rtc_state) { + aml_append(sb_scope, build_rtc_device_aml()); + } acpi_dsdt_add_fw_cfg(sb_scope, OBJECT(x86ms->fw_cfg)); acpi_dsdt_add_virtio(sb_scope); aml_append(dsdt, sb_scope); diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index fd753764fc10..748f9826fb0e 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -101,7 +101,6 @@ static void microvm_devices_init(MicrovmMachineState *mms) { X86MachineState *x86ms = X86_MACHINE(mms); ISABus *isa_bus; - ISADevice *rtc_state; GSIState *gsi_state; int i; @@ -155,8 +154,8 @@ static void microvm_devices_init(MicrovmMachineState *mms) if (mms->rtc == ON_OFF_AUTO_ON || (mms->rtc == ON_OFF_AUTO_AUTO && !kvm_enabled())) { - rtc_state = mc146818_rtc_init(isa_bus, 2000, NULL); - microvm_set_rtc(mms, rtc_state); + mms->rtc_state = mc146818_rtc_init(isa_bus, 2000, NULL); + microvm_set_rtc(mms, mms->rtc_state); } if (mms->isa_serial) { From patchwork Thu Mar 19 08:01:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 11446679 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 447BF17E6 for ; Thu, 19 Mar 2020 08:04:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1B30A2072C for ; Thu, 19 Mar 2020 08:04:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KktBBEvN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B30A2072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEqAQ-0006aL-6j for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Mar 2020 04:04:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39759) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEq7e-0001kV-BL for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEq7Y-0005Xk-Rc for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:42 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:38905) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEq7Y-0005Ug-Mf for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584604900; 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=OFA+B2NRdiftPIIZGM8KNaGgqaNO6iGHD6YJngzvo54=; b=KktBBEvNG+P6XYmCzZFu6OtpIDp/E8z1NzVVXo+APYyAt9EBbJAUtvoTLKLuis7JyGFiS/ IlVTjNHUGTUgV2MUsFScTCgW2A1BK5Da11Gsj7QWSQIooy7l+FZ1sitMMcgxzZMoOVB7XJ 9wsrJfWN1UIeRapHMbR9Vi3YcdeAfsk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-126-ZebcUN-8PfSkJJch1HQUJA-1; Thu, 19 Mar 2020 04:01:38 -0400 X-MC-Unique: ZebcUN-8PfSkJJch1HQUJA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E4CD107ACC9; Thu, 19 Mar 2020 08:01:37 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF81160BF1; Thu, 19 Mar 2020 08:01:28 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1A23F3EC09; Thu, 19 Mar 2020 09:01:18 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 11/13] microvm/acpi: add serial Date: Thu, 19 Mar 2020 09:01:15 +0100 Message-Id: <20200319080117.7725-12-kraxel@redhat.com> In-Reply-To: <20200319080117.7725-1-kraxel@redhat.com> References: <20200319080117.7725-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Sergio Lopez , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Gerd Hoffmann --- hw/i386/acpi-build.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 928e0ee2deeb..b765c31c80b0 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1226,7 +1226,7 @@ static Aml *build_lpt_device_aml(void) return dev; } -static Aml *build_com_device_aml(uint8_t uid) +static Aml *build_com_device_aml(uint8_t uid, bool sta) { Aml *dev; Aml *crs; @@ -1250,19 +1250,22 @@ static Aml *build_com_device_aml(uint8_t uid) aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0501"))); aml_append(dev, aml_name_decl("_UID", aml_int(uid))); - method = aml_method("_STA", 0, AML_NOTSERIALIZED); - aml_append(method, aml_store(aml_name("%s", enabled_field), is_present)); - if_ctx = aml_if(aml_equal(is_present, zero)); - { - aml_append(if_ctx, aml_return(aml_int(0x00))); + if (sta) { + method = aml_method("_STA", 0, AML_NOTSERIALIZED); + aml_append(method, aml_store(aml_name("%s", enabled_field), + is_present)); + if_ctx = aml_if(aml_equal(is_present, zero)); + { + aml_append(if_ctx, aml_return(aml_int(0x00))); + } + aml_append(method, if_ctx); + else_ctx = aml_else(); + { + aml_append(else_ctx, aml_return(aml_int(0x0f))); + } + aml_append(method, else_ctx); + aml_append(dev, method); } - aml_append(method, if_ctx); - else_ctx = aml_else(); - { - aml_append(else_ctx, aml_return(aml_int(0x0f))); - } - aml_append(method, else_ctx); - aml_append(dev, method); crs = aml_resource_template(); aml_append(crs, aml_io(AML_DECODE16, io_port, io_port, 0x00, 0x08)); @@ -1287,8 +1290,8 @@ static void build_isa_devices_aml(Aml *table) aml_append(scope, build_fdc_device_aml(fdc)); } aml_append(scope, build_lpt_device_aml()); - aml_append(scope, build_com_device_aml(1)); - aml_append(scope, build_com_device_aml(2)); + aml_append(scope, build_com_device_aml(1, true)); + aml_append(scope, build_com_device_aml(2, true)); if (ambiguous) { error_report("Multiple ISA busses, unable to define IPMI ACPI data"); @@ -2818,6 +2821,9 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *linker, if (mms->rtc_state) { aml_append(sb_scope, build_rtc_device_aml()); } + if (mms->isa_serial) { + aml_append(sb_scope, build_com_device_aml(1, false)); + } acpi_dsdt_add_fw_cfg(sb_scope, OBJECT(x86ms->fw_cfg)); acpi_dsdt_add_virtio(sb_scope); aml_append(dsdt, sb_scope); From patchwork Thu Mar 19 08:01:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 11446677 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0257613B1 for ; Thu, 19 Mar 2020 08:04:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CB71F2072C for ; Thu, 19 Mar 2020 08:04:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="L+VxWOUk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB71F2072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEqAP-0006ZI-VM for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Mar 2020 04:04:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39666) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEq7U-0001Vy-43 for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEq7S-00050n-R2 for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:36 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:21029) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEq7S-00050g-Mo for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584604894; 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=ERu4o6ZtMX3qssJlFkElPsXEJtkE7CGsEmZCw3MKIR4=; b=L+VxWOUkUOeuw8R8HiWyd94qX9zcqnz6rbFV9k88PJ59c5Q1bZc4tTwwjMy93Uc3q4vY6J HZI59+3j9+sricSZAVtN4A+gWDDVmLZ04dYU5I8iQP1gXxcLFFGHHdAyl4LJZm8OKH0xZF vetcvnV1dsddKZehr2U67SKRkkQGnZ4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-233-t0URfHqHMJeOEFEvVNv_YA-1; Thu, 19 Mar 2020 04:01:32 -0400 X-MC-Unique: t0URfHqHMJeOEFEvVNv_YA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 53136107B765; Thu, 19 Mar 2020 08:01:31 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8B701001938; Thu, 19 Mar 2020 08:01:30 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 265AA3EC0A; Thu, 19 Mar 2020 09:01:18 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 12/13] microvm: make virtio irq base runtime configurable Date: Thu, 19 Mar 2020 09:01:16 +0100 Message-Id: <20200319080117.7725-13-kraxel@redhat.com> In-Reply-To: <20200319080117.7725-1-kraxel@redhat.com> References: <20200319080117.7725-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Sergio Lopez , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Gerd Hoffmann --- include/hw/i386/microvm.h | 2 +- hw/i386/acpi-build.c | 6 +++--- hw/i386/microvm.c | 11 +++++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h index 53b2457db752..87828325ec32 100644 --- a/include/hw/i386/microvm.h +++ b/include/hw/i386/microvm.h @@ -28,7 +28,6 @@ /* Platform virtio definitions */ #define VIRTIO_MMIO_BASE 0xc0000000 -#define VIRTIO_IRQ_BASE 5 #define VIRTIO_NUM_TRANSPORTS 8 #define VIRTIO_CMDLINE_MAXLEN 64 @@ -61,6 +60,7 @@ typedef struct { ISADevice *rtc_state; /* Machine state */ + uint32_t virtio_irq_base; bool kernel_cmdline_fixed; Notifier machine_done; AcpiDeviceIf *acpi_dev; diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index b765c31c80b0..9bddeb77704d 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2755,7 +2755,7 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) return true; } -static void acpi_dsdt_add_virtio(Aml *scope) +static void acpi_dsdt_add_virtio(Aml *scope, MicrovmMachineState *mms) { gchar *separator; long int index; @@ -2783,7 +2783,7 @@ static void acpi_dsdt_add_virtio(Aml *scope) continue; } - uint32_t irq = VIRTIO_IRQ_BASE + index; + uint32_t irq = mms->virtio_irq_base + index; hwaddr base = VIRTIO_MMIO_BASE + index * 512; hwaddr size = 512; @@ -2825,7 +2825,7 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *linker, aml_append(sb_scope, build_com_device_aml(1, false)); } acpi_dsdt_add_fw_cfg(sb_scope, OBJECT(x86ms->fw_cfg)); - acpi_dsdt_add_virtio(sb_scope); + acpi_dsdt_add_virtio(sb_scope, mms); aml_append(dsdt, sb_scope); scope = aml_scope("\\"); diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index 748f9826fb0e..834b10aee0a2 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -122,10 +122,11 @@ static void microvm_devices_init(MicrovmMachineState *mms) kvmclock_create(); + mms->virtio_irq_base = 8; for (i = 0; i < VIRTIO_NUM_TRANSPORTS; i++) { sysbus_create_simple("virtio-mmio", VIRTIO_MMIO_BASE + i * 512, - x86ms->gsi[VIRTIO_IRQ_BASE + i]); + x86ms->gsi[mms->virtio_irq_base + i]); } /* Optional and legacy devices */ @@ -265,7 +266,7 @@ static void microvm_memory_init(MicrovmMachineState *mms) x86ms->ioapic_as = &address_space_memory; } -static gchar *microvm_get_mmio_cmdline(gchar *name) +static gchar *microvm_get_mmio_cmdline(gchar *name, uint32_t virtio_irq_base) { gchar *cmdline; gchar *separator; @@ -285,7 +286,7 @@ static gchar *microvm_get_mmio_cmdline(gchar *name) ret = g_snprintf(cmdline, VIRTIO_CMDLINE_MAXLEN, " virtio_mmio.device=512@0x%lx:%ld", VIRTIO_MMIO_BASE + index * 512, - VIRTIO_IRQ_BASE + index); + virtio_irq_base + index); if (ret < 0 || ret >= VIRTIO_CMDLINE_MAXLEN) { g_free(cmdline); return NULL; @@ -297,6 +298,7 @@ static gchar *microvm_get_mmio_cmdline(gchar *name) static void microvm_fix_kernel_cmdline(MachineState *machine) { X86MachineState *x86ms = X86_MACHINE(machine); + MicrovmMachineState *mms = MICROVM_MACHINE(machine); BusState *bus; BusChild *kid; char *cmdline; @@ -320,7 +322,8 @@ static void microvm_fix_kernel_cmdline(MachineState *machine) BusState *mmio_bus = &mmio_virtio_bus->parent_obj; if (!QTAILQ_EMPTY(&mmio_bus->children)) { - gchar *mmio_cmdline = microvm_get_mmio_cmdline(mmio_bus->name); + gchar *mmio_cmdline = microvm_get_mmio_cmdline + (mmio_bus->name, mms->virtio_irq_base); if (mmio_cmdline) { char *newcmd = g_strjoin(NULL, cmdline, mmio_cmdline, NULL); g_free(mmio_cmdline); From patchwork Thu Mar 19 08:01:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 11446687 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 234D113B1 for ; Thu, 19 Mar 2020 08:07:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED4962072C for ; Thu, 19 Mar 2020 08:07:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ikTpvKwU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED4962072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEqCm-0002gn-3W for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Mar 2020 04:07:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39644) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEq7R-0001TR-NC for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEq7Q-0004tK-Js for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:33 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:36257) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEq7Q-0004sb-Gf for qemu-devel@nongnu.org; Thu, 19 Mar 2020 04:01:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584604892; 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=vsnWX1gIlwcFz9XB8Dcx8GS4744XFdzTMJ5wUPOnbtw=; b=ikTpvKwUwS09/C7t4XvLuCPDqO0vw8xlCFXmON4xqQPHeMr9Qng14tfDEdUaQds7vcXON+ yuXp6cQsgsJPEY6AKsSsRyBwVFSIQdYCGz4IkJwI0yyu9lNRnJZJNGo0pl6RBjPOS1jmM4 2EXfOgf4m7TZ7EFqV72z0b7SbP3E1XY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-59-0IyYCKUKP_2TRYyg05ZVzw-1; Thu, 19 Mar 2020 04:01:29 -0400 X-MC-Unique: 0IyYCKUKP_2TRYyg05ZVzw-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7BA3E18B9FC1; Thu, 19 Mar 2020 08:01:28 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2282817B91; Thu, 19 Mar 2020 08:01:28 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 378DC3EC0C; Thu, 19 Mar 2020 09:01:18 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 13/13] microvm/acpi: use GSI 16-23 for virtio Date: Thu, 19 Mar 2020 09:01:17 +0100 Message-Id: <20200319080117.7725-14-kraxel@redhat.com> In-Reply-To: <20200319080117.7725-1-kraxel@redhat.com> References: <20200319080117.7725-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-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Sergio Lopez , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" With ACPI enabled and IO-APIC being properly declared in the ACPI tables we can use interrupt lines 16-23 for virtio and avoid shared interrupts. With acpi disabled we continue to use lines 8-15. Signed-off-by: Gerd Hoffmann --- hw/i386/microvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index 834b10aee0a2..139181daed06 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -122,7 +122,7 @@ static void microvm_devices_init(MicrovmMachineState *mms) kvmclock_create(); - mms->virtio_irq_base = 8; + mms->virtio_irq_base = acpi_enabled ? 16 : 8; for (i = 0; i < VIRTIO_NUM_TRANSPORTS; i++) { sysbus_create_simple("virtio-mmio", VIRTIO_MMIO_BASE + i * 512,