From: Zaid Alali <zaidal@os.amperecomputing.com>
To: rafael@kernel.org, lenb@kernel.org, james.morse@arm.com,
tony.luck@intel.com, bp@alien8.de, kees@kernel.org,
gustavoars@kernel.org, zaidal@os.amperecomputing.com,
Jonathan.Cameron@huawei.com, sudeep.holla@arm.com,
u.kleine-koenig@baylibre.com, jonathanh@nvidia.com,
viro@zeniv.linux.org.uk, ira.weiny@intel.com,
peterz@infradead.org, sthanneeru.opensrc@micron.com,
gregkh@linuxfoundation.org, Benjamin.Cheatham@amd.com,
dave.jiang@intel.com, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: [PATCH v8 4/7] ACPI: APEI: EINJ: Discover EINJv2 parameters
Date: Wed, 4 Jun 2025 15:38:01 -0700 [thread overview]
Message-ID: <20250604223804.842501-5-zaidal@os.amperecomputing.com> (raw)
In-Reply-To: <20250604223804.842501-1-zaidal@os.amperecomputing.com>
The EINJv2 set_error_type_with_address structure has a flex array
to hold the component IDs and syndrome values used when injecting
multiple errors at once.
Discover the size of this array by taking the address from the
ACPI_EINJ_SET_ERROR_TYPE_WITH_ADDRESS entry in the EINJ table
and reading the BIOS copy of the structure.
Derive the maximum number of components from the length field
in the einjv2_extension_struct at the end of the BIOS copy.
Map the whole of the structure into kernel memory (and unmap
on module unload).
[Tony: Code unchanged from Zaid's original. New commit message]
Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
---
drivers/acpi/apei/einj-core.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
index e74281f5044e..08cac48293a2 100644
--- a/drivers/acpi/apei/einj-core.c
+++ b/drivers/acpi/apei/einj-core.c
@@ -107,6 +107,7 @@ static struct debugfs_blob_wrapper vendor_blob;
static struct debugfs_blob_wrapper vendor_errors;
static char vendor_dev[64];
+static u32 max_nr_components;
static u32 available_error_type;
static u32 available_error_type_v2;
@@ -177,6 +178,7 @@ static DEFINE_MUTEX(einj_mutex);
bool einj_initialized __ro_after_init;
static void __iomem *einj_param;
+static u32 v5param_size;
static void einj_exec_ctx_init(struct apei_exec_context *ctx)
{
@@ -301,11 +303,31 @@ static void __iomem *einj_get_parameter_address(void)
struct set_error_type_with_address v5param;
struct set_error_type_with_address __iomem *p;
+ v5param_size = sizeof(v5param);
p = acpi_os_map_iomem(pa_v5, sizeof(*p));
if (p) {
- memcpy_fromio(&v5param, p, sizeof(v5param));
+ int offset, len;
+
+ memcpy_fromio(&v5param, p, v5param_size);
acpi5 = 1;
check_vendor_extension(pa_v5, &v5param);
+ if (available_error_type & ACPI65_EINJV2_SUPP) {
+ len = v5param.einjv2_struct.length;
+ offset = offsetof(struct einjv2_extension_struct, component_arr);
+ max_nr_components = (len - offset) /
+ sizeof(v5param.einjv2_struct.component_arr[0]);
+ /*
+ * The first call to acpi_os_map_iomem above does not include the
+ * component array, instead it is used to read and calculate maximum
+ * number of components supported by the system. Below, the mapping
+ * is expanded to include the component array.
+ */
+ acpi_os_unmap_iomem(p, v5param_size);
+ offset = offsetof(struct set_error_type_with_address, einjv2_struct);
+ v5param_size = offset + struct_size(&v5param.einjv2_struct,
+ component_arr, max_nr_components);
+ p = acpi_os_map_iomem(pa_v5, v5param_size);
+ }
return p;
}
}
@@ -932,7 +954,7 @@ static void __exit einj_remove(struct faux_device *fdev)
if (einj_param) {
acpi_size size = (acpi5) ?
- sizeof(struct set_error_type_with_address) :
+ v5param_size :
sizeof(struct einj_parameter);
acpi_os_unmap_iomem(einj_param, size);
--
2.43.0
next prev parent reply other threads:[~2025-06-04 22:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-04 22:37 [PATCH v8 0/7] Enable EINJv2 Support Zaid Alali
2025-06-04 22:37 ` [PATCH v8 1/7] ACPI: APEI: EINJ: Fix kernel test sparse warnings Zaid Alali
2025-06-04 22:37 ` [PATCH v8 2/7] ACPI: APEI: EINJ: Enable the discovery of EINJv2 capabilities Zaid Alali
2025-06-04 22:38 ` [PATCH v8 3/7] ACPI: APEI: EINJ: Add einjv2 extension struct Zaid Alali
2025-06-04 22:38 ` Zaid Alali [this message]
2025-06-04 22:38 ` [PATCH v8 5/7] ACPI: APEI: EINJ: Create debugfs files to enter device id and syndrome Zaid Alali
2025-06-04 22:38 ` [PATCH v8 6/7] ACPI: APEI: EINJ: Enable EINJv2 error injections Zaid Alali
2025-06-04 22:38 ` [PATCH v8 7/7] ACPI: APEI: EINJ: Update the documentation for EINJv2 support Zaid Alali
2025-06-04 23:44 ` [PATCH v8 0/7] Enable EINJv2 Support Luck, Tony
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=20250604223804.842501-5-zaidal@os.amperecomputing.com \
--to=zaidal@os.amperecomputing.com \
--cc=Benjamin.Cheatham@amd.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=bp@alien8.de \
--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=tony.luck@intel.com \
--cc=u.kleine-koenig@baylibre.com \
--cc=viro@zeniv.linux.org.uk \
/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