hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table
v6 cover hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table
This can allow the guest OS to determine more easily if i8042 controller is present in the system or not, so it doesn't need to do probing of the controller, but just initialize it immediately, before enumerating the ACPI AML namespace.
To allow "flexible" indication, I don't hardcode the bit at location 1 as on in the IA-PC boot flags, but try to search for i8042 on the ISA bus to verify it exists in the system.
Why this is useful you might ask - this patch allows the guest OS to probe and use the i8042 controller without decoding the ACPI AML blob at all. For example, as a developer of the SerenityOS kernel, I might want to allow people to not try to decode the ACPI AML namespace (for now, we still don't support ACPI AML as it's a work in progress), but still to not probe for the i8042 but just use it after looking in the IA-PC boot flags in the ACPI FADT table.
Changelog:
v6:
addressed comments from v5. added microvm changes too as a part of this series. v5:
Addressed review comments from v4. Also got rid of microvm changes. Will send them in a separate patch.
Ani Sinha (1):
hw/acpi/microvm: turn on 8042 bit in FADT boot architecture flags if
present
Liav Albani (3):
tests/acpi: i386: allow FACP acpi table changes hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT
table
tests/acpi: i386: update FACP table differences
hw/acpi/aml-build.c | 8 +++++++- hw/i386/acpi-build.c | 8 ++++++++ hw/i386/acpi-microvm.c | 6 ++++++ include/hw/acpi/acpi-defs.h | 1 + include/hw/input/i8042.h | 15 +++++++++++++++ tests/data/acpi/q35/FACP | Bin 244 -> 244 bytes tests/data/acpi/q35/FACP.nosmm | Bin 244 -> 244 bytes tests/data/acpi/q35/FACP.slic | Bin 244 -> 244 bytes tests/data/acpi/q35/FACP.xapic | Bin 244 -> 244 bytes 9 files changed, 37 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
PATCH v6 1/4 tests/acpi: i386: allow FACP acpi table changes
From: Liav Albani <[email protected]>
The FACP table is going to be changed for x86/q35 machines. To be sure the following changes are not breaking any QEMU test this change follows step 2 from the bios-tables-test.c guide on changes that affect ACPI tables.
--- tests/qtest/bios-tables-test-allowed-diff.h | 4 ++++ 1 file changed, 4 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +4 -0
@@ -1 +1,5 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/FACP" , +"tests/data/acpi/q35/FACP.nosmm" , +"tests/data/acpi/q35/FACP.slic" , +"tests/data/acpi/q35/FACP.xapic",
Signature · 1 line
2.25.1
Re: [PATCH v6 1/4] tests/acpi: i386: allow FACP acpi table changes
Quoted 18 lines · Ani Sinha
From: Liav Albani <[email protected]>
The FACP table is going to be changed for x86/q35 machines. To be sure the following changes are not breaking any QEMU test this change follows step 2 from the
bios-tables-test.cguide on changes that affect ACPI tables.Signed-off-by Liav Albani <[email protected]>Acked-by Ani Sinha <[email protected]>--- tests/qtest/bios-tables-test-allowed-diff.h | 4 ++++ 1 file changed, 4 insertions(+)tests/qtest/bios-tables-test-allowed-diff.h +0
-0
tests/qtest/bios-tables-test-allowed-diff.h line 5
Quoted 5 lines
tests/qtest/bios-tables-test-allowed-diff.h +4
-0@@ -1 +1,5 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/FACP" , +"tests/data/acpi/q35/FACP.nosmm" , +"tests/data/acpi/q35/FACP.slic" , +"tests/data/acpi/q35/FACP.xapic",
For me make check fails with the changes in patch 2. what about the rest of q35 FACP tables?
Quoted 2 lines
Signature · 1 line
2.25.1
Re: [PATCH v6 1/4] tests/acpi: i386: allow FACP acpi table changes
Quoted 15 lines · Michael S. Tsirkin
Quoted 13 lines · Ani Sinha
From: Liav Albani <[email protected]>
The FACP table is going to be changed for x86/q35 machines. To be sure the following changes are not breaking any QEMU test this change follows step 2 from the
bios-tables-test.cguide on changes that affect ACPI tables.Signed-off-by Liav Albani <[email protected]>Acked-by Ani Sinha <[email protected]>--- tests/qtest/bios-tables-test-allowed-diff.h | 4 ++++ 1 file changed, 4 insertions(+)
Quoted 13 lines
tests/qtest/bios-tables-test-allowed-diff.h line 5
Quoted 10 lines
tests/qtest/bios-tables-test-allowed-diff.h +4
-0@@ -1 +1,5 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/FACP" , +"tests/data/acpi/q35/FACP.nosmm" , +"tests/data/acpi/q35/FACP.slic" , +"tests/data/acpi/q35/FACP.xapic",For me make check fails with the changes in patch 2. what about the rest of q35 FACP tables?
This is what I have :
anisinha@anisinha-lenovo:~/workspace/qemu/tests/data/acpi/q35$ ls -l FACP* -rw-rw-r-- 1 anisinha anisinha 244 Mar 4 21:07 FACP -rw-rw-r-- 1 anisinha anisinha 244 Mar 4 21:07 FACP.nosmm -rw-rw-r-- 1 anisinha anisinha 244 Mar 4 21:07 FACP.slic -rw-rw-r-- 1 anisinha anisinha 244 Mar 4 21:07 FACP.xapic
Do you have some more tables? Strange!
PATCH v6 2/4 hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table
In reply to Ani SinhaFrom: Liav Albani <[email protected]>
This can allow the guest OS to determine more easily if i8042 controller is present in the system or not, so it doesn't need to do probing of the controller, but just initialize it immediately, before enumerating the ACPI AML namespace.
The 8042 bit in IAPC_BOOT_ARCH was introduced from ACPI spec v2 (FADT revision 2 and above). Therefore, in this change, we only enable this bit for x86/q35 machine types since x86/i440fx machines use FADT ACPI table with revision 1.
--- hw/acpi/aml-build.c | 8 +++++++- hw/i386/acpi-build.c | 8 ++++++++ include/hw/acpi/acpi-defs.h | 1 + include/hw/input/i8042.h | 15 +++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-)
hw/acpi/aml-build.c +7 -1
@@ -2152,7 +2152,13 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f,build_append_int_noprefix (tbl,0 ,1 );/* DAY_ALRM */ build_append_int_noprefix (tbl,0 ,1 );/* MON_ALRM */ build_append_int_noprefix (tbl, f->rtc_century,1 );/* CENTURY */ -build_append_int_noprefix (tbl,0 ,2 );/* IAPC_BOOT_ARCH */ +/* IAPC_BOOT_ARCH */ +if (f->rev ==1 ) { +build_append_int_noprefix (tbl,0 ,2 ); + }else { +/* since ACPI v2.0 */ +build_append_int_noprefix (tbl, f->iapc_boot_arch,2 ); + }build_append_int_noprefix (tbl,0 ,1 );/* Reserved */ build_append_int_noprefix (tbl, f->flags,4 );/* Flags */
hw/i386/acpi-build.c +8 -0
@@ -38,6 +38,7 @@#include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" #include "hw/isa/isa.h" +#include "hw/input/i8042.h" #include "hw/block/fdc.h" #include "hw/acpi/memory_hotplug.h" #include "sysemu/tpm.h"
@@ -192,6 +193,13 @@ static void init_common_fadt_data(MachineState *ms, Object *o, .address = object_property_get_uint(o, ACPI_PM_PROP_GPE0_BLK, NULL) }, }; + +/* +* ACPI v2, Table 5-10 - Fixed ACPI Description Table Boot Architecture +* Flags, bit offset 1 - 8042. +*/ + fadt.iapc_boot_arch =iapc_boot_arch_8042 (); + *data = fadt; }
include/hw/acpi/acpi-defs.h +1 -0
@@ -77,6 +77,7 @@ typedef struct AcpiFadtData {uint16_t plvl2_lat;/* P_LVL2_LAT */ uint16_t plvl3_lat;/* P_LVL3_LAT */ uint16_t arm_boot_arch;/* ARM_BOOT_ARCH */ +uint16_t iapc_boot_arch;/* IAPC_BOOT_ARCH */ uint8_t minor_ver;/* FADT Minor Version */ /*
include/hw/input/i8042.h +15 -0
@@ -23,4 +23,19 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,void i8042_isa_mouse_fake_event (ISAKBDState *isa);void i8042_setup_a20_line (ISADevice *dev,qemu_irq a20_out); +static inline bool i8042_present (void ) +{ +bool amb = false; +return object_resolve_path_type ("" ,TYPE_I8042 , &amb) || amb; +} + +/* +* ACPI v2, Table 5-10 - Fixed ACPI Description Table Boot Architecture +* Flags, bit offset 1 - 8042. +*/ +static inline u16 iapc_boot_arch_8042 (void ) +{ +return i8042_present () ?0x1 <<1 :0x0 ; +} +#endif /* HW_INPUT_I8042_H */
Signature · 1 line
2.25.1
PATCH v6 3/4 tests/acpi: i386: update FACP table differences
In reply to Ani SinhaFrom: Liav Albani <[email protected]>
After changing the IAPC boot flags register to indicate support of i8042 in the machine chipset to help the guest OS to determine its existence "faster", we need to have the updated FACP ACPI binary images in tree.
The ASL changes introduced are shown by the following diff:
@@ -42,35 +42,35 @@
[059h 0089 1] PM1 Control Block Length : 02 [05Ah 0090 1] PM2 Control Block Length : 00 [05Bh 0091 1] PM Timer Block Length : 04 [05Ch 0092 1] GPE0 Block Length : 10 [05Dh 0093 1] GPE1 Block Length : 00 [05Eh 0094 1] GPE1 Base Offset : 00 [05Fh 0095 1] _CST Support : 00 [060h 0096 2] C2 Latency : 0FFF [062h 0098 2] C3 Latency : 0FFF [064h 0100 2] CPU Cache Size : 0000 [066h 0102 2] Cache Flush Stride : 0000 [068h 0104 1] Duty Cycle Offset : 00 [069h 0105 1] Duty Cycle Width : 00 [06Ah 0106 1] RTC Day Alarm Index : 00 [06Bh 0107 1] RTC Month Alarm Index : 00 [06Ch 0108 1] RTC Century Index : 32 -[06Dh 0109 2] Boot Flags (decoded below) : 0000 +[06Dh 0109 2] Boot Flags (decoded below) : 0002
Legacy Devices Supported (V2) : 0
- 8042 Present on ports 60/64 (V2) : 0
+ 8042 Present on ports 60/64 (V2) : 1
VGA Not Present (V4) : 0
MSI Not Supported (V4) : 0
PCIe ASPM Not Supported (V4) : 0
CMOS RTC Not Present (V5) : 0
[06Fh 0111 1] Reserved : 00
[070h 0112 4] Flags (decoded below) : 000084A5
WBINVD instruction is operational (V1) : 1
WBINVD flushes all caches (V1) : 0
All CPUs support C1 (V1) : 1
C2 works on MP system (V1) : 0
Control Method Power Button (V1) : 0
Control Method Sleep Button (V1) : 1
RTC wake not in fixed reg space (V1) : 0
RTC can wake system from S4 (V1) : 1
32-bit PM Timer (V1) : 0
Docking Supported (V1) : 0
--- tests/data/acpi/q35/FACP | Bin 244 -> 244 bytes tests/data/acpi/q35/FACP.nosmm | Bin 244 -> 244 bytes tests/data/acpi/q35/FACP.slic | Bin 244 -> 244 bytes tests/data/acpi/q35/FACP.xapic | Bin 244 -> 244 bytes tests/qtest/bios-tables-test-allowed-diff.h | 4 ---- 5 files changed, 4 deletions(-)
tests/data/acpi/q35/FACP binary +0 -0
tests/data/acpi/q35/FACP.nosmm binary +0 -0
tests/data/acpi/q35/FACP.slic binary +0 -0
tests/data/acpi/q35/FACP.xapic binary +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +0 -4
@@ -1,5 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/FACP" , -"tests/data/acpi/q35/FACP.nosmm" , -"tests/data/acpi/q35/FACP.slic" , -"tests/data/acpi/q35/FACP.xapic",
Signature · 1 line
2.25.1
PATCH v6 4/4 hw/acpi/microvm: turn on 8042 bit in FADT boot architecture flags if present
In reply to Ani SinhaThe second bit of IAPC_BOOT_ARCH in FADT table indicates the presence of keyboard controller implemented as 8042 or equivalent micro controller. This change enables this flag for microvms if such a device exists (for example, when added explicitly from the QEMU commandline). Change1f810294bb31bf6ac ("hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table") enabled this flag for i386 q35 based machines. The reason for doing the same for micro-vms is to make sure we provide the correct tables to the guest OS uniformly in all cases when an i8042 device is present. When this bit is not enabled, guest OSes has to find other indirect methods to detect the device which we would like to avoid.
--- hw/i386/acpi-microvm.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/i386/acpi-microvm.c +6 -0
@@ -37,6 +37,7 @@#include "hw/pci/pcie_host.h" #include "hw/usb/xhci.h" #include "hw/virtio/virtio-mmio.h" +#include "hw/input/i8042.h" #include "acpi-common.h" #include "acpi-microvm.h"
@@ -187,6 +188,11 @@ static void acpi_build_microvm(AcpiBuildTables *tables, .address = GED_MMIO_BASE_REGS + ACPI_GED_REG_RESET, }, .reset_val = ACPI_GED_RESET_VALUE, +/* +* ACPI v2, Table 5-10 - Fixed ACPI Description Table Boot Architecture +* Flags, bit offset 1 - 8042. +*/ + .iapc_boot_arch = iapc_boot_arch_8042(), }; table_offsets = g_array_new(false, true /* clear */,
Signature · 1 line
2.25.1