All of lore.kernel.org
 help / color / mirror / Atom feed
From: james.liu@hpe.com
To: rafael@kernel.org, lenb@kernel.org
Cc: linux-acpi@vger.kernel.org, James Liu <james.liu@hpe.com>
Subject: [PATCH] ACPI: OSL: Handle the return value of acpi_os_map_generic_address() for a non-register GAS
Date: Fri, 22 Oct 2021 09:18:33 +0800	[thread overview]
Message-ID: <20211022011833.24308-1-james.liu@hpe.com> (raw)

From: James Liu <james.liu@hpe.com>

Modify acpi_os_map_generic_address() to correctly handle a non-register
GAS (i.e., a pointer to a data structure), whose bit width is expected
to be 0 according to Table 5.1 in ACPI spec. 6.4.

For example, the RegisterRegion field in SET_ERROR_TYPE_WITH_ADDRESS is a
non-register GAS, which points to a data structure whose format is defined
in Table 18.30 in ACPI Spec. 6.4.

This fix can prevent EINJ (Error Injection module) from loading failure
when a platform firmware can correctly support the format of Injection
Instruction Entry in an EINJ table.

Signed-off-by: James Liu <james.liu@hpe.com>
---
 drivers/acpi/osl.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 45c5c0e45e33..74de9341fadf 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -456,13 +456,23 @@ void __iomem *acpi_os_map_generic_address(struct acpi_generic_address *gas)
 
 	if (gas->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
 		return NULL;
+	/* Handle a non-register GAS (i.e., a pointer to a data structure),
+	 * whose bit width is expected to be 0 according to ACPI spec. 6.4.
+	 * For example, The RegisterRegion field in SET_ERROR_TYPE_WITH_ADDRESS
+	 * points to a data structure whose format is defined in Table 18.30 in
+	 * ACPI Spec. 6.4
+	 */
+	if (!gas->bit_width) {
+		pr_info("Mapping IOMEM for a non-register GAS.\n");
+		return  acpi_os_map_iomem(addr, sizeof(unsigned long long));
+	}
 
 	/* Handle possible alignment issues */
 	memcpy(&addr, &gas->address, sizeof(addr));
-	if (!addr || !gas->bit_width)
+	if (!addr)
 		return NULL;
-
-	return acpi_os_map_iomem(addr, gas->bit_width / 8);
+	else
+		return acpi_os_map_iomem(addr, gas->bit_width / 8);
 }
 EXPORT_SYMBOL(acpi_os_map_generic_address);
 
-- 
2.25.1


             reply	other threads:[~2021-10-22  1:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-22  1:18 james.liu [this message]
2021-10-22 14:55 ` [PATCH] ACPI: OSL: Handle the return value of acpi_os_map_generic_address() for a non-register GAS Rafael J. Wysocki
2021-11-03  6:39   ` James Liu
2021-10-29  6:16 ` [ACPI] f0340367a7: WARNING:at_arch/x86/mm/ioremap.c:#__ioremap_caller kernel test robot
2021-11-05 17:43 ` [PATCH] ACPI: OSL: Handle the return value of acpi_os_map_generic_address() for a non-register GAS kernel test robot
2021-11-05 17:43   ` kernel test robot
2021-11-08 17:36 kernel test robot
2021-11-09  9:41 ` Dan Carpenter
2021-11-09  9:41 ` Dan Carpenter

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=20211022011833.24308-1-james.liu@hpe.com \
    --to=james.liu@hpe.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=rafael@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.