Skip to contentSkip to conversation

hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table

PATCH In review Ani Sinha 3 participants 10 messages Mar 4, 2022 – Mar 7, 2022

lore
Share & tools
lore

Ani Sinha

author
#0 lore raw

v7 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:
v7:
fixed a compilation issue. the fix was not committed when running "make check" 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
author
#1 lore raw

PATCH v7 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
index dfb8523c8b..7570e39369 100644
@@ -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
author
#2 lore raw

PATCH v7 2/4 hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table

In reply to Ani Sinha

From: 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
index 8966e16320..1773cf55f1 100644
@@ -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
index ebd47aa26f..4ad4d7286c 100644
@@ -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
index c97e8633ad..2b42e4192b 100644
@@ -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
index 1d90432dae..e070f546e4 100644
@@ -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 uint16_t iapc_boot_arch_8042(void)
+{
+    return i8042_present() ? 0x1 << 1 : 0x0 ;
+}
+
 #endif /* HW_INPUT_I8042_H */
Signature · 1 line
2.25.1
#3 lore raw
Quoted 53 lines · Ani Sinha

From: 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
index 8966e16320..1773cf55f1 100644
@@ -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 +1 -0
index ebd47aa26f..4ad4d7286c 100644
@@ -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"

hw/i386/acpi-build.c static void init_common_fadt_data(MachineState *ms, Object *o, · line 200

Quoted 8 lines
hw/i386/acpi-build.c +5 -0
@@ -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.
+     */

I think we should drop this comment (and one for microvm). If you like, add

/*
Table 5-8 Fixed ACPI Description Table (FADT) Format IAPC_BOOT_ARCH
*/

instead.

Let's do that with a patch on top, we have a soft freeze to consider.

Quoted 43 lines
hw/i386/acpi-build.c +2 -0
+    fadt.iapc_boot_arch = iapc_boot_arch_8042();
+
     *data = fadt;
 }
 
include/hw/acpi/acpi-defs.h +1 -0
index c97e8633ad..2b42e4192b 100644
@@ -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
index 1d90432dae..e070f546e4 100644
@@ -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 uint16_t iapc_boot_arch_8042(void)
+{
+    return i8042_present() ? 0x1 << 1 : 0x0 ;
+}
+
 #endif /* HW_INPUT_I8042_H */
Signature · 1 line
2.25.1
author
#4 lore raw
Quoted 72 lines · Michael S. Tsirkin
Quoted 53 lines · Ani Sinha

From: 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
index 8966e16320..1773cf55f1 100644
@@ -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 +1 -0
index ebd47aa26f..4ad4d7286c 100644
@@ -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"

hw/i386/acpi-build.c static void init_common_fadt_data(MachineState *ms, Object *o, · line 200

Quoted 8 lines
hw/i386/acpi-build.c +5 -0
@@ -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.
+     */

I think we should drop this comment (and one for microvm). If you like, add

/*
Table 5-8 Fixed ACPI Description Table (FADT) Format IAPC_BOOT_ARCH
*/

Quoted 4 lines

instead.

Let's do that with a patch on top, we have a soft freeze to consider.

Sure.

Quoted 45 lines
Quoted 44 lines
hw/i386/acpi-build.c +2 -0
+    fadt.iapc_boot_arch = iapc_boot_arch_8042();
+
     *data = fadt;
 }
 
include/hw/acpi/acpi-defs.h +1 -0
index c97e8633ad..2b42e4192b 100644
@@ -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 -1
index 1d90432dae..e070f546e4 100644
@@ -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 uint16_t iapc_boot_arch_8042(void)
+{
+    return i8042_present() ? 0x1 << 1 : 0x0 ;
+}
+
 #endif /* HW_INPUT_I8042_H */
--

2.25.1

#5 lore raw
Quoted 68 lines · On Sun, 6 Mar 2022 19:56:04 +0530 Ani Sinha <[email protected]> wrote:
Quoted 67 lines · Michael S. Tsirkin
Quoted 53 lines · Ani Sinha

From: 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
index 8966e16320..1773cf55f1 100644
@@ -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 +1 -0
index ebd47aa26f..4ad4d7286c 100644
@@ -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"

hw/i386/acpi-build.c static void init_common_fadt_data(MachineState *ms, Object *o, · line 200

Quoted 8 lines
hw/i386/acpi-build.c +5 -0
@@ -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.
+     */  

I think we should drop this comment (and one for microvm). If you like, add

Quoted 6 lines
Quoted 6 lines

/*
Table 5-8 Fixed ACPI Description Table (FADT) Format IAPC_BOOT_ARCH
*/

instead.

I'd keep spec version though,
all chapter/table numbering is version depended.

Quoted 52 lines
Quoted 3 lines

Let's do that with a patch on top, we have a soft freeze to consider.

Sure.

Quoted 45 lines
Quoted 44 lines
hw/i386/acpi-build.c +2 -0
+    fadt.iapc_boot_arch = iapc_boot_arch_8042();
+
     *data = fadt;
 }
 
include/hw/acpi/acpi-defs.h +1 -0
index c97e8633ad..2b42e4192b 100644
@@ -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 -1
index 1d90432dae..e070f546e4 100644
@@ -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 uint16_t iapc_boot_arch_8042(void)
+{
+    return i8042_present() ? 0x1 << 1 : 0x0 ;
+}
+
 #endif /* HW_INPUT_I8042_H */
--

2.25.1

author
#6 lore raw

PATCH v7 3/4 tests/acpi: i386: update FACP table differences

In reply to 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:

@@ -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
index f6a864cc863c7763f6c09d3814ad184a658fa0a0..a8f6a8961109d01059aceef9f1869cde09a2f10c 100644
GIT binary patch
tests/data/acpi/q35/FACP.nosmm binary +0 -0
index 6a9aa5f370eb9af6a03dc739d8a159be58fdee01..c4e6d18ee5fc64159160d4589aa96b4d648c913a 100644
GIT binary patch
tests/data/acpi/q35/FACP.slic binary +0 -0
index 15986e095cf2db7ee92f7ce113c1d46d54018c62..48bbb1cf5ad0ceda1d2f6d56edf5c1e207bd1a04 100644
GIT binary patch
tests/data/acpi/q35/FACP.xapic binary +0 -0
index 2d3659c9c6753d07c3d48742343cb8e8cc034de7..31fa5dd19c213034eef4eeefa6a04e61dadd8a2a 100644
GIT binary patch
tests/qtest/bios-tables-test-allowed-diff.h +0 -4
index 7570e39369..dfb8523c8b 100644
@@ -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
author
#7 lore raw

PATCH v7 4/4 hw/acpi/microvm: turn on 8042 bit in FADT boot architecture flags if present

In reply to Ani Sinha

The 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). Change
654701e292d98b308b0 ("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
index 68ca7e7fc2..fb09185cbd 100644
@@ -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
#8 lore raw
In reply to Ani Sinha
Quoted 9 lines · Ani Sinha

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.

Quoted 7 lines

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.

I wonder how will such a guest work on an existing qemu release then.

Quoted 34 lines

Changelog:
v7:
fixed a compilation issue. the fix was not committed when running "make check" 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
author
#9 lore raw
Quoted 19 lines · Michael S. Tsirkin
Quoted 9 lines · Ani Sinha

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.

Quoted 7 lines

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.

Quoted 1 line

I wonder how will such a guest work on an existing qemu release then.

I do not know about other such guests but looking at Serenity OS which is the reason of motivation of this work, it seems to work by sending commands to the command IO port:

https://github.com/SerenityOS/serenity/blob/455224d4766df886a43c19e9c015533c025d40dd/Kernel/Devices/HID/I8042Controller.cpp#L34

Quoted 2 lines

do_wait_then_write(I8042Port::Command, I8042Command::ReadConfiguration); result.is_error())
do_write(I8042Port::Command, I8042Command::TestPS2Controller);

etc.