xref: /qemu/include/hw/acpi/ghes.h (revision f5e6e13124440797308d2c044f44d9e655fcb74d)
1 /*
2  * Support for generating APEI tables and recording CPER for Guests
3  *
4  * Copyright (c) 2020 HUAWEI TECHNOLOGIES CO., LTD.
5  *
6  * Author: Dongjiu Geng <gengdongjiu@huawei.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17 
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef ACPI_GHES_H
23 #define ACPI_GHES_H
24 
25 #include "hw/acpi/bios-linker-loader.h"
26 #include "qapi/error.h"
27 
28 /*
29  * Values for Hardware Error Notification Type field
30  */
31 enum AcpiGhesNotifyType {
32     /* Polled */
33     ACPI_GHES_NOTIFY_POLLED = 0,
34     /* External Interrupt */
35     ACPI_GHES_NOTIFY_EXTERNAL = 1,
36     /* Local Interrupt */
37     ACPI_GHES_NOTIFY_LOCAL = 2,
38     /* SCI */
39     ACPI_GHES_NOTIFY_SCI = 3,
40     /* NMI */
41     ACPI_GHES_NOTIFY_NMI = 4,
42     /* CMCI, ACPI 5.0: 18.3.2.7, Table 18-290 */
43     ACPI_GHES_NOTIFY_CMCI = 5,
44     /* MCE, ACPI 5.0: 18.3.2.7, Table 18-290 */
45     ACPI_GHES_NOTIFY_MCE = 6,
46     /* GPIO-Signal, ACPI 6.0: 18.3.2.7, Table 18-332 */
47     ACPI_GHES_NOTIFY_GPIO = 7,
48     /* ARMv8 SEA, ACPI 6.1: 18.3.2.9, Table 18-345 */
49     ACPI_GHES_NOTIFY_SEA = 8,
50     /* ARMv8 SEI, ACPI 6.1: 18.3.2.9, Table 18-345 */
51     ACPI_GHES_NOTIFY_SEI = 9,
52     /* External Interrupt - GSIV, ACPI 6.1: 18.3.2.9, Table 18-345 */
53     ACPI_GHES_NOTIFY_GSIV = 10,
54     /* Software Delegated Exception, ACPI 6.2: 18.3.2.9, Table 18-383 */
55     ACPI_GHES_NOTIFY_SDEI = 11,
56     /* 12 and greater are reserved */
57     ACPI_GHES_NOTIFY_RESERVED = 12
58 };
59 
60 enum {
61     ACPI_HEST_SRC_ID_SEA = 0,
62     /* future ids go here */
63 
64     ACPI_GHES_ERROR_SOURCE_COUNT
65 };
66 
67 typedef struct AcpiGhesState {
68     uint64_t hw_error_le;
69     bool present; /* True if GHES is present at all on this board */
70 } AcpiGhesState;
71 
72 void acpi_build_hest(GArray *table_data, GArray *hardware_errors,
73                      BIOSLinker *linker,
74                      const char *oem_id, const char *oem_table_id);
75 void acpi_ghes_add_fw_cfg(AcpiGhesState *vms, FWCfgState *s,
76                           GArray *hardware_errors);
77 int acpi_ghes_memory_errors(uint16_t source_id, uint64_t error_physical_addr);
78 
79 /**
80  * acpi_ghes_present: Report whether ACPI GHES table is present
81  *
82  * Returns: true if the system has an ACPI GHES table and it is
83  * safe to call acpi_ghes_memory_errors() to record a memory error.
84  */
85 bool acpi_ghes_present(void);
86 #endif
87