From patchwork Wed Jul 24 16:02:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 261447 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 31E132C00A9 for ; Thu, 25 Jul 2013 02:04:34 +1000 (EST) Received: from localhost ([::1]:35593 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V21YG-0006Gd-39 for incoming@patchwork.ozlabs.org; Wed, 24 Jul 2013 12:04:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V21Ug-00024g-5Z for qemu-devel@nongnu.org; Wed, 24 Jul 2013 12:00:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V21Ud-0002OG-0E for qemu-devel@nongnu.org; Wed, 24 Jul 2013 12:00:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18148) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V21Uc-0002OB-Ny for qemu-devel@nongnu.org; Wed, 24 Jul 2013 12:00:46 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r6OG0j2P025895 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 24 Jul 2013 12:00:45 -0400 Received: from redhat.com (vpn-201-81.tlv.redhat.com [10.35.201.81]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id r6OG0hmt016986; Wed, 24 Jul 2013 12:00:44 -0400 Date: Wed, 24 Jul 2013 19:02:07 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1374681580-17439-10-git-send-email-mst@redhat.com> References: <1374681580-17439-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1374681580-17439-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Anthony Liguori Subject: [Qemu-devel] [PATCH v3 09/14] i386: define pc guest info X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This defines a structure that will be used to fill in guest info table. This structure will be filled in in follow-up patches, using QOM. Fill in NUMA node info is not available in QOM so it is filled in directly. Signed-off-by: Michael S. Tsirkin Reviewed-by: Laszlo Ersek Reviewed-by: Gerd Hoffmann --- hw/i386/pc.c | 33 +++++++++++++++++++++++++++++++++ include/hw/i386/pc.h | 31 +++++++++++++++++++++++++++++++ include/qemu/typedefs.h | 1 + 3 files changed, 65 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index b0b98a8..b9b8f92 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1017,6 +1017,27 @@ static void pc_fw_cfg_guest_info(PcGuestInfo *guest_info) fw_cfg_add_file(guest_info->fw_cfg, "etc/pci-info", info, sizeof *info); } +static void pc_set_cpu_guest_info(CPUState *cpu, void *arg) +{ + PcGuestInfo *guest_info = arg; + CPUClass *klass = CPU_GET_CLASS(cpu); + uint64_t apic_id = klass->get_arch_id(cpu); + int j; + + assert(apic_id <= MAX_CPUMASK_BITS); + assert(apic_id < guest_info->apic_id_limit); + + set_bit(apic_id, guest_info->found_cpus); + + for (j = 0; j < guest_info->numa_nodes; j++) { + assert(cpu->cpu_index < max_cpus); + if (test_bit(cpu->cpu_index, node_cpumask[j])) { + guest_info->node_cpu[apic_id] = cpu_to_le64(j); + break; + } + } +} + typedef struct PcGuestInfoState { PcGuestInfo info; Notifier machine_done; @@ -1037,6 +1058,18 @@ PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size, PcGuestInfoState *guest_info_state = g_malloc0(sizeof *guest_info_state); PcGuestInfo *guest_info = &guest_info_state->info; + guest_info->ram_size = below_4g_mem_size + above_4g_mem_size; + guest_info->apic_id_limit = pc_apic_id_limit(max_cpus); + guest_info->apic_xrupt_override = kvm_allows_irq0_override(); + guest_info->numa_nodes = nb_numa_nodes; + guest_info->node_mem = g_memdup(node_mem, guest_info->numa_nodes * + sizeof *guest_info->node_mem); + guest_info->node_cpu = g_malloc0(guest_info->apic_id_limit * + sizeof *guest_info->node_cpu); + + memset(&guest_info->found_cpus, 0, sizeof guest_info->found_cpus); + qemu_for_each_cpu(pc_set_cpu_guest_info, guest_info); + guest_info->pci_info.w32.end = IO_APIC_DEFAULT_ADDRESS; if (sizeof(hwaddr) == 4) { guest_info->pci_info.w64.begin = 0; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 7fb97b0..7c0bd50 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -9,6 +9,9 @@ #include "hw/i386/ioapic.h" #include "qemu/range.h" +#include "qemu/bitmap.h" +#include "sysemu/sysemu.h" +#include "hw/pci/pci.h" /* PC-style peripherals (also used by other machines). */ @@ -17,9 +20,37 @@ typedef struct PcPciInfo { Range w64; } PcPciInfo; +/* Matches the value hard-coded in BIOS */ +#define PC_GUEST_PORT_ACPI_PM_BASE 0xb000 + +struct AcpiPmInfo { + bool s3_disabled; + bool s4_disabled; + uint8_t s4_val; + uint16_t sci_int; + uint8_t acpi_enable_cmd; + uint8_t acpi_disable_cmd; + uint32_t gpe0_blk; + uint32_t gpe0_blk_len; +}; + struct PcGuestInfo { PcPciInfo pci_info; bool has_pci_info; + hwaddr ram_size; + unsigned apic_id_limit; + bool apic_xrupt_override; + bool has_hpet; + uint64_t numa_nodes; + uint64_t *node_mem; + uint64_t *node_cpu; + DECLARE_BITMAP(found_cpus, MAX_CPUMASK_BITS + 1); + DECLARE_BITMAP(slot_hotplug_enable, PCI_SLOT_MAX); + AcpiPmInfo pm; + uint64_t mcfg_base; + const unsigned char *dsdt_code; + unsigned dsdt_size; + uint16_t pvpanic_port; FWCfgState *fw_cfg; }; diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index ac9f8d4..cb66e19 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -65,5 +65,6 @@ typedef struct QEMUSGList QEMUSGList; typedef struct SHPCDevice SHPCDevice; typedef struct FWCfgState FWCfgState; typedef struct PcGuestInfo PcGuestInfo; +typedef struct AcpiPmInfo AcpiPmInfo; #endif /* QEMU_TYPEDEFS_H */