From patchwork Fri Mar 27 12:11:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 1262773 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HlpK7HfE; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48pgmS63fPz9sP7 for ; Fri, 27 Mar 2020 23:15:36 +1100 (AEDT) Received: from localhost ([::1]:41064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHnte-0002NI-Ax for incoming@patchwork.ozlabs.org; Fri, 27 Mar 2020 08:15:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35346) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHnpg-0005PL-43 for qemu-devel@nongnu.org; Fri, 27 Mar 2020 08:11:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHnpd-0002Of-En for qemu-devel@nongnu.org; Fri, 27 Mar 2020 08:11:27 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:32087) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jHnpd-0002Mp-AJ for qemu-devel@nongnu.org; Fri, 27 Mar 2020 08:11:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585311085; 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=gzkel0+n+eEm5qu560ABS1vOYNgluJp9ebLNb1bJYSc=; b=HlpK7HfEN7p0C4asgmGGpF2ptofBNkRrKIdTHXc0HXdqoukul6l7oDeG+IruEKevO4Zer+ gnMLnxNTJezcOWCNwN2NBiS1/1ftjVA0ofTzELL+OuNKT5cb/1iX45VukOwT36prT9YL4B p2IOpOCU97wQO7qK9UEyppCJyM/r5JM= 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-221-yxLGG3jZMwOyCjBpbJuNeg-1; Fri, 27 Mar 2020 08:11:21 -0400 X-MC-Unique: yxLGG3jZMwOyCjBpbJuNeg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 51BA5100550E; Fri, 27 Mar 2020 12:11:20 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id C958EA0A88; Fri, 27 Mar 2020 12:11:12 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C89B69CA5; Fri, 27 Mar 2020 13:11:11 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 1/6] acpi: split hw/i386/acpi-build.c Date: Fri, 27 Mar 2020 13:11:06 +0100 Message-Id: <20200327121111.1530-2-kraxel@redhat.com> In-Reply-To: <20200327121111.1530-1-kraxel@redhat.com> References: <20200327121111.1530-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Split hw/i386/acpi-build.c into pieces: acpi-build-internal.h Internal header file for acpi-buid-*.c acpi-build-core.c The acpi_setup() function + dependencies. The acpi_build() function simply calls acpi_build_pc() for now, at some point in the future this will dispatch into machine-type specific build functions. acpi-build-pc.c The acpi_build_pc() function + dependencies. The bulk of the old acpi-build.c file is here now. Signed-off-by: Gerd Hoffmann --- hw/i386/acpi-build-internal.h | 35 ++++ hw/i386/acpi-build-core.c | 191 ++++++++++++++++++++++ hw/i386/{acpi-build.c => acpi-build-pc.c} | 175 +------------------- hw/i386/Makefile.objs | 3 +- 4 files changed, 230 insertions(+), 174 deletions(-) create mode 100644 hw/i386/acpi-build-internal.h create mode 100644 hw/i386/acpi-build-core.c rename hw/i386/{acpi-build.c => acpi-build-pc.c} (94%) diff --git a/hw/i386/acpi-build-internal.h b/hw/i386/acpi-build-internal.h new file mode 100644 index 000000000000..5e783d85dde6 --- /dev/null +++ b/hw/i386/acpi-build-internal.h @@ -0,0 +1,35 @@ + +#ifndef HW_I386_ACPI_BUILD_INTERNAL_H +#define HW_I386_ACPI_BUILD_INTERNAL_H + +#include "hw/acpi/aml-build.h" + +/* #define DEBUG_ACPI_BUILD */ +#ifdef DEBUG_ACPI_BUILD +#define ACPI_BUILD_DPRINTF(fmt, ...) \ + do {printf("ACPI_BUILD: " fmt, ## __VA_ARGS__); } while (0) +#else +#define ACPI_BUILD_DPRINTF(fmt, ...) +#endif + +typedef +struct AcpiBuildState { + /* Copy of table in RAM (for patching). */ + MemoryRegion *table_mr; + /* Is table patched? */ + uint8_t patched; + void *rsdp; + MemoryRegion *rsdp_mr; + MemoryRegion *linker_mr; +} AcpiBuildState; + +typedef struct FwCfgTPMConfig { + uint32_t tpmppi_address; + uint8_t tpm_version; + uint8_t tpmppi_version; +} QEMU_PACKED FwCfgTPMConfig; + +/* acpi-build-pc.c */ +void acpi_build_pc(AcpiBuildTables *tables, MachineState *machine); + +#endif diff --git a/hw/i386/acpi-build-core.c b/hw/i386/acpi-build-core.c new file mode 100644 index 000000000000..f0968b4bb594 --- /dev/null +++ b/hw/i386/acpi-build-core.c @@ -0,0 +1,191 @@ +/* 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/tpm.h" +#include "hw/acpi/utils.h" +#include "hw/acpi/vmgenid.h" +#include "hw/boards.h" +#include "hw/i386/pc.h" +#include "migration/vmstate.h" +#include "sysemu/reset.h" +#include "sysemu/tpm.h" + +#include "acpi-build.h" +#include "acpi-build-internal.h" + +static void acpi_build(AcpiBuildTables *tables, MachineState *machine) +{ + acpi_build_pc(tables, machine); +} + +static void acpi_ram_update(MemoryRegion *mr, GArray *data) +{ + uint32_t size = acpi_data_len(data); + + /* Make sure RAM size is correct - in case it got changed e.g. by migration */ + memory_region_ram_resize(mr, size, &error_abort); + + memcpy(memory_region_get_ram_ptr(mr), data->data, size); + memory_region_set_dirty(mr, 0, size); +} + +static void acpi_build_update(void *build_opaque) +{ + AcpiBuildState *build_state = build_opaque; + AcpiBuildTables tables; + + /* No state to update or already patched? Nothing to do. */ + if (!build_state || build_state->patched) { + return; + } + build_state->patched = 1; + + acpi_build_tables_init(&tables); + + acpi_build(&tables, MACHINE(qdev_get_machine())); + + acpi_ram_update(build_state->table_mr, tables.table_data); + + if (build_state->rsdp) { + memcpy(build_state->rsdp, tables.rsdp->data, acpi_data_len(tables.rsdp)); + } else { + acpi_ram_update(build_state->rsdp_mr, tables.rsdp); + } + + acpi_ram_update(build_state->linker_mr, tables.linker->cmd_blob); + acpi_build_tables_cleanup(&tables, true); +} + +static void acpi_build_reset(void *build_opaque) +{ + AcpiBuildState *build_state = build_opaque; + build_state->patched = 0; +} + +static const VMStateDescription vmstate_acpi_build = { + .name = "acpi_build", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT8(patched, AcpiBuildState), + VMSTATE_END_OF_LIST() + }, +}; + +void acpi_setup(void) +{ + PCMachineState *pcms = PC_MACHINE(qdev_get_machine()); + PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); + X86MachineState *x86ms = X86_MACHINE(pcms); + AcpiBuildTables tables; + AcpiBuildState *build_state; + Object *vmgenid_dev; + TPMIf *tpm; + static FwCfgTPMConfig tpm_config; + + if (!x86ms->fw_cfg) { + ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n"); + return; + } + + if (!pcms->acpi_build_enabled) { + ACPI_BUILD_DPRINTF("ACPI build disabled. Bailing out.\n"); + return; + } + + if (!acpi_enabled) { + ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n"); + return; + } + + build_state = g_malloc0(sizeof *build_state); + + acpi_build_tables_init(&tables); + acpi_build(&tables, MACHINE(pcms)); + + /* Now expose it all to Guest */ + build_state->table_mr = acpi_add_rom_blob(acpi_build_update, + build_state, tables.table_data, + ACPI_BUILD_TABLE_FILE, + ACPI_BUILD_TABLE_MAX_SIZE); + assert(build_state->table_mr != NULL); + + build_state->linker_mr = + acpi_add_rom_blob(acpi_build_update, build_state, + tables.linker->cmd_blob, "etc/table-loader", 0); + + fw_cfg_add_file(x86ms->fw_cfg, ACPI_BUILD_TPMLOG_FILE, + tables.tcpalog->data, acpi_data_len(tables.tcpalog)); + + tpm = tpm_find(); + if (tpm && object_property_get_bool(OBJECT(tpm), "ppi", &error_abort)) { + tpm_config = (FwCfgTPMConfig) { + .tpmppi_address = cpu_to_le32(TPM_PPI_ADDR_BASE), + .tpm_version = tpm_get_version(tpm), + .tpmppi_version = TPM_PPI_VERSION_1_30 + }; + fw_cfg_add_file(x86ms->fw_cfg, "etc/tpm/config", + &tpm_config, sizeof tpm_config); + } + + vmgenid_dev = find_vmgenid_dev(); + if (vmgenid_dev) { + vmgenid_add_fw_cfg(VMGENID(vmgenid_dev), x86ms->fw_cfg, + tables.vmgenid); + } + + if (!pcmc->rsdp_in_ram) { + /* + * Keep for compatibility with old machine types. + * Though RSDP is small, its contents isn't immutable, so + * we'll update it along with the rest of tables on guest access. + */ + uint32_t rsdp_size = acpi_data_len(tables.rsdp); + + build_state->rsdp = g_memdup(tables.rsdp->data, rsdp_size); + fw_cfg_add_file_callback(x86ms->fw_cfg, ACPI_BUILD_RSDP_FILE, + acpi_build_update, NULL, build_state, + build_state->rsdp, rsdp_size, true); + build_state->rsdp_mr = NULL; + } else { + build_state->rsdp = NULL; + build_state->rsdp_mr = acpi_add_rom_blob(acpi_build_update, + build_state, tables.rsdp, + ACPI_BUILD_RSDP_FILE, 0); + } + + qemu_register_reset(acpi_build_reset, build_state); + acpi_build_reset(build_state); + vmstate_register(NULL, 0, &vmstate_acpi_build, build_state); + + /* Cleanup tables but don't free the memory: we track it + * in build_state. + */ + acpi_build_tables_cleanup(&tables, false); +} diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build-pc.c similarity index 94% rename from hw/i386/acpi-build.c rename to hw/i386/acpi-build-pc.c index 9a19c14e661b..cad44160ff3a 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build-pc.c @@ -24,6 +24,7 @@ #include "qapi/error.h" #include "qapi/qmp/qnum.h" #include "acpi-build.h" +#include "acpi-build-internal.h" #include "qemu/bitmap.h" #include "qemu/error-report.h" #include "hw/pci/pci.h" @@ -81,14 +82,6 @@ #define ACPI_BUILD_TABLE_SIZE 0x20000 -/* #define DEBUG_ACPI_BUILD */ -#ifdef DEBUG_ACPI_BUILD -#define ACPI_BUILD_DPRINTF(fmt, ...) \ - do {printf("ACPI_BUILD: " fmt, ## __VA_ARGS__); } while (0) -#else -#define ACPI_BUILD_DPRINTF(fmt, ...) -#endif - /* Default IOAPIC ID */ #define ACPI_BUILD_IOAPIC_ID 0x0 @@ -120,12 +113,6 @@ typedef struct AcpiBuildPciBusHotplugState { bool pcihp_bridge_en; } AcpiBuildPciBusHotplugState; -typedef struct FwCfgTPMConfig { - uint32_t tpmppi_address; - uint8_t tpm_version; - uint8_t tpmppi_version; -} QEMU_PACKED FwCfgTPMConfig; - static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg); static void init_common_fadt_data(MachineState *ms, Object *o, @@ -2710,17 +2697,6 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker) "IVRS", table_data->len - iommu_start, 1, NULL, NULL); } -typedef -struct AcpiBuildState { - /* Copy of table in RAM (for patching). */ - MemoryRegion *table_mr; - /* Is table patched? */ - uint8_t patched; - void *rsdp; - MemoryRegion *rsdp_mr; - MemoryRegion *linker_mr; -} AcpiBuildState; - static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) { Object *pci_host; @@ -2746,8 +2722,7 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) return true; } -static -void acpi_build(AcpiBuildTables *tables, MachineState *machine) +void acpi_build_pc(AcpiBuildTables *tables, MachineState *machine) { PCMachineState *pcms = PC_MACHINE(machine); PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); @@ -2948,149 +2923,3 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine) /* Cleanup memory that's no longer used. */ g_array_free(table_offsets, true); } - -static void acpi_ram_update(MemoryRegion *mr, GArray *data) -{ - uint32_t size = acpi_data_len(data); - - /* Make sure RAM size is correct - in case it got changed e.g. by migration */ - memory_region_ram_resize(mr, size, &error_abort); - - memcpy(memory_region_get_ram_ptr(mr), data->data, size); - memory_region_set_dirty(mr, 0, size); -} - -static void acpi_build_update(void *build_opaque) -{ - AcpiBuildState *build_state = build_opaque; - AcpiBuildTables tables; - - /* No state to update or already patched? Nothing to do. */ - if (!build_state || build_state->patched) { - return; - } - build_state->patched = 1; - - acpi_build_tables_init(&tables); - - acpi_build(&tables, MACHINE(qdev_get_machine())); - - acpi_ram_update(build_state->table_mr, tables.table_data); - - if (build_state->rsdp) { - memcpy(build_state->rsdp, tables.rsdp->data, acpi_data_len(tables.rsdp)); - } else { - acpi_ram_update(build_state->rsdp_mr, tables.rsdp); - } - - acpi_ram_update(build_state->linker_mr, tables.linker->cmd_blob); - acpi_build_tables_cleanup(&tables, true); -} - -static void acpi_build_reset(void *build_opaque) -{ - AcpiBuildState *build_state = build_opaque; - build_state->patched = 0; -} - -static const VMStateDescription vmstate_acpi_build = { - .name = "acpi_build", - .version_id = 1, - .minimum_version_id = 1, - .fields = (VMStateField[]) { - VMSTATE_UINT8(patched, AcpiBuildState), - VMSTATE_END_OF_LIST() - }, -}; - -void acpi_setup(void) -{ - PCMachineState *pcms = PC_MACHINE(qdev_get_machine()); - PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); - X86MachineState *x86ms = X86_MACHINE(pcms); - AcpiBuildTables tables; - AcpiBuildState *build_state; - Object *vmgenid_dev; - TPMIf *tpm; - static FwCfgTPMConfig tpm_config; - - if (!x86ms->fw_cfg) { - ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n"); - return; - } - - if (!pcms->acpi_build_enabled) { - ACPI_BUILD_DPRINTF("ACPI build disabled. Bailing out.\n"); - return; - } - - if (!acpi_enabled) { - ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n"); - return; - } - - build_state = g_malloc0(sizeof *build_state); - - acpi_build_tables_init(&tables); - acpi_build(&tables, MACHINE(pcms)); - - /* Now expose it all to Guest */ - build_state->table_mr = acpi_add_rom_blob(acpi_build_update, - build_state, tables.table_data, - ACPI_BUILD_TABLE_FILE, - ACPI_BUILD_TABLE_MAX_SIZE); - assert(build_state->table_mr != NULL); - - build_state->linker_mr = - acpi_add_rom_blob(acpi_build_update, build_state, - tables.linker->cmd_blob, "etc/table-loader", 0); - - fw_cfg_add_file(x86ms->fw_cfg, ACPI_BUILD_TPMLOG_FILE, - tables.tcpalog->data, acpi_data_len(tables.tcpalog)); - - tpm = tpm_find(); - if (tpm && object_property_get_bool(OBJECT(tpm), "ppi", &error_abort)) { - tpm_config = (FwCfgTPMConfig) { - .tpmppi_address = cpu_to_le32(TPM_PPI_ADDR_BASE), - .tpm_version = tpm_get_version(tpm), - .tpmppi_version = TPM_PPI_VERSION_1_30 - }; - fw_cfg_add_file(x86ms->fw_cfg, "etc/tpm/config", - &tpm_config, sizeof tpm_config); - } - - vmgenid_dev = find_vmgenid_dev(); - if (vmgenid_dev) { - vmgenid_add_fw_cfg(VMGENID(vmgenid_dev), x86ms->fw_cfg, - tables.vmgenid); - } - - if (!pcmc->rsdp_in_ram) { - /* - * Keep for compatibility with old machine types. - * Though RSDP is small, its contents isn't immutable, so - * we'll update it along with the rest of tables on guest access. - */ - uint32_t rsdp_size = acpi_data_len(tables.rsdp); - - build_state->rsdp = g_memdup(tables.rsdp->data, rsdp_size); - fw_cfg_add_file_callback(x86ms->fw_cfg, ACPI_BUILD_RSDP_FILE, - acpi_build_update, NULL, build_state, - build_state->rsdp, rsdp_size, true); - build_state->rsdp_mr = NULL; - } else { - build_state->rsdp = NULL; - build_state->rsdp_mr = acpi_add_rom_blob(acpi_build_update, - build_state, tables.rsdp, - ACPI_BUILD_RSDP_FILE, 0); - } - - qemu_register_reset(acpi_build_reset, build_state); - acpi_build_reset(build_state); - vmstate_register(NULL, 0, &vmstate_acpi_build, build_state); - - /* Cleanup tables but don't free the memory: we track it - * in build_state. - */ - acpi_build_tables_cleanup(&tables, false); -} diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs index 8ce1b265335b..e777f1ac9fc3 100644 --- a/hw/i386/Makefile.objs +++ b/hw/i386/Makefile.objs @@ -16,4 +16,5 @@ obj-$(CONFIG_VMMOUSE) += vmmouse.o obj-$(CONFIG_PC) += port92.o obj-y += kvmvapic.o -obj-$(CONFIG_PC) += acpi-build.o +obj-$(CONFIG_PC) += acpi-build-core.o +obj-$(CONFIG_PC) += acpi-build-pc.o From patchwork Fri Mar 27 12:11:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 1262771 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Xh9KyqT+; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48pgkC31rYz9sRR for ; Fri, 27 Mar 2020 23:13:39 +1100 (AEDT) Received: from localhost ([::1]:41040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHnrk-0000H3-8b for incoming@patchwork.ozlabs.org; Fri, 27 Mar 2020 08:13:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35290) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHnpc-0005He-Rm for qemu-devel@nongnu.org; Fri, 27 Mar 2020 08:11:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHnpb-0002Ex-LP for qemu-devel@nongnu.org; Fri, 27 Mar 2020 08:11:24 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:37769) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jHnpb-0002EZ-HK for qemu-devel@nongnu.org; Fri, 27 Mar 2020 08:11:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585311083; 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=P4LbFLFNfhoCRPregA0NOj+Xtp8e0pU8PyiFRkAwvEY=; b=Xh9KyqT+tFrgjz+VSMKelNqG365pLctsGivCPSSHjS460O5Sjuo7upghYLbNUWoZADPE1S U845DeM63484qFt0PwuN74Z1CPIf+gFaY01cZWb6Uc84AZdJ76Cx+AruqfEWkCujES7D5X g/s5a86uNkLSGPTFEGsJNfnF7JEntRA= 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-456-sQoixQBsPq2OD09VpBi-MQ-1; Fri, 27 Mar 2020 08:11:19 -0400 X-MC-Unique: sQoixQBsPq2OD09VpBi-MQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C3967DBA6; Fri, 27 Mar 2020 12:11:18 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC7705DA75; Fri, 27 Mar 2020 12:11:12 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D17232049E; Fri, 27 Mar 2020 13:11:11 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 2/6] acpi: make build_madt() more generic. Date: Fri, 27 Mar 2020 13:11:07 +0100 Message-Id: <20200327121111.1530-3-kraxel@redhat.com> In-Reply-To: <20200327121111.1530-1-kraxel@redhat.com> References: <20200327121111.1530-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Remove PCMachineState dependency from build_madt(). Pass AcpiDeviceIf as separate argument instead of depending on PCMachineState->acpi_dev. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daudé --- hw/i386/acpi-build-pc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/i386/acpi-build-pc.c b/hw/i386/acpi-build-pc.c index cad44160ff3a..a9dbf080566b 100644 --- a/hw/i386/acpi-build-pc.c +++ b/hw/i386/acpi-build-pc.c @@ -347,14 +347,13 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, } static void -build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) +build_madt(GArray *table_data, BIOSLinker *linker, + X86MachineState *x86ms, AcpiDeviceIf *adev) { - MachineClass *mc = MACHINE_GET_CLASS(pcms); - X86MachineState *x86ms = X86_MACHINE(pcms); - const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(MACHINE(pcms)); + MachineClass *mc = MACHINE_GET_CLASS(x86ms); + const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(MACHINE(x86ms)); int madt_start = table_data->len; - AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(pcms->acpi_dev); - AcpiDeviceIf *adev = ACPI_DEVICE_IF(pcms->acpi_dev); + AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(adev); bool x2apic_mode = false; AcpiMultipleApicTable *madt; @@ -2782,7 +2781,8 @@ void acpi_build_pc(AcpiBuildTables *tables, MachineState *machine) aml_len += tables_blob->len - fadt; acpi_add_table(table_offsets, tables_blob); - build_madt(tables_blob, tables->linker, pcms); + build_madt(tables_blob, tables->linker, x86ms, + ACPI_DEVICE_IF(pcms->acpi_dev)); vmgenid_dev = find_vmgenid_dev(); if (vmgenid_dev) { From patchwork Fri Mar 27 12:11:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 1262767 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HSLAQBCo; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48pgh90tQxz9sRR for ; Fri, 27 Mar 2020 23:11:52 +1100 (AEDT) Received: from localhost ([::1]:41010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHnq2-0005Hf-M7 for incoming@patchwork.ozlabs.org; Fri, 27 Mar 2020 08:11:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35224) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHnpb-0005HL-6c for qemu-devel@nongnu.org; Fri, 27 Mar 2020 08:11:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHnpZ-0002AR-Kb for qemu-devel@nongnu.org; Fri, 27 Mar 2020 08:11:22 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:56604) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jHnpZ-00028k-H9 for qemu-devel@nongnu.org; Fri, 27 Mar 2020 08:11:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585311081; 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=Hea1bht1fKA6dt6ayRV0qg1GVJrLQ2Ix4Rni9cAUNxE=; b=HSLAQBCoKjCU2T5HfIg2wWTW1wi6LzMbirGaGAEzAeXbQLlyOUiDtvyqp2Hw607dKkE0TR 49Cx2f9ZcGwxJsoDBuD/A2ZdQsD6pJLEjSlxjXbkxiKjDwYFCDu5qZGPhTUi9E3KaU/mkN 8kIDcCMUtTdZTA15g50Yil0OI2odlNU= 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-371-k1h3eo1vMXeXSp-U3SzBsQ-1; Fri, 27 Mar 2020 08:11:19 -0400 X-MC-Unique: k1h3eo1vMXeXSp-U3SzBsQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8CF5B18C8C01; Fri, 27 Mar 2020 12:11:18 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id B25215C1D4; Fri, 27 Mar 2020 12:11:12 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DA359204A1; Fri, 27 Mar 2020 13:11:11 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 3/6] acpi: factor out acpi_dsdt_add_fw_cfg() Date: Fri, 27 Mar 2020 13:11:08 +0100 Message-Id: <20200327121111.1530-4-kraxel@redhat.com> In-Reply-To: <20200327121111.1530-1-kraxel@redhat.com> References: <20200327121111.1530-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add helper function to add fw_cfg device. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Igor Mammedov --- hw/i386/acpi-build-pc.c | 51 ++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/hw/i386/acpi-build-pc.c b/hw/i386/acpi-build-pc.c index a9dbf080566b..3fdae2984b91 100644 --- a/hw/i386/acpi-build-pc.c +++ b/hw/i386/acpi-build-pc.c @@ -1809,6 +1809,33 @@ static void build_smb0(Aml *table, I2CBus *smbus, int devnr, int func) aml_append(table, scope); } +static void acpi_dsdt_add_fw_cfg(Aml *scope, FWCfgState *fw_cfg) +{ + /* + * when using port i/o, the 8-bit data register *always* overlaps + * with half of the 16-bit control register. Hence, the total size + * of the i/o region used is FW_CFG_CTL_SIZE; when using DMA, the + * DMA control register is located at FW_CFG_DMA_IO_BASE + 4 + */ + Object *obj = OBJECT(fw_cfg); + uint8_t io_size = object_property_get_bool(obj, "dma_enabled", NULL) ? + ROUND_UP(FW_CFG_CTL_SIZE, 4) + sizeof(dma_addr_t) : + FW_CFG_CTL_SIZE; + Aml *dev = aml_device("FWCF"); + Aml *crs = aml_resource_template(); + + aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002"))); + + /* device present, functioning, decoding, not shown in UI */ + aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); + + aml_append(crs, + aml_io(AML_DECODE16, FW_CFG_IO_BASE, FW_CFG_IO_BASE, 0x01, io_size)); + + aml_append(dev, aml_name_decl("_CRS", crs)); + aml_append(scope, dev); +} + static void build_dsdt(GArray *table_data, BIOSLinker *linker, AcpiPmInfo *pm, AcpiMiscInfo *misc, @@ -2088,30 +2115,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, /* create fw_cfg node, unconditionally */ { - /* when using port i/o, the 8-bit data register *always* overlaps - * with half of the 16-bit control register. Hence, the total size - * of the i/o region used is FW_CFG_CTL_SIZE; when using DMA, the - * DMA control register is located at FW_CFG_DMA_IO_BASE + 4 */ - uint8_t io_size = object_property_get_bool(OBJECT(x86ms->fw_cfg), - "dma_enabled", NULL) ? - ROUND_UP(FW_CFG_CTL_SIZE, 4) + sizeof(dma_addr_t) : - FW_CFG_CTL_SIZE; - scope = aml_scope("\\_SB.PCI0"); - dev = aml_device("FWCF"); - - aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002"))); - - /* device present, functioning, decoding, not shown in UI */ - aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); - - crs = aml_resource_template(); - aml_append(crs, - aml_io(AML_DECODE16, FW_CFG_IO_BASE, FW_CFG_IO_BASE, 0x01, io_size) - ); - aml_append(dev, aml_name_decl("_CRS", crs)); - - aml_append(scope, dev); + acpi_dsdt_add_fw_cfg(scope, x86ms->fw_cfg); aml_append(dsdt, scope); } From patchwork Fri Mar 27 12:11:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 1262768 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Z0bwGD+M; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48pghC30Zyz9sP7 for ; Fri, 27 Mar 2020 23:11:55 +1100 (AEDT) Received: from localhost ([::1]:41018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHnq5-0005Lv-Eo for incoming@patchwork.ozlabs.org; Fri, 27 Mar 2020 08:11:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35286) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHnpc-0005Hd-NV for qemu-devel@nongnu.org; Fri, 27 Mar 2020 08:11:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHnpb-0002Ej-Dc for qemu-devel@nongnu.org; Fri, 27 Mar 2020 08:11:24 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:56540) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jHnpb-0002Cl-AE for qemu-devel@nongnu.org; Fri, 27 Mar 2020 08:11:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585311082; 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=iecBE+0B1PGZoq65FTFsNM1AMbDLLSz4/8wfLx6LjOs=; b=Z0bwGD+M4DOsbX8kQgRrTjg06qiB/kdmuy89gwoSQtkm1uzu2xh8NVixJZxGgy9hXwOEyO oGuc1ljo4I4MHToXtfYvnvN5IrwpHZw6eG4pwxHRKKIrUJgmWOgBTEqEejRBYqXtTgZj3r ZK+rVVO+Jf2zXS34+ff6xsR7h2MC8c4= 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-80-qIOTUP2fPRqVXEHceBeNQw-1; Fri, 27 Mar 2020 08:11:20 -0400 X-MC-Unique: qIOTUP2fPRqVXEHceBeNQw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BC3C1DBAB; Fri, 27 Mar 2020 12:11:19 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 492395E01D; Fri, 27 Mar 2020 12:11:19 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id EBA5B31E47; Fri, 27 Mar 2020 13:11:11 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 5/6] acpi: serial: don't use _STA method Date: Fri, 27 Mar 2020 13:11:10 +0100 Message-Id: <20200327121111.1530-6-kraxel@redhat.com> In-Reply-To: <20200327121111.1530-1-kraxel@redhat.com> References: <20200327121111.1530-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The _STA method dates back to the days where we had a static DSDT. The device is listed in the DSDT table unconditionally and the _STA method checks a bit in the isa bridge pci config space to figure whenever a given is isa device is present or not, then evaluates to 0x0f (present) or 0x00 (absent). These days the DSDT is generated by qemu anyway, so if a device is not present we can simply drop it from the DSDT instead. Signed-off-by: Gerd Hoffmann --- hw/i386/acpi-build-pc.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/hw/i386/acpi-build-pc.c b/hw/i386/acpi-build-pc.c index 18ca2fd46961..97af5eac3d79 100644 --- a/hw/i386/acpi-build-pc.c +++ b/hw/i386/acpi-build-pc.c @@ -1204,50 +1204,34 @@ static Aml *build_lpt_device_aml(void) return dev; } -static Aml *build_com_device_aml(uint8_t uid) +static void build_com_device_aml(Aml *scope, uint8_t uid) { Aml *dev; Aml *crs; - Aml *method; - Aml *if_ctx; - Aml *else_ctx; - Aml *zero = aml_int(0); - Aml *is_present = aml_local(0); - const char *enabled_field = "CAEN"; uint8_t irq = 4; uint16_t io_port = 0x03F8; assert(uid == 1 || uid == 2); if (uid == 2) { - enabled_field = "CBEN"; irq = 3; io_port = 0x02F8; } + if (!memory_region_present(get_system_io(), io_port)) { + return; + } dev = aml_device("COM%d", uid); aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0501"))); aml_append(dev, aml_name_decl("_UID", aml_int(uid))); - method = aml_method("_STA", 0, AML_NOTSERIALIZED); - aml_append(method, aml_store(aml_name("%s", enabled_field), is_present)); - if_ctx = aml_if(aml_equal(is_present, zero)); - { - aml_append(if_ctx, aml_return(aml_int(0x00))); - } - aml_append(method, if_ctx); - else_ctx = aml_else(); - { - aml_append(else_ctx, aml_return(aml_int(0x0f))); - } - aml_append(method, else_ctx); - aml_append(dev, method); + aml_append(dev, aml_name_decl("_STA", aml_int(0xf))); crs = aml_resource_template(); aml_append(crs, aml_io(AML_DECODE16, io_port, io_port, 0x00, 0x08)); aml_append(crs, aml_irq_no_flags(irq)); aml_append(dev, aml_name_decl("_CRS", crs)); - return dev; + aml_append(scope, dev); } static void build_isa_devices_aml(Aml *table) @@ -1265,8 +1249,8 @@ static void build_isa_devices_aml(Aml *table) aml_append(scope, build_fdc_device_aml(fdc)); } aml_append(scope, build_lpt_device_aml()); - aml_append(scope, build_com_device_aml(1)); - aml_append(scope, build_com_device_aml(2)); + build_com_device_aml(scope, 1); + build_com_device_aml(scope, 2); if (ambiguous) { error_report("Multiple ISA busses, unable to define IPMI ACPI data"); From patchwork Fri Mar 27 12:11:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 1262772 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Dhc6MZhJ; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48pglF6GzRz9sP7 for ; Fri, 27 Mar 2020 23:14:33 +1100 (AEDT) Received: from localhost ([::1]:41052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHnsd-0001Vs-V9 for incoming@patchwork.ozlabs.org; Fri, 27 Mar 2020 08:14:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35320) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHnpe-0005Jm-74 for qemu-devel@nongnu.org; Fri, 27 Mar 2020 08:11:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHnpd-0002Li-0R for qemu-devel@nongnu.org; Fri, 27 Mar 2020 08:11:25 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:26205) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jHnpc-0002Iu-ST for qemu-devel@nongnu.org; Fri, 27 Mar 2020 08:11:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585311084; 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=PgO6+1B/924aEFh7adFRZ27OOSLbW6GRY9QNhris/8k=; b=Dhc6MZhJ440UXlPO2Q9+POXWV1AdkoWCG6HkLZknhlmQetvV8C7sg5O13CDo3Ys0ybHgaw NHHCl1Ez4aiKS7oa4VYRx9oZY8kqj6xA6eQC7moFkk4rSPaVL52UfO9+vCMsBEf5LLgzfE suU2q0CVVDsm0bHvV38SqWadfVs3h48= 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-80-7u2zgjSYMm-Rs5pRprkzow-1; Fri, 27 Mar 2020 08:11:20 -0400 X-MC-Unique: 7u2zgjSYMm-Rs5pRprkzow-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CB45BDBAC; Fri, 27 Mar 2020 12:11:19 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47409CDBD5; Fri, 27 Mar 2020 12:11:19 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 0019731EA0; Fri, 27 Mar 2020 13:11:11 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 6/6] acpi: parallel: don't use _STA method Date: Fri, 27 Mar 2020 13:11:11 +0100 Message-Id: <20200327121111.1530-7-kraxel@redhat.com> In-Reply-To: <20200327121111.1530-1-kraxel@redhat.com> References: <20200327121111.1530-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The _STA method dates back to the days where we had a static DSDT. The device is listed in the DSDT table unconditionally and the _STA method checks a bit in the isa bridge pci config space to figure whenever a given is isa device is present or not, then evaluates to 0x0f (present) or 0x00 (absent). These days the DSDT is generated by qemu anyway, so if a device is not present we can simply drop it from the DSDT instead. Signed-off-by: Gerd Hoffmann --- hw/i386/acpi-build-pc.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/hw/i386/acpi-build-pc.c b/hw/i386/acpi-build-pc.c index 97af5eac3d79..8bab105d5e44 100644 --- a/hw/i386/acpi-build-pc.c +++ b/hw/i386/acpi-build-pc.c @@ -1169,39 +1169,26 @@ static Aml *build_mouse_device_aml(void) return dev; } -static Aml *build_lpt_device_aml(void) +static void build_lpt_device_aml(Aml *scope) { Aml *dev; Aml *crs; - Aml *method; - Aml *if_ctx; - Aml *else_ctx; - Aml *zero = aml_int(0); - Aml *is_present = aml_local(0); + + if (!memory_region_present(get_system_io(), 0x0378)) { + return; + } dev = aml_device("LPT"); aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0400"))); - method = aml_method("_STA", 0, AML_NOTSERIALIZED); - aml_append(method, aml_store(aml_name("LPEN"), is_present)); - if_ctx = aml_if(aml_equal(is_present, zero)); - { - aml_append(if_ctx, aml_return(aml_int(0x00))); - } - aml_append(method, if_ctx); - else_ctx = aml_else(); - { - aml_append(else_ctx, aml_return(aml_int(0x0f))); - } - aml_append(method, else_ctx); - aml_append(dev, method); + aml_append(dev, aml_name_decl("_STA", aml_int(0xf))); crs = aml_resource_template(); aml_append(crs, aml_io(AML_DECODE16, 0x0378, 0x0378, 0x08, 0x08)); aml_append(crs, aml_irq_no_flags(7)); aml_append(dev, aml_name_decl("_CRS", crs)); - return dev; + aml_append(scope, dev); } static void build_com_device_aml(Aml *scope, uint8_t uid) @@ -1248,7 +1235,7 @@ static void build_isa_devices_aml(Aml *table) if (fdc) { aml_append(scope, build_fdc_device_aml(fdc)); } - aml_append(scope, build_lpt_device_aml()); + build_lpt_device_aml(scope); build_com_device_aml(scope, 1); build_com_device_aml(scope, 2);