Page 1 of 1

ACPI LAI on aarch64

Posted: Wed Nov 02, 2022 1:08 am
by kzinti
I am using LAI (https://github.com/managarm/lai) to add ACPI support to my "OS". This works wonderfully under x86_64. Now under aarch64, it appears to work except it is making unexpected calls to laihost_outb() and laihost_inw() which have no mapping in the ARMv8 world.

The firmware is ovmf-aarch64 (UEFI). and I am using "qemu-system-aarch64 -machine virt".

Here is the relevant part of the log:

Code: Select all

Debug  : [ACPI] attempt to enable ACPI...
Error  : [ACPI] laihost_outb() not implemented: 0, 0
Error  : [ACPI] laihost_sleep() not implemented (10 ms)
Error  : [ACPI] laihost_inw() not implemented: 0
Debug  : [ACPI] wrote event register value 0x8300
Debug  : [ACPI] ACPI is now enabled.
This seems to be happening because of the following code in lai_enable_acpi():

Code: Select all

    /* enable ACPI SCI */
    laihost_outb(instance->fadt->smi_command_port, instance->fadt->acpi_enable);
    laihost_sleep(10);

    for (size_t i = 0; i < 100; i++) {
        if (laihost_inw(instance->fadt->pm1a_control_block) & ACPI_ENABLED)
            break;

        laihost_sleep(10);
    }
I believe this code is not necessary on aarch64? The ACPI spec mentions that FADT::SMI_CMD must be zero on system that do not support System Management mode. If I comment out all of the above (and the check for the existence of laihost_inw / laihost_outb), things appear to work correctly.

I can look into submitting a pull request, but was wondering if I am missing something here.

Re: ACPI LAI on aarch64

Posted: Wed Nov 02, 2022 1:09 am
by kzinti
I am starting to think that I should simply not call lai_enable_acpi() on aarch64... There is nothing in there that seems useful / can work. ACPI is already enabled as far as I can tell and all the fields related to SMI/SCI are zero, including FADT's sci_irq.

Re: ACPI LAI on aarch64

Posted: Wed Nov 02, 2022 12:53 pm
by qookie
Checking the SMI/SCI fields and only enabling it if they're not zero seems like the correct fix to me. Although lai_enable_acpi may still be useful since it invokes all the _INI methods.

EDIT: Now I wonder, how does ACPI report power button events and such if SCI is unsupported?

Re: ACPI LAI on aarch64

Posted: Wed Nov 02, 2022 1:02 pm
by kzinti
My expectation was to find a SCI interrupt number in the FADT table, but I see a zero. This might not be true of other/real aarch64 devices.

Re: ACPI LAI on aarch64

Posted: Wed Nov 02, 2022 3:19 pm
by kzinti
I created a pull request to address this: https://github.com/managarm/lai/pull/132