qemu-e2k/include/hw/acpi
Andrew Jones 099f2df2e6 hw/acpi/aml-build: Add PPTT table
Add the Processor Properties Topology Table (PPTT) used to
describe CPU topology information to ACPI guests.

Note, a DT-boot Linux guest with a non-flat CPU topology will
see socket and core IDs being sequential integers starting
from zero, which is different from ACPI-boot Linux guest,
e.g. with -smp 4,sockets=2,cores=2,threads=1

a DT boot produces:

 cpu:  0 package_id:  0 core_id:  0
 cpu:  1 package_id:  0 core_id:  1
 cpu:  2 package_id:  1 core_id:  0
 cpu:  3 package_id:  1 core_id:  1

an ACPI boot produces:

 cpu:  0 package_id: 36 core_id:  0
 cpu:  1 package_id: 36 core_id:  1
 cpu:  2 package_id: 96 core_id:  2
 cpu:  3 package_id: 96 core_id:  3

This is due to several reasons:

 1) DT cpu nodes do not have an equivalent field to what the PPTT
    ACPI Processor ID must be, i.e. something equal to the MADT CPU
    UID or equal to the UID of an ACPI processor container. In both
    ACPI cases those are platform dependant IDs assigned by the
    vendor.

 2) While QEMU is the vendor for a guest, if the topology specifies
    SMT (> 1 thread), then, with ACPI, it is impossible to assign a
    core-id the same value as a package-id, thus it is not possible
    to have package-id=0 and core-id=0. This is because package and
    core containers must be in the same ACPI namespace and therefore
    must have unique UIDs.

 3) ACPI processor containers are not mandatorily required for PPTT
    tables to be used and, due to the limitations of which IDs are
    selected described above in (2), they are not helpful for QEMU,
    so we don't build them with this patch. In the absence of them,
    Linux assigns its own unique IDs. The maintainers have chosen not
    to use counters from zero, but rather ACPI table offsets, which
    explains why the numbers are so much larger than with DT.

 4) When there is no SMT (threads=1) the core IDs for ACPI boot guests
    match the logical CPU IDs, because these IDs must be equal to the
    MADT CPU UID (as no processor containers are present), and QEMU
    uses the logical CPU ID for these MADT IDs.

So in summary, with QEMU as the vendor for the guests, we simply
use sequential integers starting from zero for the non-leaf nodes
but with ID-valid flag unset, so that guest will ignore them and
use table offsets as unique container IDs. And we use logical CPU
IDs for the leaf nodes with the ID-valid flag set, which will be
consistent with MADT.

Currently the implementation of PPTT generation complies with ACPI
specification 5.2.29 (Revision 6.3). The 6.3 spec can be found at:
https://uefi.org/sites/default/files/resources/ACPI_6_3_May16.pdf

Reviewed-by: Eric Auger <eric.auger@redhat.com>
Co-developed-by: Yanan Wang <wangyanan55@huawei.com>
Signed-off-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20211020142125.7516-6-wangyanan55@huawei.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-10-21 08:03:58 -07:00
..
acpi_dev_interface.h acpi: x86: set enabled when composing _MAT entries 2021-10-05 17:30:57 -04:00
acpi-defs.h acpi: AcpiGenericAddress no longer used to map/access fields of MMIO, drop packed attribute 2021-10-05 17:30:57 -04:00
acpi.h hw/acpi: define PIIX4 acpi pci hotplug property strings at a single place 2021-09-04 09:07:45 -04:00
aml-build.h hw/acpi/aml-build: Add PPTT table 2021-10-21 08:03:58 -07:00
bios-linker-loader.h
cpu_hotplug.h
cpu.h x86: acpi: let the firmware handle pending "CPU remove" events in SMM 2020-12-09 13:04:17 -05:00
generic_event_device.h acpi: Delete broken ACPI_GED_X86 macro 2021-09-04 09:07:46 -04:00
ghes.h hw/acpi: Provide function acpi_ghes_present() 2021-06-21 16:49:37 +01:00
ich9.h hw/i386/acpi: fix conflicting IO address range for acpi pci hotplug in q35 2021-10-05 17:30:57 -04:00
ipmi.h
memory_hotplug.h
pc-hotplug.h
pci.h pci: acpi: add _DSM method to PCI devices 2021-03-22 18:58:19 -04:00
pcihp.h hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35 2021-07-16 04:33:34 -04:00
tco.h
tpm.h acpi: Eliminate all TPM related code if CONFIG_TPM is not set 2021-06-15 10:55:03 -04:00
utils.h acpi: Move maximum size logic into acpi_add_rom_blob() 2021-03-22 18:58:19 -04:00
vmgenid.h acpi: Permit OEM ID and OEM table ID fields to be changed 2021-02-05 08:52:59 -05:00