From nobody Fri Dec 19 04:06:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588686296; cv=none; d=zohomail.com; s=zohoarc; b=N5cf4e+9EV/28Fcn/yKnMP1B3BqhGwJwKCnK53lrG0IPdfNOWihtmlLu6ffA4KZniMnfNSqMNzipc+kD5IbuiGQ6EeqZMDB3HTz0sX/Q58on8NPp1ZoZFQs8QpBlAnvJmr/K6s2MB19k0oo64fiQtIIiKkRnAUQYKAIq7/1ZFig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588686296; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3S4CcNfxGiDO+YX52LuTWfias0eECPmaL1FBHvD3tvM=; b=CJp4IlpisQl099DyTsnQnk1pmbSuPTV7fJD0/ldwd5FgKEjYGbV8JDnVYHJMTwlaLXwC3YppAgtPL9svRoiModFsneDAZfferX9idkmLNmW7gvdmZGI8UiHVIdW+civsCk9A79N5Ok2DuozoEyhp5cStBXdozonqeiuCZziXkRw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588686296570805.4374414714262; Tue, 5 May 2020 06:44:56 -0700 (PDT) Received: from localhost ([::1]:41540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVxsT-0002vA-VZ for importer@patchew.org; Tue, 05 May 2020 09:44:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxqz-0000Jc-LC for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:22 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:23773 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jVxqx-0003Oc-Q4 for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:20 -0400 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-356-d0h0Fq2MPnaN9d9IhtRj3g-1; Tue, 05 May 2020 09:43:16 -0400 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 A2913A0C0C; Tue, 5 May 2020 13:43:15 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-113-193.ams2.redhat.com [10.36.113.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7EBC10013D9; Tue, 5 May 2020 13:43:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id BEAC917511; Tue, 5 May 2020 15:43:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588686198; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3S4CcNfxGiDO+YX52LuTWfias0eECPmaL1FBHvD3tvM=; b=dEmcVMvS/n5berzGmvfHA+1yAAr3fqcV+T+YpFVJ/iAq1yrjvlLvLx8/lOSW5FR7MbeDL5 OYjjyh9GmLCdYanOj3P/++ghTXDS5nbiurpoYBMYj+Qs+tHUllZI45MRrnpwOHVQO/IeT1 68PYjsoO5kXlLL7Wg5JeyYAqG5sQb3g= X-MC-Unique: d0h0Fq2MPnaN9d9IhtRj3g-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH v2 01/13] acpi: make build_madt() more generic. Date: Tue, 5 May 2020 15:42:53 +0200 Message-Id: <20200505134305.22666-2-kraxel@redhat.com> In-Reply-To: <20200505134305.22666-1-kraxel@redhat.com> References: <20200505134305.22666-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/05 00:37:40 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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=C3=A9 Reviewed-by: Igor Mammedov --- 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 765409a90eb6..fe60c10201ad 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -366,14 +366,13 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, } =20 static void -build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) +build_madt(GArray *table_data, BIOSLinker *linker, + X86MachineState *x86ms, AcpiDeviceIf *adev) { - MachineClass *mc =3D MACHINE_GET_CLASS(pcms); - X86MachineState *x86ms =3D X86_MACHINE(pcms); - const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(MACHINE(pc= ms)); + MachineClass *mc =3D MACHINE_GET_CLASS(x86ms); + const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(MACHINE(x8= 6ms)); int madt_start =3D table_data->len; - AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_GET_CLASS(pcms->acpi_dev); - AcpiDeviceIf *adev =3D ACPI_DEVICE_IF(pcms->acpi_dev); + AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_GET_CLASS(adev); bool x2apic_mode =3D false; =20 AcpiMultipleApicTable *madt; @@ -2561,7 +2560,8 @@ void acpi_build(AcpiBuildTables *tables, MachineState= *machine) aml_len +=3D tables_blob->len - fadt; =20 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)); =20 vmgenid_dev =3D find_vmgenid_dev(); if (vmgenid_dev) { --=20 2.18.4 From nobody Fri Dec 19 04:06:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588686310; cv=none; d=zohomail.com; s=zohoarc; b=B2VyXDzCpXBko9Xj5PUH2cfF/q4aMCYIqS3Rs/99fvFeNi0C5MqLL4Qzf1iAT+DjzPss81kQf2w4BOpuFA035dlMImBrv9XuuVB2+jdjdIEJF/FORWCkB3RchD2PqKp8lLfYqFE26b/Cx0PdlCzS27G/XRTAW2Sai0lcfb0gxpU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588686310; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Z+8vYWRPNFpT+GFFZ9x5AWvcRYkBU84xKK6ADmm3SfM=; b=Y8Pvacr55npm0jdtnGVDYxaUUE7w9MSV5dVFP5nW/8f0EE8q1yhuV4yTP8261jqjQy4/tXuvk2znztZjmD7pdYerbnNujiSmChZVebPAiM+yyI0MZKbwHnmQsP2cMTABU6IsLiOusguyF2rbFJGwuNpIyoNQCL+sRnsSYpdRKNQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588686310704747.0399732119723; Tue, 5 May 2020 06:45:10 -0700 (PDT) Received: from localhost ([::1]:41890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVxsj-00033t-Bn for importer@patchew.org; Tue, 05 May 2020 09:45:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxr2-0000L4-Si for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:24 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:54896 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jVxqz-0003Op-BL for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:23 -0400 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-510-Elwx541eOzOThj7B5VDgXg-1; Tue, 05 May 2020 09:43:16 -0400 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 CBCE3A0C00; Tue, 5 May 2020 13:43:15 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-113-193.ams2.redhat.com [10.36.113.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCFCF5D785; Tue, 5 May 2020 13:43:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id CE0CF17516; Tue, 5 May 2020 15:43:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588686200; 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=Z+8vYWRPNFpT+GFFZ9x5AWvcRYkBU84xKK6ADmm3SfM=; b=VMqqbo4qYI8/W51EaozzG7o6KovQXs3WI612vbbI0SMlaTLT3LyyxHtUdxS9OtcZ7w9ECb sc2v9RSjGz04Zsv2mlJ6UOZdh3El8BfO+JI8u+DL94PTOtncRrW9x2zxOBHqtS5K6H2hnI XXbgfwcjCcfeyqDjqmmONHIZGe6ScXY= X-MC-Unique: Elwx541eOzOThj7B5VDgXg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH v2 02/13] acpi: create acpi-common.c and move madt code Date: Tue, 5 May 2020 15:42:54 +0200 Message-Id: <20200505134305.22666-3-kraxel@redhat.com> In-Reply-To: <20200505134305.22666-1-kraxel@redhat.com> References: <20200505134305.22666-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/05 00:37:40 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Gerd Hoffmann Reviewed-by: Igor Mammedov --- hw/i386/acpi-common.h | 14 ++++ hw/i386/acpi-build.c | 126 +--------------------------------- hw/i386/acpi-common.c | 152 ++++++++++++++++++++++++++++++++++++++++++ hw/i386/Makefile.objs | 1 + 4 files changed, 170 insertions(+), 123 deletions(-) create mode 100644 hw/i386/acpi-common.h create mode 100644 hw/i386/acpi-common.c diff --git a/hw/i386/acpi-common.h b/hw/i386/acpi-common.h new file mode 100644 index 000000000000..c30e461f1854 --- /dev/null +++ b/hw/i386/acpi-common.h @@ -0,0 +1,14 @@ +#ifndef HW_I386_ACPI_COMMON_H +#define HW_I386_ACPI_COMMON_H +#include "include/hw/acpi/acpi_dev_interface.h" + +#include "include/hw/acpi/bios-linker-loader.h" +#include "include/hw/i386/x86.h" + +/* Default IOAPIC ID */ +#define ACPI_BUILD_IOAPIC_ID 0x0 + +void acpi_build_madt(GArray *table_data, BIOSLinker *linker, + X86MachineState *x86ms, AcpiDeviceIf *adev); + +#endif diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index fe60c10201ad..eb530e5cd56d 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -24,6 +24,7 @@ #include "qapi/error.h" #include "qapi/qmp/qnum.h" #include "acpi-build.h" +#include "acpi-common.h" #include "qemu/bitmap.h" #include "qemu/error-report.h" #include "hw/pci/pci.h" @@ -89,9 +90,6 @@ #define ACPI_BUILD_DPRINTF(fmt, ...) #endif =20 -/* Default IOAPIC ID */ -#define ACPI_BUILD_IOAPIC_ID 0x0 - typedef struct AcpiPmInfo { bool s3_disabled; bool s4_disabled; @@ -327,124 +325,6 @@ build_facs(GArray *table_data) facs->length =3D cpu_to_le32(sizeof(*facs)); } =20 -void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, - const CPUArchIdList *apic_ids, GArray *entry) -{ - uint32_t apic_id =3D apic_ids->cpus[uid].arch_id; - - /* ACPI spec says that LAPIC entry for non present - * CPU may be omitted from MADT or it must be marked - * as disabled. However omitting non present CPU from - * MADT breaks hotplug on linux. So possible CPUs - * should be put in MADT but kept disabled. - */ - if (apic_id < 255) { - AcpiMadtProcessorApic *apic =3D acpi_data_push(entry, sizeof *apic= ); - - apic->type =3D ACPI_APIC_PROCESSOR; - apic->length =3D sizeof(*apic); - apic->processor_id =3D uid; - apic->local_apic_id =3D apic_id; - if (apic_ids->cpus[uid].cpu !=3D NULL) { - apic->flags =3D cpu_to_le32(1); - } else { - apic->flags =3D cpu_to_le32(0); - } - } else { - AcpiMadtProcessorX2Apic *apic =3D acpi_data_push(entry, sizeof *ap= ic); - - apic->type =3D ACPI_APIC_LOCAL_X2APIC; - apic->length =3D sizeof(*apic); - apic->uid =3D cpu_to_le32(uid); - apic->x2apic_id =3D cpu_to_le32(apic_id); - if (apic_ids->cpus[uid].cpu !=3D NULL) { - apic->flags =3D cpu_to_le32(1); - } else { - apic->flags =3D cpu_to_le32(0); - } - } -} - -static void -build_madt(GArray *table_data, BIOSLinker *linker, - X86MachineState *x86ms, AcpiDeviceIf *adev) -{ - MachineClass *mc =3D MACHINE_GET_CLASS(x86ms); - const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(MACHINE(x8= 6ms)); - int madt_start =3D table_data->len; - AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_GET_CLASS(adev); - bool x2apic_mode =3D false; - - AcpiMultipleApicTable *madt; - AcpiMadtIoApic *io_apic; - AcpiMadtIntsrcovr *intsrcovr; - int i; - - madt =3D acpi_data_push(table_data, sizeof *madt); - madt->local_apic_address =3D cpu_to_le32(APIC_DEFAULT_ADDRESS); - madt->flags =3D cpu_to_le32(1); - - for (i =3D 0; i < apic_ids->len; i++) { - adevc->madt_cpu(adev, i, apic_ids, table_data); - if (apic_ids->cpus[i].arch_id > 254) { - x2apic_mode =3D true; - } - } - - io_apic =3D acpi_data_push(table_data, sizeof *io_apic); - io_apic->type =3D ACPI_APIC_IO; - io_apic->length =3D sizeof(*io_apic); - io_apic->io_apic_id =3D ACPI_BUILD_IOAPIC_ID; - io_apic->address =3D cpu_to_le32(IO_APIC_DEFAULT_ADDRESS); - io_apic->interrupt =3D cpu_to_le32(0); - - if (x86ms->apic_xrupt_override) { - intsrcovr =3D acpi_data_push(table_data, sizeof *intsrcovr); - intsrcovr->type =3D ACPI_APIC_XRUPT_OVERRIDE; - intsrcovr->length =3D sizeof(*intsrcovr); - intsrcovr->source =3D 0; - intsrcovr->gsi =3D cpu_to_le32(2); - intsrcovr->flags =3D cpu_to_le16(0); /* conforms to bus specifica= tions */ - } - for (i =3D 1; i < 16; i++) { -#define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11)) - if (!(ACPI_BUILD_PCI_IRQS & (1 << i))) { - /* No need for a INT source override structure. */ - continue; - } - intsrcovr =3D acpi_data_push(table_data, sizeof *intsrcovr); - intsrcovr->type =3D ACPI_APIC_XRUPT_OVERRIDE; - intsrcovr->length =3D sizeof(*intsrcovr); - intsrcovr->source =3D i; - intsrcovr->gsi =3D cpu_to_le32(i); - intsrcovr->flags =3D cpu_to_le16(0xd); /* active high, level trig= gered */ - } - - if (x2apic_mode) { - AcpiMadtLocalX2ApicNmi *local_nmi; - - local_nmi =3D acpi_data_push(table_data, sizeof *local_nmi); - local_nmi->type =3D ACPI_APIC_LOCAL_X2APIC_NMI; - local_nmi->length =3D sizeof(*local_nmi); - local_nmi->uid =3D 0xFFFFFFFF; /* all processors */ - local_nmi->flags =3D cpu_to_le16(0); - local_nmi->lint =3D 1; /* ACPI_LINT1 */ - } else { - AcpiMadtLocalNmi *local_nmi; - - local_nmi =3D acpi_data_push(table_data, sizeof *local_nmi); - local_nmi->type =3D ACPI_APIC_LOCAL_NMI; - local_nmi->length =3D sizeof(*local_nmi); - local_nmi->processor_id =3D 0xff; /* all processors */ - local_nmi->flags =3D cpu_to_le16(0); - local_nmi->lint =3D 1; /* ACPI_LINT1 */ - } - - build_header(linker, table_data, - (void *)(table_data->data + madt_start), "APIC", - table_data->len - madt_start, 1, NULL, NULL); -} - static void build_append_pcihp_notify_entry(Aml *method, int slot) { Aml *if_ctx; @@ -2560,8 +2440,8 @@ void acpi_build(AcpiBuildTables *tables, MachineState= *machine) aml_len +=3D tables_blob->len - fadt; =20 acpi_add_table(table_offsets, tables_blob); - build_madt(tables_blob, tables->linker, x86ms, - ACPI_DEVICE_IF(pcms->acpi_dev)); + acpi_build_madt(tables_blob, tables->linker, x86ms, + ACPI_DEVICE_IF(pcms->acpi_dev)); =20 vmgenid_dev =3D find_vmgenid_dev(); if (vmgenid_dev) { diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c new file mode 100644 index 000000000000..5caca16a0b59 --- /dev/null +++ b/hw/i386/acpi-common.c @@ -0,0 +1,152 @@ +/* Support for generating ACPI tables and passing them to Guests + * + * Copyright (C) 2008-2010 Kevin O'Connor + * Copyright (C) 2006 Fabrice Bellard + * Copyright (C) 2013 Red Hat Inc + * + * Author: Michael S. Tsirkin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" + +#include "exec/memory.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/utils.h" +#include "hw/i386/pc.h" +#include "target/i386/cpu.h" + +#include "acpi-build.h" +#include "acpi-common.h" + +void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, + const CPUArchIdList *apic_ids, GArray *entry) +{ + uint32_t apic_id =3D apic_ids->cpus[uid].arch_id; + + /* ACPI spec says that LAPIC entry for non present + * CPU may be omitted from MADT or it must be marked + * as disabled. However omitting non present CPU from + * MADT breaks hotplug on linux. So possible CPUs + * should be put in MADT but kept disabled. + */ + if (apic_id < 255) { + AcpiMadtProcessorApic *apic =3D acpi_data_push(entry, sizeof *apic= ); + + apic->type =3D ACPI_APIC_PROCESSOR; + apic->length =3D sizeof(*apic); + apic->processor_id =3D uid; + apic->local_apic_id =3D apic_id; + if (apic_ids->cpus[uid].cpu !=3D NULL) { + apic->flags =3D cpu_to_le32(1); + } else { + apic->flags =3D cpu_to_le32(0); + } + } else { + AcpiMadtProcessorX2Apic *apic =3D acpi_data_push(entry, sizeof *ap= ic); + + apic->type =3D ACPI_APIC_LOCAL_X2APIC; + apic->length =3D sizeof(*apic); + apic->uid =3D cpu_to_le32(uid); + apic->x2apic_id =3D cpu_to_le32(apic_id); + if (apic_ids->cpus[uid].cpu !=3D NULL) { + apic->flags =3D cpu_to_le32(1); + } else { + apic->flags =3D cpu_to_le32(0); + } + } +} + +void acpi_build_madt(GArray *table_data, BIOSLinker *linker, + X86MachineState *x86ms, AcpiDeviceIf *adev) +{ + MachineClass *mc =3D MACHINE_GET_CLASS(x86ms); + const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(MACHINE(x8= 6ms)); + int madt_start =3D table_data->len; + AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_GET_CLASS(adev); + bool x2apic_mode =3D false; + + AcpiMultipleApicTable *madt; + AcpiMadtIoApic *io_apic; + AcpiMadtIntsrcovr *intsrcovr; + int i; + + madt =3D acpi_data_push(table_data, sizeof *madt); + madt->local_apic_address =3D cpu_to_le32(APIC_DEFAULT_ADDRESS); + madt->flags =3D cpu_to_le32(1); + + for (i =3D 0; i < apic_ids->len; i++) { + adevc->madt_cpu(adev, i, apic_ids, table_data); + if (apic_ids->cpus[i].arch_id > 254) { + x2apic_mode =3D true; + } + } + + io_apic =3D acpi_data_push(table_data, sizeof *io_apic); + io_apic->type =3D ACPI_APIC_IO; + io_apic->length =3D sizeof(*io_apic); + io_apic->io_apic_id =3D ACPI_BUILD_IOAPIC_ID; + io_apic->address =3D cpu_to_le32(IO_APIC_DEFAULT_ADDRESS); + io_apic->interrupt =3D cpu_to_le32(0); + + if (x86ms->apic_xrupt_override) { + intsrcovr =3D acpi_data_push(table_data, sizeof *intsrcovr); + intsrcovr->type =3D ACPI_APIC_XRUPT_OVERRIDE; + intsrcovr->length =3D sizeof(*intsrcovr); + intsrcovr->source =3D 0; + intsrcovr->gsi =3D cpu_to_le32(2); + intsrcovr->flags =3D cpu_to_le16(0); /* conforms to bus specifica= tions */ + } + for (i =3D 1; i < 16; i++) { +#define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11)) + if (!(ACPI_BUILD_PCI_IRQS & (1 << i))) { + /* No need for a INT source override structure. */ + continue; + } + intsrcovr =3D acpi_data_push(table_data, sizeof *intsrcovr); + intsrcovr->type =3D ACPI_APIC_XRUPT_OVERRIDE; + intsrcovr->length =3D sizeof(*intsrcovr); + intsrcovr->source =3D i; + intsrcovr->gsi =3D cpu_to_le32(i); + intsrcovr->flags =3D cpu_to_le16(0xd); /* active high, level trig= gered */ + } + + if (x2apic_mode) { + AcpiMadtLocalX2ApicNmi *local_nmi; + + local_nmi =3D acpi_data_push(table_data, sizeof *local_nmi); + local_nmi->type =3D ACPI_APIC_LOCAL_X2APIC_NMI; + local_nmi->length =3D sizeof(*local_nmi); + local_nmi->uid =3D 0xFFFFFFFF; /* all processors */ + local_nmi->flags =3D cpu_to_le16(0); + local_nmi->lint =3D 1; /* ACPI_LINT1 */ + } else { + AcpiMadtLocalNmi *local_nmi; + + local_nmi =3D acpi_data_push(table_data, sizeof *local_nmi); + local_nmi->type =3D ACPI_APIC_LOCAL_NMI; + local_nmi->length =3D sizeof(*local_nmi); + local_nmi->processor_id =3D 0xff; /* all processors */ + local_nmi->flags =3D cpu_to_le16(0); + local_nmi->lint =3D 1; /* ACPI_LINT1 */ + } + + build_header(linker, table_data, + (void *)(table_data->data + madt_start), "APIC", + table_data->len - madt_start, 1, NULL, NULL); +} + diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs index 8ce1b265335b..6abc74551a72 100644 --- a/hw/i386/Makefile.objs +++ b/hw/i386/Makefile.objs @@ -16,4 +16,5 @@ obj-$(CONFIG_VMMOUSE) +=3D vmmouse.o obj-$(CONFIG_PC) +=3D port92.o =20 obj-y +=3D kvmvapic.o +obj-$(CONFIG_ACPI) +=3D acpi-common.o obj-$(CONFIG_PC) +=3D acpi-build.o --=20 2.18.4 From nobody Fri Dec 19 04:06:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588686453; cv=none; d=zohomail.com; s=zohoarc; b=ZbUm1OOkFUYoX2ZMvpEu2BlmUo5OWzzCq2ZWHElc6au4nahbTJDTjxRRuahJ1QIZIPmogQCKQu7DT2VKOvDplvfY2fcQGdD4+CR8r7dpTrlZ0sdFmPlbt8KaR7fZU/+2uIITLx3z7+dXi3jWL24QEmEGkNVcKY14xxZ4mk8eYKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588686453; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=AkzOmJ453aBGs+rRX72gsPbaw2iO6z3DgUXBGV9tl0M=; b=c/MDfTa3xNg58u9/4ZonIQzW6AYD3qrWESZXLwsM0HrFW5NoxWYX7OpsaC1CvmPXakseL3Ln6nF5U6j03UTvZYXk2MV5s/qQRoPIfrsPZn+tlI6+tLqskDnSm4orZAPXC5I8I1MuOlndM4krCeUXpfjIWpNzBuCG1fySWENhM1w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588686453966507.40208718129406; Tue, 5 May 2020 06:47:33 -0700 (PDT) Received: from localhost ([::1]:50130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVxv2-0006Rh-Lh for importer@patchew.org; Tue, 05 May 2020 09:47:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxr4-0000Nh-0q for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:26 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:53737 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jVxr1-0003T1-3q for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:25 -0400 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-4-ORMOH5CuOTW8CFN82yLycg-1; Tue, 05 May 2020 09:43:18 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 68241461; Tue, 5 May 2020 13:43:17 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-113-193.ams2.redhat.com [10.36.113.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC9BA5D9D5; Tue, 5 May 2020 13:43:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D9FF317532; Tue, 5 May 2020 15:43:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588686202; 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=AkzOmJ453aBGs+rRX72gsPbaw2iO6z3DgUXBGV9tl0M=; b=AJRT//PerhQCufEqzRbvx0hFvFjcptxOmlQCTeeqlXF9L+6lrw9I1vJLI5DNt1DGBOm7Mq KgA9k5OJ2nLiDtFPUkyQySfYi4vaA/uFVmJYdA0W0nWYi1hRYbv64famjzYbNZmhD+GrMU EvGLndBbFbvVAdYmN9GvQKA6tulaOdk= X-MC-Unique: ORMOH5CuOTW8CFN82yLycg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH v2 03/13] acpi: madt: skip pci override on pci-less systems (microvm) Date: Tue, 5 May 2020 15:42:55 +0200 Message-Id: <20200505134305.22666-4-kraxel@redhat.com> In-Reply-To: <20200505134305.22666-1-kraxel@redhat.com> References: <20200505134305.22666-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kraxel@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/05 03:48:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Gerd Hoffmann Reviewed-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/acpi-common.h | 3 ++- hw/i386/acpi-build.c | 2 +- hw/i386/acpi-common.c | 26 +++++++++++++++----------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/hw/i386/acpi-common.h b/hw/i386/acpi-common.h index c30e461f1854..9cac18dddf5b 100644 --- a/hw/i386/acpi-common.h +++ b/hw/i386/acpi-common.h @@ -9,6 +9,7 @@ #define ACPI_BUILD_IOAPIC_ID 0x0 =20 void acpi_build_madt(GArray *table_data, BIOSLinker *linker, - X86MachineState *x86ms, AcpiDeviceIf *adev); + X86MachineState *x86ms, AcpiDeviceIf *adev, + bool has_pci); =20 #endif diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index eb530e5cd56d..4cce2192eeb0 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2441,7 +2441,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState= *machine) =20 acpi_add_table(table_offsets, tables_blob); acpi_build_madt(tables_blob, tables->linker, x86ms, - ACPI_DEVICE_IF(pcms->acpi_dev)); + ACPI_DEVICE_IF(pcms->acpi_dev), true); =20 vmgenid_dev =3D find_vmgenid_dev(); if (vmgenid_dev) { diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c index 5caca16a0b59..ab9b00581a15 100644 --- a/hw/i386/acpi-common.c +++ b/hw/i386/acpi-common.c @@ -72,7 +72,8 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, } =20 void acpi_build_madt(GArray *table_data, BIOSLinker *linker, - X86MachineState *x86ms, AcpiDeviceIf *adev) + X86MachineState *x86ms, AcpiDeviceIf *adev, + bool has_pci) { MachineClass *mc =3D MACHINE_GET_CLASS(x86ms); const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(MACHINE(x8= 6ms)); @@ -111,18 +112,21 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *= linker, intsrcovr->gsi =3D cpu_to_le32(2); intsrcovr->flags =3D cpu_to_le16(0); /* conforms to bus specifica= tions */ } - for (i =3D 1; i < 16; i++) { + + if (has_pci) { + for (i =3D 1; i < 16; i++) { #define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11)) - if (!(ACPI_BUILD_PCI_IRQS & (1 << i))) { - /* No need for a INT source override structure. */ - continue; + if (!(ACPI_BUILD_PCI_IRQS & (1 << i))) { + /* No need for a INT source override structure. */ + continue; + } + intsrcovr =3D acpi_data_push(table_data, sizeof *intsrcovr); + intsrcovr->type =3D ACPI_APIC_XRUPT_OVERRIDE; + intsrcovr->length =3D sizeof(*intsrcovr); + intsrcovr->source =3D i; + intsrcovr->gsi =3D cpu_to_le32(i); + intsrcovr->flags =3D cpu_to_le16(0xd); /* active high, level = triggered */ } - intsrcovr =3D acpi_data_push(table_data, sizeof *intsrcovr); - intsrcovr->type =3D ACPI_APIC_XRUPT_OVERRIDE; - intsrcovr->length =3D sizeof(*intsrcovr); - intsrcovr->source =3D i; - intsrcovr->gsi =3D cpu_to_le32(i); - intsrcovr->flags =3D cpu_to_le16(0xd); /* active high, level trig= gered */ } =20 if (x2apic_mode) { --=20 2.18.4 From nobody Fri Dec 19 04:06:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588686453; cv=none; d=zohomail.com; s=zohoarc; b=l3q9iMzuuIOFPQvY+SGypma3ZO3/K169RfbvWhioFRZMM9Maa+G7Rtj0/Jn85kI3AOYXyqDGJx35/FKEsKRx1VXq6GmAspJSv2KfXtV4ufUcVF1pCk7PNtOYkfRPFMZwx/+j/skdRFKATOUdkpV2ChkrnEqfCm9rUPZofsGWJYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588686453; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=qXxalZZXQ2q+1+XiKHCDl61UcTAWRsLeGI8ZX/xQFVI=; b=cex7qQf11DajtOpkdNxZP+L4AR6wo0IwsE/d5Ue2t89HgN21FIZqena3eHyGs+NXd/btmfnteVcf4Q9A0t3Gjsdv0w1sCpa1c/yYZLEQ2+6F+2xNJJmHoIIIBjeXWAlrzrCNQ0cOtlHJS2XqPSqdivmuySITQfcS6xQeMOTHD9w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588686453379354.82949735667; Tue, 5 May 2020 06:47:33 -0700 (PDT) Received: from localhost ([::1]:50030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVxv1-0006PE-RB for importer@patchew.org; Tue, 05 May 2020 09:47:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxr3-0000N7-PG for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:25 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:49865 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jVxr2-0003Vn-QB for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:25 -0400 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-434-Nwr3RYIWMriveId7IHLwzg-1; Tue, 05 May 2020 09:43:19 -0400 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 2BA3E8014C1; Tue, 5 May 2020 13:43:18 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-113-193.ams2.redhat.com [10.36.113.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id E20A263F95; Tue, 5 May 2020 13:43:09 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E5F1C1753B; Tue, 5 May 2020 15:43:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588686202; 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=qXxalZZXQ2q+1+XiKHCDl61UcTAWRsLeGI8ZX/xQFVI=; b=LyCP1XUTtqtQP+P5qz8TCL/w3mYiGaWQKDKfpnjdhgc3h55iAGPfB4IOTNZe46SpEFa89s G+KxWX4C60ILI6iF8a+Wj7IzhdVdEE/F1GpsOmdqxGDoMSd8CMsrusv9ASv8C76+kejp4E ip788UF4hj+BF1K8wLZHOz7r5DWwVto= X-MC-Unique: Nwr3RYIWMriveId7IHLwzg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH v2 04/13] acpi: move acpi_build_facs to acpi-common.c Date: Tue, 5 May 2020 15:42:56 +0200 Message-Id: <20200505134305.22666-5-kraxel@redhat.com> In-Reply-To: <20200505134305.22666-1-kraxel@redhat.com> References: <20200505134305.22666-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kraxel@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/05 03:48:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/acpi-common.h | 1 + hw/i386/acpi-build.c | 11 +---------- hw/i386/acpi-common.c | 7 +++++++ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/hw/i386/acpi-common.h b/hw/i386/acpi-common.h index 9cac18dddf5b..583c320bbe7d 100644 --- a/hw/i386/acpi-common.h +++ b/hw/i386/acpi-common.h @@ -11,5 +11,6 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *linker, X86MachineState *x86ms, AcpiDeviceIf *adev, bool has_pci); +void acpi_build_facs(GArray *table_data); =20 #endif diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 4cce2192eeb0..a69b85a266e7 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -316,15 +316,6 @@ static void acpi_align_size(GArray *blob, unsigned ali= gn) g_array_set_size(blob, ROUND_UP(acpi_data_len(blob), align)); } =20 -/* FACS */ -static void -build_facs(GArray *table_data) -{ - AcpiFacsDescriptorRev1 *facs =3D acpi_data_push(table_data, sizeof *fa= cs); - memcpy(&facs->signature, "FACS", 4); - facs->length =3D cpu_to_le32(sizeof(*facs)); -} - static void build_append_pcihp_notify_entry(Aml *method, int slot) { Aml *if_ctx; @@ -2417,7 +2408,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState= *machine) * requirements. */ facs =3D tables_blob->len; - build_facs(tables_blob); + acpi_build_facs(tables_blob); =20 /* DSDT is pointed to by FADT */ dsdt =3D tables_blob->len; diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c index ab9b00581a15..5187653893a8 100644 --- a/hw/i386/acpi-common.c +++ b/hw/i386/acpi-common.c @@ -154,3 +154,10 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *l= inker, table_data->len - madt_start, 1, NULL, NULL); } =20 +/* FACS */ +void acpi_build_facs(GArray *table_data) +{ + AcpiFacsDescriptorRev1 *facs =3D acpi_data_push(table_data, sizeof *fa= cs); + memcpy(&facs->signature, "FACS", 4); + facs->length =3D cpu_to_le32(sizeof(*facs)); +} --=20 2.18.4 From nobody Fri Dec 19 04:06:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588686788; cv=none; d=zohomail.com; s=zohoarc; b=nGpicXVlHv5nGpXrEt1FvoHQ7cYxM7p7xt6S7HuDAh/d4uNs/t06STfKzuW7rAJiS44oOuVNqBnhKYDQ3soTZiiQRSelca2+ecAvBmgA/DsIhzhmQ6nIuosOa9AIH4qwYNL1VlFQp2iuA3puQozn5x82wWNhEmg5/Ym7hIouspE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588686788; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=FEyXX/OHFY9JwII40MIftmAaH0v60jdCtx8gXuNTaOw=; b=IujBVUjdoeVQFMdXziN6lGMC2yaE8KafEehd0EwbjeLWhZ7eGxlW+v8csRwJBOyCQea6qSJSxU++P4K3c1tZkuN0oWFIx1WHophzCVMaWKkQx29f58nF8kiARMD71wV/DfHje4R1Y0Wl81N3wCtUBQKobcW3ge8LdrV52M2ABzc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588686788695493.4270931254372; Tue, 5 May 2020 06:53:08 -0700 (PDT) Received: from localhost ([::1]:46122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVy0R-0008ES-Ei for importer@patchew.org; Tue, 05 May 2020 09:53:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxr9-0000XK-61 for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:32 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:41333 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jVxr6-0003ba-KM for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:30 -0400 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-352-K4LcaknXNCuA4QRfLI0KiA-1; Tue, 05 May 2020 09:43:26 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 735B8100A614; Tue, 5 May 2020 13:43:25 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-113-193.ams2.redhat.com [10.36.113.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FD5460628; Tue, 5 May 2020 13:43:16 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id F1F8AA1ED; Tue, 5 May 2020 15:43:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588686208; 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=FEyXX/OHFY9JwII40MIftmAaH0v60jdCtx8gXuNTaOw=; b=iMCnz3OQtNvyBCcl+La3laQhDXRGqbBEL107SoId7LMwRT9to57xmPFKv9ZUKY+hbSCUxL 5QRqb/7goqM8SE2E2wyd2nhNDOzmdkf5BNg21us5vNjcfrmtZ0qtgXm3cqMFeOnSh9bVLk hNFXL3vYfM6POTNDRtr4Nh9dRIFCK44= X-MC-Unique: K4LcaknXNCuA4QRfLI0KiA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH v2 05/13] acpi: move acpi_init_common_fadt_data to acpi-common.c Date: Tue, 5 May 2020 15:42:57 +0200 Message-Id: <20200505134305.22666-6-kraxel@redhat.com> In-Reply-To: <20200505134305.22666-1-kraxel@redhat.com> References: <20200505134305.22666-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kraxel@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/05 03:48:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Gerd Hoffmann --- hw/i386/acpi-common.h | 5 ++++- hw/i386/acpi-build.c | 43 +------------------------------------------ hw/i386/acpi-common.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 43 deletions(-) diff --git a/hw/i386/acpi-common.h b/hw/i386/acpi-common.h index 583c320bbe7d..5788a13da9ca 100644 --- a/hw/i386/acpi-common.h +++ b/hw/i386/acpi-common.h @@ -1,7 +1,8 @@ #ifndef HW_I386_ACPI_COMMON_H #define HW_I386_ACPI_COMMON_H + +#include "include/hw/acpi/acpi-defs.h" #include "include/hw/acpi/acpi_dev_interface.h" - #include "include/hw/acpi/bios-linker-loader.h" #include "include/hw/i386/x86.h" =20 @@ -12,5 +13,7 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *link= er, X86MachineState *x86ms, AcpiDeviceIf *adev, bool has_pci); void acpi_build_facs(GArray *table_data); +void acpi_init_common_fadt_data(MachineState *ms, Object *o, + AcpiFadtData *data); =20 #endif diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index a69b85a266e7..d1f14394734e 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -132,47 +132,6 @@ const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio = =3D { .bit_width =3D NVDIMM_ACPI_IO_LEN << 3 }; =20 -static void init_common_fadt_data(MachineState *ms, Object *o, - AcpiFadtData *data) -{ - uint32_t io =3D object_property_get_uint(o, ACPI_PM_PROP_PM_IO_BASE, N= ULL); - AmlAddressSpace as =3D AML_AS_SYSTEM_IO; - AcpiFadtData fadt =3D { - .rev =3D 3, - .flags =3D - (1 << ACPI_FADT_F_WBINVD) | - (1 << ACPI_FADT_F_PROC_C1) | - (1 << ACPI_FADT_F_SLP_BUTTON) | - (1 << ACPI_FADT_F_RTC_S4) | - (1 << ACPI_FADT_F_USE_PLATFORM_CLOCK) | - /* APIC destination mode ("Flat Logical") has an upper limit o= f 8 - * CPUs for more than 8 CPUs, "Clustered Logical" mode has to = be - * used - */ - ((ms->smp.max_cpus > 8) ? - (1 << ACPI_FADT_F_FORCE_APIC_CLUSTER_MODEL) : 0), - .int_model =3D 1 /* Multiple APIC */, - .rtc_century =3D RTC_CENTURY, - .plvl2_lat =3D 0xfff /* C2 state not supported */, - .plvl3_lat =3D 0xfff /* C3 state not supported */, - .smi_cmd =3D ACPI_PORT_SMI_CMD, - .sci_int =3D object_property_get_uint(o, ACPI_PM_PROP_SCI_INT, NUL= L), - .acpi_enable_cmd =3D - object_property_get_uint(o, ACPI_PM_PROP_ACPI_ENABLE_CMD, NULL= ), - .acpi_disable_cmd =3D - object_property_get_uint(o, ACPI_PM_PROP_ACPI_DISABLE_CMD, NUL= L), - .pm1a_evt =3D { .space_id =3D as, .bit_width =3D 4 * 8, .address = =3D io }, - .pm1a_cnt =3D { .space_id =3D as, .bit_width =3D 2 * 8, - .address =3D io + 0x04 }, - .pm_tmr =3D { .space_id =3D as, .bit_width =3D 4 * 8, .address =3D= io + 0x08 }, - .gpe0_blk =3D { .space_id =3D as, .bit_width =3D - object_property_get_uint(o, ACPI_PM_PROP_GPE0_BLK_LEN, NULL) *= 8, - .address =3D object_property_get_uint(o, ACPI_PM_PROP_GPE0_BLK= , NULL) - }, - }; - *data =3D fadt; -} - static Object *object_resolve_type_unambiguous(const char *typename) { bool ambig; @@ -195,7 +154,7 @@ static void acpi_get_pm_info(MachineState *machine, Acp= iPmInfo *pm) pm->pcihp_io_len =3D 0; =20 assert(obj); - init_common_fadt_data(machine, obj, &pm->fadt); + acpi_init_common_fadt_data(machine, obj, &pm->fadt); if (piix) { /* w2k requires FADT(rev1) or it won't boot, keep PC compatible */ pm->fadt.rev =3D 1; diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c index 5187653893a8..69dfbf0252f3 100644 --- a/hw/i386/acpi-common.c +++ b/hw/i386/acpi-common.c @@ -28,6 +28,8 @@ #include "hw/acpi/aml-build.h" #include "hw/acpi/utils.h" #include "hw/i386/pc.h" +#include "hw/isa/apm.h" +#include "hw/rtc/mc146818rtc_regs.h" #include "target/i386/cpu.h" =20 #include "acpi-build.h" @@ -161,3 +163,44 @@ void acpi_build_facs(GArray *table_data) memcpy(&facs->signature, "FACS", 4); facs->length =3D cpu_to_le32(sizeof(*facs)); } + +void acpi_init_common_fadt_data(MachineState *ms, Object *o, + AcpiFadtData *data) +{ + uint32_t io =3D object_property_get_uint(o, ACPI_PM_PROP_PM_IO_BASE, N= ULL); + AmlAddressSpace as =3D AML_AS_SYSTEM_IO; + AcpiFadtData fadt =3D { + .rev =3D 3, + .flags =3D + (1 << ACPI_FADT_F_WBINVD) | + (1 << ACPI_FADT_F_PROC_C1) | + (1 << ACPI_FADT_F_SLP_BUTTON) | + (1 << ACPI_FADT_F_RTC_S4) | + (1 << ACPI_FADT_F_USE_PLATFORM_CLOCK) | + /* APIC destination mode ("Flat Logical") has an upper limit o= f 8 + * CPUs for more than 8 CPUs, "Clustered Logical" mode has to = be + * used + */ + ((ms->smp.max_cpus > 8) ? + (1 << ACPI_FADT_F_FORCE_APIC_CLUSTER_MODEL) : 0), + .int_model =3D 1 /* Multiple APIC */, + .rtc_century =3D RTC_CENTURY, + .plvl2_lat =3D 0xfff /* C2 state not supported */, + .plvl3_lat =3D 0xfff /* C3 state not supported */, + .smi_cmd =3D ACPI_PORT_SMI_CMD, + .sci_int =3D object_property_get_uint(o, ACPI_PM_PROP_SCI_INT, NUL= L), + .acpi_enable_cmd =3D + object_property_get_uint(o, ACPI_PM_PROP_ACPI_ENABLE_CMD, NULL= ), + .acpi_disable_cmd =3D + object_property_get_uint(o, ACPI_PM_PROP_ACPI_DISABLE_CMD, NUL= L), + .pm1a_evt =3D { .space_id =3D as, .bit_width =3D 4 * 8, .address = =3D io }, + .pm1a_cnt =3D { .space_id =3D as, .bit_width =3D 2 * 8, + .address =3D io + 0x04 }, + .pm_tmr =3D { .space_id =3D as, .bit_width =3D 4 * 8, .address =3D= io + 0x08 }, + .gpe0_blk =3D { .space_id =3D as, .bit_width =3D + object_property_get_uint(o, ACPI_PM_PROP_GPE0_BLK_LEN, NULL) *= 8, + .address =3D object_property_get_uint(o, ACPI_PM_PROP_GPE0_BLK= , NULL) + }, + }; + *data =3D fadt; +} --=20 2.18.4 From nobody Fri Dec 19 04:06:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588686296; cv=none; d=zohomail.com; s=zohoarc; b=JNC38PsuP+27ArNhrNkgCR/68CPXomJ/+vLxr++BVV0Hc7t+Yt+Sw10KFYI+cymbcUjo32dX63Gw2Wj/xh79B0JSC6+Y2kWft09B7mcWrdYfh9zroAP8dE3jzrkuSmYA4tIw7GaP6duoS/1x+Eufapyd5j6cCCP1U6kYx2in2TY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588686296; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=MhJLb4bb5y/Q8c4ojwDUWv/i3yjOhzST/5y8LGeV778=; b=oB30KB5Ljs2XfJH3ArQMyQazc6Kq/fshKDcV1XrosPrWSO+tySyu/tKKun1yt0nvkHkgCAhtW3ZceneRbpRBamLHV7qjJZD91GLnVfYmIQ5vLoN3xxIr9GU/Go3wN/+Lq4o4tgdVLvWK9l/ls0OaqIgvSDmBH0EYSOIK0duPlwM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588686296824306.78625060814977; Tue, 5 May 2020 06:44:56 -0700 (PDT) Received: from localhost ([::1]:41578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVxsV-0002w4-EV for importer@patchew.org; Tue, 05 May 2020 09:44:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxr1-0000Jq-BQ for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:23 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:45192 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jVxqz-0003Oq-B8 for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:22 -0400 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-473-Arx2Cj1XMo6SBSI8S5c6ng-1; Tue, 05 May 2020 09:43:19 -0400 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 EC918107ACF2; Tue, 5 May 2020 13:43:17 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-113-193.ams2.redhat.com [10.36.113.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8753D62959; Tue, 5 May 2020 13:43:16 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 08489A1EE; Tue, 5 May 2020 15:43:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588686200; 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=MhJLb4bb5y/Q8c4ojwDUWv/i3yjOhzST/5y8LGeV778=; b=HXf1zuqET+qiRQxM9pw1lECq8Xtg/+IpQ7D6iKNxughumw6+GccRTsxuZpNXhhnCm5kl7O YeKiEBq8rFVhtAgOY27PBuEBSgJI7Q4id38etcxztcZpdE8TEGcsQd7sfbjI7Cl+kdnpqT PKomNfChzCaix0ghVxga97KwYz7cTq4= X-MC-Unique: Arx2Cj1XMo6SBSI8S5c6ng-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH v2 06/13] acpi: move acpi_align_size to acpi-common.h Date: Tue, 5 May 2020 15:42:58 +0200 Message-Id: <20200505134305.22666-7-kraxel@redhat.com> In-Reply-To: <20200505134305.22666-1-kraxel@redhat.com> References: <20200505134305.22666-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=kraxel@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/05 00:37:38 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Gerd Hoffmann --- hw/i386/acpi-common.h | 19 +++++++++++++++++++ hw/i386/acpi-build.c | 18 ------------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/hw/i386/acpi-common.h b/hw/i386/acpi-common.h index 5788a13da9ca..f837bb17163b 100644 --- a/hw/i386/acpi-common.h +++ b/hw/i386/acpi-common.h @@ -3,12 +3,31 @@ =20 #include "include/hw/acpi/acpi-defs.h" #include "include/hw/acpi/acpi_dev_interface.h" +#include "include/hw/acpi/aml-build.h" #include "include/hw/acpi/bios-linker-loader.h" #include "include/hw/i386/x86.h" =20 +/* These are used to size the ACPI tables for -M pc-i440fx-1.7 and + * -M pc-i440fx-2.0. Even if the actual amount of AML generated grows + * a little bit, there should be plenty of free space since the DSDT + * shrunk by ~1.5k between QEMU 2.0 and QEMU 2.1. + */ +#define ACPI_BUILD_LEGACY_CPU_AML_SIZE 97 +#define ACPI_BUILD_ALIGN_SIZE 0x1000 + +#define ACPI_BUILD_TABLE_SIZE 0x20000 + /* Default IOAPIC ID */ #define ACPI_BUILD_IOAPIC_ID 0x0 =20 +static inline void acpi_align_size(GArray *blob, unsigned align) +{ + /* Align size to multiple of given size. This reduces the chance + * we need to change size in the future (breaking cross version migrat= ion). + */ + g_array_set_size(blob, ROUND_UP(acpi_data_len(blob), align)); +} + void acpi_build_madt(GArray *table_data, BIOSLinker *linker, X86MachineState *x86ms, AcpiDeviceIf *adev, bool has_pci); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index d1f14394734e..dc3b62468439 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -72,16 +72,6 @@ #include "hw/acpi/ipmi.h" #include "hw/acpi/hmat.h" =20 -/* These are used to size the ACPI tables for -M pc-i440fx-1.7 and - * -M pc-i440fx-2.0. Even if the actual amount of AML generated grows - * a little bit, there should be plenty of free space since the DSDT - * shrunk by ~1.5k between QEMU 2.0 and QEMU 2.1. - */ -#define ACPI_BUILD_LEGACY_CPU_AML_SIZE 97 -#define ACPI_BUILD_ALIGN_SIZE 0x1000 - -#define ACPI_BUILD_TABLE_SIZE 0x20000 - /* #define DEBUG_ACPI_BUILD */ #ifdef DEBUG_ACPI_BUILD #define ACPI_BUILD_DPRINTF(fmt, ...) \ @@ -267,14 +257,6 @@ static void acpi_get_pci_holes(Range *hole, Range *hol= e64) NULL)); } =20 -static void acpi_align_size(GArray *blob, unsigned align) -{ - /* Align size to multiple of given size. This reduces the chance - * we need to change size in the future (breaking cross version migrat= ion). - */ - g_array_set_size(blob, ROUND_UP(acpi_data_len(blob), align)); -} - static void build_append_pcihp_notify_entry(Aml *method, int slot) { Aml *if_ctx; --=20 2.18.4 From nobody Fri Dec 19 04:06:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588686308; cv=none; d=zohomail.com; s=zohoarc; b=kSvuocGTj+AmHUEcJf4rMjZxsvsEC0SmsYd0uQmPH7z/l/Eov3FOCJ0XWjq1bkj4hF7r5CPX47RGQh4oGfN1N6n4RpyL5bLIe6zh4CTiY1QEnw5reXsvx8mDsavo4sEjO1aNc2JfJ8CYyrpp4nKFAFyFk0hmhuNEXIauCup8HAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588686308; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=i4ldykcZJpXwx+PmIpuza7s5HH6fQc1feHOr4E11ARg=; b=bbNZjG3UOifWWQTS200gbCWYNZOYk+/l/Deg9PKqbfGPaqeTBTOUr76uKhA5fH25sUvDAiJek/vyhJnaP3F0FM06IS3WAb6f3oMTGncvucYvNng2LWsbutCuwShX9FX0Ijo5xx40JpCJ99LEP3R1xGX0LOmSA66mnEGcJgARikI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588686308609749.0848856060785; Tue, 5 May 2020 06:45:08 -0700 (PDT) Received: from localhost ([::1]:41796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVxsg-00031i-Tm for importer@patchew.org; Tue, 05 May 2020 09:45:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxr3-0000Lr-9s for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:25 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:53336 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jVxr0-0003PF-PX for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:24 -0400 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-442-JxkwOGheNmq0kzNy2fajkQ-1; Tue, 05 May 2020 09:43:19 -0400 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 3D883100A61E; Tue, 5 May 2020 13:43:18 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-113-193.ams2.redhat.com [10.36.113.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id ABAB563F9E; Tue, 5 May 2020 13:43:16 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1278AA1FB; Tue, 5 May 2020 15:43:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588686201; 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=i4ldykcZJpXwx+PmIpuza7s5HH6fQc1feHOr4E11ARg=; b=VtLmCgpWYfMOUfA+nb8NLjWnmGB2MuMWEnvCNGKfUKDQ/Jc5VSuMgO1L3LKtpSVONPhy5W zrXDhT+CotqLH9HsnQYi2ZQcjgHxlDsIXBpLllteEYtZAB7LhTdTMGSnglfiORcfjObcWG V4/2A/8FujHMw7JmP9yGTaWMi0SaJ5s= X-MC-Unique: JxkwOGheNmq0kzNy2fajkQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH v2 07/13] acpi: fadt: add hw-reduced sleep register support Date: Tue, 5 May 2020 15:42:59 +0200 Message-Id: <20200505134305.22666-8-kraxel@redhat.com> In-Reply-To: <20200505134305.22666-1-kraxel@redhat.com> References: <20200505134305.22666-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kraxel@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/05 03:48:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add fields to struct AcpiFadtData and update build_fadt() to properly generate sleep register entries. Signed-off-by: Gerd Hoffmann Reviewed-by: Igor Mammedov --- include/hw/acpi/acpi-defs.h | 2 ++ hw/acpi/aml-build.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index c13327fa7867..3be9ab504968 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -88,6 +88,8 @@ typedef struct AcpiFadtData { struct AcpiGenericAddress pm_tmr; /* PM_TMR_BLK */ struct AcpiGenericAddress gpe0_blk; /* GPE0_BLK */ struct AcpiGenericAddress reset_reg; /* RESET_REG */ + struct AcpiGenericAddress sleep_ctl; /* SLEEP_CONTROL_REG */ + struct AcpiGenericAddress sleep_sts; /* SLEEP_STATUS_REG */ uint8_t reset_val; /* RESET_VALUE */ uint8_t rev; /* Revision */ uint32_t flags; /* Flags */ diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 2c3702b8825b..c159b0d30022 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1863,9 +1863,9 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, cons= t AcpiFadtData *f, } =20 /* SLEEP_CONTROL_REG */ - build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0); + build_append_gas_from_struct(tbl, &f->sleep_ctl); /* SLEEP_STATUS_REG */ - build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0); + build_append_gas_from_struct(tbl, &f->sleep_sts); =20 /* TODO: extra fields need to be added to support revisions above rev5= */ assert(f->rev =3D=3D 5); --=20 2.18.4 From nobody Fri Dec 19 04:06:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588686642; cv=none; d=zohomail.com; s=zohoarc; b=dATVxqvRytbM89BqOVZQ8qWP/xD+3kpIVTfi0A+2DG8hJOkWZWL4TtDxCCjK4ivWvdrYfhPH8i5ylDjCHfOeESDpIXtPekQQ6749OKn3uOv0bq8/ml0MCjdvFVNTfGOOpvgypZnwCyaJg/wHqacxrGDUpILTEs9QIVsqkamaXdM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588686642; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=sq54SLAHOINc022y0i/GRX54KmFCzWGPnCDVP/mstf0=; b=OygPcjpcctasLwBLSUK+lWGwwhmRQW7eHWWEv2q8W+h6Y/g4r5K+oamlm4bjNecH3fyntLlmT5F8Z/CQkygPEw5tEvVcsriP3zWkWb4NEbPKESB/6y88KUp6cLt7VNQ/jBrgLxaUOWocfRyD0s8uNANxKPpD3CgRwA08LNvo/cA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588686642498910.5435435384721; Tue, 5 May 2020 06:50:42 -0700 (PDT) Received: from localhost ([::1]:36164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVxy4-0003qD-Q9 for importer@patchew.org; Tue, 05 May 2020 09:50:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxrB-0000YI-1d for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:34 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:59937 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jVxr6-0003bg-St for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:32 -0400 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-322-n_CUm5-wNzGW7CMD8rAJSw-1; Tue, 05 May 2020 09:43:26 -0400 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 5FABC107ACF2; Tue, 5 May 2020 13:43:25 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-113-193.ams2.redhat.com [10.36.113.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8364060BF4; Tue, 5 May 2020 13:43:17 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1E711A1FD; Tue, 5 May 2020 15:43:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588686208; 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=sq54SLAHOINc022y0i/GRX54KmFCzWGPnCDVP/mstf0=; b=dMZ3qdlii4UXtr78NsvMWguc0WnofakzlmoiPymYfJRqKVfcD5f5d5P7Gu+cfTR8zApio4 veyX+lCIrpmUbq44JeZXcCXlezHBENjd7WNd6MnLRTfpzte0P4hk84dRVJ3k2Zzt4NEL78 kGuZQlU/hQxt9qbtpQi/z7Itxc2HHc4= X-MC-Unique: n_CUm5-wNzGW7CMD8rAJSw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH v2 08/13] acpi: generic event device for x86 Date: Tue, 5 May 2020 15:43:00 +0200 Message-Id: <20200505134305.22666-9-kraxel@redhat.com> In-Reply-To: <20200505134305.22666-1-kraxel@redhat.com> References: <20200505134305.22666-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/05 00:37:40 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Uses TYPE_ACPI_GED as QOM parent for code reuse. Add registers for sleep states and reset. Add powerdown notifier for power button events. Set AcpiDeviceIfClass->madt_cpu. Signed-off-by: Gerd Hoffmann --- include/hw/acpi/generic_event_device.h | 10 +++ hw/i386/generic_event_device_x86.c | 114 +++++++++++++++++++++++++ hw/i386/Makefile.objs | 1 + 3 files changed, 125 insertions(+) create mode 100644 hw/i386/generic_event_device_x86.c diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/gener= ic_event_device.h index 9eb86ca4fd94..16d1f2b3cd30 100644 --- a/include/hw/acpi/generic_event_device.h +++ b/include/hw/acpi/generic_event_device.h @@ -68,9 +68,19 @@ #define ACPI_GED(obj) \ OBJECT_CHECK(AcpiGedState, (obj), TYPE_ACPI_GED) =20 +#define TYPE_ACPI_GED_X86 "acpi-ged-x86" +#define ACPI_GED_X86(obj) \ + OBJECT_CHECK(AcpiGedX86State, (obj), TYPE_ACPI_GED_X86) + #define ACPI_GED_EVT_SEL_OFFSET 0x0 #define ACPI_GED_EVT_SEL_LEN 0x4 =20 +#define ACPI_GED_X86_REG_SLEEP_CTL 0x00 +#define ACPI_GED_X86_REG_SLEEP_STS 0x01 +#define ACPI_GED_X86_REG_RESET 0x02 +#define ACPI_GED_X86_RESET_VALUE 0x42 +#define ACPI_GED_X86_REG_COUNT 0x03 + #define GED_DEVICE "GED" #define AML_GED_EVT_REG "EREG" #define AML_GED_EVT_SEL "ESEL" diff --git a/hw/i386/generic_event_device_x86.c b/hw/i386/generic_event_dev= ice_x86.c new file mode 100644 index 000000000000..8ae4a63084f3 --- /dev/null +++ b/hw/i386/generic_event_device_x86.c @@ -0,0 +1,114 @@ +/* + * x86 variant of the generic event device for hw reduced acpi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "exec/address-spaces.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/generic_event_device.h" +#include "hw/i386/pc.h" +#include "hw/irq.h" +#include "hw/mem/pc-dimm.h" +#include "hw/qdev-properties.h" +#include "migration/vmstate.h" +#include "qemu/error-report.h" +#include "sysemu/runstate.h" + +typedef struct AcpiGedX86State { + struct AcpiGedState parent_obj; + MemoryRegion regs; + Notifier powerdown_req; +} AcpiGedX86State; + +static uint64_t acpi_ged_x86_regs_read(void *opaque, hwaddr addr, unsigned= size) +{ + return 0; +} + +static void acpi_ged_x86_regs_write(void *opaque, hwaddr addr, uint64_t da= ta, + unsigned int size) +{ + bool slp_en; + int slp_typ; + + switch (addr) { + case ACPI_GED_X86_REG_SLEEP_CTL: + slp_typ =3D (data >> 2) & 0x07; + slp_en =3D (data >> 5) & 0x01; + if (slp_en && slp_typ =3D=3D 5) { + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); + } + return; + case ACPI_GED_X86_REG_SLEEP_STS: + return; + case ACPI_GED_X86_REG_RESET: + if (data =3D=3D ACPI_GED_X86_RESET_VALUE) { + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); + } + return; + } +} + +static const MemoryRegionOps acpi_ged_x86_regs_ops =3D { + .read =3D acpi_ged_x86_regs_read, + .write =3D acpi_ged_x86_regs_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid =3D { + .min_access_size =3D 1, + .max_access_size =3D 1, + }, +}; + +static void acpi_ged_x86_powerdown_req(Notifier *n, void *opaque) +{ + AcpiGedX86State *s =3D container_of(n, AcpiGedX86State, powerdown_req); + AcpiDeviceIf *adev =3D ACPI_DEVICE_IF(s); + AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_GET_CLASS(OBJECT(s)); + + adevc->send_event(adev, ACPI_POWER_DOWN_STATUS); +} + +static void acpi_ged_x86_initfn(Object *obj) +{ + AcpiGedX86State *s =3D ACPI_GED_X86(obj); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); + + memory_region_init_io(&s->regs, obj, &acpi_ged_x86_regs_ops, + obj, "acpi-regs", ACPI_GED_X86_REG_COUNT); + sysbus_init_mmio(sbd, &s->regs); + + s->powerdown_req.notify =3D acpi_ged_x86_powerdown_req; + qemu_register_powerdown_notifier(&s->powerdown_req); +} + +static void acpi_ged_x86_class_init(ObjectClass *class, void *data) +{ + AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_CLASS(class); + + adevc->madt_cpu =3D pc_madt_cpu_entry; +} + +static const TypeInfo acpi_ged_x86_info =3D { + .name =3D TYPE_ACPI_GED_X86, + .parent =3D TYPE_ACPI_GED, + .instance_size =3D sizeof(AcpiGedX86State), + .instance_init =3D acpi_ged_x86_initfn, + .class_init =3D acpi_ged_x86_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_HOTPLUG_HANDLER }, + { TYPE_ACPI_DEVICE_IF }, + { } + } +}; + +static void acpi_ged_x86_register_types(void) +{ + type_register_static(&acpi_ged_x86_info); +} + +type_init(acpi_ged_x86_register_types) diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs index 6abc74551a72..622739305882 100644 --- a/hw/i386/Makefile.objs +++ b/hw/i386/Makefile.objs @@ -17,4 +17,5 @@ obj-$(CONFIG_PC) +=3D port92.o =20 obj-y +=3D kvmvapic.o obj-$(CONFIG_ACPI) +=3D acpi-common.o +obj-$(CONFIG_ACPI_HW_REDUCED) +=3D generic_event_device_x86.o obj-$(CONFIG_PC) +=3D acpi-build.o --=20 2.18.4 From nobody Fri Dec 19 04:06:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588686537; cv=none; d=zohomail.com; s=zohoarc; b=D1w7d2L45DJdX18wTVLxR5Q+ouSylpda1Uf8IKjYrxXGtKBu/ckXUKue1gCHqzKgaYAR2rWOdsWk7wSxj6Pr6Gzn4HU8iAgXDA+ztTeycM3FAphbQqDFC3/wveqSf7nLVnzEgFuIlOuhFDHZ0ctyhsmKKRSIFKtmlV0TLuTTcxk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588686537; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=YUvZiRb2AYjyhQT5qknWtNKJOF5B/pkJqYBc6zj0z7k=; b=ZiGkaL+PKtpCsqZo3r9YXajR3FcJaODGSjMw+m3ZPI7Rd2TZt2CspBVtW3a0gjPwMvhVDj8FYSGPt3yMudlFIPk4jsTngvsAiQOgqIseu0UjUqn5sz4C4vLqBnR2RoJC2oVnl1mxPju6zkYkP7jiFjQpPn7HFyUf8w35RK7fovc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588686537358941.4354625948616; Tue, 5 May 2020 06:48:57 -0700 (PDT) Received: from localhost ([::1]:58118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVxwO-0001Es-0z for importer@patchew.org; Tue, 05 May 2020 09:48:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxr5-0000Q8-3i for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:27 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:27546 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jVxr3-0003Zd-N9 for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:26 -0400 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-348-BYK_rjB6PRy6NK7H87hEvQ-1; Tue, 05 May 2020 09:43:19 -0400 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 B21B1100A61F; Tue, 5 May 2020 13:43:18 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-113-193.ams2.redhat.com [10.36.113.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id D24DA10013D9; Tue, 5 May 2020 13:43:17 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2FB0A9D54; Tue, 5 May 2020 15:43:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588686205; 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=YUvZiRb2AYjyhQT5qknWtNKJOF5B/pkJqYBc6zj0z7k=; b=RY9N6O0MPdrezpgkikHikuJ4pUmMgnfqFUG59oO49+fXviRE5s0v582c68UlpjREsi8MP0 wuIPNBqKqihEVpQx7VCZ2pBwvPpl6RW80lMCJWiyzHrFTaxh2iniQg+em4MIsj6LaMLHcv cRXQ6Ei7uf7u9KTdDoEZFiLMxuaxem4= X-MC-Unique: BYK_rjB6PRy6NK7H87hEvQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH v2 09/13] microvm: add minimal acpi support Date: Tue, 5 May 2020 15:43:01 +0200 Message-Id: <20200505134305.22666-10-kraxel@redhat.com> In-Reply-To: <20200505134305.22666-1-kraxel@redhat.com> References: <20200505134305.22666-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kraxel@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/05 03:48:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" $subject says all. Can be disabled using the usual -no-acpi switch. Signed-off-by: Gerd Hoffmann --- hw/i386/acpi-microvm.h | 6 ++ include/hw/i386/microvm.h | 8 ++ hw/i386/acpi-microvm.c | 198 ++++++++++++++++++++++++++++++++++++++ hw/i386/microvm.c | 22 +++++ hw/i386/Kconfig | 1 + hw/i386/Makefile.objs | 1 + 6 files changed, 236 insertions(+) create mode 100644 hw/i386/acpi-microvm.h create mode 100644 hw/i386/acpi-microvm.c diff --git a/hw/i386/acpi-microvm.h b/hw/i386/acpi-microvm.h new file mode 100644 index 000000000000..6a6c2967102b --- /dev/null +++ b/hw/i386/acpi-microvm.h @@ -0,0 +1,6 @@ +#ifndef HW_I386_ACPI_MICROVM_H +#define HW_I386_ACPI_MICROVM_H + +void acpi_setup_microvm(void); + +#endif diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h index ba68d1f22bb3..55f5984cfaa1 100644 --- a/include/hw/i386/microvm.h +++ b/include/hw/i386/microvm.h @@ -24,6 +24,7 @@ =20 #include "hw/boards.h" #include "hw/i386/x86.h" +#include "hw/acpi/acpi_dev_interface.h" =20 /* Platform virtio definitions */ #define VIRTIO_MMIO_BASE 0xc0000000 @@ -31,6 +32,11 @@ #define VIRTIO_NUM_TRANSPORTS 8 #define VIRTIO_CMDLINE_MAXLEN 64 =20 +#define GED_MMIO_BASE 0xc1000000 +#define GED_MMIO_BASE_MEMHP (GED_MMIO_BASE + 0x100) +#define GED_MMIO_BASE_REGS (GED_MMIO_BASE + 0x200) +#define GED_MMIO_IRQ 9 + /* Machine type options */ #define MICROVM_MACHINE_PIT "pit" #define MICROVM_MACHINE_PIC "pic" @@ -58,6 +64,8 @@ typedef struct { =20 /* Machine state */ bool kernel_cmdline_fixed; + Notifier machine_done; + AcpiDeviceIf *acpi_dev; } MicrovmMachineState; =20 #define TYPE_MICROVM_MACHINE MACHINE_TYPE_NAME("microvm") diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c new file mode 100644 index 000000000000..ce5ab86d642c --- /dev/null +++ b/hw/i386/acpi-microvm.c @@ -0,0 +1,198 @@ +/* Support for generating ACPI tables and passing them to Guests + * + * Copyright (C) 2008-2010 Kevin O'Connor + * Copyright (C) 2006 Fabrice Bellard + * Copyright (C) 2013 Red Hat Inc + * + * Author: Michael S. Tsirkin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" + +#include "exec/memory.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/bios-linker-loader.h" +#include "hw/acpi/generic_event_device.h" +#include "hw/acpi/utils.h" +#include "hw/boards.h" +#include "hw/i386/fw_cfg.h" +#include "hw/i386/microvm.h" + +#include "acpi-common.h" +#include "acpi-microvm.h" + +/* FIXME: copy & paste */ +static void acpi_dsdt_add_power_button(Aml *scope) +{ + Aml *dev =3D aml_device(ACPI_POWER_BUTTON_DEVICE); + aml_append(dev, aml_name_decl("_HID", aml_string("PNP0C0C"))); + aml_append(dev, aml_name_decl("_UID", aml_int(0))); + aml_append(scope, dev); +} + +static void +build_dsdt_microvm(GArray *table_data, BIOSLinker *linker, + MicrovmMachineState *mms) +{ + X86MachineState *x86ms =3D X86_MACHINE(mms); + Aml *dsdt, *sb_scope, *scope, *pkg; + bool ambiguous; + Object *isabus; + + isabus =3D object_resolve_path_type("", TYPE_ISA_BUS, &ambiguous); + assert(isabus); + assert(!ambiguous); + + dsdt =3D init_aml_allocator(); + + /* Reserve space for header */ + acpi_data_push(dsdt->buf, sizeof(AcpiTableHeader)); + + sb_scope =3D aml_scope("_SB"); + fw_cfg_add_acpi_dsdt(sb_scope, x86ms->fw_cfg); + isa_build_aml(ISA_BUS(isabus), sb_scope); + build_ged_aml(sb_scope, GED_DEVICE, HOTPLUG_HANDLER(mms->acpi_dev), + GED_MMIO_IRQ, AML_SYSTEM_MEMORY, GED_MMIO_BASE); + acpi_dsdt_add_power_button(sb_scope); + aml_append(dsdt, sb_scope); + + scope =3D aml_scope("\\"); + pkg =3D aml_package(4); + aml_append(pkg, aml_int(5)); /* SLEEP_CONTROL_REG.SLP_TYP */ + aml_append(pkg, aml_int(0)); /* ignored */ + 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, 5, NULL, NULL); + free_aml_allocator(); +} + +static void acpi_build_microvm(AcpiBuildTables *tables, + MicrovmMachineState *mms) +{ + MachineState *machine =3D MACHINE(mms); + GArray *table_offsets; + GArray *tables_blob =3D tables->table_data; + unsigned facs, dsdt, xsdt; + AcpiFadtData pmfadt =3D { + .rev =3D 5, + .minor_ver =3D 1, + .flags =3D ((1 << ACPI_FADT_F_HW_REDUCED_ACPI) | + (1 << ACPI_FADT_F_RESET_REG_SUP)), + .sleep_ctl =3D { + .space_id =3D AML_AS_SYSTEM_MEMORY, + .bit_width =3D 8, + .address =3D GED_MMIO_BASE_REGS + ACPI_GED_X86_REG_SLEEP_CTL, + }, + .sleep_sts =3D { + .space_id =3D AML_AS_SYSTEM_MEMORY, + .bit_width =3D 8, + .address =3D GED_MMIO_BASE_REGS + ACPI_GED_X86_REG_SLEEP_STS, + }, + .reset_reg =3D { + .space_id =3D AML_AS_SYSTEM_MEMORY, + .bit_width =3D 8, + .address =3D GED_MMIO_BASE_REGS + ACPI_GED_X86_REG_RESET, + }, + .reset_val =3D ACPI_GED_X86_RESET_VALUE, + }; + + table_offsets =3D 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 =3D tables_blob->len; + acpi_build_facs(tables_blob); + + dsdt =3D tables_blob->len; + build_dsdt_microvm(tables_blob, tables->linker, mms); + + pmfadt.facs_tbl_offset =3D &facs; + pmfadt.dsdt_tbl_offset =3D &dsdt; + pmfadt.xdsdt_tbl_offset =3D &dsdt; + acpi_add_table(table_offsets, tables_blob); + build_fadt(tables_blob, tables->linker, &pmfadt, NULL, NULL); + + acpi_add_table(table_offsets, tables_blob); + acpi_build_madt(tables_blob, tables->linker, X86_MACHINE(machine), + mms->acpi_dev, false); + + xsdt =3D tables_blob->len; + build_xsdt(tables_blob, tables->linker, table_offsets, NULL, NULL); + + /* RSDP is in FSEG memory, so allocate it separately */ + { + AcpiRsdpData rsdp_data =3D { + .revision =3D 2, + .oem_id =3D ACPI_BUILD_APPNAME6, + .xsdt_tbl_offset =3D &xsdt, + .rsdt_tbl_offset =3D NULL, + }; + 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_no_update(void *build_opaque) +{ + /* nothing, microvm tables don't change at runtime */ +} + +void acpi_setup_microvm(void) +{ + MicrovmMachineState *mms =3D MICROVM_MACHINE(qdev_get_machine()); + X86MachineState *x86ms =3D X86_MACHINE(mms); + AcpiBuildTables tables; + + assert(x86ms->fw_cfg); + + if (!x86_machine_is_acpi_enabled(x86ms)) { + return; + } + + acpi_build_tables_init(&tables); + acpi_build_microvm(&tables, mms); + + /* Now expose it all to Guest */ + acpi_add_rom_blob(acpi_build_no_update, NULL, + tables.table_data, + ACPI_BUILD_TABLE_FILE, + ACPI_BUILD_TABLE_MAX_SIZE); + acpi_add_rom_blob(acpi_build_no_update, NULL, + tables.linker->cmd_blob, + "etc/table-loader", 0); + acpi_add_rom_blob(acpi_build_no_update, NULL, + tables.rsdp, + ACPI_BUILD_RSDP_FILE, 0); + + acpi_build_tables_cleanup(&tables, false); +} diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index 38d8e5170323..6ba2d9d3f028 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-microvm.h" =20 #include "hw/loader.h" #include "hw/irq.h" @@ -41,6 +42,8 @@ #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 "hw/acpi/generic_event_device.h" =20 #include "cpu.h" #include "elf.h" @@ -128,6 +131,17 @@ static void microvm_devices_init(MicrovmMachineState *= mms) } =20 /* Optional and legacy devices */ + if (x86_machine_is_acpi_enabled(x86ms)) { + DeviceState *dev =3D qdev_create(NULL, TYPE_ACPI_GED_X86); + qdev_prop_set_uint32(dev, "ged-event", ACPI_GED_PWR_DOWN_EVT); + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, GED_MMIO_BASE); + /* sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, GED_MMIO_BASE_MEMHP); */ + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, GED_MMIO_BASE_REGS); + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, + x86ms->gsi[GED_MMIO_IRQ]); + qdev_init_nofail(dev); + mms->acpi_dev =3D ACPI_DEVICE_IF(dev); + } =20 if (mms->pic =3D=3D ON_OFF_AUTO_ON || mms->pic =3D=3D ON_OFF_AUTO_AUTO= ) { qemu_irq *i8259; @@ -468,6 +482,11 @@ static void microvm_machine_set_auto_kernel_cmdline(Ob= ject *obj, bool value, mms->auto_kernel_cmdline =3D value; } =20 +static void microvm_machine_done(Notifier *notifier, void *data) +{ + acpi_setup_microvm(); +} + static void microvm_machine_initfn(Object *obj) { MicrovmMachineState *mms =3D MICROVM_MACHINE(obj); @@ -482,6 +501,9 @@ static void microvm_machine_initfn(Object *obj) =20 /* State */ mms->kernel_cmdline_fixed =3D false; + + mms->machine_done.notify =3D microvm_machine_done; + qemu_add_machine_init_done_notifier(&mms->machine_done); } =20 static void microvm_class_init(ObjectClass *oc, void *data) diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index c93f32f6579d..be746bcb49eb 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -102,6 +102,7 @@ config MICROVM select I8259 select MC146818RTC select VIRTIO_MMIO + select ACPI_HW_REDUCED =20 config X86_IOMMU bool diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs index 622739305882..bbb2fe78f3cd 100644 --- a/hw/i386/Makefile.objs +++ b/hw/i386/Makefile.objs @@ -19,3 +19,4 @@ obj-y +=3D kvmvapic.o obj-$(CONFIG_ACPI) +=3D acpi-common.o obj-$(CONFIG_ACPI_HW_REDUCED) +=3D generic_event_device_x86.o obj-$(CONFIG_PC) +=3D acpi-build.o +obj-$(CONFIG_MICROVM) +=3D acpi-microvm.o --=20 2.18.4 From nobody Fri Dec 19 04:06:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588686677; cv=none; d=zohomail.com; s=zohoarc; b=SYpAQFLAuyJzP9ZxDzTMaAiHwij7yvri3rGSNgxx8Ai5PW84TT+NCr5M9mE5Dp135Tqc8CciubzBPzBELRORQKsM/o0qr0pmk3AHbMeooDJesbPl/B+eO6WU4zckXmEtVIot98pTtGgdsNXXr/Zsg1tdT79I9dkxtTLml5w2Djs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588686677; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=dU/F5xXPMddt7wfYt+AHFoIrXcl4kiK6uH51F4UWAOc=; b=ONxOi5XxqFxAuhS8juSVEHVpwOWZ1ozME2chQFxXsWW2UQRWZxat9RhV9k3HdU3JS4CQInvrOvzD1b4Al5MCI44jSFoLVlq54YozBGE4onlBUrbVTNt6jlVwJBJDBH+sTUrMrDGIjqpaJ8OHs2wafj0ezwWaZgr78uYhi86l1vc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158868667762113.283654182253485; Tue, 5 May 2020 06:51:17 -0700 (PDT) Received: from localhost ([::1]:38594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVxye-0004yi-8p for importer@patchew.org; Tue, 05 May 2020 09:51:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49562) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxr7-0000W1-Ck for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:30 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:24766 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jVxr6-0003bc-Le for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:29 -0400 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-468-AzfLbkAfOg2J-RcHRMyT5w-1; Tue, 05 May 2020 09:43:26 -0400 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 22D12107ACF5; Tue, 5 May 2020 13:43:25 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-113-193.ams2.redhat.com [10.36.113.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id ECE4E60BEC; Tue, 5 May 2020 13:43:16 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3858C9D55; Tue, 5 May 2020 15:43:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588686208; 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=dU/F5xXPMddt7wfYt+AHFoIrXcl4kiK6uH51F4UWAOc=; b=PODFkJZv0Jx2sOM3pTwaXf3eBRbZwid6ltuWrDmGXdSLRXNmym/itMOrV1MWThE1ZkXm1O VDvfggzmHfgFd8Vy1761fzNsdhbNQXyt4wVcxsH7bmMCG3QSlwihZY5HCuYbgrTXVaFOKf yYcbjO5F2QZ56Lvc+ddoNiLl2MYyeXw= X-MC-Unique: AzfLbkAfOg2J-RcHRMyT5w-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH v2 10/13] microvm: disable virtio-mmio cmdline hack Date: Tue, 5 May 2020 15:43:02 +0200 Message-Id: <20200505134305.22666-11-kraxel@redhat.com> In-Reply-To: <20200505134305.22666-1-kraxel@redhat.com> References: <20200505134305.22666-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kraxel@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/05 03:48:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" ... in case we are using ACPI. Signed-off-by: Gerd Hoffmann Reviewed-by: Igor Mammedov --- hw/i386/microvm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index 6ba2d9d3f028..a3708fdf1e39 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -369,7 +369,8 @@ static void microvm_machine_reset(MachineState *machine) CPUState *cs; X86CPU *cpu; =20 - if (machine->kernel_filename !=3D NULL && + if (!x86_machine_is_acpi_enabled(X86_MACHINE(machine)) && + machine->kernel_filename !=3D NULL && mms->auto_kernel_cmdline && !mms->kernel_cmdline_fixed) { microvm_fix_kernel_cmdline(machine); mms->kernel_cmdline_fixed =3D true; --=20 2.18.4 From nobody Fri Dec 19 04:06:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588686568; cv=none; d=zohomail.com; s=zohoarc; b=aPuy4HxcwqEHKKVKOA6fgxaGbke8dtB04xVDHc1pD2bXNlZAQm7vUWJvAzkPKV7wrKsKMUzCrg3qNl+CuBGp6GOzBuIZGbRkh9kRWoXPMu9A8InJsRzda41sF74EW5VOEreFkS2FrBouWbShDFh3J05LqsryGCBkcFq2qULPC6w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588686568; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=xPLSoTFO9NPpXqAmy8mwfJHiKPZDJRAf/4MPfD+zyhY=; b=OjwnN1EJleOJKVTk27cDvfIV7dtJu+bNuklajwlm5/igUaD1w4H+r2mCXmBaOI7BzyfNJVuE46mNx53K7ExRsewxoV9CImIcA01e4vfCySC71nLIMLFsH2GYITHO8lLJCDTMcy3zMMz7HCBqD9jpSzE/pIvaYb9rEawX+EyZ6MQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588686568654140.21669870305413; Tue, 5 May 2020 06:49:28 -0700 (PDT) Received: from localhost ([::1]:60718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVxwt-0002KX-CW for importer@patchew.org; Tue, 05 May 2020 09:49:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxr4-0000OH-8M for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:26 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:58920 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jVxr1-0003V5-PG for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:25 -0400 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-465-UriqJfQ2PGm5bxSFrbVnOg-1; Tue, 05 May 2020 09:43:20 -0400 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 2756D1005510; Tue, 5 May 2020 13:43:19 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-113-193.ams2.redhat.com [10.36.113.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC9E71002389; Tue, 5 May 2020 13:43:18 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 413799D56; Tue, 5 May 2020 15:43:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588686202; 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=xPLSoTFO9NPpXqAmy8mwfJHiKPZDJRAf/4MPfD+zyhY=; b=NTNys1XxHTz8MuZpQG640jvOL4ZkSlz7R6wPwEnxtfoRDcmgavKp0t0YBF203DaB5s1A/t l17Y02/wfMWqZUgbzoW/o/L62TCkBllqkZ4pLKpDgZFN+sWTZD3u14R3S+chH0JPmimTyO VRkMYH+626C70MCUWpphz6uWYj5SzXk= X-MC-Unique: UriqJfQ2PGm5bxSFrbVnOg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH v2 11/13] microvm: add acpi_dsdt_add_virtio() for x86 Date: Tue, 5 May 2020 15:43:03 +0200 Message-Id: <20200505134305.22666-12-kraxel@redhat.com> In-Reply-To: <20200505134305.22666-1-kraxel@redhat.com> References: <20200505134305.22666-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/05 00:37:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Makes x86 linux kernel find virtio-mmio devices automatically. Signed-off-by: Gerd Hoffmann Reviewed-by: Sergio Lopez --- hw/i386/acpi-microvm.c | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c index ce5ab86d642c..4d91ac9360ce 100644 --- a/hw/i386/acpi-microvm.c +++ b/hw/i386/acpi-microvm.c @@ -21,6 +21,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "qapi/error.h" =20 #include "exec/memory.h" @@ -32,6 +33,7 @@ #include "hw/boards.h" #include "hw/i386/fw_cfg.h" #include "hw/i386/microvm.h" +#include "hw/virtio/virtio-mmio.h" =20 #include "acpi-common.h" #include "acpi-microvm.h" @@ -45,6 +47,54 @@ static void acpi_dsdt_add_power_button(Aml *scope) aml_append(scope, dev); } =20 +static void acpi_dsdt_add_virtio(Aml *scope) +{ + gchar *separator; + long int index; + BusState *bus; + BusChild *kid; + + bus =3D sysbus_get_default(); + QTAILQ_FOREACH(kid, &bus->children, sibling) { + DeviceState *dev =3D kid->child; + Object *obj =3D object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MMIO); + + if (obj) { + VirtIOMMIOProxy *mmio =3D VIRTIO_MMIO(obj); + VirtioBusState *mmio_virtio_bus =3D &mmio->bus; + BusState *mmio_bus =3D &mmio_virtio_bus->parent_obj; + + if (QTAILQ_EMPTY(&mmio_bus->children)) { + continue; + } + separator =3D g_strrstr(mmio_bus->name, "."); + if (!separator) { + continue; + } + if (qemu_strtol(separator + 1, NULL, 10, &index) !=3D 0) { + continue; + } + + uint32_t irq =3D VIRTIO_IRQ_BASE + index; + hwaddr base =3D VIRTIO_MMIO_BASE + index * 512; + hwaddr size =3D 512; + + Aml *dev =3D 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 =3D 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_H= IGH, + 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) @@ -69,6 +119,7 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *linke= r, build_ged_aml(sb_scope, GED_DEVICE, HOTPLUG_HANDLER(mms->acpi_dev), GED_MMIO_IRQ, AML_SYSTEM_MEMORY, GED_MMIO_BASE); acpi_dsdt_add_power_button(sb_scope); + acpi_dsdt_add_virtio(sb_scope); aml_append(dsdt, sb_scope); =20 scope =3D aml_scope("\\"); --=20 2.18.4 From nobody Fri Dec 19 04:06:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588686541; cv=none; d=zohomail.com; s=zohoarc; b=bRCIz2qeeKgfv6zcTSvCobyVTKrlGto/rz1zwHLbnGbqWlcKs0cr/FBOMO0Z0eIEWRLdKdeKgBdr2yPmLuyUehvdDlk7Z0LfREKb2AaMi2CJ+NAcXyn9qYqdzb3zYqziJ9JY8rD+rSg/iFOrSsTmPl2GY8Bl9SAQqY/O+Di6YQQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588686541; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=zgSpJqdMPIXS+SyyuipeEjYSEQ5SaPyedMVSrXiUrTQ=; b=CTBddguA+JOdLxvtJHLAaboMGa82zDfjNl7K9j1/HAs0zuLjg0I7O0P1NfkaFP2pYPT8AE/RT0GfgRlrC60pxWbRWFQ0tJRrvbIzEBK0d8SkZUiy7Xff+WKclGaozZNnemBWKKIiK/OKy3t2TD/cWEjE2oifRiKCcsEg9JyBrW4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588686541139195.63836984976763; Tue, 5 May 2020 06:49:01 -0700 (PDT) Received: from localhost ([::1]:58518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVxwR-0001Rb-SA for importer@patchew.org; Tue, 05 May 2020 09:48:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxr9-0000XS-8Q for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:32 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:41921 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jVxr6-0003be-RL for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:30 -0400 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-194-z3zmkZ_MMIiZuBuTN7E5cg-1; Tue, 05 May 2020 09:43:26 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B594100A629; Tue, 5 May 2020 13:43:25 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-113-193.ams2.redhat.com [10.36.113.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id B04285F7EA; Tue, 5 May 2020 13:43:18 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4D1F29D57; Tue, 5 May 2020 15:43:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588686208; 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=zgSpJqdMPIXS+SyyuipeEjYSEQ5SaPyedMVSrXiUrTQ=; b=ORfr1+Kr9rPGQRY/MUhZUQ7Ox+9azxDFHO5w9U9E013cKZ8ONciy09NnOmHGtlwPg1y/Lb qI3uUexgfoADIpKMLTI5hgpQN3KgbME9fumfAE+4kmqJemQbO4QIhg8U98IU81PjiLwART B4WQAmylxBqM6o140ztXmMqO9hwoAHc= X-MC-Unique: z3zmkZ_MMIiZuBuTN7E5cg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH v2 12/13] microvm: make virtio irq base runtime configurable Date: Tue, 5 May 2020 15:43:04 +0200 Message-Id: <20200505134305.22666-13-kraxel@redhat.com> In-Reply-To: <20200505134305.22666-1-kraxel@redhat.com> References: <20200505134305.22666-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kraxel@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/05 03:48:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Gerd Hoffmann Reviewed-by: Sergio Lopez --- include/hw/i386/microvm.h | 2 +- hw/i386/acpi-microvm.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 55f5984cfaa1..878d2a8011f4 100644 --- a/include/hw/i386/microvm.h +++ b/include/hw/i386/microvm.h @@ -28,7 +28,6 @@ =20 /* Platform virtio definitions */ #define VIRTIO_MMIO_BASE 0xc0000000 -#define VIRTIO_IRQ_BASE 5 #define VIRTIO_NUM_TRANSPORTS 8 #define VIRTIO_CMDLINE_MAXLEN 64 =20 @@ -63,6 +62,7 @@ typedef struct { bool auto_kernel_cmdline; =20 /* Machine state */ + uint32_t virtio_irq_base; bool kernel_cmdline_fixed; Notifier machine_done; AcpiDeviceIf *acpi_dev; diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c index 4d91ac9360ce..1230080c45cd 100644 --- a/hw/i386/acpi-microvm.c +++ b/hw/i386/acpi-microvm.c @@ -47,7 +47,7 @@ static void acpi_dsdt_add_power_button(Aml *scope) aml_append(scope, dev); } =20 -static void acpi_dsdt_add_virtio(Aml *scope) +static void acpi_dsdt_add_virtio(Aml *scope, MicrovmMachineState *mms) { gchar *separator; long int index; @@ -75,7 +75,7 @@ static void acpi_dsdt_add_virtio(Aml *scope) continue; } =20 - uint32_t irq =3D VIRTIO_IRQ_BASE + index; + uint32_t irq =3D mms->virtio_irq_base + index; hwaddr base =3D VIRTIO_MMIO_BASE + index * 512; hwaddr size =3D 512; =20 @@ -119,7 +119,7 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *link= er, build_ged_aml(sb_scope, GED_DEVICE, HOTPLUG_HANDLER(mms->acpi_dev), GED_MMIO_IRQ, AML_SYSTEM_MEMORY, GED_MMIO_BASE); acpi_dsdt_add_power_button(sb_scope); - acpi_dsdt_add_virtio(sb_scope); + acpi_dsdt_add_virtio(sb_scope, mms); aml_append(dsdt, sb_scope); =20 scope =3D aml_scope("\\"); diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index a3708fdf1e39..2aa2804e4ca0 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -124,10 +124,11 @@ static void microvm_devices_init(MicrovmMachineState = *mms) =20 kvmclock_create(); =20 + mms->virtio_irq_base =3D 8; for (i =3D 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]); } =20 /* Optional and legacy devices */ @@ -274,7 +275,7 @@ static void microvm_memory_init(MicrovmMachineState *mm= s) x86ms->ioapic_as =3D &address_space_memory; } =20 -static gchar *microvm_get_mmio_cmdline(gchar *name) +static gchar *microvm_get_mmio_cmdline(gchar *name, uint32_t virtio_irq_ba= se) { gchar *cmdline; gchar *separator; @@ -294,7 +295,7 @@ static gchar *microvm_get_mmio_cmdline(gchar *name) ret =3D g_snprintf(cmdline, VIRTIO_CMDLINE_MAXLEN, " virtio_mmio.device=3D512@0x%lx:%ld", VIRTIO_MMIO_BASE + index * 512, - VIRTIO_IRQ_BASE + index); + virtio_irq_base + index); if (ret < 0 || ret >=3D VIRTIO_CMDLINE_MAXLEN) { g_free(cmdline); return NULL; @@ -306,6 +307,7 @@ static gchar *microvm_get_mmio_cmdline(gchar *name) static void microvm_fix_kernel_cmdline(MachineState *machine) { X86MachineState *x86ms =3D X86_MACHINE(machine); + MicrovmMachineState *mms =3D MICROVM_MACHINE(machine); BusState *bus; BusChild *kid; char *cmdline; @@ -329,7 +331,8 @@ static void microvm_fix_kernel_cmdline(MachineState *ma= chine) BusState *mmio_bus =3D &mmio_virtio_bus->parent_obj; =20 if (!QTAILQ_EMPTY(&mmio_bus->children)) { - gchar *mmio_cmdline =3D microvm_get_mmio_cmdline(mmio_bus-= >name); + gchar *mmio_cmdline =3D microvm_get_mmio_cmdline + (mmio_bus->name, mms->virtio_irq_base); if (mmio_cmdline) { char *newcmd =3D g_strjoin(NULL, cmdline, mmio_cmdline= , NULL); g_free(mmio_cmdline); --=20 2.18.4 From nobody Fri Dec 19 04:06:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588686458; cv=none; d=zohomail.com; s=zohoarc; b=Hy87fEcf9R6hMkAZmAlavEst31pdPLGDNIP97W1VsFFG+IH2GaEju63MYJ2/ZILyC2pRgB06WtErOJZXbPCZaaK3aeordR6PaLsj4PBu8gPcicmOasDrty6dJGCTSmAJyVaczhW/p9tQqrUhjCcnG+Hd5UuX/Wf5dc0SdLxiLac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588686458; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=hrIQsYam6cYX95FqmE4LazgkxSySEewBiHZ6lQbYwKc=; b=lk59G7830mcVeeVhJmVIh31IdMpbCVjK7xC8SJon2XEamI4BdZPzZ9sy97Jw+V4rH5kpFMmT80t4yrV/nrkXn8X2xJxBmGPayVe48kej+EAgnjFmWVw8eIfrC0E/Nv56xtCZMl/pTMZ29/gmzbiH0TND1p3axoSOPxLmJkxhOIw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588686458883622.5445868573634; Tue, 5 May 2020 06:47:38 -0700 (PDT) Received: from localhost ([::1]:50642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVxv7-0006eR-MH for importer@patchew.org; Tue, 05 May 2020 09:47:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVxr4-0000OV-BW for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:26 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:44380 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jVxr1-0003To-9n for qemu-devel@nongnu.org; Tue, 05 May 2020 09:43:26 -0400 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-272-mEpdhyfRP4Cbwn4xJG__xg-1; Tue, 05 May 2020 09:43:20 -0400 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 34EC0461; Tue, 5 May 2020 13:43:19 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-113-193.ams2.redhat.com [10.36.113.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id B39F562482; Tue, 5 May 2020 13:43:18 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 55C919D58; Tue, 5 May 2020 15:43:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588686202; 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=hrIQsYam6cYX95FqmE4LazgkxSySEewBiHZ6lQbYwKc=; b=Q/Aujw1bJzv6s1uBzcxczGi3ObO33wtUqJsQhQBtYhZuYo8UYl0E2hrOOyUv8eYE/5du2W T6uTULdqE7L8h3wd8fwFKF8aBDtGLGJ7/73GqiI0vz4RuAlphoLN/51ry36M26d8WLsmqx ReczfMfIkozOEcQRpPvGP61vpeiGu6c= X-MC-Unique: mEpdhyfRP4Cbwn4xJG__xg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH v2 13/13] microvm/acpi: use GSI 16-23 for virtio Date: Tue, 5 May 2020 15:43:05 +0200 Message-Id: <20200505134305.22666-14-kraxel@redhat.com> In-Reply-To: <20200505134305.22666-1-kraxel@redhat.com> References: <20200505134305.22666-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kraxel@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/05 03:48:16 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Sergio Lopez --- 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 2aa2804e4ca0..08ed2a17f2ca 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -124,7 +124,7 @@ static void microvm_devices_init(MicrovmMachineState *m= ms) =20 kvmclock_create(); =20 - mms->virtio_irq_base =3D 8; + mms->virtio_irq_base =3D x86_machine_is_acpi_enabled(x86ms) ? 16 : 8; for (i =3D 0; i < VIRTIO_NUM_TRANSPORTS; i++) { sysbus_create_simple("virtio-mmio", VIRTIO_MMIO_BASE + i * 512, --=20 2.18.4