Skip to content

Commit bc02c76

Browse files
committed
actypes.h: Expand the ACPI_ACCESS_ definitions
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. Signed-off-by: Mark Langsdorf <[email protected]>
1 parent b9c69f8 commit bc02c76

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

source/include/actypes.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,14 @@ typedef UINT64 ACPI_INTEGER;
687687
* Can be used with AccessSize field of ACPI_GENERIC_ADDRESS and
688688
* ACPI_RESOURCE_GENERIC_REGISTER.
689689
*/
690-
#define ACPI_ACCESS_BIT_WIDTH(AccessSize) (1 << ((AccessSize) + 2))
691-
#define ACPI_ACCESS_BYTE_WIDTH(AccessSize) (1 << ((AccessSize) - 1))
692-
690+
#define ACPI_ACCESS_BIT_SHIFT 2
691+
#define ACPI_ACCESS_BYTE_SHIFT -1
692+
#define ACPI_ACCESS_BIT_MAX (31 - ACPI_ACCESS_BIT_SHIFT)
693+
#define ACPI_ACCESS_BYTE_MAX (31 - ACPI_ACCESS_BYTE_SHIFT)
694+
#define ACPI_ACCESS_BIT_DEFAULT (8 - ACPI_ACCESS_BIT_SHIFT)
695+
#define ACPI_ACCESS_BYTE_DEFAULT (8 - ACPI_ACCESS_BYTE_SHIFT)
696+
#define ACPI_ACCESS_BIT_WIDTH(size) (1 << ((size) + ACPI_ACCESS_BIT_SHIFT))
697+
#define ACPI_ACCESS_BYTE_WIDTH(size) (1 << ((size) + ACPI_ACCESS_BYTE_SHIFT))
693698

694699
/*******************************************************************************
695700
*

0 commit comments

Comments
 (0)