From nobody Sun Feb 8 09:32:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1557728745; cv=none; d=zoho.com; s=zohoarc; b=aLRIewKlfwe0peV07hKRBhOYEdYMKfXrg/kb6ryoUidYQAk3Fe1puygP+10QOfJu4iZg9wupoQ1OH8+t848VxEnnZPFRwLANKCQKcelK9ZdPb4v73v5ObR2WGtyw6zng6v0Wn7MtJ5IDY5zs7CtsefEGRXrLqmVLzHrkL7iq/Jo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557728745; h=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:ARC-Authentication-Results; bh=8YGVkTXAPDgMtJ+9g/jht7GhZFZGwLIT9PMSqpOr0rU=; b=TKDEbTZX+42DkCZIN+oPiNgniP6LFTOPQflbVLHnQZNjCbkP5tbm6sZl3MVg/jPbS7mp28Km9y9gbktsGzbeQjsOpgzV9NYYS1LQENTpsLl7UFDwTF5wP53tM2nZdTdsXpB4/dwdme8pbbUjI0AU47tWsj0pI+NkNw0m942TIqo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1557728745538616.315857823895; Sun, 12 May 2019 23:25:45 -0700 (PDT) Received: from localhost ([127.0.0.1]:51809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4P8-0007UK-Ep for importer@patchew.org; Mon, 13 May 2019 02:25:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35349) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4Jy-00037V-Fj for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQ4Jx-0004eq-3I for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:22 -0400 Received: from mga07.intel.com ([134.134.136.100]:24552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQ4Jw-0004ds-Qi for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:21 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 May 2019 23:20:19 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga003.jf.intel.com with ESMTP; 12 May 2019 23:20:17 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 From: Wei Yang To: qemu-devel@nongnu.org Date: Mon, 13 May 2019 14:19:05 +0800 Message-Id: <20190513061913.9284-2-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190513061913.9284-1-richardw.yang@linux.intel.com> References: <20190513061913.9284-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.100 Subject: [Qemu-devel] [RFC PATCH 1/9] hw/acpi: expand pc_madt_cpu_entry in place X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yang.zhong@intel.com, ehabkost@redhat.com, mst@redhat.com, Wei Yang , pbonzini@redhat.com, imammedo@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This is a preparation for MADT refactor. Signed-off-by: Wei Yang --- hw/acpi/cpu.c | 33 +++++++++++-- hw/acpi/piix4.c | 1 - hw/i386/acpi-build.c | 71 ++++++++++++---------------- hw/isa/lpc_ich9.c | 1 - include/hw/acpi/acpi_dev_interface.h | 6 --- 5 files changed, 59 insertions(+), 53 deletions(-) diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index 7a90c8f82d..d786df1a2c 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -329,7 +329,7 @@ void build_cpus_aml(Aml *table, MachineState *machine, = CPUHotplugFeatures opts, char *cphp_res_path =3D g_strdup_printf("%s." CPUHP_RES_DEVICE, res_ro= ot); Object *obj =3D object_resolve_path_type("", TYPE_ACPI_DEVICE_IF, NULL= ); AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_GET_CLASS(obj); - AcpiDeviceIf *adev =3D ACPI_DEVICE_IF(obj); + uint32_t apic_id; =20 cpu_ctrl_dev =3D aml_device("%s", cphp_res_path); { @@ -522,8 +522,35 @@ void build_cpus_aml(Aml *table, MachineState *machine,= CPUHotplugFeatures opts, aml_append(dev, method); =20 /* build _MAT object */ - assert(adevc && adevc->madt_cpu); - adevc->madt_cpu(adev, i, arch_ids, madt_buf); + assert(adevc); + apic_id =3D arch_ids->cpus[i].arch_id; + if (apic_id < 255) { + AcpiMadtProcessorApic *apic =3D acpi_data_push(madt_buf, + sizeof *apic); + + apic->type =3D ACPI_APIC_PROCESSOR; + apic->length =3D sizeof(*apic); + apic->processor_id =3D i; + apic->local_apic_id =3D apic_id; + if (arch_ids->cpus[i].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(madt_buf, + sizeof *api= c); + + apic->type =3D ACPI_APIC_LOCAL_X2APIC; + apic->length =3D sizeof(*apic); + apic->uid =3D cpu_to_le32(i); + apic->x2apic_id =3D cpu_to_le32(apic_id); + if (arch_ids->cpus[i].cpu !=3D NULL) { + apic->flags =3D cpu_to_le32(1); + } else { + apic->flags =3D cpu_to_le32(0); + } + } switch (madt_buf->data[0]) { case ACPI_APIC_PROCESSOR: { AcpiMadtProcessorApic *apic =3D (void *)madt_buf->data; diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 9c079d6834..76fde125a3 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -722,7 +722,6 @@ static void piix4_pm_class_init(ObjectClass *klass, voi= d *data) hc->unplug =3D piix4_device_unplug_cb; adevc->ospm_status =3D piix4_ospm_status; adevc->send_event =3D piix4_send_gpe; - adevc->madt_cpu =3D pc_madt_cpu_entry; } =20 static const TypeInfo piix4_pm_info =3D { diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 29980bb3f4..54b70e62ac 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -301,52 +301,12 @@ 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, PCMachineState *pcms) { MachineClass *mc =3D MACHINE_GET_CLASS(pcms); const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(MACHINE(pc= ms)); 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); bool x2apic_mode =3D false; =20 AcpiMultipleApicTable *madt; @@ -359,8 +319,35 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCM= achineState *pcms) madt->flags =3D cpu_to_le32(1); =20 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) { + uint32_t apic_id =3D apic_ids->cpus[i].arch_id; + if (apic_id < 255) { + AcpiMadtProcessorApic *apic =3D acpi_data_push(table_data, + sizeof *apic); + + apic->type =3D ACPI_APIC_PROCESSOR; + apic->length =3D sizeof(*apic); + apic->processor_id =3D i; + apic->local_apic_id =3D apic_id; + if (apic_ids->cpus[i].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(table_data, + sizeof *apic); + + apic->type =3D ACPI_APIC_LOCAL_X2APIC; + apic->length =3D sizeof(*apic); + apic->uid =3D cpu_to_le32(i); + apic->x2apic_id =3D cpu_to_le32(apic_id); + if (apic_ids->cpus[i].cpu !=3D NULL) { + apic->flags =3D cpu_to_le32(1); + } else { + apic->flags =3D cpu_to_le32(0); + } + } + if (apic_id > 254) { x2apic_mode =3D true; } } diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index ac44aa53be..8e00504cd9 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -811,7 +811,6 @@ static void ich9_lpc_class_init(ObjectClass *klass, voi= d *data) hc->unplug =3D ich9_pm_device_unplug_cb; adevc->ospm_status =3D ich9_pm_ospm_status; adevc->send_event =3D ich9_send_gpe; - adevc->madt_cpu =3D pc_madt_cpu_entry; } =20 static const TypeInfo ich9_lpc_info =3D { diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_de= v_interface.h index 43ff119179..160b785045 100644 --- a/include/hw/acpi/acpi_dev_interface.h +++ b/include/hw/acpi/acpi_dev_interface.h @@ -35,10 +35,6 @@ void acpi_send_event(DeviceState *dev, AcpiEventStatusBi= ts event); * ospm_status: returns status of ACPI device objects, reported * via _OST method if device supports it. * send_event: inject a specified event into guest - * madt_cpu: fills @entry with Interrupt Controller Structure - * for CPU indexed by @uid in @apic_ids array, - * returned structure types are: - * 0 - Local APIC, 9 - Local x2APIC, 0xB - GICC * * Interface is designed for providing unified interface * to generic ACPI functionality that could be used without @@ -52,7 +48,5 @@ typedef struct AcpiDeviceIfClass { /* */ void (*ospm_status)(AcpiDeviceIf *adev, ACPIOSTInfoList ***list); void (*send_event)(AcpiDeviceIf *adev, AcpiEventStatusBits ev); - void (*madt_cpu)(AcpiDeviceIf *adev, int uid, - const CPUArchIdList *apic_ids, GArray *entry); } AcpiDeviceIfClass; #endif --=20 2.19.1