xref: /qemu/docs/specs/acpi_hest_ghes.rst (revision 8f5a4cfc7ed9e06e07fdd8e8fdf50ef3ea783f63)
1APEI tables generating and CPER record
2======================================
3
4..
5   Copyright (c) 2020 HUAWEI TECHNOLOGIES CO., LTD.
6
7   This work is licensed under the terms of the GNU GPL, version 2 or later.
8   See the COPYING file in the top-level directory.
9
10Design Details
11--------------
12
13::
14
15         etc/acpi/tables                           etc/hardware_errors
16      ====================                   ===============================
17  + +--------------------------+            +----------------------------+
18  | | HEST                     | +--------->|    error_block_address1    |------+
19  | +--------------------------+ |          +----------------------------+      |
20  | | GHES1                    | | +------->|    error_block_address2    |------+-+
21  | +--------------------------+ | |        +----------------------------+      | |
22  | | .................        | | |        |      ..............        |      | |
23  | | error_status_address-----+-+ |        -----------------------------+      | |
24  | | .................        |   |   +--->|    error_block_addressN    |------+-+---+
25  | | read_ack_register--------+-+ |   |    +----------------------------+      | |   |
26  | | read_ack_preserve        | +-+---+--->|     read_ack_register1     |      | |   |
27  | | read_ack_write           |   |   |    +----------------------------+      | |   |
28  + +--------------------------+   | +-+--->|     read_ack_register2     |      | |   |
29  | | GHES2                    |   | | |    +----------------------------+      | |   |
30  + +--------------------------+   | | |    |       .............        |      | |   |
31  | | .................        |   | | |    +----------------------------+      | |   |
32  | | error_status_address-----+---+ | | +->|     read_ack_registerN     |      | |   |
33  | | .................        |     | | |  +----------------------------+      | |   |
34  | | read_ack_register--------+-----+ | |  |Generic Error Status Block 1|<-----+ |   |
35  | | read_ack_preserve        |       | |  |-+------------------------+-+        |   |
36  | | read_ack_write           |       | |  | |          CPER          | |        |   |
37  + +--------------------------|       | |  | |          CPER          | |        |   |
38  | | ...............          |       | |  | |          ....          | |        |   |
39  + +--------------------------+       | |  | |          CPER          | |        |   |
40  | | GHESN                    |       | |  |-+------------------------+-|        |   |
41  + +--------------------------+       | |  |Generic Error Status Block 2|<-------+   |
42  | | .................        |       | |  |-+------------------------+-+            |
43  | | error_status_address-----+-------+ |  | |           CPER         | |            |
44  | | .................        |         |  | |           CPER         | |            |
45  | | read_ack_register--------+---------+  | |           ....         | |            |
46  | | read_ack_preserve        |            | |           CPER         | |            |
47  | | read_ack_write           |            +-+------------------------+-+            |
48  + +--------------------------+            |         ..........         |            |
49                                            |----------------------------+            |
50                                            |Generic Error Status Block N |<----------+
51                                            |-+-------------------------+-+
52                                            | |          CPER           | |
53                                            | |          CPER           | |
54                                            | |          ....           | |
55                                            | |          CPER           | |
56                                            +-+-------------------------+-+
57
58
59(1) QEMU generates the ACPI HEST table. This table goes in the current
60    "etc/acpi/tables" fw_cfg blob. Each error source has different
61    notification types.
62
63(2) A new fw_cfg blob called "etc/hardware_errors" is introduced. QEMU
64    also needs to populate this blob. The "etc/hardware_errors" fw_cfg blob
65    contains an address registers table and an Error Status Data Block table.
66
67(3) The address registers table contains N Error Block Address entries
68    and N Read Ack Register entries. The size for each entry is 8-byte.
69    The Error Status Data Block table contains N Error Status Data Block
70    entries. The size for each entry is defined at the source code as
71    ACPI_GHES_MAX_RAW_DATA_LENGTH (currently 1024 bytes). The total size
72    for the "etc/hardware_errors" fw_cfg blob is
73    (N * 8 * 2 + N * ACPI_GHES_MAX_RAW_DATA_LENGTH) bytes.
74    N is the number of the kinds of hardware error sources.
75
76(4) QEMU generates the ACPI linker/loader script for the firmware. The
77    firmware pre-allocates memory for "etc/acpi/tables", "etc/hardware_errors"
78    and copies blob contents there.
79
80(5) QEMU generates N ADD_POINTER commands, which patch addresses in the
81    "error_status_address" fields of the HEST table with a pointer to the
82    corresponding "address registers" in the "etc/hardware_errors" blob.
83
84(6) QEMU generates N ADD_POINTER commands, which patch addresses in the
85    "read_ack_register" fields of the HEST table with a pointer to the
86    corresponding "read_ack_register" within the "etc/hardware_errors" blob.
87
88(7) QEMU generates N ADD_POINTER commands for the firmware, which patch
89    addresses in the "error_block_address" fields with a pointer to the
90    respective "Error Status Data Block" in the "etc/hardware_errors" blob.
91
92(8) QEMU defines a third and write-only fw_cfg blob which is called
93    "etc/hardware_errors_addr". Through that blob, the firmware can send back
94    the guest-side allocation addresses to QEMU. The "etc/hardware_errors_addr"
95    blob contains a 8-byte entry. QEMU generates a single WRITE_POINTER command
96    for the firmware. The firmware will write back the start address of
97    "etc/hardware_errors" blob to the fw_cfg file "etc/hardware_errors_addr".
98
99(9) When QEMU gets a SIGBUS from the kernel, QEMU writes CPER into corresponding
100    "Error Status Data Block", guest memory, and then injects platform specific
101    interrupt (in case of arm/virt machine it's Synchronous External Abort) as a
102    notification which is necessary for notifying the guest.
103
104(10) This notification (in virtual hardware) will be handled by the guest
105     kernel, on receiving notification, guest APEI driver could read the CPER error
106     and take appropriate action.
107
108(11) kvm_arch_on_sigbus_vcpu() uses source_id as index in "etc/hardware_errors" to
109     find out "Error Status Data Block" entry corresponding to error source. So supported
110     source_id values should be assigned here and not be changed afterwards to make sure
111     that guest will write error into expected "Error Status Data Block" even if guest was
112     migrated to a newer QEMU.
113