Re: [PATCH v9 05/10] ACPI ERST: support for ACPI ERST feature
Ani, I'll change this from the g_assert_not_reached() back to STATUS_FAILED. Alas I realized I didn't do the last step in producing the new ACPI tables in the patchset, so even though I just put out v12, I'll need to do a followup v13 with the missing tables. Thanks! eric On 1/11/22 02:35, Ani Sinha wrote: On Tue, Dec 14, 2021 at 2:33 AM Eric DeVolder wrote: Ani, an inline response below. Thanks! eric On 12/10/21 08:09, Ani Sinha wrote: On Thu, Dec 9, 2021 at 11:24 PM Eric DeVolder wrote: Ani, inline responses below. eric On 12/9/21 00:29, Ani Sinha wrote: On Fri, Dec 3, 2021 at 12:39 AM Eric DeVolder wrote: This implements a PCI device for ACPI ERST. This implements the non-NVRAM "mode" of operation for ERST as it is supported by Linux and Windows. Few more comments on this patch ... Signed-off-by: Eric DeVolder --- hw/acpi/Kconfig | 6 + hw/acpi/erst.c | 836 +++ hw/acpi/meson.build | 1 + hw/acpi/trace-events | 15 + 4 files changed, 858 insertions(+) create mode 100644 hw/acpi/erst.c diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig index 622b0b5..19caebd 100644 --- a/hw/acpi/Kconfig +++ b/hw/acpi/Kconfig @@ -10,6 +10,7 @@ config ACPI_X86 select ACPI_HMAT select ACPI_PIIX4 select ACPI_PCIHP +select ACPI_ERST config ACPI_X86_ICH bool @@ -60,3 +61,8 @@ config ACPI_HW_REDUCED select ACPI select ACPI_MEMORY_HOTPLUG select ACPI_NVDIMM + +config ACPI_ERST +bool +default y +depends on ACPI && PCI diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c new file mode 100644 index 000..4304f55 --- /dev/null +++ b/hw/acpi/erst.c @@ -0,0 +1,836 @@ +/* + * ACPI Error Record Serialization Table, ERST, Implementation + * + * ACPI ERST introduced in ACPI 4.0, June 16, 2009. + * ACPI Platform Error Interfaces : Error Serialization + * + * Copyright (c) 2021 Oracle and/or its affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-core.h" +#include "exec/memory.h" +#include "qom/object.h" +#include "hw/pci/pci.h" +#include "qom/object_interfaces.h" +#include "qemu/error-report.h" +#include "migration/vmstate.h" +#include "hw/qdev-properties.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-defs.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/bios-linker-loader.h" +#include "exec/address-spaces.h" +#include "sysemu/hostmem.h" +#include "hw/acpi/erst.h" +#include "trace.h" + +/* ACPI 4.0: Table 17-16 Serialization Actions */ +#define ACTION_BEGIN_WRITE_OPERATION 0x0 +#define ACTION_BEGIN_READ_OPERATION 0x1 +#define ACTION_BEGIN_CLEAR_OPERATION 0x2 +#define ACTION_END_OPERATION 0x3 +#define ACTION_SET_RECORD_OFFSET 0x4 +#define ACTION_EXECUTE_OPERATION 0x5 +#define ACTION_CHECK_BUSY_STATUS 0x6 +#define ACTION_GET_COMMAND_STATUS0x7 +#define ACTION_GET_RECORD_IDENTIFIER 0x8 +#define ACTION_SET_RECORD_IDENTIFIER 0x9 +#define ACTION_GET_RECORD_COUNT 0xA +#define ACTION_BEGIN_DUMMY_WRITE_OPERATION 0xB +#define ACTION_RESERVED 0xC +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE 0xD +#define ACTION_GET_ERROR_LOG_ADDRESS_LENGTH 0xE +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES 0xF +#define ACTION_GET_EXECUTE_OPERATION_TIMINGS 0x10 + +/* ACPI 4.0: Table 17-17 Command Status Definitions */ +#define STATUS_SUCCESS0x00 +#define STATUS_NOT_ENOUGH_SPACE 0x01 +#define STATUS_HARDWARE_NOT_AVAILABLE 0x02 +#define STATUS_FAILED 0x03 +#define STATUS_RECORD_STORE_EMPTY 0x04 +#define STATUS_RECORD_NOT_FOUND 0x05 + + +/* UEFI 2.1: Appendix N Common Platform Error Record */ +#define UEFI_CPER_RECORD_MIN_SIZE 128U +#define UEFI_CPER_RECORD_LENGTH_OFFSET 20U +#define UEFI_CPER_RECORD_ID_OFFSET 96U +#define IS_UEFI_CPER_RECORD(ptr) \ +(((ptr)[0] == 'C') && \ + ((ptr)[1] == 'P') && \ + ((ptr)[2] == 'E') && \ + ((ptr)[3] == 'R')) + +/* + * NOTE that when accessing CPER fields within a record, memcpy() + * is utilized to avoid a possible misaligned access on the host. + */ + +/* + * This implementation is an ACTION (cmd) and VALUE (data) + * interface consisting of just two 64-bit registers. + */ +#define ERST_REG_SIZE (16UL) +#define ERST_ACTION_OFFSET (0UL) /* action (cmd) */ +#define ERST_VALUE_OFFSET (8UL) /* argument/value (data) */ + +/* + * ERST_RECORD_SIZE is the buffer size for exchanging ERST + * record contents. Thus, it defines the maximum record size. + * As this is mapped through a PCI BAR, it must be a power of + * two and larger than UEFI_CPER_RECORD_MIN_SIZE. + * The backing storage is divided into fixed size "slots", + * each ERST_RECORD_SIZE in length, and each "slot" + * storing a single record. No attempt at optimizing
Re: [PATCH v9 05/10] ACPI ERST: support for ACPI ERST feature
On Tue, Dec 14, 2021 at 2:33 AM Eric DeVolder wrote: > > Ani, an inline response below. > Thanks! > eric > > On 12/10/21 08:09, Ani Sinha wrote: > > On Thu, Dec 9, 2021 at 11:24 PM Eric DeVolder > > wrote: > >> > >> Ani, inline responses below. eric > >> > >> On 12/9/21 00:29, Ani Sinha wrote: > >>> On Fri, Dec 3, 2021 at 12:39 AM Eric DeVolder > >>> wrote: > > This implements a PCI device for ACPI ERST. This implements the > non-NVRAM "mode" of operation for ERST as it is supported by > Linux and Windows. > >>> > >>> Few more comments on this patch ... > >>> > > Signed-off-by: Eric DeVolder > --- > hw/acpi/Kconfig | 6 + > hw/acpi/erst.c | 836 > +++ > hw/acpi/meson.build | 1 + > hw/acpi/trace-events | 15 + > 4 files changed, 858 insertions(+) > create mode 100644 hw/acpi/erst.c > > diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig > index 622b0b5..19caebd 100644 > --- a/hw/acpi/Kconfig > +++ b/hw/acpi/Kconfig > @@ -10,6 +10,7 @@ config ACPI_X86 > select ACPI_HMAT > select ACPI_PIIX4 > select ACPI_PCIHP > +select ACPI_ERST > > config ACPI_X86_ICH > bool > @@ -60,3 +61,8 @@ config ACPI_HW_REDUCED > select ACPI > select ACPI_MEMORY_HOTPLUG > select ACPI_NVDIMM > + > +config ACPI_ERST > +bool > +default y > +depends on ACPI && PCI > diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c > new file mode 100644 > index 000..4304f55 > --- /dev/null > +++ b/hw/acpi/erst.c > @@ -0,0 +1,836 @@ > +/* > + * ACPI Error Record Serialization Table, ERST, Implementation > + * > + * ACPI ERST introduced in ACPI 4.0, June 16, 2009. > + * ACPI Platform Error Interfaces : Error Serialization > + * > + * Copyright (c) 2021 Oracle and/or its affiliates. > + * > + * SPDX-License-Identifier: GPL-2.0-or-later > + */ > + > +#include > +#include > +#include > + > +#include "qemu/osdep.h" > +#include "qapi/error.h" > +#include "hw/qdev-core.h" > +#include "exec/memory.h" > +#include "qom/object.h" > +#include "hw/pci/pci.h" > +#include "qom/object_interfaces.h" > +#include "qemu/error-report.h" > +#include "migration/vmstate.h" > +#include "hw/qdev-properties.h" > +#include "hw/acpi/acpi.h" > +#include "hw/acpi/acpi-defs.h" > +#include "hw/acpi/aml-build.h" > +#include "hw/acpi/bios-linker-loader.h" > +#include "exec/address-spaces.h" > +#include "sysemu/hostmem.h" > +#include "hw/acpi/erst.h" > +#include "trace.h" > + > +/* ACPI 4.0: Table 17-16 Serialization Actions */ > +#define ACTION_BEGIN_WRITE_OPERATION 0x0 > +#define ACTION_BEGIN_READ_OPERATION 0x1 > +#define ACTION_BEGIN_CLEAR_OPERATION 0x2 > +#define ACTION_END_OPERATION 0x3 > +#define ACTION_SET_RECORD_OFFSET 0x4 > +#define ACTION_EXECUTE_OPERATION 0x5 > +#define ACTION_CHECK_BUSY_STATUS 0x6 > +#define ACTION_GET_COMMAND_STATUS0x7 > +#define ACTION_GET_RECORD_IDENTIFIER 0x8 > +#define ACTION_SET_RECORD_IDENTIFIER 0x9 > +#define ACTION_GET_RECORD_COUNT 0xA > +#define ACTION_BEGIN_DUMMY_WRITE_OPERATION 0xB > +#define ACTION_RESERVED 0xC > +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE 0xD > +#define ACTION_GET_ERROR_LOG_ADDRESS_LENGTH 0xE > +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES 0xF > +#define ACTION_GET_EXECUTE_OPERATION_TIMINGS 0x10 > + > +/* ACPI 4.0: Table 17-17 Command Status Definitions */ > +#define STATUS_SUCCESS0x00 > +#define STATUS_NOT_ENOUGH_SPACE 0x01 > +#define STATUS_HARDWARE_NOT_AVAILABLE 0x02 > +#define STATUS_FAILED 0x03 > +#define STATUS_RECORD_STORE_EMPTY 0x04 > +#define STATUS_RECORD_NOT_FOUND 0x05 > + > + > +/* UEFI 2.1: Appendix N Common Platform Error Record */ > +#define UEFI_CPER_RECORD_MIN_SIZE 128U > +#define UEFI_CPER_RECORD_LENGTH_OFFSET 20U > +#define UEFI_CPER_RECORD_ID_OFFSET 96U > +#define IS_UEFI_CPER_RECORD(ptr) \ > +(((ptr)[0] == 'C') && \ > + ((ptr)[1] == 'P') && \ > + ((ptr)[2] == 'E') && \ > + ((ptr)[3] == 'R')) > + > +/* > + * NOTE that when accessing CPER fields within a record, memcpy() > + * is utilized to avoid a possible misaligned access on the host. > + */ > + > +/* > + * This implementation is an ACTION (cmd) and VALUE (data) > + * interface consisting of just
Re: [PATCH v9 05/10] ACPI ERST: support for ACPI ERST feature
On Tue, Dec 14, 2021 at 2:33 AM Eric DeVolder wrote: > > Ani, an inline response below. > Thanks! > eric > > On 12/10/21 08:09, Ani Sinha wrote: > > On Thu, Dec 9, 2021 at 11:24 PM Eric DeVolder > > wrote: > >> > >> Ani, inline responses below. eric > >> > >> On 12/9/21 00:29, Ani Sinha wrote: > >>> On Fri, Dec 3, 2021 at 12:39 AM Eric DeVolder > >>> wrote: > > This implements a PCI device for ACPI ERST. This implements the > non-NVRAM "mode" of operation for ERST as it is supported by > Linux and Windows. > >>> > >>> Few more comments on this patch ... > >>> > > Signed-off-by: Eric DeVolder > --- > hw/acpi/Kconfig | 6 + > hw/acpi/erst.c | 836 > +++ > hw/acpi/meson.build | 1 + > hw/acpi/trace-events | 15 + > 4 files changed, 858 insertions(+) > create mode 100644 hw/acpi/erst.c > > diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig > index 622b0b5..19caebd 100644 > --- a/hw/acpi/Kconfig > +++ b/hw/acpi/Kconfig > @@ -10,6 +10,7 @@ config ACPI_X86 > select ACPI_HMAT > select ACPI_PIIX4 > select ACPI_PCIHP > +select ACPI_ERST > > config ACPI_X86_ICH > bool > @@ -60,3 +61,8 @@ config ACPI_HW_REDUCED > select ACPI > select ACPI_MEMORY_HOTPLUG > select ACPI_NVDIMM > + > +config ACPI_ERST > +bool > +default y > +depends on ACPI && PCI > diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c > new file mode 100644 > index 000..4304f55 > --- /dev/null > +++ b/hw/acpi/erst.c > @@ -0,0 +1,836 @@ > +/* > + * ACPI Error Record Serialization Table, ERST, Implementation > + * > + * ACPI ERST introduced in ACPI 4.0, June 16, 2009. > + * ACPI Platform Error Interfaces : Error Serialization > + * > + * Copyright (c) 2021 Oracle and/or its affiliates. > + * > + * SPDX-License-Identifier: GPL-2.0-or-later > + */ > + > +#include > +#include > +#include > + > +#include "qemu/osdep.h" > +#include "qapi/error.h" > +#include "hw/qdev-core.h" > +#include "exec/memory.h" > +#include "qom/object.h" > +#include "hw/pci/pci.h" > +#include "qom/object_interfaces.h" > +#include "qemu/error-report.h" > +#include "migration/vmstate.h" > +#include "hw/qdev-properties.h" > +#include "hw/acpi/acpi.h" > +#include "hw/acpi/acpi-defs.h" > +#include "hw/acpi/aml-build.h" > +#include "hw/acpi/bios-linker-loader.h" > +#include "exec/address-spaces.h" > +#include "sysemu/hostmem.h" > +#include "hw/acpi/erst.h" > +#include "trace.h" > + > +/* ACPI 4.0: Table 17-16 Serialization Actions */ > +#define ACTION_BEGIN_WRITE_OPERATION 0x0 > +#define ACTION_BEGIN_READ_OPERATION 0x1 > +#define ACTION_BEGIN_CLEAR_OPERATION 0x2 > +#define ACTION_END_OPERATION 0x3 > +#define ACTION_SET_RECORD_OFFSET 0x4 > +#define ACTION_EXECUTE_OPERATION 0x5 > +#define ACTION_CHECK_BUSY_STATUS 0x6 > +#define ACTION_GET_COMMAND_STATUS0x7 > +#define ACTION_GET_RECORD_IDENTIFIER 0x8 > +#define ACTION_SET_RECORD_IDENTIFIER 0x9 > +#define ACTION_GET_RECORD_COUNT 0xA > +#define ACTION_BEGIN_DUMMY_WRITE_OPERATION 0xB > +#define ACTION_RESERVED 0xC > +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE 0xD > +#define ACTION_GET_ERROR_LOG_ADDRESS_LENGTH 0xE > +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES 0xF > +#define ACTION_GET_EXECUTE_OPERATION_TIMINGS 0x10 > + > +/* ACPI 4.0: Table 17-17 Command Status Definitions */ > +#define STATUS_SUCCESS0x00 > +#define STATUS_NOT_ENOUGH_SPACE 0x01 > +#define STATUS_HARDWARE_NOT_AVAILABLE 0x02 > +#define STATUS_FAILED 0x03 > +#define STATUS_RECORD_STORE_EMPTY 0x04 > +#define STATUS_RECORD_NOT_FOUND 0x05 > + > + > +/* UEFI 2.1: Appendix N Common Platform Error Record */ > +#define UEFI_CPER_RECORD_MIN_SIZE 128U > +#define UEFI_CPER_RECORD_LENGTH_OFFSET 20U > +#define UEFI_CPER_RECORD_ID_OFFSET 96U > +#define IS_UEFI_CPER_RECORD(ptr) \ > +(((ptr)[0] == 'C') && \ > + ((ptr)[1] == 'P') && \ > + ((ptr)[2] == 'E') && \ > + ((ptr)[3] == 'R')) > + > +/* > + * NOTE that when accessing CPER fields within a record, memcpy() > + * is utilized to avoid a possible misaligned access on the host. > + */ > + > +/* > + * This implementation is an ACTION (cmd) and VALUE (data) > + * interface consisting of just
Re: [PATCH v9 05/10] ACPI ERST: support for ACPI ERST feature
Ani, an inline response below. Thanks! eric On 12/10/21 08:09, Ani Sinha wrote: On Thu, Dec 9, 2021 at 11:24 PM Eric DeVolder wrote: Ani, inline responses below. eric On 12/9/21 00:29, Ani Sinha wrote: On Fri, Dec 3, 2021 at 12:39 AM Eric DeVolder wrote: This implements a PCI device for ACPI ERST. This implements the non-NVRAM "mode" of operation for ERST as it is supported by Linux and Windows. Few more comments on this patch ... Signed-off-by: Eric DeVolder --- hw/acpi/Kconfig | 6 + hw/acpi/erst.c | 836 +++ hw/acpi/meson.build | 1 + hw/acpi/trace-events | 15 + 4 files changed, 858 insertions(+) create mode 100644 hw/acpi/erst.c diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig index 622b0b5..19caebd 100644 --- a/hw/acpi/Kconfig +++ b/hw/acpi/Kconfig @@ -10,6 +10,7 @@ config ACPI_X86 select ACPI_HMAT select ACPI_PIIX4 select ACPI_PCIHP +select ACPI_ERST config ACPI_X86_ICH bool @@ -60,3 +61,8 @@ config ACPI_HW_REDUCED select ACPI select ACPI_MEMORY_HOTPLUG select ACPI_NVDIMM + +config ACPI_ERST +bool +default y +depends on ACPI && PCI diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c new file mode 100644 index 000..4304f55 --- /dev/null +++ b/hw/acpi/erst.c @@ -0,0 +1,836 @@ +/* + * ACPI Error Record Serialization Table, ERST, Implementation + * + * ACPI ERST introduced in ACPI 4.0, June 16, 2009. + * ACPI Platform Error Interfaces : Error Serialization + * + * Copyright (c) 2021 Oracle and/or its affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-core.h" +#include "exec/memory.h" +#include "qom/object.h" +#include "hw/pci/pci.h" +#include "qom/object_interfaces.h" +#include "qemu/error-report.h" +#include "migration/vmstate.h" +#include "hw/qdev-properties.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-defs.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/bios-linker-loader.h" +#include "exec/address-spaces.h" +#include "sysemu/hostmem.h" +#include "hw/acpi/erst.h" +#include "trace.h" + +/* ACPI 4.0: Table 17-16 Serialization Actions */ +#define ACTION_BEGIN_WRITE_OPERATION 0x0 +#define ACTION_BEGIN_READ_OPERATION 0x1 +#define ACTION_BEGIN_CLEAR_OPERATION 0x2 +#define ACTION_END_OPERATION 0x3 +#define ACTION_SET_RECORD_OFFSET 0x4 +#define ACTION_EXECUTE_OPERATION 0x5 +#define ACTION_CHECK_BUSY_STATUS 0x6 +#define ACTION_GET_COMMAND_STATUS0x7 +#define ACTION_GET_RECORD_IDENTIFIER 0x8 +#define ACTION_SET_RECORD_IDENTIFIER 0x9 +#define ACTION_GET_RECORD_COUNT 0xA +#define ACTION_BEGIN_DUMMY_WRITE_OPERATION 0xB +#define ACTION_RESERVED 0xC +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE 0xD +#define ACTION_GET_ERROR_LOG_ADDRESS_LENGTH 0xE +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES 0xF +#define ACTION_GET_EXECUTE_OPERATION_TIMINGS 0x10 + +/* ACPI 4.0: Table 17-17 Command Status Definitions */ +#define STATUS_SUCCESS0x00 +#define STATUS_NOT_ENOUGH_SPACE 0x01 +#define STATUS_HARDWARE_NOT_AVAILABLE 0x02 +#define STATUS_FAILED 0x03 +#define STATUS_RECORD_STORE_EMPTY 0x04 +#define STATUS_RECORD_NOT_FOUND 0x05 + + +/* UEFI 2.1: Appendix N Common Platform Error Record */ +#define UEFI_CPER_RECORD_MIN_SIZE 128U +#define UEFI_CPER_RECORD_LENGTH_OFFSET 20U +#define UEFI_CPER_RECORD_ID_OFFSET 96U +#define IS_UEFI_CPER_RECORD(ptr) \ +(((ptr)[0] == 'C') && \ + ((ptr)[1] == 'P') && \ + ((ptr)[2] == 'E') && \ + ((ptr)[3] == 'R')) + +/* + * NOTE that when accessing CPER fields within a record, memcpy() + * is utilized to avoid a possible misaligned access on the host. + */ + +/* + * This implementation is an ACTION (cmd) and VALUE (data) + * interface consisting of just two 64-bit registers. + */ +#define ERST_REG_SIZE (16UL) +#define ERST_ACTION_OFFSET (0UL) /* action (cmd) */ +#define ERST_VALUE_OFFSET (8UL) /* argument/value (data) */ + +/* + * ERST_RECORD_SIZE is the buffer size for exchanging ERST + * record contents. Thus, it defines the maximum record size. + * As this is mapped through a PCI BAR, it must be a power of + * two and larger than UEFI_CPER_RECORD_MIN_SIZE. + * The backing storage is divided into fixed size "slots", + * each ERST_RECORD_SIZE in length, and each "slot" + * storing a single record. No attempt at optimizing storage + * through compression, compaction, etc is attempted. + * NOTE that slot 0 is reserved for the backing storage header. + * Depending upon the size of the backing storage, additional + * slots will be part of the slot 0 header in order to account + * for a record_id for each available remaining slot. + */ +/* 8KiB records, not too small, not too big */ +#define
Re: [PATCH v9 05/10] ACPI ERST: support for ACPI ERST feature
On Thu, Dec 9, 2021 at 11:24 PM Eric DeVolder wrote: > > Ani, inline responses below. eric > > On 12/9/21 00:29, Ani Sinha wrote: > > On Fri, Dec 3, 2021 at 12:39 AM Eric DeVolder > > wrote: > >> > >> This implements a PCI device for ACPI ERST. This implements the > >> non-NVRAM "mode" of operation for ERST as it is supported by > >> Linux and Windows. > > > > Few more comments on this patch ... > > > >> > >> Signed-off-by: Eric DeVolder > >> --- > >> hw/acpi/Kconfig | 6 + > >> hw/acpi/erst.c | 836 > >> +++ > >> hw/acpi/meson.build | 1 + > >> hw/acpi/trace-events | 15 + > >> 4 files changed, 858 insertions(+) > >> create mode 100644 hw/acpi/erst.c > >> > >> diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig > >> index 622b0b5..19caebd 100644 > >> --- a/hw/acpi/Kconfig > >> +++ b/hw/acpi/Kconfig > >> @@ -10,6 +10,7 @@ config ACPI_X86 > >> select ACPI_HMAT > >> select ACPI_PIIX4 > >> select ACPI_PCIHP > >> +select ACPI_ERST > >> > >> config ACPI_X86_ICH > >> bool > >> @@ -60,3 +61,8 @@ config ACPI_HW_REDUCED > >> select ACPI > >> select ACPI_MEMORY_HOTPLUG > >> select ACPI_NVDIMM > >> + > >> +config ACPI_ERST > >> +bool > >> +default y > >> +depends on ACPI && PCI > >> diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c > >> new file mode 100644 > >> index 000..4304f55 > >> --- /dev/null > >> +++ b/hw/acpi/erst.c > >> @@ -0,0 +1,836 @@ > >> +/* > >> + * ACPI Error Record Serialization Table, ERST, Implementation > >> + * > >> + * ACPI ERST introduced in ACPI 4.0, June 16, 2009. > >> + * ACPI Platform Error Interfaces : Error Serialization > >> + * > >> + * Copyright (c) 2021 Oracle and/or its affiliates. > >> + * > >> + * SPDX-License-Identifier: GPL-2.0-or-later > >> + */ > >> + > >> +#include > >> +#include > >> +#include > >> + > >> +#include "qemu/osdep.h" > >> +#include "qapi/error.h" > >> +#include "hw/qdev-core.h" > >> +#include "exec/memory.h" > >> +#include "qom/object.h" > >> +#include "hw/pci/pci.h" > >> +#include "qom/object_interfaces.h" > >> +#include "qemu/error-report.h" > >> +#include "migration/vmstate.h" > >> +#include "hw/qdev-properties.h" > >> +#include "hw/acpi/acpi.h" > >> +#include "hw/acpi/acpi-defs.h" > >> +#include "hw/acpi/aml-build.h" > >> +#include "hw/acpi/bios-linker-loader.h" > >> +#include "exec/address-spaces.h" > >> +#include "sysemu/hostmem.h" > >> +#include "hw/acpi/erst.h" > >> +#include "trace.h" > >> + > >> +/* ACPI 4.0: Table 17-16 Serialization Actions */ > >> +#define ACTION_BEGIN_WRITE_OPERATION 0x0 > >> +#define ACTION_BEGIN_READ_OPERATION 0x1 > >> +#define ACTION_BEGIN_CLEAR_OPERATION 0x2 > >> +#define ACTION_END_OPERATION 0x3 > >> +#define ACTION_SET_RECORD_OFFSET 0x4 > >> +#define ACTION_EXECUTE_OPERATION 0x5 > >> +#define ACTION_CHECK_BUSY_STATUS 0x6 > >> +#define ACTION_GET_COMMAND_STATUS0x7 > >> +#define ACTION_GET_RECORD_IDENTIFIER 0x8 > >> +#define ACTION_SET_RECORD_IDENTIFIER 0x9 > >> +#define ACTION_GET_RECORD_COUNT 0xA > >> +#define ACTION_BEGIN_DUMMY_WRITE_OPERATION 0xB > >> +#define ACTION_RESERVED 0xC > >> +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE 0xD > >> +#define ACTION_GET_ERROR_LOG_ADDRESS_LENGTH 0xE > >> +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES 0xF > >> +#define ACTION_GET_EXECUTE_OPERATION_TIMINGS 0x10 > >> + > >> +/* ACPI 4.0: Table 17-17 Command Status Definitions */ > >> +#define STATUS_SUCCESS0x00 > >> +#define STATUS_NOT_ENOUGH_SPACE 0x01 > >> +#define STATUS_HARDWARE_NOT_AVAILABLE 0x02 > >> +#define STATUS_FAILED 0x03 > >> +#define STATUS_RECORD_STORE_EMPTY 0x04 > >> +#define STATUS_RECORD_NOT_FOUND 0x05 > >> + > >> + > >> +/* UEFI 2.1: Appendix N Common Platform Error Record */ > >> +#define UEFI_CPER_RECORD_MIN_SIZE 128U > >> +#define UEFI_CPER_RECORD_LENGTH_OFFSET 20U > >> +#define UEFI_CPER_RECORD_ID_OFFSET 96U > >> +#define IS_UEFI_CPER_RECORD(ptr) \ > >> +(((ptr)[0] == 'C') && \ > >> + ((ptr)[1] == 'P') && \ > >> + ((ptr)[2] == 'E') && \ > >> + ((ptr)[3] == 'R')) > >> + > >> +/* > >> + * NOTE that when accessing CPER fields within a record, memcpy() > >> + * is utilized to avoid a possible misaligned access on the host. > >> + */ > >> + > >> +/* > >> + * This implementation is an ACTION (cmd) and VALUE (data) > >> + * interface consisting of just two 64-bit registers. > >> + */ > >> +#define ERST_REG_SIZE (16UL) > >> +#define ERST_ACTION_OFFSET (0UL) /* action (cmd) */ > >> +#define ERST_VALUE_OFFSET (8UL) /* argument/value (data) */ > >> + > >> +/* > >> + * ERST_RECORD_SIZE is the buffer size for exchanging ERST > >> + * record contents. Thus, it defines the maximum record size. > >> + * As this is mapped through a PCI BAR, it must be a power of > >> + * two and larger
Re: [PATCH v9 05/10] ACPI ERST: support for ACPI ERST feature
On 12/9/21 00:31, Ani Sinha wrote: On Wed, Dec 8, 2021 at 10:08 PM Eric DeVolder wrote: On 12/6/21 02:14, Ani Sinha wrote: On Fri, Dec 3, 2021 at 12:39 AM Eric DeVolder wrote: This implements a PCI device for ACPI ERST. This implements the non-NVRAM "mode" of operation for ERST as it is supported by Linux and Windows. OK sent some more comments. It will take another pass for me to fully review this. Hi Ani, thank you for reviewing. I have incorporated your feedback thus far. I have v10 ready to go but not sure if your review of v9 is completed yet? I completed scanning this patch. Don't hold your breath. I review things when I find gaps in other work and can't promise timely reviews. You can send a v10 once you have addressed my last set of comments. Thanks Ani! I understand on the reviews. I have incorporated all feedback and posted v10. Thank you! eric
Re: [PATCH v9 05/10] ACPI ERST: support for ACPI ERST feature
Ani, inline responses below. eric On 12/9/21 00:29, Ani Sinha wrote: On Fri, Dec 3, 2021 at 12:39 AM Eric DeVolder wrote: This implements a PCI device for ACPI ERST. This implements the non-NVRAM "mode" of operation for ERST as it is supported by Linux and Windows. Few more comments on this patch ... Signed-off-by: Eric DeVolder --- hw/acpi/Kconfig | 6 + hw/acpi/erst.c | 836 +++ hw/acpi/meson.build | 1 + hw/acpi/trace-events | 15 + 4 files changed, 858 insertions(+) create mode 100644 hw/acpi/erst.c diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig index 622b0b5..19caebd 100644 --- a/hw/acpi/Kconfig +++ b/hw/acpi/Kconfig @@ -10,6 +10,7 @@ config ACPI_X86 select ACPI_HMAT select ACPI_PIIX4 select ACPI_PCIHP +select ACPI_ERST config ACPI_X86_ICH bool @@ -60,3 +61,8 @@ config ACPI_HW_REDUCED select ACPI select ACPI_MEMORY_HOTPLUG select ACPI_NVDIMM + +config ACPI_ERST +bool +default y +depends on ACPI && PCI diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c new file mode 100644 index 000..4304f55 --- /dev/null +++ b/hw/acpi/erst.c @@ -0,0 +1,836 @@ +/* + * ACPI Error Record Serialization Table, ERST, Implementation + * + * ACPI ERST introduced in ACPI 4.0, June 16, 2009. + * ACPI Platform Error Interfaces : Error Serialization + * + * Copyright (c) 2021 Oracle and/or its affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-core.h" +#include "exec/memory.h" +#include "qom/object.h" +#include "hw/pci/pci.h" +#include "qom/object_interfaces.h" +#include "qemu/error-report.h" +#include "migration/vmstate.h" +#include "hw/qdev-properties.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-defs.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/bios-linker-loader.h" +#include "exec/address-spaces.h" +#include "sysemu/hostmem.h" +#include "hw/acpi/erst.h" +#include "trace.h" + +/* ACPI 4.0: Table 17-16 Serialization Actions */ +#define ACTION_BEGIN_WRITE_OPERATION 0x0 +#define ACTION_BEGIN_READ_OPERATION 0x1 +#define ACTION_BEGIN_CLEAR_OPERATION 0x2 +#define ACTION_END_OPERATION 0x3 +#define ACTION_SET_RECORD_OFFSET 0x4 +#define ACTION_EXECUTE_OPERATION 0x5 +#define ACTION_CHECK_BUSY_STATUS 0x6 +#define ACTION_GET_COMMAND_STATUS0x7 +#define ACTION_GET_RECORD_IDENTIFIER 0x8 +#define ACTION_SET_RECORD_IDENTIFIER 0x9 +#define ACTION_GET_RECORD_COUNT 0xA +#define ACTION_BEGIN_DUMMY_WRITE_OPERATION 0xB +#define ACTION_RESERVED 0xC +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE 0xD +#define ACTION_GET_ERROR_LOG_ADDRESS_LENGTH 0xE +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES 0xF +#define ACTION_GET_EXECUTE_OPERATION_TIMINGS 0x10 + +/* ACPI 4.0: Table 17-17 Command Status Definitions */ +#define STATUS_SUCCESS0x00 +#define STATUS_NOT_ENOUGH_SPACE 0x01 +#define STATUS_HARDWARE_NOT_AVAILABLE 0x02 +#define STATUS_FAILED 0x03 +#define STATUS_RECORD_STORE_EMPTY 0x04 +#define STATUS_RECORD_NOT_FOUND 0x05 + + +/* UEFI 2.1: Appendix N Common Platform Error Record */ +#define UEFI_CPER_RECORD_MIN_SIZE 128U +#define UEFI_CPER_RECORD_LENGTH_OFFSET 20U +#define UEFI_CPER_RECORD_ID_OFFSET 96U +#define IS_UEFI_CPER_RECORD(ptr) \ +(((ptr)[0] == 'C') && \ + ((ptr)[1] == 'P') && \ + ((ptr)[2] == 'E') && \ + ((ptr)[3] == 'R')) + +/* + * NOTE that when accessing CPER fields within a record, memcpy() + * is utilized to avoid a possible misaligned access on the host. + */ + +/* + * This implementation is an ACTION (cmd) and VALUE (data) + * interface consisting of just two 64-bit registers. + */ +#define ERST_REG_SIZE (16UL) +#define ERST_ACTION_OFFSET (0UL) /* action (cmd) */ +#define ERST_VALUE_OFFSET (8UL) /* argument/value (data) */ + +/* + * ERST_RECORD_SIZE is the buffer size for exchanging ERST + * record contents. Thus, it defines the maximum record size. + * As this is mapped through a PCI BAR, it must be a power of + * two and larger than UEFI_CPER_RECORD_MIN_SIZE. + * The backing storage is divided into fixed size "slots", + * each ERST_RECORD_SIZE in length, and each "slot" + * storing a single record. No attempt at optimizing storage + * through compression, compaction, etc is attempted. + * NOTE that slot 0 is reserved for the backing storage header. + * Depending upon the size of the backing storage, additional + * slots will be part of the slot 0 header in order to account + * for a record_id for each available remaining slot. + */ +/* 8KiB records, not too small, not too big */ +#define ERST_RECORD_SIZE (8192UL) + +#define ACPI_ERST_MEMDEV_PROP "memdev" +#define ACPI_ERST_RECORD_SIZE_PROP "record_size" + +/* + * From the ACPI ERST spec sections: +
Re: [PATCH v9 05/10] ACPI ERST: support for ACPI ERST feature
On Wed, Dec 8, 2021 at 10:08 PM Eric DeVolder wrote: > > > > On 12/6/21 02:14, Ani Sinha wrote: > > On Fri, Dec 3, 2021 at 12:39 AM Eric DeVolder > > wrote: > >> > >> This implements a PCI device for ACPI ERST. This implements the > >> non-NVRAM "mode" of operation for ERST as it is supported by > >> Linux and Windows. > > > > OK sent some more comments. It will take another pass for me to fully > > review this. > > > > Hi Ani, thank you for reviewing. I have incorporated your feedback thus far. > I have v10 ready to go but not sure if your review of v9 is completed yet? I completed scanning this patch. Don't hold your breath. I review things when I find gaps in other work and can't promise timely reviews. You can send a v10 once you have addressed my last set of comments.
Re: [PATCH v9 05/10] ACPI ERST: support for ACPI ERST feature
On Fri, Dec 3, 2021 at 12:39 AM Eric DeVolder wrote: > > This implements a PCI device for ACPI ERST. This implements the > non-NVRAM "mode" of operation for ERST as it is supported by > Linux and Windows. Few more comments on this patch ... > > Signed-off-by: Eric DeVolder > --- > hw/acpi/Kconfig | 6 + > hw/acpi/erst.c | 836 > +++ > hw/acpi/meson.build | 1 + > hw/acpi/trace-events | 15 + > 4 files changed, 858 insertions(+) > create mode 100644 hw/acpi/erst.c > > diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig > index 622b0b5..19caebd 100644 > --- a/hw/acpi/Kconfig > +++ b/hw/acpi/Kconfig > @@ -10,6 +10,7 @@ config ACPI_X86 > select ACPI_HMAT > select ACPI_PIIX4 > select ACPI_PCIHP > +select ACPI_ERST > > config ACPI_X86_ICH > bool > @@ -60,3 +61,8 @@ config ACPI_HW_REDUCED > select ACPI > select ACPI_MEMORY_HOTPLUG > select ACPI_NVDIMM > + > +config ACPI_ERST > +bool > +default y > +depends on ACPI && PCI > diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c > new file mode 100644 > index 000..4304f55 > --- /dev/null > +++ b/hw/acpi/erst.c > @@ -0,0 +1,836 @@ > +/* > + * ACPI Error Record Serialization Table, ERST, Implementation > + * > + * ACPI ERST introduced in ACPI 4.0, June 16, 2009. > + * ACPI Platform Error Interfaces : Error Serialization > + * > + * Copyright (c) 2021 Oracle and/or its affiliates. > + * > + * SPDX-License-Identifier: GPL-2.0-or-later > + */ > + > +#include > +#include > +#include > + > +#include "qemu/osdep.h" > +#include "qapi/error.h" > +#include "hw/qdev-core.h" > +#include "exec/memory.h" > +#include "qom/object.h" > +#include "hw/pci/pci.h" > +#include "qom/object_interfaces.h" > +#include "qemu/error-report.h" > +#include "migration/vmstate.h" > +#include "hw/qdev-properties.h" > +#include "hw/acpi/acpi.h" > +#include "hw/acpi/acpi-defs.h" > +#include "hw/acpi/aml-build.h" > +#include "hw/acpi/bios-linker-loader.h" > +#include "exec/address-spaces.h" > +#include "sysemu/hostmem.h" > +#include "hw/acpi/erst.h" > +#include "trace.h" > + > +/* ACPI 4.0: Table 17-16 Serialization Actions */ > +#define ACTION_BEGIN_WRITE_OPERATION 0x0 > +#define ACTION_BEGIN_READ_OPERATION 0x1 > +#define ACTION_BEGIN_CLEAR_OPERATION 0x2 > +#define ACTION_END_OPERATION 0x3 > +#define ACTION_SET_RECORD_OFFSET 0x4 > +#define ACTION_EXECUTE_OPERATION 0x5 > +#define ACTION_CHECK_BUSY_STATUS 0x6 > +#define ACTION_GET_COMMAND_STATUS0x7 > +#define ACTION_GET_RECORD_IDENTIFIER 0x8 > +#define ACTION_SET_RECORD_IDENTIFIER 0x9 > +#define ACTION_GET_RECORD_COUNT 0xA > +#define ACTION_BEGIN_DUMMY_WRITE_OPERATION 0xB > +#define ACTION_RESERVED 0xC > +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE 0xD > +#define ACTION_GET_ERROR_LOG_ADDRESS_LENGTH 0xE > +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES 0xF > +#define ACTION_GET_EXECUTE_OPERATION_TIMINGS 0x10 > + > +/* ACPI 4.0: Table 17-17 Command Status Definitions */ > +#define STATUS_SUCCESS0x00 > +#define STATUS_NOT_ENOUGH_SPACE 0x01 > +#define STATUS_HARDWARE_NOT_AVAILABLE 0x02 > +#define STATUS_FAILED 0x03 > +#define STATUS_RECORD_STORE_EMPTY 0x04 > +#define STATUS_RECORD_NOT_FOUND 0x05 > + > + > +/* UEFI 2.1: Appendix N Common Platform Error Record */ > +#define UEFI_CPER_RECORD_MIN_SIZE 128U > +#define UEFI_CPER_RECORD_LENGTH_OFFSET 20U > +#define UEFI_CPER_RECORD_ID_OFFSET 96U > +#define IS_UEFI_CPER_RECORD(ptr) \ > +(((ptr)[0] == 'C') && \ > + ((ptr)[1] == 'P') && \ > + ((ptr)[2] == 'E') && \ > + ((ptr)[3] == 'R')) > + > +/* > + * NOTE that when accessing CPER fields within a record, memcpy() > + * is utilized to avoid a possible misaligned access on the host. > + */ > + > +/* > + * This implementation is an ACTION (cmd) and VALUE (data) > + * interface consisting of just two 64-bit registers. > + */ > +#define ERST_REG_SIZE (16UL) > +#define ERST_ACTION_OFFSET (0UL) /* action (cmd) */ > +#define ERST_VALUE_OFFSET (8UL) /* argument/value (data) */ > + > +/* > + * ERST_RECORD_SIZE is the buffer size for exchanging ERST > + * record contents. Thus, it defines the maximum record size. > + * As this is mapped through a PCI BAR, it must be a power of > + * two and larger than UEFI_CPER_RECORD_MIN_SIZE. > + * The backing storage is divided into fixed size "slots", > + * each ERST_RECORD_SIZE in length, and each "slot" > + * storing a single record. No attempt at optimizing storage > + * through compression, compaction, etc is attempted. > + * NOTE that slot 0 is reserved for the backing storage header. > + * Depending upon the size of the backing storage, additional > + * slots will be part of the slot 0 header in order to account > + * for a record_id for each available remaining slot. > + */ > +/* 8KiB records, not too
Re: [PATCH v9 05/10] ACPI ERST: support for ACPI ERST feature
On 12/6/21 02:14, Ani Sinha wrote: On Fri, Dec 3, 2021 at 12:39 AM Eric DeVolder wrote: This implements a PCI device for ACPI ERST. This implements the non-NVRAM "mode" of operation for ERST as it is supported by Linux and Windows. OK sent some more comments. It will take another pass for me to fully review this. Hi Ani, thank you for reviewing. I have incorporated your feedback thus far. I have v10 ready to go but not sure if your review of v9 is completed yet? Thanks! eric
Re: [PATCH v9 05/10] ACPI ERST: support for ACPI ERST feature
On Mon, Dec 6, 2021 at 9:51 PM Eric DeVolder wrote: > > Hi Ani, inline responses below. > eric > > On 12/6/21 02:14, Ani Sinha wrote: > > On Fri, Dec 3, 2021 at 12:39 AM Eric DeVolder > > wrote: > >> > >> This implements a PCI device for ACPI ERST. This implements the > >> non-NVRAM "mode" of operation for ERST as it is supported by > >> Linux and Windows. > > > > OK sent some more comments. It will take another pass for me to fully > > review this. > > > >> > >> Signed-off-by: Eric DeVolder > >> --- > >> hw/acpi/Kconfig | 6 + > >> hw/acpi/erst.c | 836 > >> +++ > >> hw/acpi/meson.build | 1 + > >> hw/acpi/trace-events | 15 + > >> 4 files changed, 858 insertions(+) > >> create mode 100644 hw/acpi/erst.c > >> > >> diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig > >> index 622b0b5..19caebd 100644 > >> --- a/hw/acpi/Kconfig > >> +++ b/hw/acpi/Kconfig > >> @@ -10,6 +10,7 @@ config ACPI_X86 > >> select ACPI_HMAT > >> select ACPI_PIIX4 > >> select ACPI_PCIHP > >> +select ACPI_ERST > >> > >> config ACPI_X86_ICH > >> bool > >> @@ -60,3 +61,8 @@ config ACPI_HW_REDUCED > >> select ACPI > >> select ACPI_MEMORY_HOTPLUG > >> select ACPI_NVDIMM > >> + > >> +config ACPI_ERST > >> +bool > >> +default y > >> +depends on ACPI && PCI > >> diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c > >> new file mode 100644 > >> index 000..4304f55 > >> --- /dev/null > >> +++ b/hw/acpi/erst.c > >> @@ -0,0 +1,836 @@ > >> +/* > >> + * ACPI Error Record Serialization Table, ERST, Implementation > >> + * > >> + * ACPI ERST introduced in ACPI 4.0, June 16, 2009. > >> + * ACPI Platform Error Interfaces : Error Serialization > >> + * > >> + * Copyright (c) 2021 Oracle and/or its affiliates. > >> + * > >> + * SPDX-License-Identifier: GPL-2.0-or-later > >> + */ > >> + > >> +#include > >> +#include > >> +#include > >> + > >> +#include "qemu/osdep.h" > >> +#include "qapi/error.h" > >> +#include "hw/qdev-core.h" > >> +#include "exec/memory.h" > >> +#include "qom/object.h" > >> +#include "hw/pci/pci.h" > >> +#include "qom/object_interfaces.h" > >> +#include "qemu/error-report.h" > >> +#include "migration/vmstate.h" > >> +#include "hw/qdev-properties.h" > >> +#include "hw/acpi/acpi.h" > >> +#include "hw/acpi/acpi-defs.h" > >> +#include "hw/acpi/aml-build.h" > >> +#include "hw/acpi/bios-linker-loader.h" > >> +#include "exec/address-spaces.h" > >> +#include "sysemu/hostmem.h" > >> +#include "hw/acpi/erst.h" > >> +#include "trace.h" > >> + > >> +/* ACPI 4.0: Table 17-16 Serialization Actions */ > > > > Is there any reason why you refer to version 4.0 and not the latest version > > 6.3? > Some time ago Igor asked that I cite the earliest spec reference in which > ERST appears. > > > > >> +#define ACTION_BEGIN_WRITE_OPERATION 0x0 > >> +#define ACTION_BEGIN_READ_OPERATION 0x1 > >> +#define ACTION_BEGIN_CLEAR_OPERATION 0x2 > >> +#define ACTION_END_OPERATION 0x3 > >> +#define ACTION_SET_RECORD_OFFSET 0x4 > >> +#define ACTION_EXECUTE_OPERATION 0x5 > >> +#define ACTION_CHECK_BUSY_STATUS 0x6 > >> +#define ACTION_GET_COMMAND_STATUS0x7 > >> +#define ACTION_GET_RECORD_IDENTIFIER 0x8 > >> +#define ACTION_SET_RECORD_IDENTIFIER 0x9 > >> +#define ACTION_GET_RECORD_COUNT 0xA > >> +#define ACTION_BEGIN_DUMMY_WRITE_OPERATION 0xB > >> +#define ACTION_RESERVED 0xC > >> +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE 0xD > >> +#define ACTION_GET_ERROR_LOG_ADDRESS_LENGTH 0xE > >> +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES 0xF > >> +#define ACTION_GET_EXECUTE_OPERATION_TIMINGS 0x10 > > > > ACTION_GET_EXECUTE_OPERATION_TIMINGS is not present here: > > https://uefi.org/sites/default/files/resources/ACPI_4.pdf, section > > 17.4.1.1 . > > But I do see it in version 6.3 > > https://uefi.org/sites/default/files/resources/ACPI_6_3_May16.pdf > > section 18.5.1.1 > Ah, should I remove it (to stay 4.0-esque), or leave it stay current? > > > > >> + > >> +/* ACPI 4.0: Table 17-17 Command Status Definitions */ > >> +#define STATUS_SUCCESS0x00 > >> +#define STATUS_NOT_ENOUGH_SPACE 0x01 > >> +#define STATUS_HARDWARE_NOT_AVAILABLE 0x02 > >> +#define STATUS_FAILED 0x03 > >> +#define STATUS_RECORD_STORE_EMPTY 0x04 > >> +#define STATUS_RECORD_NOT_FOUND 0x05 > >> + > >> + > >> +/* UEFI 2.1: Appendix N Common Platform Error Record */ > >> +#define UEFI_CPER_RECORD_MIN_SIZE 128U > >> +#define UEFI_CPER_RECORD_LENGTH_OFFSET 20U > >> +#define UEFI_CPER_RECORD_ID_OFFSET 96U > >> +#define IS_UEFI_CPER_RECORD(ptr) \ > >> +(((ptr)[0] == 'C') && \ > >> + ((ptr)[1] == 'P') && \ > >> + ((ptr)[2] == 'E') && \ > >> + ((ptr)[3] == 'R')) > >> + > >> +/* > >> + * NOTE that when accessing CPER fields within a record, memcpy() > >> + * is utilized to avoid a
Re: [PATCH v9 05/10] ACPI ERST: support for ACPI ERST feature
On Mon, Dec 6, 2021 at 9:51 PM Eric DeVolder wrote: > > Hi Ani, inline responses below. > eric > > On 12/6/21 02:14, Ani Sinha wrote: > > On Fri, Dec 3, 2021 at 12:39 AM Eric DeVolder > > wrote: > >> > >> This implements a PCI device for ACPI ERST. This implements the > >> non-NVRAM "mode" of operation for ERST as it is supported by > >> Linux and Windows. > > > > OK sent some more comments. It will take another pass for me to fully > > review this. > > > >> > >> Signed-off-by: Eric DeVolder > >> --- > >> hw/acpi/Kconfig | 6 + > >> hw/acpi/erst.c | 836 > >> +++ > >> hw/acpi/meson.build | 1 + > >> hw/acpi/trace-events | 15 + > >> 4 files changed, 858 insertions(+) > >> create mode 100644 hw/acpi/erst.c > >> > >> diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig > >> index 622b0b5..19caebd 100644 > >> --- a/hw/acpi/Kconfig > >> +++ b/hw/acpi/Kconfig > >> @@ -10,6 +10,7 @@ config ACPI_X86 > >> select ACPI_HMAT > >> select ACPI_PIIX4 > >> select ACPI_PCIHP > >> +select ACPI_ERST > >> > >> config ACPI_X86_ICH > >> bool > >> @@ -60,3 +61,8 @@ config ACPI_HW_REDUCED > >> select ACPI > >> select ACPI_MEMORY_HOTPLUG > >> select ACPI_NVDIMM > >> + > >> +config ACPI_ERST > >> +bool > >> +default y > >> +depends on ACPI && PCI > >> diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c > >> new file mode 100644 > >> index 000..4304f55 > >> --- /dev/null > >> +++ b/hw/acpi/erst.c > >> @@ -0,0 +1,836 @@ > >> +/* > >> + * ACPI Error Record Serialization Table, ERST, Implementation > >> + * > >> + * ACPI ERST introduced in ACPI 4.0, June 16, 2009. > >> + * ACPI Platform Error Interfaces : Error Serialization > >> + * > >> + * Copyright (c) 2021 Oracle and/or its affiliates. > >> + * > >> + * SPDX-License-Identifier: GPL-2.0-or-later > >> + */ > >> + > >> +#include > >> +#include > >> +#include > >> + > >> +#include "qemu/osdep.h" > >> +#include "qapi/error.h" > >> +#include "hw/qdev-core.h" > >> +#include "exec/memory.h" > >> +#include "qom/object.h" > >> +#include "hw/pci/pci.h" > >> +#include "qom/object_interfaces.h" > >> +#include "qemu/error-report.h" > >> +#include "migration/vmstate.h" > >> +#include "hw/qdev-properties.h" > >> +#include "hw/acpi/acpi.h" > >> +#include "hw/acpi/acpi-defs.h" > >> +#include "hw/acpi/aml-build.h" > >> +#include "hw/acpi/bios-linker-loader.h" > >> +#include "exec/address-spaces.h" > >> +#include "sysemu/hostmem.h" > >> +#include "hw/acpi/erst.h" > >> +#include "trace.h" > >> + > >> +/* ACPI 4.0: Table 17-16 Serialization Actions */ > > > > Is there any reason why you refer to version 4.0 and not the latest version > > 6.3? > Some time ago Igor asked that I cite the earliest spec reference in which > ERST appears. > > > > >> +#define ACTION_BEGIN_WRITE_OPERATION 0x0 > >> +#define ACTION_BEGIN_READ_OPERATION 0x1 > >> +#define ACTION_BEGIN_CLEAR_OPERATION 0x2 > >> +#define ACTION_END_OPERATION 0x3 > >> +#define ACTION_SET_RECORD_OFFSET 0x4 > >> +#define ACTION_EXECUTE_OPERATION 0x5 > >> +#define ACTION_CHECK_BUSY_STATUS 0x6 > >> +#define ACTION_GET_COMMAND_STATUS0x7 > >> +#define ACTION_GET_RECORD_IDENTIFIER 0x8 > >> +#define ACTION_SET_RECORD_IDENTIFIER 0x9 > >> +#define ACTION_GET_RECORD_COUNT 0xA > >> +#define ACTION_BEGIN_DUMMY_WRITE_OPERATION 0xB > >> +#define ACTION_RESERVED 0xC > >> +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE 0xD > >> +#define ACTION_GET_ERROR_LOG_ADDRESS_LENGTH 0xE > >> +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES 0xF > >> +#define ACTION_GET_EXECUTE_OPERATION_TIMINGS 0x10 > > > > ACTION_GET_EXECUTE_OPERATION_TIMINGS is not present here: > > https://uefi.org/sites/default/files/resources/ACPI_4.pdf, section > > 17.4.1.1 . > > But I do see it in version 6.3 > > https://uefi.org/sites/default/files/resources/ACPI_6_3_May16.pdf > > section 18.5.1.1 > Ah, should I remove it (to stay 4.0-esque), or leave it stay current? I would leave it there since its in the latest spec but add a comment mentioning which version of ACPI this action was introduced. If someone else thinks otherwise, please speak up now. > > > > >> + > >> +/* ACPI 4.0: Table 17-17 Command Status Definitions */ > >> +#define STATUS_SUCCESS0x00 > >> +#define STATUS_NOT_ENOUGH_SPACE 0x01 > >> +#define STATUS_HARDWARE_NOT_AVAILABLE 0x02 > >> +#define STATUS_FAILED 0x03 > >> +#define STATUS_RECORD_STORE_EMPTY 0x04 > >> +#define STATUS_RECORD_NOT_FOUND 0x05 > >> + > >> + > >> +/* UEFI 2.1: Appendix N Common Platform Error Record */ > >> +#define UEFI_CPER_RECORD_MIN_SIZE 128U > >> +#define UEFI_CPER_RECORD_LENGTH_OFFSET 20U > >> +#define UEFI_CPER_RECORD_ID_OFFSET 96U > >> +#define IS_UEFI_CPER_RECORD(ptr) \ > >> +(((ptr)[0] == 'C') && \ > >> + ((ptr)[1] == 'P') &&
Re: [PATCH v9 05/10] ACPI ERST: support for ACPI ERST feature
Hi Ani, inline responses below. eric On 12/6/21 02:14, Ani Sinha wrote: On Fri, Dec 3, 2021 at 12:39 AM Eric DeVolder wrote: This implements a PCI device for ACPI ERST. This implements the non-NVRAM "mode" of operation for ERST as it is supported by Linux and Windows. OK sent some more comments. It will take another pass for me to fully review this. Signed-off-by: Eric DeVolder --- hw/acpi/Kconfig | 6 + hw/acpi/erst.c | 836 +++ hw/acpi/meson.build | 1 + hw/acpi/trace-events | 15 + 4 files changed, 858 insertions(+) create mode 100644 hw/acpi/erst.c diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig index 622b0b5..19caebd 100644 --- a/hw/acpi/Kconfig +++ b/hw/acpi/Kconfig @@ -10,6 +10,7 @@ config ACPI_X86 select ACPI_HMAT select ACPI_PIIX4 select ACPI_PCIHP +select ACPI_ERST config ACPI_X86_ICH bool @@ -60,3 +61,8 @@ config ACPI_HW_REDUCED select ACPI select ACPI_MEMORY_HOTPLUG select ACPI_NVDIMM + +config ACPI_ERST +bool +default y +depends on ACPI && PCI diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c new file mode 100644 index 000..4304f55 --- /dev/null +++ b/hw/acpi/erst.c @@ -0,0 +1,836 @@ +/* + * ACPI Error Record Serialization Table, ERST, Implementation + * + * ACPI ERST introduced in ACPI 4.0, June 16, 2009. + * ACPI Platform Error Interfaces : Error Serialization + * + * Copyright (c) 2021 Oracle and/or its affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-core.h" +#include "exec/memory.h" +#include "qom/object.h" +#include "hw/pci/pci.h" +#include "qom/object_interfaces.h" +#include "qemu/error-report.h" +#include "migration/vmstate.h" +#include "hw/qdev-properties.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-defs.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/bios-linker-loader.h" +#include "exec/address-spaces.h" +#include "sysemu/hostmem.h" +#include "hw/acpi/erst.h" +#include "trace.h" + +/* ACPI 4.0: Table 17-16 Serialization Actions */ Is there any reason why you refer to version 4.0 and not the latest version 6.3? Some time ago Igor asked that I cite the earliest spec reference in which ERST appears. +#define ACTION_BEGIN_WRITE_OPERATION 0x0 +#define ACTION_BEGIN_READ_OPERATION 0x1 +#define ACTION_BEGIN_CLEAR_OPERATION 0x2 +#define ACTION_END_OPERATION 0x3 +#define ACTION_SET_RECORD_OFFSET 0x4 +#define ACTION_EXECUTE_OPERATION 0x5 +#define ACTION_CHECK_BUSY_STATUS 0x6 +#define ACTION_GET_COMMAND_STATUS0x7 +#define ACTION_GET_RECORD_IDENTIFIER 0x8 +#define ACTION_SET_RECORD_IDENTIFIER 0x9 +#define ACTION_GET_RECORD_COUNT 0xA +#define ACTION_BEGIN_DUMMY_WRITE_OPERATION 0xB +#define ACTION_RESERVED 0xC +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE 0xD +#define ACTION_GET_ERROR_LOG_ADDRESS_LENGTH 0xE +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES 0xF +#define ACTION_GET_EXECUTE_OPERATION_TIMINGS 0x10 ACTION_GET_EXECUTE_OPERATION_TIMINGS is not present here: https://uefi.org/sites/default/files/resources/ACPI_4.pdf, section 17.4.1.1 . But I do see it in version 6.3 https://uefi.org/sites/default/files/resources/ACPI_6_3_May16.pdf section 18.5.1.1 Ah, should I remove it (to stay 4.0-esque), or leave it stay current? + +/* ACPI 4.0: Table 17-17 Command Status Definitions */ +#define STATUS_SUCCESS0x00 +#define STATUS_NOT_ENOUGH_SPACE 0x01 +#define STATUS_HARDWARE_NOT_AVAILABLE 0x02 +#define STATUS_FAILED 0x03 +#define STATUS_RECORD_STORE_EMPTY 0x04 +#define STATUS_RECORD_NOT_FOUND 0x05 + + +/* UEFI 2.1: Appendix N Common Platform Error Record */ +#define UEFI_CPER_RECORD_MIN_SIZE 128U +#define UEFI_CPER_RECORD_LENGTH_OFFSET 20U +#define UEFI_CPER_RECORD_ID_OFFSET 96U +#define IS_UEFI_CPER_RECORD(ptr) \ +(((ptr)[0] == 'C') && \ + ((ptr)[1] == 'P') && \ + ((ptr)[2] == 'E') && \ + ((ptr)[3] == 'R')) + +/* + * NOTE that when accessing CPER fields within a record, memcpy() + * is utilized to avoid a possible misaligned access on the host. + */ + +/* + * This implementation is an ACTION (cmd) and VALUE (data) + * interface consisting of just two 64-bit registers. + */ +#define ERST_REG_SIZE (16UL) +#define ERST_ACTION_OFFSET (0UL) /* action (cmd) */ +#define ERST_VALUE_OFFSET (8UL) /* argument/value (data) */ + +/* + * ERST_RECORD_SIZE is the buffer size for exchanging ERST + * record contents. Thus, it defines the maximum record size. + * As this is mapped through a PCI BAR, it must be a power of + * two and larger than UEFI_CPER_RECORD_MIN_SIZE. + * The backing storage is divided into fixed size "slots", + * each ERST_RECORD_SIZE in length, and each "slot" + * storing a single record. No
Re: [PATCH v9 05/10] ACPI ERST: support for ACPI ERST feature
On Fri, Dec 3, 2021 at 12:39 AM Eric DeVolder wrote: > > This implements a PCI device for ACPI ERST. This implements the > non-NVRAM "mode" of operation for ERST as it is supported by > Linux and Windows. OK sent some more comments. It will take another pass for me to fully review this. > > Signed-off-by: Eric DeVolder > --- > hw/acpi/Kconfig | 6 + > hw/acpi/erst.c | 836 > +++ > hw/acpi/meson.build | 1 + > hw/acpi/trace-events | 15 + > 4 files changed, 858 insertions(+) > create mode 100644 hw/acpi/erst.c > > diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig > index 622b0b5..19caebd 100644 > --- a/hw/acpi/Kconfig > +++ b/hw/acpi/Kconfig > @@ -10,6 +10,7 @@ config ACPI_X86 > select ACPI_HMAT > select ACPI_PIIX4 > select ACPI_PCIHP > +select ACPI_ERST > > config ACPI_X86_ICH > bool > @@ -60,3 +61,8 @@ config ACPI_HW_REDUCED > select ACPI > select ACPI_MEMORY_HOTPLUG > select ACPI_NVDIMM > + > +config ACPI_ERST > +bool > +default y > +depends on ACPI && PCI > diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c > new file mode 100644 > index 000..4304f55 > --- /dev/null > +++ b/hw/acpi/erst.c > @@ -0,0 +1,836 @@ > +/* > + * ACPI Error Record Serialization Table, ERST, Implementation > + * > + * ACPI ERST introduced in ACPI 4.0, June 16, 2009. > + * ACPI Platform Error Interfaces : Error Serialization > + * > + * Copyright (c) 2021 Oracle and/or its affiliates. > + * > + * SPDX-License-Identifier: GPL-2.0-or-later > + */ > + > +#include > +#include > +#include > + > +#include "qemu/osdep.h" > +#include "qapi/error.h" > +#include "hw/qdev-core.h" > +#include "exec/memory.h" > +#include "qom/object.h" > +#include "hw/pci/pci.h" > +#include "qom/object_interfaces.h" > +#include "qemu/error-report.h" > +#include "migration/vmstate.h" > +#include "hw/qdev-properties.h" > +#include "hw/acpi/acpi.h" > +#include "hw/acpi/acpi-defs.h" > +#include "hw/acpi/aml-build.h" > +#include "hw/acpi/bios-linker-loader.h" > +#include "exec/address-spaces.h" > +#include "sysemu/hostmem.h" > +#include "hw/acpi/erst.h" > +#include "trace.h" > + > +/* ACPI 4.0: Table 17-16 Serialization Actions */ Is there any reason why you refer to version 4.0 and not the latest version 6.3? > +#define ACTION_BEGIN_WRITE_OPERATION 0x0 > +#define ACTION_BEGIN_READ_OPERATION 0x1 > +#define ACTION_BEGIN_CLEAR_OPERATION 0x2 > +#define ACTION_END_OPERATION 0x3 > +#define ACTION_SET_RECORD_OFFSET 0x4 > +#define ACTION_EXECUTE_OPERATION 0x5 > +#define ACTION_CHECK_BUSY_STATUS 0x6 > +#define ACTION_GET_COMMAND_STATUS0x7 > +#define ACTION_GET_RECORD_IDENTIFIER 0x8 > +#define ACTION_SET_RECORD_IDENTIFIER 0x9 > +#define ACTION_GET_RECORD_COUNT 0xA > +#define ACTION_BEGIN_DUMMY_WRITE_OPERATION 0xB > +#define ACTION_RESERVED 0xC > +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE 0xD > +#define ACTION_GET_ERROR_LOG_ADDRESS_LENGTH 0xE > +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES 0xF > +#define ACTION_GET_EXECUTE_OPERATION_TIMINGS 0x10 ACTION_GET_EXECUTE_OPERATION_TIMINGS is not present here: https://uefi.org/sites/default/files/resources/ACPI_4.pdf, section 17.4.1.1 . But I do see it in version 6.3 https://uefi.org/sites/default/files/resources/ACPI_6_3_May16.pdf section 18.5.1.1 > + > +/* ACPI 4.0: Table 17-17 Command Status Definitions */ > +#define STATUS_SUCCESS0x00 > +#define STATUS_NOT_ENOUGH_SPACE 0x01 > +#define STATUS_HARDWARE_NOT_AVAILABLE 0x02 > +#define STATUS_FAILED 0x03 > +#define STATUS_RECORD_STORE_EMPTY 0x04 > +#define STATUS_RECORD_NOT_FOUND 0x05 > + > + > +/* UEFI 2.1: Appendix N Common Platform Error Record */ > +#define UEFI_CPER_RECORD_MIN_SIZE 128U > +#define UEFI_CPER_RECORD_LENGTH_OFFSET 20U > +#define UEFI_CPER_RECORD_ID_OFFSET 96U > +#define IS_UEFI_CPER_RECORD(ptr) \ > +(((ptr)[0] == 'C') && \ > + ((ptr)[1] == 'P') && \ > + ((ptr)[2] == 'E') && \ > + ((ptr)[3] == 'R')) > + > +/* > + * NOTE that when accessing CPER fields within a record, memcpy() > + * is utilized to avoid a possible misaligned access on the host. > + */ > + > +/* > + * This implementation is an ACTION (cmd) and VALUE (data) > + * interface consisting of just two 64-bit registers. > + */ > +#define ERST_REG_SIZE (16UL) > +#define ERST_ACTION_OFFSET (0UL) /* action (cmd) */ > +#define ERST_VALUE_OFFSET (8UL) /* argument/value (data) */ > + > +/* > + * ERST_RECORD_SIZE is the buffer size for exchanging ERST > + * record contents. Thus, it defines the maximum record size. > + * As this is mapped through a PCI BAR, it must be a power of > + * two and larger than UEFI_CPER_RECORD_MIN_SIZE. > + * The backing storage is divided into fixed size "slots", > + * each ERST_RECORD_SIZE in length, and each "slot" > + * storing a single record.
[PATCH v9 05/10] ACPI ERST: support for ACPI ERST feature
This implements a PCI device for ACPI ERST. This implements the non-NVRAM "mode" of operation for ERST as it is supported by Linux and Windows. Signed-off-by: Eric DeVolder --- hw/acpi/Kconfig | 6 + hw/acpi/erst.c | 836 +++ hw/acpi/meson.build | 1 + hw/acpi/trace-events | 15 + 4 files changed, 858 insertions(+) create mode 100644 hw/acpi/erst.c diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig index 622b0b5..19caebd 100644 --- a/hw/acpi/Kconfig +++ b/hw/acpi/Kconfig @@ -10,6 +10,7 @@ config ACPI_X86 select ACPI_HMAT select ACPI_PIIX4 select ACPI_PCIHP +select ACPI_ERST config ACPI_X86_ICH bool @@ -60,3 +61,8 @@ config ACPI_HW_REDUCED select ACPI select ACPI_MEMORY_HOTPLUG select ACPI_NVDIMM + +config ACPI_ERST +bool +default y +depends on ACPI && PCI diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c new file mode 100644 index 000..4304f55 --- /dev/null +++ b/hw/acpi/erst.c @@ -0,0 +1,836 @@ +/* + * ACPI Error Record Serialization Table, ERST, Implementation + * + * ACPI ERST introduced in ACPI 4.0, June 16, 2009. + * ACPI Platform Error Interfaces : Error Serialization + * + * Copyright (c) 2021 Oracle and/or its affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-core.h" +#include "exec/memory.h" +#include "qom/object.h" +#include "hw/pci/pci.h" +#include "qom/object_interfaces.h" +#include "qemu/error-report.h" +#include "migration/vmstate.h" +#include "hw/qdev-properties.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-defs.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/bios-linker-loader.h" +#include "exec/address-spaces.h" +#include "sysemu/hostmem.h" +#include "hw/acpi/erst.h" +#include "trace.h" + +/* ACPI 4.0: Table 17-16 Serialization Actions */ +#define ACTION_BEGIN_WRITE_OPERATION 0x0 +#define ACTION_BEGIN_READ_OPERATION 0x1 +#define ACTION_BEGIN_CLEAR_OPERATION 0x2 +#define ACTION_END_OPERATION 0x3 +#define ACTION_SET_RECORD_OFFSET 0x4 +#define ACTION_EXECUTE_OPERATION 0x5 +#define ACTION_CHECK_BUSY_STATUS 0x6 +#define ACTION_GET_COMMAND_STATUS0x7 +#define ACTION_GET_RECORD_IDENTIFIER 0x8 +#define ACTION_SET_RECORD_IDENTIFIER 0x9 +#define ACTION_GET_RECORD_COUNT 0xA +#define ACTION_BEGIN_DUMMY_WRITE_OPERATION 0xB +#define ACTION_RESERVED 0xC +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE 0xD +#define ACTION_GET_ERROR_LOG_ADDRESS_LENGTH 0xE +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES 0xF +#define ACTION_GET_EXECUTE_OPERATION_TIMINGS 0x10 + +/* ACPI 4.0: Table 17-17 Command Status Definitions */ +#define STATUS_SUCCESS0x00 +#define STATUS_NOT_ENOUGH_SPACE 0x01 +#define STATUS_HARDWARE_NOT_AVAILABLE 0x02 +#define STATUS_FAILED 0x03 +#define STATUS_RECORD_STORE_EMPTY 0x04 +#define STATUS_RECORD_NOT_FOUND 0x05 + + +/* UEFI 2.1: Appendix N Common Platform Error Record */ +#define UEFI_CPER_RECORD_MIN_SIZE 128U +#define UEFI_CPER_RECORD_LENGTH_OFFSET 20U +#define UEFI_CPER_RECORD_ID_OFFSET 96U +#define IS_UEFI_CPER_RECORD(ptr) \ +(((ptr)[0] == 'C') && \ + ((ptr)[1] == 'P') && \ + ((ptr)[2] == 'E') && \ + ((ptr)[3] == 'R')) + +/* + * NOTE that when accessing CPER fields within a record, memcpy() + * is utilized to avoid a possible misaligned access on the host. + */ + +/* + * This implementation is an ACTION (cmd) and VALUE (data) + * interface consisting of just two 64-bit registers. + */ +#define ERST_REG_SIZE (16UL) +#define ERST_ACTION_OFFSET (0UL) /* action (cmd) */ +#define ERST_VALUE_OFFSET (8UL) /* argument/value (data) */ + +/* + * ERST_RECORD_SIZE is the buffer size for exchanging ERST + * record contents. Thus, it defines the maximum record size. + * As this is mapped through a PCI BAR, it must be a power of + * two and larger than UEFI_CPER_RECORD_MIN_SIZE. + * The backing storage is divided into fixed size "slots", + * each ERST_RECORD_SIZE in length, and each "slot" + * storing a single record. No attempt at optimizing storage + * through compression, compaction, etc is attempted. + * NOTE that slot 0 is reserved for the backing storage header. + * Depending upon the size of the backing storage, additional + * slots will be part of the slot 0 header in order to account + * for a record_id for each available remaining slot. + */ +/* 8KiB records, not too small, not too big */ +#define ERST_RECORD_SIZE (8192UL) + +#define ACPI_ERST_MEMDEV_PROP "memdev" +#define ACPI_ERST_RECORD_SIZE_PROP "record_size" + +/* + * From the ACPI ERST spec sections: + * A record id of all 0s is used to indicate 'unspecified' record id. + * A record id of all 1s is used to indicate empty or end. + */ +#define ERST_UNSPECIFIED_RECORD_ID (0UL)