Re: [edk2] [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255 warning

2017-11-06 Thread Gao, Liming
Jiewen:
  We plan to enable this option in new VS tool chain VS2017. So, we can keep 
DSC without the change, and enable this option after VS2017 tool chain is 
added. 

Thanks
Liming
>-Original Message-
>From: Yao, Jiewen
>Sent: Tuesday, November 07, 2017 2:00 PM
>To: Yao, Jiewen ; Song, BinX ;
>edk2-devel@lists.01.org
>Cc: Gao, Liming 
>Subject: RE: [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255 warning
>
>Sorry, let me clarify, if we believe C4255 can help catch more problem, and we
>fixed all problem, why not enable it in BaseTool directly.
>
>
>
>> -Original Message-
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
>Yao,
>> Jiewen
>> Sent: Tuesday, November 7, 2017 1:44 PM
>> To: Song, BinX ; edk2-devel@lists.01.org
>> Cc: Gao, Liming 
>> Subject: Re: [edk2] [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT
>C4255
>> warning
>>
>> Yes, I suggest we fix it.
>>
>> > -Original Message-
>> > From: Song, BinX
>> > Sent: Tuesday, November 7, 2017 1:43 PM
>> > To: Yao, Jiewen ; edk2-devel@lists.01.org
>> > Cc: Gao, Liming 
>> > Subject: RE: [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255
>warning
>> >
>> > Hi Jiewen,
>> >
>> > Do you mean we fix the problem after enable MSFT C4255 warning?
>> > If yes, I have fix them in related patch, such as MdeModulePkg.
>> >
>> > Best Regards,
>> > Bell Song
>> >
>> >
>> > > -Original Message-
>> > > From: Yao, Jiewen
>> > > Sent: Tuesday, November 7, 2017 1:39 PM
>> > > To: Song, BinX ; edk2-devel@lists.01.org
>> > > Cc: Gao, Liming 
>> > > Subject: RE: [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255
>> > > warning
>> > >
>> > > Hi
>> > > I suggest we fix the problem.
>> > >
>> > > > -Original Message-
>> > > > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf
>Of
>> > > Song,
>> > > > BinX
>> > > > Sent: Tuesday, November 7, 2017 1:35 PM
>> > > > To: edk2-devel@lists.01.org
>> > > > Cc: Gao, Liming 
>> > > > Subject: [edk2] [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT
>C4255
>> > > warning
>> > > >
>> > > > Enable MSFT C4255 warning
>> > > >
>> > > > From MSDN:
>> > > > Compiler Warning (level 4) C4255
>> > > > function' : no function prototype given: converting '()' to '(void)'
>> > > > The compiler did not find an explicit list of arguments to a function.
>> > > > This warning is for the C compiler only.
>> > > >
>> > > > Cc: Liming Gao 
>> > > > Contributed-under: TianoCore Contribution Agreement 1.1
>> > > > Signed-off-by: Bell Song 
>> > > > ---
>> > > >  IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc | 1 +
>> > > >  1 file changed, 1 insertion(+)
>> > > >
>> > > > diff --git a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
>> > > > b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
>> > > > index 6496dad..4b4d5b2 100644
>> > > > --- a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
>> > > > +++ b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
>> > > > @@ -95,3 +95,4 @@
>> > > >
>> > > >  [BuildOptions]
>> > > >*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
>> > > > +  MSFT:*_*_*_CC_FLAGS = /we4255
>> > > > --
>> > > > 2.10.2.windows.1
>> > > >
>> > > > ___
>> > > > edk2-devel mailing list
>> > > > edk2-devel@lists.01.org
>> > > > https://lists.01.org/mailman/listinfo/edk2-devel
>> ___
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] Riding the UEFI shell / enabling the platform for C developers

2017-11-06 Thread joaquin_conobolillo

Hi Tim,




With the disappearance of MSDOS as a simple, single threaded, unprotected 
operating system with full hardware access to user programs on upcoming 
personal computer models the UEFI shell was intended to be the successor of 
MSDOS.

please try  

https://github.com/JoaquinCono/VisualUEFIShell

for UEFI Shell Applications.




Regards,

JC






Sent from Surface





From: Joaquin Cono Bolillo
Sent: ‎Friday‎, ‎December‎ ‎2‎, ‎2016 ‎8‎:‎55‎ ‎AM
To: Tim Lewis






Hi Tim,

 

this is because StdLibC is not implemented carefully.

There will be a C Development Environment CdePkg on Github

beginning next year.

 

JC

 

 

Gesendet von Mail für Windows 10

 


Von: Tim Lewis
Gesendet: Friday, December 2, 2016 03:08 AM
An: edk2-devel@lists.01.org
Betreff: [edk2] Root Cause of Parse Failure With Redirected Input

 

  if (StrStr (TempLine, L"ShellCommand,") == TempLine) {

LoopVariable++;

  }

 

This line fails because, with redirected input, the file has the UCS-2 byte 
order mark, so the string "ShellCommand," is not at the beginning of the line. 
With the file, the byte order mark is not present.

 

Why?

 

 if (StreamingUnicode) {

   TempLine = ParseReturnStdInLine (FileHandle);

 } else {

   TempLine = ShellFileHandleReturnLine (FileHandle, );

 }

 

The Shell library function ShellFileHandleReturnLine will strip off the byte 
order mark. But the ParseReturnStdInLine does not. So the first character on 
the line is not 'S', it is the byte order mark.

 

Tim

___

edk2-devel mailing list

edk2-devel@lists.01.org

https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH] ShellPkg/dh: Fix wrong output when dumping PciRootBridgeIo

2017-11-06 Thread Ruiyu Ni
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 
Cc: Jaben Carsey 
---
 ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index d343f3352e..b7b0246ac9 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -682,7 +682,7 @@ PciRootBridgeIoDumpInformation(
 break;
   }
   if (Temp != NULL) {
-Temp2 = CatSPrint(RetVal, L"%s", Temp);
+Temp2 = CatSPrint(RetVal, L"\r\n%s", Temp);
 FreePool(Temp);
 FreePool(RetVal);
 RetVal = Temp2;
@@ -690,7 +690,7 @@ PciRootBridgeIoDumpInformation(
   }
 
   Temp2 = CatSPrint(RetVal,
-L"\r\n%%H%02x%016lx  %016lx  %02x%%N",
+L"%%H%02x%016lx  %016lx  %02x%%N",
 Configuration->SpecificFlag,
 Configuration->AddrRangeMin,
 Configuration->AddrRangeMax,
-- 
2.12.2.windows.2

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255 warning

2017-11-06 Thread Yao, Jiewen
Sorry, let me clarify, if we believe C4255 can help catch more problem, and we 
fixed all problem, why not enable it in BaseTool directly.



> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Yao,
> Jiewen
> Sent: Tuesday, November 7, 2017 1:44 PM
> To: Song, BinX ; edk2-devel@lists.01.org
> Cc: Gao, Liming 
> Subject: Re: [edk2] [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255
> warning
> 
> Yes, I suggest we fix it.
> 
> > -Original Message-
> > From: Song, BinX
> > Sent: Tuesday, November 7, 2017 1:43 PM
> > To: Yao, Jiewen ; edk2-devel@lists.01.org
> > Cc: Gao, Liming 
> > Subject: RE: [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255 warning
> >
> > Hi Jiewen,
> >
> > Do you mean we fix the problem after enable MSFT C4255 warning?
> > If yes, I have fix them in related patch, such as MdeModulePkg.
> >
> > Best Regards,
> > Bell Song
> >
> >
> > > -Original Message-
> > > From: Yao, Jiewen
> > > Sent: Tuesday, November 7, 2017 1:39 PM
> > > To: Song, BinX ; edk2-devel@lists.01.org
> > > Cc: Gao, Liming 
> > > Subject: RE: [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255
> > > warning
> > >
> > > Hi
> > > I suggest we fix the problem.
> > >
> > > > -Original Message-
> > > > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> > > Song,
> > > > BinX
> > > > Sent: Tuesday, November 7, 2017 1:35 PM
> > > > To: edk2-devel@lists.01.org
> > > > Cc: Gao, Liming 
> > > > Subject: [edk2] [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255
> > > warning
> > > >
> > > > Enable MSFT C4255 warning
> > > >
> > > > From MSDN:
> > > > Compiler Warning (level 4) C4255
> > > > function' : no function prototype given: converting '()' to '(void)'
> > > > The compiler did not find an explicit list of arguments to a function.
> > > > This warning is for the C compiler only.
> > > >
> > > > Cc: Liming Gao 
> > > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > > Signed-off-by: Bell Song 
> > > > ---
> > > >  IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> > > > b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> > > > index 6496dad..4b4d5b2 100644
> > > > --- a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> > > > +++ b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> > > > @@ -95,3 +95,4 @@
> > > >
> > > >  [BuildOptions]
> > > >*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
> > > > +  MSFT:*_*_*_CC_FLAGS = /we4255
> > > > --
> > > > 2.10.2.windows.1
> > > >
> > > > ___
> > > > edk2-devel mailing list
> > > > edk2-devel@lists.01.org
> > > > https://lists.01.org/mailman/listinfo/edk2-devel
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255 warning

2017-11-06 Thread Yao, Jiewen
Yes, I suggest we fix it.

> -Original Message-
> From: Song, BinX
> Sent: Tuesday, November 7, 2017 1:43 PM
> To: Yao, Jiewen ; edk2-devel@lists.01.org
> Cc: Gao, Liming 
> Subject: RE: [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255 warning
> 
> Hi Jiewen,
> 
> Do you mean we fix the problem after enable MSFT C4255 warning?
> If yes, I have fix them in related patch, such as MdeModulePkg.
> 
> Best Regards,
> Bell Song
> 
> 
> > -Original Message-
> > From: Yao, Jiewen
> > Sent: Tuesday, November 7, 2017 1:39 PM
> > To: Song, BinX ; edk2-devel@lists.01.org
> > Cc: Gao, Liming 
> > Subject: RE: [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255
> > warning
> >
> > Hi
> > I suggest we fix the problem.
> >
> > > -Original Message-
> > > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> > Song,
> > > BinX
> > > Sent: Tuesday, November 7, 2017 1:35 PM
> > > To: edk2-devel@lists.01.org
> > > Cc: Gao, Liming 
> > > Subject: [edk2] [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255
> > warning
> > >
> > > Enable MSFT C4255 warning
> > >
> > > From MSDN:
> > > Compiler Warning (level 4) C4255
> > > function' : no function prototype given: converting '()' to '(void)'
> > > The compiler did not find an explicit list of arguments to a function.
> > > This warning is for the C compiler only.
> > >
> > > Cc: Liming Gao 
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Bell Song 
> > > ---
> > >  IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> > > b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> > > index 6496dad..4b4d5b2 100644
> > > --- a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> > > +++ b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> > > @@ -95,3 +95,4 @@
> > >
> > >  [BuildOptions]
> > >*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
> > > +  MSFT:*_*_*_CC_FLAGS = /we4255
> > > --
> > > 2.10.2.windows.1
> > >
> > > ___
> > > edk2-devel mailing list
> > > edk2-devel@lists.01.org
> > > https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255 warning

2017-11-06 Thread Song, BinX
Hi Jiewen,

Do you mean we fix the problem after enable MSFT C4255 warning?
If yes, I have fix them in related patch, such as MdeModulePkg.

Best Regards,
Bell Song


> -Original Message-
> From: Yao, Jiewen
> Sent: Tuesday, November 7, 2017 1:39 PM
> To: Song, BinX ; edk2-devel@lists.01.org
> Cc: Gao, Liming 
> Subject: RE: [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255
> warning
> 
> Hi
> I suggest we fix the problem.
> 
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Song,
> > BinX
> > Sent: Tuesday, November 7, 2017 1:35 PM
> > To: edk2-devel@lists.01.org
> > Cc: Gao, Liming 
> > Subject: [edk2] [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255
> warning
> >
> > Enable MSFT C4255 warning
> >
> > From MSDN:
> > Compiler Warning (level 4) C4255
> > function' : no function prototype given: converting '()' to '(void)'
> > The compiler did not find an explicit list of arguments to a function.
> > This warning is for the C compiler only.
> >
> > Cc: Liming Gao 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Bell Song 
> > ---
> >  IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> > b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> > index 6496dad..4b4d5b2 100644
> > --- a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> > +++ b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> > @@ -95,3 +95,4 @@
> >
> >  [BuildOptions]
> >*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
> > +  MSFT:*_*_*_CC_FLAGS = /we4255
> > --
> > 2.10.2.windows.1
> >
> > ___
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255 warning

2017-11-06 Thread Yao, Jiewen
Hi
I suggest we fix the problem.

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Song,
> BinX
> Sent: Tuesday, November 7, 2017 1:35 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming 
> Subject: [edk2] [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255 warning
> 
> Enable MSFT C4255 warning
> 
> From MSDN:
> Compiler Warning (level 4) C4255
> function' : no function prototype given: converting '()' to '(void)'
> The compiler did not find an explicit list of arguments to a function.
> This warning is for the C compiler only.
> 
> Cc: Liming Gao 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Bell Song 
> ---
>  IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> index 6496dad..4b4d5b2 100644
> --- a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> +++ b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> @@ -95,3 +95,4 @@
> 
>  [BuildOptions]
>*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
> +  MSFT:*_*_*_CC_FLAGS = /we4255
> --
> 2.10.2.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 04/14] IntelFsp2Pkg: Enable MSFT C4255 warning

2017-11-06 Thread Yao, Jiewen
Hi
I suggest we fix the problem.

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Song,
> BinX
> Sent: Tuesday, November 7, 2017 1:35 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming 
> Subject: [edk2] [PATCH 04/14] IntelFsp2Pkg: Enable MSFT C4255 warning
> 
> Enable MSFT C4255 warning
> 
> From MSDN:
> Compiler Warning (level 4) C4255
> function' : no function prototype given: converting '()' to '(void)'
> The compiler did not find an explicit list of arguments to a function.
> This warning is for the C compiler only.
> 
> Cc: Liming Gao 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Bell Song 
> ---
>  IntelFsp2Pkg/IntelFsp2Pkg.dsc | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/IntelFsp2Pkg/IntelFsp2Pkg.dsc b/IntelFsp2Pkg/IntelFsp2Pkg.dsc
> index 1469d35..770cc01 100644
> --- a/IntelFsp2Pkg/IntelFsp2Pkg.dsc
> +++ b/IntelFsp2Pkg/IntelFsp2Pkg.dsc
> @@ -80,3 +80,4 @@
> 
>  [BuildOptions]
>*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
> +  MSFT:*_*_*_CC_FLAGS = /we4255
> --
> 2.10.2.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 12/14] SignedCapsulePkg: Enable MSFT C4255 warning

2017-11-06 Thread Yao, Jiewen
Hi
I suggest we fix the problem.

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Song,
> BinX
> Sent: Tuesday, November 7, 2017 1:35 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming 
> Subject: [edk2] [PATCH 12/14] SignedCapsulePkg: Enable MSFT C4255 warning
> 
> Enable MSFT C4255 warning
> 
> From MSDN:
> Compiler Warning (level 4) C4255
> function' : no function prototype given: converting '()' to '(void)'
> The compiler did not find an explicit list of arguments to a function.
> This warning is for the C compiler only.
> 
> Cc: Liming Gao 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Bell Song 
> ---
>  SignedCapsulePkg/SignedCapsulePkg.dsc | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/SignedCapsulePkg/SignedCapsulePkg.dsc
> b/SignedCapsulePkg/SignedCapsulePkg.dsc
> index 7ea74d7..4d24db2 100644
> --- a/SignedCapsulePkg/SignedCapsulePkg.dsc
> +++ b/SignedCapsulePkg/SignedCapsulePkg.dsc
> @@ -208,3 +208,4 @@
> 
>  [BuildOptions]
>*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
> +  MSFT:*_*_*_CC_FLAGS = /we4255
> --
> 2.10.2.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] PcAtChipsetPkg/IsaAcpiDxe: Restore PCI attributes correctly

2017-11-06 Thread Ni, Ruiyu
Laszlo,
Sure I will add the Bugzilla url in the commit message.

Steven,
Could you please check whether this patch can fix your "reconnect -r" hang?

Thanks/Ray

> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com]
> Sent: Tuesday, November 7, 2017 7:23 AM
> To: Ni, Ruiyu ; edk2-devel@lists.01.org
> Cc: Zeng, Star ; Shi, Steven 
> Subject: Re: [PATCH] PcAtChipsetPkg/IsaAcpiDxe: Restore PCI attributes
> correctly
> 
> Hi Ray,
> 
> On 11/03/17 09:28, Ruiyu Ni wrote:
> > The original code enables some BITs in PCI attributes in Start(), but
> > wrongly to disable these BITs in Stop().
> >
> > The correct behavior is to save the original PCI attributes before
> > enables some BITs in Start(), and restore to original value in Stop().
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ruiyu Ni 
> > Cc: Star Zeng 
> > Cc: Laszlo Ersek 
> > ---
> >  PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c | 44
> > +
> > PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.h |  3 ++-
> >  2 files changed, 25 insertions(+), 22 deletions(-)
> 
> Is this for ?
> 
> If so, can you please add the reference to the commit message?
> 
> Also, I think we should ask Steven to test the patch. (CC'd.)
> 
> I'll try to comment more later.
> 
> Thanks
> Laszlo
> 
> 
> >
> > diff --git a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c
> > b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c
> > index 32381b112d..60d2fb5a5b 100644
> > --- a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c
> > +++ b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c
> > @@ -172,6 +172,7 @@ PcatIsaAcpiDriverBindingStart (
> >EFI_PCI_IO_PROTOCOL  *PciIo;
> >PCAT_ISA_ACPI_DEV*PcatIsaAcpiDev;
> >UINT64   Supports;
> > +  UINT64   OriginalAttributes;
> >BOOLEAN  Enabled;
> >
> >Enabled = FALSE;
> > @@ -210,9 +211,18 @@ PcatIsaAcpiDriverBindingStart (
> >if (Supports == 0 || Supports == (EFI_PCI_IO_ATTRIBUTE_ISA_IO |
> EFI_PCI_IO_ATTRIBUTE_ISA_IO_16)) {
> >  Status = EFI_UNSUPPORTED;
> >  goto Done;
> > -  }
> > +  }
> > +
> > +  Status = PciIo->Attributes (
> > +PciIo,
> > +EfiPciIoAttributeOperationGet,
> > +0,
> > +
> > +);
> > +  if (EFI_ERROR (Status)) {
> > +goto Done;
> > +  }
> >
> > -  Enabled = TRUE;
> >Status = PciIo->Attributes (
> >  PciIo,
> >  EfiPciIoAttributeOperationEnable, @@ -222,7
> > +232,8 @@ PcatIsaAcpiDriverBindingStart (
> >if (EFI_ERROR (Status)) {
> >  goto Done;
> >}
> > -
> > +
> > +  Enabled = TRUE;
> >//
> >// Allocate memory for the PCAT ISA ACPI Device structure
> >//
> > @@ -239,9 +250,10 @@ PcatIsaAcpiDriverBindingStart (
> >//
> >// Initialize the PCAT ISA ACPI Device structure
> >//
> > -  PcatIsaAcpiDev->Signature = PCAT_ISA_ACPI_DEV_SIGNATURE;
> > -  PcatIsaAcpiDev->Handle= Controller;
> > -  PcatIsaAcpiDev->PciIo = PciIo;
> > +  PcatIsaAcpiDev->Signature = PCAT_ISA_ACPI_DEV_SIGNATURE;
> > +  PcatIsaAcpiDev->Handle= Controller;
> > +  PcatIsaAcpiDev->PciIo = PciIo;
> > +  PcatIsaAcpiDev->OriginalAttribute = OriginalAttributes;
> >
> >//
> >// Initialize PcatIsaAcpiDeviceList @@ -274,8 +286,8 @@ Done:
> >  if (PciIo != NULL && Enabled) {
> >PciIo->Attributes (
> > PciIo,
> > -   EfiPciIoAttributeOperationDisable,
> > -   EFI_PCI_DEVICE_ENABLE | Supports |
> EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO,
> > +   EfiPciIoAttributeOperationSet,
> > +   OriginalAttributes,
> > NULL
> > );
> >  }
> > @@ -321,7 +333,6 @@ PcatIsaAcpiDriverBindingStop (
> >EFI_STATUS Status;
> >EFI_ISA_ACPI_PROTOCOL  *IsaAcpi;
> >PCAT_ISA_ACPI_DEV  *PcatIsaAcpiDev;
> > -  UINT64 Supports;
> >
> >//
> >// Get the ISA ACPI Protocol Interface @@ -348,23 +359,14 @@
> > PcatIsaAcpiDriverBindingStop (
> >//
> >Status = PcatIsaAcpiDev->PciIo->Attributes (
> >  PcatIsaAcpiDev->PciIo,
> > -EfiPciIoAttributeOperationSupported,
> > -0,
> > -
> > +EfiPciIoAttributeOperationSet,
> > +PcatIsaAcpiDev->OriginalAttribute,
> > +0
> >  );
> >if (EFI_ERROR (Status)) {
> >  return Status;
> >}
> >
> > -  Supports &= (UINT64) (EFI_PCI_IO_ATTRIBUTE_ISA_IO |
> > EFI_PCI_IO_ATTRIBUTE_ISA_IO_16);
> > -
> > -  

Re: [edk2] [PATCH v2 2/3] ShellPkg: Fix misuses of AllocateCopyPool

2017-11-06 Thread Ni, Ruiyu
Reviewed-by: Ruiyu Ni 

Thanks/Ray

> -Original Message-
> From: Wang, Jian J
> Sent: Tuesday, November 7, 2017 1:11 PM
> To: edk2-devel@lists.01.org
> Cc: Carsey, Jaben ; Ni, Ruiyu ;
> Bi, Dandan 
> Subject: [PATCH v2 2/3] ShellPkg: Fix misuses of AllocateCopyPool
> 
> > v2:
> > a. Use ReallocatePool instead of allocating then copying wherever
> applicable
> 
> AllocateCopyPool(AllocationSize, *Buffer) will copy "AllocationSize" bytes of
> memory from old "Buffer" to new allocated one. If "AllocationSize" is bigger
> than size of "Buffer", heap memory overflow occurs during copy.
> 
> One solution is to allocate pool first then copy the necessary bytes to new
> memory. Another is using ReallocatePool instead if old buffer will be freed
> on spot.
> 
> Cc: Jaben Carsey 
> Cc: Ruiyu Ni 
> Cc: Bi Dandan 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang 
> ---
>  ShellPkg/Application/Shell/Shell.c | 4 +++-
>  ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c | 7
> +--
>  2 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/ShellPkg/Application/Shell/Shell.c
> b/ShellPkg/Application/Shell/Shell.c
> index 5471930ba1..656206fdce 100644
> --- a/ShellPkg/Application/Shell/Shell.c
> +++ b/ShellPkg/Application/Shell/Shell.c
> @@ -1646,7 +1646,7 @@ ShellConvertVariables (
>//
>// now do the replacements...
>//
> -  NewCommandLine1 = AllocateCopyPool(NewSize, OriginalCommandLine);
> +  NewCommandLine1 = AllocateZeroPool (NewSize);
>NewCommandLine2 = AllocateZeroPool(NewSize);
>ItemTemp= AllocateZeroPool(ItemSize+(2*sizeof(CHAR16)));
>if (NewCommandLine1 == NULL || NewCommandLine2 == NULL ||
> ItemTemp == NULL) {
> @@ -1655,6 +1655,8 @@ ShellConvertVariables (
>  SHELL_FREE_NON_NULL(ItemTemp);
>  return (NULL);
>}
> +  CopyMem (NewCommandLine1, OriginalCommandLine, StrSize
> (OriginalCommandLine));
> +
>for (MasterEnvList = EfiShellGetEnv(NULL)
>  ;  MasterEnvList != NULL && *MasterEnvList != CHAR_NULL
>  ;  MasterEnvList += StrLen(MasterEnvList) + 1
> diff --git
> a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> index 1122c89b8b..ee3db63358 100644
> ---
> a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> +++
> b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> @@ -143,10 +143,11 @@ UpdateOptionalData(
>  OriginalOptionDataSize += (*(UINT16*)(OriginalData + sizeof(UINT32)));
>  OriginalOptionDataSize -= OriginalSize;
>  NewSize = OriginalSize - OriginalOptionDataSize + DataSize;
> -NewData = AllocateCopyPool(NewSize, OriginalData);
> +NewData = AllocatePool(NewSize);
>  if (NewData == NULL) {
>Status = EFI_OUT_OF_RESOURCES;
>  } else {
> +  CopyMem (NewData, OriginalData, OriginalSize - OriginalOptionDataSize);
>CopyMem(NewData + OriginalSize - OriginalOptionDataSize, Data,
> DataSize);
>  }
>}
> @@ -1120,11 +1121,13 @@ BcfgAddOpt(
>  // Now we know how many EFI_INPUT_KEY structs we need to attach to
> the end of the EFI_KEY_OPTION struct.
>  // Re-allocate with the added information.
>  //
> -KeyOptionBuffer = AllocateCopyPool(sizeof(EFI_KEY_OPTION) +
> (sizeof(EFI_INPUT_KEY) * NewKeyOption.KeyData.Options.InputKeyCount),
> );
> +KeyOptionBuffer = AllocatePool (sizeof(EFI_KEY_OPTION) +
> (sizeof(EFI_INPUT_KEY) * NewKeyOption.KeyData.Options.InputKeyCount));
>  if (KeyOptionBuffer == NULL) {
>ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM),
> gShellBcfgHiiHandle, L"bcfg");
>ShellStatus = SHELL_OUT_OF_RESOURCES;
> +  return ShellStatus;
>  }
> +CopyMem (KeyOptionBuffer, ,
> sizeof(EFI_KEY_OPTION));
>}
>for (LoopCounter = 0 ; ShellStatus == SHELL_SUCCESS && LoopCounter <
> NewKeyOption.KeyData.Options.InputKeyCount; LoopCounter++) {
>  //
> --
> 2.14.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 14/14] UefiCpuPkg: Enable MSFT C4255 warning

2017-11-06 Thread Song, BinX
Enable MSFT C4255 warning

>From MSDN:
Compiler Warning (level 4) C4255
function' : no function prototype given: converting '()' to '(void)'
The compiler did not find an explicit list of arguments to a function.
This warning is for the C compiler only.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song 
---
 UefiCpuPkg/UefiCpuPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index 41cf809..a691ccc 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -156,3 +156,4 @@
 
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
+  MSFT:*_*_*_CC_FLAGS = /we4255
-- 
2.10.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 12/14] SignedCapsulePkg: Enable MSFT C4255 warning

2017-11-06 Thread Song, BinX
Enable MSFT C4255 warning

>From MSDN:
Compiler Warning (level 4) C4255
function' : no function prototype given: converting '()' to '(void)'
The compiler did not find an explicit list of arguments to a function.
This warning is for the C compiler only.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song 
---
 SignedCapsulePkg/SignedCapsulePkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/SignedCapsulePkg/SignedCapsulePkg.dsc 
b/SignedCapsulePkg/SignedCapsulePkg.dsc
index 7ea74d7..4d24db2 100644
--- a/SignedCapsulePkg/SignedCapsulePkg.dsc
+++ b/SignedCapsulePkg/SignedCapsulePkg.dsc
@@ -208,3 +208,4 @@
 
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
+  MSFT:*_*_*_CC_FLAGS = /we4255
-- 
2.10.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 13/14] SourceLevelDebugPkg: Enable MSFT C4255 warning

2017-11-06 Thread Song, BinX
Enable MSFT C4255 warning

>From MSDN:
Compiler Warning (level 4) C4255
function' : no function prototype given: converting '()' to '(void)'
The compiler did not find an explicit list of arguments to a function.
This warning is for the C compiler only.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song 
---
 SourceLevelDebugPkg/SourceLevelDebugPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/SourceLevelDebugPkg/SourceLevelDebugPkg.dsc 
b/SourceLevelDebugPkg/SourceLevelDebugPkg.dsc
index d9b1b84..e17976d 100644
--- a/SourceLevelDebugPkg/SourceLevelDebugPkg.dsc
+++ b/SourceLevelDebugPkg/SourceLevelDebugPkg.dsc
@@ -110,3 +110,4 @@
 
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
+  MSFT:*_*_*_CC_FLAGS = /we4255
-- 
2.10.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 07/14] MdePkg: Enable MSFT C4255 warning

2017-11-06 Thread Song, BinX
Enable MSFT C4255 warning

>From MSDN:
Compiler Warning (level 4) C4255
function' : no function prototype given: converting '()' to '(void)'
The compiler did not find an explicit list of arguments to a function.
This warning is for the C compiler only.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song 
---
 MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.c| 2 +-
 MdePkg/Library/BaseLib/X64/CpuBreakpoint.c | 2 +-
 MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c | 1 +
 MdePkg/MdePkg.dsc  | 1 +
 4 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.c 
b/MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.c
index f5df7f2..4f8c92d 100644
--- a/MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.c
+++ b/MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.c
@@ -19,7 +19,7 @@
   Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics.
 **/
 
-void __debugbreak ();
+void __debugbreak (VOID);
 
 #pragma intrinsic(__debugbreak)
 
diff --git a/MdePkg/Library/BaseLib/X64/CpuBreakpoint.c 
b/MdePkg/Library/BaseLib/X64/CpuBreakpoint.c
index d654f84..7d0cf4c 100644
--- a/MdePkg/Library/BaseLib/X64/CpuBreakpoint.c
+++ b/MdePkg/Library/BaseLib/X64/CpuBreakpoint.c
@@ -17,7 +17,7 @@
   Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics.
 **/
 
-void __debugbreak ();
+void __debugbreak (VOID);
 
 #pragma intrinsic(__debugbreak)
 
diff --git 
a/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c 
b/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c
index 8b8e528..744201b 100644
--- a/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c
+++ b/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c
@@ -38,6 +38,7 @@ EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER 
*mExtractGetInfoHandlerTable = NULL;
 RETURN_STATUS
 EFIAPI
 ReallocateExtractHandlerTable (
+  VOID
   )
 { 
   //
diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index 8f57263..9032836 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc
@@ -189,3 +189,4 @@
 
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
+  MSFT:*_*_*_CC_FLAGS = /we4255
-- 
2.10.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 05/14] IntelFsp2WrapperPkg: Enable MSFT C4255 warning

2017-11-06 Thread Song, BinX
Enable MSFT C4255 warning

>From MSDN:
Compiler Warning (level 4) C4255
function' : no function prototype given: converting '()' to '(void)'
The compiler did not find an explicit list of arguments to a function.
This warning is for the C compiler only.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song 
---
 IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc 
b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
index 6496dad..4b4d5b2 100644
--- a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
+++ b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
@@ -95,3 +95,4 @@
 
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
+  MSFT:*_*_*_CC_FLAGS = /we4255
-- 
2.10.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 06/14] MdeModulePkg: Enable MSFT C4255 warning

2017-11-06 Thread Song, BinX
Enable MSFT C4255 warning

>From MSDN:
Compiler Warning (level 4) C4255
function' : no function prototype given: converting '()' to '(void)'
The compiler did not find an explicit list of arguments to a function.
This warning is for the C compiler only.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song 
---
 MdeModulePkg/Include/Library/PlatformVarCleanupLib.h| 1 +
 .../Library/BrotliCustomDecompressLib/GuidedSectionExtraction.c | 1 +
 .../Library/DxeSecurityManagementLib/DxeSecurityManagementLib.c | 2 ++
 .../Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c| 1 +
 MdeModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c  | 1 +
 MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c  | 1 +
 MdeModulePkg/MdeModulePkg.dsc   | 2 +-
 MdeModulePkg/Universal/SetupBrowserDxe/Expression.c | 1 +
 8 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Include/Library/PlatformVarCleanupLib.h 
b/MdeModulePkg/Include/Library/PlatformVarCleanupLib.h
index a4691f0..1d642f6 100644
--- a/MdeModulePkg/Include/Library/PlatformVarCleanupLib.h
+++ b/MdeModulePkg/Include/Library/PlatformVarCleanupLib.h
@@ -32,6 +32,7 @@ typedef enum {
 VAR_ERROR_FLAG
 EFIAPI
 GetLastBootVarErrorFlag (
+  VOID
   );
 
 /**
diff --git 
a/MdeModulePkg/Library/BrotliCustomDecompressLib/GuidedSectionExtraction.c 
b/MdeModulePkg/Library/BrotliCustomDecompressLib/GuidedSectionExtraction.c
index 427adb8..c623e1e 100644
--- a/MdeModulePkg/Library/BrotliCustomDecompressLib/GuidedSectionExtraction.c
+++ b/MdeModulePkg/Library/BrotliCustomDecompressLib/GuidedSectionExtraction.c
@@ -186,6 +186,7 @@ BrotliGuidedSectionExtraction (
 EFI_STATUS
 EFIAPI
 BrotliDecompressLibConstructor (
+  VOID
   )
 {
   return ExtractGuidedSectionRegisterHandlers (
diff --git 
a/MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.c 
b/MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.c
index b96d786..aa4d93b 100644
--- a/MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.c
+++ b/MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.c
@@ -61,6 +61,7 @@ SECURITY2_INFO *mSecurity2Table  = NULL;
 RETURN_STATUS
 EFIAPI
 ReallocateSecurityHandlerTable (
+  VOID
   )
 {
   //
@@ -301,6 +302,7 @@ ExecuteSecurityHandlers (
 RETURN_STATUS
 EFIAPI
 ReallocateSecurity2HandlerTable (
+  VOID
   )
 {
   //
diff --git 
a/MdeModulePkg/Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c 
b/MdeModulePkg/Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c
index ada9a80..b02dc51 100644
--- a/MdeModulePkg/Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c
+++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c
@@ -207,6 +207,7 @@ LzmaArchGuidedSectionExtraction (
 EFI_STATUS
 EFIAPI
 LzmaArchDecompressLibConstructor (
+  VOID
   )
 {
   return ExtractGuidedSectionRegisterHandlers (
diff --git 
a/MdeModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c 
b/MdeModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c
index f19e0d2..7ef9fbb 100644
--- a/MdeModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c
+++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c
@@ -190,6 +190,7 @@ LzmaGuidedSectionExtraction (
 EFI_STATUS
 EFIAPI
 LzmaDecompressLibConstructor (
+  VOID
   )
 {
   return ExtractGuidedSectionRegisterHandlers (
diff --git a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c 
b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c
index c5fd30e..450b4b3 100644
--- a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c
+++ b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c
@@ -1187,6 +1187,7 @@ Done:
 VAR_ERROR_FLAG
 EFIAPI
 GetLastBootVarErrorFlag (
+  VOID
   )
 {
   return mLastVarErrorFlag;
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index ad34254..e0becab 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -490,4 +490,4 @@
 
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
-
+  MSFT:*_*_*_CC_FLAGS = /we4255
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c 
b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
index 901b35c..297741c 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
@@ -751,6 +751,7 @@ PopExpression (
 **/
 UINTN
 SaveExpressionEvaluationStackOffset (
+  VOID
   )
 {
   UINTN TempStackOffset;
-- 
2.10.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 04/14] IntelFsp2Pkg: Enable MSFT C4255 warning

2017-11-06 Thread Song, BinX
Enable MSFT C4255 warning

>From MSDN:
Compiler Warning (level 4) C4255
function' : no function prototype given: converting '()' to '(void)'
The compiler did not find an explicit list of arguments to a function.
This warning is for the C compiler only.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song 
---
 IntelFsp2Pkg/IntelFsp2Pkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/IntelFsp2Pkg/IntelFsp2Pkg.dsc b/IntelFsp2Pkg/IntelFsp2Pkg.dsc
index 1469d35..770cc01 100644
--- a/IntelFsp2Pkg/IntelFsp2Pkg.dsc
+++ b/IntelFsp2Pkg/IntelFsp2Pkg.dsc
@@ -80,3 +80,4 @@
 
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
+  MSFT:*_*_*_CC_FLAGS = /we4255
-- 
2.10.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 01/14] FatPkg: Enable MSFT C4255 warning

2017-11-06 Thread Song, BinX
Enable MSFT C4255 warning

>From MSDN:
Compiler Warning (level 4) C4255
function' : no function prototype given: converting '()' to '(void)'
The compiler did not find an explicit list of arguments to a function.
This warning is for the C compiler only.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song 
---
 FatPkg/FatPkg.dsc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/FatPkg/FatPkg.dsc b/FatPkg/FatPkg.dsc
index 841201c..243f547 100644
--- a/FatPkg/FatPkg.dsc
+++ b/FatPkg/FatPkg.dsc
@@ -85,3 +85,6 @@
 [Components]
   FatPkg/FatPei/FatPei.inf
   FatPkg/EnhancedFatDxe/Fat.inf
+
+[BuildOptions]
+  MSFT:*_*_*_CC_FLAGS = /we4255
-- 
2.10.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 08/14] NetworkPkg: Enable MSFT C4255 warning

2017-11-06 Thread Song, BinX
Enable MSFT C4255 warning

>From MSDN:
Compiler Warning (level 4) C4255
function' : no function prototype given: converting '()' to '(void)'
The compiler did not find an explicit list of arguments to a function.
This warning is for the C compiler only.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song 
---
 NetworkPkg/IScsiDxe/IScsiDriver.c | 1 +
 NetworkPkg/NetworkPkg.dsc | 1 +
 2 files changed, 2 insertions(+)

diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c 
b/NetworkPkg/IScsiDxe/IScsiDriver.c
index fbeef97..a0ece3a 100644
--- a/NetworkPkg/IScsiDxe/IScsiDriver.c
+++ b/NetworkPkg/IScsiDxe/IScsiDriver.c
@@ -87,6 +87,7 @@ IScsiIsDevicePathSupported (
 **/
 EFI_STATUS
 IScsiCheckAip (
+  VOID
   )
 {
   UINTNAipHandleCount;
diff --git a/NetworkPkg/NetworkPkg.dsc b/NetworkPkg/NetworkPkg.dsc
index b193f5f..f8c65cc 100644
--- a/NetworkPkg/NetworkPkg.dsc
+++ b/NetworkPkg/NetworkPkg.dsc
@@ -128,3 +128,4 @@
 
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
+  MSFT:*_*_*_CC_FLAGS = /we4255
-- 
2.10.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 11/14] ShellPkg: Enable MSFT C4255 warning

2017-11-06 Thread Song, BinX
Enable MSFT C4255 warning

>From MSDN:
Compiler Warning (level 4) C4255
function' : no function prototype given: converting '()' to '(void)'
The compiler did not find an explicit list of arguments to a function.
This warning is for the C compiler only.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song 
---
 ShellPkg/Application/Shell/Shell.c   | 1 +
 ShellPkg/Application/Shell/ShellProtocol.c   | 2 ++
 ShellPkg/Library/UefiShellLib/UefiShellLib.c | 1 +
 ShellPkg/ShellPkg.dsc| 1 +
 4 files changed, 5 insertions(+)

diff --git a/ShellPkg/Application/Shell/Shell.c 
b/ShellPkg/Application/Shell/Shell.c
index 5471930..4f84bb3 100644
--- a/ShellPkg/Application/Shell/Shell.c
+++ b/ShellPkg/Application/Shell/Shell.c
@@ -726,6 +726,7 @@ FreeResources:
 **/
 EFI_STATUS
 SetBuiltInAlias(
+  VOID
   )
 {
   EFI_STATUS  Status;
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c 
b/ShellPkg/Application/Shell/ShellProtocol.c
index 5e34b8d..dc3deee 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/ShellPkg/Application/Shell/ShellProtocol.c
@@ -1679,6 +1679,7 @@ InternalShellExecute(
 STATIC
 BOOLEAN
 NestingEnabled(
+  VOID
 )
 {
   EFI_STATUS  Status;
@@ -3286,6 +3287,7 @@ EfiShellIsRootShell(
 **/
 CHAR16 *
 InternalEfiShellGetListAlias(
+  VOID
   )
 {
   
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c 
b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 25d3e33..677791c 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -369,6 +369,7 @@ ShellLibDestructor (
 EFI_STATUS
 EFIAPI
 ShellInitialize (
+  VOID
   )
 {
   EFI_STATUS Status;
diff --git a/ShellPkg/ShellPkg.dsc b/ShellPkg/ShellPkg.dsc
index ed6ac43..d56edb7 100644
--- a/ShellPkg/ShellPkg.dsc
+++ b/ShellPkg/ShellPkg.dsc
@@ -133,3 +133,4 @@
 
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
+  MSFT:*_*_*_CC_FLAGS = /we4255
-- 
2.10.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 09/14] PcAtChipsetPkg: Enable MSFT C4255 warning

2017-11-06 Thread Song, BinX
Enable MSFT C4255 warning

>From MSDN:
Compiler Warning (level 4) C4255
function' : no function prototype given: converting '()' to '(void)'
The compiler did not find an explicit list of arguments to a function.
This warning is for the C compiler only.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song 
---
 PcAtChipsetPkg/PcAtChipsetPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dsc 
b/PcAtChipsetPkg/PcAtChipsetPkg.dsc
index b740f00..19e892f 100644
--- a/PcAtChipsetPkg/PcAtChipsetPkg.dsc
+++ b/PcAtChipsetPkg/PcAtChipsetPkg.dsc
@@ -61,3 +61,4 @@
 
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
+  MSFT:*_*_*_CC_FLAGS = /we4255
-- 
2.10.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 10/14] SecurityPkg: Enable MSFT C4255 warning

2017-11-06 Thread Song, BinX
Enable MSFT C4255 warning

>From MSDN:
Compiler Warning (level 4) C4255
function' : no function prototype given: converting '()' to '(void)'
The compiler did not find an explicit list of arguments to a function.
This warning is for the C compiler only.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song 
---
 SecurityPkg/SecurityPkg.dsc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc
index bb7147e..a90914d 100644
--- a/SecurityPkg/SecurityPkg.dsc
+++ b/SecurityPkg/SecurityPkg.dsc
@@ -336,4 +336,4 @@
MSFT:*_*_IA32_DLINK_FLAGS = /ALIGN:256
   INTEL:*_*_IA32_DLINK_FLAGS = /ALIGN:256
 *_*_*_CC_FLAGS   = -D DISABLE_NEW_DEPRECATED_INTERFACES
-
+   MSFT:*_*_*_CC_FLAGS   = /we4255
-- 
2.10.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 02/14] IntelFrameworkModulePkg: Enable MSFT C4255 warning

2017-11-06 Thread Song, BinX
Enable MSFT C4255 warning

>From MSDN:
Compiler Warning (level 4) C4255
function' : no function prototype given: converting '()' to '(void)'
The compiler did not find an explicit list of arguments to a function.
This warning is for the C compiler only.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song 
---
 IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc  | 1 +
 .../BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c  | 1 +
 .../Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c | 1 +
 .../Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c| 1 +
 4 files changed, 4 insertions(+)

diff --git a/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc 
b/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc
index a9a01aa..0cc6184 100644
--- a/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc
+++ b/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc
@@ -199,3 +199,4 @@
 
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
+  MSFT:*_*_*_CC_FLAGS = /we4255
diff --git 
a/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
 
b/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
index 5d64f02..cb009e7 100644
--- 
a/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
+++ 
b/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
@@ -1040,6 +1040,7 @@ TianoDecompress (
 RETURN_STATUS
 EFIAPI
 TianoDecompressLibConstructor (
+  VOID
 )
 {
   return ExtractGuidedSectionRegisterHandlers (
diff --git 
a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c
 
b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c
index ada9a80..b02dc51 100644
--- 
a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c
+++ 
b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c
@@ -207,6 +207,7 @@ LzmaArchGuidedSectionExtraction (
 EFI_STATUS
 EFIAPI
 LzmaArchDecompressLibConstructor (
+  VOID
   )
 {
   return ExtractGuidedSectionRegisterHandlers (
diff --git 
a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c
 
b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c
index f19e0d2..7ef9fbb 100644
--- 
a/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c
+++ 
b/IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c
@@ -190,6 +190,7 @@ LzmaGuidedSectionExtraction (
 EFI_STATUS
 EFIAPI
 LzmaDecompressLibConstructor (
+  VOID
   )
 {
   return ExtractGuidedSectionRegisterHandlers (
-- 
2.10.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 03/14] IntelFrameworkPkg: Enable MSFT C4255 warning

2017-11-06 Thread Song, BinX
Enable MSFT C4255 warning

>From MSDN:
Compiler Warning (level 4) C4255
function' : no function prototype given: converting '()' to '(void)'
The compiler did not find an explicit list of arguments to a function.
This warning is for the C compiler only.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song 
---
 IntelFrameworkPkg/IntelFrameworkPkg.dsc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/IntelFrameworkPkg/IntelFrameworkPkg.dsc 
b/IntelFrameworkPkg/IntelFrameworkPkg.dsc
index 2985d38..c9940e4 100644
--- a/IntelFrameworkPkg/IntelFrameworkPkg.dsc
+++ b/IntelFrameworkPkg/IntelFrameworkPkg.dsc
@@ -72,4 +72,4 @@
 
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
-
+  MSFT:*_*_*_CC_FLAGS = /we4255
-- 
2.10.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 00/14] Enable MSFT C4255 warning

2017-11-06 Thread Song, BinX
Enable MSFT C4255 warning.

>From MSDN:
Compiler Warning (level 4) C4255
function' : no function prototype given: converting '()' to '(void)'
The compiler did not find an explicit list of arguments to a function.
This warning is for the C compiler only.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song 
---
Bell Song (14):
  FatPkg: Enable MSFT C4255 warning
  IntelFrameworkModulePkg: Enable MSFT C4255 warning
  IntelFrameworkPkg: Enable MSFT C4255 warning
  IntelFsp2Pkg: Enable MSFT C4255 warning
  IntelFsp2WrapperPkg: Enable MSFT C4255 warning
  MdeModulePkg: Enable MSFT C4255 warning
  MdePkg: Enable MSFT C4255 warning
  NetworkPkg: Enable MSFT C4255 warning
  PcAtChipsetPkg: Enable MSFT C4255 warning
  SecurityPkg: Enable MSFT C4255 warning
  ShellPkg: Enable MSFT C4255 warning
  SignedCapsulePkg: Enable MSFT C4255 warning
  SourceLevelDebugPkg: Enable MSFT C4255 warning
  UefiCpuPkg: Enable MSFT C4255 warning

 FatPkg/FatPkg.dsc  | 3 +++
 IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc| 1 +
 .../BaseUefiTianoCustomDecompressLib.c | 1 +
 .../Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c   | 1 +
 .../Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c  | 1 +
 IntelFrameworkPkg/IntelFrameworkPkg.dsc| 2 +-
 IntelFsp2Pkg/IntelFsp2Pkg.dsc  | 1 +
 IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc| 1 +
 MdeModulePkg/Include/Library/PlatformVarCleanupLib.h   | 1 +
 .../Library/BrotliCustomDecompressLib/GuidedSectionExtraction.c| 1 +
 .../Library/DxeSecurityManagementLib/DxeSecurityManagementLib.c| 2 ++
 .../Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c   | 1 +
 MdeModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c | 1 +
 MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c | 1 +
 MdeModulePkg/MdeModulePkg.dsc  | 2 +-
 MdeModulePkg/Universal/SetupBrowserDxe/Expression.c| 1 +
 MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.c| 2 +-
 MdePkg/Library/BaseLib/X64/CpuBreakpoint.c | 2 +-
 MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c | 1 +
 MdePkg/MdePkg.dsc  | 1 +
 NetworkPkg/IScsiDxe/IScsiDriver.c  | 1 +
 NetworkPkg/NetworkPkg.dsc  | 1 +
 PcAtChipsetPkg/PcAtChipsetPkg.dsc  | 1 +
 SecurityPkg/SecurityPkg.dsc| 2 +-
 ShellPkg/Application/Shell/Shell.c | 1 +
 ShellPkg/Application/Shell/ShellProtocol.c | 2 ++
 ShellPkg/Library/UefiShellLib/UefiShellLib.c   | 1 +
 ShellPkg/ShellPkg.dsc  | 1 +
 SignedCapsulePkg/SignedCapsulePkg.dsc  | 1 +
 SourceLevelDebugPkg/SourceLevelDebugPkg.dsc| 1 +
 UefiCpuPkg/UefiCpuPkg.dsc  | 1 +
 31 files changed, 35 insertions(+), 5 deletions(-)

-- 
2.10.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 2/3] ShellPkg: Fix misuses of AllocateCopyPool

2017-11-06 Thread Jian J Wang
> v2:
> a. Use ReallocatePool instead of allocating then copying wherever applicable

AllocateCopyPool(AllocationSize, *Buffer) will copy "AllocationSize" bytes of
memory from old "Buffer" to new allocated one. If "AllocationSize" is bigger
than size of "Buffer", heap memory overflow occurs during copy.

One solution is to allocate pool first then copy the necessary bytes to new
memory. Another is using ReallocatePool instead if old buffer will be freed
on spot.

Cc: Jaben Carsey 
Cc: Ruiyu Ni 
Cc: Bi Dandan 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang 
---
 ShellPkg/Application/Shell/Shell.c | 4 +++-
 ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c | 7 +--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/ShellPkg/Application/Shell/Shell.c 
b/ShellPkg/Application/Shell/Shell.c
index 5471930ba1..656206fdce 100644
--- a/ShellPkg/Application/Shell/Shell.c
+++ b/ShellPkg/Application/Shell/Shell.c
@@ -1646,7 +1646,7 @@ ShellConvertVariables (
   //
   // now do the replacements...
   //
-  NewCommandLine1 = AllocateCopyPool(NewSize, OriginalCommandLine);
+  NewCommandLine1 = AllocateZeroPool (NewSize);
   NewCommandLine2 = AllocateZeroPool(NewSize);
   ItemTemp= AllocateZeroPool(ItemSize+(2*sizeof(CHAR16)));
   if (NewCommandLine1 == NULL || NewCommandLine2 == NULL || ItemTemp == NULL) {
@@ -1655,6 +1655,8 @@ ShellConvertVariables (
 SHELL_FREE_NON_NULL(ItemTemp);
 return (NULL);
   }
+  CopyMem (NewCommandLine1, OriginalCommandLine, StrSize 
(OriginalCommandLine));
+
   for (MasterEnvList = EfiShellGetEnv(NULL)
 ;  MasterEnvList != NULL && *MasterEnvList != CHAR_NULL
 ;  MasterEnvList += StrLen(MasterEnvList) + 1
diff --git a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c 
b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
index 1122c89b8b..ee3db63358 100644
--- a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
+++ b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
@@ -143,10 +143,11 @@ UpdateOptionalData(
 OriginalOptionDataSize += (*(UINT16*)(OriginalData + sizeof(UINT32)));
 OriginalOptionDataSize -= OriginalSize;
 NewSize = OriginalSize - OriginalOptionDataSize + DataSize;
-NewData = AllocateCopyPool(NewSize, OriginalData);
+NewData = AllocatePool(NewSize);
 if (NewData == NULL) {
   Status = EFI_OUT_OF_RESOURCES;
 } else {
+  CopyMem (NewData, OriginalData, OriginalSize - OriginalOptionDataSize);
   CopyMem(NewData + OriginalSize - OriginalOptionDataSize, Data, DataSize);
 }
   }
@@ -1120,11 +1121,13 @@ BcfgAddOpt(
 // Now we know how many EFI_INPUT_KEY structs we need to attach to the 
end of the EFI_KEY_OPTION struct.  
 // Re-allocate with the added information.
 //
-KeyOptionBuffer = AllocateCopyPool(sizeof(EFI_KEY_OPTION) + 
(sizeof(EFI_INPUT_KEY) * NewKeyOption.KeyData.Options.InputKeyCount), 
);
+KeyOptionBuffer = AllocatePool (sizeof(EFI_KEY_OPTION) + 
(sizeof(EFI_INPUT_KEY) * NewKeyOption.KeyData.Options.InputKeyCount));
 if (KeyOptionBuffer == NULL) {
   ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), 
gShellBcfgHiiHandle, L"bcfg");  
   ShellStatus = SHELL_OUT_OF_RESOURCES;
+  return ShellStatus;
 }
+CopyMem (KeyOptionBuffer, , sizeof(EFI_KEY_OPTION));
   }
   for (LoopCounter = 0 ; ShellStatus == SHELL_SUCCESS && LoopCounter < 
NewKeyOption.KeyData.Options.InputKeyCount; LoopCounter++) {
 //
-- 
2.14.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 1/3] MdeModulePkg: Fix misuses of AllocateCopyPool

2017-11-06 Thread Jian J Wang
>v2:
> a. Use ReallocatePool to replace AllocateCopyPool wherever applicable.

AllocateCopyPool(AllocationSize, *Buffer) will copy "AllocationSize" bytes of
memory from old "Buffer" to new allocated one. If "AllocationSize" is bigger
than size of "Buffer", heap memory overflow occurs during copy.

One solution is to allocate pool first then copy the necessary bytes to new
memory. Another is using ReallocatePool instead if old buffer will be freed
on spot.

Cc: Star Zeng 
Cc: Eric Dong 
Cc: Bi Dandan 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang 
---
 .../Application/UiApp/FrontPageCustomizedUiSupport.c |  9 ++---
 .../BootMaintenanceManagerCustomizedUiSupport.c  |  9 ++---
 MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c  | 10 +-
 MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 12 
 .../Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c |  3 ++-
 MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c |  9 ++---
 6 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c 
b/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c
index 1505ef9319..bff2f78e59 100644
--- a/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c
+++ b/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c
@@ -639,9 +639,12 @@ UiListThirdPartyDrivers (
 
 Count++;
 if (Count >= CurrentSize) {
-  DriverListPtr = AllocateCopyPool ((Count + UI_HII_DRIVER_LIST_SIZE) * 
sizeof (UI_HII_DRIVER_INSTANCE), gHiiDriverList);
-  ASSERT (DriverListPtr != NULL);
-  FreePool (gHiiDriverList);
+  DriverListPtr = ReallocatePool (
+CurrentSize * sizeof (UI_HII_DRIVER_INSTANCE),
+(Count + UI_HII_DRIVER_LIST_SIZE)
+  * sizeof (UI_HII_DRIVER_INSTANCE),
+gHiiDriverList
+);
   gHiiDriverList = DriverListPtr;
   CurrentSize += UI_HII_DRIVER_LIST_SIZE;
 }
diff --git 
a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUiSupport.c
 
b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUiSupport.c
index b25bc67c06..09b1ecff94 100644
--- 
a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUiSupport.c
+++ 
b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUiSupport.c
@@ -435,9 +435,12 @@ BmmListThirdPartyDrivers (
 
 Count++;
 if (Count >= CurrentSize) {
-  DriverListPtr = AllocateCopyPool ((Count + UI_HII_DRIVER_LIST_SIZE) * 
sizeof (UI_HII_DRIVER_INSTANCE), gHiiDriverList);
-  ASSERT (DriverListPtr != NULL);
-  FreePool (gHiiDriverList);
+  DriverListPtr = ReallocatePool (
+CurrentSize * sizeof (UI_HII_DRIVER_INSTANCE),
+(Count + UI_HII_DRIVER_LIST_SIZE)
+  * sizeof (UI_HII_DRIVER_INSTANCE),
+gHiiDriverList
+);
   gHiiDriverList = DriverListPtr;
   CurrentSize += UI_HII_DRIVER_LIST_SIZE;
 }
diff --git a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c 
b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
index 23ae6c5392..ac8a975bf6 100644
--- a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
+++ b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
@@ -240,7 +240,11 @@ AddIdToMacDeviceList (
   } else {
 mMacDeviceList.MaxListLen += MAX_MAC_ADDRESS_NODE_LIST_LEN;
 if (mMacDeviceList.CurListLen != 0) {
-  TempDeviceList = (MENU_INFO_ITEM *)AllocateCopyPool (sizeof 
(MENU_INFO_ITEM) * mMacDeviceList.MaxListLen, (VOID *)mMacDeviceList.NodeList);
+  TempDeviceList = ReallocatePool (
+ sizeof (MENU_INFO_ITEM) * mMacDeviceList.CurListLen,
+ sizeof (MENU_INFO_ITEM) * mMacDeviceList.MaxListLen,
+ mMacDeviceList.NodeList
+ );
 } else {
   TempDeviceList = (MENU_INFO_ITEM *)AllocatePool (sizeof (MENU_INFO_ITEM) 
* mMacDeviceList.MaxListLen);
 }
@@ -251,10 +255,6 @@ AddIdToMacDeviceList (
 TempDeviceList[mMacDeviceList.CurListLen].PromptId = PromptId;  
 TempDeviceList[mMacDeviceList.CurListLen].QuestionId = (EFI_QUESTION_ID) 
(mMacDeviceList.CurListLen + NETWORK_DEVICE_LIST_KEY_OFFSET);
 
-if (mMacDeviceList.CurListLen > 0) {
-  FreePool(mMacDeviceList.NodeList);
-}
-
 mMacDeviceList.NodeList = TempDeviceList;
   }
   mMacDeviceList.CurListLen ++;
diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c 
b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
index ce894c08b5..f9b8c3df27 100644
--- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
+++ 

[edk2] [PATCH v2 0/3] Fix misuses of AllocateCopyPool

2017-11-06 Thread Jian J Wang
> v2:
> a. Use ReallocatePool instead of allocating then copying wherever applicable

AllocateCopyPool(AllocationSize, *Buffer) will copy "AllocationSize" bytes of
memory from old "Buffer" to new allocated one. If "AllocationSize" is bigger
than size of "Buffer", heap memory overflow occurs during copy.

One solution is to allocate pool first then copy the necessary bytes to new
memory. Another is using ReallocatePool instead if old buffer will be freed
on spot.

Jian J Wang (3):
  MdeModulePkg: Fix misuses of AllocateCopyPool
  ShellPkg: Fix misuses of AllocateCopyPool
  IntelFrameworkModulePkg: Fix misuses of AllocateCopyPool

 .../Universal/BdsDxe/DeviceMngr/DeviceManager.c  | 10 +-
 .../Application/UiApp/FrontPageCustomizedUiSupport.c |  9 ++---
 .../BootMaintenanceManagerCustomizedUiSupport.c  |  9 ++---
 MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c  | 10 +-
 MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 12 
 .../Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c |  3 ++-
 MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c |  9 ++---
 ShellPkg/Application/Shell/Shell.c   |  4 +++-
 .../UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c|  7 +--
 9 files changed, 46 insertions(+), 27 deletions(-)

-- 
2.14.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 3/3] IntelFrameworkModulePkg: Fix misuses of AllocateCopyPool

2017-11-06 Thread Jian J Wang
> v2:
> a. Use ReallocatePool instead of allocating then copying wherever applicable

AllocateCopyPool(AllocationSize, *Buffer) will copy "AllocationSize" bytes of
memory from old "Buffer" to new allocated one. If "AllocationSize" is bigger
than size of "Buffer", heap memory overflow occurs during copy.

One solution is to allocate pool first then copy the necessary bytes to new
memory. Another is using ReallocatePool instead if old buffer will be freed
on spot.

Cc: Liming Gao 
Cc: Bi Dandan 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang 
---
 .../Universal/BdsDxe/DeviceMngr/DeviceManager.c| 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git 
a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c 
b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
index 125c49db5e..5103c7e5d1 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
@@ -480,7 +480,11 @@ AddIdToMacDeviceList (
   } else {
 mMacDeviceList.MaxListLen += MAX_MAC_ADDRESS_NODE_LIST_LEN;
 if (mMacDeviceList.CurListLen != 0) {
-  TempDeviceList = (MENU_INFO_ITEM *)AllocateCopyPool (sizeof 
(MENU_INFO_ITEM) * mMacDeviceList.MaxListLen, (VOID *)mMacDeviceList.NodeList);
+  TempDeviceList = ReallocatePool (
+ sizeof (MENU_INFO_ITEM) * mMacDeviceList.CurListLen,
+ sizeof (MENU_INFO_ITEM) * mMacDeviceList.MaxListLen,
+ mMacDeviceList.NodeList
+ );
 } else {
   TempDeviceList = (MENU_INFO_ITEM *)AllocatePool (sizeof (MENU_INFO_ITEM) 
* mMacDeviceList.MaxListLen);
 }
@@ -491,10 +495,6 @@ AddIdToMacDeviceList (
 TempDeviceList[mMacDeviceList.CurListLen].PromptId = PromptId;  
 TempDeviceList[mMacDeviceList.CurListLen].QuestionId = (EFI_QUESTION_ID) 
(mMacDeviceList.CurListLen + NETWORK_DEVICE_LIST_KEY_OFFSET);
 
-if (mMacDeviceList.CurListLen > 0) {
-  FreePool(mMacDeviceList.NodeList);
-}
-
 mMacDeviceList.NodeList = TempDeviceList;
   }
   mMacDeviceList.CurListLen ++;
-- 
2.14.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [RFC PATCH edk2-platforms 1/3] Silicon/NXP: add RTC support library for PCF8563 I2C IP

2017-11-06 Thread Udit Kumar
Thanks Ard, 
Your another patch set is addressing my concern 

Regards
Udit

> -Original Message-
> From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
> Sent: Monday, November 06, 2017 4:41 PM
> To: Udit Kumar 
> Cc: edk2-devel@lists.01.org; leif.lindh...@linaro.org;
> daniel.thomp...@linaro.org
> Subject: Re: [edk2] [RFC PATCH edk2-platforms 1/3] Silicon/NXP: add RTC
> support library for PCF8563 I2C IP
> 
> On 6 November 2017 at 11:09, Udit Kumar  wrote:
> > Thanks Ard.
> > This will allow to use PCF8563 on any platform not limiting to targeted
> platform.
> 
> Yes, that was the intention.
> 
> > Few comments are inline.
> >
> 
> Thanks.
> 
> >
> >> -Original Message-
> >> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf
> >> Of Ard Biesheuvel
> >> Sent: Friday, November 03, 2017 3:47 PM
> >> To: edk2-devel@lists.01.org; leif.lindh...@linaro.org;
> >> daniel.thomp...@linaro.org
> >> Cc: Ard Biesheuvel 
> >> Subject: [edk2] [RFC PATCH edk2-platforms 1/3] Silicon/NXP: add RTC
> >> support library for PCF8563 I2C IP
> >>
> >> Add a RealTimeClockLib implementation for the NXP PCF8563 as used on
> >> the Socionext Developer Box board. Note that the standard I2C
> >> protocol stack does not support runtime use, so this driver invokes
> >> the I2C master protocol directly. This requires support from the
> >> platform side as well, and so this driver will only attach to a I2C
> >> master that has the gPcf8563RealTimeClockLibI2cMasterProtolGuid
> >> protocol installed on its handle. It is up to the platform to ensure
> >> that the driver producing the I2C master protocol in question is
> >> runtime capable, and is not shared with the I2C protocol stack (i.e.,
> >> it should not have the I2C Bus Configuration Management protocol installed
> as well).
> >>
> >> Contributed-under: TianoCore Contribution Agreement 1.1
> >> Signed-off-by: Ard Biesheuvel 
> >> ---
> >>  Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c
> |
> >> 385 
> >>
> >> Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.d
> >> ec |
> >> 29 ++
> >>
> >> Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.i
> >> nf |
> >> 52 +++
> >>  3 files changed, 466 insertions(+)
> >>
> >> diff --git
> >> a/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib
> >> .c
> >> b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib
> >> .c
> >> new file mode 100644
> >> index ..fea65a225d7f
> >> --- /dev/null
> >> +++
> >> b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib
> >> .c
> >> @@ -0,0 +1,385 @@
> >> +/** @file
> >> +
> >> +  Copyright (c) 2017, Linaro, Ltd. All rights reserved.
> >> +
> >> +  This program and the accompanying materials  are licensed and made
> >> + available under the terms and conditions of the BSD
> >> License
> >> +  which accompanies this distribution.  The full text of the license
> >> + may be found
> >> at
> >> +
> >> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fope
> >> nso
> >> urce.org%2Flicenses%2Fbsd-
> >>
> license.php=02%7C01%7Cudit.kumar%40nxp.com%7C6faa68073eef4ed07
> >>
> 25208d522a40d65%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C636
> >>
> 453010374642660=vDhroHNG20VCsMtj7%2FggWcWRG8hwt5fbV1Kv4R
> >> Na98Q%3D=0
> >> +
> >> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> >> BASIS,
> >> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> >> EXPRESS OR IMPLIED.
> >> +
> >> +**/
> >> +
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include  #include
> >> +
> >> +#include 
> >> +#include 
> >> +#include 
> >> +
> >> +#define SLAVE_ADDRESS (FixedPcdGet8 (PcdI2cSlaveAddress))
> >> +#define PCF8563_DATA_REG_OFFSET   0x2
> >> +
> >> +#define PCF8563_SECONDS_MASK  0x7f
> >> +#define PCF8563_MINUTES_MASK  0x7f
> >> +#define PCF8563_HOURS_MASK0x3f
> >> +#define PCF8563_DAYS_MASK 0x3f
> >> +#define PCF8563_WEEKDAYS_MASK 0x07
> >> +#define PCF8563_MONTHS_MASK   0x1f
> >> +#define PCF8563_CENTURY_MASK  0x80
> >> +
> >> +#define EPOCH_BASE2000
> >> +
> >> +STATIC EFI_HANDLE mI2cMasterHandle;
> >> +STATIC VOID   *mDriverEventRegistration;
> >> +STATIC EFI_I2C_MASTER_PROTOCOL*mI2cMaster;
> >> +STATIC EFI_EVENT  mRtcVirtualAddrChangeEvent;
> >> +
> >> +typedef struct {
> >> +  UINTN   OperationCount;
> >> +  EFI_I2C_OPERATION   SetAddressOp;
> >> +  EFI_I2C_OPERATION   GetSetDateTimeOp;
> >> +} RTC_I2C_REQUEST;
> >> +
> >> +#pragma pack(1)
> >> +typedef struct {
> >> +  UINT8 VL_seconds;
> >> +  UINT8 Minutes;
> >> +  UINT8 Hours;
> >> +  UINT8 Days;
> >> +  UINT8 Weekdays;
> >> +  UINT8 Century_months;
> >> +  UINT8 Years;

Re: [edk2] [PATCH v2] MdeModulePkg/PciBus: Disable BME of all devices when entering RT

2017-11-06 Thread Yao, Jiewen
Looks good.
Reviewed-by: jiewen@intel.com

> -Original Message-
> From: Ni, Ruiyu
> Sent: Tuesday, November 7, 2017 10:40 AM
> To: Ni, Ruiyu ; edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Michael Turner
> ; Yao, Jiewen 
> Subject: RE: [edk2] [PATCH v2] MdeModulePkg/PciBus: Disable BME of all devices
> when entering RT
> 
> Jiewen,
> Any comments?
> 
> Thanks/Ray
> 
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> > Ruiyu Ni
> > Sent: Wednesday, November 1, 2017 12:49 PM
> > To: edk2-devel@lists.01.org
> > Cc: Kinney, Michael D ; Michael Turner
> > ; Yao, Jiewen 
> > Subject: [edk2] [PATCH v2] MdeModulePkg/PciBus: Disable BME of all
> > devices when entering RT
> >
> > The patch ensures all DMA transactions are blocked after ExitBootService.
> > If a platform enables IOMMU before and needs disable IOMMU after
> > ExitBootService, the IOMMU should be disabled after PCI bus driver disables
> > BME.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Michael Turner 
> > Signed-off-by: Ruiyu Ni 
> > Cc: Michael D Kinney 
> > Cc: Jiewen Yao 
> > Cc: Jeff Fan 
> > ---
> >  MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h   |  2 +
> >  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf  |  3 +
> >  MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c | 86
> > +++
> >  3 files changed, 91 insertions(+)
> >
> > diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
> > b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
> > index 55eb3a5a80..79b5b71082 100644
> > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
> > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
> > @@ -18,6 +18,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
> > KIND, EITHER EXPRESS OR IMPLIED.
> >
> >  #include 
> >
> > +#include 
> > +
> >  #include 
> >  #include 
> >  #include 
> > diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> > b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> > index 97608bfcf2..d5b8fab3ca 100644
> > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> > @@ -80,6 +80,9 @@ [LibraryClasses]
> >DebugLib
> >PeCoffLib
> >
> > +[Guids]
> > +  gEfiEventExitBootServicesGuid   ##
> SOMETIMES_CONSUMES ##
> > Event
> > +
> >  [Protocols]
> >gEfiPciHotPlugRequestProtocolGuid   ##
> SOMETIMES_PRODUCES
> >gEfiPciIoProtocolGuid   ## BY_START
> > diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
> > b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
> > index 97bb971a59..004f2a3b5b 100644
> > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
> > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
> > @@ -21,6 +21,72 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
> > KIND, EITHER EXPRESS OR IMPLIED.
> >  LIST_ENTRY  mPciDevicePool;
> >
> >  /**
> > + Disable Bus Master Enable bit in all devices in the list.
> > +
> > + @param Devices  A device list.
> > +**/
> > +VOID
> > +DisableBmeOnTree (
> > +  IN LIST_ENTRY  *Devices
> > +  )
> > +{
> > +  LIST_ENTRY  *Link;
> > +  PCI_IO_DEVICE   *PciIoDevice;
> > +  UINT16   Command;
> > +
> > +  for ( Link = GetFirstNode (Devices)
> > +  ; !IsNull (Devices, Link)
> > +  ; Link = GetNextNode (Devices, Link)
> > +  ) {
> > +PciIoDevice = PCI_IO_DEVICE_FROM_LINK (Link);
> > +//
> > +// Turn off all children's Bus Master, if any
> > +//
> > +DisableBmeOnTree (>ChildList);
> > +
> > +//
> > +// If this is a device that supports BME, disable BME on this device.
> > +//
> > +if ((PciIoDevice->Supports & EFI_PCI_IO_ATTRIBUTE_BUS_MASTER) != 0)
> > {
> > +  PCI_READ_COMMAND_REGISTER(PciIoDevice, );
> > +  if ((Command & EFI_PCI_COMMAND_BUS_MASTER) != 0) {
> > +Command &= ~EFI_PCI_COMMAND_BUS_MASTER;
> > +PCI_SET_COMMAND_REGISTER (PciIoDevice, Command);
> > +DEBUG ((
> > +  DEBUG_INFO,"  %02x   %02x  %02x %04x\n",
> > +  PciIoDevice->BusNumber, PciIoDevice->DeviceNumber,
> PciIoDevice-
> > >FunctionNumber,
> > +  Command
> > +  ));
> > +  }
> > +}
> > +  }
> > +}
> > +
> > +/**
> > +  Exit Boot Services Event notification handler.
> > +
> > +  Disable Bus Master on any that were enabled during BDS.
> > +
> > +  @param[in]  Event Event whose notification function is being
> invoked.
> > +  @param[in]  Context   Pointer to the notification function's context.
> > +
> > +**/
> > +VOID
> > +EFIAPI
> > +OnExitBootServices (
> > +  IN  EFI_EVENT Event,
> > +  IN  VOID 

Re: [edk2] [PATCH 1/2] CryptoPkg/BaseCryptLib: Add C-structure to matching certificate stack

2017-11-06 Thread Yao, Jiewen
It is good to document this data structure.

Reviewed-by: jiewen@intel.com

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Long,
> Qin
> Sent: Tuesday, November 7, 2017 10:31 AM
> To: Chen, Chen A ; edk2-devel@lists.01.org
> Cc: Zhang, Chao B 
> Subject: Re: [edk2] [PATCH 1/2] CryptoPkg/BaseCryptLib: Add C-structure to
> matching certificate stack
> 
> Reviewed-by: Long Qin 
> 
> One minor comment: please leave one space before the structure name:
> +} EFI_CERT_DATA;
> and
> +} EFI_CERT_STACK;
> 
> 
> Best Regards & Thanks,
> LONG, Qin
> 
> -Original Message-
> From: Chen, Chen A
> Sent: Tuesday, November 7, 2017 9:05 AM
> To: edk2-devel@lists.01.org
> Cc: Chen, Chen A ; Long, Qin ;
> Zhang, Chao B 
> Subject: [PATCH 1/2] CryptoPkg/BaseCryptLib: Add C-structure to matching
> certificate stack
> 
> The parameter CertStack of Pkcs7GetSigners will return all embedded X.509
> certificate in one given PKCS7 signature. The format is:
> //
> // UINT8  CertNumber;
> // UINT32 Cert1Length;
> // UINT8  Cert1[];
> // UINT32 Cert2Length;
> // UINT8  Cert2[];
> // ...
> // UINT32 CertnLength;
> // UINT8  Certn[];
> //
> Add EFI_CERT_STACK and EFI_CERT_DATA structure, these two C-structure are
> used for parsing CertStack more clearly.
> 
> Cc: Long Qin 
> Cc: Zhang Chao 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: chenc2 
> ---
>  CryptoPkg/Include/Library/BaseCryptLib.h   | 33
> ++
>  .../Library/BaseCryptLib/Pk/CryptPkcs7Verify.c |  3 ++
>  .../Library/BaseCryptLib/Pk/CryptPkcs7VerifyNull.c |  3 ++
>  3 files changed, 39 insertions(+)
> 
> diff --git a/CryptoPkg/Include/Library/BaseCryptLib.h
> b/CryptoPkg/Include/Library/BaseCryptLib.h
> index e2b6a95666..3fd9a3c911 100644
> --- a/CryptoPkg/Include/Library/BaseCryptLib.h
> +++ b/CryptoPkg/Include/Library/BaseCryptLib.h
> @@ -2377,6 +2377,36 @@ Pkcs5HashPassword (
>);
> 
>  /**
> +  The 3rd parameter of Pkcs7GetSigners will return all embedded
> +  X.509 certificate in one given PKCS7 signature. The format is:
> +  //
> +  // UINT8  CertNumber;
> +  // UINT32 Cert1Length;
> +  // UINT8  Cert1[];
> +  // UINT32 Cert2Length;
> +  // UINT8  Cert2[];
> +  // ...
> +  // UINT32 CertnLength;
> +  // UINT8  Certn[];
> +  //
> +
> +  The two following C-structure are used for parsing CertStack more clearly.
> +**/
> +#pragma pack(1)
> +
> +typedef struct {
> +  UINT32CertDataLength;   // The length in bytes of X.509 
> certificate.
> +  UINT8 CertDataBuffer[0];// The X.509 certificate content (DER).
> +}EFI_CERT_DATA;
> +
> +typedef struct {
> +  UINT8 CertNumber;   // Number of X.509 certificate.
> +  //EFI_CERT_DATA   CertArray[];  // An array of X.509 certificate.
> +}EFI_CERT_STACK;
> +
> +#pragma pack()
> +
> +/**
>Get the signer's certificates from PKCS#7 signed data as described in 
> "PKCS #7:
>Cryptographic Message Syntax Standard". The input signed data could be
> wrapped
>in a ContentInfo structure.
> @@ -2390,6 +2420,7 @@ Pkcs5HashPassword (
>@param[out] CertStackPointer to Signer's certificates retrieved from
> P7Data.
> It's caller's responsibility to free the buffer 
> with
> Pkcs7FreeSigners().
> +   This data structure is EFI_CERT_STACK type.
>@param[out] StackLength  Length of signer's certificates in bytes.
>@param[out] TrustedCert  Pointer to a trusted certificate from Signer's
> certificates.
> It's caller's responsibility to free the buffer 
> with
> @@ -2437,9 +2468,11 @@ Pkcs7FreeSigners (
>@param[out] SignerChainCerts  Pointer to the certificates list chained to
> signer's
>  certificate. It's caller's responsibility to 
> free
> the buffer
>  with Pkcs7FreeSigners().
> +This data structure is EFI_CERT_STACK
> type.
>@param[out] ChainLength   Length of the chained certificates list
> buffer in bytes.
>@param[out] UnchainCerts  Pointer to the unchained certificates lists.
> It's caller's
>  responsibility to free the buffer with
> Pkcs7FreeSigners().
> +This data structure is EFI_CERT_STACK
> type.
>@param[out] UnchainLength Length of the unchained certificates list
> buffer in bytes.
> 
>@retval  TRUE The operation is finished successfully.
> diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c
> b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c
> index 296df028b1..fe8e5950f9 100644
> --- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c
> 

Re: [edk2] [PATCH v2] MdeModulePkg/PciBus: Disable BME of all devices when entering RT

2017-11-06 Thread Ni, Ruiyu
Jiewen,
Any comments?

Thanks/Ray

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Ruiyu Ni
> Sent: Wednesday, November 1, 2017 12:49 PM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Michael Turner
> ; Yao, Jiewen 
> Subject: [edk2] [PATCH v2] MdeModulePkg/PciBus: Disable BME of all
> devices when entering RT
> 
> The patch ensures all DMA transactions are blocked after ExitBootService.
> If a platform enables IOMMU before and needs disable IOMMU after
> ExitBootService, the IOMMU should be disabled after PCI bus driver disables
> BME.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Michael Turner 
> Signed-off-by: Ruiyu Ni 
> Cc: Michael D Kinney 
> Cc: Jiewen Yao 
> Cc: Jeff Fan 
> ---
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h   |  2 +
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf  |  3 +
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c | 86
> +++
>  3 files changed, 91 insertions(+)
> 
> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
> b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
> index 55eb3a5a80..79b5b71082 100644
> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
> @@ -18,6 +18,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
> KIND, EITHER EXPRESS OR IMPLIED.
> 
>  #include 
> 
> +#include 
> +
>  #include 
>  #include 
>  #include 
> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> index 97608bfcf2..d5b8fab3ca 100644
> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> @@ -80,6 +80,9 @@ [LibraryClasses]
>DebugLib
>PeCoffLib
> 
> +[Guids]
> +  gEfiEventExitBootServicesGuid   ## SOMETIMES_CONSUMES ##
> Event
> +
>  [Protocols]
>gEfiPciHotPlugRequestProtocolGuid   ## SOMETIMES_PRODUCES
>gEfiPciIoProtocolGuid   ## BY_START
> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
> b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
> index 97bb971a59..004f2a3b5b 100644
> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
> @@ -21,6 +21,72 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
> KIND, EITHER EXPRESS OR IMPLIED.
>  LIST_ENTRY  mPciDevicePool;
> 
>  /**
> + Disable Bus Master Enable bit in all devices in the list.
> +
> + @param Devices  A device list.
> +**/
> +VOID
> +DisableBmeOnTree (
> +  IN LIST_ENTRY  *Devices
> +  )
> +{
> +  LIST_ENTRY  *Link;
> +  PCI_IO_DEVICE   *PciIoDevice;
> +  UINT16   Command;
> +
> +  for ( Link = GetFirstNode (Devices)
> +  ; !IsNull (Devices, Link)
> +  ; Link = GetNextNode (Devices, Link)
> +  ) {
> +PciIoDevice = PCI_IO_DEVICE_FROM_LINK (Link);
> +//
> +// Turn off all children's Bus Master, if any
> +//
> +DisableBmeOnTree (>ChildList);
> +
> +//
> +// If this is a device that supports BME, disable BME on this device.
> +//
> +if ((PciIoDevice->Supports & EFI_PCI_IO_ATTRIBUTE_BUS_MASTER) != 0)
> {
> +  PCI_READ_COMMAND_REGISTER(PciIoDevice, );
> +  if ((Command & EFI_PCI_COMMAND_BUS_MASTER) != 0) {
> +Command &= ~EFI_PCI_COMMAND_BUS_MASTER;
> +PCI_SET_COMMAND_REGISTER (PciIoDevice, Command);
> +DEBUG ((
> +  DEBUG_INFO,"  %02x   %02x  %02x %04x\n",
> +  PciIoDevice->BusNumber, PciIoDevice->DeviceNumber, PciIoDevice-
> >FunctionNumber,
> +  Command
> +  ));
> +  }
> +}
> +  }
> +}
> +
> +/**
> +  Exit Boot Services Event notification handler.
> +
> +  Disable Bus Master on any that were enabled during BDS.
> +
> +  @param[in]  Event Event whose notification function is being invoked.
> +  @param[in]  Context   Pointer to the notification function's context.
> +
> +**/
> +VOID
> +EFIAPI
> +OnExitBootServices (
> +  IN  EFI_EVENT Event,
> +  IN  VOID  *Context
> +  )
> +{
> +  DEBUG ((
> +DEBUG_INFO,
> +"PciBus: Disable Bus Master of all devices...\n"
> +"  Bus# Device# Function#  NewCommand\n"
> +));
> +  DisableBmeOnTree();
> +}
> +
> +/**
>Initialize the PCI devices pool.
> 
>  **/
> @@ -29,7 +95,27 @@ InitializePciDevicePool (
>VOID
>)
>  {
> +  EFI_EVENT   ExitBootServicesEvent;
> +  EFI_STATUS  Status;
> +
>InitializeListHead ();
> +
> +  //
> +  // DisableBME on ExitBootServices should be synchonized with any
> IOMMU ExitBootServices routine.
> +  // DisableBME should be run before the IOMMU protections are disabled.
> +  // One way to do this is to ensure that the IOMMU ExitBootServices
> 

Re: [edk2] [Help] UEFI boot KVM4T vm hang On TianoCore

2017-11-06 Thread Hangaohuai
Hi, Laszlo Ersek;
Thanks for your reply.

I have trying to shoot this trouble:

1. edk get the MtrrValidBitsMask by "AsmCpuid (CPUID_VIR_PHY_ADDRESS_SIZE, 
, NULL, NULL, NULL); "(0x8008)
2. Cpuid(0x8008) is held in kvm struct (>arch.cpuid_entries[i])
3. (0x8008) is set by qemu;

Part1:
We set the 4294967296, the 
"GetFirstNonAddress: Pci64Base=0x448"
But the MtrrValidBitsMask get 0x3FF  ;
Does not pass the check.
  MtrrLibInitializeMtrrMask (, );
  if (((BaseAddress & ~MtrrValidAddressMask) != 0) || (Length & 
~MtrrValidAddressMask) != 0) {
return RETURN_UNSUPPORTED;
  }

Part2:
Xhci_hcd will use the address above maxMemory, so we visit the wrong address.
Checking by starting a 3294967296 
memory with USB3.0.

So , I think edk2 is ok; maxMemory depend on CPU support more the 42bit.


***
Hi,

sorry about the delayed response.

CC'ing Igor, and commenting below:

On 10/31/17 15:29, Hangaohuai wrote:
> Hi, Laszlo Ersek;
>
> I have tested the uefi booting KVM vm with the configuration(xml); but 
> start hang.
> Enable the memoryhotplug, with usb3.0 config. The config as Config1 
> below.
>
> Tested branches:
> UDK2017 eea98eea4ccbb1d640657770bccb5497fddc6064
> Master   76fd5a660d704538a1b14a58d03a4eef9682b01c
>
> Both hang on the snapshot TianoCore in VNC
>
> Try to shoot the problem;
> I find the early version can boot success with the same config.
> Maybe the patch1 below cause the problem;
>
> Try to ignore the patch does, the master/ UDK2017 both can boot 
> success.
> But I don't know why. Hope for your help,thanks.
>
> Patch1
> ***
> commit 4f5eff8193096eb847639f090a7dfae3cff95fde
> Author: Laszlo Ersek 
> Date:   Fri Mar 4 20:06:26 2016 +0100
>
> OvmfPkg: PciHostBridgeLib: install 64-bit PCI host aperture
>
> diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c 
> b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib
> index 3e02778..1d3d10a 100644
> --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
> +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
> @@ -132,6 +132,13 @@ InitRootBridge (
>RootBus->MemAbove4G.Base  = 0;
>RootBus->MemAbove4G.Limit = 0;
> +  if (PcdGet64 (PcdPciMmio64Size) > 0) {
> +RootBus->AllocationAttributes |= EFI_PCI_HOST_BRIDGE_MEM64_DECODE;
> +RootBus->MemAbove4G.Base   = PcdGet64 (PcdPciMmio64Base);
> +RootBus->MemAbove4G.Limit  = PcdGet64 (PcdPciMmio64Base) +
> + (PcdGet64 (PcdPciMmio64Size) - 
> + 1);  }
> +
>RootBus->Bus.Base  = RootBusNumber;
>RootBus->Bus.Limit = MaxSubBusNumber;
>RootBus->Io.Base   = PcdGet64 (PcdPciIoBase);
> diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf 
> b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeL
> index bbec746..7a964c7 100644
> --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
> +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
> @@ -51,4 +51,6 @@
>gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize
>gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base
>gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size
> +  gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base
> +  gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size
>gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
> ***
>
>
> Config1
> ***
> 4294967296
>   4294967
>   4294967
> Xxxx
> 
>  function='0x0'/>  
> ***

The patch that you identified is responsible for exposing the 64-bit MMIO 
aperture for PCI MMIO BAR allocation purposes.

Reverting this patch might mask the issue, but I don't expect the actual 
problem to be in this patch.

Instead, the base address and the size of the aperture in question is 
determined in the file

  OvmfPkg/PlatformPei/MemDetect.c

in the function

  GetFirstNonAddress()

This function takes the memory (DIMM) hotplug range in question, the end of 
which is presented by QEMU in the fw_cfg file

  etc/reserved-memory-end

To my knowledge, this fw_cfg file is an 8-byte integer in LE encoding.

Quoting the code:

>   //
>   // If QEMU presents an E820 map, then get the highest exclusive >=4GB RAM
>   // address from it. This can express an address >= 4GB+1TB.
>   //
>   // Otherwise, get the flat size of the memory above 4GB from the CMOS (which
>   // can only express a size smaller than 1TB), and add it to 4GB.
>   //
>   Status = ScanOrAdd64BitE820Ram ();
>   if (EFI_ERROR (Status)) {
> FirstNonAddress = BASE_4GB + GetSystemMemorySizeAbove4gb ();
>   }
>
> ...
>
>   //
>   // The "etc/reserved-memory-end" fw_cfg file, when present, contains an
>   // absolute, exclusive end address for the memory hotplug area. This area
>   // starts right at the end of the memory above 4GB. The 64-bit PCI host
>   // aperture must be placed above it.
>   //
>   Status = QemuFwCfgFindFile 

[edk2] [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017] Change ReadMe format

2017-11-06 Thread Guo, Mang
Contributed-under: TianoCore Contribution Agreement 1.1

Signed-off-by: Guo Mang 
---
 ReadMe.MD | 63 ---
 1 file changed, 36 insertions(+), 27 deletions(-)

diff --git a/ReadMe.MD b/ReadMe.MD
index f5cbc7c..a42260e 100644
--- a/ReadMe.MD
+++ b/ReadMe.MD
@@ -41,17 +41,19 @@ This code base is based on UDK2017 core packages.
   Download PREBOOT.EXE Version 21.1 from the "Intel® Ethernet Connections
   Boot Utility, Preboot Images, and EFI Drivers" page.
   
https://downloadcenter.intel.com/download/19186/Intel-Ethernet-Connections-Boot-Utility-Preboot-Images-and-EFI-Drivers
-   Windows user:
-   1. Install PREBOOT.EXE into the default folder (C:\Intel21.1).
-   2. Copy the UEFI x64 PCI-E gigabit driver 
(C:\Intel21.1\APPS\EFI\EFIx64\E7320X3.EFI) 
+
+  Windows user:
+  1. Install PREBOOT.EXE into the default folder (C:\Intel21.1).
+  2. Copy the UEFI x64 PCI-E gigabit driver 
(C:\Intel21.1\APPS\EFI\EFIx64\E7320X3.EFI) 
   to the platform package directory below, create the folder if it does 
not exist:
-  
"C:\MyWorkspace\edk2-platforms\Platform\BroxtonPlatformPkg\Common\Binaries\UNDI\I210PcieUndiDxe"
-   Linux user:
-   1. Use command "unzip PREBOOT.EXE" to extract UEFI x64 PCI-E gigabit driver
+* 
"C:\MyWorkspace\edk2-platforms\Platform\BroxtonPlatformPkg\Common\Binaries\UNDI\I210PcieUndiDxe"
+
+  Linux user:
+  1. Use command "unzip PREBOOT.EXE" to extract UEFI x64 PCI-E gigabit 
driver
   (preboot/APPS/EFI/EFIx64/E7320X3.EFI)
-   2. Copy E7320X3.EFI to platform package directory below, create the folder
+  2. Copy E7320X3.EFI to platform package directory below, create the 
folder
   if it does not exist:
-* 
"~/src/MyWorkspace/edk2-platforms/Platform/BroxtonPlatformPkg/Common/Binaries/UNDI/I210PcieUndiDxe"
+* 
"~/src/MyWorkspace/edk2-platforms/Platform/BroxtonPlatformPkg/Common/Binaries/UNDI/I210PcieUndiDxe"
 
 6. Follow the instructions found in the "Patch-HOWTO.txt" file located in the 
Workspace
(e.g. 
"C:\MyWorkspace\edk2-platforms\Core\CryptoPkg\Library\OpensslLib\Patch-HOWTO.txt")
@@ -67,7 +69,7 @@ This code base is based on UDK2017 core packages.
 ## 2. HOW TO BUILD (WINDOWS ENVIRONMENT)
 
 Windows System Configuration:
-  Microsoft Windows 7 Ultimate 64-bit*
+  - Microsoft Windows 7 Ultimate 64-bit*
 
 1. Setup Build Environment
 
@@ -77,24 +79,29 @@ Windows System Configuration:
   * Make sure that a file with the extension of ".py" will be opened by 
Python.exe.
 
3. Install the NASM assembly language compiler:
-  a. Download NASM 2.12.02 binaries:
+
+a. Download NASM 2.12.02 binaries:
 * 
http://www.nasm.us/pub/nasm/releasebuilds/2.12.02/win32/nasm-2.12.02-win32.zip
 * 
http://www.nasm.us/pub/nasm/releasebuilds/2.12.02/win64/nasm-2.12.02-win64.zip
-  b. Unzip the 32-bit & 64-bit versions of nasm.exe to the directories 
listed below,
+
+b. Unzip the 32-bit & 64-bit versions of nasm.exe to the directories 
listed below,
  respectively, and create the folders if they do not exist:
 * 
"C:\MyWorkspace\edk2-platforms\Platform\BroxtonPlatformPkg\Common\Tools\nasm\Win32"
 * 
"C:\MyWorkspace\edk2-platforms\Platform\BroxtonPlatformPkg\Common\Tools\nasm\Win64"
 
4. Install the ACPI Source Language (ASL) compiler:
-  a. Install the IASL 2016-09-30 compiler from acpica.org:
+
+a. Install the IASL 2016-09-30 compiler from acpica.org:
  https://acpica.org/sites/acpica/files/iasl-win-20160930.zip
-  b. Unzip the "iasl.exe" file into the directory below, and create the 
folder
+
+b. Unzip the "iasl.exe" file into the directory below, and create the 
folder
  if it does not exist:
  * 
"C:\MyWorkspace\edk2-platforms\Platform\BroxtonPlatformPkg\Common\Tools\Iasl"
 
 2. Build
 
-  2a. Build Steps (32-bit)
+2a. Build Steps (32-bit)
+
 1. To build a 32-bit release version
   * Open a command prompt of Microsoft Visual Studio, such as "Developer 
Command Prompt for VS2013";
   * Type the command: `cd C:\MyWorkspace\edk2-platforms`
@@ -110,9 +117,10 @@ Windows System Configuration:
 3. After the build successfully completes, the 8MB firmware binary image 
will be located in the
following location on your local hard drive:
 
-  
"C:\MyWorkspace\edk2-platforms\Platform\BroxtonPlatformPkg\Common\Tools\Stitch"
+  * 
"C:\MyWorkspace\edk2-platforms\Platform\BroxtonPlatformPkg\Common\Tools\Stitch"
+
+2b. Build Steps (64-bit)
 
-  2b. Build Steps (64-bit)
 1. To build a 64-bit release version
   * Open a command prompt of Microsoft Visual Studio, such as "Developer 
Command Prompt for VS2013";
   * Type the command: `cd C:\MyWorkspace\edk2-platforms`
@@ -128,36 +136,37 @@ Windows System Configuration:
 3. After the build successfully completes, the 8MB firmware binary image 
will be located 

Re: [edk2] [PATCH 1/2] CryptoPkg/BaseCryptLib: Add C-structure to matching certificate stack

2017-11-06 Thread Long, Qin
Reviewed-by: Long Qin 

One minor comment: please leave one space before the structure name:
+} EFI_CERT_DATA;
and
+} EFI_CERT_STACK;


Best Regards & Thanks,
LONG, Qin

-Original Message-
From: Chen, Chen A 
Sent: Tuesday, November 7, 2017 9:05 AM
To: edk2-devel@lists.01.org
Cc: Chen, Chen A ; Long, Qin ; 
Zhang, Chao B 
Subject: [PATCH 1/2] CryptoPkg/BaseCryptLib: Add C-structure to matching 
certificate stack

The parameter CertStack of Pkcs7GetSigners will return all embedded X.509 
certificate in one given PKCS7 signature. The format is:
//
// UINT8  CertNumber;
// UINT32 Cert1Length;
// UINT8  Cert1[];
// UINT32 Cert2Length;
// UINT8  Cert2[];
// ...
// UINT32 CertnLength;
// UINT8  Certn[];
//
Add EFI_CERT_STACK and EFI_CERT_DATA structure, these two C-structure are used 
for parsing CertStack more clearly.

Cc: Long Qin 
Cc: Zhang Chao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: chenc2 
---
 CryptoPkg/Include/Library/BaseCryptLib.h   | 33 ++
 .../Library/BaseCryptLib/Pk/CryptPkcs7Verify.c |  3 ++
 .../Library/BaseCryptLib/Pk/CryptPkcs7VerifyNull.c |  3 ++
 3 files changed, 39 insertions(+)

diff --git a/CryptoPkg/Include/Library/BaseCryptLib.h 
b/CryptoPkg/Include/Library/BaseCryptLib.h
index e2b6a95666..3fd9a3c911 100644
--- a/CryptoPkg/Include/Library/BaseCryptLib.h
+++ b/CryptoPkg/Include/Library/BaseCryptLib.h
@@ -2377,6 +2377,36 @@ Pkcs5HashPassword (
   );
 
 /**
+  The 3rd parameter of Pkcs7GetSigners will return all embedded
+  X.509 certificate in one given PKCS7 signature. The format is:
+  //
+  // UINT8  CertNumber;
+  // UINT32 Cert1Length;
+  // UINT8  Cert1[];
+  // UINT32 Cert2Length;
+  // UINT8  Cert2[];
+  // ...
+  // UINT32 CertnLength;
+  // UINT8  Certn[];
+  //
+
+  The two following C-structure are used for parsing CertStack more clearly.
+**/
+#pragma pack(1)
+
+typedef struct {
+  UINT32CertDataLength;   // The length in bytes of X.509 certificate.
+  UINT8 CertDataBuffer[0];// The X.509 certificate content (DER).
+}EFI_CERT_DATA;
+
+typedef struct {
+  UINT8 CertNumber;   // Number of X.509 certificate.
+  //EFI_CERT_DATA   CertArray[];  // An array of X.509 certificate.
+}EFI_CERT_STACK;
+
+#pragma pack()
+
+/**
   Get the signer's certificates from PKCS#7 signed data as described in "PKCS 
#7:
   Cryptographic Message Syntax Standard". The input signed data could be 
wrapped
   in a ContentInfo structure.
@@ -2390,6 +2420,7 @@ Pkcs5HashPassword (
   @param[out] CertStackPointer to Signer's certificates retrieved from 
P7Data.
It's caller's responsibility to free the buffer with
Pkcs7FreeSigners().
+   This data structure is EFI_CERT_STACK type.
   @param[out] StackLength  Length of signer's certificates in bytes.
   @param[out] TrustedCert  Pointer to a trusted certificate from Signer's 
certificates.
It's caller's responsibility to free the buffer 
with @@ -2437,9 +2468,11 @@ Pkcs7FreeSigners (
   @param[out] SignerChainCerts  Pointer to the certificates list chained to 
signer's
 certificate. It's caller's responsibility to 
free the buffer
 with Pkcs7FreeSigners().
+This data structure is EFI_CERT_STACK type.
   @param[out] ChainLength   Length of the chained certificates list buffer 
in bytes.
   @param[out] UnchainCerts  Pointer to the unchained certificates lists. 
It's caller's
 responsibility to free the buffer with 
Pkcs7FreeSigners().
+This data structure is EFI_CERT_STACK type.
   @param[out] UnchainLength Length of the unchained certificates list 
buffer in bytes.
 
   @retval  TRUE The operation is finished successfully.
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c 
b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c
index 296df028b1..fe8e5950f9 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c
@@ -242,6 +242,7 @@ _Exit:
   @param[out] CertStackPointer to Signer's certificates retrieved from 
P7Data.
It's caller's responsibility to free the buffer with
Pkcs7FreeSigners().
+   This data structure is EFI_CERT_STACK type.
   @param[out] StackLength  Length of signer's certificates in bytes.
   @param[out] TrustedCert  Pointer to a trusted certificate from Signer's 
certificates.
It's caller's responsibility to free the buffer 
with @@ -442,9 +443,11 @@ Pkcs7FreeSigners (
   @param[out] SignerChainCerts  Pointer to the 

Re: [edk2] [PATCH 2/2] SecurityPkg/AuthVariableLib: Use EFI_CERT_DATA to parse certificate

2017-11-06 Thread Long, Qin
Reviewed-by: Long Qin 


Best Regards & Thanks,
LONG, Qin

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of chenc2
Sent: Tuesday, November 7, 2017 9:05 AM
To: edk2-devel@lists.01.org
Cc: Zhang, Chao B ; Long, Qin 
Subject: [edk2] [PATCH 2/2] SecurityPkg/AuthVariableLib: Use EFI_CERT_DATA to 
parse certificate

The function Pkcs7GetSigners return certificate stack as binary buffer.
Use EFI_CERT_DATA to parsing certificate stack more clearly, and access 
certificate by the field of EFI_CERT_DATA structure.

Cc: Long Qin 
Cc: Zhang Chao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: chenc2 
---
 SecurityPkg/Library/AuthVariableLib/AuthService.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c 
b/SecurityPkg/Library/AuthVariableLib/AuthService.c
index 6cbeb98535..213a524f27 100644
--- a/SecurityPkg/Library/AuthVariableLib/AuthService.c
+++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c
@@ -1828,6 +1828,7 @@ VerifyTimeBasedPayload (
   UINT8*CertsInCertDb;
   UINT32   CertsSizeinDb;
   UINT8Sha256Digest[SHA256_DIGEST_SIZE];
+  EFI_CERT_DATA*CertDataPtr;
 
   //
   // 1. TopLevelCert is the top-level issuer certificate in signature Signer 
Cert Chain @@ -1841,6 +1842,7 @@ VerifyTimeBasedPayload (
   SignerCerts= NULL;
   TopLevelCert   = NULL;
   CertsInCertDb  = NULL;
+  CertDataPtr= NULL;
 
   //
   // When the attribute EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS is 
@@ -2098,9 +2100,10 @@ VerifyTimeBasedPayload (
 //
 // Check hash of signer cert CommonName + Top-level issuer 
tbsCertificate against data in CertDb
 //
+CertDataPtr = (EFI_CERT_DATA *)(SignerCerts + 1);
 Status = CalculatePrivAuthVarSignChainSHA256Digest(
-   SignerCerts + sizeof(UINT8) + sizeof(UINT32),
-   ReadUnaligned32 ((UINT32 *)(SignerCerts + sizeof(UINT8))),
+   CertDataPtr->CertDataBuffer,
+   ReadUnaligned32 ((UINT32 
+ *)&(CertDataPtr->CertDataLength)),
TopLevelCert,
TopLevelCertSize,
Sha256Digest
@@ -2135,12 +2138,13 @@ VerifyTimeBasedPayload (
   //
   // When adding a new common authenticated variable, always save Hash of 
cn of signer cert + tbsCertificate of Top-level issuer
   //
+  CertDataPtr = (EFI_CERT_DATA *)(SignerCerts + 1);
   Status = InsertCertsToDb (
  VariableName,
  VendorGuid,
  Attributes,
- SignerCerts + sizeof(UINT8) + sizeof(UINT32),
- ReadUnaligned32 ((UINT32 *)(SignerCerts + sizeof(UINT8))),
+ CertDataPtr->CertDataBuffer,
+ ReadUnaligned32 ((UINT32 
+ *)&(CertDataPtr->CertDataLength)),
  TopLevelCert,
  TopLevelCertSize
  );
--
2.13.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] MdeModulePkg SerialDxe: Handle Timeout change more robustly

2017-11-06 Thread Zeng, Star
Laszlo,

I agree it could be more rigorous to compare against the original parameters.
Please check the V2 patch at 
https://lists.01.org/pipermail/edk2-devel/2017-November/016968.html.

Julien,

Please help take the test on your case with the V2 patch.

Thanks,
Star
-Original Message-
From: Laszlo Ersek [mailto:ler...@redhat.com] 
Sent: Tuesday, November 7, 2017 5:43 AM
To: Zeng, Star ; edk2-devel@lists.01.org
Cc: Julien Grall ; Ni, Ruiyu 
Subject: Re: [PATCH] MdeModulePkg SerialDxe: Handle Timeout change more robustly

Star,

On 11/02/17 02:41, Star Zeng wrote:
> https://lists.01.org/pipermail/edk2-devel/2017-October/016479.html
> reported "Xen Console input very slow in recent UEFI" that appears 
> after 4cf3f37c87ba1f9d58072444bd735e40e4779e70 "MdeModulePkg
> SerialDxe: Process timeout consistently in SerialRead".
> 
> Julien did more debugging and find out the following is happening in 
> TerminalConInTimerHandler (MdeModulePkg/Universal/Console/TerminalDxe)
> when a character is received:
> 1) GetControl will return EFI_SERIAL_INPUT_BUFFER_EMPTY unset
>   => Entering in the loop to fetch character from the serial
> 2) GetOneKeyFromSerial()
>   => Return directly with the character read
> 3) Looping as the fifo is not full and no error
> 4) GetOneKeyFromSerial() -> SerialRead()
>   => No more character so SerialPortPoll() will return FALSE and loop
>  until timeout
>   => Return EFI_TIMEOUT
> 5) Exiting the loop from TerminalConInTimerHandler
> 6) Characters are printed
> 
> After some investigation, I found it is related to the Timeout value.
> 
> The Timeout is 100 (1s) by default to follow UEFI spec.
> And the Terminal driver will recalculate and set the Timeout value 
> based on the properties of UART in TerminalDriverBindingStart()/ 
> TerminalConInTimerHandler().
> 
>   SerialInTimeOut = 0;
>   if (Mode->BaudRate != 0) {
> //
> // According to BAUD rate to calculate the timeout value.
> //
> SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) *
>   2 * 100 / (UINTN) Mode->BaudRate;
>   }
> 
> For example, based on the PCD values of PcdUartDefaultBaudRate, 
> PcdUartDefaultDataBits and PcdUartDefaultStopBits, SerialInTimeOut =
> (1 + 8  + 1) * 2 * 100 / (UINTN) 115200 = 173 (us).
> 
> When SerialDxe is used,
> TerminalDriverBindingStart()/TerminalConInTimerHandler() ->
>   SerialIo->SetAttributes() ->
> SerialSetAttributes() ->
>   SerialPortSetAttributes()
> 
> Some implementations of SerialPortSetAttributes() could handle the 
> input parameters and return RETURN_SUCCESS, for example 
> BaseSerialPortLib16550, then Timeout value will be changed to 173 
> (us), no "slow down" will be observed.
> But some implementations of SerialPortSetAttributes() just return 
> RETURN_UNSUPPORTED, for example XenConsoleSerialPortLib, then Timeout 
> value will be not changed and kept 100 (1s), "slow down" will be 
> observed.
> 
> SerialPortLib instance can be enhanced to 1. Handle the input 
> parameters and return status accordingly instead of just returning 
> RETURN_UNSUPPORTED in SerialPortSetAttributes().
> 2. Just return RETURN_SUCCESS instead of RETURN_UNSUPPORTED in
> SerialPortSetAttributes() if the instance does not care the input 
> parameters at all.
> 
> And SerialDxe can also be enhanced like this patch to be more robust 
> to handle Timeout change.
> 
> Cc: Julien Grall 
> Cc: Laszlo Ersek 
> Cc: Ruiyu Ni 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/Universal/SerialDxe/SerialIo.c | 16 +++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Universal/SerialDxe/SerialIo.c 
> b/MdeModulePkg/Universal/SerialDxe/SerialIo.c
> index ebcd92726314..060ea56c2b1a 100644
> --- a/MdeModulePkg/Universal/SerialDxe/SerialIo.c
> +++ b/MdeModulePkg/Universal/SerialDxe/SerialIo.c
> @@ -285,7 +285,21 @@ SerialSetAttributes (
>  
>Status = SerialPortSetAttributes (, , , 
> , , );
>if (EFI_ERROR (Status)) {
> -return Status;
> +//
> +// If it is just to set Timeout value and unsupported is returned,
> +// do not return error.
> +//
> +if ((Status == EFI_UNSUPPORTED) &&
> +(This->Mode->Timeout  != Timeout) &&
> +(This->Mode->ReceiveFifoDepth == ReceiveFifoDepth) &&
> +(This->Mode->BaudRate == BaudRate) &&
> +(This->Mode->DataBits == (UINT32) DataBits) &&
> +(This->Mode->Parity   == (UINT32) Parity) &&
> +(This->Mode->StopBits == (UINT32) StopBits)) {
> +  Status = EFI_SUCCESS;
> +} else {
> +  return Status;
> +}
>}
>  
>//
> 

is the SerialPortSetAttributes() library API allowed to overwrite -- possibly 
even with garbage -- the IN OUT parameters 

[edk2] [PATCH V2] MdeModulePkg SerialDxe: Handle Timeout change more robustly

2017-11-06 Thread Star Zeng
https://lists.01.org/pipermail/edk2-devel/2017-October/016479.html
reported "Xen Console input very slow in recent UEFI" that appears
after 4cf3f37c87ba1f9d58072444bd735e40e4779e70 "MdeModulePkg
SerialDxe: Process timeout consistently in SerialRead".

Julien did more debugging and find out the following is happening in
TerminalConInTimerHandler (MdeModulePkg/Universal/Console/TerminalDxe)
when a character is received:
1) GetControl will return EFI_SERIAL_INPUT_BUFFER_EMPTY unset
  => Entering in the loop to fetch character from the serial
2) GetOneKeyFromSerial()
  => Return directly with the character read
3) Looping as the fifo is not full and no error
4) GetOneKeyFromSerial() -> SerialRead()
  => No more character so SerialPortPoll() will return FALSE and loop
 until timeout
  => Return EFI_TIMEOUT
5) Exiting the loop from TerminalConInTimerHandler
6) Characters are printed

After some investigation, I found it is related to the Timeout value.

The Timeout is 100 (1s) by default to follow UEFI spec.
And the Terminal driver will recalculate and set the Timeout value
based on the properties of UART in TerminalDriverBindingStart()/
TerminalConInTimerHandler().

  SerialInTimeOut = 0;
  if (Mode->BaudRate != 0) {
//
// According to BAUD rate to calculate the timeout value.
//
SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) *
  2 * 100 / (UINTN) Mode->BaudRate;
  }

For example, based on the PCD values of PcdUartDefaultBaudRate,
PcdUartDefaultDataBits and PcdUartDefaultStopBits, SerialInTimeOut =
(1 + 8  + 1) * 2 * 100 / (UINTN) 115200 = 173 (us).

When SerialDxe is used,
TerminalDriverBindingStart()/TerminalConInTimerHandler() ->
  SerialIo->SetAttributes() ->
SerialSetAttributes() ->
  SerialPortSetAttributes()

Some implementations of SerialPortSetAttributes() could handle the
input parameters and return RETURN_SUCCESS, for example
BaseSerialPortLib16550, then Timeout value will be changed to 173 (us),
no "slow down" will be observed.
But some implementations of SerialPortSetAttributes() just return
RETURN_UNSUPPORTED, for example XenConsoleSerialPortLib, then Timeout
value will be not changed and kept 100 (1s), "slow down" will be
observed.

SerialPortLib instance can be enhanced to
1. Handle the input parameters and return status accordingly instead of
just returning RETURN_UNSUPPORTED in SerialPortSetAttributes().
2. Just return RETURN_SUCCESS instead of RETURN_UNSUPPORTED in
SerialPortSetAttributes() if the instance does not care the input
parameters at all.

And SerialDxe can also be enhanced like this patch to be more robust
to handle Timeout change.

Cc: Julien Grall 
Cc: Laszlo Ersek 
Cc: Ruiyu Ni 
Compare against the original parameters
  Suggested-by: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 

V2: Compare against the original parameters
---
 MdeModulePkg/Universal/SerialDxe/SerialIo.c | 45 +++--
 1 file changed, 42 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/SerialDxe/SerialIo.c 
b/MdeModulePkg/Universal/SerialDxe/SerialIo.c
index ebcd92726314..5be77e7acfb0 100644
--- a/MdeModulePkg/Universal/SerialDxe/SerialIo.c
+++ b/MdeModulePkg/Universal/SerialDxe/SerialIo.c
@@ -280,12 +280,51 @@ SerialSetAttributes (
   IN EFI_STOP_BITS_TYPE StopBits
   )
 {
-  EFI_STATUSStatus;
-  EFI_TPL   Tpl;
+  EFI_STATUSStatus;
+  EFI_TPL   Tpl;
+  UINT64OriginalBaudRate;
+  UINT32OriginalReceiveFifoDepth;
+  UINT32OriginalTimeout;
+  EFI_PARITY_TYPE   OriginalParity;
+  UINT8 OriginalDataBits;
+  EFI_STOP_BITS_TYPEOriginalStopBits;
 
+  //
+  // Preserve the original input values in case
+  // SerialPortSetAttributes() updates the input/output parameters even on 
error.
+  //
+  OriginalBaudRate = BaudRate;
+  OriginalReceiveFifoDepth = ReceiveFifoDepth;
+  OriginalTimeout = Timeout;
+  OriginalParity = Parity;
+  OriginalDataBits = DataBits;
+  OriginalStopBits = StopBits;
   Status = SerialPortSetAttributes (, , , 
, , );
   if (EFI_ERROR (Status)) {
-return Status;
+//
+// If it is just to set Timeout value and unsupported is returned,
+// do not return error.
+//
+if ((Status == EFI_UNSUPPORTED) &&
+(This->Mode->Timeout  != OriginalTimeout) &&
+(This->Mode->ReceiveFifoDepth == OriginalReceiveFifoDepth) &&
+(This->Mode->BaudRate == OriginalBaudRate) &&
+(This->Mode->DataBits == (UINT32) OriginalDataBits) &&
+(This->Mode->Parity   == (UINT32) OriginalParity) &&
+(This->Mode->StopBits == (UINT32) OriginalStopBits)) {
+  //
+  // Restore to the original input values.
+  //
+  

Re: [edk2] [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries of RT_CODE in memory map

2017-11-06 Thread Zeng, Star
Hi,

Do you have further concern to this patch and have a RB?
If no, I am happy to help push this patch with my AB.

Thanks,
Star
-Original Message-
From: Wang, Jian J 
Sent: Tuesday, November 7, 2017 8:55 AM
To: Zeng, Star ; edk2-devel@lists.01.org
Cc: Laszlo Ersek ; Yao, Jiewen ; Dong, 
Eric 
Subject: RE: [edk2] [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries of 
RT_CODE in memory map

Thanks for the review. And I agree that GCD.SetMemoryAttributes should be used 
all the time in DxeCore. Let's fix it in another patch.

> -Original Message-
> From: Zeng, Star
> Sent: Monday, November 06, 2017 5:16 PM
> To: Wang, Jian J ; edk2-devel@lists.01.org
> Cc: Laszlo Ersek ; Yao, Jiewen 
> ; Dong, Eric ; Zeng, Star 
> 
> Subject: RE: [edk2] [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries 
> of RT_CODE in memory map
> 
> I am ok to this code approach.
> 
> Acknowledged-by: Star Zeng 
> 
> Besides, I think except GCD services, DxeCore should not call gCpu-
> >SetMemoryAttributes() directly, for example 
> >ApplyMemoryProtectionPolicy(), it
> should have no assumption of the CPU code (to set capabilities), and 
> call GCD setcapabilities first, and then call GCD setattributes since
> 14dde9e903bb9a719ebb8f3381da72b19509bc36 "MdeModulePkg/Core: Fix out- 
> of-sync issue in GCD", otherwise there may be mismatch of page 
> attributes between GCD and gCPU after 
> RefreshGcdMemoryAttributesFromPaging() by the calling 
> gCpu->SetMemoryAttributes() in ApplyMemoryProtectionPolicy().
> 
> Anyway, that could be in a separated patch. :)
> 
> Thanks,
> Star
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Jian J Wang
> Sent: Friday, November 3, 2017 8:57 AM
> To: edk2-devel@lists.01.org
> Cc: Laszlo Ersek ; Yao, Jiewen 
> ; Dong, Eric 
> Subject: [edk2] [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries of 
> RT_CODE in memory map
> 
> > v2
> > a. Fix an issue which will cause setting capability failure if size is 
> > smaller
> >than a page.
> 
> More than one entry of RT_CODE memory might cause boot problem for 
> some old OSs. This patch will fix this issue to keep OS compatibility as much 
> as possible.
> 
> More detailed information, please refer to
> https://bugzilla.tianocore.org/show_bug.cgi?id=753
> 
> Cc: Eric Dong 
> Cc: Jiewen Yao 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang 
> ---
>  UefiCpuPkg/CpuDxe/CpuPageTable.c | 18 ++
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c
> b/UefiCpuPkg/CpuDxe/CpuPageTable.c
> index d312eb66f8..4a7827ebc9 100644
> --- a/UefiCpuPkg/CpuDxe/CpuPageTable.c
> +++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c
> @@ -809,7 +809,9 @@ RefreshGcdMemoryAttributesFromPaging (
>PageLength= 0;
> 
>for (Index = 0; Index < NumberOfDescriptors; Index++) {
> -if (MemorySpaceMap[Index].GcdMemoryType ==
> EfiGcdMemoryTypeNonExistent) {
> +if (MemorySpaceMap[Index].GcdMemoryType ==
> EfiGcdMemoryTypeNonExistent
> +|| (MemorySpaceMap[Index].BaseAddress & EFI_PAGE_MASK) != 0
> +|| (MemorySpaceMap[Index].Length & EFI_PAGE_MASK) != 0) {
>continue;
>  }
> 
> @@ -829,6 +831,15 @@ RefreshGcdMemoryAttributesFromPaging (
>  // Sync real page attributes to GCD
>  BaseAddress   = MemorySpaceMap[Index].BaseAddress;
>  MemorySpaceLength = MemorySpaceMap[Index].Length;
> +Capabilities  = MemorySpaceMap[Index].Capabilities |
> +EFI_MEMORY_PAGETYPE_MASK;
> +Status = gDS->SetMemorySpaceCapabilities (
> +BaseAddress,
> +MemorySpaceLength,
> +Capabilities
> +);
> +ASSERT_EFI_ERROR (Status);
> +
>  while (MemorySpaceLength > 0) {
>if (PageLength == 0) {
>  PageEntry = GetPageTableEntry (, BaseAddress, 
> ); @@ -846,7 +857,6 @@ 
> RefreshGcdMemoryAttributesFromPaging (
>  if (Attributes != (MemorySpaceMap[Index].Attributes &
> EFI_MEMORY_PAGETYPE_MASK)) {
>DoUpdate = TRUE;
>Attributes |= (MemorySpaceMap[Index].Attributes & 
> ~EFI_MEMORY_PAGETYPE_MASK);
> -  Capabilities = Attributes | MemorySpaceMap[Index].Capabilities;
>  } else {
>DoUpdate = FALSE;
>  }
> @@ -854,8 +864,8 @@ RefreshGcdMemoryAttributesFromPaging (
> 
>Length = MIN (PageLength, MemorySpaceLength);
>if (DoUpdate) {
> -gDS->SetMemorySpaceCapabilities (BaseAddress, Length, Capabilities);
> -

[edk2] [PATCH 2/2] SecurityPkg/AuthVariableLib: Use EFI_CERT_DATA to parse certificate

2017-11-06 Thread chenc2
The function Pkcs7GetSigners return certificate stack as binary buffer.
Use EFI_CERT_DATA to parsing certificate stack more clearly, and access
certificate by the field of EFI_CERT_DATA structure.

Cc: Long Qin 
Cc: Zhang Chao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: chenc2 
---
 SecurityPkg/Library/AuthVariableLib/AuthService.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c 
b/SecurityPkg/Library/AuthVariableLib/AuthService.c
index 6cbeb98535..213a524f27 100644
--- a/SecurityPkg/Library/AuthVariableLib/AuthService.c
+++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c
@@ -1828,6 +1828,7 @@ VerifyTimeBasedPayload (
   UINT8*CertsInCertDb;
   UINT32   CertsSizeinDb;
   UINT8Sha256Digest[SHA256_DIGEST_SIZE];
+  EFI_CERT_DATA*CertDataPtr;
 
   //
   // 1. TopLevelCert is the top-level issuer certificate in signature Signer 
Cert Chain
@@ -1841,6 +1842,7 @@ VerifyTimeBasedPayload (
   SignerCerts= NULL;
   TopLevelCert   = NULL;
   CertsInCertDb  = NULL;
+  CertDataPtr= NULL;
 
   //
   // When the attribute EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS is
@@ -2098,9 +2100,10 @@ VerifyTimeBasedPayload (
 //
 // Check hash of signer cert CommonName + Top-level issuer 
tbsCertificate against data in CertDb
 //
+CertDataPtr = (EFI_CERT_DATA *)(SignerCerts + 1);
 Status = CalculatePrivAuthVarSignChainSHA256Digest(
-   SignerCerts + sizeof(UINT8) + sizeof(UINT32),
-   ReadUnaligned32 ((UINT32 *)(SignerCerts + sizeof(UINT8))),
+   CertDataPtr->CertDataBuffer,
+   ReadUnaligned32 ((UINT32 *)&(CertDataPtr->CertDataLength)),
TopLevelCert,
TopLevelCertSize,
Sha256Digest
@@ -2135,12 +2138,13 @@ VerifyTimeBasedPayload (
   //
   // When adding a new common authenticated variable, always save Hash of 
cn of signer cert + tbsCertificate of Top-level issuer
   //
+  CertDataPtr = (EFI_CERT_DATA *)(SignerCerts + 1);
   Status = InsertCertsToDb (
  VariableName,
  VendorGuid,
  Attributes,
- SignerCerts + sizeof(UINT8) + sizeof(UINT32),
- ReadUnaligned32 ((UINT32 *)(SignerCerts + sizeof(UINT8))),
+ CertDataPtr->CertDataBuffer,
+ ReadUnaligned32 ((UINT32 *)&(CertDataPtr->CertDataLength)),
  TopLevelCert,
  TopLevelCertSize
  );
-- 
2.13.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 1/2] CryptoPkg/BaseCryptLib: Add C-structure to matching certificate stack

2017-11-06 Thread chenc2
The parameter CertStack of Pkcs7GetSigners will return all embedded X.509
certificate in one given PKCS7 signature. The format is:
//
// UINT8  CertNumber;
// UINT32 Cert1Length;
// UINT8  Cert1[];
// UINT32 Cert2Length;
// UINT8  Cert2[];
// ...
// UINT32 CertnLength;
// UINT8  Certn[];
//
Add EFI_CERT_STACK and EFI_CERT_DATA structure, these two C-structure are
used for parsing CertStack more clearly.

Cc: Long Qin 
Cc: Zhang Chao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: chenc2 
---
 CryptoPkg/Include/Library/BaseCryptLib.h   | 33 ++
 .../Library/BaseCryptLib/Pk/CryptPkcs7Verify.c |  3 ++
 .../Library/BaseCryptLib/Pk/CryptPkcs7VerifyNull.c |  3 ++
 3 files changed, 39 insertions(+)

diff --git a/CryptoPkg/Include/Library/BaseCryptLib.h 
b/CryptoPkg/Include/Library/BaseCryptLib.h
index e2b6a95666..3fd9a3c911 100644
--- a/CryptoPkg/Include/Library/BaseCryptLib.h
+++ b/CryptoPkg/Include/Library/BaseCryptLib.h
@@ -2377,6 +2377,36 @@ Pkcs5HashPassword (
   );
 
 /**
+  The 3rd parameter of Pkcs7GetSigners will return all embedded
+  X.509 certificate in one given PKCS7 signature. The format is:
+  //
+  // UINT8  CertNumber;
+  // UINT32 Cert1Length;
+  // UINT8  Cert1[];
+  // UINT32 Cert2Length;
+  // UINT8  Cert2[];
+  // ...
+  // UINT32 CertnLength;
+  // UINT8  Certn[];
+  //
+
+  The two following C-structure are used for parsing CertStack more clearly.
+**/
+#pragma pack(1)
+
+typedef struct {
+  UINT32CertDataLength;   // The length in bytes of X.509 certificate.
+  UINT8 CertDataBuffer[0];// The X.509 certificate content (DER).
+}EFI_CERT_DATA;
+
+typedef struct {
+  UINT8 CertNumber;   // Number of X.509 certificate.
+  //EFI_CERT_DATA   CertArray[];  // An array of X.509 certificate.
+}EFI_CERT_STACK;
+
+#pragma pack()
+
+/**
   Get the signer's certificates from PKCS#7 signed data as described in "PKCS 
#7:
   Cryptographic Message Syntax Standard". The input signed data could be 
wrapped
   in a ContentInfo structure.
@@ -2390,6 +2420,7 @@ Pkcs5HashPassword (
   @param[out] CertStackPointer to Signer's certificates retrieved from 
P7Data.
It's caller's responsibility to free the buffer with
Pkcs7FreeSigners().
+   This data structure is EFI_CERT_STACK type.
   @param[out] StackLength  Length of signer's certificates in bytes.
   @param[out] TrustedCert  Pointer to a trusted certificate from Signer's 
certificates.
It's caller's responsibility to free the buffer with
@@ -2437,9 +2468,11 @@ Pkcs7FreeSigners (
   @param[out] SignerChainCerts  Pointer to the certificates list chained to 
signer's
 certificate. It's caller's responsibility to 
free the buffer
 with Pkcs7FreeSigners().
+This data structure is EFI_CERT_STACK type.
   @param[out] ChainLength   Length of the chained certificates list buffer 
in bytes.
   @param[out] UnchainCerts  Pointer to the unchained certificates lists. 
It's caller's
 responsibility to free the buffer with 
Pkcs7FreeSigners().
+This data structure is EFI_CERT_STACK type.
   @param[out] UnchainLength Length of the unchained certificates list 
buffer in bytes.
 
   @retval  TRUE The operation is finished successfully.
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c 
b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c
index 296df028b1..fe8e5950f9 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c
@@ -242,6 +242,7 @@ _Exit:
   @param[out] CertStackPointer to Signer's certificates retrieved from 
P7Data.
It's caller's responsibility to free the buffer with
Pkcs7FreeSigners().
+   This data structure is EFI_CERT_STACK type.
   @param[out] StackLength  Length of signer's certificates in bytes.
   @param[out] TrustedCert  Pointer to a trusted certificate from Signer's 
certificates.
It's caller's responsibility to free the buffer with
@@ -442,9 +443,11 @@ Pkcs7FreeSigners (
   @param[out] SignerChainCerts  Pointer to the certificates list chained to 
signer's
 certificate. It's caller's responsibility to 
free the buffer
 with Pkcs7FreeSigners().
+This data structure is EFI_CERT_STACK type.
   @param[out] ChainLength   Length of the chained certificates list buffer 
in bytes.
   @param[out] UnchainCerts  Pointer to the unchained certificates lists. 
It's caller's
 responsibility to free the 

Re: [edk2] [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries of RT_CODE in memory map

2017-11-06 Thread Wang, Jian J
Thanks for the review. And I agree that GCD.SetMemoryAttributes should be
used all the time in DxeCore. Let's fix it in another patch.

> -Original Message-
> From: Zeng, Star
> Sent: Monday, November 06, 2017 5:16 PM
> To: Wang, Jian J ; edk2-devel@lists.01.org
> Cc: Laszlo Ersek ; Yao, Jiewen ;
> Dong, Eric ; Zeng, Star 
> Subject: RE: [edk2] [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries of
> RT_CODE in memory map
> 
> I am ok to this code approach.
> 
> Acknowledged-by: Star Zeng 
> 
> Besides, I think except GCD services, DxeCore should not call gCpu-
> >SetMemoryAttributes() directly, for example ApplyMemoryProtectionPolicy(), it
> should have no assumption of the CPU code (to set capabilities), and call GCD
> setcapabilities first, and then call GCD setattributes since
> 14dde9e903bb9a719ebb8f3381da72b19509bc36 "MdeModulePkg/Core: Fix out-
> of-sync issue in GCD", otherwise there may be mismatch of page attributes
> between GCD and gCPU after RefreshGcdMemoryAttributesFromPaging() by the
> calling gCpu->SetMemoryAttributes() in ApplyMemoryProtectionPolicy().
> 
> Anyway, that could be in a separated patch. :)
> 
> Thanks,
> Star
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Jian J
> Wang
> Sent: Friday, November 3, 2017 8:57 AM
> To: edk2-devel@lists.01.org
> Cc: Laszlo Ersek ; Yao, Jiewen ;
> Dong, Eric 
> Subject: [edk2] [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries of RT_CODE
> in memory map
> 
> > v2
> > a. Fix an issue which will cause setting capability failure if size is 
> > smaller
> >than a page.
> 
> More than one entry of RT_CODE memory might cause boot problem for some
> old OSs. This patch will fix this issue to keep OS compatibility as much as 
> possible.
> 
> More detailed information, please refer to
> https://bugzilla.tianocore.org/show_bug.cgi?id=753
> 
> Cc: Eric Dong 
> Cc: Jiewen Yao 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang 
> ---
>  UefiCpuPkg/CpuDxe/CpuPageTable.c | 18 ++
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c
> b/UefiCpuPkg/CpuDxe/CpuPageTable.c
> index d312eb66f8..4a7827ebc9 100644
> --- a/UefiCpuPkg/CpuDxe/CpuPageTable.c
> +++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c
> @@ -809,7 +809,9 @@ RefreshGcdMemoryAttributesFromPaging (
>PageLength= 0;
> 
>for (Index = 0; Index < NumberOfDescriptors; Index++) {
> -if (MemorySpaceMap[Index].GcdMemoryType ==
> EfiGcdMemoryTypeNonExistent) {
> +if (MemorySpaceMap[Index].GcdMemoryType ==
> EfiGcdMemoryTypeNonExistent
> +|| (MemorySpaceMap[Index].BaseAddress & EFI_PAGE_MASK) != 0
> +|| (MemorySpaceMap[Index].Length & EFI_PAGE_MASK) != 0) {
>continue;
>  }
> 
> @@ -829,6 +831,15 @@ RefreshGcdMemoryAttributesFromPaging (
>  // Sync real page attributes to GCD
>  BaseAddress   = MemorySpaceMap[Index].BaseAddress;
>  MemorySpaceLength = MemorySpaceMap[Index].Length;
> +Capabilities  = MemorySpaceMap[Index].Capabilities |
> +EFI_MEMORY_PAGETYPE_MASK;
> +Status = gDS->SetMemorySpaceCapabilities (
> +BaseAddress,
> +MemorySpaceLength,
> +Capabilities
> +);
> +ASSERT_EFI_ERROR (Status);
> +
>  while (MemorySpaceLength > 0) {
>if (PageLength == 0) {
>  PageEntry = GetPageTableEntry (, BaseAddress,
> ); @@ -846,7 +857,6 @@
> RefreshGcdMemoryAttributesFromPaging (
>  if (Attributes != (MemorySpaceMap[Index].Attributes &
> EFI_MEMORY_PAGETYPE_MASK)) {
>DoUpdate = TRUE;
>Attributes |= (MemorySpaceMap[Index].Attributes &
> ~EFI_MEMORY_PAGETYPE_MASK);
> -  Capabilities = Attributes | MemorySpaceMap[Index].Capabilities;
>  } else {
>DoUpdate = FALSE;
>  }
> @@ -854,8 +864,8 @@ RefreshGcdMemoryAttributesFromPaging (
> 
>Length = MIN (PageLength, MemorySpaceLength);
>if (DoUpdate) {
> -gDS->SetMemorySpaceCapabilities (BaseAddress, Length, Capabilities);
> -gDS->SetMemorySpaceAttributes (BaseAddress, Length, Attributes);
> +Status = gDS->SetMemorySpaceAttributes (BaseAddress, Length,
> Attributes);
> +ASSERT_EFI_ERROR (Status);
>  DEBUG ((DEBUG_INFO, "Update memory space attribute: [%02d] %016lx -
>  %016lx (%08lx -> %08lx)\r\n",
>   Index, BaseAddress, BaseAddress + Length - 1,
>   MemorySpaceMap[Index].Attributes, Attributes));
> --
> 2.14.1.windows.1
> 
> 

[edk2] Riding the UEFI shell / enabling the platform for C developers

2017-11-06 Thread joaquin_conobolillo
Hi Tim,



With the disappearance of MSDOS as a simple, single threaded, unprotected 
operating system with full hardware access to user programs on upcoming 
personal computer models the UEFI shell was intended to be the successor of 
MSDOS.

please try  

https://github.com/JoaquinCono/VisualUEFIShell

for UEFI Shell Applications.




Regards,

JC






Sent from Surface





From: Joaquin Cono Bolillo
Sent: ‎Friday‎, ‎December‎ ‎2‎, ‎2016 ‎8‎:‎55‎ ‎AM
To: Tim Lewis






Hi Tim,

 

this is because StdLibC is not implemented carefully.

There will be a C Development Environment CdePkg on Github

beginning next year.

 

JC

 

 

Gesendet von Mail für Windows 10

 


Von: Tim Lewis
Gesendet: Friday, December 2, 2016 03:08 AM
An: edk2-devel@lists.01.org
Betreff: [edk2] Root Cause of Parse Failure With Redirected Input

 

  if (StrStr (TempLine, L"ShellCommand,") == TempLine) {

LoopVariable++;

  }

 

This line fails because, with redirected input, the file has the UCS-2 byte 
order mark, so the string "ShellCommand," is not at the beginning of the line. 
With the file, the byte order mark is not present.

 

Why?

 

 if (StreamingUnicode) {

   TempLine = ParseReturnStdInLine (FileHandle);

 } else {

   TempLine = ShellFileHandleReturnLine (FileHandle, );

 }

 

The Shell library function ShellFileHandleReturnLine will strip off the byte 
order mark. But the ParseReturnStdInLine does not. So the first character on 
the line is not 'S', it is the byte order mark.

 

Tim

___

edk2-devel mailing list

edk2-devel@lists.01.org

https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] PcAtChipsetPkg/IsaAcpiDxe: Restore PCI attributes correctly

2017-11-06 Thread Laszlo Ersek
Hi Ray,

On 11/03/17 09:28, Ruiyu Ni wrote:
> The original code enables some BITs in PCI attributes in Start(),
> but wrongly to disable these BITs in Stop().
> 
> The correct behavior is to save the original PCI attributes before
> enables some BITs in Start(), and restore to original value
> in Stop().
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni 
> Cc: Star Zeng 
> Cc: Laszlo Ersek 
> ---
>  PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c | 44 
> +
>  PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.h |  3 ++-
>  2 files changed, 25 insertions(+), 22 deletions(-)

Is this for ?

If so, can you please add the reference to the commit message?

Also, I think we should ask Steven to test the patch. (CC'd.)

I'll try to comment more later.

Thanks
Laszlo


> 
> diff --git a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c 
> b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c
> index 32381b112d..60d2fb5a5b 100644
> --- a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c
> +++ b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c
> @@ -172,6 +172,7 @@ PcatIsaAcpiDriverBindingStart (
>EFI_PCI_IO_PROTOCOL  *PciIo;
>PCAT_ISA_ACPI_DEV*PcatIsaAcpiDev;
>UINT64   Supports;
> +  UINT64   OriginalAttributes;
>BOOLEAN  Enabled;
>  
>Enabled = FALSE;
> @@ -210,9 +211,18 @@ PcatIsaAcpiDriverBindingStart (
>if (Supports == 0 || Supports == (EFI_PCI_IO_ATTRIBUTE_ISA_IO | 
> EFI_PCI_IO_ATTRIBUTE_ISA_IO_16)) {
>  Status = EFI_UNSUPPORTED;
>  goto Done;
> -  }  
> +  }
> +
> +  Status = PciIo->Attributes (
> +PciIo,
> +EfiPciIoAttributeOperationGet,
> +0,
> +
> +);
> +  if (EFI_ERROR (Status)) {
> +goto Done;
> +  }
>  
> -  Enabled = TRUE;
>Status = PciIo->Attributes (
>  PciIo, 
>  EfiPciIoAttributeOperationEnable, 
> @@ -222,7 +232,8 @@ PcatIsaAcpiDriverBindingStart (
>if (EFI_ERROR (Status)) {
>  goto Done;
>}
> -  
> +
> +  Enabled = TRUE;
>//
>// Allocate memory for the PCAT ISA ACPI Device structure
>//
> @@ -239,9 +250,10 @@ PcatIsaAcpiDriverBindingStart (
>//
>// Initialize the PCAT ISA ACPI Device structure
>//
> -  PcatIsaAcpiDev->Signature = PCAT_ISA_ACPI_DEV_SIGNATURE;
> -  PcatIsaAcpiDev->Handle= Controller;
> -  PcatIsaAcpiDev->PciIo = PciIo;
> +  PcatIsaAcpiDev->Signature = PCAT_ISA_ACPI_DEV_SIGNATURE;
> +  PcatIsaAcpiDev->Handle= Controller;
> +  PcatIsaAcpiDev->PciIo = PciIo;
> +  PcatIsaAcpiDev->OriginalAttribute = OriginalAttributes;
>  
>//
>// Initialize PcatIsaAcpiDeviceList
> @@ -274,8 +286,8 @@ Done:
>  if (PciIo != NULL && Enabled) {
>PciIo->Attributes (
> PciIo, 
> -   EfiPciIoAttributeOperationDisable, 
> -   EFI_PCI_DEVICE_ENABLE | Supports | 
> EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO,
> +   EfiPciIoAttributeOperationSet, 
> +   OriginalAttributes,
> NULL 
> );
>  }
> @@ -321,7 +333,6 @@ PcatIsaAcpiDriverBindingStop (
>EFI_STATUS Status;
>EFI_ISA_ACPI_PROTOCOL  *IsaAcpi;
>PCAT_ISA_ACPI_DEV  *PcatIsaAcpiDev;
> -  UINT64 Supports;
>
>//
>// Get the ISA ACPI Protocol Interface
> @@ -348,23 +359,14 @@ PcatIsaAcpiDriverBindingStop (
>//
>Status = PcatIsaAcpiDev->PciIo->Attributes (
>  PcatIsaAcpiDev->PciIo,
> -EfiPciIoAttributeOperationSupported,
> -0,
> -
> +EfiPciIoAttributeOperationSet,
> +PcatIsaAcpiDev->OriginalAttribute,
> +0
>  );
>if (EFI_ERROR (Status)) {
>  return Status;
>}
>  
> -  Supports &= (UINT64) (EFI_PCI_IO_ATTRIBUTE_ISA_IO | 
> EFI_PCI_IO_ATTRIBUTE_ISA_IO_16);
> -
> -  PcatIsaAcpiDev->PciIo->Attributes (
> -   PcatIsaAcpiDev->PciIo, 
> -   EfiPciIoAttributeOperationDisable, 
> -   EFI_PCI_DEVICE_ENABLE | Supports | 
> EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO,
> -   NULL 
> -   );
> - 
>//
>// Uninstall protocol interface: EFI_ISA_ACPI_PROTOCOL
>//
> diff --git a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.h 
> b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.h
> index 0671127644..3ad3a3f313 100644
> --- a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.h
> +++ b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.h
> @@ -1,7 +1,7 @@
>  /** @file
>EFI PCAT ISA ACPI Driver for a Generic PC Platform
>  

Re: [edk2] [PATCH] MdeModulePkg SerialDxe: Handle Timeout change more robustly

2017-11-06 Thread Laszlo Ersek
Star,

On 11/02/17 02:41, Star Zeng wrote:
> https://lists.01.org/pipermail/edk2-devel/2017-October/016479.html
> reported "Xen Console input very slow in recent UEFI" that appears
> after 4cf3f37c87ba1f9d58072444bd735e40e4779e70 "MdeModulePkg
> SerialDxe: Process timeout consistently in SerialRead".
> 
> Julien did more debugging and find out the following is happening in
> TerminalConInTimerHandler (MdeModulePkg/Universal/Console/TerminalDxe)
> when a character is received:
> 1) GetControl will return EFI_SERIAL_INPUT_BUFFER_EMPTY unset
>   => Entering in the loop to fetch character from the serial
> 2) GetOneKeyFromSerial()
>   => Return directly with the character read
> 3) Looping as the fifo is not full and no error
> 4) GetOneKeyFromSerial() -> SerialRead()
>   => No more character so SerialPortPoll() will return FALSE and loop
>  until timeout
>   => Return EFI_TIMEOUT
> 5) Exiting the loop from TerminalConInTimerHandler
> 6) Characters are printed
> 
> After some investigation, I found it is related to the Timeout value.
> 
> The Timeout is 100 (1s) by default to follow UEFI spec.
> And the Terminal driver will recalculate and set the Timeout value
> based on the properties of UART in TerminalDriverBindingStart()/
> TerminalConInTimerHandler().
> 
>   SerialInTimeOut = 0;
>   if (Mode->BaudRate != 0) {
> //
> // According to BAUD rate to calculate the timeout value.
> //
> SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) *
>   2 * 100 / (UINTN) Mode->BaudRate;
>   }
> 
> For example, based on the PCD values of PcdUartDefaultBaudRate,
> PcdUartDefaultDataBits and PcdUartDefaultStopBits, SerialInTimeOut =
> (1 + 8  + 1) * 2 * 100 / (UINTN) 115200 = 173 (us).
> 
> When SerialDxe is used,
> TerminalDriverBindingStart()/TerminalConInTimerHandler() ->
>   SerialIo->SetAttributes() ->
> SerialSetAttributes() ->
>   SerialPortSetAttributes()
> 
> Some implementations of SerialPortSetAttributes() could handle the
> input parameters and return RETURN_SUCCESS, for example
> BaseSerialPortLib16550, then Timeout value will be changed to 173 (us),
> no "slow down" will be observed.
> But some implementations of SerialPortSetAttributes() just return
> RETURN_UNSUPPORTED, for example XenConsoleSerialPortLib, then Timeout
> value will be not changed and kept 100 (1s), "slow down" will be
> observed.
> 
> SerialPortLib instance can be enhanced to
> 1. Handle the input parameters and return status accordingly instead of
> just returning RETURN_UNSUPPORTED in SerialPortSetAttributes().
> 2. Just return RETURN_SUCCESS instead of RETURN_UNSUPPORTED in
> SerialPortSetAttributes() if the instance does not care the input
> parameters at all.
> 
> And SerialDxe can also be enhanced like this patch to be more robust
> to handle Timeout change.
> 
> Cc: Julien Grall 
> Cc: Laszlo Ersek 
> Cc: Ruiyu Ni 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/Universal/SerialDxe/SerialIo.c | 16 +++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Universal/SerialDxe/SerialIo.c 
> b/MdeModulePkg/Universal/SerialDxe/SerialIo.c
> index ebcd92726314..060ea56c2b1a 100644
> --- a/MdeModulePkg/Universal/SerialDxe/SerialIo.c
> +++ b/MdeModulePkg/Universal/SerialDxe/SerialIo.c
> @@ -285,7 +285,21 @@ SerialSetAttributes (
>  
>Status = SerialPortSetAttributes (, , , 
> , , );
>if (EFI_ERROR (Status)) {
> -return Status;
> +//
> +// If it is just to set Timeout value and unsupported is returned,
> +// do not return error.
> +//
> +if ((Status == EFI_UNSUPPORTED) &&
> +(This->Mode->Timeout  != Timeout) &&
> +(This->Mode->ReceiveFifoDepth == ReceiveFifoDepth) &&
> +(This->Mode->BaudRate == BaudRate) &&
> +(This->Mode->DataBits == (UINT32) DataBits) &&
> +(This->Mode->Parity   == (UINT32) Parity) &&
> +(This->Mode->StopBits == (UINT32) StopBits)) {
> +  Status = EFI_SUCCESS;
> +} else {
> +  return Status;
> +}
>}
>  
>//
> 

is the SerialPortSetAttributes() library API allowed to overwrite --
possibly even with garbage -- the IN OUT parameters if it fails?
Practice is inconsistent on this; some library APIs explicitly "taint"
output parameters on error, while others explicitly "preserve"
input/output parameters on error. Yet others (a few exceptional APIs)
output valid / sensible values *even* on error. This API in particular
promises neither (in the lib class header), so I don't know.

If it is not much burden, I'd prefer comparisons against the original
parameters, not against those that were possibly modified by
SerialPortSetAttributes(), before it returned EFI_UNSUPPORTED.

I'll leave it up to you to decide.

Reviewed-by: Laszlo Ersek 

Re: [edk2] [Help] UEFI boot KVM4T vm hang On TianoCore

2017-11-06 Thread Laszlo Ersek
Hi,

sorry about the delayed response.

CC'ing Igor, and commenting below:

On 10/31/17 15:29, Hangaohuai wrote:
> Hi, Laszlo Ersek;
>
> I have tested the uefi booting KVM vm with the configuration(xml); but
> start hang.
> Enable the memoryhotplug, with usb3.0 config. The config as Config1
> below.
>
> Tested branches:
> UDK2017 eea98eea4ccbb1d640657770bccb5497fddc6064
> Master   76fd5a660d704538a1b14a58d03a4eef9682b01c
>
> Both hang on the snapshot TianoCore in VNC
>
> Try to shoot the problem;
> I find the early version can boot success with the same config.
> Maybe the patch1 below cause the problem;
>
> Try to ignore the patch does, the master/ UDK2017 both can boot
> success.
> But I don't know why. Hope for your help,thanks.
>
> Patch1
> ***
> commit 4f5eff8193096eb847639f090a7dfae3cff95fde
> Author: Laszlo Ersek 
> Date:   Fri Mar 4 20:06:26 2016 +0100
>
> OvmfPkg: PciHostBridgeLib: install 64-bit PCI host aperture
>
> diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c 
> b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib
> index 3e02778..1d3d10a 100644
> --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
> +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
> @@ -132,6 +132,13 @@ InitRootBridge (
>RootBus->MemAbove4G.Base  = 0;
>RootBus->MemAbove4G.Limit = 0;
> +  if (PcdGet64 (PcdPciMmio64Size) > 0) {
> +RootBus->AllocationAttributes |= EFI_PCI_HOST_BRIDGE_MEM64_DECODE;
> +RootBus->MemAbove4G.Base   = PcdGet64 (PcdPciMmio64Base);
> +RootBus->MemAbove4G.Limit  = PcdGet64 (PcdPciMmio64Base) +
> + (PcdGet64 (PcdPciMmio64Size) - 1);
> +  }
> +
>RootBus->Bus.Base  = RootBusNumber;
>RootBus->Bus.Limit = MaxSubBusNumber;
>RootBus->Io.Base   = PcdGet64 (PcdPciIoBase);
> diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf 
> b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeL
> index bbec746..7a964c7 100644
> --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
> +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
> @@ -51,4 +51,6 @@
>gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize
>gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base
>gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size
> +  gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base
> +  gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size
>gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
> ***
>
>
> Config1
> ***
> 4294967296
>   4294967
>   4294967
> Xxxx
> 
>  function='0x0'/>
>  
> ***

The patch that you identified is responsible for exposing the 64-bit
MMIO aperture for PCI MMIO BAR allocation purposes.

Reverting this patch might mask the issue, but I don't expect the actual
problem to be in this patch.

Instead, the base address and the size of the aperture in question is
determined in the file

  OvmfPkg/PlatformPei/MemDetect.c

in the function

  GetFirstNonAddress()

This function takes the memory (DIMM) hotplug range in question, the end
of which is presented by QEMU in the fw_cfg file

  etc/reserved-memory-end

To my knowledge, this fw_cfg file is an 8-byte integer in LE encoding.

Quoting the code:

>   //
>   // If QEMU presents an E820 map, then get the highest exclusive >=4GB RAM
>   // address from it. This can express an address >= 4GB+1TB.
>   //
>   // Otherwise, get the flat size of the memory above 4GB from the CMOS (which
>   // can only express a size smaller than 1TB), and add it to 4GB.
>   //
>   Status = ScanOrAdd64BitE820Ram ();
>   if (EFI_ERROR (Status)) {
> FirstNonAddress = BASE_4GB + GetSystemMemorySizeAbove4gb ();
>   }
>
> ...
>
>   //
>   // The "etc/reserved-memory-end" fw_cfg file, when present, contains an
>   // absolute, exclusive end address for the memory hotplug area. This area
>   // starts right at the end of the memory above 4GB. The 64-bit PCI host
>   // aperture must be placed above it.
>   //
>   Status = QemuFwCfgFindFile ("etc/reserved-memory-end", ,
>  );
>   if (!EFI_ERROR (Status) && FwCfgSize == sizeof HotPlugMemoryEnd) {
> QemuFwCfgSelectItem (FwCfgItem);
> QemuFwCfgReadBytes (FwCfgSize, );
>
> ASSERT (HotPlugMemoryEnd >= FirstNonAddress);
> FirstNonAddress = HotPlugMemoryEnd;
>   }

Can you check if the ASSERT fires for you?

For that, please capture the OVMF debug log like this:

(1) build OVMF with the following flag:

  --pcd=gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel=0x8040004F

(2) modify your domain XML as follows:

  
 ^^^   
<--- don't forget this attribute!

  
  
  
  

  

Then the file "/tmp/ovmf.log" should contain a verbose OVMF log --
please attach it.

Thanks
Laszlo
___

[edk2] [PATCH v2 0/3] ArmPlatformPkg EmbeddedPkg: consolidate shared RTC functionality

2017-11-06 Thread Ard Biesheuvel
This moves input validation and recording of the DST and timezone settings
(which cannot usually be done by the hardware) into the core RTC driver in
EmbeddedPkg, and removes it from one of the RealTimeClockLib implementations,
the one for the ARM PL031.

v2: split PL031 into two
reinstate (but fix) the PL031 timezone handling (after reading and even
understanding the original code)

Ard Biesheuvel (3):
  EmbeddedPkg/RealTimeClockRuntimeDxe: move common functionality into
core
  ArmPlatformPkg/PL031RealTimeClockLib: remove validation and DST
handling
  ArmPlatformPkg/PL031RealTimeClockLib: ignore DST setting when timezone
is set

 ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c | 194 
++--
 EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c  | 171 
-
 EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf  |  11 +-
 3 files changed, 188 insertions(+), 188 deletions(-)

-- 
2.11.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 3/3] ArmPlatformPkg/PL031RealTimeClockLib: ignore DST setting when timezone is set

2017-11-06 Thread Ard Biesheuvel
According to the UEFI spec, the timezone setting which the platform needs
to record in addition to the actual date and time already reflects the
current DST setting. In other words, moving the clock from standard time
to daylight saving time also involves adding or subtracting 60 minutes
from the timezone setting, as well as flicking the EFI_TIME_IN_DAYLIGHT
bit in the DST setting.

This means we need to disregard the DST setting if the timezone is
specified, and only add or subtract the additional hour if we are on
local time.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c | 12 

 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git 
a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c 
b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
index f1eb0deb3249..459dcc0a0519 100644
--- a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
+++ b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
@@ -164,12 +164,10 @@ LibGetTime (
   }
 
   // Adjust for the correct time zone
+  // The timezone setting also reflects the DST setting of the clock
   if (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE) {
 EpochSeconds += Time->TimeZone * SEC_PER_MIN;
-  }
-
-  // Adjust for the correct period
-  if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) {
+  } else if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) {
 // Convert to adjusted time, i.e. spring forwards one hour
 EpochSeconds += SEC_PER_HOUR;
   }
@@ -229,12 +227,10 @@ LibSetTime (
   EpochSeconds = EfiTimeToEpoch (Time);
 
   // Adjust for the correct time zone, i.e. convert to UTC time zone
+  // The timezone setting also reflects the DST setting of the clock
   if (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE) {
 EpochSeconds -= Time->TimeZone * SEC_PER_MIN;
-  }
-
-  // Adjust for the correct period
-  if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) {
+  } else if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) {
 // Convert to un-adjusted time, i.e. fall back one hour
 EpochSeconds -= SEC_PER_HOUR;
   }
-- 
2.11.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 1/3] EmbeddedPkg/RealTimeClockRuntimeDxe: move common functionality into core

2017-11-06 Thread Ard Biesheuvel
RealTimeClockRuntimeDxe defers the hardware/platform specific handling
of reading/setting the hardware clock to RealTimeClockLib, but for
unknown reasons, it also defers common functionality such as input
validation and recording the timezone and DST settings (which are
informational only and not managed by hardware)

This has led to a lot of duplication in implementations of RealTimeClockLib
as well as TimeBaseLib, to the point where each library implementation
has its own set of UEFI variables to record the timezone and DST settings.
This makes little sense, and so let's update RealTimeClockRuntimeDxe now
to allow future implementations to rely on the core driver to take care of
these things.

Note that reading the timezone and DST settings occurs before calling into
the library, so we can phase out this behavior gradually from library
implementations in EDK2, edk2-platforms or out of tree.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c | 171 
+++-
 EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf |  11 +-
 2 files changed, 171 insertions(+), 11 deletions(-)

diff --git a/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c 
b/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
index f1e067c0b59e..6b7cc876fa33 100644
--- a/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
+++ b/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
@@ -1,10 +1,8 @@
 /** @file
   Implement EFI RealTimeClock runtime services via RTC Lib.
 
-  Currently this driver does not support runtime virtual calling.
-
-
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+  Copyright (c) 2017, Linaro, Ltd. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
@@ -17,14 +15,116 @@
 **/
 
 #include 
+#include 
+#include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 EFI_HANDLE  mHandle = NULL;
 
+//
+// These values can be set by SetTime () and need to be returned by GetTime ()
+// but cannot usually be kept by the RTC hardware, so we store them in a UEFI
+// variable instead.
+//
+typedef struct {
+  INT16   TimeZone;
+  UINT8   Daylight;
+} NON_VOLATILE_TIME_SETTINGS;
+
+STATIC CONST CHAR16 mTimeSettingsVariableName[] = L"RtcTimeSettings";
+STATIC NON_VOLATILE_TIME_SETTINGS mTimeSettings;
+
+STATIC
+BOOLEAN
+IsValidTimeZone (
+  IN  INT16  TimeZone
+  )
+{
+  return TimeZone == EFI_UNSPECIFIED_TIMEZONE ||
+ (TimeZone >= -1440 && TimeZone <= 1440);
+}
+
+STATIC
+BOOLEAN
+IsValidDaylight (
+  IN  INT8  Daylight
+  )
+{
+  return Daylight == 0 ||
+ Daylight == EFI_TIME_ADJUST_DAYLIGHT ||
+ Daylight == (EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT);
+}
 
+STATIC
+BOOLEAN
+EFIAPI
+IsLeapYear (
+  IN EFI_TIME   *Time
+  )
+{
+  if (Time->Year % 4 == 0) {
+if (Time->Year % 100 == 0) {
+  if (Time->Year % 400 == 0) {
+return TRUE;
+  } else {
+return FALSE;
+  }
+} else {
+  return TRUE;
+}
+  } else {
+return FALSE;
+  }
+}
+
+STATIC CONST INTN mDayOfMonth[12] = {
+  31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
+};
+
+STATIC
+BOOLEAN
+EFIAPI
+IsDayValid (
+  IN  EFI_TIME  *Time
+  )
+{
+  ASSERT (Time->Day >= 1);
+  ASSERT (Time->Day <= mDayOfMonth[Time->Month - 1]);
+  ASSERT (Time->Month != 2 || (IsLeapYear (Time) && Time->Day <= 29));
+
+  if (Time->Day < 1 ||
+  Time->Day > mDayOfMonth[Time->Month - 1] ||
+  (Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))) {
+return FALSE;
+  }
+  return TRUE;
+}
+
+STATIC
+BOOLEAN
+EFIAPI
+IsTimeValid(
+  IN EFI_TIME *Time
+  )
+{
+  // Check the input parameters are within the range specified by UEFI
+  if (Time->Year   < 1900   ||
+  Time->Year   >    ||
+  Time->Month  < 1  ||
+  Time->Month  > 12 ||
+  !IsDayValid (Time)||
+  Time->Hour   > 23 ||
+  Time->Minute > 59 ||
+  Time->Second > 59 ||
+  !IsValidTimeZone (Time->TimeZone) ||
+  !IsValidDaylight (Time->Daylight)) {
+return FALSE;
+  }
+  return TRUE;
+}
 
 /**
   Returns the current time and date information, and the time-keeping 
capabilities
@@ -43,9 +143,20 @@ EFI_STATUS
 EFIAPI
 GetTime (
   OUT EFI_TIME*Time,
-  OUT  EFI_TIME_CAPABILITIES  *Capabilities
+  OUT EFI_TIME_CAPABILITIES   *Capabilities
   )
 {
+  if (Time == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  //
+  // Set these first so the RealTimeClockLib implementation
+  // can override them based on its own settings.
+  //
+  Time->TimeZone = mTimeSettings.TimeZone;
+  Time->Daylight = mTimeSettings.Daylight;
+
   return LibGetTime (Time, Capabilities);
 }
 
@@ -67,7 +178,41 @@ SetTime (
   

[edk2] [PATCH v2 2/3] ArmPlatformPkg/PL031RealTimeClockLib: remove validation and DST handling

2017-11-06 Thread Ard Biesheuvel
This library, which is intended to encapsulate the hardware specifics
of the ARM PL031 RTC, also implements its own input validation routines
and record the timezone and DST settings in its own set of EFI variables.

This functionality has recently been added to the core driver, so let's
remove it here.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c | 186 
++--
 1 file changed, 15 insertions(+), 171 deletions(-)

diff --git 
a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c 
b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
index 41ebcb95ab85..f1eb0deb3249 100644
--- a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
+++ b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
@@ -40,8 +40,6 @@
 
 #include 
 
-STATIC CONST CHAR16   mTimeZoneVariableName[] = L"PL031RtcTimeZone";
-STATIC CONST CHAR16   mDaylightVariableName[] = L"PL031RtcDaylight";
 STATIC BOOLEANmPL031Initialized = FALSE;
 STATIC EFI_EVENT  mRtcVirtualAddrChangeEvent;
 STATIC UINTN  mPL031RtcBase;
@@ -134,15 +132,12 @@ LibGetTime (
 {
   EFI_STATUS  Status = EFI_SUCCESS;
   UINT32  EpochSeconds;
-  INT16   TimeZone;
-  UINT8   Daylight;
-  UINTN   Size;
 
   // Initialize the hardware if not already done
   if (!mPL031Initialized) {
 Status = InitializePL031 ();
 if (EFI_ERROR (Status)) {
-  goto EXIT;
+  return Status;
 }
   }
 
@@ -156,7 +151,7 @@ LibGetTime (
 Status = EFI_SUCCESS;
   } else if (EFI_ERROR (Status)) {
 // Battery backed up hardware RTC exists but could not be read due to 
error. Abort.
-goto EXIT;
+return Status;
   } else {
 // Battery backed up hardware RTC exists and we read the time correctly 
from it.
 // Now sync the PL031 to the new time.
@@ -165,107 +160,18 @@ LibGetTime (
 
   // Ensure Time is a valid pointer
   if (Time == NULL) {
-Status = EFI_INVALID_PARAMETER;
-goto EXIT;
+return EFI_INVALID_PARAMETER;
   }
 
-  // Get the current time zone information from non-volatile storage
-  Size = sizeof (TimeZone);
-  Status = EfiGetVariable (
-  (CHAR16 *)mTimeZoneVariableName,
-  ,
-  NULL,
-  ,
-  (VOID *)
-  );
-
-  if (EFI_ERROR (Status)) {
-ASSERT(Status != EFI_INVALID_PARAMETER);
-ASSERT(Status != EFI_BUFFER_TOO_SMALL);
-
-if (Status != EFI_NOT_FOUND)
-  goto EXIT;
-
-// The time zone variable does not exist in non-volatile storage, so 
create it.
-Time->TimeZone = EFI_UNSPECIFIED_TIMEZONE;
-// Store it
-Status = EfiSetVariable (
-(CHAR16 *)mTimeZoneVariableName,
-,
-EFI_VARIABLE_NON_VOLATILE | 
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
-Size,
-(VOID *)&(Time->TimeZone)
-);
-if (EFI_ERROR (Status)) {
-  DEBUG ((
-EFI_D_ERROR,
-"LibGetTime: Failed to save %s variable to non-volatile storage, 
Status = %r\n",
-mTimeZoneVariableName,
-Status
-));
-  goto EXIT;
-}
-  } else {
-// Got the time zone
-Time->TimeZone = TimeZone;
-
-// Check TimeZone bounds:   -1440 to 1440 or 2047
-if (((Time->TimeZone < -1440) || (Time->TimeZone > 1440))
-&& (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE)) {
-  Time->TimeZone = EFI_UNSPECIFIED_TIMEZONE;
-}
-
-// Adjust for the correct time zone
-if (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE) {
-  EpochSeconds += Time->TimeZone * SEC_PER_MIN;
-}
+  // Adjust for the correct time zone
+  if (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE) {
+EpochSeconds += Time->TimeZone * SEC_PER_MIN;
   }
 
-  // Get the current daylight information from non-volatile storage
-  Size = sizeof (Daylight);
-  Status = EfiGetVariable (
-  (CHAR16 *)mDaylightVariableName,
-  ,
-  NULL,
-  ,
-  (VOID *)
-  );
-
-  if (EFI_ERROR (Status)) {
-ASSERT(Status != EFI_INVALID_PARAMETER);
-ASSERT(Status != EFI_BUFFER_TOO_SMALL);
-
-if (Status != EFI_NOT_FOUND)
-  goto EXIT;
-
-// The daylight variable does not exist in non-volatile storage, so create 
it.
-Time->Daylight = 0;
-// Store it
-Status = EfiSetVariable (
-(CHAR16 *)mDaylightVariableName,
-,
-EFI_VARIABLE_NON_VOLATILE | 
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
-Size,
-(VOID *)&(Time->Daylight)
-);
-if (EFI_ERROR (Status)) {
-  DEBUG ((
-

Re: [edk2] UEFI Image Attribute

2017-11-06 Thread TVKR
Thanks for the reply Igor.

Yes, I was referring to the AttributesSetting of the
EFI_FIRMWARE_IMAGE_DESCRIPTOR which is read as part of the GetImageInfo
service of the FMP on a device.

So,if the device sets this attributes, does it mean that its UEFI driver's
FMP implementation can ONLY support firmware files created as per the PI
spec's FV/FFS format?

Regards

On Fri, Nov 3, 2017 at 2:38 PM, Igor Skochinsky 
wrote:

> Hi,
>
> Do you mean the one in EFI_FIRMWARE_IMAGE_DESCRIPTOR?
>
> My guess is it means “UEFI firmware image”, i.e. a set of firmware volumes
> ready for flashing (an .fd file in some contexts), as opposed to a non-UEFI
> firmware such as EC, BMC or some other variation.
>
> --
> WBR, Igor.
> _
> From: TVKR 
> Sent: Friday, November 3, 2017 18:02
> Subject: [edk2] UEFI Image Attribute
> To: 
>
>
> What does the IMAGE_ATTRIBUTE_UEFI_IMAGE attribute mean? The spec says that
> "image is an EFI compatible image", but what that mean exactly?
>
> Thanks
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
>
>
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] MdeModulePkg VarCheckHiiLib: Fix typo "0x02%x" to be "0x%02x"

2017-11-06 Thread Bi, Dandan
Reviewed-by: Dandan Bi 

Thanks,
Dandan

-Original Message-
From: Zeng, Star 
Sent: Monday, November 6, 2017 8:51 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star ; Bi, Dandan ; Yao, 
Jiewen 
Subject: [PATCH] MdeModulePkg VarCheckHiiLib: Fix typo "0x02%x" to be "0x%02x"

Cc: Dandan Bi 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c 
b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c
index f018c87ba199..2c3b9eb8e4c9 100644
--- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c
+++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c
@@ -147,8 +147,8 @@ DumpHiiPackage (
 IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpCodeHeader;
 if (IfrEfiVarStore->Header.Length >= sizeof 
(EFI_IFR_VARSTORE_EFI)) {
   DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->OpCode - 0x%02x 
(%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode)));
-  DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->Length - 0x02%x\n", 
IfrOpCodeHeader->Length));
-  DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->Scope  - 0x02%x\n", 
IfrOpCodeHeader->Scope));
+  DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->Length - 0x%02x\n", 
IfrOpCodeHeader->Length));
+  DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->Scope  - 0x%02x\n", 
IfrOpCodeHeader->Scope));
   DEBUG ((EFI_D_INFO, "  Guid   - %g\n", 
>Guid));
   DEBUG ((EFI_D_INFO, "  VarStoreId - 0x%04x\n", 
IfrEfiVarStore->VarStoreId));
   DEBUG ((EFI_D_INFO, "  Size   - 0x%04x\n", 
IfrEfiVarStore->Size));
@@ -162,8 +162,8 @@ DumpHiiPackage (
   case EFI_IFR_NUMERIC_OP:
   case EFI_IFR_ORDERED_LIST_OP:
 DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", 
IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode)));
-DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->Length - 0x02%x\n", 
IfrOpCodeHeader->Length));
-DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->Scope  - 0x02%x\n", 
IfrOpCodeHeader->Scope));
+DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->Length - 0x%02x\n", 
IfrOpCodeHeader->Length));
+DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->Scope  - 0x%02x\n", 
IfrOpCodeHeader->Scope));
 DEBUG ((EFI_D_INFO, "  Prompt   - 0x%04x\n", 
((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Prompt));
 DEBUG ((EFI_D_INFO, "  Help - 0x%04x\n", 
((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Help));
 DEBUG ((EFI_D_INFO, "  QuestionId   - 0x%04x\n", 
((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.QuestionId));
-- 
2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] Build error in StdLib with VS 2015 compiler

2017-11-06 Thread Gao, Liming
For VS2015, don't define it. The change is like below. 

#ifndef __STDC_HOSTED__
#if !defined(_MSC_VER) || _MSC_VER != 1900
#define __STDC_HOSTED__ 1
#endif
#endif

> -Original Message-
> From: Karunakar P [mailto:karunak...@amiindia.co.in]
> Sent: Monday, November 6, 2017 5:32 PM
> To: Gao, Liming ; 'Tim Lewis' ; 
> 'edk2-devel@lists.01.org' 
> Cc: Ye, Ting ; Fu, Siyuan ; Wu, 
> Jiaxin 
> Subject: RE: [edk2] Build error in StdLib with VS 2015 compiler
> 
> What do you say...
> 
> 
> Thanks,
> Karunakar
> 
> -Original Message-
> From: Karunakar P
> Sent: Thursday, November 02, 2017 8:17 PM
> To: 'Gao, Liming'; 'Tim Lewis'; edk2-devel@lists.01.org
> Cc: Ye, Ting; Fu, Siyuan; Wu, Jiaxin
> Subject: RE: [edk2] Build error in StdLib with VS 2015 compiler
> 
> Then it works fine.
> But the problem is it may miss the backward compatibility with other 
> compilers.
> 
> I guess better to define as mentioned previously.
> 
> Thank You,
> Karunakar
> 
> -Original Message-
> From: Gao, Liming [mailto:liming@intel.com]
> Sent: Thursday, November 02, 2017 7:33 PM
> To: Karunakar P; 'Tim Lewis'; edk2-devel@lists.01.org
> Cc: Ye, Ting; Fu, Siyuan; Wu, Jiaxin
> Subject: RE: [edk2] Build error in StdLib with VS 2015 compiler
> 
> Could you remove them, and build again?
> 
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> > Karunakar P
> > Sent: Thursday, November 2, 2017 8:32 PM
> > To: 'Tim Lewis' ; edk2-devel@lists.01.org
> > Cc: Ye, Ting ; Fu, Siyuan ; Wu, 
> > Jiaxin 
> > Subject: Re: [edk2] Build error in StdLib with VS 2015 compiler
> >
> > It is C only.
> >
> > -Karunakar
> >
> > -Original Message-
> > From: Tim Lewis [mailto:tim.le...@insyde.com]
> > Sent: Thursday, November 02, 2017 8:59 AM
> > To: Karunakar P; edk2-devel@lists.01.org
> > Cc: 'Ye, Ting'; 'Fu, Siyuan'; 'Wu, Jiaxin'
> > Subject: RE: [edk2] Build error in StdLib with VS 2015 compiler
> >
> > Are you building C++ (.cpp)? Tim
> >
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> > Karunakar P
> > Sent: Wednesday, November 1, 2017 8:27 PM
> > To: 'edk2-devel@lists.01.org' 
> > Cc: 'Ye, Ting' ; 'Fu, Siyuan' ; 
> > 'Wu, Jiaxin' 
> > Subject: Re: [edk2] Build error in StdLib with VS 2015 compiler
> >
> > Any comment on this?
> >
> > From: Karunakar P
> > Sent: Tuesday, October 31, 2017 3:18 PM
> > To: 'edk2-devel@lists.01.org'
> > Cc: 'Wu, Jiaxin'; 'Fu, Siyuan'; 'Ye, Ting'
> > Subject: Build error in StdLib with VS 2015 compiler
> >
> > Hello All,
> >
> > Facing an build error with Stdlib module when built with VS 2015 compiler.
> >
> > e:\test\StdLib\Include\sys/EfiCdefs.h(357): error C2220: warning treated as 
> > error - no 'object' file generated
> > e:\test\StdLib\Include\sys/EfiCdefs.h(357): warning C4117: macro name 
> > '__STDC_HOSTED__' is reserved, '#define' ignored
> >
> > below change resolving this error. Would you please review and provide 
> > comments.
> >
> > #ifndef __STDC_HOSTED__
> > #define __STDC_HOSTED__ 1
> > #endif
> >
> >
> > Thank You,
> > Karunakar
> > ___
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
> >
> > ___
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH] MdeModulePkg VarCheckHiiLib: Fix typo "0x02%x" to be "0x%02x"

2017-11-06 Thread Star Zeng
Cc: Dandan Bi 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c 
b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c
index f018c87ba199..2c3b9eb8e4c9 100644
--- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c
+++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c
@@ -147,8 +147,8 @@ DumpHiiPackage (
 IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpCodeHeader;
 if (IfrEfiVarStore->Header.Length >= sizeof 
(EFI_IFR_VARSTORE_EFI)) {
   DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->OpCode - 0x%02x 
(%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode)));
-  DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->Length - 0x02%x\n", 
IfrOpCodeHeader->Length));
-  DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->Scope  - 0x02%x\n", 
IfrOpCodeHeader->Scope));
+  DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->Length - 0x%02x\n", 
IfrOpCodeHeader->Length));
+  DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->Scope  - 0x%02x\n", 
IfrOpCodeHeader->Scope));
   DEBUG ((EFI_D_INFO, "  Guid   - %g\n", 
>Guid));
   DEBUG ((EFI_D_INFO, "  VarStoreId - 0x%04x\n", 
IfrEfiVarStore->VarStoreId));
   DEBUG ((EFI_D_INFO, "  Size   - 0x%04x\n", 
IfrEfiVarStore->Size));
@@ -162,8 +162,8 @@ DumpHiiPackage (
   case EFI_IFR_NUMERIC_OP:
   case EFI_IFR_ORDERED_LIST_OP:
 DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", 
IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode)));
-DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->Length - 0x02%x\n", 
IfrOpCodeHeader->Length));
-DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->Scope  - 0x02%x\n", 
IfrOpCodeHeader->Scope));
+DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->Length - 0x%02x\n", 
IfrOpCodeHeader->Length));
+DEBUG ((EFI_D_INFO, "IfrOpCodeHeader->Scope  - 0x%02x\n", 
IfrOpCodeHeader->Scope));
 DEBUG ((EFI_D_INFO, "  Prompt   - 0x%04x\n", 
((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Prompt));
 DEBUG ((EFI_D_INFO, "  Help - 0x%04x\n", 
((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Help));
 DEBUG ((EFI_D_INFO, "  QuestionId   - 0x%04x\n", 
((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.QuestionId));
-- 
2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 1/2] UefiCpuPkg/CpuFeaturesDxe.inf: Add missed Depex protocol.

2017-11-06 Thread Eric Dong
The gEfiMpServiceProtocolGuid protocol is used by
CpuFeaturesDxe.inf during feature detection. Should be
included in the [DepEx] section but actually not.
This patch add it.

Cc: Liming Gao 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf 
b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf
index b1733be..77c6d80 100644
--- a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf
+++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf
@@ -48,7 +48,7 @@
   gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitAfterSmmRelocation  ## CONSUMES
 
 [Depex]
-  TRUE
+  gEfiMpServiceProtocolGuid
 
 [UserExtensions.TianoCore."ExtraFiles"]
   CpuFeaturesDxeExtra.uni
-- 
2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 2/2] UefiCpuPkg/CpuFeaturesPei.inf: Add missed Depex Ppi.

2017-11-06 Thread Eric Dong
The gEfiPeiMpServicesPpiGuid Ppi is used by CpuFeaturesPei.inf
during feature detection. Should be included in the [DepEx]
section but actually not. This patch add it.

Cc: Liming Gao 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf 
b/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf
index e617c5b..ad3bab3 100644
--- a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf
+++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf
@@ -44,7 +44,7 @@
   gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitOnS3Resume  ## CONSUMES
 
 [Depex]
-  TRUE
+  gEfiPeiMpServicesPpiGuid
 
 [UserExtensions.TianoCore."ExtraFiles"]
   CpuFeaturesPeiExtra.uni
-- 
2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 0/2] Add missed Depex Protocol/Ppi.

2017-11-06 Thread Eric Dong
The Protocol/Ppi used in the drivers but the it not add them
in the dependence section, it may cause driver assert. 
This patch series add the missed Protocol/Ppi.

Eric Dong (2):
  UefiCpuPkg/CpuFeaturesDxe.inf: Add missed Depex protocol.
  UefiCpuPkg/CpuFeaturesPei.inf: Add missed Depex Ppi.

 UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf | 2 +-
 UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
2.7.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [RFC PATCH edk2-platforms 1/3] Silicon/NXP: add RTC support library for PCF8563 I2C IP

2017-11-06 Thread Ard Biesheuvel
On 6 November 2017 at 11:09, Udit Kumar  wrote:
> Thanks Ard.
> This will allow to use PCF8563 on any platform not limiting to targeted 
> platform.

Yes, that was the intention.

> Few comments are inline.
>

Thanks.

>
>> -Original Message-
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ard
>> Biesheuvel
>> Sent: Friday, November 03, 2017 3:47 PM
>> To: edk2-devel@lists.01.org; leif.lindh...@linaro.org;
>> daniel.thomp...@linaro.org
>> Cc: Ard Biesheuvel 
>> Subject: [edk2] [RFC PATCH edk2-platforms 1/3] Silicon/NXP: add RTC support
>> library for PCF8563 I2C IP
>>
>> Add a RealTimeClockLib implementation for the NXP PCF8563 as used on
>> the Socionext Developer Box board. Note that the standard I2C protocol
>> stack does not support runtime use, so this driver invokes the I2C master
>> protocol directly. This requires support from the platform side as well,
>> and so this driver will only attach to a I2C master that has the
>> gPcf8563RealTimeClockLibI2cMasterProtolGuid protocol installed on its
>> handle. It is up to the platform to ensure that the driver producing
>> the I2C master protocol in question is runtime capable, and is not
>> shared with the I2C protocol stack (i.e., it should not have the I2C
>> Bus Configuration Management protocol installed as well).
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ard Biesheuvel 
>> ---
>>  Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c   |
>> 385 
>>  Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.dec |
>> 29 ++
>>  Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf |
>> 52 +++
>>  3 files changed, 466 insertions(+)
>>
>> diff --git
>> a/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c
>> b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c
>> new file mode 100644
>> index ..fea65a225d7f
>> --- /dev/null
>> +++
>> b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c
>> @@ -0,0 +1,385 @@
>> +/** @file
>> +
>> +  Copyright (c) 2017, Linaro, Ltd. All rights reserved.
>> +
>> +  This program and the accompanying materials
>> +  are licensed and made available under the terms and conditions of the BSD
>> License
>> +  which accompanies this distribution.  The full text of the license may be 
>> found
>> at
>> +
>> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fopenso
>> urce.org%2Flicenses%2Fbsd-
>> license.php=02%7C01%7Cudit.kumar%40nxp.com%7C6faa68073eef4ed07
>> 25208d522a40d65%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C636
>> 453010374642660=vDhroHNG20VCsMtj7%2FggWcWRG8hwt5fbV1Kv4R
>> Na98Q%3D=0
>> +
>> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
>> BASIS,
>> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
>> EXPRESS OR IMPLIED.
>> +
>> +**/
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#define SLAVE_ADDRESS (FixedPcdGet8 (PcdI2cSlaveAddress))
>> +#define PCF8563_DATA_REG_OFFSET   0x2
>> +
>> +#define PCF8563_SECONDS_MASK  0x7f
>> +#define PCF8563_MINUTES_MASK  0x7f
>> +#define PCF8563_HOURS_MASK0x3f
>> +#define PCF8563_DAYS_MASK 0x3f
>> +#define PCF8563_WEEKDAYS_MASK 0x07
>> +#define PCF8563_MONTHS_MASK   0x1f
>> +#define PCF8563_CENTURY_MASK  0x80
>> +
>> +#define EPOCH_BASE2000
>> +
>> +STATIC EFI_HANDLE mI2cMasterHandle;
>> +STATIC VOID   *mDriverEventRegistration;
>> +STATIC EFI_I2C_MASTER_PROTOCOL*mI2cMaster;
>> +STATIC EFI_EVENT  mRtcVirtualAddrChangeEvent;
>> +
>> +typedef struct {
>> +  UINTN   OperationCount;
>> +  EFI_I2C_OPERATION   SetAddressOp;
>> +  EFI_I2C_OPERATION   GetSetDateTimeOp;
>> +} RTC_I2C_REQUEST;
>> +
>> +#pragma pack(1)
>> +typedef struct {
>> +  UINT8 VL_seconds;
>> +  UINT8 Minutes;
>> +  UINT8 Hours;
>> +  UINT8 Days;
>> +  UINT8 Weekdays;
>> +  UINT8 Century_months;
>> +  UINT8 Years;
>> +} RTC_DATETIME;
>> +#pragma pack()
>> +
>> +/**
>> +  Returns the current time and date information, and the time-keeping
>> +  capabilities of the hardware platform.
>> +
>> +  @param  Time  A pointer to storage to receive a snapshot 
>> of
>> +the current time.
>> +  @param  Capabilities  An optional pointer to a buffer to receive 
>> the
>> +real time clock device's capabilities.
>> +
>> +  @retval EFI_SUCCESS   The operation completed successfully.
>> +  @retval EFI_INVALID_PARAMETER Time is NULL.
>> +  @retval EFI_DEVICE_ERROR  The time could not be retrieved due to
>> hardware
>> +

Re: [edk2] [RFC PATCH edk2-platforms 1/3] Silicon/NXP: add RTC support library for PCF8563 I2C IP

2017-11-06 Thread Udit Kumar
Thanks Ard. 
This will allow to use PCF8563 on any platform not limiting to targeted 
platform. 
Few comments are inline.

Regards
Udit 

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ard
> Biesheuvel
> Sent: Friday, November 03, 2017 3:47 PM
> To: edk2-devel@lists.01.org; leif.lindh...@linaro.org;
> daniel.thomp...@linaro.org
> Cc: Ard Biesheuvel 
> Subject: [edk2] [RFC PATCH edk2-platforms 1/3] Silicon/NXP: add RTC support
> library for PCF8563 I2C IP
> 
> Add a RealTimeClockLib implementation for the NXP PCF8563 as used on
> the Socionext Developer Box board. Note that the standard I2C protocol
> stack does not support runtime use, so this driver invokes the I2C master
> protocol directly. This requires support from the platform side as well,
> and so this driver will only attach to a I2C master that has the
> gPcf8563RealTimeClockLibI2cMasterProtolGuid protocol installed on its
> handle. It is up to the platform to ensure that the driver producing
> the I2C master protocol in question is runtime capable, and is not
> shared with the I2C protocol stack (i.e., it should not have the I2C
> Bus Configuration Management protocol installed as well).
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c   |
> 385 
>  Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.dec |
> 29 ++
>  Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf |
> 52 +++
>  3 files changed, 466 insertions(+)
> 
> diff --git
> a/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c
> b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c
> new file mode 100644
> index ..fea65a225d7f
> --- /dev/null
> +++
> b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c
> @@ -0,0 +1,385 @@
> +/** @file
> +
> +  Copyright (c) 2017, Linaro, Ltd. All rights reserved.
> +
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD
> License
> +  which accompanies this distribution.  The full text of the license may be 
> found
> at
> +
> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fopenso
> urce.org%2Flicenses%2Fbsd-
> license.php=02%7C01%7Cudit.kumar%40nxp.com%7C6faa68073eef4ed07
> 25208d522a40d65%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C636
> 453010374642660=vDhroHNG20VCsMtj7%2FggWcWRG8hwt5fbV1Kv4R
> Na98Q%3D=0
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define SLAVE_ADDRESS (FixedPcdGet8 (PcdI2cSlaveAddress))
> +#define PCF8563_DATA_REG_OFFSET   0x2
> +
> +#define PCF8563_SECONDS_MASK  0x7f
> +#define PCF8563_MINUTES_MASK  0x7f
> +#define PCF8563_HOURS_MASK0x3f
> +#define PCF8563_DAYS_MASK 0x3f
> +#define PCF8563_WEEKDAYS_MASK 0x07
> +#define PCF8563_MONTHS_MASK   0x1f
> +#define PCF8563_CENTURY_MASK  0x80
> +
> +#define EPOCH_BASE2000
> +
> +STATIC EFI_HANDLE mI2cMasterHandle;
> +STATIC VOID   *mDriverEventRegistration;
> +STATIC EFI_I2C_MASTER_PROTOCOL*mI2cMaster;
> +STATIC EFI_EVENT  mRtcVirtualAddrChangeEvent;
> +
> +typedef struct {
> +  UINTN   OperationCount;
> +  EFI_I2C_OPERATION   SetAddressOp;
> +  EFI_I2C_OPERATION   GetSetDateTimeOp;
> +} RTC_I2C_REQUEST;
> +
> +#pragma pack(1)
> +typedef struct {
> +  UINT8 VL_seconds;
> +  UINT8 Minutes;
> +  UINT8 Hours;
> +  UINT8 Days;
> +  UINT8 Weekdays;
> +  UINT8 Century_months;
> +  UINT8 Years;
> +} RTC_DATETIME;
> +#pragma pack()
> +
> +/**
> +  Returns the current time and date information, and the time-keeping
> +  capabilities of the hardware platform.
> +
> +  @param  Time  A pointer to storage to receive a snapshot of
> +the current time.
> +  @param  Capabilities  An optional pointer to a buffer to receive 
> the
> +real time clock device's capabilities.
> +
> +  @retval EFI_SUCCESS   The operation completed successfully.
> +  @retval EFI_INVALID_PARAMETER Time is NULL.
> +  @retval EFI_DEVICE_ERROR  The time could not be retrieved due to
> hardware
> +error.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +LibGetTime (
> +  OUT EFI_TIME*Time,
> +  OUT EFI_TIME_CAPABILITIES   *Capabilities
> +  )
> +{
> +  RTC_I2C_REQUEST Op;
> +  RTC_DATETIME

Re: [edk2] [PATCH v2] MdeModulePkg/SdMmcPciHcDxe: call SdMmcFreeTrb() to complete sync operation

2017-11-06 Thread Ard Biesheuvel
On 6 November 2017 at 08:56, Zeng, Star  wrote:
> Except the typo "incorrecnt" needs to be "incorrect" in commit log, others 
> are good to me.
>
> With typo fixed, Reviewed-by: Star Zeng 
>

Thanks

Pushed as 6743455e34d1b313d644d9f7ca726b9932effb1f


> -Original Message-
> From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
> Sent: Sunday, November 5, 2017 5:31 PM
> To: edk2-devel@lists.01.org
> Cc: Tian, Feng ; Zeng, Star ; Dong, 
> Eric ; Ard Biesheuvel 
> Subject: [PATCH v2] MdeModulePkg/SdMmcPciHcDxe: call SdMmcFreeTrb() to 
> complete sync operation
>
> Currently, we complete a synchronous operation without unmapping the DMA 
> mappings, and free the pages using FreePages () rather than calling 
> EFI_PCI_IO_PROTOCOL::FreeBuffer. This is simply incorrecnt, but it also 
> breaks non-coherent DMA as well as DMA protection and/or memory encryption so 
> let's do it correctly and call SdMmcFreeTrb() instead.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 8 +---
>  1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c 
> b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
> index 23faec5e2be0..0be8828abfcc 100644
> --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
> +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
> @@ -1008,13 +1008,7 @@ SdMmcPassThruPassThru (
>}
>
>  Done:
> -  if ((Trb != NULL) && (Trb->AdmaDesc != NULL)) {
> -FreePages (Trb->AdmaDesc, Trb->AdmaPages);
> -  }
> -
> -  if (Trb != NULL) {
> -FreePool (Trb);
> -  }
> +  SdMmcFreeTrb (Trb);
>
>return Status;
>  }
> --
> 2.11.0
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017] Update ReadMe.MD

2017-11-06 Thread Guo, Mang
Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Guo Mang 
---
 ReadMe.MD | 114 --
 1 file changed, 74 insertions(+), 40 deletions(-)

diff --git a/ReadMe.MD b/ReadMe.MD
index ae1556b..f5cbc7c 100644
--- a/ReadMe.MD
+++ b/ReadMe.MD
@@ -24,56 +24,45 @@ This code base is based on UDK2017 core packages.
under the "C:\MyWorkspace\edk2-platforms" directory.
 
 3. Get the BaseTools binary and copy them to BaseTools binary folder.
-   1. Enter folder BaseTools\Bin
-   2. `git clone https://github.com/tianocore/edk2-BaseTools-win32.git Win32`
-   3. Enter folder Win32
-   4. `git checkout 7b52b1a9bf853b5c498ea61d0a4f17083f543be4`
+   1. `git clone https://github.com/tianocore/edk2-BaseTools-win32.git Win32`
+   2. Enter folder Win32
+   3. `git checkout 0e088c19ab31fccd1d2f55d9e4fe0314b57c0097`
+   4. Copy Win32 to the BaseTools Binary folder.
+   (C:\MyWorkspace\edk2-platforms\BaseTools\Bin\)
 
 4. Get the Intel(R) Firmware Support Package(Intel FSP).
1. Run `git clone -b ApolloLake https://github.com/IntelFsp/FSP.git` to 
download FSP
2. Enter folder FSP
-   3. Run `git checkout 08b5af471a0caea79724ca3eb4794e6a0a7a31aa`
+   3. Run `git checkout de67689ef6261c1a0ecee01b7312bd635e3435e7`
4. Copy the ApolloLakeFspBinPkg to the folder
   "C:\MyWorkspace\edk2-platforms\Silicon\BroxtonSoC\BroxtonFspPkg"
 
 5. Install UEFI UNDI driver:
-   1. Download PREBOOT.EXE Version 21.1 from the "Intel® Ethernet Connections
+  Download PREBOOT.EXE Version 21.1 from the "Intel® Ethernet Connections
   Boot Utility, Preboot Images, and EFI Drivers" page.
   
https://downloadcenter.intel.com/download/19186/Intel-Ethernet-Connections-Boot-Utility-Preboot-Images-and-EFI-Drivers
-   2. Install PREBOOT.EXE into the default folder (C:\Intel21.1).
-   3. Copy the UEFI x64 PCI-E gigabit driver 
(C:\Intel21.1\APPS\EFI\EFIx64\EX3.EFI,
-  where "" is the driver version number) to the platform package 
directory below, create the folder if it does not exist:
+   Windows user:
+   1. Install PREBOOT.EXE into the default folder (C:\Intel21.1).
+   2. Copy the UEFI x64 PCI-E gigabit driver 
(C:\Intel21.1\APPS\EFI\EFIx64\E7320X3.EFI) 
+  to the platform package directory below, create the folder if it does 
not exist:
   
"C:\MyWorkspace\edk2-platforms\Platform\BroxtonPlatformPkg\Common\Binaries\UNDI\I210PcieUndiDxe"
-   4. Open the file 
"C:\MyWorkspace\edk2-platforms\Platform\BroxtonPlatformPkg\PlatformPkg.fdf"
-  and change the UNDI driver file name reference with the one that was 
downloaded:
- SECTION PE32 = 
BroxtonPlatformPkg/Common/Binaries/UNDI/I210PcieUndiDxe/E7006X3.EFI
-
-6. Install the NASM assembly language compiler:
-   1. Download NASM 2.12.02 binaries:
-  * 
http://www.nasm.us/pub/nasm/releasebuilds/2.12.02/win32/nasm-2.12.02-win32.zip
-  * 
http://www.nasm.us/pub/nasm/releasebuilds/2.12.02/win64/nasm-2.12.02-win64.zip
-   2. Unzip the 32-bit & 64-bit versions of nasm.exe to the directories listed 
below,
-  respectively, and create the folders if they do not exist:
-  * 
"C:\MyWorkspace\edk2-platforms\Platform\BroxtonPlatformPkg\Common\Tools\nasm\Win32"
-  * 
"C:\MyWorkspace\edk2-platforms\Platform\BroxtonPlatformPkg\Common\Tools\nasm\Win64"
-
-7. Install the ACPI Source Language (ASL) compiler:
-   1. Install the IASL 2016-09-30 compiler from acpica.org:
-  https://acpica.org/sites/acpica/files/iasl-win-20160930.zip
-   2. Unzip the "iasl.exe" file into the directory below, and create the folder
+   Linux user:
+   1. Use command "unzip PREBOOT.EXE" to extract UEFI x64 PCI-E gigabit driver
+  (preboot/APPS/EFI/EFIx64/E7320X3.EFI)
+   2. Copy E7320X3.EFI to platform package directory below, create the folder
   if it does not exist:
-  * 
"C:\MyWorkspace\edk2-platforms\Platform\BroxtonPlatformPkg\Common\Tools\Iasl"
+* 
"~/src/MyWorkspace/edk2-platforms/Platform/BroxtonPlatformPkg/Common/Binaries/UNDI/I210PcieUndiDxe"
 
-8. Follow the instructions found in the "Patch-HOWTO.txt" file located in the 
Workspace
+6. Follow the instructions found in the "Patch-HOWTO.txt" file located in the 
Workspace
(e.g. 
"C:\MyWorkspace\edk2-platforms\Core\CryptoPkg\Library\OpensslLib\Patch-HOWTO.txt")
to install the OpenSSL source code and enable the CryptoPkg module.
 
-9. Download MinnowBoard v3 Binary Object Modules
+7. Download MinnowBoard v3 Binary Object Modules
1. Download the "MinnowBoard_v3-0.63-Binary.Objects.zip" from the project 
page:
   * https://firmware.intel.com/projects/minnowboardv3
-   2. Unzip and copy the two folders (A_Stepping, B_Stepping) into
+   2. Unzip and copy the two folders (FAB_A, FAB_B) into
   the directory below, and create the folder if it does not exist:
-  * 
"C:\MyWorkspace\edk2-platforms\Platform\BroxtonPlatformPkg\Common\Binaries\IFWI"
+  * 

Re: [edk2] Build error in StdLib with VS 2015 compiler

2017-11-06 Thread Karunakar P
What do you say...


Thanks,
Karunakar

-Original Message-
From: Karunakar P 
Sent: Thursday, November 02, 2017 8:17 PM
To: 'Gao, Liming'; 'Tim Lewis'; edk2-devel@lists.01.org
Cc: Ye, Ting; Fu, Siyuan; Wu, Jiaxin
Subject: RE: [edk2] Build error in StdLib with VS 2015 compiler

Then it works fine.
But the problem is it may miss the backward compatibility with other compilers.

I guess better to define as mentioned previously.

Thank You,
Karunakar

-Original Message-
From: Gao, Liming [mailto:liming@intel.com] 
Sent: Thursday, November 02, 2017 7:33 PM
To: Karunakar P; 'Tim Lewis'; edk2-devel@lists.01.org
Cc: Ye, Ting; Fu, Siyuan; Wu, Jiaxin
Subject: RE: [edk2] Build error in StdLib with VS 2015 compiler

Could you remove them, and build again?

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Karunakar P
> Sent: Thursday, November 2, 2017 8:32 PM
> To: 'Tim Lewis' ; edk2-devel@lists.01.org
> Cc: Ye, Ting ; Fu, Siyuan ; Wu, 
> Jiaxin 
> Subject: Re: [edk2] Build error in StdLib with VS 2015 compiler
> 
> It is C only.
> 
> -Karunakar
> 
> -Original Message-
> From: Tim Lewis [mailto:tim.le...@insyde.com]
> Sent: Thursday, November 02, 2017 8:59 AM
> To: Karunakar P; edk2-devel@lists.01.org
> Cc: 'Ye, Ting'; 'Fu, Siyuan'; 'Wu, Jiaxin'
> Subject: RE: [edk2] Build error in StdLib with VS 2015 compiler
> 
> Are you building C++ (.cpp)? Tim
> 
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Karunakar P
> Sent: Wednesday, November 1, 2017 8:27 PM
> To: 'edk2-devel@lists.01.org' 
> Cc: 'Ye, Ting' ; 'Fu, Siyuan' ; 'Wu, 
> Jiaxin' 
> Subject: Re: [edk2] Build error in StdLib with VS 2015 compiler
> 
> Any comment on this?
> 
> From: Karunakar P
> Sent: Tuesday, October 31, 2017 3:18 PM
> To: 'edk2-devel@lists.01.org'
> Cc: 'Wu, Jiaxin'; 'Fu, Siyuan'; 'Ye, Ting'
> Subject: Build error in StdLib with VS 2015 compiler
> 
> Hello All,
> 
> Facing an build error with Stdlib module when built with VS 2015 compiler.
> 
> e:\test\StdLib\Include\sys/EfiCdefs.h(357): error C2220: warning treated as 
> error - no 'object' file generated
> e:\test\StdLib\Include\sys/EfiCdefs.h(357): warning C4117: macro name 
> '__STDC_HOSTED__' is reserved, '#define' ignored
> 
> below change resolving this error. Would you please review and provide 
> comments.
> 
> #ifndef __STDC_HOSTED__
> #define __STDC_HOSTED__ 1
> #endif
> 
> 
> Thank You,
> Karunakar
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v3] MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support bit check

2017-11-06 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: Bi, Dandan 
Sent: Monday, November 6, 2017 3:47 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star ; Dong, Eric ; Gao, 
Liming 
Subject: [PATCH v3] MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support 
bit check

V3:
(1) Reset QuestionStoredInBitField to FALSE at end opcode(EFI_IFR_END_OP)
(2) Fix typo and format issues(line alignment for debug print message and value 
assignment...)

V2:
(1)Remove the VarOffsetBitLevel/StorageWidthBitLevel to reduce the final 
VarCheckBinSize and update the implementation accordingly.
(2)Update the VAR_CHECK_HII_REVISION
(3)Refine the Debug message and function comments,like update oneof", 
"checkbox", "numeric" to "OneOf", "CheckBox", "Numeric".

VarCheckHiiLib check the value set to storage based on the possible value 
listed in the vfr file. Since we have enhanced vfr to support Question value 
stored in bit field, so now enhance VarCheckHiiLib to support bit field check.

Cc: Star Zeng 
Cc: Eric Dong 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 .../VarCheckHiiLib/InternalVarCheckStructure.h |   9 +-
 MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h  |   4 +-
 .../Library/VarCheckHiiLib/VarCheckHiiGen.c| 248 +++--
 .../Library/VarCheckHiiLib/VarCheckHiiLib.inf  |   5 +-
 .../VarCheckHiiLib/VarCheckHiiLibNullClass.c   | 174 ++-
 5 files changed, 310 insertions(+), 130 deletions(-)

diff --git a/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h 
b/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h
index a9faed4..8878e4a 100644
--- a/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h
+++ b/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h
@@ -1,9 +1,9 @@
 /** @file
   Internal structure for Var Check Hii.
 
-Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials  are licensed and made available 
under the terms and conditions of the BSD License  which accompanies this 
distribution.  The full text of the license may be found at  
http://opensource.org/licenses/bsd-license.php
 
@@ -21,11 +21,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #define HEADER_ALIGNMENT  4
 #define HEADER_ALIGN(Header)  (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & 
(~(HEADER_ALIGNMENT - 1)))
 
 #pragma pack (1)
 
-#define VAR_CHECK_HII_REVISION  0x0001
+#define VAR_CHECK_HII_REVISION  0x0002
 
 typedef struct {
   UINT16Revision;
   UINT16HeaderLength;
   UINT32Length; // Length include this header
@@ -40,41 +40,46 @@ typedef struct {
 typedef struct {
   UINT8 OpCode;
   UINT8 Length; // Length include this header
   UINT16VarOffset;
   UINT8 StorageWidth;
+  BOOLEAN   BitFieldStore; // Whether the Question is stored in bit 
field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, 
otherwise in byte level.
 } VAR_CHECK_HII_QUESTION_HEADER;
 
 typedef struct {
   UINT8 OpCode;
   UINT8 Length; // Length include this header
   UINT16VarOffset;
   UINT8 StorageWidth;
+  BOOLEAN   BitFieldStore; // Whether the Question is stored in bit 
field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, 
otherwise in byte level.
 //UINTx   Data[]; // x = UINT8/UINT16/UINT32/UINT64;
 } VAR_CHECK_HII_QUESTION_ONEOF;
 
 typedef struct {
   UINT8 OpCode;
   UINT8 Length; // Length include this header
   UINT16VarOffset;
   UINT8 StorageWidth;
+  BOOLEAN   BitFieldStore; // Whether the Question is stored in bit 
field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, 
otherwise in byte level.
 } VAR_CHECK_HII_QUESTION_CHECKBOX;
 
 typedef struct {
   UINT8 OpCode;
   UINT8 Length; // Length include this header
   UINT16VarOffset;
   UINT8 StorageWidth;
+  BOOLEAN   BitFieldStore; // Whether the Question is stored in bit 
field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, 
otherwise in byte level.
 //UINTx   Minimum; // x = UINT8/UINT16/UINT32/UINT64;
 //UINTx   Maximum; // x = UINT8/UINT16/UINT32/UINT64;
 } VAR_CHECK_HII_QUESTION_NUMERIC;
 
 typedef struct {
   UINT8 OpCode;
   UINT8 Length; // Length include this header
   UINT16VarOffset;
   UINT8 StorageWidth;
+  BOOLEAN   BitFieldStore; // Whether the Question is stored in bit 
field, if TRUE, the 

Re: [edk2] [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries of RT_CODE in memory map

2017-11-06 Thread Zeng, Star
I am ok to this code approach.

Acknowledged-by: Star Zeng 

Besides, I think except GCD services, DxeCore should not call 
gCpu->SetMemoryAttributes() directly, for example 
ApplyMemoryProtectionPolicy(), it should have no assumption of the CPU code (to 
set capabilities), and call GCD setcapabilities first, and then call GCD 
setattributes since 14dde9e903bb9a719ebb8f3381da72b19509bc36 
"MdeModulePkg/Core: Fix out-of-sync issue in GCD", otherwise there may be 
mismatch of page attributes between GCD and gCPU after 
RefreshGcdMemoryAttributesFromPaging() by the calling 
gCpu->SetMemoryAttributes() in ApplyMemoryProtectionPolicy().

Anyway, that could be in a separated patch. :)

Thanks,
Star
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Jian J 
Wang
Sent: Friday, November 3, 2017 8:57 AM
To: edk2-devel@lists.01.org
Cc: Laszlo Ersek ; Yao, Jiewen ; Dong, 
Eric 
Subject: [edk2] [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries of RT_CODE 
in memory map

> v2
> a. Fix an issue which will cause setting capability failure if size is smaller
>than a page.

More than one entry of RT_CODE memory might cause boot problem for some old 
OSs. This patch will fix this issue to keep OS compatibility as much as 
possible.

More detailed information, please refer to
https://bugzilla.tianocore.org/show_bug.cgi?id=753

Cc: Eric Dong 
Cc: Jiewen Yao 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang 
---
 UefiCpuPkg/CpuDxe/CpuPageTable.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c b/UefiCpuPkg/CpuDxe/CpuPageTable.c
index d312eb66f8..4a7827ebc9 100644
--- a/UefiCpuPkg/CpuDxe/CpuPageTable.c
+++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c
@@ -809,7 +809,9 @@ RefreshGcdMemoryAttributesFromPaging (
   PageLength= 0;
 
   for (Index = 0; Index < NumberOfDescriptors; Index++) {
-if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeNonExistent) {
+if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeNonExistent
+|| (MemorySpaceMap[Index].BaseAddress & EFI_PAGE_MASK) != 0
+|| (MemorySpaceMap[Index].Length & EFI_PAGE_MASK) != 0) {
   continue;
 }
 
@@ -829,6 +831,15 @@ RefreshGcdMemoryAttributesFromPaging (
 // Sync real page attributes to GCD
 BaseAddress   = MemorySpaceMap[Index].BaseAddress;
 MemorySpaceLength = MemorySpaceMap[Index].Length;
+Capabilities  = MemorySpaceMap[Index].Capabilities |
+EFI_MEMORY_PAGETYPE_MASK;
+Status = gDS->SetMemorySpaceCapabilities (
+BaseAddress,
+MemorySpaceLength,
+Capabilities
+);
+ASSERT_EFI_ERROR (Status);
+
 while (MemorySpaceLength > 0) {
   if (PageLength == 0) {
 PageEntry = GetPageTableEntry (, BaseAddress, 
); @@ -846,7 +857,6 @@ RefreshGcdMemoryAttributesFromPaging (
 if (Attributes != (MemorySpaceMap[Index].Attributes & 
EFI_MEMORY_PAGETYPE_MASK)) {
   DoUpdate = TRUE;
   Attributes |= (MemorySpaceMap[Index].Attributes & 
~EFI_MEMORY_PAGETYPE_MASK);
-  Capabilities = Attributes | MemorySpaceMap[Index].Capabilities;
 } else {
   DoUpdate = FALSE;
 }
@@ -854,8 +864,8 @@ RefreshGcdMemoryAttributesFromPaging (
 
   Length = MIN (PageLength, MemorySpaceLength);
   if (DoUpdate) {
-gDS->SetMemorySpaceCapabilities (BaseAddress, Length, Capabilities);
-gDS->SetMemorySpaceAttributes (BaseAddress, Length, Attributes);
+Status = gDS->SetMemorySpaceAttributes (BaseAddress, Length, 
Attributes);
+ASSERT_EFI_ERROR (Status);
 DEBUG ((DEBUG_INFO, "Update memory space attribute: [%02d] %016lx - 
%016lx (%08lx -> %08lx)\r\n",
  Index, BaseAddress, BaseAddress + Length - 1,
  MemorySpaceMap[Index].Attributes, Attributes));
--
2.14.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2] MdeModulePkg/SdMmcPciHcDxe: call SdMmcFreeTrb() to complete sync operation

2017-11-06 Thread Zeng, Star
Except the typo "incorrecnt" needs to be "incorrect" in commit log, others are 
good to me.

With typo fixed, Reviewed-by: Star Zeng 

-Original Message-
From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org] 
Sent: Sunday, November 5, 2017 5:31 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng ; Zeng, Star ; Dong, 
Eric ; Ard Biesheuvel 
Subject: [PATCH v2] MdeModulePkg/SdMmcPciHcDxe: call SdMmcFreeTrb() to complete 
sync operation

Currently, we complete a synchronous operation without unmapping the DMA 
mappings, and free the pages using FreePages () rather than calling 
EFI_PCI_IO_PROTOCOL::FreeBuffer. This is simply incorrecnt, but it also breaks 
non-coherent DMA as well as DMA protection and/or memory encryption so let's do 
it correctly and call SdMmcFreeTrb() instead.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c 
b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
index 23faec5e2be0..0be8828abfcc 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
@@ -1008,13 +1008,7 @@ SdMmcPassThruPassThru (
   }
 
 Done:
-  if ((Trb != NULL) && (Trb->AdmaDesc != NULL)) {
-FreePages (Trb->AdmaDesc, Trb->AdmaPages);
-  }
-
-  if (Trb != NULL) {
-FreePool (Trb);
-  }
+  SdMmcFreeTrb (Trb);
 
   return Status;
 }
--
2.11.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel