Message ID | 20200430165837.165447-1-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series | ACPICA: Update to version 20200430 | expand |
On 2020-04-30 10:58 a.m., Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > Changes in this release of ACPICA are detailed at the following > link on the ACPICA developer mailing list: > > https://lists.acpica.org/hyperkitty/list/devel@acpica.org/thread/TJTJBDAV2LZYAYNIL3EQMJBGDTPJW4PM/ > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/acpica/source/common/acgetline.c | 2 - > src/acpica/source/common/dmtbdump2.c | 4 +- > src/acpica/source/compiler/aslcompiler.l | 2 +- > src/acpica/source/compiler/aslload.c | 81 ++++----- > src/acpica/source/compiler/aslmessages.c | 1 + > src/acpica/source/compiler/aslmessages.h | 1 + > src/acpica/source/compiler/aslpredef.c | 2 +- > src/acpica/source/compiler/aslxref.c | 165 ++++++++++++++++-- > src/acpica/source/compiler/dtutils.c | 11 +- > .../source/components/debugger/dbhistry.c | 1 - > .../source/components/disassembler/dmbuffer.c | 19 +- > .../source/components/dispatcher/dsfield.c | 24 ++- > .../source/components/executer/exfield.c | 2 +- > src/acpica/source/include/acglobal.h | 1 + > src/acpica/source/include/acpixf.h | 2 +- > src/acpica/source/include/acpredef.h | 4 +- > 16 files changed, 249 insertions(+), 73 deletions(-) > > diff --git a/src/acpica/source/common/acgetline.c b/src/acpica/source/common/acgetline.c > index cf9d779a..e1ddaa69 100644 > --- a/src/acpica/source/common/acgetline.c > +++ b/src/acpica/source/common/acgetline.c > @@ -189,8 +189,6 @@ AcpiAcClearLine ( > #define _ASCII_LEFT_ARROW 'D' > #define _ASCII_NEWLINE '\n' > > -extern UINT32 AcpiGbl_NextCmdNum; > - > /* Erase a single character on the input command line */ > > #define ACPI_CLEAR_CHAR() \ > diff --git a/src/acpica/source/common/dmtbdump2.c b/src/acpica/source/common/dmtbdump2.c > index 688a2cf9..45484825 100644 > --- a/src/acpica/source/common/dmtbdump2.c > +++ b/src/acpica/source/common/dmtbdump2.c > @@ -528,8 +528,10 @@ AcpiDmDumpIvrs ( > DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, Subtable, > sizeof (ACPI_IVRS_HARDWARE1)); > } > - else if (Subtable->Type == ACPI_IVRS_TYPE_HARDWARE2) > + else > { > + /* ACPI_IVRS_TYPE_HARDWARE2 subtable type */ > + > EntryOffset = Offset + sizeof (ACPI_IVRS_HARDWARE2); > DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, Subtable, > sizeof (ACPI_IVRS_HARDWARE2)); > diff --git a/src/acpica/source/compiler/aslcompiler.l b/src/acpica/source/compiler/aslcompiler.l > index 4c3fbde3..c12eb90b 100644 > --- a/src/acpica/source/compiler/aslcompiler.l > +++ b/src/acpica/source/compiler/aslcompiler.l > @@ -819,7 +819,7 @@ NamePathTail [.]{NameSeg} > } > > /* > - * The eror code is contained inside the > + * The error code is contained inside the > * {ErrorCode} pattern. Extract it and log it > * as the expected error code. > */ > diff --git a/src/acpica/source/compiler/aslload.c b/src/acpica/source/compiler/aslload.c > index bd2fc977..bdc0d805 100644 > --- a/src/acpica/source/compiler/aslload.c > +++ b/src/acpica/source/compiler/aslload.c > @@ -1,6 +1,6 @@ > /****************************************************************************** > * > - * Module Name: dswload - Dispatcher namespace load callbacks > + * Module Name: aslload - compiler namespace load callbacks > * > *****************************************************************************/ > > @@ -201,7 +201,6 @@ LdAnalyzeExternals ( > ACPI_NAMESPACE_NODE *Node, > ACPI_PARSE_OBJECT *Op, > ACPI_OBJECT_TYPE ExternalOpType, > - ACPI_OBJECT_TYPE ObjectType, > ACPI_WALK_STATE *WalkState); > > > @@ -515,7 +514,6 @@ LdNamespace1Begin ( > ACPI_PARSE_OBJECT *MethodOp; > ACPI_STATUS Status; > ACPI_OBJECT_TYPE ObjectType; > - ACPI_OBJECT_TYPE ActualObjectType = ACPI_TYPE_ANY; > char *Path; > UINT32 Flags = ACPI_NS_NO_UPSEARCH; > ACPI_PARSE_OBJECT *Arg; > @@ -689,8 +687,7 @@ LdNamespace1Begin ( > * > * first child is name, next child is ObjectType > */ > - ActualObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer; > - ObjectType = ACPI_TYPE_ANY; > + ObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer; > > /* > * We will mark every new node along the path as "External". This > @@ -709,7 +706,7 @@ LdNamespace1Begin ( > * Store (\_SB_.PCI0.ABCD, Local0) > * } > */ > - Flags |= ACPI_NS_EXTERNAL; > + Flags |= ACPI_NS_EXTERNAL | ACPI_NS_DONT_OPEN_SCOPE; > break; > > case PARSEOP_DEFAULT_ARG: > @@ -913,8 +910,7 @@ LdNamespace1Begin ( > else if ((Node->Flags & ANOBJ_IS_EXTERNAL) || > (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) > { > - Status = LdAnalyzeExternals (Node, Op, ActualObjectType, > - ObjectType, WalkState); > + Status = LdAnalyzeExternals (Node, Op, ObjectType, WalkState); > if (ACPI_FAILURE (Status)) > { > if (Status == AE_ERROR) > @@ -929,6 +925,19 @@ LdNamespace1Begin ( > } > return_ACPI_STATUS (Status); > } > + > + if (!(Node->Flags & ANOBJ_IS_EXTERNAL) && > + (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) > + { > + /* > + * If we get to here, it means that an actual definition of > + * the object declared external exists. Meaning that Op > + * loading this this Op should have no change to the ACPI > + * namespace. By going to FinishNode, we skip the > + * assignment of Node->Op = Op. > + */ > + goto FinishNode; > + } > } > else > { > @@ -980,30 +989,15 @@ LdNamespace1Begin ( > } > } > > -FinishNode: > - /* > - * Point the parse node to the new namespace node, and point > - * the Node back to the original Parse node > - */ > - Op->Asl.Node = Node; > + /* Point the Node back to the original Parse node */ > + > Node->Op = Op; > > - /* > - * Set the actual data type if appropriate (EXTERNAL term only) > - * As of 11/19/2019, ASL External() does not support parameter > - * counts. When an External method is loaded, the parameter count is > - * recorded in the external's arg count parameter. The parameter count may > - * or may not be known in the declaration. If the value of this node turns > - * out to be ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS, it indicates that > - * we do not know the parameter count and that we must look at the usage of > - * the External method call to get this information. > - */ > - if (ActualObjectType != ACPI_TYPE_ANY) > - { > - Node->Type = (UINT8) ActualObjectType; > - Node->Value = (UINT32) > - Op->Asl.Child->Asl.Next->Asl.Next->Asl.Value.Integer; > - } > +FinishNode: > + > + /* Point the parse node to the new namespace node */ > + > + Op->Asl.Node = Node; > > if (Op->Asl.ParseOpcode == PARSEOP_METHOD) > { > @@ -1013,6 +1007,13 @@ FinishNode: > */ > Node->Value = (UINT32) Op->Asl.Extra; > } > + else if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL && > + Node->Type == ACPI_TYPE_METHOD && > + (Node->Flags & ANOBJ_IS_EXTERNAL)) > + { > + Node->Value = > + (UINT32) Op->Asl.Child->Asl.Next->Asl.Next->Asl.Value.Integer; > + } > > return_ACPI_STATUS (Status); > } > @@ -1020,7 +1021,7 @@ FinishNode: > > /******************************************************************************* > * > - * FUNCTION: LdAnalyzeExternals > + * FUNCTION: LdMatchExternType > * > * PARAMETERS: Type1 > * Type2 > @@ -1037,7 +1038,7 @@ FinishNode: > ******************************************************************************/ > > static BOOLEAN > -LdTypesMatchExternType ( > +LdMatchExternType ( > ACPI_OBJECT_TYPE Type1, > ACPI_OBJECT_TYPE Type2) > { > @@ -1093,7 +1094,6 @@ LdTypesMatchExternType ( > * PARAMETERS: Node - Node that represents the named object > * Op - Named object declaring this named object > * ExternalOpType - Type of ExternalOp > - * ObjectType - Type of Declared object > * WalkState - Current WalkState > * > * RETURN: Status > @@ -1111,7 +1111,6 @@ LdAnalyzeExternals ( > ACPI_NAMESPACE_NODE *Node, > ACPI_PARSE_OBJECT *Op, > ACPI_OBJECT_TYPE ExternalOpType, > - ACPI_OBJECT_TYPE ObjectType, > ACPI_WALK_STATE *WalkState) > { > ACPI_STATUS Status = AE_OK; > @@ -1135,12 +1134,12 @@ LdAnalyzeExternals ( > else > { > ActualExternalOpType = Node->Type; > - ActualOpType = ObjectType; > + ActualOpType = ExternalOpType; > } > > if ((ActualOpType != ACPI_TYPE_ANY) && > (ActualExternalOpType != ACPI_TYPE_ANY) && > - !LdTypesMatchExternType (ActualExternalOpType, ActualOpType)) > + !LdMatchExternType (ActualExternalOpType, ActualOpType)) > { > if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL && > Node->Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) > @@ -1168,6 +1167,8 @@ LdAnalyzeExternals ( > } > } > > + /* Set the object type of the external */ > + > if ((Node->Flags & ANOBJ_IS_EXTERNAL) && > (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL)) > { > @@ -1176,13 +1177,13 @@ LdAnalyzeExternals ( > * previously declared External > */ > Node->Flags &= ~ANOBJ_IS_EXTERNAL; > - Node->Type = (UINT8) ObjectType; > + Node->Type = (UINT8) ExternalOpType; > > /* Just retyped a node, probably will need to open a scope */ > > - if (AcpiNsOpensScope (ObjectType)) > + if (AcpiNsOpensScope (ExternalOpType)) > { > - Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); > + Status = AcpiDsScopeStackPush (Node, ExternalOpType, WalkState); > if (ACPI_FAILURE (Status)) > { > return (Status); > @@ -1203,7 +1204,7 @@ LdAnalyzeExternals ( > } > else if ((Node->Flags & ANOBJ_IS_EXTERNAL) && > (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) && > - (ObjectType == ACPI_TYPE_ANY)) > + (ExternalOpType == ACPI_TYPE_ANY)) > { > /* Allow update of externals of unknown type. */ > > diff --git a/src/acpica/source/compiler/aslmessages.c b/src/acpica/source/compiler/aslmessages.c > index 81280b28..eb344940 100644 > --- a/src/acpica/source/compiler/aslmessages.c > +++ b/src/acpica/source/compiler/aslmessages.c > @@ -380,6 +380,7 @@ const char *AslCompilerMsgs [] = > /* ASL_MSG_TYPE_MISMATCH_FOUND_HERE */ "Actual object declaration:", > /* ASL_MSG_DUPLICATE_EXTERN_MISMATCH */ "Type mismatch between multiple external declarations detected", > /* ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE */"Duplicate external declaration:", > +/* ASL_MSG_CONDREF_NEEDS_EXTERNAL_DECL */"CondRefOf parameter requires External() declaration", > }; > > /* Table compiler */ > diff --git a/src/acpica/source/compiler/aslmessages.h b/src/acpica/source/compiler/aslmessages.h > index 6d5ffd4d..9a7215c6 100644 > --- a/src/acpica/source/compiler/aslmessages.h > +++ b/src/acpica/source/compiler/aslmessages.h > @@ -382,6 +382,7 @@ typedef enum > ASL_MSG_TYPE_MISMATCH_FOUND_HERE, > ASL_MSG_DUPLICATE_EXTERN_MISMATCH, > ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE, > + ASL_MSG_CONDREF_NEEDS_EXTERNAL_DECL, > > > /* These messages are used by the Data Table compiler only */ > diff --git a/src/acpica/source/compiler/aslpredef.c b/src/acpica/source/compiler/aslpredef.c > index afef94a0..1ee4fd49 100644 > --- a/src/acpica/source/compiler/aslpredef.c > +++ b/src/acpica/source/compiler/aslpredef.c > @@ -674,7 +674,7 @@ ApCheckForSpecialName ( > /* > * Was not actually emitted by the compiler. This is a special case, > * however. If the ASL code being compiled was the result of a > - * dissasembly, it may possibly contain valid compiler-emitted names > + * disassembly, it may possibly contain valid compiler-emitted names > * of the form "_T_x". We don't want to issue an error or even a > * warning and force the user to manually change the names. So, we > * will issue a remark instead. > diff --git a/src/acpica/source/compiler/aslxref.c b/src/acpica/source/compiler/aslxref.c > index 38356aa2..0df33e31 100644 > --- a/src/acpica/source/compiler/aslxref.c > +++ b/src/acpica/source/compiler/aslxref.c > @@ -199,6 +199,16 @@ XfCheckFieldRange ( > UINT32 FieldBitLength, > UINT32 AccessBitWidth); > > +static BOOLEAN > +XfFindCondRefOfName ( > + ACPI_NAMESPACE_NODE *Node, > + ACPI_PARSE_OBJECT *Op); > + > +static BOOLEAN > +XfRefIsGuardedByIfCondRefOf ( > + ACPI_NAMESPACE_NODE *Node, > + ACPI_PARSE_OBJECT *Op); > + > > /******************************************************************************* > * > @@ -581,17 +591,6 @@ XfNamespaceLocateBegin ( > return_ACPI_STATUS (AE_OK); > } > > - /* > - * One special case: CondRefOf operator - we don't care if the name exists > - * or not at this point, just ignore it, the point of the operator is to > - * determine if the name exists at runtime. > - */ > - if ((Op->Asl.Parent) && > - (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) > - { > - return_ACPI_STATUS (AE_OK); > - } > - > /* > * We must enable the "search-to-root" for single NameSegs, but > * we have to be very careful about opening up scopes > @@ -600,7 +599,8 @@ XfNamespaceLocateBegin ( > if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || > (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || > (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) || > - (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) > + (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) || > + (Op->Asl.ParseOpcode == PARSEOP_CONDREFOF)) > { > /* > * These are name references, do not push the scope stack > @@ -665,7 +665,22 @@ XfNamespaceLocateBegin ( > * We didn't find the name reference by path -- we can qualify this > * a little better before we print an error message > */ > - if (strlen (Path) == ACPI_NAMESEG_SIZE) > + > + if ((Op->Asl.Parent) && > + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) > + { > + /* > + * One special case: CondRefOf operator - if the name doesn't > + * exist at this point, it means that there's no actual or > + * external declaration. If the name is not found, just ignore > + * it, the point of the operator is to determine if the name > + * exists at runtime. We wanted to see if this named object > + * exists to facilitate analysis to allow protected usage of > + * undeclared externals. > + */ > + return_ACPI_STATUS (AE_OK); > + } > + else if (strlen (Path) == ACPI_NAMESEG_SIZE) > { > /* A simple, one-segment ACPI name */ > > @@ -1190,6 +1205,7 @@ XfNamespaceLocateBegin ( > > /* > * 5) Check for external resolution > + * > * By this point, everything should be loaded in the namespace. If a > * namespace lookup results in a namespace node that is an external, it > * means that this named object was not defined in the input ASL. This > @@ -1197,11 +1213,38 @@ XfNamespaceLocateBegin ( > * use the external keyword to suppress compiler errors about undefined > * objects. Note: this only applies when compiling multiple definition > * blocks. > + * > + * Do not check for external resolution in the following cases: > + * > + * case 1) External (ABCD) > + * > + * This declares ABCD as an external so there is no requirement for > + * ABCD to be loaded in the namespace when analyzing the actual > + * External() statement. > + * > + * case 2) CondRefOf (ABCD) > + * > + * This operator will query the ACPI namespace on the existence of > + * ABCD. If ABCD does not exist, this operator will return a 0 > + * without incurring AML runtime errors. Therefore, ABCD is allowed > + * to not exist when analyzing the CondRefOf operator. > + * > + * case 3) External (ABCD) > + * if (CondRefOf (ABCD)) > + * { > + * Store (0, ABCD) > + * } > + * > + * In this case, ABCD is accessed only if it exists due to the if > + * statement so there is no need to flag the ABCD nested in the > + * store operator. > */ > if (AslGbl_ParseTreeRoot->Asl.Child && AslGbl_ParseTreeRoot->Asl.Child->Asl.Next && > - (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL && > - Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL) && > - (Node->Flags & ANOBJ_IS_EXTERNAL)) > + (Node->Flags & ANOBJ_IS_EXTERNAL) && > + Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL && > + Op->Asl.ParseOpcode != PARSEOP_EXTERNAL && > + Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_CONDREFOF && > + !XfRefIsGuardedByIfCondRefOf (Node, Op)) > { > AslError (ASL_ERROR, ASL_MSG_UNDEFINED_EXTERNAL, Op, NULL); > } > @@ -1219,6 +1262,96 @@ XfNamespaceLocateBegin ( > } > > > +/******************************************************************************* > + * > + * FUNCTION: XfRefIsGuardedByIfCondRefOf > + * > + * PARAMETERS: Node - Named object reference node > + * Op - Named object reference parse node > + * > + * RETURN: BOOLEAN > + * > + * DESCRIPTION: returns true if Op checked inside if (CondRefOf (...)) > + * refers to Node. > + * > + ******************************************************************************/ > + > +static BOOLEAN > +XfRefIsGuardedByIfCondRefOf ( > + ACPI_NAMESPACE_NODE *Node, > + ACPI_PARSE_OBJECT *Op) > +{ > + ACPI_PARSE_OBJECT *Parent = Op->Asl.Parent; > + > + > + while (Parent) > + { > + if (Parent->Asl.ParseOpcode == PARSEOP_IF && > + XfFindCondRefOfName (Node, Parent->Asl.Child)) > + { > + return (TRUE); > + } > + > + Parent = Parent->Asl.Parent; > + } > + > + return (FALSE); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: XfRefIsGuardedByIfCondRefOf > + * > + * PARAMETERS: Node - Named object reference node > + * Op - Named object reference parse node > + * > + * RETURN: BOOLEAN > + * > + * DESCRIPTION: returns true if Op checked inside if (CondRefOf (...)) > + * refers to Node. > + * > + ******************************************************************************/ > + > +static BOOLEAN > +XfFindCondRefOfName ( > + ACPI_NAMESPACE_NODE *Node, > + ACPI_PARSE_OBJECT *Op) > +{ > + BOOLEAN CondRefOfFound = FALSE; > + > + > + if (!Op) > + { > + return (FALSE); > + } > + > + switch (Op->Asl.ParseOpcode) > + { > + case PARSEOP_CONDREFOF: > + > + return (Op->Asl.Child->Common.Node == Node); > + break; > + > + case PARSEOP_LAND: > + > + CondRefOfFound = XfFindCondRefOfName (Node, Op->Asl.Child); > + if (CondRefOfFound) > + { > + return (TRUE); > + } > + > + return (XfFindCondRefOfName (Node, Op->Asl.Child->Asl.Next)); > + break; > + > + default: > + > + return (FALSE); > + break; > + } > +} > + > + > /******************************************************************************* > * > * FUNCTION: XfNamespaceLocateEnd > diff --git a/src/acpica/source/compiler/dtutils.c b/src/acpica/source/compiler/dtutils.c > index bb07894e..55093a76 100644 > --- a/src/acpica/source/compiler/dtutils.c > +++ b/src/acpica/source/compiler/dtutils.c > @@ -186,11 +186,20 @@ DtError ( > DT_FIELD *FieldObject, > char *ExtraMessage) > { > + UINT32 Line = 0; > + > + > + /* Field object could be NULL */ > + > + if (FieldObject) > + { > + Line = FieldObject->Line; > + } > > /* Check if user wants to ignore this exception */ > > if (AslIsExceptionIgnored (AslGbl_Files[ASL_FILE_INPUT].Filename, > - FieldObject->Line, Level, MessageId)) > + Line, Level, MessageId)) > { > return; > } > diff --git a/src/acpica/source/components/debugger/dbhistry.c b/src/acpica/source/components/debugger/dbhistry.c > index 554115bf..b9b2ed87 100644 > --- a/src/acpica/source/components/debugger/dbhistry.c > +++ b/src/acpica/source/components/debugger/dbhistry.c > @@ -175,7 +175,6 @@ static HISTORY_INFO AcpiGbl_HistoryBuffer[HISTORY_SIZE]; > static UINT16 AcpiGbl_LoHistory = 0; > static UINT16 AcpiGbl_NumHistory = 0; > static UINT16 AcpiGbl_NextHistoryIndex = 0; > -UINT32 AcpiGbl_NextCmdNum = 1; > > > /******************************************************************************* > diff --git a/src/acpica/source/components/disassembler/dmbuffer.c b/src/acpica/source/components/disassembler/dmbuffer.c > index 1d734d4f..47279a2c 100644 > --- a/src/acpica/source/components/disassembler/dmbuffer.c > +++ b/src/acpica/source/components/disassembler/dmbuffer.c > @@ -400,6 +400,10 @@ AcpiDmIsUuidBuffer ( > /* Buffer size is the buffer argument */ > > SizeOp = Op->Common.Value.Arg; > + if (!SizeOp) > + { > + return (FALSE); > + } > > /* Next, the initializer byte list to examine */ > > @@ -520,6 +524,10 @@ AcpiDmIsUnicodeBuffer ( > /* Buffer size is the buffer argument */ > > SizeOp = Op->Common.Value.Arg; > + if (!SizeOp) > + { > + return (FALSE); > + } > > /* Next, the initializer byte list to examine */ > > @@ -596,6 +604,10 @@ AcpiDmIsStringBuffer ( > /* Buffer size is the buffer argument */ > > SizeOp = Op->Common.Value.Arg; > + if (!SizeOp) > + { > + return (FALSE); > + } > > /* Next, the initializer byte list to examine */ > > @@ -675,13 +687,18 @@ AcpiDmIsPldBuffer ( > UINT64 InitializerSize; > > > + if (!Op) > + { > + return (FALSE); > + } > + > /* > * Get the BufferSize argument - Buffer(BufferSize) > * If the buffer was generated by the ToPld macro, it must > * be a BYTE constant. > */ > SizeOp = Op->Common.Value.Arg; > - if (SizeOp->Common.AmlOpcode != AML_BYTE_OP) > + if (!SizeOp || SizeOp->Common.AmlOpcode != AML_BYTE_OP) > { > return (FALSE); > } > diff --git a/src/acpica/source/components/dispatcher/dsfield.c b/src/acpica/source/components/dispatcher/dsfield.c > index e2576606..f4199078 100644 > --- a/src/acpica/source/components/dispatcher/dsfield.c > +++ b/src/acpica/source/components/dispatcher/dsfield.c > @@ -341,7 +341,12 @@ AcpiDsCreateBufferField ( > Status = AcpiNsLookup (WalkState->ScopeInfo, > Arg->Common.Value.String, ACPI_TYPE_ANY, > ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); > - if (ACPI_FAILURE (Status)) > + if ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) && > + Status == AE_ALREADY_EXISTS) > + { > + Status = AE_OK; > + } > + else if (ACPI_FAILURE (Status)) > { > ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, > Arg->Common.Value.String, Status); > @@ -682,12 +687,21 @@ AcpiDsCreateField ( > Info.RegionNode = RegionNode; > > Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); > - if (Info.RegionNode->Object->Region.SpaceId == ACPI_ADR_SPACE_PLATFORM_COMM && > - !(RegionNode->Object->Field.InternalPccBuffer > - = ACPI_ALLOCATE_ZEROED(Info.RegionNode->Object->Region.Length))) > + if (ACPI_FAILURE (Status)) > { > - return_ACPI_STATUS (AE_NO_MEMORY); > + return_ACPI_STATUS (Status); > } > + > + if (Info.RegionNode->Object->Region.SpaceId == ACPI_ADR_SPACE_PLATFORM_COMM) > + { > + RegionNode->Object->Field.InternalPccBuffer = > + ACPI_ALLOCATE_ZEROED(Info.RegionNode->Object->Region.Length); > + if (!RegionNode->Object->Field.InternalPccBuffer) > + { > + return_ACPI_STATUS (AE_NO_MEMORY); > + } > + } > + > return_ACPI_STATUS (Status); > } > > diff --git a/src/acpica/source/components/executer/exfield.c b/src/acpica/source/components/executer/exfield.c > index 167d182c..897c2d47 100644 > --- a/src/acpica/source/components/executer/exfield.c > +++ b/src/acpica/source/components/executer/exfield.c > @@ -167,7 +167,7 @@ > #define ACPI_INVALID_PROTOCOL_ID 0x80 > #define ACPI_MAX_PROTOCOL_ID 0x0F > > -const UINT8 AcpiProtocolLengths[] = > +static const UINT8 AcpiProtocolLengths[] = > { > ACPI_INVALID_PROTOCOL_ID, /* 0 - reserved */ > ACPI_INVALID_PROTOCOL_ID, /* 1 - reserved */ > diff --git a/src/acpica/source/include/acglobal.h b/src/acpica/source/include/acglobal.h > index d41f24c8..a45ece02 100644 > --- a/src/acpica/source/include/acglobal.h > +++ b/src/acpica/source/include/acglobal.h > @@ -436,6 +436,7 @@ ACPI_GLOBAL (ACPI_EXTERNAL_FILE *, AcpiGbl_ExternalFileList); > #ifdef ACPI_DEBUGGER > ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_AbortMethod, FALSE); > ACPI_INIT_GLOBAL (ACPI_THREAD_ID, AcpiGbl_DbThreadId, ACPI_INVALID_THREAD_ID); > +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_NextCmdNum, 1); > > ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_NoIniMethods); > ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_NoRegionSupport); > diff --git a/src/acpica/source/include/acpixf.h b/src/acpica/source/include/acpixf.h > index eeb63cd5..ed280425 100644 > --- a/src/acpica/source/include/acpixf.h > +++ b/src/acpica/source/include/acpixf.h > @@ -154,7 +154,7 @@ > > /* Current ACPICA subsystem version in YYYYMMDD format */ > > -#define ACPI_CA_VERSION 0x20200326 > +#define ACPI_CA_VERSION 0x20200430 > > #include "acconfig.h" > #include "actypes.h" > diff --git a/src/acpica/source/include/acpredef.h b/src/acpica/source/include/acpredef.h > index 99c48b06..924d7b90 100644 > --- a/src/acpica/source/include/acpredef.h > +++ b/src/acpica/source/include/acpredef.h > @@ -769,10 +769,10 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] = > {{"_NIC", METHOD_0ARGS, /* ACPI 6.3 */ > METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, > > - {{"_NIG", METHOD_1ARGS (ACPI_TYPE_BUFFER), /* ACPI 6.3 */ > + {{"_NIG", METHOD_0ARGS, /* ACPI 6.3 */ > METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, > > - {{"_NIH", METHOD_0ARGS, /* ACPI 6.3 */ > + {{"_NIH", METHOD_1ARGS (ACPI_TYPE_BUFFER), /* ACPI 6.3 */ > METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, > > {{"_NTT", METHOD_0ARGS, > Acked-by: Alex Hung <alex.hung@canonical.com>
On 5/1/20 12:58 AM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > Changes in this release of ACPICA are detailed at the following > link on the ACPICA developer mailing list: > > https://lists.acpica.org/hyperkitty/list/devel@acpica.org/thread/TJTJBDAV2LZYAYNIL3EQMJBGDTPJW4PM/ > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/acpica/source/common/acgetline.c | 2 - > src/acpica/source/common/dmtbdump2.c | 4 +- > src/acpica/source/compiler/aslcompiler.l | 2 +- > src/acpica/source/compiler/aslload.c | 81 ++++----- > src/acpica/source/compiler/aslmessages.c | 1 + > src/acpica/source/compiler/aslmessages.h | 1 + > src/acpica/source/compiler/aslpredef.c | 2 +- > src/acpica/source/compiler/aslxref.c | 165 ++++++++++++++++-- > src/acpica/source/compiler/dtutils.c | 11 +- > .../source/components/debugger/dbhistry.c | 1 - > .../source/components/disassembler/dmbuffer.c | 19 +- > .../source/components/dispatcher/dsfield.c | 24 ++- > .../source/components/executer/exfield.c | 2 +- > src/acpica/source/include/acglobal.h | 1 + > src/acpica/source/include/acpixf.h | 2 +- > src/acpica/source/include/acpredef.h | 4 +- > 16 files changed, 249 insertions(+), 73 deletions(-) > > diff --git a/src/acpica/source/common/acgetline.c b/src/acpica/source/common/acgetline.c > index cf9d779a..e1ddaa69 100644 > --- a/src/acpica/source/common/acgetline.c > +++ b/src/acpica/source/common/acgetline.c > @@ -189,8 +189,6 @@ AcpiAcClearLine ( > #define _ASCII_LEFT_ARROW 'D' > #define _ASCII_NEWLINE '\n' > > -extern UINT32 AcpiGbl_NextCmdNum; > - > /* Erase a single character on the input command line */ > > #define ACPI_CLEAR_CHAR() \ > diff --git a/src/acpica/source/common/dmtbdump2.c b/src/acpica/source/common/dmtbdump2.c > index 688a2cf9..45484825 100644 > --- a/src/acpica/source/common/dmtbdump2.c > +++ b/src/acpica/source/common/dmtbdump2.c > @@ -528,8 +528,10 @@ AcpiDmDumpIvrs ( > DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, Subtable, > sizeof (ACPI_IVRS_HARDWARE1)); > } > - else if (Subtable->Type == ACPI_IVRS_TYPE_HARDWARE2) > + else > { > + /* ACPI_IVRS_TYPE_HARDWARE2 subtable type */ > + > EntryOffset = Offset + sizeof (ACPI_IVRS_HARDWARE2); > DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, Subtable, > sizeof (ACPI_IVRS_HARDWARE2)); > diff --git a/src/acpica/source/compiler/aslcompiler.l b/src/acpica/source/compiler/aslcompiler.l > index 4c3fbde3..c12eb90b 100644 > --- a/src/acpica/source/compiler/aslcompiler.l > +++ b/src/acpica/source/compiler/aslcompiler.l > @@ -819,7 +819,7 @@ NamePathTail [.]{NameSeg} > } > > /* > - * The eror code is contained inside the > + * The error code is contained inside the > * {ErrorCode} pattern. Extract it and log it > * as the expected error code. > */ > diff --git a/src/acpica/source/compiler/aslload.c b/src/acpica/source/compiler/aslload.c > index bd2fc977..bdc0d805 100644 > --- a/src/acpica/source/compiler/aslload.c > +++ b/src/acpica/source/compiler/aslload.c > @@ -1,6 +1,6 @@ > /****************************************************************************** > * > - * Module Name: dswload - Dispatcher namespace load callbacks > + * Module Name: aslload - compiler namespace load callbacks > * > *****************************************************************************/ > > @@ -201,7 +201,6 @@ LdAnalyzeExternals ( > ACPI_NAMESPACE_NODE *Node, > ACPI_PARSE_OBJECT *Op, > ACPI_OBJECT_TYPE ExternalOpType, > - ACPI_OBJECT_TYPE ObjectType, > ACPI_WALK_STATE *WalkState); > > > @@ -515,7 +514,6 @@ LdNamespace1Begin ( > ACPI_PARSE_OBJECT *MethodOp; > ACPI_STATUS Status; > ACPI_OBJECT_TYPE ObjectType; > - ACPI_OBJECT_TYPE ActualObjectType = ACPI_TYPE_ANY; > char *Path; > UINT32 Flags = ACPI_NS_NO_UPSEARCH; > ACPI_PARSE_OBJECT *Arg; > @@ -689,8 +687,7 @@ LdNamespace1Begin ( > * > * first child is name, next child is ObjectType > */ > - ActualObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer; > - ObjectType = ACPI_TYPE_ANY; > + ObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer; > > /* > * We will mark every new node along the path as "External". This > @@ -709,7 +706,7 @@ LdNamespace1Begin ( > * Store (\_SB_.PCI0.ABCD, Local0) > * } > */ > - Flags |= ACPI_NS_EXTERNAL; > + Flags |= ACPI_NS_EXTERNAL | ACPI_NS_DONT_OPEN_SCOPE; > break; > > case PARSEOP_DEFAULT_ARG: > @@ -913,8 +910,7 @@ LdNamespace1Begin ( > else if ((Node->Flags & ANOBJ_IS_EXTERNAL) || > (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) > { > - Status = LdAnalyzeExternals (Node, Op, ActualObjectType, > - ObjectType, WalkState); > + Status = LdAnalyzeExternals (Node, Op, ObjectType, WalkState); > if (ACPI_FAILURE (Status)) > { > if (Status == AE_ERROR) > @@ -929,6 +925,19 @@ LdNamespace1Begin ( > } > return_ACPI_STATUS (Status); > } > + > + if (!(Node->Flags & ANOBJ_IS_EXTERNAL) && > + (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) > + { > + /* > + * If we get to here, it means that an actual definition of > + * the object declared external exists. Meaning that Op > + * loading this this Op should have no change to the ACPI > + * namespace. By going to FinishNode, we skip the > + * assignment of Node->Op = Op. > + */ > + goto FinishNode; > + } > } > else > { > @@ -980,30 +989,15 @@ LdNamespace1Begin ( > } > } > > -FinishNode: > - /* > - * Point the parse node to the new namespace node, and point > - * the Node back to the original Parse node > - */ > - Op->Asl.Node = Node; > + /* Point the Node back to the original Parse node */ > + > Node->Op = Op; > > - /* > - * Set the actual data type if appropriate (EXTERNAL term only) > - * As of 11/19/2019, ASL External() does not support parameter > - * counts. When an External method is loaded, the parameter count is > - * recorded in the external's arg count parameter. The parameter count may > - * or may not be known in the declaration. If the value of this node turns > - * out to be ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS, it indicates that > - * we do not know the parameter count and that we must look at the usage of > - * the External method call to get this information. > - */ > - if (ActualObjectType != ACPI_TYPE_ANY) > - { > - Node->Type = (UINT8) ActualObjectType; > - Node->Value = (UINT32) > - Op->Asl.Child->Asl.Next->Asl.Next->Asl.Value.Integer; > - } > +FinishNode: > + > + /* Point the parse node to the new namespace node */ > + > + Op->Asl.Node = Node; > > if (Op->Asl.ParseOpcode == PARSEOP_METHOD) > { > @@ -1013,6 +1007,13 @@ FinishNode: > */ > Node->Value = (UINT32) Op->Asl.Extra; > } > + else if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL && > + Node->Type == ACPI_TYPE_METHOD && > + (Node->Flags & ANOBJ_IS_EXTERNAL)) > + { > + Node->Value = > + (UINT32) Op->Asl.Child->Asl.Next->Asl.Next->Asl.Value.Integer; > + } > > return_ACPI_STATUS (Status); > } > @@ -1020,7 +1021,7 @@ FinishNode: > > /******************************************************************************* > * > - * FUNCTION: LdAnalyzeExternals > + * FUNCTION: LdMatchExternType > * > * PARAMETERS: Type1 > * Type2 > @@ -1037,7 +1038,7 @@ FinishNode: > ******************************************************************************/ > > static BOOLEAN > -LdTypesMatchExternType ( > +LdMatchExternType ( > ACPI_OBJECT_TYPE Type1, > ACPI_OBJECT_TYPE Type2) > { > @@ -1093,7 +1094,6 @@ LdTypesMatchExternType ( > * PARAMETERS: Node - Node that represents the named object > * Op - Named object declaring this named object > * ExternalOpType - Type of ExternalOp > - * ObjectType - Type of Declared object > * WalkState - Current WalkState > * > * RETURN: Status > @@ -1111,7 +1111,6 @@ LdAnalyzeExternals ( > ACPI_NAMESPACE_NODE *Node, > ACPI_PARSE_OBJECT *Op, > ACPI_OBJECT_TYPE ExternalOpType, > - ACPI_OBJECT_TYPE ObjectType, > ACPI_WALK_STATE *WalkState) > { > ACPI_STATUS Status = AE_OK; > @@ -1135,12 +1134,12 @@ LdAnalyzeExternals ( > else > { > ActualExternalOpType = Node->Type; > - ActualOpType = ObjectType; > + ActualOpType = ExternalOpType; > } > > if ((ActualOpType != ACPI_TYPE_ANY) && > (ActualExternalOpType != ACPI_TYPE_ANY) && > - !LdTypesMatchExternType (ActualExternalOpType, ActualOpType)) > + !LdMatchExternType (ActualExternalOpType, ActualOpType)) > { > if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL && > Node->Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) > @@ -1168,6 +1167,8 @@ LdAnalyzeExternals ( > } > } > > + /* Set the object type of the external */ > + > if ((Node->Flags & ANOBJ_IS_EXTERNAL) && > (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL)) > { > @@ -1176,13 +1177,13 @@ LdAnalyzeExternals ( > * previously declared External > */ > Node->Flags &= ~ANOBJ_IS_EXTERNAL; > - Node->Type = (UINT8) ObjectType; > + Node->Type = (UINT8) ExternalOpType; > > /* Just retyped a node, probably will need to open a scope */ > > - if (AcpiNsOpensScope (ObjectType)) > + if (AcpiNsOpensScope (ExternalOpType)) > { > - Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); > + Status = AcpiDsScopeStackPush (Node, ExternalOpType, WalkState); > if (ACPI_FAILURE (Status)) > { > return (Status); > @@ -1203,7 +1204,7 @@ LdAnalyzeExternals ( > } > else if ((Node->Flags & ANOBJ_IS_EXTERNAL) && > (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) && > - (ObjectType == ACPI_TYPE_ANY)) > + (ExternalOpType == ACPI_TYPE_ANY)) > { > /* Allow update of externals of unknown type. */ > > diff --git a/src/acpica/source/compiler/aslmessages.c b/src/acpica/source/compiler/aslmessages.c > index 81280b28..eb344940 100644 > --- a/src/acpica/source/compiler/aslmessages.c > +++ b/src/acpica/source/compiler/aslmessages.c > @@ -380,6 +380,7 @@ const char *AslCompilerMsgs [] = > /* ASL_MSG_TYPE_MISMATCH_FOUND_HERE */ "Actual object declaration:", > /* ASL_MSG_DUPLICATE_EXTERN_MISMATCH */ "Type mismatch between multiple external declarations detected", > /* ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE */"Duplicate external declaration:", > +/* ASL_MSG_CONDREF_NEEDS_EXTERNAL_DECL */"CondRefOf parameter requires External() declaration", > }; > > /* Table compiler */ > diff --git a/src/acpica/source/compiler/aslmessages.h b/src/acpica/source/compiler/aslmessages.h > index 6d5ffd4d..9a7215c6 100644 > --- a/src/acpica/source/compiler/aslmessages.h > +++ b/src/acpica/source/compiler/aslmessages.h > @@ -382,6 +382,7 @@ typedef enum > ASL_MSG_TYPE_MISMATCH_FOUND_HERE, > ASL_MSG_DUPLICATE_EXTERN_MISMATCH, > ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE, > + ASL_MSG_CONDREF_NEEDS_EXTERNAL_DECL, > > > /* These messages are used by the Data Table compiler only */ > diff --git a/src/acpica/source/compiler/aslpredef.c b/src/acpica/source/compiler/aslpredef.c > index afef94a0..1ee4fd49 100644 > --- a/src/acpica/source/compiler/aslpredef.c > +++ b/src/acpica/source/compiler/aslpredef.c > @@ -674,7 +674,7 @@ ApCheckForSpecialName ( > /* > * Was not actually emitted by the compiler. This is a special case, > * however. If the ASL code being compiled was the result of a > - * dissasembly, it may possibly contain valid compiler-emitted names > + * disassembly, it may possibly contain valid compiler-emitted names > * of the form "_T_x". We don't want to issue an error or even a > * warning and force the user to manually change the names. So, we > * will issue a remark instead. > diff --git a/src/acpica/source/compiler/aslxref.c b/src/acpica/source/compiler/aslxref.c > index 38356aa2..0df33e31 100644 > --- a/src/acpica/source/compiler/aslxref.c > +++ b/src/acpica/source/compiler/aslxref.c > @@ -199,6 +199,16 @@ XfCheckFieldRange ( > UINT32 FieldBitLength, > UINT32 AccessBitWidth); > > +static BOOLEAN > +XfFindCondRefOfName ( > + ACPI_NAMESPACE_NODE *Node, > + ACPI_PARSE_OBJECT *Op); > + > +static BOOLEAN > +XfRefIsGuardedByIfCondRefOf ( > + ACPI_NAMESPACE_NODE *Node, > + ACPI_PARSE_OBJECT *Op); > + > > /******************************************************************************* > * > @@ -581,17 +591,6 @@ XfNamespaceLocateBegin ( > return_ACPI_STATUS (AE_OK); > } > > - /* > - * One special case: CondRefOf operator - we don't care if the name exists > - * or not at this point, just ignore it, the point of the operator is to > - * determine if the name exists at runtime. > - */ > - if ((Op->Asl.Parent) && > - (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) > - { > - return_ACPI_STATUS (AE_OK); > - } > - > /* > * We must enable the "search-to-root" for single NameSegs, but > * we have to be very careful about opening up scopes > @@ -600,7 +599,8 @@ XfNamespaceLocateBegin ( > if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || > (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || > (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) || > - (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) > + (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) || > + (Op->Asl.ParseOpcode == PARSEOP_CONDREFOF)) > { > /* > * These are name references, do not push the scope stack > @@ -665,7 +665,22 @@ XfNamespaceLocateBegin ( > * We didn't find the name reference by path -- we can qualify this > * a little better before we print an error message > */ > - if (strlen (Path) == ACPI_NAMESEG_SIZE) > + > + if ((Op->Asl.Parent) && > + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) > + { > + /* > + * One special case: CondRefOf operator - if the name doesn't > + * exist at this point, it means that there's no actual or > + * external declaration. If the name is not found, just ignore > + * it, the point of the operator is to determine if the name > + * exists at runtime. We wanted to see if this named object > + * exists to facilitate analysis to allow protected usage of > + * undeclared externals. > + */ > + return_ACPI_STATUS (AE_OK); > + } > + else if (strlen (Path) == ACPI_NAMESEG_SIZE) > { > /* A simple, one-segment ACPI name */ > > @@ -1190,6 +1205,7 @@ XfNamespaceLocateBegin ( > > /* > * 5) Check for external resolution > + * > * By this point, everything should be loaded in the namespace. If a > * namespace lookup results in a namespace node that is an external, it > * means that this named object was not defined in the input ASL. This > @@ -1197,11 +1213,38 @@ XfNamespaceLocateBegin ( > * use the external keyword to suppress compiler errors about undefined > * objects. Note: this only applies when compiling multiple definition > * blocks. > + * > + * Do not check for external resolution in the following cases: > + * > + * case 1) External (ABCD) > + * > + * This declares ABCD as an external so there is no requirement for > + * ABCD to be loaded in the namespace when analyzing the actual > + * External() statement. > + * > + * case 2) CondRefOf (ABCD) > + * > + * This operator will query the ACPI namespace on the existence of > + * ABCD. If ABCD does not exist, this operator will return a 0 > + * without incurring AML runtime errors. Therefore, ABCD is allowed > + * to not exist when analyzing the CondRefOf operator. > + * > + * case 3) External (ABCD) > + * if (CondRefOf (ABCD)) > + * { > + * Store (0, ABCD) > + * } > + * > + * In this case, ABCD is accessed only if it exists due to the if > + * statement so there is no need to flag the ABCD nested in the > + * store operator. > */ > if (AslGbl_ParseTreeRoot->Asl.Child && AslGbl_ParseTreeRoot->Asl.Child->Asl.Next && > - (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL && > - Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL) && > - (Node->Flags & ANOBJ_IS_EXTERNAL)) > + (Node->Flags & ANOBJ_IS_EXTERNAL) && > + Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL && > + Op->Asl.ParseOpcode != PARSEOP_EXTERNAL && > + Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_CONDREFOF && > + !XfRefIsGuardedByIfCondRefOf (Node, Op)) > { > AslError (ASL_ERROR, ASL_MSG_UNDEFINED_EXTERNAL, Op, NULL); > } > @@ -1219,6 +1262,96 @@ XfNamespaceLocateBegin ( > } > > > +/******************************************************************************* > + * > + * FUNCTION: XfRefIsGuardedByIfCondRefOf > + * > + * PARAMETERS: Node - Named object reference node > + * Op - Named object reference parse node > + * > + * RETURN: BOOLEAN > + * > + * DESCRIPTION: returns true if Op checked inside if (CondRefOf (...)) > + * refers to Node. > + * > + ******************************************************************************/ > + > +static BOOLEAN > +XfRefIsGuardedByIfCondRefOf ( > + ACPI_NAMESPACE_NODE *Node, > + ACPI_PARSE_OBJECT *Op) > +{ > + ACPI_PARSE_OBJECT *Parent = Op->Asl.Parent; > + > + > + while (Parent) > + { > + if (Parent->Asl.ParseOpcode == PARSEOP_IF && > + XfFindCondRefOfName (Node, Parent->Asl.Child)) > + { > + return (TRUE); > + } > + > + Parent = Parent->Asl.Parent; > + } > + > + return (FALSE); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: XfRefIsGuardedByIfCondRefOf > + * > + * PARAMETERS: Node - Named object reference node > + * Op - Named object reference parse node > + * > + * RETURN: BOOLEAN > + * > + * DESCRIPTION: returns true if Op checked inside if (CondRefOf (...)) > + * refers to Node. > + * > + ******************************************************************************/ > + > +static BOOLEAN > +XfFindCondRefOfName ( > + ACPI_NAMESPACE_NODE *Node, > + ACPI_PARSE_OBJECT *Op) > +{ > + BOOLEAN CondRefOfFound = FALSE; > + > + > + if (!Op) > + { > + return (FALSE); > + } > + > + switch (Op->Asl.ParseOpcode) > + { > + case PARSEOP_CONDREFOF: > + > + return (Op->Asl.Child->Common.Node == Node); > + break; > + > + case PARSEOP_LAND: > + > + CondRefOfFound = XfFindCondRefOfName (Node, Op->Asl.Child); > + if (CondRefOfFound) > + { > + return (TRUE); > + } > + > + return (XfFindCondRefOfName (Node, Op->Asl.Child->Asl.Next)); > + break; > + > + default: > + > + return (FALSE); > + break; > + } > +} > + > + > /******************************************************************************* > * > * FUNCTION: XfNamespaceLocateEnd > diff --git a/src/acpica/source/compiler/dtutils.c b/src/acpica/source/compiler/dtutils.c > index bb07894e..55093a76 100644 > --- a/src/acpica/source/compiler/dtutils.c > +++ b/src/acpica/source/compiler/dtutils.c > @@ -186,11 +186,20 @@ DtError ( > DT_FIELD *FieldObject, > char *ExtraMessage) > { > + UINT32 Line = 0; > + > + > + /* Field object could be NULL */ > + > + if (FieldObject) > + { > + Line = FieldObject->Line; > + } > > /* Check if user wants to ignore this exception */ > > if (AslIsExceptionIgnored (AslGbl_Files[ASL_FILE_INPUT].Filename, > - FieldObject->Line, Level, MessageId)) > + Line, Level, MessageId)) > { > return; > } > diff --git a/src/acpica/source/components/debugger/dbhistry.c b/src/acpica/source/components/debugger/dbhistry.c > index 554115bf..b9b2ed87 100644 > --- a/src/acpica/source/components/debugger/dbhistry.c > +++ b/src/acpica/source/components/debugger/dbhistry.c > @@ -175,7 +175,6 @@ static HISTORY_INFO AcpiGbl_HistoryBuffer[HISTORY_SIZE]; > static UINT16 AcpiGbl_LoHistory = 0; > static UINT16 AcpiGbl_NumHistory = 0; > static UINT16 AcpiGbl_NextHistoryIndex = 0; > -UINT32 AcpiGbl_NextCmdNum = 1; > > > /******************************************************************************* > diff --git a/src/acpica/source/components/disassembler/dmbuffer.c b/src/acpica/source/components/disassembler/dmbuffer.c > index 1d734d4f..47279a2c 100644 > --- a/src/acpica/source/components/disassembler/dmbuffer.c > +++ b/src/acpica/source/components/disassembler/dmbuffer.c > @@ -400,6 +400,10 @@ AcpiDmIsUuidBuffer ( > /* Buffer size is the buffer argument */ > > SizeOp = Op->Common.Value.Arg; > + if (!SizeOp) > + { > + return (FALSE); > + } > > /* Next, the initializer byte list to examine */ > > @@ -520,6 +524,10 @@ AcpiDmIsUnicodeBuffer ( > /* Buffer size is the buffer argument */ > > SizeOp = Op->Common.Value.Arg; > + if (!SizeOp) > + { > + return (FALSE); > + } > > /* Next, the initializer byte list to examine */ > > @@ -596,6 +604,10 @@ AcpiDmIsStringBuffer ( > /* Buffer size is the buffer argument */ > > SizeOp = Op->Common.Value.Arg; > + if (!SizeOp) > + { > + return (FALSE); > + } > > /* Next, the initializer byte list to examine */ > > @@ -675,13 +687,18 @@ AcpiDmIsPldBuffer ( > UINT64 InitializerSize; > > > + if (!Op) > + { > + return (FALSE); > + } > + > /* > * Get the BufferSize argument - Buffer(BufferSize) > * If the buffer was generated by the ToPld macro, it must > * be a BYTE constant. > */ > SizeOp = Op->Common.Value.Arg; > - if (SizeOp->Common.AmlOpcode != AML_BYTE_OP) > + if (!SizeOp || SizeOp->Common.AmlOpcode != AML_BYTE_OP) > { > return (FALSE); > } > diff --git a/src/acpica/source/components/dispatcher/dsfield.c b/src/acpica/source/components/dispatcher/dsfield.c > index e2576606..f4199078 100644 > --- a/src/acpica/source/components/dispatcher/dsfield.c > +++ b/src/acpica/source/components/dispatcher/dsfield.c > @@ -341,7 +341,12 @@ AcpiDsCreateBufferField ( > Status = AcpiNsLookup (WalkState->ScopeInfo, > Arg->Common.Value.String, ACPI_TYPE_ANY, > ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); > - if (ACPI_FAILURE (Status)) > + if ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) && > + Status == AE_ALREADY_EXISTS) > + { > + Status = AE_OK; > + } > + else if (ACPI_FAILURE (Status)) > { > ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, > Arg->Common.Value.String, Status); > @@ -682,12 +687,21 @@ AcpiDsCreateField ( > Info.RegionNode = RegionNode; > > Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); > - if (Info.RegionNode->Object->Region.SpaceId == ACPI_ADR_SPACE_PLATFORM_COMM && > - !(RegionNode->Object->Field.InternalPccBuffer > - = ACPI_ALLOCATE_ZEROED(Info.RegionNode->Object->Region.Length))) > + if (ACPI_FAILURE (Status)) > { > - return_ACPI_STATUS (AE_NO_MEMORY); > + return_ACPI_STATUS (Status); > } > + > + if (Info.RegionNode->Object->Region.SpaceId == ACPI_ADR_SPACE_PLATFORM_COMM) > + { > + RegionNode->Object->Field.InternalPccBuffer = > + ACPI_ALLOCATE_ZEROED(Info.RegionNode->Object->Region.Length); > + if (!RegionNode->Object->Field.InternalPccBuffer) > + { > + return_ACPI_STATUS (AE_NO_MEMORY); > + } > + } > + > return_ACPI_STATUS (Status); > } > > diff --git a/src/acpica/source/components/executer/exfield.c b/src/acpica/source/components/executer/exfield.c > index 167d182c..897c2d47 100644 > --- a/src/acpica/source/components/executer/exfield.c > +++ b/src/acpica/source/components/executer/exfield.c > @@ -167,7 +167,7 @@ > #define ACPI_INVALID_PROTOCOL_ID 0x80 > #define ACPI_MAX_PROTOCOL_ID 0x0F > > -const UINT8 AcpiProtocolLengths[] = > +static const UINT8 AcpiProtocolLengths[] = > { > ACPI_INVALID_PROTOCOL_ID, /* 0 - reserved */ > ACPI_INVALID_PROTOCOL_ID, /* 1 - reserved */ > diff --git a/src/acpica/source/include/acglobal.h b/src/acpica/source/include/acglobal.h > index d41f24c8..a45ece02 100644 > --- a/src/acpica/source/include/acglobal.h > +++ b/src/acpica/source/include/acglobal.h > @@ -436,6 +436,7 @@ ACPI_GLOBAL (ACPI_EXTERNAL_FILE *, AcpiGbl_ExternalFileList); > #ifdef ACPI_DEBUGGER > ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_AbortMethod, FALSE); > ACPI_INIT_GLOBAL (ACPI_THREAD_ID, AcpiGbl_DbThreadId, ACPI_INVALID_THREAD_ID); > +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_NextCmdNum, 1); > > ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_NoIniMethods); > ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_NoRegionSupport); > diff --git a/src/acpica/source/include/acpixf.h b/src/acpica/source/include/acpixf.h > index eeb63cd5..ed280425 100644 > --- a/src/acpica/source/include/acpixf.h > +++ b/src/acpica/source/include/acpixf.h > @@ -154,7 +154,7 @@ > > /* Current ACPICA subsystem version in YYYYMMDD format */ > > -#define ACPI_CA_VERSION 0x20200326 > +#define ACPI_CA_VERSION 0x20200430 > > #include "acconfig.h" > #include "actypes.h" > diff --git a/src/acpica/source/include/acpredef.h b/src/acpica/source/include/acpredef.h > index 99c48b06..924d7b90 100644 > --- a/src/acpica/source/include/acpredef.h > +++ b/src/acpica/source/include/acpredef.h > @@ -769,10 +769,10 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] = > {{"_NIC", METHOD_0ARGS, /* ACPI 6.3 */ > METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, > > - {{"_NIG", METHOD_1ARGS (ACPI_TYPE_BUFFER), /* ACPI 6.3 */ > + {{"_NIG", METHOD_0ARGS, /* ACPI 6.3 */ > METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, > > - {{"_NIH", METHOD_0ARGS, /* ACPI 6.3 */ > + {{"_NIH", METHOD_1ARGS (ACPI_TYPE_BUFFER), /* ACPI 6.3 */ > METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, > > {{"_NTT", METHOD_0ARGS, > Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff --git a/src/acpica/source/common/acgetline.c b/src/acpica/source/common/acgetline.c index cf9d779a..e1ddaa69 100644 --- a/src/acpica/source/common/acgetline.c +++ b/src/acpica/source/common/acgetline.c @@ -189,8 +189,6 @@ AcpiAcClearLine ( #define _ASCII_LEFT_ARROW 'D' #define _ASCII_NEWLINE '\n' -extern UINT32 AcpiGbl_NextCmdNum; - /* Erase a single character on the input command line */ #define ACPI_CLEAR_CHAR() \ diff --git a/src/acpica/source/common/dmtbdump2.c b/src/acpica/source/common/dmtbdump2.c index 688a2cf9..45484825 100644 --- a/src/acpica/source/common/dmtbdump2.c +++ b/src/acpica/source/common/dmtbdump2.c @@ -528,8 +528,10 @@ AcpiDmDumpIvrs ( DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, Subtable, sizeof (ACPI_IVRS_HARDWARE1)); } - else if (Subtable->Type == ACPI_IVRS_TYPE_HARDWARE2) + else { + /* ACPI_IVRS_TYPE_HARDWARE2 subtable type */ + EntryOffset = Offset + sizeof (ACPI_IVRS_HARDWARE2); DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, Subtable, sizeof (ACPI_IVRS_HARDWARE2)); diff --git a/src/acpica/source/compiler/aslcompiler.l b/src/acpica/source/compiler/aslcompiler.l index 4c3fbde3..c12eb90b 100644 --- a/src/acpica/source/compiler/aslcompiler.l +++ b/src/acpica/source/compiler/aslcompiler.l @@ -819,7 +819,7 @@ NamePathTail [.]{NameSeg} } /* - * The eror code is contained inside the + * The error code is contained inside the * {ErrorCode} pattern. Extract it and log it * as the expected error code. */ diff --git a/src/acpica/source/compiler/aslload.c b/src/acpica/source/compiler/aslload.c index bd2fc977..bdc0d805 100644 --- a/src/acpica/source/compiler/aslload.c +++ b/src/acpica/source/compiler/aslload.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: dswload - Dispatcher namespace load callbacks + * Module Name: aslload - compiler namespace load callbacks * *****************************************************************************/ @@ -201,7 +201,6 @@ LdAnalyzeExternals ( ACPI_NAMESPACE_NODE *Node, ACPI_PARSE_OBJECT *Op, ACPI_OBJECT_TYPE ExternalOpType, - ACPI_OBJECT_TYPE ObjectType, ACPI_WALK_STATE *WalkState); @@ -515,7 +514,6 @@ LdNamespace1Begin ( ACPI_PARSE_OBJECT *MethodOp; ACPI_STATUS Status; ACPI_OBJECT_TYPE ObjectType; - ACPI_OBJECT_TYPE ActualObjectType = ACPI_TYPE_ANY; char *Path; UINT32 Flags = ACPI_NS_NO_UPSEARCH; ACPI_PARSE_OBJECT *Arg; @@ -689,8 +687,7 @@ LdNamespace1Begin ( * * first child is name, next child is ObjectType */ - ActualObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer; - ObjectType = ACPI_TYPE_ANY; + ObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer; /* * We will mark every new node along the path as "External". This @@ -709,7 +706,7 @@ LdNamespace1Begin ( * Store (\_SB_.PCI0.ABCD, Local0) * } */ - Flags |= ACPI_NS_EXTERNAL; + Flags |= ACPI_NS_EXTERNAL | ACPI_NS_DONT_OPEN_SCOPE; break; case PARSEOP_DEFAULT_ARG: @@ -913,8 +910,7 @@ LdNamespace1Begin ( else if ((Node->Flags & ANOBJ_IS_EXTERNAL) || (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) { - Status = LdAnalyzeExternals (Node, Op, ActualObjectType, - ObjectType, WalkState); + Status = LdAnalyzeExternals (Node, Op, ObjectType, WalkState); if (ACPI_FAILURE (Status)) { if (Status == AE_ERROR) @@ -929,6 +925,19 @@ LdNamespace1Begin ( } return_ACPI_STATUS (Status); } + + if (!(Node->Flags & ANOBJ_IS_EXTERNAL) && + (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) + { + /* + * If we get to here, it means that an actual definition of + * the object declared external exists. Meaning that Op + * loading this this Op should have no change to the ACPI + * namespace. By going to FinishNode, we skip the + * assignment of Node->Op = Op. + */ + goto FinishNode; + } } else { @@ -980,30 +989,15 @@ LdNamespace1Begin ( } } -FinishNode: - /* - * Point the parse node to the new namespace node, and point - * the Node back to the original Parse node - */ - Op->Asl.Node = Node; + /* Point the Node back to the original Parse node */ + Node->Op = Op; - /* - * Set the actual data type if appropriate (EXTERNAL term only) - * As of 11/19/2019, ASL External() does not support parameter - * counts. When an External method is loaded, the parameter count is - * recorded in the external's arg count parameter. The parameter count may - * or may not be known in the declaration. If the value of this node turns - * out to be ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS, it indicates that - * we do not know the parameter count and that we must look at the usage of - * the External method call to get this information. - */ - if (ActualObjectType != ACPI_TYPE_ANY) - { - Node->Type = (UINT8) ActualObjectType; - Node->Value = (UINT32) - Op->Asl.Child->Asl.Next->Asl.Next->Asl.Value.Integer; - } +FinishNode: + + /* Point the parse node to the new namespace node */ + + Op->Asl.Node = Node; if (Op->Asl.ParseOpcode == PARSEOP_METHOD) { @@ -1013,6 +1007,13 @@ FinishNode: */ Node->Value = (UINT32) Op->Asl.Extra; } + else if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL && + Node->Type == ACPI_TYPE_METHOD && + (Node->Flags & ANOBJ_IS_EXTERNAL)) + { + Node->Value = + (UINT32) Op->Asl.Child->Asl.Next->Asl.Next->Asl.Value.Integer; + } return_ACPI_STATUS (Status); } @@ -1020,7 +1021,7 @@ FinishNode: /******************************************************************************* * - * FUNCTION: LdAnalyzeExternals + * FUNCTION: LdMatchExternType * * PARAMETERS: Type1 * Type2 @@ -1037,7 +1038,7 @@ FinishNode: ******************************************************************************/ static BOOLEAN -LdTypesMatchExternType ( +LdMatchExternType ( ACPI_OBJECT_TYPE Type1, ACPI_OBJECT_TYPE Type2) { @@ -1093,7 +1094,6 @@ LdTypesMatchExternType ( * PARAMETERS: Node - Node that represents the named object * Op - Named object declaring this named object * ExternalOpType - Type of ExternalOp - * ObjectType - Type of Declared object * WalkState - Current WalkState * * RETURN: Status @@ -1111,7 +1111,6 @@ LdAnalyzeExternals ( ACPI_NAMESPACE_NODE *Node, ACPI_PARSE_OBJECT *Op, ACPI_OBJECT_TYPE ExternalOpType, - ACPI_OBJECT_TYPE ObjectType, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; @@ -1135,12 +1134,12 @@ LdAnalyzeExternals ( else { ActualExternalOpType = Node->Type; - ActualOpType = ObjectType; + ActualOpType = ExternalOpType; } if ((ActualOpType != ACPI_TYPE_ANY) && (ActualExternalOpType != ACPI_TYPE_ANY) && - !LdTypesMatchExternType (ActualExternalOpType, ActualOpType)) + !LdMatchExternType (ActualExternalOpType, ActualOpType)) { if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL && Node->Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) @@ -1168,6 +1167,8 @@ LdAnalyzeExternals ( } } + /* Set the object type of the external */ + if ((Node->Flags & ANOBJ_IS_EXTERNAL) && (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL)) { @@ -1176,13 +1177,13 @@ LdAnalyzeExternals ( * previously declared External */ Node->Flags &= ~ANOBJ_IS_EXTERNAL; - Node->Type = (UINT8) ObjectType; + Node->Type = (UINT8) ExternalOpType; /* Just retyped a node, probably will need to open a scope */ - if (AcpiNsOpensScope (ObjectType)) + if (AcpiNsOpensScope (ExternalOpType)) { - Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + Status = AcpiDsScopeStackPush (Node, ExternalOpType, WalkState); if (ACPI_FAILURE (Status)) { return (Status); @@ -1203,7 +1204,7 @@ LdAnalyzeExternals ( } else if ((Node->Flags & ANOBJ_IS_EXTERNAL) && (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) && - (ObjectType == ACPI_TYPE_ANY)) + (ExternalOpType == ACPI_TYPE_ANY)) { /* Allow update of externals of unknown type. */ diff --git a/src/acpica/source/compiler/aslmessages.c b/src/acpica/source/compiler/aslmessages.c index 81280b28..eb344940 100644 --- a/src/acpica/source/compiler/aslmessages.c +++ b/src/acpica/source/compiler/aslmessages.c @@ -380,6 +380,7 @@ const char *AslCompilerMsgs [] = /* ASL_MSG_TYPE_MISMATCH_FOUND_HERE */ "Actual object declaration:", /* ASL_MSG_DUPLICATE_EXTERN_MISMATCH */ "Type mismatch between multiple external declarations detected", /* ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE */"Duplicate external declaration:", +/* ASL_MSG_CONDREF_NEEDS_EXTERNAL_DECL */"CondRefOf parameter requires External() declaration", }; /* Table compiler */ diff --git a/src/acpica/source/compiler/aslmessages.h b/src/acpica/source/compiler/aslmessages.h index 6d5ffd4d..9a7215c6 100644 --- a/src/acpica/source/compiler/aslmessages.h +++ b/src/acpica/source/compiler/aslmessages.h @@ -382,6 +382,7 @@ typedef enum ASL_MSG_TYPE_MISMATCH_FOUND_HERE, ASL_MSG_DUPLICATE_EXTERN_MISMATCH, ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE, + ASL_MSG_CONDREF_NEEDS_EXTERNAL_DECL, /* These messages are used by the Data Table compiler only */ diff --git a/src/acpica/source/compiler/aslpredef.c b/src/acpica/source/compiler/aslpredef.c index afef94a0..1ee4fd49 100644 --- a/src/acpica/source/compiler/aslpredef.c +++ b/src/acpica/source/compiler/aslpredef.c @@ -674,7 +674,7 @@ ApCheckForSpecialName ( /* * Was not actually emitted by the compiler. This is a special case, * however. If the ASL code being compiled was the result of a - * dissasembly, it may possibly contain valid compiler-emitted names + * disassembly, it may possibly contain valid compiler-emitted names * of the form "_T_x". We don't want to issue an error or even a * warning and force the user to manually change the names. So, we * will issue a remark instead. diff --git a/src/acpica/source/compiler/aslxref.c b/src/acpica/source/compiler/aslxref.c index 38356aa2..0df33e31 100644 --- a/src/acpica/source/compiler/aslxref.c +++ b/src/acpica/source/compiler/aslxref.c @@ -199,6 +199,16 @@ XfCheckFieldRange ( UINT32 FieldBitLength, UINT32 AccessBitWidth); +static BOOLEAN +XfFindCondRefOfName ( + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op); + +static BOOLEAN +XfRefIsGuardedByIfCondRefOf ( + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op); + /******************************************************************************* * @@ -581,17 +591,6 @@ XfNamespaceLocateBegin ( return_ACPI_STATUS (AE_OK); } - /* - * One special case: CondRefOf operator - we don't care if the name exists - * or not at this point, just ignore it, the point of the operator is to - * determine if the name exists at runtime. - */ - if ((Op->Asl.Parent) && - (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) - { - return_ACPI_STATUS (AE_OK); - } - /* * We must enable the "search-to-root" for single NameSegs, but * we have to be very careful about opening up scopes @@ -600,7 +599,8 @@ XfNamespaceLocateBegin ( if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) || - (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) + (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) || + (Op->Asl.ParseOpcode == PARSEOP_CONDREFOF)) { /* * These are name references, do not push the scope stack @@ -665,7 +665,22 @@ XfNamespaceLocateBegin ( * We didn't find the name reference by path -- we can qualify this * a little better before we print an error message */ - if (strlen (Path) == ACPI_NAMESEG_SIZE) + + if ((Op->Asl.Parent) && + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) + { + /* + * One special case: CondRefOf operator - if the name doesn't + * exist at this point, it means that there's no actual or + * external declaration. If the name is not found, just ignore + * it, the point of the operator is to determine if the name + * exists at runtime. We wanted to see if this named object + * exists to facilitate analysis to allow protected usage of + * undeclared externals. + */ + return_ACPI_STATUS (AE_OK); + } + else if (strlen (Path) == ACPI_NAMESEG_SIZE) { /* A simple, one-segment ACPI name */ @@ -1190,6 +1205,7 @@ XfNamespaceLocateBegin ( /* * 5) Check for external resolution + * * By this point, everything should be loaded in the namespace. If a * namespace lookup results in a namespace node that is an external, it * means that this named object was not defined in the input ASL. This @@ -1197,11 +1213,38 @@ XfNamespaceLocateBegin ( * use the external keyword to suppress compiler errors about undefined * objects. Note: this only applies when compiling multiple definition * blocks. + * + * Do not check for external resolution in the following cases: + * + * case 1) External (ABCD) + * + * This declares ABCD as an external so there is no requirement for + * ABCD to be loaded in the namespace when analyzing the actual + * External() statement. + * + * case 2) CondRefOf (ABCD) + * + * This operator will query the ACPI namespace on the existence of + * ABCD. If ABCD does not exist, this operator will return a 0 + * without incurring AML runtime errors. Therefore, ABCD is allowed + * to not exist when analyzing the CondRefOf operator. + * + * case 3) External (ABCD) + * if (CondRefOf (ABCD)) + * { + * Store (0, ABCD) + * } + * + * In this case, ABCD is accessed only if it exists due to the if + * statement so there is no need to flag the ABCD nested in the + * store operator. */ if (AslGbl_ParseTreeRoot->Asl.Child && AslGbl_ParseTreeRoot->Asl.Child->Asl.Next && - (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL && - Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL) && - (Node->Flags & ANOBJ_IS_EXTERNAL)) + (Node->Flags & ANOBJ_IS_EXTERNAL) && + Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL && + Op->Asl.ParseOpcode != PARSEOP_EXTERNAL && + Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_CONDREFOF && + !XfRefIsGuardedByIfCondRefOf (Node, Op)) { AslError (ASL_ERROR, ASL_MSG_UNDEFINED_EXTERNAL, Op, NULL); } @@ -1219,6 +1262,96 @@ XfNamespaceLocateBegin ( } +/******************************************************************************* + * + * FUNCTION: XfRefIsGuardedByIfCondRefOf + * + * PARAMETERS: Node - Named object reference node + * Op - Named object reference parse node + * + * RETURN: BOOLEAN + * + * DESCRIPTION: returns true if Op checked inside if (CondRefOf (...)) + * refers to Node. + * + ******************************************************************************/ + +static BOOLEAN +XfRefIsGuardedByIfCondRefOf ( + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Parent = Op->Asl.Parent; + + + while (Parent) + { + if (Parent->Asl.ParseOpcode == PARSEOP_IF && + XfFindCondRefOfName (Node, Parent->Asl.Child)) + { + return (TRUE); + } + + Parent = Parent->Asl.Parent; + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: XfRefIsGuardedByIfCondRefOf + * + * PARAMETERS: Node - Named object reference node + * Op - Named object reference parse node + * + * RETURN: BOOLEAN + * + * DESCRIPTION: returns true if Op checked inside if (CondRefOf (...)) + * refers to Node. + * + ******************************************************************************/ + +static BOOLEAN +XfFindCondRefOfName ( + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op) +{ + BOOLEAN CondRefOfFound = FALSE; + + + if (!Op) + { + return (FALSE); + } + + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_CONDREFOF: + + return (Op->Asl.Child->Common.Node == Node); + break; + + case PARSEOP_LAND: + + CondRefOfFound = XfFindCondRefOfName (Node, Op->Asl.Child); + if (CondRefOfFound) + { + return (TRUE); + } + + return (XfFindCondRefOfName (Node, Op->Asl.Child->Asl.Next)); + break; + + default: + + return (FALSE); + break; + } +} + + /******************************************************************************* * * FUNCTION: XfNamespaceLocateEnd diff --git a/src/acpica/source/compiler/dtutils.c b/src/acpica/source/compiler/dtutils.c index bb07894e..55093a76 100644 --- a/src/acpica/source/compiler/dtutils.c +++ b/src/acpica/source/compiler/dtutils.c @@ -186,11 +186,20 @@ DtError ( DT_FIELD *FieldObject, char *ExtraMessage) { + UINT32 Line = 0; + + + /* Field object could be NULL */ + + if (FieldObject) + { + Line = FieldObject->Line; + } /* Check if user wants to ignore this exception */ if (AslIsExceptionIgnored (AslGbl_Files[ASL_FILE_INPUT].Filename, - FieldObject->Line, Level, MessageId)) + Line, Level, MessageId)) { return; } diff --git a/src/acpica/source/components/debugger/dbhistry.c b/src/acpica/source/components/debugger/dbhistry.c index 554115bf..b9b2ed87 100644 --- a/src/acpica/source/components/debugger/dbhistry.c +++ b/src/acpica/source/components/debugger/dbhistry.c @@ -175,7 +175,6 @@ static HISTORY_INFO AcpiGbl_HistoryBuffer[HISTORY_SIZE]; static UINT16 AcpiGbl_LoHistory = 0; static UINT16 AcpiGbl_NumHistory = 0; static UINT16 AcpiGbl_NextHistoryIndex = 0; -UINT32 AcpiGbl_NextCmdNum = 1; /******************************************************************************* diff --git a/src/acpica/source/components/disassembler/dmbuffer.c b/src/acpica/source/components/disassembler/dmbuffer.c index 1d734d4f..47279a2c 100644 --- a/src/acpica/source/components/disassembler/dmbuffer.c +++ b/src/acpica/source/components/disassembler/dmbuffer.c @@ -400,6 +400,10 @@ AcpiDmIsUuidBuffer ( /* Buffer size is the buffer argument */ SizeOp = Op->Common.Value.Arg; + if (!SizeOp) + { + return (FALSE); + } /* Next, the initializer byte list to examine */ @@ -520,6 +524,10 @@ AcpiDmIsUnicodeBuffer ( /* Buffer size is the buffer argument */ SizeOp = Op->Common.Value.Arg; + if (!SizeOp) + { + return (FALSE); + } /* Next, the initializer byte list to examine */ @@ -596,6 +604,10 @@ AcpiDmIsStringBuffer ( /* Buffer size is the buffer argument */ SizeOp = Op->Common.Value.Arg; + if (!SizeOp) + { + return (FALSE); + } /* Next, the initializer byte list to examine */ @@ -675,13 +687,18 @@ AcpiDmIsPldBuffer ( UINT64 InitializerSize; + if (!Op) + { + return (FALSE); + } + /* * Get the BufferSize argument - Buffer(BufferSize) * If the buffer was generated by the ToPld macro, it must * be a BYTE constant. */ SizeOp = Op->Common.Value.Arg; - if (SizeOp->Common.AmlOpcode != AML_BYTE_OP) + if (!SizeOp || SizeOp->Common.AmlOpcode != AML_BYTE_OP) { return (FALSE); } diff --git a/src/acpica/source/components/dispatcher/dsfield.c b/src/acpica/source/components/dispatcher/dsfield.c index e2576606..f4199078 100644 --- a/src/acpica/source/components/dispatcher/dsfield.c +++ b/src/acpica/source/components/dispatcher/dsfield.c @@ -341,7 +341,12 @@ AcpiDsCreateBufferField ( Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); - if (ACPI_FAILURE (Status)) + if ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) && + Status == AE_ALREADY_EXISTS) + { + Status = AE_OK; + } + else if (ACPI_FAILURE (Status)) { ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, Arg->Common.Value.String, Status); @@ -682,12 +687,21 @@ AcpiDsCreateField ( Info.RegionNode = RegionNode; Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); - if (Info.RegionNode->Object->Region.SpaceId == ACPI_ADR_SPACE_PLATFORM_COMM && - !(RegionNode->Object->Field.InternalPccBuffer - = ACPI_ALLOCATE_ZEROED(Info.RegionNode->Object->Region.Length))) + if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS (Status); } + + if (Info.RegionNode->Object->Region.SpaceId == ACPI_ADR_SPACE_PLATFORM_COMM) + { + RegionNode->Object->Field.InternalPccBuffer = + ACPI_ALLOCATE_ZEROED(Info.RegionNode->Object->Region.Length); + if (!RegionNode->Object->Field.InternalPccBuffer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + return_ACPI_STATUS (Status); } diff --git a/src/acpica/source/components/executer/exfield.c b/src/acpica/source/components/executer/exfield.c index 167d182c..897c2d47 100644 --- a/src/acpica/source/components/executer/exfield.c +++ b/src/acpica/source/components/executer/exfield.c @@ -167,7 +167,7 @@ #define ACPI_INVALID_PROTOCOL_ID 0x80 #define ACPI_MAX_PROTOCOL_ID 0x0F -const UINT8 AcpiProtocolLengths[] = +static const UINT8 AcpiProtocolLengths[] = { ACPI_INVALID_PROTOCOL_ID, /* 0 - reserved */ ACPI_INVALID_PROTOCOL_ID, /* 1 - reserved */ diff --git a/src/acpica/source/include/acglobal.h b/src/acpica/source/include/acglobal.h index d41f24c8..a45ece02 100644 --- a/src/acpica/source/include/acglobal.h +++ b/src/acpica/source/include/acglobal.h @@ -436,6 +436,7 @@ ACPI_GLOBAL (ACPI_EXTERNAL_FILE *, AcpiGbl_ExternalFileList); #ifdef ACPI_DEBUGGER ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_AbortMethod, FALSE); ACPI_INIT_GLOBAL (ACPI_THREAD_ID, AcpiGbl_DbThreadId, ACPI_INVALID_THREAD_ID); +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_NextCmdNum, 1); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_NoIniMethods); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_NoRegionSupport); diff --git a/src/acpica/source/include/acpixf.h b/src/acpica/source/include/acpixf.h index eeb63cd5..ed280425 100644 --- a/src/acpica/source/include/acpixf.h +++ b/src/acpica/source/include/acpixf.h @@ -154,7 +154,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20200326 +#define ACPI_CA_VERSION 0x20200430 #include "acconfig.h" #include "actypes.h" diff --git a/src/acpica/source/include/acpredef.h b/src/acpica/source/include/acpredef.h index 99c48b06..924d7b90 100644 --- a/src/acpica/source/include/acpredef.h +++ b/src/acpica/source/include/acpredef.h @@ -769,10 +769,10 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] = {{"_NIC", METHOD_0ARGS, /* ACPI 6.3 */ METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, - {{"_NIG", METHOD_1ARGS (ACPI_TYPE_BUFFER), /* ACPI 6.3 */ + {{"_NIG", METHOD_0ARGS, /* ACPI 6.3 */ METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, - {{"_NIH", METHOD_0ARGS, /* ACPI 6.3 */ + {{"_NIH", METHOD_1ARGS (ACPI_TYPE_BUFFER), /* ACPI 6.3 */ METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, {{"_NTT", METHOD_0ARGS,