From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by mx.groups.io with SMTP id smtpd.web10.7541.1659453296527895330 for ; Tue, 02 Aug 2022 08:14:56 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PHWRj3m4; spf=pass (domain: gmail.com, ip: 209.85.167.41, mailfrom: aladyshev22@gmail.com) Received: by mail-lf1-f41.google.com with SMTP id x39so12829474lfu.7 for ; Tue, 02 Aug 2022 08:14:56 -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=Gzy2A11cxZJVBbIrv/AskehwIBhLxGsf4InV7PSVVx4=; b=PHWRj3m4rnaPpUQ/pSCWhkYCFKum7pzxWcVBnHuHhz1y1BdAecvv+jMKiUlQgQAOw9 mXFo3HQhVxx6OKUE/QdGcAATH3X3XCStmrIlqx6moSes6H+FpYqwM9MZzL0fArrL9Exa Wn11IDhOzPKuZ7XU3z6oJ6iBagiW1uHkqi9ck5zw9G034dsmO016abGdjtUYBQu24aVv rCyQLlnsBIH+sCDrWZ0kLjCUBn/zmuj7NuDr6yBujU/af7XZgJ108FKaLkG50RYn+t3n PM2w7iRbYfDUtJ3FoDN5Y3yrIDZFsna+1n0/RWMEFQrRMCWUFX2NgZdD6AA1OGOK7skm M7XQ== 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=Gzy2A11cxZJVBbIrv/AskehwIBhLxGsf4InV7PSVVx4=; b=3RIRU9pip+W/Vok3P7TIwgbnleMwU+SMWgO8uW3/8/Y8n8jYptAwDQkRfYhoizd1FP ryOD7T+TF+lDF5eJ/QP6HJqx4GK7CVFDUxinRJLgqLkegCFjpYH6i2iSGOBO3wUYkoLP gW5Xq3yM+XYVWT5jCU70y235a+mb9uJqghVjTJ/FrunuPhsH/ae+xF/Om+UP1vpn5lEO zy6d76jwCchRZtVl8E+2JQn46xEiNoQdVhbIKmwHmYk0UXFdy3DpKAVmeEuGem64bhvV 6AT5zjEf15tpsssComqsFFLfSQN8zfEPcS1Yn0U3xieDtWrPQZofz8bW0PEnUEfE2T23 YMUw== X-Gm-Message-State: ACgBeo2f1N5e8W+f+BXmw3Mr/Z+WJiwcd7smvHIrRFUvqmqyk3mBAW4g v2LbWuNZdoX0/7owYL/YM6nrUVEjPgZSLZqk X-Google-Smtp-Source: AA6agR7/yAQ1bfO24JVg3/aiGquj3XZcxUfHvjaZpLoMHtcLr6A8b4PvIwAhwRbELmkkpylF2dZayA== X-Received: by 2002:a05:6512:1054:b0:48a:f321:60be with SMTP id c20-20020a056512105400b0048af32160bemr4704995lfb.84.1659453294380; Tue, 02 Aug 2022 08:14:54 -0700 (PDT) Return-Path: Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id c6-20020a19e346000000b0048a82fec50esm2118793lfk.305.2022.08.02.08.14.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 08:14:53 -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] BaseTools: Correct initialization data size check for array PCDs Date: Tue, 2 Aug 2022 18:15:11 +0300 Message-Id: <20220802151511.24778-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 41f93c93f2..ccb4cf378f 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