mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lv Zheng <lv.zheng@intel.com>
To: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Len Brown <len.brown@intel.com>
Cc: Lv Zheng <lv.zheng@intel.com>, Lv Zheng <zetalog@gmail.com>,
	<linux-kernel@vger.kernel.org>,
	linux-acpi@vger.kernel.org, Bob Moore <robert.moore@intel.com>
Subject: [PATCH 23/30] ACPICA: Hardware: Enhance acpi_hw_validate_register() with access_width/bit_offset awareness
Date: Thu, 24 Mar 2016 09:41:09 +0800	[thread overview]
Message-ID: <2fb98494a7434b63703b68cc44283a6d4e87a332.1458714003.git.lv.zheng@intel.com> (raw)
In-Reply-To: <cover.1458714002.git.lv.zheng@intel.com>

ACPICA commit 997a90f810a4cb78604ef2e187611a181b498286

This patch enhances acpi_hw_validate_register() to sanitize register
accesses with awareness of access_width and bit_offset. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/997a90f8
Link: https://bugs.acpica.org/show_bug.cgi?id=1240
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
---
 drivers/acpi/acpica/hwregs.c |   25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c
index 93f8831..bc3f60a 100644
--- a/drivers/acpi/acpica/hwregs.c
+++ b/drivers/acpi/acpica/hwregs.c
@@ -83,6 +83,8 @@ acpi_status
 acpi_hw_validate_register(struct acpi_generic_address *reg,
 			  u8 max_bit_width, u64 *address)
 {
+	u8 bit_width;
+	u8 access_width;
 
 	/* Must have a valid pointer to a GAS structure */
 
@@ -109,23 +111,26 @@ acpi_hw_validate_register(struct acpi_generic_address *reg,
 		return (AE_SUPPORT);
 	}
 
-	/* Validate the bit_width */
+	/* Validate the access_width */
 
-	if ((reg->bit_width != 8) &&
-	    (reg->bit_width != 16) &&
-	    (reg->bit_width != 32) && (reg->bit_width != max_bit_width)) {
+	if (reg->access_width > 4) {
 		ACPI_ERROR((AE_INFO,
-			    "Unsupported register bit width: 0x%X",
-			    reg->bit_width));
+			    "Unsupported register access width: 0x%X",
+			    reg->access_width));
 		return (AE_SUPPORT);
 	}
 
-	/* Validate the bit_offset. Just a warning for now. */
+	/* Validate the bit_width, convert access_width into number of bits */
 
-	if (reg->bit_offset != 0) {
+	access_width = reg->access_width ? reg->access_width : 1;
+	access_width = 1 << (access_width + 2);
+	bit_width =
+	    ACPI_ROUND_UP(reg->bit_offset + reg->bit_width, access_width);
+	if (max_bit_width < bit_width) {
 		ACPI_WARNING((AE_INFO,
-			      "Unsupported register bit offset: 0x%X",
-			      reg->bit_offset));
+			      "Requested bit width 0x%X is smaller than register bit width 0x%X",
+			      max_bit_width, bit_width));
+		return (AE_SUPPORT);
 	}
 
 	return (AE_OK);
-- 
1.7.10

  parent reply	other threads:[~2016-03-24  1:41 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-24  1:38 [PATCH 00/30] ACPICA: 20160318 Release Lv Zheng
2016-03-24  1:38 ` [PATCH 01/30] ACPICA: Linuxize: reduce divergences for 20160212 release Lv Zheng
2016-03-24  1:46   ` Joe Perches
2016-03-24  6:19     ` Zheng, Lv
2016-03-24  6:35       ` Brown, Len
2016-03-24  6:53         ` Zheng, Lv
2016-03-24 11:00       ` Joe Perches
2016-03-28  3:02         ` Zheng, Lv
2016-03-28  3:15           ` Joe Perches
2016-03-29  5:37             ` Zheng, Lv
2016-03-29  5:56               ` Joe Perches
2016-03-24  1:38 ` [PATCH 02/30] ACPICA: Linuxize: Remove useless platform headers Lv Zheng
2016-03-24  1:38 ` [PATCH 03/30] ACPICA: Headers: Add new constants for the DBG2 ACPI table Lv Zheng
2016-03-24  1:38 ` [PATCH 04/30] ACPICA: Headers: Minor update for SPCR " Lv Zheng
2016-03-24  1:38 ` [PATCH 05/30] ACPICA: ACPI 6.1: Updates for the HEST " Lv Zheng
2016-03-24  1:39 ` [PATCH 06/30] ACPICA: IORT: Add in support for the SMMUv3 subtable Lv Zheng
2016-03-24  1:39 ` [PATCH 07/30] ACPICA: ACPI 6.1: Update NFIT table for additional new fields Lv Zheng
2016-03-24  1:39 ` [PATCH 08/30] ACPICA: Headers: Update DMAR table for October 2014 I/O spec Lv Zheng
2016-03-24  1:39 ` [PATCH 09/30] ACPICA: Tables: Update FADT handling Lv Zheng
2016-03-24  1:39 ` [PATCH 10/30] ACPICA: ACPI 6.1: Add full support for this version of ACPI spec Lv Zheng
2016-03-24  1:39 ` [PATCH 11/30] ACPICA: iASL/Headers: Fix incorrect definition of FPDT table Lv Zheng
2016-03-24  1:39 ` [PATCH 12/30] ACPICA: Intepreter: Add object extensions to Concatenate operand Lv Zheng
2016-03-24  1:39 ` [PATCH 13/30] ACPICA: Interpreter: Update some function headers, no functional change Lv Zheng
2016-03-24  1:40 ` [PATCH 14/30] ACPICA: iASL: Cleanup/optimization for ToPLD macro support Lv Zheng
2016-03-24  1:40 ` [PATCH 15/30] ACPICA: Cleanup some invocation indentations, no functional change Lv Zheng
2016-03-24  1:40 ` [PATCH 16/30] ACPICA: Headers: Update generation of the ACPICA library Lv Zheng
2016-03-24  1:40 ` [PATCH 17/30] ACPICA: Add support for QNX 6.6 platform Lv Zheng
2016-03-24  1:40 ` [PATCH 18/30] ACPICA: Utilities: Update for strtoul64 merger Lv Zheng
2016-03-24  1:40 ` [PATCH 19/30] ACPICA: All: const keyword changes across the ACPICA source Lv Zheng
2016-03-24  1:40 ` [PATCH 20/30] ACPICA: iASL/Disassembler: Improve handling of unresolved methods Lv Zheng
2016-03-24  1:40 ` [PATCH 21/30] ACPICA: Utilities: Add ACPI_IS_POWER_OF_TWO() Lv Zheng
2016-03-24  1:41 ` [PATCH 22/30] Utilities: Fix missing parentheses in ACPI_GET_BITS()/ACPI_SET_BITS() Lv Zheng
2016-03-24  1:41 ` Lv Zheng [this message]
2016-03-24  1:41 ` [PATCH 24/30] ACPICA: Hardware: Add access_width/bit_offset support in acpi_hw_read() Lv Zheng
2016-03-29  8:14   ` Zheng, Lv
2016-03-24  1:41 ` [PATCH 25/30] ACPICA: Hardware: Add access_width/bit_offset support for acpi_hw_write() Lv Zheng
2016-03-24  1:41 ` [PATCH 26/30] ACPICA: Interpreter: Fix wrong conditions for acpi_ev_install_region_handlers() invocation Lv Zheng
2016-03-24  1:41 ` [PATCH 27/30] ACPICA: Tables: Fix wrong MLC condition for dynamic table loading Lv Zheng
2016-03-24  1:41 ` [PATCH 28/30] ACPICA: Events: Fix an issue that _REG association can happen before namespace is initialized Lv Zheng
2016-03-24  1:41 ` [PATCH 29/30] ACPICA: Namespace: Reorder \_SB._INI to make sure it is evaluated before _REG evaluations Lv Zheng
2016-03-24  1:42 ` [PATCH 30/30] ACPICA: Update version to 20160318 Lv Zheng
2016-03-24 13:08 ` [PATCH 00/30] ACPICA: 20160318 Release Rafael J. Wysocki
2016-03-28  3:03   ` Zheng, Lv
2016-07-11 14:38   ` Matthias Brugger
2016-07-11 14:48     ` Rafael J. Wysocki
2016-07-11 14:48       ` Matthias Brugger
2016-07-11 14:54       ` Rafael J. Wysocki
2016-07-11 15:20         ` Matthias Brugger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2fb98494a7434b63703b68cc44283a6d4e87a332.1458714003.git.lv.zheng@intel.com \
    --to=lv.zheng@intel.com \
    --cc=len.brown@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=robert.moore@intel.com \
    --cc=zetalog@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®