Skip to contentSkip to conversation

ACPICA 20170629 Release

PATCH In review Lv Zheng 2 participants 18 messages Jul 10, 2017 – Jul 21, 2017

Subsystems (2)
lore
Share & tools
lore

Lv Zheng

author
#0 lore raw

cover ACPICA 20170629 Release

The 20170629 ACPICA kernel-resident subsystem updates are linuxized based on the linux-pm/linux-next branch.

The patchset has passed the following build/boot tests. Build tests are performed as follows:
1. i386 + allyes
2. i386 + allno
3. i386 + default + ACPI_DEBUGGER=y
4. i386 + default + ACPI_DEBUGGER=n + ACPI_DEBUG=y
5. i386 + default + ACPI_DEBUG=n + ACPI=y
6. i386 + default + ACPI=n
7. x86_64 + allyes
8. x86_64 + allno
9. x86_64 + default + ACPI_DEBUGGER=y
10.x86_64 + default + ACPI_DEBUGGER=n + ACPI_DEBUG=y 11.x86_64 + default + ACPI_DEBUG=n + ACPI=y
12.x86_64 + default + ACPI=n
Boot tests are performed as follows:
1. x86_64 + default + ACPI_DEBUGGER=y
Where:
1. i386: machine named as "Dell Inspiron Mini 1010"
2. x86_64: machine named as "Microsoft Surface Pro 3"
3. default: kernel configuration with following items enabled:
All hardware drivers related to the machines of i386/x86_64 All "drivers/acpi" configurations
All "drivers/platform" drivers
All other drivers that link the APIs provided by ACPICA subsystem

The divergences checking result:
Before applying (20170531 Release):
369 lines
After applying (20170629 Release):
390 lines (increased due to export of acpi_tb_xxx functions)

Alex James (1):
ACPICA: iASL: Ensure that the target node is valid in
acpi_ex_create_alias

Bob Moore (2):
ACPICA: Small indentation changes, no functional change
ACPICA: Update version to 20170629

Erik Schmauss (3):
ACPICA: Tools: Deallocate memory allocated by
ac_get_all_tables_from_file via ac_delete_table_list
ACPICA: iASL compiler: allow compilation of externals with paths that
refer to existing names
ACPICA: Disassembler: skip parsing of incorrect external declarations

Ganapatrao Kulkarni (1):
ACPICA: iasl: Update to IORT SMMUv3 disassembling

Kees Cook (1):
Back port of "ACPICA: Use designated initializers"

Lv Zheng (7):
ACPICA: linuxize: cleanup typedef definitions
ACPICA: Tables: Add sanity check in acpi_put_table()
ACPICA: Tables: Cleanup table handler invokers
ACPICA: Tables: Do not validate signature for dynamic table load
ACPICA: Tables: Change table duplication check to be related to
acpi_gbl_verify_table_checksum
ACPICA: Tables: Combine checksum/duplication verification together
ACPICA: Tables: Add deferred table verification support

Robin Murphy (1):
ACPICA: IORT: Update SMMU models for revision C

 drivers/acpi/acpica/acapps.h    |   2 +
 drivers/acpi/acpica/aclocal.h   |   5 +-
 drivers/acpi/acpica/acobject.h  |  12 ++-
 drivers/acpi/acpica/actables.h  |   5 +-
 drivers/acpi/acpica/excreate.c  |   5 +
 drivers/acpi/acpica/hwxfsleep.c |   9 +-
 drivers/acpi/acpica/nsaccess.c  |   6 ++
 drivers/acpi/acpica/psobject.c  |  26 +++++
 drivers/acpi/acpica/tbdata.c    | 230 +++++++++++++++++++++++++++++++++++-----
 drivers/acpi/acpica/tbinstal.c  | 161 ++++------------------------
 drivers/acpi/acpica/tbxface.c   |  39 ++++++-
 drivers/acpi/acpica/tbxfload.c  |   2 +-
 drivers/acpi/bus.c              |   3 -
 drivers/acpi/tables.c           |   4 +-
 include/acpi/acpixf.h           |  15 +--
 include/acpi/actbl.h            |   1 +
 include/acpi/actbl2.h           |  16 ++-
 include/acpi/platform/acenv.h   |   9 +-
 include/acpi/platform/aclinux.h |   3 +
 19 files changed, 356 insertions(+), 197 deletions(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 1/16 ACPICA: Small indentation changes, no functional change

From: Bob Moore <[email protected]>

ACPICA commit bb457076d42b95b1453e261da2c8cc0c05ba4718

Fix some alignment issues

---
 drivers/acpi/acpica/aclocal.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/acpica/aclocal.h +2 -2
index 8ddd3b2..822dbc5 100644
@@ -867,7 +867,7 @@ struct acpi_parse_obj_named {
 
 /* This version is used by the iASL compiler only */
 
-#define ACPI_MAX_PARSEOP_NAME   20
+#define ACPI_MAX_PARSEOP_NAME       20
 
 struct acpi_parse_obj_asl {
 	ACPI_PARSE_COMMON union acpi_parse_object *child;
@@ -907,7 +907,7 @@ union acpi_parse_object {
 struct asl_comment_state {
 	u8 comment_type;
 	u32 spaces_before;
-	union acpi_parse_object *latest_parse_node;
+	union acpi_parse_object *latest_parse_op;
 	union acpi_parse_object *parsing_paren_brace_node;
 	u8 capture_comments;
 };
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH 2/16 ACPICA: IORT: Update SMMU models for revision C

In reply to Lv Zheng

From: Robin Murphy <[email protected]>

ACPICA commit d00a4eb86e64bb4fa70f57ab5e5ca0a4ca2ad8ef

IORT revision C has been published with a number of new SMMU implementation identifiers; define them.

---
 include/acpi/actbl2.h | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
include/acpi/actbl2.h +10 -2
index 707dda74..5829eed 100644
@@ -664,7 +664,7 @@ struct acpi_ibft_target {
  * IORT - IO Remapping Table
  *
  * Conforms to "IO Remapping Table System Software on ARM Platforms",
- * Document number: ARM DEN 0049B, October 2015
+ * Document number: ARM DEN 0049C, May 2017
  *
  ******************************************************************************/
 
@@ -779,6 +779,8 @@ struct acpi_iort_smmu {
 #define ACPI_IORT_SMMU_V2               0x00000001	/* Generic SMMUv2 */
 #define ACPI_IORT_SMMU_CORELINK_MMU400  0x00000002	/* ARM Corelink MMU-400 */
 #define ACPI_IORT_SMMU_CORELINK_MMU500  0x00000003	/* ARM Corelink MMU-500 */
+#define ACPI_IORT_SMMU_CORELINK_MMU401  0x00000004	/* ARM Corelink MMU-401 */
+#define ACPI_IORT_SMMU_CAVIUM_THUNDERX  0x00000005	/* Cavium thunder_x SMMUv2 */
 
 /* Masks for Flags field above */
 
@@ -799,13 +801,19 @@ struct acpi_iort_smmu_v3 {
 	u32 flags;
 	u32 reserved;
 	u64 vatos_address;
-	u32 model;		/* O: generic SMMUv3 */
+	u32 model;
 	u32 event_gsiv;
 	u32 pri_gsiv;
 	u32 gerr_gsiv;
 	u32 sync_gsiv;
 };
 
+/* Values for Model field above */
+
+#define ACPI_IORT_SMMU_V3_GENERIC           0x00000000	/* Generic SMMUv3 */
+#define ACPI_IORT_SMMU_V3_HISILICON_HI161X  0x00000001	/* hi_silicon Hi161x SMMUv3 */
+#define ACPI_IORT_SMMU_V3_CAVIUM_CN99XX     0x00000002	/* Cavium CN99xx SMMUv3 */
+
 /* Masks for Flags field above */
 
 #define ACPI_IORT_SMMU_V3_COHACC_OVERRIDE   (1)
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH 3/16 ACPICA: Tools: Deallocate memory allocated by ac_get_all_tables_from_file via ac_delete_table_list

In reply to Lv Zheng

From: Erik Schmauss <[email protected]>

ACPICA commit 8521b98ebdea450011fa62c14a77fed9affa4236

---
 drivers/acpi/acpica/acapps.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/acpi/acpica/acapps.h +2 -0
index bb6a84b..7a1a68b 100644
@@ -114,6 +114,8 @@ ac_get_all_tables_from_file(char *filename,
 			    u8 get_only_aml_tables,
 			    struct acpi_new_table_desc **return_list_head);
 
+void ac_delete_table_list(struct acpi_new_table_desc *list_head);
+
 u8 ac_is_file_binary(FILE * file);
 
 acpi_status ac_validate_table_header(FILE * file, long table_offset);
Signature · 1 line
2.7.4
author
#4 lore raw

PATCH 4/16 ACPICA: iASL compiler: allow compilation of externals with paths that refer to existing names

In reply to Lv Zheng

From: Erik Schmauss <[email protected]>

ACPICA commit 9a252114197409290813bee570e9d53c22b99d32

This change allows compilation of code like the following:

definition_block (...)

{
    External (ABCD.EFGH)
    Device (ABCD)
    {
        Name (IJLK,0)
    }
}

but does not allow compilation of code like the following:

definition_block (...)

{
    External (ABCD)
    Device (ABCD)
    {
        Name (EFGH,0)
    }
}
---
 drivers/acpi/acpica/aclocal.h  | 1 +
 drivers/acpi/acpica/nsaccess.c | 6 ++++++
 2 files changed, 7 insertions(+)
drivers/acpi/acpica/aclocal.h +1 -0
index 822dbc5..bae943b 100644
@@ -199,6 +199,7 @@ struct acpi_namespace_node {
 #define ANOBJ_EVALUATED                 0x20	/* Set on first evaluation of node */
 #define ANOBJ_ALLOCATED_BUFFER          0x40	/* Method AML buffer is dynamic (install_method) */
 
+#define IMPLICIT_EXTERNAL               0x02	/* iASL only: This object created implicitly via External */
 #define ANOBJ_IS_EXTERNAL               0x08	/* iASL only: This object created via External() */
 #define ANOBJ_METHOD_NO_RETVAL          0x10	/* iASL only: Method has no return value */
 #define ANOBJ_METHOD_SOME_NO_RETVAL     0x20	/* iASL only: Method has at least one return value */
drivers/acpi/acpica/nsaccess.c +6 -0
index e5f4fa4..14be12f 100644
@@ -634,6 +634,12 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
 					    this_node->object;
 				}
 			}
+#ifdef ACPI_ASL_COMPILER
+			if (!acpi_gbl_disasm_flag &&
+			    (this_node->flags & ANOBJ_IS_EXTERNAL)) {
+				this_node->flags |= IMPLICIT_EXTERNAL;
+			}
+#endif
 		}
 
 		/* Special handling for the last segment (num_segments == 0) */
Signature · 1 line
2.7.4
author
#5 lore raw

PATCH 5/16 Back port of "ACPICA: Use designated initializers"

In reply to Lv Zheng

From: Kees Cook <[email protected]>

ACPICA commit 47538f5f0773c0820d8f552e20f6e77104290c01

The following commit is not correctly linuxized by its ACPICA form (see link #1 for reference):
Commit: 3d867f6c5fd6535cdeceef3170e5e84e5dd80fc1
Subject: ACPICA: Use designated initializers
Thus breaks linuxize process.

This patch is a linuxized back port result of the upstreamed ACPICA commit (see link #2 for reference).

---
 drivers/acpi/acpica/hwxfsleep.c | 9 ++++++---
 include/acpi/platform/acenv.h   | 9 +++++----
 include/acpi/platform/aclinux.h | 3 +++
 3 files changed, 14 insertions(+), 7 deletions(-)
drivers/acpi/acpica/hwxfsleep.c +6 -3
index 7ef1393..e5c095c 100644
@@ -72,13 +72,16 @@ static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id);
 static struct acpi_sleep_functions acpi_sleep_dispatch[] = {
 	{ACPI_STRUCT_INIT(legacy_function,
 			  ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep)),
-	 ACPI_STRUCT_INIT(extended_function, acpi_hw_extended_sleep) },
+	 ACPI_STRUCT_INIT(extended_function,
+			  acpi_hw_extended_sleep)},
 	{ACPI_STRUCT_INIT(legacy_function,
 			  ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep)),
-	 ACPI_STRUCT_INIT(extended_function, acpi_hw_extended_wake_prep) },
+	 ACPI_STRUCT_INIT(extended_function,
+			  acpi_hw_extended_wake_prep)},
 	{ACPI_STRUCT_INIT(legacy_function,
 			  ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake)),
-	 ACPI_STRUCT_INIT(extended_function, acpi_hw_extended_wake) }
+	 ACPI_STRUCT_INIT(extended_function,
+			  acpi_hw_extended_wake)}
 };
 
 /*
include/acpi/platform/acenv.h +5 -4
index 912563c..043fd55 100644
@@ -288,6 +288,11 @@
 #define ACPI_INLINE
 #endif
 
+/* Use ordered initialization if compiler doesn't support designated. */
+#ifndef ACPI_STRUCT_INIT
+#define ACPI_STRUCT_INIT(field, value)  value
+#endif
+
 /*
  * Configurable calling conventions:
  *
@@ -382,8 +387,4 @@
 #define ACPI_INIT_FUNCTION
 #endif
 
-#ifndef ACPI_STRUCT_INIT
-#define ACPI_STRUCT_INIT(field, value) value
-#endif
-
 #endif				/* __ACENV_H__ */
include/acpi/platform/aclinux.h +3 -0
index 047f138..afd95f2 100644
@@ -178,6 +178,9 @@
 #define ACPI_MSG_BIOS_ERROR     KERN_ERR "ACPI BIOS Error (bug): "
 #define ACPI_MSG_BIOS_WARNING   KERN_WARNING "ACPI BIOS Warning (bug): "
 
+/*
+ * Linux wants to use designated initializers for function pointer structs.
+ */
 #define ACPI_STRUCT_INIT(field, value)	.field = value
 
 #else				/* !__KERNEL__ */
Signature · 1 line
2.7.4
author
#6 lore raw

PATCH 6/16 ACPICA: linuxize: cleanup typedef definitions

In reply to Lv Zheng

ACPICA commit 894e49ef22db354eb1685cdb6f5f991766351d3c

acpisrc now has capability to convert both the followings:
1. Form 1:

  typedef struct/union foo {         struct/union foo {
     ....                       -->      ...

} FOO; }
2. Form 2:
typedef struct/union foo FOO; --> typedef struct/union foo foo;
It becomes unable to handle the following:
3. Form3:
typedef struct/union foo { /* comment */

      ...
  } FOO;
    -->
  strut/union foo { /* comment */
      ...

};

As:
1. The purpose of acpisrc is to convert formatted code (ACPICA coding style) into linux coding style,
2. acpisrc is a very simple tool that doesn't fully handle C language. This commit changes the definitions side in order not to regress and we shall make "no comments in struct/union line" as a new ACPICA coding style rule. Lv Zheng.

---
 drivers/acpi/acpica/acobject.h | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/acpi/acpica/acobject.h +9 -3
index 27c3f98..549f227 100644
@@ -122,7 +122,9 @@ struct acpi_object_integer {
 	_type                           *pointer; \
 	u32                             length;
 
-struct acpi_object_string {	/* Null terminated, ASCII characters only */
+/* Null terminated, ASCII characters only */
+
+struct acpi_object_string {
 	ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_BUFFER_INFO(char)	/* String in AML stream or allocated string */
 };
 
@@ -211,7 +213,9 @@ struct acpi_object_method {
 	union acpi_operand_object       *notify_list[2];    /* Handlers for system/device notifies */\
 	union acpi_operand_object       *handler;	/* Handler for Address space */
 
-struct acpi_object_notify_common {	/* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */
+/* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */
+
+struct acpi_object_notify_common {
 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO};
 
 struct acpi_object_device {
@@ -258,7 +262,9 @@ ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO};
 	u8                              access_length;	/* For serial regions/fields */
 
 
-struct acpi_object_field_common {	/* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */
+/* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */
+
+struct acpi_object_field_common {
 	ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *region_obj;	/* Parent Operation Region object (REGION/BANK fields only) */
 };
 
Signature · 1 line
2.7.4
author
#7 lore raw

PATCH 7/16 ACPICA: Tables: Add sanity check in acpi_put_table()

In reply to Lv Zheng

ACPICA commit 73512384c9eb1e7f1b28d0a7372df26a3732f96b

To avoid caller to trigger unexpected warning messages (Link #1):
ACPI Warning: Table ffffffffbb461d20, Validation count is zero before decrement
Which is reported from acpi_tb_put_table(). When the table is validated, the pointer must be non-zero. Thus the message is not suitable for invalidated tables. This patch fixes the callee side based on this fact. Reported by Cristian Aravena Romero, Fixed by Lv Zheng.

---
 drivers/acpi/acpica/tbxface.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/acpi/acpica/tbxface.c +4 -0
index 010b1c43..18508b2 100644
@@ -369,6 +369,10 @@ void acpi_put_table(struct acpi_table_header *table)
 
 	ACPI_FUNCTION_TRACE(acpi_put_table);
 
+	if (!table) {
+		return_VOID;
+	}
+
 	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
 
 	/* Walk the root table list */
Signature · 1 line
2.7.4
author
#8 lore raw

PATCH 8/16 ACPICA: Tables: Cleanup table handler invokers

In reply to Lv Zheng

ACPICA commit 4551f51fa8ba33a977721c3b250cb70a309e3f23

Recently, we allows the table mutex to be held in both early and late stage APIs. This patch further cleans up the related code to reduce redundant code related to acpi_gbl_table_handler. Lv Zheng.

---
 drivers/acpi/acpica/actables.h |  2 ++
 drivers/acpi/acpica/tbdata.c   | 43 ++++++++++++++++++++++++++++--------------
 drivers/acpi/acpica/tbinstal.c |  8 ++------
 3 files changed, 33 insertions(+), 20 deletions(-)
drivers/acpi/acpica/actables.h +2 -0
index c8da453..89ed31b 100644
@@ -132,6 +132,8 @@ acpi_tb_install_and_load_table(acpi_physical_address address,
 
 acpi_status acpi_tb_unload_table(u32 table_index);
 
+void acpi_tb_notify_table(u32 event, void *table);
+
 void acpi_tb_terminate(void);
 
 acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index);
drivers/acpi/acpica/tbdata.c +29 -14

60 lines not on this page · raw message

drivers/acpi/acpica/tbinstal.c +2 -6
index 4620f3c..ee74515 100644
@@ -306,14 +306,10 @@ acpi_tb_install_standard_table(acpi_physical_address address,
 	acpi_tb_install_table_with_override(&new_table_desc, override,
 					    table_index);
 
-	/* Invoke table handler if present */
+	/* Invoke table handler */
 
 	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
-	if (acpi_gbl_table_handler) {
-		(void)acpi_gbl_table_handler(ACPI_TABLE_EVENT_INSTALL,
-					     new_table_desc.pointer,
-					     acpi_gbl_table_handler_context);
-	}
+	acpi_tb_notify_table(ACPI_TABLE_EVENT_INSTALL, new_table_desc.pointer);
 	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
 
 unlock_and_exit:
Signature · 1 line
2.7.4
author
#9 lore raw

PATCH 9/16 ACPICA: Tables: Do not validate signature for dynamic table load

In reply to Lv Zheng

ACPICA commit d3c944f2cdc8c7e847b7942b1864f285189f7bce

Windows seems to allow arbitrary table signatures for Load/load_table opcodes:
ACPI BIOS Error (bug): Table has invalid signature [PRAD] (0x44415250)
So this patch removes dynamic load signature checks. However we need to find a way to avoid table loading against tables like MADT. This is not covered by this commit.

This Windows behavior has been validated on link #1. An end user bug report can also be found on link #2.

This patch also includes simple cleanup for static load signature check code. Reported by Ye Xiaolong, Fixed by Lv Zheng.

---
 drivers/acpi/acpica/tbinstal.c | 28 ----------------------------
 drivers/acpi/acpica/tbxfload.c |  2 +-
 2 files changed, 1 insertion(+), 29 deletions(-)
drivers/acpi/acpica/tbinstal.c +0 -28
index ee74515..9d21296 100644
@@ -222,34 +222,6 @@ acpi_tb_install_standard_table(acpi_physical_address address,
 	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
 
 	if (reload) {
-		/*
-		 * Validate the incoming table signature.
-		 *
-		 * 1) Originally, we checked the table signature for "SSDT" or "PSDT".
-		 * 2) We added support for OEMx tables, signature "OEM".
-		 * 3) Valid tables were encountered with a null signature, so we just
-		 *    gave up on validating the signature, (05/2008).
-		 * 4) We encountered non-AML tables such as the MADT, which caused
-		 *    interpreter errors and kernel faults. So now, we once again allow
-		 *    only "SSDT", "OEMx", and now, also a null signature. (05/2011).
-		 */
-		if ((new_table_desc.signature.ascii[0] != 0x00) &&
-		    (!ACPI_COMPARE_NAME
-		     (&new_table_desc.signature, ACPI_SIG_SSDT))
-		    && (strncmp(new_table_desc.signature.ascii, "OEM", 3))) {
-			ACPI_BIOS_ERROR((AE_INFO,
-					 "Table has invalid signature [%4.4s] (0x%8.8X), "
-					 "must be SSDT or OEMx",
-					 acpi_ut_valid_nameseg(new_table_desc.
-							       signature.
-							       ascii) ?
-					 new_table_desc.signature.
-					 ascii : "????",
-					 new_table_desc.signature.integer));
-
-			status = AE_BAD_SIGNATURE;
-			goto unlock_and_exit;
-		}
 
 		/* Check if table is already registered */
 
drivers/acpi/acpica/tbxfload.c +1 -1
index b71ce3b..d81f442 100644
@@ -206,7 +206,7 @@ acpi_status acpi_tb_load_namespace(void)
 	for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
 		table = &acpi_gbl_root_table_list.tables[i];
 
-		if (!acpi_gbl_root_table_list.tables[i].address ||
+		if (!table->address ||
 		    (!ACPI_COMPARE_NAME(table->signature.ascii, ACPI_SIG_SSDT)
 		     && !ACPI_COMPARE_NAME(table->signature.ascii,
 					   ACPI_SIG_PSDT)
Signature · 1 line
2.7.4
author
#10 lore raw

PATCH 10/16 ACPICA: Tables: Change table duplication check to be related to acpi_gbl_verify_table_checksum

In reply to Lv Zheng

ACPICA commit 3d837b5d4b1033942b4d91c7d3801a09c3157918

acpi_gbl_verify_table_checksum is used to avoid validating (mapping) an entire table in OS boot stage. 2nd "Reload" check in acpi_tb_install_standard_table() is prepared for the same purpose. So this patch combines them together using a renamed acpi_gbl_enable_table_validation flag. Lv Zheng.

---
 drivers/acpi/acpica/tbdata.c   |  4 ++--
 drivers/acpi/acpica/tbinstal.c |  2 +-
 drivers/acpi/acpica/tbxface.c  |  8 ++++++++
 drivers/acpi/bus.c             |  3 ---
 drivers/acpi/tables.c          |  4 ++--
 include/acpi/acpixf.h          | 15 ++++++++-------
 6 files changed, 21 insertions(+), 15 deletions(-)
drivers/acpi/acpica/tbdata.c +2 -2
index 7056ca0..24d99711 100644
@@ -338,7 +338,7 @@ void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc)
 acpi_status acpi_tb_validate_temp_table(struct acpi_table_desc *table_desc)
 {
 
-	if (!table_desc->pointer && !acpi_gbl_verify_table_checksum) {
+	if (!table_desc->pointer && !acpi_gbl_enable_table_validation) {
 		/*
 		 * Only validates the header of the table.
 		 * Note that Length contains the size of the mapping after invoking
@@ -394,7 +394,7 @@ acpi_tb_verify_temp_table(struct acpi_table_desc *table_desc, char *signature)
 
 	/* Verify the checksum */
 
-	if (acpi_gbl_verify_table_checksum) {
+	if (acpi_gbl_enable_table_validation) {
 		status =
 		    acpi_tb_verify_checksum(table_desc->pointer,
 					    table_desc->length);
drivers/acpi/acpica/tbinstal.c +1 -1
index 9d21296..f7bc362 100644
@@ -221,7 +221,7 @@ acpi_tb_install_standard_table(acpi_physical_address address,
 
 	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
 
-	if (reload) {
+	if (acpi_gbl_enable_table_validation) {
 
 		/* Check if table is already registered */
 
drivers/acpi/acpica/tbxface.c +8 -0
index 18508b2..38c0104 100644
@@ -194,6 +194,14 @@ acpi_status ACPI_INIT_FUNCTION acpi_reallocate_root_table(void)
 		}
 	}
 
+	if (!acpi_gbl_enable_table_validation) {
+		/*
+		 * Now it's safe to do full table validation. We can do deferred
+		 * table initilization here once the flag is set.
+		 */
+		acpi_gbl_enable_table_validation = TRUE;
+	}
+
 	acpi_gbl_root_table_list.flags |= ACPI_ROOT_ALLOW_RESIZE;
 
 	status = acpi_tb_resize_root_table_list();
drivers/acpi/bus.c +0 -3
index af74b42..59f2f96 100644
@@ -995,9 +995,6 @@ void __init acpi_early_init(void)
 
 	printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION);
 
-	/* It's safe to verify table checksums during late stage */
-	acpi_gbl_verify_table_checksum = TRUE;
-
 	/* enable workarounds, unless strict ACPI spec. compliance */
 	if (!acpi_strict)
 		acpi_gbl_enable_interpreter_slack = TRUE;
drivers/acpi/tables.c +2 -2
index ff42539..80ce2a7 100644
@@ -740,10 +740,10 @@ int __init acpi_table_init(void)
 
 	if (acpi_verify_table_checksum) {
 		pr_info("Early table checksum verification enabled\n");
-		acpi_gbl_verify_table_checksum = TRUE;
+		acpi_gbl_enable_table_validation = TRUE;
 	} else {
 		pr_info("Early table checksum verification disabled\n");
-		acpi_gbl_verify_table_checksum = FALSE;
+		acpi_gbl_enable_table_validation = FALSE;
 	}
 
 	status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0);
include/acpi/acpixf.h +8 -7
index a59c44c..12dac84 100644
@@ -160,13 +160,14 @@ ACPI_INIT_GLOBAL(u8, acpi_gbl_create_osi_method, TRUE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_use_default_register_widths, TRUE);
 
 /*
- * Whether or not to verify the table checksum before installation. Set
- * this to TRUE to verify the table checksum before install it to the table
- * manager. Note that enabling this option causes errors to happen in some
- * OSPMs during early initialization stages. Default behavior is to do such
- * verification.
- */
-ACPI_INIT_GLOBAL(u8, acpi_gbl_verify_table_checksum, TRUE);
+ * Whether or not to validate (map) an entire table to verify
+ * checksum/duplication in early stage before install. Set this to TRUE to
+ * allow early table validation before install it to the table manager.
+ * Note that enabling this option causes errors to happen in some OSPMs
+ * during early initialization stages. Default behavior is to allow such
+ * validation.
+ */
+ACPI_INIT_GLOBAL(u8, acpi_gbl_enable_table_validation, TRUE);
 
 /*
  * Optionally enable output from the AML Debug Object.
Signature · 1 line
2.7.4
author
#11 lore raw

PATCH 11/16 ACPICA: Tables: Combine checksum/duplication verification together

In reply to Lv Zheng

ACPICA commit 182bdffc0644f568be614a6d4debd651e29ca587

They are all mechanisms used to verify if a table is qualified to be installed and controlled by acpi_gbl_enable_table_validation, so combine them together. By doing so, table duplication check is applied to the statically loaded tables (however whether it is actually enabled is still determined by acpi_gbl_enable_table_validation). Lv Zheng.

---
 drivers/acpi/acpica/actables.h |   3 +-
 drivers/acpi/acpica/tbdata.c   | 151 +++++++++++++++++++++++++++++++++++++++--
 drivers/acpi/acpica/tbinstal.c | 125 ++++++----------------------------
 3 files changed, 169 insertions(+), 110 deletions(-)
drivers/acpi/acpica/actables.h +2 -1
index 89ed31b..84a3ceb 100644
@@ -76,7 +76,8 @@ void acpi_tb_release_temp_table(struct acpi_table_desc *table_desc);
 acpi_status acpi_tb_validate_temp_table(struct acpi_table_desc *table_desc);
 
 acpi_status
-acpi_tb_verify_temp_table(struct acpi_table_desc *table_desc, char *signature);
+acpi_tb_verify_temp_table(struct acpi_table_desc *table_desc,
+			  char *signature, u32 *table_index);
 
 u8 acpi_tb_is_table_loaded(u32 table_index);
 
drivers/acpi/acpica/tbdata.c +147 -4

196 lines not on this page · raw message

drivers/acpi/acpica/tbinstal.c +20 -105

157 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#12 lore raw

PATCH 12/16 ACPICA: Tables: Add deferred table verification support

In reply to Lv Zheng

ACPICA commit 2dd6c151d5d5e76dacba8f7db9e259fc72982d17 ACPICA commit ffddee6638aced83be18b8bc88569586c1a43e03

This patch allows tables not verified in early stage verfied in acpi_reallocate_root_table(). This is useful for OSPMs like linux where tables cannot be verified in early stage due to early ioremp limitations on some architectures. Reported by Hans de Geode, fixed by Lv Zheng.

---
 drivers/acpi/acpica/tbdata.c  | 34 ++++++++++++++++++++++++++++------
 drivers/acpi/acpica/tbxface.c | 27 ++++++++++++++++++++++-----
 include/acpi/actbl.h          |  1 +
 3 files changed, 51 insertions(+), 11 deletions(-)
drivers/acpi/acpica/tbdata.c +28 -6
index 577361b..b19a2f0 100644
@@ -432,6 +432,15 @@ acpi_tb_check_duplication(struct acpi_table_desc *table_desc, u32 *table_index)
 	/* Check if table is already registered */
 
 	for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
+
+		/* Do not compare with unverified tables */
+
+		if (!
+		    (acpi_gbl_root_table_list.tables[i].
+		     flags & ACPI_TABLE_IS_VERIFIED)) {
+			continue;
+		}
+
 		/*
 		 * Check for a table match on the entire table length,
 		 * not just the header.
@@ -483,6 +492,8 @@ acpi_tb_check_duplication(struct acpi_table_desc *table_desc, u32 *table_index)
  *
  * DESCRIPTION: This function is called to validate and verify the table, the
  *              returned table descriptor is in "VALIDATED" state.
+ *              Note that 'TableIndex' is required to be set to !NULL to
+ *              enable duplication check.
  *
  *****************************************************************************/
 
@@ -554,6 +565,8 @@ acpi_tb_verify_temp_table(struct acpi_table_desc *table_desc,
 				goto invalidate_and_exit;
 			}
 		}
+
+		table_desc->flags |= ACPI_TABLE_IS_VERIFIED;
 	}
 
 	return_ACPI_STATUS(status);
@@ -579,6 +592,8 @@ acpi_status acpi_tb_resize_root_table_list(void)
 {
 	struct acpi_table_desc *tables;
 	u32 table_count;
+	u32 current_table_count, max_table_count;
+	u32 i;
 
 	ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
 
@@ -598,8 +613,8 @@ acpi_status acpi_tb_resize_root_table_list(void)
 		table_count = acpi_gbl_root_table_list.current_table_count;
 	}
 
-	tables = ACPI_ALLOCATE_ZEROED(((acpi_size)table_count +
-				       ACPI_ROOT_TABLE_SIZE_INCREMENT) *
+	max_table_count = table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT;
+	tables = ACPI_ALLOCATE_ZEROED(((acpi_size)max_table_count) *
 				      sizeof(struct acpi_table_desc));
 	if (!tables) {
 		ACPI_ERROR((AE_INFO,
@@ -609,9 +624,16 @@ acpi_status acpi_tb_resize_root_table_list(void)
 
 	/* Copy and free the previous table array */
 
+	current_table_count = 0;
 	if (acpi_gbl_root_table_list.tables) {
-		memcpy(tables, acpi_gbl_root_table_list.tables,
-		       (acpi_size)table_count * sizeof(struct acpi_table_desc));
+		for (i = 0; i < table_count; i++) {
+			if (acpi_gbl_root_table_list.tables[i].address) {
+				memcpy(tables + current_table_count,
+				       acpi_gbl_root_table_list.tables + i,
+				       sizeof(struct acpi_table_desc));
+				current_table_count++;
+			}
+		}
 
 		if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
 			ACPI_FREE(acpi_gbl_root_table_list.tables);
@@ -619,8 +641,8 @@ acpi_status acpi_tb_resize_root_table_list(void)
 	}
 
 	acpi_gbl_root_table_list.tables = tables;
-	acpi_gbl_root_table_list.max_table_count =
-	    table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT;
+	acpi_gbl_root_table_list.max_table_count = max_table_count;
+	acpi_gbl_root_table_list.current_table_count = current_table_count;
 	acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
 
 	return_ACPI_STATUS(AE_OK);
drivers/acpi/acpica/tbxface.c +22 -5
index 38c0104..26ad596 100644
@@ -167,7 +167,8 @@ ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_tables)
 acpi_status ACPI_INIT_FUNCTION acpi_reallocate_root_table(void)
 {
 	acpi_status status;
-	u32 i;
+	struct acpi_table_desc *table_desc;
+	u32 i, j;
 
 	ACPI_FUNCTION_TRACE(acpi_reallocate_root_table);
 
@@ -179,6 +180,8 @@ acpi_status ACPI_INIT_FUNCTION acpi_reallocate_root_table(void)
 		return_ACPI_STATUS(AE_SUPPORT);
 	}
 
+	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
+
 	/*
 	 * Ensure OS early boot logic, which is required by some hosts. If the
 	 * table state is reported to be wrong, developers should fix the
@@ -186,11 +189,11 @@ acpi_status ACPI_INIT_FUNCTION acpi_reallocate_root_table(void)
 	 * early stage.
 	 */
 	for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
-		if (acpi_gbl_root_table_list.tables[i].pointer) {
+		table_desc = &acpi_gbl_root_table_list.tables[i];
+		if (table_desc->pointer) {
 			ACPI_ERROR((AE_INFO,
 				    "Table [%4.4s] is not invalidated during early boot stage",
-				    acpi_gbl_root_table_list.tables[i].
-				    signature.ascii));
+				    table_desc->signature.ascii));
 		}
 	}
 
@@ -200,11 +203,25 @@ acpi_status ACPI_INIT_FUNCTION acpi_reallocate_root_table(void)
 		 * table initilization here once the flag is set.
 		 */
 		acpi_gbl_enable_table_validation = TRUE;
+		for (i = 0; i < acpi_gbl_root_table_list.current_table_count;
+		     ++i) {
+			table_desc = &acpi_gbl_root_table_list.tables[i];
+			if (!(table_desc->flags & ACPI_TABLE_IS_VERIFIED)) {
+				status =
+				    acpi_tb_verify_temp_table(table_desc, NULL,
+							      &j);
+				if (ACPI_FAILURE(status)) {
+					acpi_tb_uninstall_table(table_desc);
+				}
+			}
+		}
 	}
 
 	acpi_gbl_root_table_list.flags |= ACPI_ROOT_ALLOW_RESIZE;
-
 	status = acpi_tb_resize_root_table_list();
+	acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
+
+	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
 	return_ACPI_STATUS(status);
 }
 
include/acpi/actbl.h +1 -0
index bdc55c0..89509b8 100644
@@ -394,6 +394,7 @@ struct acpi_table_desc {
 #define ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL (1)	/* Physical address, internally mapped */
 #define ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL  (2)	/* Virtual address, internallly allocated */
 #define ACPI_TABLE_ORIGIN_MASK              (3)
+#define ACPI_TABLE_IS_VERIFIED              (4)
 #define ACPI_TABLE_IS_LOADED                (8)
 
 /*
Signature · 1 line
2.7.4
author
#13 lore raw

PATCH 13/16 ACPICA: iASL: Ensure that the target node is valid in acpi_ex_create_alias

In reply to Lv Zheng

From: Alex James <[email protected]>

ACPICA commit 8b14afac65d983610cc5387ede6d85ea5ee075be

The following ACPI table contains an invalid target node within the Alias operator:

definition_block ("", "SSDT", 1, "Bug", "BugTable", 0x00001000)

{
    Scope (_SB)
    {
        Device (DEV0)
        {
            Name (_ADR, 1)

            Device (DEV1)
            {
                Alias (_ADR, _ADR)
            }
        }
    }
}

If an ACPI table contains such an invalid target node in an Alias operator, a segmentation fault will occur when the target node is dereferenced within acpi_ex_create_alias. Add a check for such an invalid target node in acpi_ex_create_alias and return AE_NULL_OBJECT as suggested by @acpibob.

---
 drivers/acpi/acpica/excreate.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/acpi/acpica/excreate.c +5 -0
index d43d7da..6867586 100644
@@ -87,6 +87,11 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state)
 				  target_node->object);
 	}
 
+	/* Ensure that the target node is valid */
+	if (!target_node) {
+		return_ACPI_STATUS(AE_NULL_OBJECT);
+	}
+
 	/*
 	 * For objects that can never change (i.e., the NS node will
 	 * permanently point to the same object), we can simply attach
Signature · 1 line
2.7.4
author
#14 lore raw

PATCH 14/16 ACPICA: Disassembler: skip parsing of incorrect external declarations

In reply to Lv Zheng

From: Erik Schmauss <[email protected]>

ACPICA commit ed25461901d34120067b07ec280af30abc0458f1

---
 drivers/acpi/acpica/psobject.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/acpi/acpica/psobject.c +26 -0
index ef6384e..0bef6df 100644
@@ -359,6 +359,32 @@ acpi_ps_create_op(struct acpi_walk_state *walk_state,
 		    acpi_ps_build_named_op(walk_state, aml_op_start, op,
 					   &named_op);
 		acpi_ps_free_op(op);
+
+#ifdef ACPI_ASL_COMPILER
+		if (acpi_gbl_disasm_flag
+		    && walk_state->opcode == AML_EXTERNAL_OP
+		    && status == AE_NOT_FOUND) {
+			/*
+			 * If parsing of AML_EXTERNAL_OP's name path fails, then skip
+			 * past this opcode and keep parsing. This is a much better
+			 * alternative than to abort the entire disassembler. At this
+			 * point, the parser_state is at the end of the namepath of the
+			 * external declaration opcode. Setting walk_state->Aml to
+			 * walk_state->parser_state.Aml + 2 moves increments the
+			 * walk_state->Aml past the object type and the paramcount of the
+			 * external opcode. For the error message, only print the AML
+			 * offset. We could attempt to print the name but this may cause
+			 * a segmentation fault when printing the namepath because the
+			 * AML may be incorrect.
+			 */
+			acpi_os_printf
+			    ("// Invalid external declaration at AML offset 0x%x.\n",
+			     walk_state->aml -
+			     walk_state->parser_state.aml_start);
+			walk_state->aml = walk_state->parser_state.aml + 2;
+			return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
+		}
+#endif
 		if (ACPI_FAILURE(status)) {
 			return_ACPI_STATUS(status);
 		}
Signature · 1 line
2.7.4
author
#15 lore raw

PATCH 15/16 ACPICA: iasl: Update to IORT SMMUv3 disassembling

In reply to Lv Zheng

From: Ganapatrao Kulkarni <[email protected]>

ACPICA commit 8cadc4fb500e2aa52241e367c87a0f95d9760c58

ARM IORT specification has provision to define Proximity domain in SMMUv3 IORT table. Adding required changes to decode Proximity domain of SMMUv3 IORT table.

---
 include/acpi/actbl2.h | 4 ++++
 1 file changed, 4 insertions(+)
include/acpi/actbl2.h +4 -0
index 5829eed..d568948 100644
@@ -806,6 +806,9 @@ struct acpi_iort_smmu_v3 {
 	u32 pri_gsiv;
 	u32 gerr_gsiv;
 	u32 sync_gsiv;
+	u8 pxm;
+	u8 reserved1;
+	u16 reserved2;
 };
 
 /* Values for Model field above */
@@ -818,6 +821,7 @@ struct acpi_iort_smmu_v3 {
 
 #define ACPI_IORT_SMMU_V3_COHACC_OVERRIDE   (1)
 #define ACPI_IORT_SMMU_V3_HTTU_OVERRIDE     (1<<1)
+#define ACPI_IORT_SMMU_V3_PXM_VALID         (1<<3)
 
 /*******************************************************************************
  *
Signature · 1 line
2.7.4
author
#16 lore raw

PATCH 16/16 ACPICA: Update version to 20170629

In reply to Lv Zheng

From: Bob Moore <[email protected]>

ACPICA commit 7271c1c54c095c06ed9e7d28641f2356da840038

Version 20170629

---
 include/acpi/acpixf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/acpi/acpixf.h +1 -1
index 12dac84..06b87ad 100644
@@ -46,7 +46,7 @@
 
 /* Current ACPICA subsystem version in YYYYMMDD format */
 
-#define ACPI_CA_VERSION                 0x20170531
+#define ACPI_CA_VERSION                 0x20170629
 
 #include <acpi/acconfig.h>
 #include <acpi/actypes.h>
Signature · 1 line
2.7.4
#17 lore raw
In reply to Lv Zheng
Quoted 80 lines · Lv Zheng

The 20170629 ACPICA kernel-resident subsystem updates are linuxized based on the linux-pm/linux-next branch.

The patchset has passed the following build/boot tests. Build tests are performed as follows:
1. i386 + allyes
2. i386 + allno
3. i386 + default + ACPI_DEBUGGER=y
4. i386 + default + ACPI_DEBUGGER=n + ACPI_DEBUG=y
5. i386 + default + ACPI_DEBUG=n + ACPI=y
6. i386 + default + ACPI=n
7. x86_64 + allyes
8. x86_64 + allno
9. x86_64 + default + ACPI_DEBUGGER=y
10.x86_64 + default + ACPI_DEBUGGER=n + ACPI_DEBUG=y 11.x86_64 + default + ACPI_DEBUG=n + ACPI=y
12.x86_64 + default + ACPI=n
Boot tests are performed as follows:
1. x86_64 + default + ACPI_DEBUGGER=y
Where:
1. i386: machine named as "Dell Inspiron Mini 1010"
2. x86_64: machine named as "Microsoft Surface Pro 3"
3. default: kernel configuration with following items enabled:
All hardware drivers related to the machines of i386/x86_64 All "drivers/acpi" configurations
All "drivers/platform" drivers
All other drivers that link the APIs provided by ACPICA subsystem

The divergences checking result:
Before applying (20170531 Release):
369 lines
After applying (20170629 Release):
390 lines (increased due to export of acpi_tb_xxx functions)

Alex James (1):
ACPICA: iASL: Ensure that the target node is valid in
acpi_ex_create_alias

Bob Moore (2):
ACPICA: Small indentation changes, no functional change
ACPICA: Update version to 20170629

Erik Schmauss (3):
ACPICA: Tools: Deallocate memory allocated by
ac_get_all_tables_from_file via ac_delete_table_list
ACPICA: iASL compiler: allow compilation of externals with paths that
refer to existing names
ACPICA: Disassembler: skip parsing of incorrect external declarations

Ganapatrao Kulkarni (1):
ACPICA: iasl: Update to IORT SMMUv3 disassembling

Kees Cook (1):
Back port of "ACPICA: Use designated initializers"

Lv Zheng (7):
ACPICA: linuxize: cleanup typedef definitions
ACPICA: Tables: Add sanity check in acpi_put_table()
ACPICA: Tables: Cleanup table handler invokers
ACPICA: Tables: Do not validate signature for dynamic table load
ACPICA: Tables: Change table duplication check to be related to
acpi_gbl_verify_table_checksum
ACPICA: Tables: Combine checksum/duplication verification together
ACPICA: Tables: Add deferred table verification support

Robin Murphy (1):
ACPICA: IORT: Update SMMU models for revision C

 drivers/acpi/acpica/acapps.h    |   2 +
 drivers/acpi/acpica/aclocal.h   |   5 +-
 drivers/acpi/acpica/acobject.h  |  12 ++-
 drivers/acpi/acpica/actables.h  |   5 +-
 drivers/acpi/acpica/excreate.c  |   5 +
 drivers/acpi/acpica/hwxfsleep.c |   9 +-
 drivers/acpi/acpica/nsaccess.c  |   6 ++
 drivers/acpi/acpica/psobject.c  |  26 +++++
 drivers/acpi/acpica/tbdata.c    | 230 +++++++++++++++++++++++++++++++++++-----
 drivers/acpi/acpica/tbinstal.c  | 161 ++++------------------------
 drivers/acpi/acpica/tbxface.c   |  39 ++++++-
 drivers/acpi/acpica/tbxfload.c  |   2 +-
Quoted 8 lines
 drivers/acpi/bus.c              |   3 -
 drivers/acpi/tables.c           |   4 +-
 include/acpi/acpixf.h           |  15 +--
 include/acpi/actbl.h            |   1 +
 include/acpi/actbl2.h           |  16 ++-
 include/acpi/platform/acenv.h   |   9 +-
 include/acpi/platform/aclinux.h |   3 +
 19 files changed, 356 insertions(+), 197 deletions(-)

Whole series applied.

Thanks,
Rafael