Linux ACPI
 help / color / mirror / Atom feed
From: Tony Luck <tony.luck@intel.com>
To: zaidal@os.amperecomputing.com
Cc: Jonathan.Cameron@huawei.com, benjamin.cheatham@amd.com,
	bp@alien8.de, dan.carpenter@linaro.org, dan.j.williams@intel.com,
	dave.jiang@intel.com, gregkh@linuxfoundation.org,
	gustavoars@kernel.org, ira.weiny@intel.com, james.morse@arm.com,
	jonathanh@nvidia.com, kees@kernel.org, lenb@kernel.org,
	linux-acpi@vger.kernel.org, linux-hardening@vger.kernel.org,
	linux-kernel@vger.kernel.org, peterz@infradead.org,
	rafael@kernel.org, sthanneeru.opensrc@micron.com,
	sudeep.holla@arm.com, tony.luck@intel.com,
	viro@zeniv.linux.org.uk, Yi1 Lai <yi1.lai@intel.com>
Subject: [PATCH] ACPI: APEI: EINJ: Fix trigger actions
Date: Thu,  3 Jul 2025 13:04:21 -0700	[thread overview]
Message-ID: <20250703200421.28012-1-tony.luck@intel.com> (raw)
In-Reply-To: <20250617193026.637510-2-zaidal@os.amperecomputing.com>

The trigger events are in BIOS memory immediately following the
acpi_einj_trigger structure. These were not copied to regular
kernel memory for use by apei_exec_ctx_init() so injections in
"notrigger=0" mode failed with a message like this:

  APEI: Invalid action table, unknown instruction type: 123

Fix by allocating a "table_size" block of memory and copying the whole
table for use in the rest of the trigger flow.

Fixes: 1a35c88302a3 ("ACPI: APEI: EINJ: Fix kernel test sparse warnings")
Reported-by: Yi1 Lai <yi1.lai@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
---
 drivers/acpi/apei/einj-core.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
index 3d37978418e8..bf8dc92a373a 100644
--- a/drivers/acpi/apei/einj-core.c
+++ b/drivers/acpi/apei/einj-core.c
@@ -394,6 +394,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
 				u64 param1, u64 param2)
 {
 	struct acpi_einj_trigger trigger_tab;
+	struct acpi_einj_trigger *full_trigger_tab;
 	struct apei_exec_context trigger_ctx;
 	struct apei_resources trigger_resources;
 	struct acpi_whea_header *trigger_entry;
@@ -430,6 +431,9 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
 
 	rc = -EIO;
 	table_size = trigger_tab.table_size;
+	full_trigger_tab = kmalloc(table_size, GFP_KERNEL);
+	if (!full_trigger_tab)
+		goto out_rel_header;
 	r = request_mem_region(trigger_paddr + sizeof(trigger_tab),
 			       table_size - sizeof(trigger_tab),
 			       "APEI EINJ Trigger Table");
@@ -437,7 +441,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
 		pr_err("Can not request [mem %#010llx-%#010llx] for Trigger Table Entry\n",
 		       (unsigned long long)trigger_paddr + sizeof(trigger_tab),
 		       (unsigned long long)trigger_paddr + table_size - 1);
-		goto out_rel_header;
+		goto out_free_trigger_tab;
 	}
 	iounmap(p);
 	p = ioremap_cache(trigger_paddr, table_size);
@@ -445,9 +449,9 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
 		pr_err("Failed to map trigger table!\n");
 		goto out_rel_entry;
 	}
-	memcpy_fromio(&trigger_tab, p, sizeof(trigger_tab));
+	memcpy_fromio(full_trigger_tab, p, table_size);
 	trigger_entry = (struct acpi_whea_header *)
-		((char *)&trigger_tab + sizeof(struct acpi_einj_trigger));
+		((char *)full_trigger_tab + sizeof(struct acpi_einj_trigger));
 	apei_resources_init(&trigger_resources);
 	apei_exec_ctx_init(&trigger_ctx, einj_ins_type,
 			   ARRAY_SIZE(einj_ins_type),
@@ -469,7 +473,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
 
 		apei_resources_init(&addr_resources);
 		trigger_param_region = einj_get_trigger_parameter_region(
-			&trigger_tab, param1, param2);
+			full_trigger_tab, param1, param2);
 		if (trigger_param_region) {
 			rc = apei_resources_add(&addr_resources,
 				trigger_param_region->address,
@@ -500,6 +504,8 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
 out_rel_entry:
 	release_mem_region(trigger_paddr + sizeof(trigger_tab),
 			   table_size - sizeof(trigger_tab));
+out_free_trigger_tab:
+	kfree(full_trigger_tab);
 out_rel_header:
 	release_mem_region(trigger_paddr, sizeof(trigger_tab));
 out:
-- 
2.50.0


  reply	other threads:[~2025-07-03 20:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-17 19:30 [PATCH v10 0/7] Enable EINJv2 Support Zaid Alali
2025-06-17 19:30 ` [PATCH v10 1/7] ACPI: APEI: EINJ: Fix kernel test sparse warnings Zaid Alali
2025-07-03 20:04   ` Tony Luck [this message]
2025-07-07 16:24     ` [PATCH] ACPI: APEI: EINJ: Fix trigger actions Rafael J. Wysocki
2025-06-17 19:30 ` [PATCH v10 2/7] ACPI: APEI: EINJ: Enable the discovery of EINJv2 capabilities Zaid Alali
2025-06-17 19:30 ` [PATCH v10 3/7] ACPI: APEI: EINJ: Add einjv2 extension struct Zaid Alali
2025-06-17 19:30 ` [PATCH v10 4/7] ACPI: APEI: EINJ: Discover EINJv2 parameters Zaid Alali
2025-06-17 19:30 ` [PATCH v10 5/7] ACPI: APEI: EINJ: Create debugfs files to enter device id and syndrome Zaid Alali
2025-06-17 19:30 ` [PATCH v10 6/7] ACPI: APEI: EINJ: Enable EINJv2 error injections Zaid Alali
2025-06-17 19:30 ` [PATCH v10 7/7] ACPI: APEI: EINJ: Update the documentation for EINJv2 support Zaid Alali
2025-06-18 18:51 ` [PATCH v10 0/7] Enable EINJv2 Support Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250703200421.28012-1-tony.luck@intel.com \
    --to=tony.luck@intel.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=benjamin.cheatham@amd.com \
    --cc=bp@alien8.de \
    --cc=dan.carpenter@linaro.org \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavoars@kernel.org \
    --cc=ira.weiny@intel.com \
    --cc=james.morse@arm.com \
    --cc=jonathanh@nvidia.com \
    --cc=kees@kernel.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=sthanneeru.opensrc@micron.com \
    --cc=sudeep.holla@arm.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=yi1.lai@intel.com \
    --cc=zaidal@os.amperecomputing.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox