hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table
v5 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:
v5:
Addressed review comments from v4. Also got rid of microvm changes. Will send them in a separate patch.
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 ++++++++ include/hw/acpi/acpi-defs.h | 1 + include/hw/input/i8042.h | 6 ++++++ 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 8 files changed, 22 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
PATCH v5 1/3 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
PATCH v5 2/3 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.
This change only applies to the x86/q35 machine type, as it uses FACP ACPI table with revision higher than 1, which should implement at least ACPI 2.0 features within the table, hence it can also set the IA-PC boot flags register according to the ACPI 2.0 specification.
--- hw/acpi/aml-build.c | 8 +++++++- hw/i386/acpi-build.c | 8 ++++++++ include/hw/acpi/acpi-defs.h | 1 + include/hw/input/i8042.h | 6 ++++++ 4 files changed, 22 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 =i8042_present () ?0x1 <<1 :0x0 ; + *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 +6 -0
@@ -23,4 +23,10 @@ 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; +} +#endif /* HW_INPUT_I8042_H */
Signature · 1 line
2.25.1
PATCH v5 3/3 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
Re: [PATCH v5 3/3] tests/acpi: i386: update FACP table differences
Quoted 47 lines · Ani Sinha
From: 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:
(quoted diff) +2
-2@@ -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
Quoted 2 lines
Signed-off-by Liav Albani <[email protected]>Acked-by Ani Sinha <[email protected]>
Fails make check:
▶ 3/60 ERROR:../tests/qtest/bios-tables-test.c:532:test_acpi_asl: assertion failed: (all_tables_match) ERROR
Quoted 56 lines
--- 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
-0tests/data/acpi/q35/FACP.nosmm binary +0
-0tests/data/acpi/q35/FACP.slic binary +0
-0tests/data/acpi/q35/FACP.xapic binary +0
-0tests/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
Re: [PATCH v5 3/3] tests/acpi: i386: update FACP table differences
Quoted 49 lines · Michael S. Tsirkin
Quoted 47 lines · Ani Sinha
From: 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:
(quoted diff) +2
-2@@ -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
Quoted 5 lines
Quoted 2 lines
Signed-off-by Liav Albani <[email protected]>Acked-by Ani Sinha <[email protected]>Fails make check:
▶ 3/60 ERROR:../tests/qtest/bios-tables-test.c:532:test_acpi_asl: assertion failed: (all_tables_match) ERROR
Unable to repro this even after rebasing to latest master.