summaryrefslogtreecommitdiff
path: root/usr/src/cmd/acpi/iasl/aslxref.c
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@joyent.com>2018-07-26 17:41:45 +0000
committerRobert Mustacchi <rm@joyent.com>2019-01-10 20:11:18 +0000
commit35786f6866ae52207d0f1a25fe7ca5f652f32ce0 (patch)
treec0de3a2c5ca511e732b7ab0d94191085317bad2a /usr/src/cmd/acpi/iasl/aslxref.c
parentbc36eafdde0c7048471866fc7cea7b93852592db (diff)
downloadillumos-joyent-35786f6866ae52207d0f1a25fe7ca5f652f32ce0.tar.gz
9823 Deadlock in ACPI Method Evaluation
9824 Update ACPI to joyent/20180629 Reviewed by: Patrick Mooney <patrick.mooney@joyent.com> Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Reviewed by: Andy Fiddaman <af@citrus-it.net> Approved by: Richard Lowe <richlowe@richlowe.net>
Diffstat (limited to 'usr/src/cmd/acpi/iasl/aslxref.c')
-rw-r--r--usr/src/cmd/acpi/iasl/aslxref.c398
1 files changed, 165 insertions, 233 deletions
diff --git a/usr/src/cmd/acpi/iasl/aslxref.c b/usr/src/cmd/acpi/iasl/aslxref.c
index a2cb6b3324..c34ab49c82 100644
--- a/usr/src/cmd/acpi/iasl/aslxref.c
+++ b/usr/src/cmd/acpi/iasl/aslxref.c
@@ -4,10 +4,118 @@
*
*****************************************************************************/
-/*
- * Copyright (C) 2000 - 2016, Intel Corp.
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
* All rights reserved.
*
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************
+ *
+ * Alternatively, you may choose to be licensed under the terms of the
+ * following license:
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -23,23 +131,23 @@
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Alternatively, you may choose to be licensed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ *****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
@@ -89,22 +197,6 @@ XfCheckFieldRange (
UINT32 FieldBitLength,
UINT32 AccessBitWidth);
-#ifdef __UNDER_DEVELOPMENT
-static ACPI_PARSE_OBJECT *
-XfGetParentMethod (
- ACPI_PARSE_OBJECT *Op);
-
-static void
-XfCheckIllegalReference (
- ACPI_PARSE_OBJECT *Op,
- ACPI_NAMESPACE_NODE *Node);
-
-static BOOLEAN
-XfIsObjectParental (
- ACPI_PARSE_OBJECT *MethodOp1,
- ACPI_PARSE_OBJECT *MethodOp2);
-#endif
-
/*******************************************************************************
*
@@ -425,7 +517,7 @@ XfNamespaceLocateBegin (
* references to other objects within the namespace and the parent objects
* of name declarations
*/
- if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)
+ if (Op->Asl.CompileFlags & OP_IS_NAME_DECLARATION)
{
return_ACPI_STATUS (AE_OK);
}
@@ -451,7 +543,7 @@ XfNamespaceLocateBegin (
RegisterNumber = Op->Asl.AmlOpcode & 0x0007; /* 0x60 through 0x67 */
MethodLocals = Node->MethodLocals;
- if (Op->Asl.CompileFlags & NODE_IS_TARGET)
+ if (Op->Asl.CompileFlags & OP_IS_TARGET)
{
/* Local is being initialized */
@@ -490,21 +582,18 @@ XfNamespaceLocateBegin (
RegisterNumber = Op->Asl.AmlOpcode - AML_ARG0; /* 0x68 through 0x6F */
MethodArgs = Node->MethodArgs;
- if (Op->Asl.CompileFlags & NODE_IS_TARGET)
+ /* Mark this Arg as referenced */
+
+ MethodArgs[RegisterNumber].Flags |= ASL_ARG_REFERENCED;
+ MethodArgs[RegisterNumber].Op = Op;
+
+ if (Op->Asl.CompileFlags & OP_IS_TARGET)
{
/* Arg is being initialized */
MethodArgs[RegisterNumber].Flags |= ASL_ARG_INITIALIZED;
- MethodArgs[RegisterNumber].Op = Op;
-
- return_ACPI_STATUS (AE_OK);
}
- /* Mark this Arg as referenced */
-
- MethodArgs[RegisterNumber].Flags |= ASL_ARG_REFERENCED;
- MethodArgs[RegisterNumber].Op = Op;
-
return_ACPI_STATUS (AE_OK);
}
@@ -516,7 +605,8 @@ XfNamespaceLocateBegin (
(!(OpInfo->Flags & AML_CREATE)) &&
(Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) &&
(Op->Asl.ParseOpcode != PARSEOP_NAMESEG) &&
- (Op->Asl.ParseOpcode != PARSEOP_METHODCALL))
+ (Op->Asl.ParseOpcode != PARSEOP_METHODCALL) &&
+ (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL))
{
return_ACPI_STATUS (AE_OK);
}
@@ -539,7 +629,8 @@ XfNamespaceLocateBegin (
Flags = ACPI_NS_SEARCH_PARENT;
if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
(Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
- (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
+ (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) ||
+ (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL))
{
/*
* These are name references, do not push the scope stack
@@ -569,7 +660,7 @@ XfNamespaceLocateBegin (
/* Name must appear as the last parameter */
NextOp = Op->Asl.Child;
- while (!(NextOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION))
+ while (!(NextOp->Asl.CompileFlags & OP_IS_NAME_DECLARATION))
{
NextOp = NextOp->Asl.Next;
}
@@ -595,7 +686,7 @@ XfNamespaceLocateBegin (
Gbl_NsLookupCount++;
Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
- ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node));
+ ACPI_IMODE_EXECUTE, Flags, WalkState, &Node);
if (ACPI_FAILURE (Status))
{
if (Status == AE_NOT_FOUND)
@@ -653,6 +744,26 @@ XfNamespaceLocateBegin (
return_ACPI_STATUS (Status);
}
+ /* Object was found above, check for an illegal forward reference */
+
+ if (Op->Asl.CompileFlags & OP_NOT_FOUND_DURING_LOAD)
+ {
+ /*
+ * During the load phase, this Op was flagged as a possible
+ * illegal forward reference
+ *
+ * Note: Allow "forward references" from within a method to an
+ * object that is not within any method (module-level code)
+ */
+ if (!WalkState->ScopeInfo || (UtGetParentMethod (Node) &&
+ !UtNodeIsDescendantOf (WalkState->ScopeInfo->Scope.Node,
+ UtGetParentMethod (Node))))
+ {
+ AslError (ASL_ERROR, ASL_MSG_ILLEGAL_FORWARD_REF, Op,
+ Op->Asl.ExternalName);
+ }
+ }
+
/* Check for a reference vs. name declaration */
if (!(OpInfo->Flags & AML_NAMED) &&
@@ -661,13 +772,6 @@ XfNamespaceLocateBegin (
/* This node has been referenced, mark it for reference check */
Node->Flags |= ANOBJ_IS_REFERENCED;
-
-#ifdef __UNDER_DEVELOPMENT
-
- /* Check for an illegal reference */
-
- XfCheckIllegalReference (Op, Node);
-#endif
}
/* Attempt to optimize the NamePath */
@@ -809,7 +913,7 @@ XfNamespaceLocateBegin (
Op->Asl.AmlLength = 0;
Op->Asl.ParseOpcode = PARSEOP_INTEGER;
Op->Asl.Value.Integer = (UINT64) Offset;
- Op->Asl.CompileFlags |= NODE_IS_RESOURCE_FIELD;
+ Op->Asl.CompileFlags |= OP_IS_RESOURCE_FIELD;
OpcGenerateAmlOpcode (Op);
}
@@ -826,16 +930,18 @@ XfNamespaceLocateBegin (
/*
* A reference to a method within one of these opcodes is not an
* invocation of the method, it is simply a reference to the method.
+ *
+ * September 2016: Removed DeRefOf from this list
*/
if ((Op->Asl.Parent) &&
- ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_REFOF) ||
- (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEREFOF) ||
+ ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_REFOF) ||
(Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_PACKAGE) ||
(Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)||
(Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_OBJECTTYPE)))
{
return_ACPI_STATUS (AE_OK);
}
+
/*
* There are two types of method invocation:
* 1) Invocation with arguments -- the parser recognizes this
@@ -1076,7 +1182,8 @@ XfNamespaceLocateEnd (
if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
(Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
- (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
+ (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) ||
+ (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL))
{
return_ACPI_STATUS (AE_OK);
}
@@ -1095,178 +1202,3 @@ XfNamespaceLocateEnd (
return_ACPI_STATUS (AE_OK);
}
-
-
-#ifdef __UNDER_DEVELOPMENT
-/*******************************************************************************
- *
- * FUNCTION: XfIsObjectParental
- *
- * PARAMETERS: ChildOp - Op to be checked
- * PossibleParentOp - Determine if this op is in the family
- *
- * RETURN: TRUE if ChildOp is a descendent of PossibleParentOp
- *
- * DESCRIPTION: Determine if an Op is a descendent of another Op. Used to
- * detect if a method is declared within another method.
- *
- ******************************************************************************/
-
-static BOOLEAN
-XfIsObjectParental (
- ACPI_PARSE_OBJECT *ChildOp,
- ACPI_PARSE_OBJECT *PossibleParentOp)
-{
- ACPI_PARSE_OBJECT *ParentOp;
-
-
- /* Search upwards through the tree for possible parent */
-
- ParentOp = ChildOp;
- while (ParentOp)
- {
- if (ParentOp == PossibleParentOp)
- {
- return (TRUE);
- }
-
- ParentOp = ParentOp->Asl.Parent;
- }
-
- return (FALSE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: XfGetParentMethod
- *
- * PARAMETERS: Op - Op to be checked
- *
- * RETURN: Op for parent method. NULL if object is not within a method.
- *
- * DESCRIPTION: Determine if an object is within a control method. Used to
- * implement special rules for named references from within a
- * control method.
- *
- * NOTE: It would be better to have the parser set a flag in the Op if possible.
- *
- ******************************************************************************/
-
-static ACPI_PARSE_OBJECT *
-XfGetParentMethod (
- ACPI_PARSE_OBJECT *Op)
-{
- ACPI_PARSE_OBJECT *ParentOp;
-
-
- if (!Op)
- {
- return (NULL);
- }
-
- if (Op->Asl.ParseOpcode == PARSEOP_METHOD)
- {
- return (NULL);
- }
-
- /* Walk upwards through the parse tree, up to the root if necessary */
-
- ParentOp = Op;
- while (ParentOp)
- {
- if (ParentOp->Asl.ParseOpcode == PARSEOP_METHOD)
- {
- return (ParentOp);
- }
-
- ParentOp = ParentOp->Asl.Parent;
- }
-
- /* Object is not within a method */
-
- return (NULL);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: XfCheckIllegalReference
- *
- * PARAMETERS: Op - Op referring to the target
- * TargetNode - Target of the reference
- *
- * RETURN: None. Emits error message for an illegal reference
- *
- * DESCRIPTION: Determine if a named reference is legal. A "named" reference
- * is something like: Store(ABCD, ...), where ABCD is an AML
- * Nameseg or Namepath.
- *
- * NOTE: Caller must ensure that the name Op is in fact a reference, and not
- * an actual name declaration (creation of a named object).
- *
- ******************************************************************************/
-
-static void
-XfCheckIllegalReference (
- ACPI_PARSE_OBJECT *Op,
- ACPI_NAMESPACE_NODE *TargetNode)
-{
- ACPI_PARSE_OBJECT *MethodOp1;
- ACPI_PARSE_OBJECT *MethodOp2;
- ACPI_PARSE_OBJECT *TargetOp;
-
-
- /*
- * Check for an illegal reference to a named object:
- *
- * 1) References from one control method to another, non-parent
- * method are not allowed, they will fail at runtime.
- *
- * 2) Forward references within a control method are not allowed.
- * AML interpreters use a one-pass parse of control methods
- * so these forward references will fail at runtime.
- */
- TargetOp = TargetNode->Op;
-
- MethodOp1 = XfGetParentMethod (Op);
- MethodOp2 = XfGetParentMethod (TargetOp);
-
- /* Are both objects within control method(s)? */
-
- if (!MethodOp1 || !MethodOp2)
- {
- return;
- }
-
- /* Objects not in the same method? */
-
- if (MethodOp1 != MethodOp2)
- {
- /*
- * 1) Cross-method named reference
- *
- * This is OK if and only if the target reference is within in a
- * method that is a parent of current method
- */
- if (!XfIsObjectParental (MethodOp1, MethodOp2))
- {
- AslError (ASL_ERROR, ASL_MSG_ILLEGAL_METHOD_REF, Op,
- Op->Asl.ExternalName);
- }
- }
-
- /*
- * 2) Both reference and target are in the same method. Check if this is
- * an (illegal) forward reference by examining the exact source code
- * location of each (the referenced object and the object declaration).
- * This is a bit nasty, yet effective.
- */
- else if (Op->Asl.LogicalByteOffset < TargetOp->Asl.LogicalByteOffset)
- {
- AslError (ASL_ERROR, ASL_MSG_ILLEGAL_FORWARD_REF, Op,
- Op->Asl.ExternalName);
- }
-
-}
-#endif