ACPI: APEI: GHES: Add device-managed notifier helper and NVIDIA CPER handler
Subsystems (6)
Kai-Heng Feng
maintainerv3 cover ACPI: APEI: GHES: Add device-managed notifier helper and NVIDIA CPER handler
NVIDIA DGX and HGX platforms provide an ACPI device (NVDA2012) alongside the GHES error source. The device does not generate the error records itself; its purpose is to allow the vendor CPER handler driver to load automatically via ACPI enumeration rather than manual module loading.
The series introduces devm_ghes_register_vendor_record_notifier() helper, let HiSilicon PCI driver and new NVIDA GHES driver use the new helper.
Kai-Heng Feng (3):
ACPI: APEI: GHES: Add devm_ghes_register_vendor_record_notifier()
PCI: hisi: Use devm_ghes_register_vendor_record_notifier()
ACPI: APEI: GHES: Add NVIDIA vendor CPER record handler
MAINTAINERS | 6 + drivers/acpi/apei/Kconfig | 14 +++ drivers/acpi/apei/Makefile | 1 + drivers/acpi/apei/ghes-nvidia.c | 149 +++++++++++++++++++++++ drivers/acpi/apei/ghes.c | 18 +++ drivers/pci/controller/pcie-hisi-error.c | 12 +- include/acpi/ghes.h | 11 ++ 7 files changed, 200 insertions(+), 11 deletions(-) create mode 100644 drivers/acpi/apei/ghes-nvidia.c
Signature · 1 line
2.50.1 (Apple Git-155)
Kai-Heng Feng
maintainerPATCH v3 1/3 ACPI: APEI: GHES: Add devm_ghes_register_vendor_record_notifier()
Add a device-managed wrapper around ghes_register_vendor_record_notifier() so drivers can avoid manual cleanup on device removal or probe failure.
---
v3:
- Change patch title
- Move documentation to header file.
v2:
- New patch.
drivers/acpi/apei/ghes.c | 18 ++++++++++++++++++ include/acpi/ghes.h | 11 +++++++++++ 2 files changed, 29 insertions(+)
drivers/acpi/apei/ghes.c +18 -0
@@ -689,6 +689,24 @@ void ghes_unregister_vendor_record_notifier(struct notifier_block *nb) }EXPORT_SYMBOL_GPL (ghes_unregister_vendor_record_notifier); +static void ghes_vendor_record_notifier_destroy (void *nb) +{ +ghes_unregister_vendor_record_notifier (nb); +} + +int devm_ghes_register_vendor_record_notifier (struct device *dev, +struct notifier_block *nb) +{ +int ret; + + ret =ghes_register_vendor_record_notifier (nb); +if (ret) +return ret; + +return devm_add_action_or_reset (dev, ghes_vendor_record_notifier_destroy, nb); +} +EXPORT_SYMBOL_GPL (devm_ghes_register_vendor_record_notifier); +static void ghes_vendor_record_work_func (struct work_struct *work) {struct ghes_vendor_record_entry *entry;
include/acpi/ghes.h +11 -0
@@ -71,6 +71,17 @@ int ghes_register_vendor_record_notifier(struct notifier_block *nb);*/ void ghes_unregister_vendor_record_notifier (struct notifier_block *nb); +/** +* devm_ghes_register_vendor_record_notifier - device-managed vendor +* record notifier registration. +* @dev: device that owns the notifier lifetime +* @nb: pointer to the notifier_block structure of the vendor record handler +* +* Return: 0 on success, negative errno on failure. +*/ +int devm_ghes_register_vendor_record_notifier (struct device *dev, +struct notifier_block *nb); +struct list_head *ghes_get_devices (void );void ghes_estatus_pool_region_free (unsigned long addr,u32 size);
Signature · 1 line
2.50.1 (Apple Git-155)
Re: [PATCH v3 1/3] ACPI: APEI: GHES: Add devm_ghes_register_vendor_record_notifier()
Quoted 6 lines · Kai-Heng Feng
Add a device-managed wrapper around
ghes_register_vendor_record_notifier()so drivers can avoid manual cleanup on device removal or probe failure.Cc Shiju Jose <[email protected]>Cc Jonathan Cameron <[email protected]>Signed-off-by Kai-Heng Feng <[email protected]>
RE: [PATCH v3 1/3] ACPI: APEI: GHES: Add devm_ghes_register_vendor_record_notifier()
In reply to Kai-Heng FengQuoted 18 lines
-----Original Message-----
From: Kai-Heng Feng <[email protected]>
Sent: 30 March 2026 10:42
To: [email protected]
Cc: Jonathan Cameron <[email protected]>; [email protected]; Guohanjun (Hanjun Guo) <[email protected]>; [email protected]; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]; Kai-Heng Feng <[email protected]>; Shiju Jose <[email protected]>; Tony Luck <[email protected]>; Borislav Petkov <[email protected]>; Mauro Carvalho Chehab <[email protected]>; Shuai Xue <[email protected]>; Len Brown <[email protected]>; Robert Moore <[email protected]>; Fabio M. De Francesco <[email protected]>; Breno Leitao <[email protected]>; Jason Tian <[email protected]>
Subject: [PATCH v3 1/3] ACPI: APEI: GHES: Adddevm_ghes_register_vendor_record_notifier()
Quoted 7 lines
Add a device-managed wrapper around
ghes_register_vendor_record_notifier()
so drivers can avoid manual cleanup on device removal or probe failure.Cc Shiju Jose <[email protected]>Cc Jonathan Cameron <[email protected]>Signed-off-by Kai-Heng Feng <[email protected]>
Quoted 65 lines
---
v3:
- Change patch title
- Move documentation to header file.
v2:
- New patch.
drivers/acpi/apei/ghes.c| 18 ++++++++++++++++++include/acpi/ghes.h| 11 +++++++++++2 files changed, 29 insertions(+)drivers/acpi/apei/ghes.c index renamed from drivers/acpi/apei/ghes.c +0
-0
8acd2742bb27..3236a3ce79d6100644drivers/acpi/apei/ghes.c +17
-0@@ -689,6 +689,24 @@ void ghes_unregister_vendor_record_notifier(struct notifier_block *nb) }EXPORT_SYMBOL_GPL (ghes_unregister_vendor_record_notifier ); +static void ghes_vendor_record_notifier_destroy (void *nb) { +ghes_unregister_vendor_record_notifier (nb); +} + +int devm_ghes_register_vendor_record_notifier (struct device *dev, +struct notifier_block *nb) +{ +int ret; + + ret =ghes_register_vendor_record_notifier (nb); +if (ret) +return ret; + +return devm_add_action_or_reset (dev, +ghes_vendor_record_notifier_destroy, nb); } +EXPORT_SYMBOL_GPL (devm_ghes_register_vendor_record_notifier); +static void ghes_vendor_record_work_func (struct work_struct *work) { struct ghes_vendor_record_entry *entry; diff --git
a/include/acpi/ghes.hb/include/acpi/ghes.hindex7bea522c0657..8d7e5caef3f1100644include/acpi/ghes.h +12
-0@@ -71,6 +71,17 @@ int ghes_register_vendor_record_notifier(structnotifier_block *nb); */ void ghes_unregister_vendor_record_notifier (struct notifier_block *nb); +/** +* devm_ghes_register_vendor_record_notifier - device-managed vendor +* record notifier registration. +* @dev: device that owns the notifier lifetime +* @nb: pointer to the notifier_block structure of the vendor record +handler +* +* Return: 0 on success, negative errno on failure. +*/ +int devm_ghes_register_vendor_record_notifier (struct device *dev, +struct notifier_block *nb); +struct list_head *ghes_get_devices (void );void
ghes_estatus_pool_region_free(unsigned long addr, u32 size); --
2.50.1 (Apple Git-155)
Re: [PATCH v3 1/3] ACPI: APEI: GHES: Add devm_ghes_register_vendor_record_notifier()
In reply to Kai-Heng FengQuoted 6 lines · Kai-Heng Feng
Add a device-managed wrapper around
ghes_register_vendor_record_notifier()so drivers can avoid manual cleanup on device removal or probe failure.Cc Shiju Jose <[email protected]>Cc Jonathan Cameron <[email protected]>Signed-off-by Kai-Heng Feng <[email protected]>
LGTM.
Thanks.
Shuai
Kai-Heng Feng
maintainerPATCH v3 2/3 PCI: hisi: Use devm_ghes_register_vendor_record_notifier()
In reply to Kai-Heng FengSwitch to the device-managed variant so the notifier is automatically unregistered on device removal, allowing the open-coded remove callback to be dropped entirely.
---
v3:
- No change.
v2:
- New patch.
drivers/pci/controller/pcie-hisi-error.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/pci/controller/pcie-hisi-error.c +1 -11
@@ -287,25 +287,16 @@ static int hisi_pcie_error_handler_probe(struct platform_device *pdev) priv->nb.notifier_call = hisi_pcie_notify_error; priv->dev = &pdev->dev; - ret =ghes_register_vendor_record_notifier (&priv->nb); + ret =devm_ghes_register_vendor_record_notifier (&pdev->dev, &priv->nb);if (ret) {dev_err (&pdev->dev,"Failed to register hisi pcie controller error handler with apei\n" );return ret; } -platform_set_drvdata (pdev, priv); -return 0 ; } -static void hisi_pcie_error_handler_remove (struct platform_device *pdev) -{ -struct hisi_pcie_error_private *priv =platform_get_drvdata (pdev); - -ghes_unregister_vendor_record_notifier (&priv->nb); -} -static const struct acpi_device_id hisi_pcie_acpi_match[] = { {"HISI0361" ,0 }, { }
@@ -317,7 +308,6 @@ static struct platform_driver hisi_pcie_error_handler_driver = { .acpi_match_table = hisi_pcie_acpi_match, }, .probe = hisi_pcie_error_handler_probe, - .remove = hisi_pcie_error_handler_remove, };module_platform_driver (hisi_pcie_error_handler_driver);
Signature · 1 line
2.50.1 (Apple Git-155)
Re: [PATCH v3 2/3] PCI: hisi: Use devm_ghes_register_vendor_record_notifier()
Quoted 7 lines · Kai-Heng Feng
Switch to the device-managed variant so the notifier is automatically unregistered on device removal, allowing the open-coded remove callback to be dropped entirely.
Cc Shiju Jose <[email protected]>Cc Jonathan Cameron <[email protected]>Signed-off-by Kai-Heng Feng <[email protected]>
Since there is an API dependency, feel free to take it through ACPI tree.
- Mani
Quoted 51 lines
---
v3:
- No change.
v2:
- New patch.drivers/pci/controller/pcie-hisi-error.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)drivers/pci/controller/pcie-hisi-error.c +1
-11@@ -287,25 +287,16 @@ static int hisi_pcie_error_handler_probe(struct platform_device *pdev) priv->nb.notifier_call = hisi_pcie_notify_error; priv->dev = &pdev->dev; - ret =ghes_register_vendor_record_notifier (&priv->nb); + ret =devm_ghes_register_vendor_record_notifier (&pdev->dev, &priv->nb);if (ret) {dev_err (&pdev->dev,"Failed to register hisi pcie controller error handler with apei\n" );return ret; } -platform_set_drvdata (pdev, priv); -return 0 ; } -static void hisi_pcie_error_handler_remove (struct platform_device *pdev) -{ -struct hisi_pcie_error_private *priv =platform_get_drvdata (pdev); - -ghes_unregister_vendor_record_notifier (&priv->nb); -} -static const struct acpi_device_id hisi_pcie_acpi_match[] = { {"HISI0361" ,0 }, { }@@ -317,7 +308,6 @@ static struct platform_driver hisi_pcie_error_handler_driver = { .acpi_match_table = hisi_pcie_acpi_match, }, .probe = hisi_pcie_error_handler_probe, - .remove = hisi_pcie_error_handler_remove, };module_platform_driver (hisi_pcie_error_handler_driver);Signature · 1 line
2.50.1 (Apple Git-155)
Signature · 1 line
மணிவண்ணன் சதாசிவம்
RE: [PATCH v3 2/3] PCI: hisi: Use devm_ghes_register_vendor_record_notifier()
In reply to Kai-Heng FengQuoted 16 lines
-----Original Message-----
From: Kai-Heng Feng <[email protected]>
Sent: 30 March 2026 10:42
To: [email protected]
Cc: Jonathan Cameron <[email protected]>; [email protected]; Guohanjun (Hanjun Guo) <[email protected]>; [email protected]; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]; Kai-Heng Feng <[email protected]>; Shiju Jose <[email protected]>; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Manivannan Sadhasivam <[email protected]>; Rob Herring <[email protected]>; Bjorn Helgaas <[email protected]>
Subject: [PATCH v3 2/3] PCI: hisi: Usedevm_ghes_register_vendor_record_notifier()
Quoted 7 lines
Switch to the device-managed variant so the notifier is automatically unregistered on device removal, allowing the open-coded remove callback to be dropped entirely.
Cc Shiju Jose <[email protected]>Cc Jonathan Cameron <[email protected]>Signed-off-by Kai-Heng Feng <[email protected]>
Quoted 55 lines
---
v3:
- No change.
v2:
- New patch.
drivers/pci/controller/pcie-hisi-error.c| 12 +-----------1 file changed, 1 insertion(+), 11 deletions(-)drivers/pci/controller/pcie- renamed from drivers/pci/controller/pcie-hisi-error.c +0
-0
hisi-error.c
indexaaf1ed2b6e59..36be86d827a8100644drivers/pci/controller/pcie-hisi-error.c +2
-9@@ -287,25 +287,16 @@ static int hisi_pcie_error_handler_probe(struct platform_device *pdev) priv->nb.notifier_call = hisi_pcie_notify_error; priv->dev = &pdev->dev; - ret =ghes_register_vendor_record_notifier (&priv->nb); + ret =devm_ghes_register_vendor_record_notifier (&pdev->dev, +&priv->nb);if (ret) {dev_err (&pdev->dev, "Failed to register hisi pcie controller error handler with apei\n"); return ret; } -platform_set_drvdata (pdev, priv); -return 0 ; } -static void hisi_pcie_error_handler_remove(struct platform_device *pdev) -{ -struct hisi_pcie_error_private *priv =platform_get_drvdata (pdev); - -ghes_unregister_vendor_record_notifier (&priv->nb); -} -static const struct acpi_device_id hisi_pcie_acpi_match[] = { { "HISI0361", 0 }, { }drivers/pci/controller/pcie-hisi-error.c +0
-2@@ -317,7 +308,6 @@ static struct platform_driver hisi_pcie_error_handler_driver = { .acpi_match_table = hisi_pcie_acpi_match, }, .probe = hisi_pcie_error_handler_probe, - .remove = hisi_pcie_error_handler_remove, };module_platform_driver (hisi_pcie_error_handler_driver); --2.50.1 (Apple Git-155)
Kai-Heng Feng
maintainerPATCH v3 3/3 ACPI: APEI: GHES: Add NVIDIA vendor CPER record handler
In reply to Kai-Heng FengAdd support for decoding NVIDIA-specific CPER sections delivered via the APEI GHES vendor record notifier chain. NVIDIA hardware generates vendor-specific CPER sections containing error signatures and diagnostic register dumps. This implementation registers a notifier_block with the GHES vendor record notifier and decodes these sections, printing error details via dev_info().
The driver binds to ACPI device NVDA2012, present on NVIDIA server platforms. The NVIDIA CPER section contains a fixed header with error metadata (signature, error type, severity, socket) followed by variable-length register address-value pairs for hardware diagnostics.
This work is based on libcper [0].
Example output:
nvidia-ghes NVDA2012:00: NVIDIA CPER section, error_data_length: 544 nvidia-ghes NVDA2012:00: signature: CMET-INFO
nvidia-ghes NVDA2012:00: error_type: 0
nvidia-ghes NVDA2012:00: error_instance: 0
nvidia-ghes NVDA2012:00: severity: 3
nvidia-ghes NVDA2012:00: socket: 0
nvidia-ghes NVDA2012:00: number_regs: 32
nvidia-ghes NVDA2012:00: instance_base: 0x0000000000000000
nvidia-ghes NVDA2012:00: register[0]: address=0x8000000100000000 value=0x0000000100000000
[0] https://github.com/openbmc/libcper/commit/683e055061ce
---
v3:
- NVIDIA_GHES to GHES_NVIDIA.
- Better error handling in probe()
- "int i" in for loop.
v2:
- Use right headers.
- Use embedded struct and __counted_by.
- Drop __packed.
- Remove unecessary casts.
- Use * in sizeof().
- Use devm_kmalloc() and struct assignment.
- Use dev_err_probe and new devm helper.
MAINTAINERS | 6 ++ drivers/acpi/apei/Kconfig | 14 +++ drivers/acpi/apei/Makefile | 1 + drivers/acpi/apei/ghes-nvidia.c | 149 ++++++++++++++++++++++++++++++++ 4 files changed, 170 insertions(+) create mode 100644 drivers/acpi/apei/ghes-nvidia.c
MAINTAINERS +6 -0
@@ -18919,6 +18919,12 @@ S: Maintained F: drivers/video/fbdev/nvidia/ F: drivers/video/fbdev/riva/ +NVIDIA GHES VENDOR CPER RECORD HANDLER +M: Kai-Heng Feng <[email protected]> +L: [email protected] +S: Maintained +F: drivers/acpi/apei/nvidia-ghes.c + NVIDIA VRS RTC DRIVER M: Shubhi Garg <[email protected]> L: [email protected]
drivers/acpi/apei/Kconfig +14 -0
@@ -74,6 +74,20 @@ config ACPI_APEI_EINJ_CXL If unsure say 'n' +config ACPI_APEI_GHES_NVIDIA + tristate "NVIDIA GHES vendor record handler" + depends on ACPI_APEI_GHES + help + Support for decoding NVIDIA-specific CPER sections delivered via + the APEI GHES vendor record notifier chain. Registers a handler + for the NVIDIA section GUID and logs error signatures, severity, + socket, and diagnostic register address-value pairs. + + Enable on NVIDIA server platforms (e.g. DGX, HGX) that expose + ACPI device NVDA2012 in their firmware tables. + + If unsure, say N. + config ACPI_APEI_ERST_DEBUG tristate "APEI Error Record Serialization Table (ERST) Debug Support" depends on ACPI_APEI
drivers/acpi/apei/Makefile +1 -0
@@ -10,5 +10,6 @@ obj-$(CONFIG_ACPI_APEI_EINJ) += einj.o einj-y := einj-core.o einj-$(CONFIG_ACPI_APEI_EINJ_CXL) += einj-cxl.o obj-$(CONFIG_ACPI_APEI_ERST_DEBUG) += erst-dbg.o +obj-$(CONFIG_ACPI_APEI_GHES_NVIDIA) += ghes-nvidia.o apei-y := apei-base.o hest.o erst.o bert.o
drivers/acpi/apei/ghes-nvidia.c new file +149 -0
149 lines not on this page · raw message
Signature · 1 line
2.50.1 (Apple Git-155)
[email protected]
AI reviewRe: [PATCH v3 3/3] ACPI: APEI: GHES: Add NVIDIA vendor CPER record handler
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Dropping the `__packed` attribute from `struct cper_sec_nvidia` causes Undefined Behavior and…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Dropping the __packed attribute from struct cper_sec_nvidia causes Undefined Behavior and potential alignment faults when accessing 64-bit fields.
- [High] A signed-to-unsigned conversion vulnerability in the length check allows a maliciously crafted ACPI CPER record to bypass bounds validation. --
--- Patch [3]: [PATCH v3 3/3] ACPI: APEI: GHES: Add NVIDIA vendor CPER record handler --- commit ca65b6ef5ec8eb0410ab8adcafb43315cd0cfefa
Author: Kai-Heng Feng <[email protected]>
ACPI: APEI: GHES: Add NVIDIA vendor CPER record handler
This commit adds support for decoding NVIDIA-specific CPER sections via the APEI GHES vendor record notifier chain. It registers a notifier_block to parse and print error metadata and diagnostic register dumps.
Quoted 6 lines
drivers/acpi/apei/ghes-nvidia.c new file +0
-0@@ -0,0 +1,149 @@
[ ... ]
Quoted 4 lines
drivers/acpi/apei/ghes-nvidia.c new file +4
-0+struct cper_sec_nvidia { +char signature[16 ]; +__le16 error_type; +__le16 error_instance;
drivers/acpi/apei/ghes-nvidia.c line 32
Quoted 10 lines
drivers/acpi/apei/ghes-nvidia.c new file +10
-0+u8 severity; +u8 socket; +u8 number_regs; +u8 reserved; +__le64 instance_base; +struct { +__le64 addr; +__le64 val; + } regs[] __counted_by(number_regs); +};
[Severity: High]
Does dropping the __packed attribute from this structure introduce a risk of unaligned memory accesses?
The ACPI GHES error payload is often located at a 4-byte aligned offset (such as offset 84 or 92) from the estatus base block, meaning the pointer returned by acpi_hest_get_payload() can be unaligned.
Casting this misaligned pointer to a struct with 8-byte alignment requirements and accessing 64-bit members like instance_base or the regs array can result in undefined behavior or alignment faults on architectures with strict alignment requirements.
[ ... ]
Quoted 5 lines
drivers/acpi/apei/ghes-nvidia.c new file +5
-0+static int nvidia_ghes_notify (struct notifier_block *nb, +unsigned long event,void *data) +{ +struct acpi_hest_generic_data *gdata = data; +struct nvidia_ghes_private *priv;
drivers/acpi/apei/ghes-nvidia.c line 89
Quoted 10 lines
drivers/acpi/apei/ghes-nvidia.c new file +10
-0+const struct cper_sec_nvidia *nvidia_err; +guid_t sec_guid; + +import_guid (&sec_guid, gdata->section_type); +if (!guid_equal (&sec_guid, &nvidia_sec_guid)) +return NOTIFY_DONE ; + + priv = container_of(nb, struct nvidia_ghes_private, nb); + +if (acpi_hest_get_error_length (gdata) <sizeof (*nvidia_err)) {
[Severity: High]
Could a maliciously crafted ACPI CPER record bypass this length validation?
Looking at acpi_hest_get_error_length(), it returns an int. If the CPER record contains an error_data_length larger than INT_MAX, it will be returned as a negative int.
When this negative value is compared against sizeof(*nvidia_err), which is a size_t, it will be promoted to a very large unsigned integer. This causes the less-than condition to evaluate to false, bypassing the early return.
The bypassed length would then be passed as a size_t to nvidia_ghes_print_error(), where it again evaluates the error_data_length < min_size check as false, allowing the loop to perform an out-of-bounds memory read.
Quoted 4 lines
drivers/acpi/apei/ghes-nvidia.c new file +4
-0+dev_err (priv->dev,"Section too small (%d < %zu)\n" , +acpi_hest_get_error_length (gdata),sizeof (*nvidia_err)); +return NOTIFY_OK ; + }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Rafael J. Wysocki
maintainerQuoted 24 lines · Kai-Heng Feng
NVIDIA DGX and HGX platforms provide an ACPI device (NVDA2012) alongside the GHES error source. The device does not generate the error records itself; its purpose is to allow the vendor CPER handler driver to load automatically via ACPI enumeration rather than manual module loading.
The series introduces
devm_ghes_register_vendor_record_notifier()helper, let HiSilicon PCI driver and new NVIDA GHES driver use the new helper.Kai-Heng Feng (3):
ACPI: APEI: GHES: Adddevm_ghes_register_vendor_record_notifier()
PCI: hisi: Usedevm_ghes_register_vendor_record_notifier()
ACPI: APEI: GHES: Add NVIDIA vendor CPER record handlerMAINTAINERS | 6 + drivers/acpi/apei/Kconfig | 14 +++ drivers/acpi/apei/Makefile | 1 + drivers/acpi/apei/ghes-nvidia.c | 149 +++++++++++++++++++++++ drivers/acpi/apei/ghes.c | 18 +++ drivers/pci/controller/pcie-hisi-error.c | 12 +- include/acpi/ghes.h | 11 ++ 7 files changed, 200 insertions(+), 11 deletions(-) create mode 100644 drivers/acpi/apei/ghes-nvidia.c
Quoted 1 line
--
Whole series applied as 7.1 material, thanks!