Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 May 2019 22:49:10 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org
Subject:   svn commit: r347413 - in vendor-sys/acpica/dist: . source/compiler source/components/events source/include source/include/platform
Message-ID:  <201905092249.x49MnA5u020899@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Thu May  9 22:49:10 2019
New Revision: 347413
URL: https://svnweb.freebsd.org/changeset/base/347413

Log:
  Import ACPICA 20190509.

Modified:
  vendor-sys/acpica/dist/changes.txt
  vendor-sys/acpica/dist/source/compiler/aslcodegen.c
  vendor-sys/acpica/dist/source/compiler/aslcompile.c
  vendor-sys/acpica/dist/source/compiler/aslcompiler.h
  vendor-sys/acpica/dist/source/compiler/aslerror.c
  vendor-sys/acpica/dist/source/compiler/aslfiles.c
  vendor-sys/acpica/dist/source/compiler/aslload.c
  vendor-sys/acpica/dist/source/compiler/aslmain.c
  vendor-sys/acpica/dist/source/compiler/aslmessages.c
  vendor-sys/acpica/dist/source/compiler/aslmessages.h
  vendor-sys/acpica/dist/source/compiler/asloperands.c
  vendor-sys/acpica/dist/source/compiler/aslstartup.c
  vendor-sys/acpica/dist/source/compiler/aslutils.c
  vendor-sys/acpica/dist/source/compiler/aslwalks.c
  vendor-sys/acpica/dist/source/compiler/aslxref.c
  vendor-sys/acpica/dist/source/components/events/evgpe.c
  vendor-sys/acpica/dist/source/include/acpixf.h
  vendor-sys/acpica/dist/source/include/platform/aclinux.h

Modified: vendor-sys/acpica/dist/changes.txt
==============================================================================
--- vendor-sys/acpica/dist/changes.txt	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/changes.txt	Thu May  9 22:49:10 2019	(r347413)
@@ -1,4 +1,91 @@
 ----------------------------------------
+09 May 2019. Summary of changes for version 20190509:
+
+
+1) ACPICA kernel-resident subsystem:
+
+Revert commit  6c43e1a ("ACPICA: Clear status of GPEs before enabling 
+them") that causes problems with Thunderbolt controllers to occur if a 
+dock device is connected at init time (the xhci_hcd and thunderbolt 
+modules crash which prevents peripherals connected through them from 
+working). Commit 6c43e1a effectively causes commit ecc1165b8b74 ("ACPICA: 
+Dispatch active GPEs at init time") to get undone, so the problem 
+addressed by commit ecc1165b8b74 appears again as a result of it.
+
+
+2) iASL Compiler/Disassembler and ACPICA tools:
+
+Reverted iASL: Additional forward reference detection. This change 
+reverts forward reference detection for field declarations. The feature 
+unintentionally emitted AML bytecode with incorrect package lengths for 
+some ASL code related to Fields and OperationRegions. This malformed AML 
+can cause systems to crash
+during boot. The malformed AML bytecode is emitted in iASL version 
+20190329 and 20190405.
+
+iASL: improve forward reference detection. This change improves forward 
+reference detection for named objects inside of scopes. If a parse object 
+has the OP_NOT_FOUND_DURING_LOAD set, it means that Op is a reference to 
+a named object that is declared later in the AML bytecode. This is 
+allowed if the reference is inside of a method and the declaration is 
+outside of a method like so:
+
+DefinitionBlock(...)
+{
+    Method (TEST)
+    {
+        Return (NUM0)
+    }
+    Name (NUM0,0)
+}
+
+However, if the declaration and reference are both in the same method or 
+outside any methods, this is a forward reference and should be marked as 
+an error because it would result in runtime errors.
+
+DefinitionBlock(...)
+{
+    Name (BUFF, Buffer (NUM0) {}) // Forward reference
+    Name (NUM0, 0x0)
+
+    Method (TEST)
+    {
+        Local0 = NUM1
+        Name (NUM1, 0x1) // Forward reference
+        return (Local0)
+    }
+}
+
+iASL: Implemented additional buffer overflow analysis for BufferField 
+declarations. Check if a buffer index argument to a create buffer field 
+operation is beyond the end of the target buffer.
+
+This affects these AML operators:
+ 
+   AML_CREATE_FIELD_OP
+   AML_CREATE_BIT_FIELD_OP
+   AML_CREATE_BYTE_FIELD_OP
+   AML_CREATE_WORD_FIELD_OP
+   AML_CREATE_DWORD_FIELD_OP
+   AML_CREATE_QWORD_FIELD_OP
+
+ There are three conditions that must be satisfied in order to allow this 
+validation at compile time:
+ 
+   1) The length of the target buffer must be an integer constant
+   2) The index specified in the create* must be an integer constant
+   3) For CreateField, the bit length argument must be non-zero.
+
+Example:
+    Name (BUF1, Buffer() {1,2})
+    CreateField (BUF1, 7, 9, CF03)  // 3: ERR
+
+dsdt.asl     14:     CreateField (BUF1, 7, 9, CF03)  // 3: ERR
+Error    6165 -                           ^ Buffer index beyond end of 
+target buffer
+
+
+----------------------------------------
 05 April 2019. Summary of changes for version 20190405:
 
 

Modified: vendor-sys/acpica/dist/source/compiler/aslcodegen.c
==============================================================================
--- vendor-sys/acpica/dist/source/compiler/aslcodegen.c	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/source/compiler/aslcodegen.c	Thu May  9 22:49:10 2019	(r347413)
@@ -690,7 +690,8 @@ CgUpdateHeader (
     {
         if (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1) != AE_OK)
         {
-            printf ("EOF while reading checksum bytes\n");
+            AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, NULL,
+                "Table length is greater than size of the input file");
             return;
         }
 

Modified: vendor-sys/acpica/dist/source/compiler/aslcompile.c
==============================================================================
--- vendor-sys/acpica/dist/source/compiler/aslcompile.c	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/source/compiler/aslcompile.c	Thu May  9 22:49:10 2019	(r347413)
@@ -224,7 +224,6 @@ CmDoCompile (
         if (AslGbl_PreprocessOnly)
         {
             UtEndEvent (Event);
-            CmCleanupAndExit ();
             return (AE_OK);
         }
     }
@@ -919,7 +918,7 @@ CmCleanupAndExit (
      * We will delete the AML file if there are errors and the
      * force AML output option has not been used.
      */
-    if (AslGbl_ParserErrorDetected || ((AslGbl_ExceptionCount[ASL_ERROR] > 0) &&
+    if (AslGbl_ParserErrorDetected || AslGbl_PreprocessOnly || ((AslGbl_ExceptionCount[ASL_ERROR] > 0) &&
         (!AslGbl_IgnoreErrors) &&
         AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle))
     {

Modified: vendor-sys/acpica/dist/source/compiler/aslcompiler.h
==============================================================================
--- vendor-sys/acpica/dist/source/compiler/aslcompiler.h	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/source/compiler/aslcompiler.h	Thu May  9 22:49:10 2019	(r347413)
@@ -1105,10 +1105,6 @@ ASL_GLOBAL_FILE_NODE *
 FlGetCurrentFileNode (
     void);
 
-BOOLEAN
-FlInputFileExists (
-    char                    *InputFilename);
-
 
 /*
  * aslhwmap - hardware map summary

Modified: vendor-sys/acpica/dist/source/compiler/aslerror.c
==============================================================================
--- vendor-sys/acpica/dist/source/compiler/aslerror.c	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/source/compiler/aslerror.c	Thu May  9 22:49:10 2019	(r347413)
@@ -869,16 +869,8 @@ static void AslInitEnode (
             return;
         }
 
-	if (!FlInputFileExists (Filename))
-	{
-            /*
-             * This means that this file is an include file. Record the .src
-             * file as the error message source because this file is not in
-             * the global file list.
-             */
-            Enode->SourceFilename =
-                FileNode->Files[ASL_FILE_SOURCE_OUTPUT].Filename;
-	}
+        Enode->SourceFilename =
+            FileNode->Files[ASL_FILE_SOURCE_OUTPUT].Filename;
     }
 }
 

Modified: vendor-sys/acpica/dist/source/compiler/aslfiles.c
==============================================================================
--- vendor-sys/acpica/dist/source/compiler/aslfiles.c	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/source/compiler/aslfiles.c	Thu May  9 22:49:10 2019	(r347413)
@@ -163,6 +163,10 @@ FlOpenIncludeWithPrefix (
     ACPI_PARSE_OBJECT       *Op,
     char                    *Filename);
 
+static BOOLEAN
+FlInputFileExists (
+    char                    *InputFilename);
+
 #ifdef ACPI_OBSOLETE_FUNCTIONS
 ACPI_STATUS
 FlParseInputPathname (
@@ -250,7 +254,7 @@ FlInitOneFile (
  *
  ******************************************************************************/
 
-BOOLEAN
+static BOOLEAN
 FlInputFileExists (
     char                    *Filename)
 {

Modified: vendor-sys/acpica/dist/source/compiler/aslload.c
==============================================================================
--- vendor-sys/acpica/dist/source/compiler/aslload.c	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/source/compiler/aslload.c	Thu May  9 22:49:10 2019	(r347413)
@@ -263,10 +263,29 @@ LdLoadFieldElements (
     ACPI_WALK_STATE         *WalkState)
 {
     ACPI_PARSE_OBJECT       *Child = NULL;
+    ACPI_PARSE_OBJECT       *SourceRegion;
     ACPI_NAMESPACE_NODE     *Node;
     ACPI_STATUS             Status;
 
 
+
+    SourceRegion = UtGetArg (Op, 0);
+    if (SourceRegion)
+    {
+        Status = AcpiNsLookup (WalkState->ScopeInfo,
+            SourceRegion->Asl.Value.String,
+            ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
+            ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
+        if (Status == AE_NOT_FOUND)
+        {
+            /*
+             * If the named object is not found, it means that it is either a
+             * forward reference or the named object does not exist.
+             */
+            SourceRegion->Asl.CompileFlags |= OP_NOT_FOUND_DURING_LOAD;
+        }
+    }
+
     /* Get the first named field element */
 
     switch (Op->Asl.AmlOpcode)
@@ -493,7 +512,7 @@ LdNamespace1Begin (
     case AML_FIELD_OP:
 
         Status = LdLoadFieldElements (Op, WalkState);
-        break;
+        return (Status);
 
     case AML_INT_CONNECTION_OP:
 
@@ -557,8 +576,7 @@ LdNamespace1Begin (
          * We only want references to named objects:
          *      Store (2, WXYZ) -> Attempt to resolve the name
          */
-        if ((OpInfo->Class == AML_CLASS_NAMED_OBJECT) &&
-            (OpInfo->Type != AML_TYPE_NAMED_FIELD))
+        if (OpInfo->Class == AML_CLASS_NAMED_OBJECT)
         {
             return (AE_OK);
         }

Modified: vendor-sys/acpica/dist/source/compiler/aslmain.c
==============================================================================
--- vendor-sys/acpica/dist/source/compiler/aslmain.c	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/source/compiler/aslmain.c	Thu May  9 22:49:10 2019	(r347413)
@@ -291,7 +291,8 @@ main (
     /*
      * At this point, compilation of a data table or disassembly is complete.
      */
-    if (AslGbl_FileType == ASL_INPUT_TYPE_ASCII_DATA || AcpiGbl_DisasmFlag)
+    if (AslGbl_PreprocessOnly || AcpiGbl_DisasmFlag ||
+        AslGbl_FileType == ASL_INPUT_TYPE_ASCII_DATA)
     {
         goto CleanupAndExit;
     }

Modified: vendor-sys/acpica/dist/source/compiler/aslmessages.c
==============================================================================
--- vendor-sys/acpica/dist/source/compiler/aslmessages.c	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/source/compiler/aslmessages.c	Thu May  9 22:49:10 2019	(r347413)
@@ -283,7 +283,7 @@ const char                      *AslCompilerMsgs [] =
 /*    ASL_MSG_NO_RETVAL */                  "Called method returns no value",
 /*    ASL_MSG_NO_WHILE */                   "No enclosing While statement",
 /*    ASL_MSG_NON_ASCII */                  "Invalid characters found in file",
-/*    ASL_MSG_NON_ZERO */                   "Operand evaluates to zero",
+/*    ASL_MSG_BUFFER_FIELD_LENGTH */        "Field length must be non-zero",
 /*    ASL_MSG_NOT_EXIST */                  "Object does not exist",
 /*    ASL_MSG_NOT_FOUND */                  "Object not found or not accessible from current scope",
 /*    ASL_MSG_NOT_METHOD */                 "Not a control method, cannot invoke",
@@ -342,7 +342,7 @@ const char                      *AslCompilerMsgs [] =
 /*    ASL_MSG_RANGE */                      "Constant out of range",
 /*    ASL_MSG_BUFFER_ALLOCATION */          "Could not allocate line buffer",
 /*    ASL_MSG_MISSING_DEPENDENCY */         "Missing dependency",
-/*    ASL_MSG_ILLEGAL_FORWARD_REF */        "Forward references are not supported by the ASL language",
+/*    ASL_MSG_ILLEGAL_FORWARD_REF */        "Illegal forward reference",
 /*    ASL_MSG_ILLEGAL_METHOD_REF */         "Object is declared in a different method",
 /*    ASL_MSG_LOCAL_NOT_USED */             "Method Local is set but never used",
 /*    ASL_MSG_ARG_AS_LOCAL_NOT_USED */      "Method Argument (as a local) is set but never used",
@@ -364,7 +364,8 @@ const char                      *AslCompilerMsgs [] =
 /*    ASL_MSG_NAMEPATH_NOT_EXIST */         "One or more objects within the Pathname do not exist",
 /*    ASL_MSG_REGION_LENGTH */              "Operation Region declared with zero length",
 /*    ASL_MSG_TEMPORARY_OBJECT */           "Object is created temporarily in another method and cannot be accessed",
-/*    ASL_MSG_UNDEFINED_EXTERNAL */         "Named object was declared external but the actual definition does not exist"
+/*    ASL_MSG_UNDEFINED_EXTERNAL */         "Named object was declared external but the actual definition does not exist",
+/*    ASL_MSG_BUFFER_FIELD_OVERFLOW */        "Buffer field extends beyond end of target buffer"
 };
 
 /* Table compiler */

Modified: vendor-sys/acpica/dist/source/compiler/aslmessages.h
==============================================================================
--- vendor-sys/acpica/dist/source/compiler/aslmessages.h	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/source/compiler/aslmessages.h	Thu May  9 22:49:10 2019	(r347413)
@@ -285,7 +285,7 @@ typedef enum
     ASL_MSG_NO_RETVAL,
     ASL_MSG_NO_WHILE,
     ASL_MSG_NON_ASCII,
-    ASL_MSG_NON_ZERO,
+    ASL_MSG_BUFFER_FIELD_LENGTH,
     ASL_MSG_NOT_EXIST,
     ASL_MSG_NOT_FOUND,
     ASL_MSG_NOT_METHOD,
@@ -367,6 +367,7 @@ typedef enum
     ASL_MSG_REGION_LENGTH,
     ASL_MSG_TEMPORARY_OBJECT,
     ASL_MSG_UNDEFINED_EXTERNAL,
+    ASL_MSG_BUFFER_FIELD_OVERFLOW,
 
     /* These messages are used by the Data Table compiler only */
 

Modified: vendor-sys/acpica/dist/source/compiler/asloperands.c
==============================================================================
--- vendor-sys/acpica/dist/source/compiler/asloperands.c	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/source/compiler/asloperands.c	Thu May  9 22:49:10 2019	(r347413)
@@ -819,6 +819,7 @@ OpnDoBuffer (
     BufferLengthOp->Asl.Value.Integer = BufferLength;
 
     (void) OpcSetOptimalIntegerSize (BufferLengthOp);
+    UtSetParseOpName (BufferLengthOp);
 
     /* Remaining nodes are handled via the tree walk */
 }
@@ -905,6 +906,7 @@ OpnDoPackage (
          */
         Op->Asl.Child->Asl.ParseOpcode = PARSEOP_INTEGER;
         Op->Asl.Child->Asl.Value.Integer = PackageLength;
+        UtSetParseOpName (Op);
 
         /* Set the AML opcode */
 

Modified: vendor-sys/acpica/dist/source/compiler/aslstartup.c
==============================================================================
--- vendor-sys/acpica/dist/source/compiler/aslstartup.c	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/source/compiler/aslstartup.c	Thu May  9 22:49:10 2019	(r347413)
@@ -550,13 +550,9 @@ AslDoOneFile (
         Status = CmDoCompile ();
         if (ACPI_FAILURE (Status))
         {
+            PrTerminatePreprocessor ();
             return (Status);
         }
-
-        /* Cleanup (for next source file) and exit */
-
-        AeClearErrorLog ();
-        PrTerminatePreprocessor ();
 
         /*
          * At this point, we know how many lines are in the input file. Save it

Modified: vendor-sys/acpica/dist/source/compiler/aslutils.c
==============================================================================
--- vendor-sys/acpica/dist/source/compiler/aslutils.c	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/source/compiler/aslutils.c	Thu May  9 22:49:10 2019	(r347413)
@@ -541,8 +541,14 @@ UtDisplayOneSummary (
 {
     UINT32                  i;
     ASL_GLOBAL_FILE_NODE    *FileNode;
+    BOOLEAN                 DisplayAMLSummary;
 
 
+    DisplayAMLSummary =
+        !AslGbl_PreprocessOnly && !AslGbl_ParserErrorDetected &&
+        ((AslGbl_ExceptionCount[ASL_ERROR] == 0) || AslGbl_IgnoreErrors) &&
+        AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle;
+
     if (FileId != ASL_FILE_STDOUT)
     {
         /* Compiler name and version number */
@@ -595,9 +601,7 @@ UtDisplayOneSummary (
 
             /* AML summary */
 
-            if (!AslGbl_ParserErrorDetected &&
-                ((AslGbl_ExceptionCount[ASL_ERROR] == 0) || AslGbl_IgnoreErrors) &&
-                AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle)
+            if (DisplayAMLSummary)
             {
                 FlPrintFile (FileId,
                     "%-14s %s - %7u bytes %6u opcodes  %6u named objects\n",
@@ -633,7 +637,7 @@ UtDisplayOneSummary (
             continue;
         }
 
-        FlPrintFile (FileId, "%14s %s - %u bytes\n",
+        FlPrintFile (FileId, "%-14s %s - %7u bytes\n",
             AslGbl_FileDescs[i].ShortDescription,
             AslGbl_Files[i].Filename, FlGetFileSize (i));
     }

Modified: vendor-sys/acpica/dist/source/compiler/aslwalks.c
==============================================================================
--- vendor-sys/acpica/dist/source/compiler/aslwalks.c	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/source/compiler/aslwalks.c	Thu May  9 22:49:10 2019	(r347413)
@@ -165,7 +165,15 @@ static void
 AnAnalyzeStoreOperator (
     ACPI_PARSE_OBJECT       *Op);
 
+static BOOLEAN
+AnIsValidBufferConstant (
+    ACPI_PARSE_OBJECT       *Op);
 
+static void
+AnValidateCreateBufferField (
+    ACPI_PARSE_OBJECT       *CreateBufferFieldOp);
+
+
 /*******************************************************************************
  *
  * FUNCTION:    AnMethodTypingWalkEnd
@@ -669,6 +677,14 @@ AnOtherSemanticAnalysisWalkBegin (
     OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
 
 
+    if (OpInfo->Flags & AML_CREATE)
+    {
+        /* This group contains all of the Create Buffer Field operators */
+
+        AnValidateCreateBufferField (Op);
+        return (AE_OK);
+    }
+
     /*
      * Determine if an execution class operator actually does something by
      * checking if it has a target and/or the function return value is used.
@@ -734,10 +750,10 @@ AnOtherSemanticAnalysisWalkBegin (
         }
     }
 
-
     /*
      * Semantic checks for individual ASL operators
      */
+
     switch (Op->Asl.ParseOpcode)
     {
     case PARSEOP_STORE:
@@ -785,22 +801,6 @@ AnOtherSemanticAnalysisWalkBegin (
         }
         break;
 
-    case PARSEOP_CREATEFIELD:
-        /*
-         * Check for a zero Length (NumBits) operand. NumBits is the 3rd operand
-         */
-        ArgOp = Op->Asl.Child;
-        ArgOp = ArgOp->Asl.Next;
-        ArgOp = ArgOp->Asl.Next;
-
-        if ((ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) ||
-           ((ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) &&
-            (ArgOp->Asl.Value.Integer == 0)))
-        {
-            AslError (ASL_ERROR, ASL_MSG_NON_ZERO, ArgOp, NULL);
-        }
-        break;
-
     case PARSEOP_CONNECTION:
         /*
          * Ensure that the referenced operation region has the correct SPACE_ID.
@@ -883,6 +883,194 @@ AnOtherSemanticAnalysisWalkBegin (
     }
 
     return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AnValidateCreateBufferField
+ *
+ * PARAMETERS:  Op                  - A create buffer field operator
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Check if a buffer index argument to a create buffer field
+ *              operation is beyond the end of the target buffer.
+ *
+ *  Validates these AML operators:
+ *
+ *  AML_CREATE_FIELD_OP
+ *  AML_CREATE_BIT_FIELD_OP
+ *  AML_CREATE_BYTE_FIELD_OP
+ *  AML_CREATE_WORD_FIELD_OP
+ *  AML_CREATE_DWORD_FIELD_OP
+ *  AML_CREATE_QWORD_FIELD_OP
+ *
+ *  There are two conditions that must be satisfied in order to enable
+ *  validation at compile time:
+ *
+ *  1) The length of the target buffer must be an integer constant
+ *  2) The index specified in the create* must be an integer constant
+ *  3) For CreateField, the bit length argument must be non-zero.
+ *
+ ******************************************************************************/
+
+static void
+AnValidateCreateBufferField (
+    ACPI_PARSE_OBJECT       *CreateBufferFieldOp)
+{
+    ACPI_PARSE_OBJECT       *TargetBufferOp;
+    ACPI_PARSE_OBJECT       *ArgOp;
+    UINT32                  TargetBufferLength;
+    UINT32                  LastFieldByteIndex;
+
+
+    /*
+     * 1) Get the length of the target buffer
+     */
+    ArgOp = CreateBufferFieldOp->Asl.Child;     /* Reference to target buffer */
+
+    /*
+     * If no attached Node, the target buffer may be something like an
+     * ArgX or LocalX and cannot be evaluated at compile time.
+     */
+    if (!ArgOp->Asl.Node)
+    {
+        return;
+    }
+
+    TargetBufferOp = ArgOp->Asl.Node->Op;
+    TargetBufferOp = TargetBufferOp->Asl.Child; /* Target buffer */
+    TargetBufferOp = TargetBufferOp->Asl.Next;  /* "Buffer" keyword */
+    if (!TargetBufferOp)
+    {
+        /* Not a statement of the form NAME(XXXX, Buffer.... */
+
+        return;
+    }
+
+    /* Get the buffer length argument. It must be an integer constant */
+
+    ArgOp = TargetBufferOp->Asl.Child;
+    if (!AnIsValidBufferConstant (ArgOp))
+    {
+        return;
+    }
+
+    TargetBufferLength = (UINT32) ArgOp->Asl.Value.Integer;
+
+    /*
+     * 2) Get the value of the buffer index argument. It must be
+     * an integer constant.
+     */
+    ArgOp = CreateBufferFieldOp->Asl.Child;     /* Reference to target buffer */
+    ArgOp = ArgOp->Asl.Next;                    /* Buffer Index argument*/
+    if (!AnIsValidBufferConstant (ArgOp))
+    {
+        return;
+    }
+
+    LastFieldByteIndex =
+        (UINT32) ArgOp->Asl.Value.Integer;      /* Index can be in either bytes or bits */
+
+    /*
+     * 3) Get the length of the new buffer field, in bytes. Also,
+     * create the final target buffer index for the last byte of the field
+     */
+    switch (CreateBufferFieldOp->Asl.ParseOpcode)
+    {
+    case PARSEOP_CREATEBITFIELD:                /* A one bit field */
+
+        LastFieldByteIndex = ACPI_ROUND_BITS_DOWN_TO_BYTES (LastFieldByteIndex);
+        break;
+
+    case PARSEOP_CREATEBYTEFIELD:
+        break;
+
+    case PARSEOP_CREATEWORDFIELD:
+
+        LastFieldByteIndex += (sizeof (UINT16) - 1);
+        break;
+
+    case PARSEOP_CREATEDWORDFIELD:
+
+        LastFieldByteIndex += (sizeof (UINT32) - 1);
+        break;
+
+    case PARSEOP_CREATEQWORDFIELD:
+
+        LastFieldByteIndex += (sizeof (UINT64) - 1);
+        break;
+
+    case PARSEOP_CREATEFIELD:                   /* Multi-bit field */
+
+        ArgOp = ArgOp->Asl.Next;                /* Length argument, in bits */
+        if (!AnIsValidBufferConstant (ArgOp))
+        {
+            return;
+        }
+
+        /* The buffer field length is not allowed to be zero */
+
+        if (ArgOp->Asl.Value.Integer == 0)
+        {
+            AslError (ASL_WARNING,  ASL_MSG_BUFFER_FIELD_LENGTH, ArgOp, NULL);
+            return;
+        }
+
+        LastFieldByteIndex +=
+            ((UINT32) ArgOp->Asl.Value.Integer - 1);    /* Create final bit index */
+
+        /* Convert bit index to a byte index */
+
+        LastFieldByteIndex = ACPI_ROUND_BITS_DOWN_TO_BYTES (LastFieldByteIndex);
+        break;
+
+    default:
+        return;
+    }
+
+    /*
+     * 4) Check for an access (index) beyond the end of the target buffer,
+     * or a zero length target buffer.
+     */
+    if (!TargetBufferLength || (LastFieldByteIndex >= TargetBufferLength))
+    {
+        AslError (ASL_WARNING, ASL_MSG_BUFFER_FIELD_OVERFLOW, ArgOp, NULL);
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AnIsValidBufferConstant
+ *
+ * PARAMETERS:  Op                  - A buffer-related operand
+ *
+ * RETURN:      TRUE if operand is valid constant, FALSE otherwise
+ *
+ * DESCRIPTION: Check if the input Op is valid constant that can be used
+ *              in compile-time analysis.
+ *
+ ******************************************************************************/
+
+static BOOLEAN
+AnIsValidBufferConstant (
+    ACPI_PARSE_OBJECT       *Op)
+{
+    if (!Op)
+    {
+        return (FALSE);
+    }
+
+    if ((Op->Asl.ParseOpcode == PARSEOP_INTEGER) ||
+        (Op->Asl.ParseOpcode == PARSEOP_ZERO)    ||
+        (Op->Asl.ParseOpcode == PARSEOP_ONE))
+    {
+        return (TRUE);
+    }
+
+    return (FALSE);
 }
 
 

Modified: vendor-sys/acpica/dist/source/compiler/aslxref.c
==============================================================================
--- vendor-sys/acpica/dist/source/compiler/aslxref.c	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/source/compiler/aslxref.c	Thu May  9 22:49:10 2019	(r347413)
@@ -460,6 +460,8 @@ XfNamespaceLocateBegin (
     ASL_METHOD_LOCAL        *MethodArgs = NULL;
     int                     RegisterNumber;
     UINT32                  i;
+    ACPI_NAMESPACE_NODE     *DeclarationParentMethod;
+    ACPI_PARSE_OBJECT       *ReferenceParentMethod;
 
 
     ACPI_FUNCTION_TRACE_PTR (XfNamespaceLocateBegin, Op);
@@ -613,8 +615,7 @@ XfNamespaceLocateBegin (
         (Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) &&
         (Op->Asl.ParseOpcode != PARSEOP_NAMESEG)    &&
         (Op->Asl.ParseOpcode != PARSEOP_METHODCALL) &&
-        (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL)   &&
-        (OpInfo->Type != AML_TYPE_NAMED_FIELD))
+        (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL))
     {
         return_ACPI_STATUS (AE_OK);
     }
@@ -638,8 +639,7 @@ XfNamespaceLocateBegin (
     if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
         (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)    ||
         (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) ||
-        (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)   ||
-        (OpInfo->Type == AML_TYPE_NAMED_FIELD))
+        (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL))
     {
         /*
          * These are name references, do not push the scope stack
@@ -676,10 +676,6 @@ XfNamespaceLocateBegin (
 
         Path = NextOp->Asl.Value.String;
     }
-    else if (OpInfo->Type == AML_TYPE_NAMED_FIELD)
-    {
-        Path = Op->Asl.Child->Asl.Value.String;
-    }
     else
     {
         Path = Op->Asl.Value.String;
@@ -798,22 +794,43 @@ XfNamespaceLocateBegin (
         return_ACPI_STATUS (Status);
     }
 
-    /* Object was found above, check for an illegal forward reference */
+   /* 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
+         * illegal forward reference. In other words, Op is a name path or
+         * name segment that refers to a named object declared after the
+         * reference. In this scinario, Node refers to the actual declaration
+         * and Op is a parse node that references the named object.
          *
-         * Note: Allow "forward references" from within a method to an
-         * object that is not within any method (module-level code)
+         * Note:
+         *
+         * Object references inside of control methods are allowed to
+         * refer to objects declared outside of control methods.
+         *
+         * If the declaration and reference are both contained inside of the
+         * same method or outside of any method, this is a forward reference
+         * and should be reported as a compiler error.
          */
-        if (!WalkState->ScopeInfo || (UtGetParentMethod (Node) &&
-            !UtNodeIsDescendantOf (WalkState->ScopeInfo->Scope.Node,
-                UtGetParentMethod (Node))))
+        DeclarationParentMethod = UtGetParentMethod (Node);
+        ReferenceParentMethod = XfGetParentMethod (Op);
+
+        /* case 1: declaration and refrence are both outside of method */
+
+        if (!ReferenceParentMethod && !DeclarationParentMethod)
         {
             AslError (ASL_ERROR, ASL_MSG_ILLEGAL_FORWARD_REF, Op,
+                Op->Asl.ExternalName);
+        }
+
+        /* case 2: declaration and reference are both inside of the same method */
+
+        else if (ReferenceParentMethod && DeclarationParentMethod &&
+            ReferenceParentMethod == DeclarationParentMethod->Op)
+        {
+             AslError (ASL_ERROR, ASL_MSG_ILLEGAL_FORWARD_REF, Op,
                 Op->Asl.ExternalName);
         }
     }

Modified: vendor-sys/acpica/dist/source/components/events/evgpe.c
==============================================================================
--- vendor-sys/acpica/dist/source/components/events/evgpe.c	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/source/components/events/evgpe.c	Thu May  9 22:49:10 2019	(r347413)
@@ -240,14 +240,6 @@ AcpiEvEnableGpe (
     ACPI_FUNCTION_TRACE (EvEnableGpe);
 
 
-    /* Clear the GPE (of stale events) */
-
-    Status = AcpiHwClearGpe(GpeEventInfo);
-    if (ACPI_FAILURE(Status))
-    {
-        return_ACPI_STATUS(Status);
-    }
-
     /* Enable the requested GPE */
 
     Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_ENABLE);

Modified: vendor-sys/acpica/dist/source/include/acpixf.h
==============================================================================
--- vendor-sys/acpica/dist/source/include/acpixf.h	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/source/include/acpixf.h	Thu May  9 22:49:10 2019	(r347413)
@@ -154,7 +154,7 @@
 
 /* Current ACPICA subsystem version in YYYYMMDD format */
 
-#define ACPI_CA_VERSION                 0x20190405
+#define ACPI_CA_VERSION                 0x20190509
 
 #include "acconfig.h"
 #include "actypes.h"

Modified: vendor-sys/acpica/dist/source/include/platform/aclinux.h
==============================================================================
--- vendor-sys/acpica/dist/source/include/platform/aclinux.h	Thu May  9 22:42:23 2019	(r347412)
+++ vendor-sys/acpica/dist/source/include/platform/aclinux.h	Thu May  9 22:49:10 2019	(r347413)
@@ -205,6 +205,11 @@
 
 #define ACPI_INIT_FUNCTION __init
 
+/* Use a specific bugging default separate from ACPICA */
+
+#undef ACPI_DEBUG_DEFAULT
+#define ACPI_DEBUG_DEFAULT          (ACPI_LV_INFO | ACPI_LV_REPAIR)
+
 #ifndef CONFIG_ACPI
 
 /* External globals for __KERNEL__, stubs is needed */
@@ -220,11 +225,6 @@
 
 #define ACPI_NO_ERROR_MESSAGES
 #undef ACPI_DEBUG_OUTPUT
-
-/* Use a specific bugging default separate from ACPICA */
-
-#undef ACPI_DEBUG_DEFAULT
-#define ACPI_DEBUG_DEFAULT          (ACPI_LV_INFO | ACPI_LV_REPAIR)
 
 /* External interface for __KERNEL__, stub is needed */
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905092249.x49MnA5u020899>