All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPI: OSL: Handle the return value of acpi_os_map_generic_address() for a non-register GAS
@ 2021-10-22  1:18 james.liu
  2021-10-22 14:55 ` Rafael J. Wysocki
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: james.liu @ 2021-10-22  1:18 UTC (permalink / raw)
  To: rafael, lenb; +Cc: linux-acpi, James Liu

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


^ permalink raw reply related	[flat|nested] 9+ messages in thread
* Re: [PATCH] ACPI: OSL: Handle the return value of acpi_os_map_generic_address() for a non-register GAS
  2021-10-22  1:18 [PATCH] ACPI: OSL: Handle the return value of acpi_os_map_generic_address() for a non-register GAS james.liu
  2021-10-22 14:55 ` Rafael J. Wysocki
@ 2021-11-09  9:41 ` Dan Carpenter
  2021-11-05 17:43   ` kernel test robot
  2 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2021-11-08 17:36 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 3717 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20211022011833.24308-1-james.liu@hpe.com>
References: <20211022011833.24308-1-james.liu@hpe.com>
TO: james.liu(a)hpe.com
TO: rafael(a)kernel.org
TO: lenb(a)kernel.org
CC: linux-acpi(a)vger.kernel.org
CC: James Liu <james.liu@hpe.com>

Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on v5.15 next-20211108]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/james-liu-hpe-com/ACPI-OSL-Handle-the-return-value-of-acpi_os_map_generic_address-for-a-non-register-GAS/20211022-091959
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
:::::: branch date: 3 weeks ago
:::::: commit date: 3 weeks ago
config: i386-randconfig-m021-20211025 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/acpi/osl.c:467 acpi_os_map_generic_address() error: uninitialized symbol 'addr'.

vim +/addr +467 drivers/acpi/osl.c

^1da177e4c3f41 Linus Torvalds    2005-04-16  452  
6915564dc5a8ab Rafael J. Wysocki 2020-09-11  453  void __iomem *acpi_os_map_generic_address(struct acpi_generic_address *gas)
29718521237a1b Myron Stowe       2010-10-21  454  {
bc9ffce27962c0 Myron Stowe       2011-11-07  455  	u64 addr;
29718521237a1b Myron Stowe       2010-10-21  456  
bc9ffce27962c0 Myron Stowe       2011-11-07  457  	if (gas->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
6915564dc5a8ab Rafael J. Wysocki 2020-09-11  458  		return NULL;
f0340367a7885a James Liu         2021-10-22  459  	/* Handle a non-register GAS (i.e., a pointer to a data structure),
f0340367a7885a James Liu         2021-10-22  460  	 * whose bit width is expected to be 0 according to ACPI spec. 6.4.
f0340367a7885a James Liu         2021-10-22  461  	 * For example, The RegisterRegion field in SET_ERROR_TYPE_WITH_ADDRESS
f0340367a7885a James Liu         2021-10-22  462  	 * points to a data structure whose format is defined in Table 18.30 in
f0340367a7885a James Liu         2021-10-22  463  	 * ACPI Spec. 6.4
f0340367a7885a James Liu         2021-10-22  464  	 */
f0340367a7885a James Liu         2021-10-22  465  	if (!gas->bit_width) {
f0340367a7885a James Liu         2021-10-22  466  		pr_info("Mapping IOMEM for a non-register GAS.\n");
f0340367a7885a James Liu         2021-10-22 @467  		return  acpi_os_map_iomem(addr, sizeof(unsigned long long));
f0340367a7885a James Liu         2021-10-22  468  	}
29718521237a1b Myron Stowe       2010-10-21  469  
bc9ffce27962c0 Myron Stowe       2011-11-07  470  	/* Handle possible alignment issues */
bc9ffce27962c0 Myron Stowe       2011-11-07  471  	memcpy(&addr, &gas->address, sizeof(addr));
f0340367a7885a James Liu         2021-10-22  472  	if (!addr)
6915564dc5a8ab Rafael J. Wysocki 2020-09-11  473  		return NULL;
f0340367a7885a James Liu         2021-10-22  474  	else
6915564dc5a8ab Rafael J. Wysocki 2020-09-11  475  		return acpi_os_map_iomem(addr, gas->bit_width / 8);
29718521237a1b Myron Stowe       2010-10-21  476  }
6f68c91c55ea35 Myron Stowe       2011-11-07  477  EXPORT_SYMBOL(acpi_os_map_generic_address);
29718521237a1b Myron Stowe       2010-10-21  478  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 39140 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-11-09  9:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-22  1:18 [PATCH] ACPI: OSL: Handle the return value of acpi_os_map_generic_address() for a non-register GAS james.liu
2021-10-22 14:55 ` 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

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.