From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from walk.intel-email.com (walk.intel-email.com [101.227.64.242]) by mx.groups.io with SMTP id smtpd.web12.6456.1664245040877627935 for ; Mon, 26 Sep 2022 19:17:21 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@byosoft.com.cn header.s=cloud-union header.b=p5kDeQzN; spf=pass (domain: byosoft.com.cn, ip: 101.227.64.242, mailfrom: gaoliming@byosoft.com.cn) Received: from walk.intel-email.com (localhost [127.0.0.1]) by walk.intel-email.com (Postfix) with ESMTP id 6B57ACD1F692 for ; Tue, 27 Sep 2022 10:17:18 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=byosoft.com.cn; s=cloud-union; t=1664245038; bh=VMCuOo9a1Dj0JUNNg0K6YseVZ6TvRj7i7VboFtkYJco=; h=From:To:Cc:References:In-Reply-To:Subject:Date; b=p5kDeQzNpB7oDzCDuyq95jRXB2VHpAcr81U8NsT5+0T6vL3KwukJ6/2v3U8cUPSqK UwFgOKbTzgYBv7F6KWJVqVdsryYBiN/tnmKfPzSrP2am5mo7hiDJ6wW0uqaW1p+89B vwuBuNrY+FtavAueizzaboezLXGCFjzTs/a8+Kyc= Received: from localhost (localhost [127.0.0.1]) by walk.intel-email.com (Postfix) with ESMTP id 671F1CD1F62A for ; Tue, 27 Sep 2022 10:17:18 +0800 (CST) Received: from walk.intel-email.com (localhost [127.0.0.1]) by walk.intel-email.com (Postfix) with ESMTP id 370E8CD1F668 for ; Tue, 27 Sep 2022 10:17:18 +0800 (CST) Authentication-Results: walk.intel-email.com; none Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by walk.intel-email.com (Postfix) with SMTP id B5ACACD1F6F6 for ; Tue, 27 Sep 2022 10:17:14 +0800 (CST) Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Tue, 27 Sep 2022 10:17:13 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-Originating-IP: 58.246.60.130 X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: "'Konstantin Aladyshev'" , Cc: , References: <20220830102054.18641-1-aladyshev22@gmail.com> In-Reply-To: <20220830102054.18641-1-aladyshev22@gmail.com> Subject: =?UTF-8?B?5Zue5aSNOiBbUEFUQ0ggdjJdIEJhc2VUb29sczogQ29ycmVjdCBpbml0aWFsaXphdGlvbiBkYXRhIHNpemUgY2hlY2sgZm9yIGFycmF5IFBDRHM=?= Date: Tue, 27 Sep 2022 10:17:13 +0800 Message-ID: <016e01d8d217$41e53210$c5af9630$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQIc55nAsF0ScUUymGedS+VqgPY9aa1qX0Kw Sender: "gaoliming" Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Reviewed-by: Liming Gao > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: Konstantin Aladyshev > =B7=A2=CB=CD=CA=B1=BC=E4: 2022=C4=EA8=D4=C230=C8=D5 18:21 > =CA=D5=BC=FE=C8=CB: devel@edk2.groups.io > =B3=AD=CB=CD: bob.c.feng@intel.com; gaoliming@byosoft.com.cn; > yuwei.chen@intel.com; Konstantin Aladyshev > =D6=F7=CC=E2: [PATCH v2] BaseTools: Correct initialization data size = check for array > PCDs >=20 > Currently it is not possible to initialize all elements in the > array PCD. >=20 > For example, this PCD would result to a build failure: > gTokenSpaceGuid.PcdArray|{0x11, 0x22}|UINT8[2]|0x4C4CB9A3 >=20 > Correct logical operator in the initialization data size checks to > fix the issue. >=20 > Signed-off-by: Konstantin Aladyshev > --- > .../Source/Python/Workspace/DscBuildData.py | 16 = ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) >=20 > 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() >=20 > if "{CODE(" in Pcd.DefaultValueFromDec: >=20 > if Pcd.Capacity[-1] !=3D "-1": >=20 > - CApp =3D CApp + > '__STATIC_ASSERT(sizeof(%s_%s_INIT_Value) < %d * sizeof(%s), "Pcd = %s.%s > Value in Dec exceed the array capability %s"); // From %s Line %s \n = ' % > (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCNa > me, > Pcd.TokenCName,Pcd.DatumType,Pcd.DefaultValueFromDecInfo[0],Pcd.Defa > ultValueFromDecInfo[1]) >=20 > + CApp =3D CApp + > '__STATIC_ASSERT(sizeof(%s_%s_INIT_Value) <=3D %d * sizeof(%s), "Pcd = %s.%s > Value in Dec exceed the array capability %s"); // From %s Line %s \n = ' % > (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCNa > me, > Pcd.TokenCName,Pcd.DatumType,Pcd.DefaultValueFromDecInfo[0],Pcd.Defa > ultValueFromDecInfo[1]) >=20 > CApp =3D CApp + ' PcdArraySize =3D > sizeof(%s_%s_INIT_Value);\n ' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName) >=20 > CApp =3D CApp + ' memcpy > (Pcd, %s_%s_INIT_Value,PcdArraySize);\n ' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName) >=20 > else: >=20 > if Pcd.Capacity[-1] !=3D "-1": >=20 > - CApp =3D CApp + '__STATIC_ASSERT(%d < %d * > sizeof(%s), "Pcd %s.%s Value in Dec exceed the array capability %s"); = // > From %s Line %s \n' % > (ValueSize,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,Pcd.DatumType,Pcd.DefaultValueFromDecInfo[0],Pcd.Defa > ultValueFromDecInfo[1]) >=20 > + CApp =3D CApp + '__STATIC_ASSERT(%d <=3D %d * > sizeof(%s), "Pcd %s.%s Value in Dec exceed the array capability %s"); = // > From %s Line %s \n' % > (ValueSize,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,Pcd.DatumType,Pcd.DefaultValueFromDecInfo[0],Pcd.Defa > ultValueFromDecInfo[1]) >=20 > CApp =3D CApp + ' PcdArraySize =3D %d;\n' % = ValueSize >=20 > CApp =3D CApp + ' Value =3D %s; // From DEC > Default Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), > Pcd.DefaultValueFromDec) >=20 > CApp =3D CApp + ' memcpy (Pcd, Value, > PcdArraySize);\n' >=20 > @@ -2204,7 +2204,7 @@ class DscBuildData(PlatformBuildClassObject): > if "{CODE(" in Value: >=20 > if Pcd.IsArray() and Pcd.Capacity[-1] !=3D = "-1": >=20 > pcdarraysize =3D Pcd.PcdArraySize() >=20 > - CApp =3D CApp + > '__STATIC_ASSERT(sizeof(%s_%s_%s_%s_Value) < %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.TokenSpaceGuidCN > ame, Pcd.TokenCName,Pcd.DatumType, valuefrom) >=20 > + 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.TokenSpaceGuidCN > ame, Pcd.TokenCName,Pcd.DatumType, valuefrom) >=20 > CApp =3D CApp+ ' PcdArraySize =3D > sizeof(%s_%s_%s_%s_Value);\n ' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) >=20 > CApp =3D CApp + ' memcpy (Pcd, > &%s_%s_%s_%s_Value,PcdArraySize);\n ' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) >=20 > else: >=20 > @@ -2217,12 +2217,12 @@ class DscBuildData(PlatformBuildClassObject): > pcdarraysize =3D Pcd.PcdArraySize() >=20 > if "{CODE(" in pcddefaultvalue: >=20 > if Pcd.Capacity[-1] !=3D "-1": >=20 > - CApp =3D CApp + > '__STATIC_ASSERT(sizeof(%s_%s_%s_%s_Value) < %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.TokenSpaceGuidCN > ame, Pcd.TokenCName,Pcd.DatumType,valuefrom) >=20 > + 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.TokenSpaceGuidCN > ame, Pcd.TokenCName,Pcd.DatumType,valuefrom) >=20 > CApp =3D CApp + ' PcdArraySize =3D > sizeof(%s_%s_%s_%s_Value);\n ' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) >=20 > CApp =3D CApp + ' memcpy > (Pcd, %s_%s_%s_%s_Value, PcdArraySize);\n' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) >=20 > else: >=20 > if Pcd.Capacity[-1] !=3D "-1": >=20 > - CApp =3D CApp + > '__STATIC_ASSERT(%d < %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed = the > array capability %s"); // From %s \n' % > (ValueSize,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,Pcd.DatumType,valuefrom) >=20 > + 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.TokenSpaceGuidCName, > Pcd.TokenCName,Pcd.DatumType,valuefrom) >=20 > CApp =3D CApp + ' PcdArraySize =3D %d;\n' = % > ValueSize >=20 > CApp =3D CApp + ' Value =3D %s; // > From DSC Default Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), > Pcd.DefaultFromDSC.get(TAB_DEFAULT, > {}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.DefaultValue) if > Pcd.DefaultFromDSC else Pcd.DefaultValue) >=20 > CApp =3D CApp + ' memcpy (Pcd, Value, > PcdArraySize);\n' >=20 > @@ -2238,7 +2238,7 @@ class DscBuildData(PlatformBuildClassObject): > if "{CODE(" in Value: >=20 > if Pcd.IsArray() and Pcd.Capacity[-1] !=3D = "-1": >=20 > pcdarraysize =3D Pcd.PcdArraySize() >=20 > - CApp =3D CApp + > '__STATIC_ASSERT(sizeof(%s_%s_%s_%s_Value) < %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.TokenSpaceGuidCN > ame, Pcd.TokenCName,Pcd.DatumType,valuefrom) >=20 > + 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.TokenSpaceGuidCN > ame, Pcd.TokenCName,Pcd.DatumType,valuefrom) >=20 > CApp =3D CApp + ' PcdArraySize =3D > sizeof(%s_%s_%s_%s_Value);\n '% (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) >=20 > CApp =3D CApp + ' memcpy (Pcd, > &%s_%s_%s_%s_Value, PcdArraySize);\n' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) >=20 > else: >=20 > @@ -2251,12 +2251,12 @@ class DscBuildData(PlatformBuildClassObject): > pcdarraysize =3D Pcd.PcdArraySize() >=20 > if "{CODE(" in pcddefaultvalue: >=20 > if Pcd.Capacity[-1] !=3D "-1": >=20 > - CApp =3D CApp + > '__STATIC_ASSERT(sizeof(%s_%s_%s_%s_Value) < %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.TokenSpaceGuidCN > ame, Pcd.TokenCName,Pcd.DatumType,valuefrom) >=20 > + 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.TokenSpaceGuidCN > ame, Pcd.TokenCName,Pcd.DatumType,valuefrom) >=20 > CApp + ' PcdArraySize =3D > sizeof(%s_%s_%s_%s_Value);\n ' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) >=20 > CApp =3D CApp + ' memcpy > (Pcd, %s_%s_%s_%s_Value, PcdArraySize);\n' % (Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,SkuName, DefaultStoreName) >=20 > else: >=20 > if Pcd.Capacity[-1] !=3D "-1": >=20 > - CApp =3D CApp + > '__STATIC_ASSERT(%d < %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed = the > array capability %s"); // From %s \n' % > (ValueSize,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName, > Pcd.TokenCName,Pcd.DatumType,valuefrom) >=20 > + 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.TokenSpaceGuidCName, > Pcd.TokenCName,Pcd.DatumType,valuefrom) >=20 > CApp =3D CApp + ' PcdArraySize =3D %d;\n' = % > ValueSize >=20 > CApp =3D CApp + ' Value =3D %s; // > From DSC Default Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), > Pcd.DscRawValue.get(TAB_DEFAULT, {}).get(TAB_DEFAULT_STORES_DEFAULT, > Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue) >=20 > CApp =3D CApp + ' memcpy (Pcd, Value, > PcdArraySize);\n' >=20 > -- > 2.25.1