From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) by mx.groups.io with SMTP id smtpd.web10.9724.1661854853945491854 for ; Tue, 30 Aug 2022 03:20:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AHa9zPEX; spf=pass (domain: gmail.com, ip: 209.85.208.181, mailfrom: aladyshev22@gmail.com) Received: by mail-lj1-f181.google.com with SMTP id y10so7692210ljq.0 for ; Tue, 30 Aug 2022 03:20:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=CPvKGAASsPCZxiuhCb/3sWiWYr99KYh6yGaz6MJktro=; b=AHa9zPEX/H9IegPlEuKMaYD/gpG0+WLZku2KGkChoT1R2/1JzpUU0bVrDuCD1OU+9B gk92pJVJ7tNd8ijA8m5xZF8PlRbwI/GcMzwTIXo6T1AsZa2FVOZwY6zjFK8pc3UE5lBz 3LVpKvsgpcUCronKTURjiUAADMA1EfcJvCprZXwa7mdB8Gx824io4JqBJMo44UC3jzBn FUIL91k8sp7J+rtPQOnuJayL++V1WTIsnDKGefOFREPOWgd1+v4VcY+EuCfG8shedwLP xGQLo0DdlHAptjiq23uY7KAec6MY1RFQA5NBMM1Kp+Upln9oI0M9kr9D1CeMEHWIN+Qk Yu4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=CPvKGAASsPCZxiuhCb/3sWiWYr99KYh6yGaz6MJktro=; b=yWXd7By1Mst+K/Xq7aPXKlf3GB2CS2qGXXOAELbNvui/cbXjE4t9tVU1Tt+N4PvY7M KDOVFIf8RHmffw9uxfPGuVHu8k3XfRYytBVWGNAvz7FXubYTGDz+1EcldaArCW9dLB/M TlQy/C34ep0j5P8FzyxNUIcjBjVkeQq/A6nmXOdotkFnhCEML4i7ggor9mrVefZPIaGc a7MaZlwPZm1ZzAmpmvtOevxOnYBOccmHwLnzlbx+aUcRvJmipkyayvryPkT+IyR+LRms hO6+QeLVI3RGVkn9PGeZCxgB54Q/tCw6cwrBAVgqFveCU7MUvXrRajoSzuH1eVJSCk/9 DVdw== X-Gm-Message-State: ACgBeo2GrBrTdXxL6lSAOnRI89kjVRcY96q8ukrlWI96ZRAv4vb6kii5 Zj6/hNo14zV1XXfVLUNQjPJt2LEBQYw= X-Google-Smtp-Source: AA6agR4FVbSrPMo18bsLwPZY4y+los/gL4Rnw6dR+Qd1zBgXB52DPJKmLMvzy+bz38Vf6bNQ9ErRzQ== X-Received: by 2002:a2e:8484:0:b0:25e:c325:c94f with SMTP id b4-20020a2e8484000000b0025ec325c94fmr7196583ljh.310.1661854851776; Tue, 30 Aug 2022 03:20:51 -0700 (PDT) Return-Path: Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id p9-20020a2eba09000000b0025df5f38da8sm1712859lja.119.2022.08.30.03.20.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 03:20:51 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: bob.c.feng@intel.com, gaoliming@byosoft.com.cn, yuwei.chen@intel.com, Konstantin Aladyshev Subject: [PATCH v2] BaseTools: Correct initialization data size check for array PCDs Date: Tue, 30 Aug 2022 13:20:54 +0300 Message-Id: <20220830102054.18641-1-aladyshev22@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Currently it is not possible to initialize all elements in the array PCD. For example, this PCD would result to a build failure: gTokenSpaceGuid.PcdArray|{0x11, 0x22}|UINT8[2]|0x4C4CB9A3 Correct logical operator in the initialization data size checks to fix the issue. Signed-off-by: Konstantin Aladyshev --- .../Source/Python/Workspace/DscBuildData.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index e9f68384b4..73c6ee4006 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -2089,12 +2089,12 @@ class DscBuildData(PlatformBuildClassObject): pcdarraysize =3D Pcd.PcdArraySize()=0D if "{CODE(" in Pcd.DefaultValueFromDec:=0D if Pcd.Capacity[-1] !=3D "-1":=0D - CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s_%s_INIT= _Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dec exceed the array capabil= ity %s"); // From %s Line %s \n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCNa= me,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName, Pcd.TokenCName,P= cd.DatumType,Pcd.DefaultValueFromDecInfo[0],Pcd.DefaultValueFromDecInfo[1])= =0D + CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s_%s_INIT= _Value) <=3D %d * sizeof(%s), "Pcd %s.%s Value in Dec exceed the array capa= bility %s"); // From %s Line %s \n ' % (Pcd.TokenSpaceGuidCName, Pcd.Token= CName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName, Pcd.TokenCNam= e,Pcd.DatumType,Pcd.DefaultValueFromDecInfo[0],Pcd.DefaultValueFromDecInfo[= 1])=0D CApp =3D CApp + ' PcdArraySize =3D sizeof(%s_%s_INIT_V= alue);\n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)=0D CApp =3D CApp + ' memcpy (Pcd, %s_%s_INIT_Value,PcdAr= raySize);\n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)=0D else:=0D if Pcd.Capacity[-1] !=3D "-1":=0D - CApp =3D CApp + '__STATIC_ASSERT(%d < %d * sizeof(= %s), "Pcd %s.%s Value in Dec exceed the array capability %s"); // From %s L= ine %s \n' % (ValueSize,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCN= ame, Pcd.TokenCName,Pcd.DatumType,Pcd.DefaultValueFromDecInfo[0],Pcd.Defaul= tValueFromDecInfo[1])=0D + CApp =3D CApp + '__STATIC_ASSERT(%d <=3D %d * size= of(%s), "Pcd %s.%s Value in Dec exceed the array capability %s"); // From %= s Line %s \n' % (ValueSize,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGui= dCName, Pcd.TokenCName,Pcd.DatumType,Pcd.DefaultValueFromDecInfo[0],Pcd.Def= aultValueFromDecInfo[1])=0D CApp =3D CApp + ' PcdArraySize =3D %d;\n' % ValueSize= =0D CApp =3D CApp + ' Value =3D %s; // From DEC Defau= lt Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), Pcd.DefaultV= alueFromDec)=0D CApp =3D CApp + ' memcpy (Pcd, Value, PcdArraySize);\= n'=0D @@ -2204,7 +2204,7 @@ class DscBuildData(PlatformBuildClassObject): if "{CODE(" in Value:=0D if Pcd.IsArray() and Pcd.Capacity[-1] !=3D "-1":=0D pcdarraysize =3D Pcd.PcdArraySize()=0D - CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s_%s_= %s_%s_Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array ca= pability %s"); // From %s \n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,Sk= uName, DefaultStoreName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCN= ame, Pcd.TokenCName,Pcd.DatumType, valuefrom)=0D + CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s_%s_= %s_%s_Value) <=3D %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array= capability %s"); // From %s \n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName= ,SkuName, DefaultStoreName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGui= dCName, Pcd.TokenCName,Pcd.DatumType, valuefrom)=0D CApp =3D CApp+ ' PcdArraySize =3D sizeof(%s_%s_%s_= %s_Value);\n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName, DefaultS= toreName)=0D CApp =3D CApp + ' memcpy (Pcd, &%s_%s_%s_%s_Value= ,PcdArraySize);\n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName, Def= aultStoreName)=0D else:=0D @@ -2217,12 +2217,12 @@ class DscBuildData(PlatformBuildClassObject): pcdarraysize =3D Pcd.PcdArraySize()=0D if "{CODE(" in pcddefaultvalue:=0D if Pcd.Capacity[-1] !=3D "-1":=0D - CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s= _%s_%s_%s_Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the arra= y capability %s"); // From %s \n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCNa= me,SkuName, DefaultStoreName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceG= uidCName, Pcd.TokenCName,Pcd.DatumType,valuefrom)=0D + CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s= _%s_%s_%s_Value) <=3D %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the a= rray capability %s"); // From %s \n' % (Pcd.TokenSpaceGuidCName, Pcd.Token= CName,SkuName, DefaultStoreName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpa= ceGuidCName, Pcd.TokenCName,Pcd.DatumType,valuefrom)=0D CApp =3D CApp + ' PcdArraySize =3D sizeof(%s_%= s_%s_%s_Value);\n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName, Def= aultStoreName)=0D CApp =3D CApp + ' memcpy (Pcd, %s_%s_%s_%s_Va= lue, PcdArraySize);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName, = DefaultStoreName)=0D else:=0D if Pcd.Capacity[-1] !=3D "-1":=0D - CApp =3D CApp + '__STATIC_ASSERT(%d < %d *= sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array capability %s"); // F= rom %s \n' % (ValueSize,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidC= Name, Pcd.TokenCName,Pcd.DatumType,valuefrom)=0D + CApp =3D CApp + '__STATIC_ASSERT(%d <=3D %= d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array capability %s"); /= / From %s \n' % (ValueSize,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGu= idCName, Pcd.TokenCName,Pcd.DatumType,valuefrom)=0D CApp =3D CApp + ' PcdArraySize =3D %d;\n' % Va= lueSize=0D CApp =3D CApp + ' Value =3D %s; // From D= SC Default Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), Pcd.= DefaultFromDSC.get(TAB_DEFAULT, {}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.Def= aultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)=0D CApp =3D CApp + ' memcpy (Pcd, Value, PcdArra= ySize);\n'=0D @@ -2238,7 +2238,7 @@ class DscBuildData(PlatformBuildClassObject): if "{CODE(" in Value:=0D if Pcd.IsArray() and Pcd.Capacity[-1] !=3D "-1":=0D pcdarraysize =3D Pcd.PcdArraySize()=0D - CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s_%s_= %s_%s_Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array ca= pability %s"); // From %s \n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,Sk= uName, DefaultStoreName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCN= ame, Pcd.TokenCName,Pcd.DatumType,valuefrom)=0D + CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s_%s_= %s_%s_Value) <=3D %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array= capability %s"); // From %s \n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName= ,SkuName, DefaultStoreName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGui= dCName, Pcd.TokenCName,Pcd.DatumType,valuefrom)=0D CApp =3D CApp + ' PcdArraySize =3D sizeof(%s_%s_%s= _%s_Value);\n '% (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName, DefaultS= toreName)=0D CApp =3D CApp + ' memcpy (Pcd, &%s_%s_%s_%s_Value= , PcdArraySize);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName, Def= aultStoreName)=0D else:=0D @@ -2251,12 +2251,12 @@ class DscBuildData(PlatformBuildClassObject): pcdarraysize =3D Pcd.PcdArraySize()=0D if "{CODE(" in pcddefaultvalue:=0D if Pcd.Capacity[-1] !=3D "-1":=0D - CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s= _%s_%s_%s_Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the arra= y capability %s"); // From %s \n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCNa= me,SkuName, DefaultStoreName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceG= uidCName, Pcd.TokenCName,Pcd.DatumType,valuefrom)=0D + CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s= _%s_%s_%s_Value) <=3D %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the a= rray capability %s"); // From %s \n' % (Pcd.TokenSpaceGuidCName, Pcd.Token= CName,SkuName, DefaultStoreName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpa= ceGuidCName, Pcd.TokenCName,Pcd.DatumType,valuefrom)=0D CApp + ' PcdArraySize =3D sizeof(%s_%s_%s_%s_V= alue);\n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName, DefaultStore= Name)=0D CApp =3D CApp + ' memcpy (Pcd, %s_%s_%s_%s_Va= lue, PcdArraySize);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName, = DefaultStoreName)=0D else:=0D if Pcd.Capacity[-1] !=3D "-1":=0D - CApp =3D CApp + '__STATIC_ASSERT(%d < %d *= sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array capability %s"); // F= rom %s \n' % (ValueSize,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidC= Name, Pcd.TokenCName,Pcd.DatumType,valuefrom)=0D + CApp =3D CApp + '__STATIC_ASSERT(%d <=3D %= d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array capability %s"); /= / From %s \n' % (ValueSize,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGu= idCName, Pcd.TokenCName,Pcd.DatumType,valuefrom)=0D CApp =3D CApp + ' PcdArraySize =3D %d;\n' % Va= lueSize=0D CApp =3D CApp + ' Value =3D %s; // From D= SC Default Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), Pcd.= DscRawValue.get(TAB_DEFAULT, {}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.Defaul= tValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)=0D CApp =3D CApp + ' memcpy (Pcd, Value, PcdArra= ySize);\n'=0D --=20 2.25.1