Skip to contentSkip to conversation

Regarding presence of duplicate ACPI CPU entries at two nodes \\_SB.CXXX and \\_SB.CPUS.CXXX of namespace

Question Salil Mehta 1 participant 2 messages Jan 29, 2020

lore
Share & tools
lore
#0 lore raw

Hello,

Observation:
If we launch Linux Guest VM using QEMU(running on any type host. I am using x86) with CPU based on any ARM64 architecture then I could see QEMU populating ACPI nodes related to same CPU at 2 places of the ACPI namespace:
1. \\_SB.CXXX
2. \\_SB.CPUS.CXXX

Above results in Guest VM showing duplicate CPU entries in the sysfs for the same CPUS. I could make out the entries under \\_SB.CPUS.XXX are part of the container.

estuary:/$ ls -al /sys/bus/acpi/devices/

Observation 1: (belongs to \\_SB.C00X)
ACPI0007:00 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0007:00 ACPI0007:01 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0007:01 ACPI0007:02 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0007:02 ACPI0007:03 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0007:03 ACPI0007:04 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0007:04 ACPI0007:05 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0007:05

Observation 2: (belongs to \\_SB.CPUS.C00X and under container ACPI0010:00 part of \\_SB.CPUS) ACPI0007:06 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0010:00/ACPI0007:06 ACPI0007:07 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0010:00/ACPI0007:07 ACPI0007:08 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0010:00/ACPI0007:08 ACPI0007:09 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0010:00/ACPI0007:09 ACPI0007:0a -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0010:00/ACPI0007:0a ACPI0007:0b -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0010:00/ACPI0007:0b ACPI0010:00 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0010:00

estuary:/$ cat /sys/bus/acpi/devices/ACPI0010\:00/path 
\_SB_.CPUS
estuary:/$ cat /sys/bus/acpi/devices/ACPI0007\:00/uid 
0
estuary:/$ cat /sys/bus/acpi/devices/ACPI0007\:00/path
\_SB_.C000
estuary:/$ cat /sys/bus/acpi/devices/ACPI0007\:06/uid 
0
estuary:/$ cat /sys/bus/acpi/devices/ACPI0007\:06/path
\_SB_.CPUS.C000

QEMU Code Excerpt:
I could trace with in QEMU AML code, the CPUS are being appended at 2 places:

Code 1. File: hw/arm/virt-acpi-build.c (Cause of Observation 1 i.e. \\_SB.CXXX )

static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus)

{
    uint16_t i;

    for (i = 0; i < smp_cpus; i++) { --->{should be possible cpus anyways}
        Aml *dev = aml_device("C%.03X", i);
        aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0007")));
        aml_append(dev, aml_name_decl("_UID", aml_int(i)));
        aml_append(scope, dev);
    }
}

Code 2. File: hw/acpi/cpu.c (Cause of Observation 2 i.e. \\_SB.CPUS.CXXX)

void build_cpus_aml(..)
{
[...]
cpus_dev = aml_device("\\_SB.CPUS");

  {
    [...]
            /* build Processor object for each processor */
        for (i = 0; i < arch_ids->len; i++) {
            Aml *dev;
            Aml *uid = aml_int(i);
            GArray *madt_buf = g_array_new(0, 1, 1);
            int arch_id = arch_ids->cpus[i].arch_id;

            if (opts.acpi_1_compatible && arch_id < 255) {
                dev = aml_processor(i, 0, 0, CPU_NAME_FMT, i);
            } else {
                dev = aml_device(CPU_NAME_FMT, i);
                aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0007")));
                aml_append(dev, aml_name_decl("_UID", uid));
            }
    [...]

}
[...]
}

Questions:
Q1. I could not understand the purpose of keeping acpi_dsdt_add_cpus() after the code 2.
was introduced as part of the below change and which is already adding CPUS related AML to \\_SB.CPUS namespace?

acpi: cpuhp: add CPU devices AML with _STA method
commit 5e1b5d93887b52eede156f846b6c4c5c8bbcfcdb

Q2. Do we really require CPUs being added by acpi_dsdt_add_cpus() in \\_SB.CXXX
Namespace OR is it a stray code left?

Please help to correct if there is a gap in my understanding here and please forgive me if I have terribly missed out something very basic here.

Many thanks!

Best Regards
Salil

#1 lore raw

Please ignore this!

Quoted 138 lines

From: Linuxarm [mailto:[email protected]] On Behalf Of Salil Mehta
Sent: Wednesday, January 29, 2020 11:51 AM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Linuxarm <[email protected]>; [email protected]; pbonzini <[email protected]>; Igor Mammedov <[email protected]>; [email protected]
Subject: [Question] Regarding presence of duplicate ACPI CPU entries at two nodes \\_SB.CXXX and \\_SB.CPUS.CXXX of namespace

Hello,

Observation:
If we launch Linux Guest VM using QEMU(running on any type host. I am using x86) with
CPU based on any ARM64 architecture then I could see QEMU populating ACPI nodes related to same CPU at 2 places of the ACPI namespace:
1. \\_SB.CXXX
2. \\_SB.CPUS.CXXX

Above results in Guest VM showing duplicate CPU entries in the sysfs for the same CPUS.
I could make out the entries under \\_SB.CPUS.XXX are part of the container.

estuary:/$ ls -al /sys/bus/acpi/devices/

Observation 1: (belongs to \\_SB.C00X)
ACPI0007:00 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0007:00 ACPI0007:01 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0007:01 ACPI0007:02 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0007:02 ACPI0007:03 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0007:03 ACPI0007:04 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0007:04 ACPI0007:05 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0007:05

Observation 2: (belongs to \\_SB.CPUS.C00X and under container ACPI0010:00 part of \\_SB.CPUS)
ACPI0007:06
-> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0010:00/ACPI0007:06 ACPI0007:07
-> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0010:00/ACPI0007:07 ACPI0007:08
-> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0010:00/ACPI0007:08 ACPI0007:09
-> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0010:00/ACPI0007:09 ACPI0007:0a
-> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0010:00/ACPI0007:0a ACPI0007:0b
-> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0010:00/ACPI0007:0b ACPI0010:00 -> ../../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0010:00

estuary:/$ cat /sys/bus/acpi/devices/ACPI0010\:00/path
\_SB_.CPUS
estuary:/$ cat /sys/bus/acpi/devices/ACPI0007\:00/uid
0
estuary:/$ cat /sys/bus/acpi/devices/ACPI0007\:00/path
\_SB_.C000
estuary:/$ cat /sys/bus/acpi/devices/ACPI0007\:06/uid
0
estuary:/$ cat /sys/bus/acpi/devices/ACPI0007\:06/path
\_SB_.CPUS.C000

QEMU Code Excerpt:
I could trace with in QEMU AML code, the CPUS are being appended at 2 places:

Code 1. File: hw/arm/virt-acpi-build.c (Cause of Observation 1 i.e. \\_SB.CXXX )

static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus)

{
    uint16_t i;

    for (i = 0; i < smp_cpus; i++) { --->{should be possible cpus anyways}
        Aml *dev = aml_device("C%.03X", i);
        aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0007")));
        aml_append(dev, aml_name_decl("_UID", aml_int(i)));
        aml_append(scope, dev);
    }
}

Code 2. File: hw/acpi/cpu.c (Cause of Observation 2 i.e. \\_SB.CPUS.CXXX)

void build_cpus_aml(..)
{
[...]
cpus_dev = aml_device("\\_SB.CPUS");

  {
    [...]
            /* build Processor object for each processor */
        for (i = 0; i < arch_ids->len; i++) {
            Aml *dev;
            Aml *uid = aml_int(i);
            GArray *madt_buf = g_array_new(0, 1, 1);
            int arch_id = arch_ids->cpus[i].arch_id;

            if (opts.acpi_1_compatible && arch_id < 255) {
                dev = aml_processor(i, 0, 0, CPU_NAME_FMT, i);
            } else {
                dev = aml_device(CPU_NAME_FMT, i);
                aml_append(dev, aml_name_decl("_HID",
aml_string("ACPI0007")));
                aml_append(dev, aml_name_decl("_UID", uid));
            }
    [...]

}
[...]
}

Questions:
Q1. I could not understand the purpose of keeping acpi_dsdt_add_cpus() after the code 2.
was introduced as part of the below change and which is already adding CPUS
related
AML to \\_SB.CPUS namespace?

acpi: cpuhp: add CPU devices AML with _STA method
commit 5e1b5d93887b52eede156f846b6c4c5c8bbcfcdb

Q2. Do we really require CPUs being added by acpi_dsdt_add_cpus() in \\_SB.CXXX
Namespace OR is it a stray code left?

Please help to correct if there is a gap in my understanding here and please forgive me if I have terribly missed out something very basic here.

Many thanks!

Best Regards
Salil