Skip to content

Commit fcfd828

Browse files
mlangsdorfgregkh
authored andcommitted
ACPICA: actypes.h: Expand the ACPI_ACCESS_ definitions
[ Upstream commit f81bdea ] ACPICA commit bc02c76d518135531483dfc276ed28b7ee632ce1 The current ACPI_ACCESS_*_WIDTH defines do not provide a way to test that size is small enough to not cause an overflow when applied to a 32-bit integer. Rather than adding more magic numbers, add ACPI_ACCESS_*_SHIFT, ACPI_ACCESS_*_MAX, and ACPI_ACCESS_*_DEFAULT #defines and redefine ACPI_ACCESS_*_WIDTH in terms of the new #defines. This was inititally reported on Linux where a size of 102 in ACPI_ACCESS_BIT_WIDTH caused an overflow error in the SPCR initialization code. Link: open-acpica/acpica@bc02c76d Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com> Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e3a51d6 commit fcfd828

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎include/acpi/actypes.h‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,14 @@ typedef u64 acpi_integer;
536536
* Can be used with access_width of struct acpi_generic_address and access_size of
537537
* struct acpi_resource_generic_register.
538538
*/
539-
#define ACPI_ACCESS_BIT_WIDTH(size) (1 << ((size) + 2))
540-
#define ACPI_ACCESS_BYTE_WIDTH(size) (1 << ((size) - 1))
539+
#define ACPI_ACCESS_BIT_SHIFT 2
540+
#define ACPI_ACCESS_BYTE_SHIFT -1
541+
#define ACPI_ACCESS_BIT_MAX (31 - ACPI_ACCESS_BIT_SHIFT)
542+
#define ACPI_ACCESS_BYTE_MAX (31 - ACPI_ACCESS_BYTE_SHIFT)
543+
#define ACPI_ACCESS_BIT_DEFAULT (8 - ACPI_ACCESS_BIT_SHIFT)
544+
#define ACPI_ACCESS_BYTE_DEFAULT (8 - ACPI_ACCESS_BYTE_SHIFT)
545+
#define ACPI_ACCESS_BIT_WIDTH(size) (1 << ((size) + ACPI_ACCESS_BIT_SHIFT))
546+
#define ACPI_ACCESS_BYTE_WIDTH(size) (1 << ((size) + ACPI_ACCESS_BYTE_SHIFT))
541547

542548
/*******************************************************************************
543549
*

0 commit comments

Comments
 (0)