From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756213AbcEEE6x (ORCPT ); Thu, 5 May 2016 00:58:53 -0400 Received: from mga14.intel.com ([192.55.52.115]:22831 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750954AbcEEE6v (ORCPT ); Thu, 5 May 2016 00:58:51 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,580,1455004800"; d="scan'208";a="97542782" From: Lv Zheng To: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Len Brown Cc: Lv Zheng , Lv Zheng , , linux-acpi@vger.kernel.org, Bob Moore Subject: [PATCH v2 09/13] ACPICA: Executer: Introduce a set of macros to handle bit width mask generation Date: Thu, 5 May 2016 12:58:45 +0800 Message-Id: <4d2d64afd645e4312b46c34429bff020de52efeb.1462418912.git.lv.zheng@intel.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: https://github.com/acpica/acpica/commit/c23034a3 Link: https://bugs.acpica.org/show_bug.cgi?id=1270 Reported-by: Sascha Wildner Signed-off-by: Lv Zheng Signed-off-by: Bob Moore --- drivers/acpi/acpica/acmacros.h | 12 ++++++++++++ drivers/acpi/acpica/exfldio.c | 12 ++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h index ecbaaba..a3b9543 100644 --- a/drivers/acpi/acpica/acmacros.h +++ b/drivers/acpi/acpica/acmacros.h @@ -270,9 +270,21 @@ * Bit positions start at zero. * MASK_BITS_ABOVE creates a mask starting AT the position and above * MASK_BITS_BELOW creates a mask starting one bit BELOW the position + * MASK_BITS_ABOVE/BELOW accpets a bit offset to create a mask + * MASK_BITS_ABOVE/BELOW_32/64 accpets a bit width to create a mask + * Note: The ACPI_INTEGER_BIT_SIZE check is used to bypass compiler + * differences with the shift operator */ #define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_UINT64_MAX) << ((u32) (position)))) #define ACPI_MASK_BITS_BELOW(position) ((ACPI_UINT64_MAX) << ((u32) (position))) +#define ACPI_MASK_BITS_ABOVE_32(width) ((u32) ACPI_MASK_BITS_ABOVE(width)) +#define ACPI_MASK_BITS_BELOW_32(width) ((u32) ACPI_MASK_BITS_BELOW(width)) +#define ACPI_MASK_BITS_ABOVE_64(width) ((width) == ACPI_INTEGER_BIT_SIZE ? \ + ACPI_UINT64_MAX : \ + ACPI_MASK_BITS_ABOVE(width)) +#define ACPI_MASK_BITS_BELOW_64(width) ((width) == ACPI_INTEGER_BIT_SIZE ? \ + (u64) 0 : \ + ACPI_MASK_BITS_BELOW(width)) /* Bitfields within ACPI registers */ diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c index 72f9176..ee76d29 100644 --- a/drivers/acpi/acpica/exfldio.c +++ b/drivers/acpi/acpica/exfldio.c @@ -897,17 +897,9 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc, access_bit_width = ACPI_MUL_8(obj_desc->common_field.access_byte_width); - /* - * Create the bitmasks used for bit insertion. - * Note: This if/else is used to bypass compiler differences with the - * shift operator - */ - if (access_bit_width == ACPI_INTEGER_BIT_SIZE) { - width_mask = ACPI_UINT64_MAX; - } else { - width_mask = ACPI_MASK_BITS_ABOVE(access_bit_width); - } + /* Create the bitmasks used for bit insertion */ + width_mask = ACPI_MASK_BITS_ABOVE_64(access_bit_width); mask = width_mask & ACPI_MASK_BITS_BELOW(obj_desc->common_field.start_field_bit_offset); -- 1.7.10