From: james.liu@hpe.com
To: rafael@kernel.org, lenb@kernel.org
Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
rwright@hpe.com, david.chang@hpe.com, clayc@hpe.com,
james.liu@hpe.com
Subject: [PATCH v2] ACPI: OSL: Fix the memory mapping of an ACPI GAS that addresses a data structure
Date: Mon, 23 May 2022 05:43:02 +0800 [thread overview]
Message-ID: <20220522214302.39024-1-james.liu@hpe.com> (raw)
From: James Liu <james.liu@hpe.com>
Modify acpi_os_map_generic_address() & acpi_os_unmap_generic_address()
to correctly handle cases that a GAS table (i.e., Table 5.1, ACPI 6.4)
is used to address a data structure; in the case, the GAS has the field
of "Register Bit Width" equal to 0.
For example, "Injection Instruction Entry" (Table 18.25, ACPI 6.4) has
a RegisterRegion field that is a GAS that points to a data structure
SET_ERROR_TYPE_WITH_ADDRESS (Table 18.30), which is required when using
EINJ (Error Injection module).
This fix preserves a fairly sufficient memory space (i.e. page size) to
store the data structure to prevent EINJ module from loading failure if
platform firmware can correctly support Injection Instruction Entry in
an EINJ table.
Signed-off-by: James Liu <james.liu@hpe.com>
---
drivers/acpi/osl.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 45c5c0e45..99f987c8c 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -452,14 +452,20 @@ EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);
void __iomem *acpi_os_map_generic_address(struct acpi_generic_address *gas)
{
- u64 addr;
+ u64 addr = 0;
if (gas->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
return NULL;
+ /* Handle a case that GAS is used to address an ACPI data structure */
+ if (!gas->bit_width) {
+ pr_info("An ACPI data structure at 0x%llx is mapped\n", addr);
+ return acpi_os_map_iomem(addr, PAGE_SIZE);
+ }
+
/* 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);
@@ -468,15 +474,28 @@ EXPORT_SYMBOL(acpi_os_map_generic_address);
void acpi_os_unmap_generic_address(struct acpi_generic_address *gas)
{
- u64 addr;
+ u64 addr = 0;
struct acpi_ioremap *map;
if (gas->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
return;
+ /* Handle a case that GAS is used to address an ACPI data structure */
+ if (!gas->bit_width) {
+ pr_info("An ACPI data structure at 0x%llx is unmapped\n", addr);
+ mutex_lock(&acpi_ioremap_lock);
+ map = acpi_map_lookup(addr, PAGE_SIZE);
+ if (!map) {
+ mutex_unlock(&acpi_ioremap_lock);
+ return;
+ }
+ acpi_os_drop_map_ref(map);
+ mutex_unlock(&acpi_ioremap_lock);
+ }
+
/* Handle possible alignment issues */
memcpy(&addr, &gas->address, sizeof(addr));
- if (!addr || !gas->bit_width)
+ if (!addr)
return;
mutex_lock(&acpi_ioremap_lock);
--
2.25.1
next reply other threads:[~2022-05-22 21:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-22 21:43 james.liu [this message]
[not found] ` <PH7PR84MB1958F5A9F4F05EFE72A9E906E6A29@PH7PR84MB1958.NAMPRD84.PROD.OUTLOOK.COM>
2022-06-06 9:16 ` James Liu
2022-06-29 14:27 ` 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=20220522214302.39024-1-james.liu@hpe.com \
--to=james.liu@hpe.com \
--cc=clayc@hpe.com \
--cc=david.chang@hpe.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rwright@hpe.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
all inboxes | Powered by JetHome®