Skip to content

Commit 9222aa8

Browse files
Lv Zhengrafaeljw
authored andcommitted
ACPICA: Executer: Introduce a set of macros to handle bit width mask generation
ACPICA commit c23034a3a09d5ed79f1827d51f43cfbccf68ab64 A regression was reported to the shift offset >= width of type. This patch fixes this issue. BZ 1270. This is a part of the fix because the order of the patches are modified for Linux upstream, containing the cleanups for the old code. Lv Zheng. Link: acpica/acpica@c23034a3 Link: https://bugs.acpica.org/show_bug.cgi?id=1270 Reported-by: Sascha Wildner <[email protected]> Signed-off-by: Lv Zheng <[email protected]> Signed-off-by: Bob Moore <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent b314a17 commit 9222aa8

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

drivers/acpi/acpica/acmacros.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,21 @@
270270
* Bit positions start at zero.
271271
* MASK_BITS_ABOVE creates a mask starting AT the position and above
272272
* MASK_BITS_BELOW creates a mask starting one bit BELOW the position
273+
* MASK_BITS_ABOVE/BELOW accpets a bit offset to create a mask
274+
* MASK_BITS_ABOVE/BELOW_32/64 accpets a bit width to create a mask
275+
* Note: The ACPI_INTEGER_BIT_SIZE check is used to bypass compiler
276+
* differences with the shift operator
273277
*/
274278
#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_UINT64_MAX) << ((u32) (position))))
275279
#define ACPI_MASK_BITS_BELOW(position) ((ACPI_UINT64_MAX) << ((u32) (position)))
280+
#define ACPI_MASK_BITS_ABOVE_32(width) ((u32) ACPI_MASK_BITS_ABOVE(width))
281+
#define ACPI_MASK_BITS_BELOW_32(width) ((u32) ACPI_MASK_BITS_BELOW(width))
282+
#define ACPI_MASK_BITS_ABOVE_64(width) ((width) == ACPI_INTEGER_BIT_SIZE ? \
283+
ACPI_UINT64_MAX : \
284+
ACPI_MASK_BITS_ABOVE(width))
285+
#define ACPI_MASK_BITS_BELOW_64(width) ((width) == ACPI_INTEGER_BIT_SIZE ? \
286+
(u64) 0 : \
287+
ACPI_MASK_BITS_BELOW(width))
276288

277289
/* Bitfields within ACPI registers */
278290

drivers/acpi/acpica/exfldio.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -897,17 +897,9 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
897897

898898
access_bit_width = ACPI_MUL_8(obj_desc->common_field.access_byte_width);
899899

900-
/*
901-
* Create the bitmasks used for bit insertion.
902-
* Note: This if/else is used to bypass compiler differences with the
903-
* shift operator
904-
*/
905-
if (access_bit_width == ACPI_INTEGER_BIT_SIZE) {
906-
width_mask = ACPI_UINT64_MAX;
907-
} else {
908-
width_mask = ACPI_MASK_BITS_ABOVE(access_bit_width);
909-
}
900+
/* Create the bitmasks used for bit insertion */
910901

902+
width_mask = ACPI_MASK_BITS_ABOVE_64(access_bit_width);
911903
mask = width_mask &
912904
ACPI_MASK_BITS_BELOW(obj_desc->common_field.start_field_bit_offset);
913905

0 commit comments

Comments
 (0)