Re: [edk2-devel] [edk2-platforms] [PATCH v3 4/4] Platform/Intel: Add FIT generation tool

2019-10-17 Thread Kubacki, Michael A
Reviewed-by: Michael Kubacki 

> -Original Message-
> From: Agyeman, Prince 
> Sent: Thursday, October 17, 2019 5:02 PM
> To: devel@edk2.groups.io
> Cc: Sinha, Ankit ; Desimone, Nathaniel L
> ; Kubacki, Michael A
> 
> Subject: [edk2-platforms] [PATCH v3 4/4] Platform/Intel: Add FIT generation
> tool
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2210
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2211
> 
> Added FitGen tool build and FIT generation to the BIOS build process.
> 
> What was done:
> 
> - Build the FIT generation tool
> - Added default/empty BIOS_INFO_GUID to the build.cfg
> - Added BIOS_INFO_GUID to GalagoPro3,KabylakeRvp3 and
> WhiskeylakeURvp's build_config.cfg This allows a board to specify the GUID
> associated with the BIOS Info PEIM to be used in the board's FIT generation.
> 
> BIOS_INFO_GUID is passed as an argument to FitGen tool which allow the
> tool to locate the BIOS Info module to be used in FIT generation.
> 
> Cc: Ankit Sinha 
> Cc: Nate DeSimone 
> Cc: Michael Kubacki 
> 
> Signed-off-by: Prince Agyeman 
> ---
>  .../GalagoPro3/build_config.cfg   |  1 +
>  .../KabylakeRvp3/build_config.cfg |  1 +
>  .../WhiskeylakeURvp/build_config.cfg  |  1 +
>  Platform/Intel/build.cfg  |  1 +
>  Platform/Intel/build_bios.py  | 57 +++
>  5 files changed, 61 insertions(+)
> 
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/build_config.cfg
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/build_config.cfg
> index 8c6c51abb4..458fe3d35d 100644
> --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/build_config.cfg
> +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/build_config.cfg
> @@ -31,3 +31,4 @@ FSP_PKG_NAME = KabylakeFspPkg  FSP_BINARY_BUILD
> = FALSE  FSP_TEST_RELEASE = FALSE  SECURE_BOOT_ENABLE = FALSE
> +BIOS_INFO_GUID = C83BCE0E-6F16-4D3C-8D9F-4D6F5A032929
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/build_config.cfg
> b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/build_config.cfg
> index 78f808bfaf..f6ae4b342a 100644
> --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/build_config.cfg
> +++
> b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/build_config.cfg
> @@ -33,3 +33,4 @@ FSP_PKG_NAME = AmberLakeFspPkg
> FSP_BINARY_BUILD = FALSE  FSP_TEST_RELEASE = FALSE
> SECURE_BOOT_ENABLE = FALSE
> +BIOS_INFO_GUID = C83BCE0E-6F16-4D3C-8D9F-4D6F5A032929
> diff --git
> a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/build_confi
> g.cfg
> b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/build_confi
> g.cfg
> index 1b0619bc1c..1dfe5ffd10 100644
> ---
> a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/build_confi
> g.cfg
> +++
> b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/build_confi
> +++ g.cfg
> @@ -31,3 +31,4 @@ FSP_PKG_NAME = CoffeelakeSiliconPkg
> FSP_BINARY_BUILD = FALSE  FSP_TEST_RELEASE = FALSE
> SECURE_BOOT_ENABLE = FALSE
> +BIOS_INFO_GUID = A842B2D2-5C88-44E9-A9E2-4830F26662B7
> diff --git a/Platform/Intel/build.cfg b/Platform/Intel/build.cfg index
> 2040774d1b..6aee96694c 100644
> --- a/Platform/Intel/build.cfg
> +++ b/Platform/Intel/build.cfg
> @@ -48,6 +48,7 @@ SECURE_BOOT_ENABLE = FALSE  REBUILD_MODE =
> BUILD_ROM_ONLY =  NUMBER_OF_PROCESSORS = 0
> +BIOS_INFO_GUID =
> 
> 
>  [PLATFORMS]
> diff --git a/Platform/Intel/build_bios.py b/Platform/Intel/build_bios.py index
> 46285df19a..ea098de705 100644
> --- a/Platform/Intel/build_bios.py
> +++ b/Platform/Intel/build_bios.py
> @@ -196,6 +196,31 @@ def pre_build(build_config, build_type="DEBUG",
> silent=False, toolchain=None):
>  if return_code != 0:
>  build_failed(config)
> 
> +#
> +# build platform silicon tools
> +#
> +# save the current workspace
> +saved_work_directory = config["WORKSPACE"]
> +# change the workspace to silicon tools directory
> +config["WORKSPACE"] = os.path.join(config["WORKSPACE_SILICON"],
> + "Tools")
> +
> +command = ["nmake"]
> +if os.name == "posix":  # linux
> +command = ["make"]
> +# add path to generated FitGen binary to
> +# environment path variable
> +config["PATH"] += os.pathsep + \
> +  os.path.join(config["BASE_TOOLS_PATH"],
> +   "Source", "C", "bin")
> +
> +# build the silicon tools
> +_, _, result, return_code = execute_script(command, config, shell=shell)
> +if return_code != 0:
> +build_failed(config)
> +
> +# restore WORKSPACE environment variable
> +config["WORKSPACE"] = saved_work_directory
> +
>  config["SILENT_MODE"] = 'TRUE' if silent else 'FALSE'
> 
>  print("==")
> @@ -404,6 +429,35 @@ def post_build(config):
>  :returns: nothing
>  """
>  print("Running post_build to complete the build process.")
> +board_fd = config["BOARD"].upper()
> +final_fd = 

Re: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 05/14] RiscV/Library: Initial version of libraries introduced in RISC-V platform package

2019-10-17 Thread Abner Chang



> -Original Message-
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Leif Lindholm
> Sent: Thursday, October 3, 2019 1:05 AM
> To: devel@edk2.groups.io; Chen, Gilbert 
> Cc: Palmer Dabbelt 
> Subject: Re: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 05/14]
> RiscV/Library: Initial version of libraries introduced in RISC-V platform
> package
> 
> On Thu, Sep 19, 2019 at 11:51:22AM +0800, Gilbert Chen wrote:
> > FirmwareContextProcessorSpecificLib
> > - Common library to consume
> EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC
> >  and build up processor specific data HOB.
> >
> > RealTimClockLibNull
> > - NULL instance of Real Time Clock library.
> >
> > Signed-off-by: Gilbert Chen 
> > ---
> >  .../FirmwareContextProcessorSpecificLib.c  |  82 +
> >  .../FirmwareContextProcessorSpecificLib.inf|  33 
> >  .../RealTimeClockLibNull/RealTimeClockLibNull.c| 204
> +
> >  .../RealTimeClockLibNull/RealTimeClockLibNull.inf  |  30 +++
> 
> I think you can replace this NULL RealTimeClockLib implementation with
> EmbeddedPkg/Library/VirtualRealTimeClockLib/ (which did not exist at the
> time of the original port).
Ok. U500.dsc will use VirtualRealTimeClockLib. The RiscVPlatformPkg keeps using 
the NULL one under RiscVPlatformPkg/Library. Same as RiscVPkg, no EmbeddedPkg 
modules involved.
> 
> >  4 files changed, 349 insertions(+)
> >  create mode 100644
> >
> Platform/RiscV/Library/FirmwareContextProcessorSpecificLib/FirmwareCon
> > textProcessorSpecificLib.c  create mode 100644
> >
> Platform/RiscV/Library/FirmwareContextProcessorSpecificLib/FirmwareCon
> > textProcessorSpecificLib.inf  create mode 100644
> > Platform/RiscV/Library/RealTimeClockLibNull/RealTimeClockLibNull.c
> >  create mode 100644
> > Platform/RiscV/Library/RealTimeClockLibNull/RealTimeClockLibNull.inf
> >
> > diff --git
> > a/Platform/RiscV/Library/FirmwareContextProcessorSpecificLib/FirmwareC
> > ontextProcessorSpecificLib.c
> >
> b/Platform/RiscV/Library/FirmwareContextProcessorSpecificLib/FirmwareC
> > ontextProcessorSpecificLib.c
> > new file mode 100644
> > index ..4d4c51dc
> > --- /dev/null
> > +++ b/Platform/RiscV/Library/FirmwareContextProcessorSpecificLib/Firmw
> > +++ areContextProcessorSpecificLib.c
> > @@ -0,0 +1,82 @@
> > +/**@file
> > +  Common library to build upfirmware context processor-specific
> > +information
> > +
> > +  Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All
> > + rights reserved.
> > +
> > +  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +
> > +//
> > +// The package level header files this module uses // #include
> > +
> > +
> > +//
> > +// The Library classes this module consumes // #include
> > + #include  #include
> > +
> 
> Please sort these includes alphabetically.
> 
> > +
> > +#include 
> > +#include  #include
> > +
> 
> Please sort these includes alphabetically.
> 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +/**
> > +  Build up common firmware context processor-specific information
> > +
> > +  @param  FirmwareContextHartSpecific  Pointer to
> EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC
> > +  @param  ParentProcessorGuid  Pointer to GUID of Processor which
> contains this core
> > +  @param  ParentProcessorUid   Unique ID of pysical processor which
> owns this core.
> > +  @param  CoreGuid Pointer to GUID of core
> > +  @param  HartId   Hart ID of this core.
> > +  @param  IsBootHart   This is boot hart or not
> > +  @param  ProcessorSpecDataHob Pointer to
> RISC_V_PROCESSOR_SPECIFIC_DATA_HOB
> > +
> > +  @return EFI_STATUS
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +CommonFirmwareContextHartSpecificInfo (
> > +  EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC
> > +*FirmwareContextHartSpecific,
> > +  EFI_GUID  *ParentProcessorGuid,
> > +  UINTN ParentProcessorUid,
> > +  EFI_GUID  *CoreGuid,
> > +  UINTN HartId,
> > +  BOOLEAN   IsBootHart,
> > +  RISC_V_PROCESSOR_SPECIFIC_DATA_HOB *ProcessorSpecDataHob
> 
> Spec is not a clear enough abbreviation, please use Specific.
> Or call it something else. If you keep the name, it certainly wouldn't hurt to
> use a local variable with a shorter name..
> 
> > +  )
> > +{
> > +  //
> > +  // Build up RISC_V_PROCESSOR_SPECIFIC_DATA_HOB.
> > +  //
> > +  CopyGuid (>ParentPrcessorGuid,
> > +ParentProcessorGuid);
> > +  ProcessorSpecDataHob->ParentProcessorUid = ParentProcessorUid;
> > +  CopyGuid (>CoreGuid, CoreGuid);
> > +  ProcessorSpecDataHob->Context = NULL;
> > +  ProcessorSpecDataHob->ProcessorSpecificData.Revision =
> SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA_REVISION;
> 
> 80 Characters is up to  
> here ->
> These lines are way too long, please wrap them.
> 
> > +  ProcessorSpecDataHob->ProcessorSpecificData.Length   = sizeof
> (SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA);
> > +  

Re: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 10/14] U500Pkg/Library: Library instances of U500 platform library

2019-10-17 Thread Abner Chang



> -Original Message-
> From: Leif Lindholm [mailto:leif.lindh...@linaro.org]
> Sent: Friday, October 18, 2019 12:38 AM
> To: devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist)
> 
> Cc: Chen, Gilbert ; Palmer Dabbelt
> 
> Subject: Re: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 10/14]
> U500Pkg/Library: Library instances of U500 platform library
> 
> On Thu, Oct 17, 2019 at 04:09:44PM +, Abner Chang wrote:
> > > -Original Message-
> > > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf
> > > Of Leif Lindholm
> > > Sent: Thursday, October 17, 2019 7:19 PM
> > > To: devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist)
> > > 
> > > Cc: Chen, Gilbert ; Palmer Dabbelt
> > > 
> > > Subject: Re: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 10/14]
> > > U500Pkg/Library: Library instances of U500 platform library
> > >
> > > On Thu, Oct 17, 2019 at 07:44:47AM +, Abner Chang wrote:
> > > > > -Original Message-
> > > > > From: Chang, Abner (HPS SW/FW Technologist)
> > > > > Sent: Thursday, October 17, 2019 10:21 AM
> > > > > To: devel@edk2.groups.io; leif.lindh...@linaro.org; Chen,
> > > > > Gilbert 
> > > > > Cc: Palmer Dabbelt 
> > > > > Subject: RE: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2
> > > > > 10/14]
> > > > > U500Pkg/Library: Library instances of U500 platform library
> > >
> > > > > > Seeing this, I have a bit of a feeling that this Opensbi isn't
> > > > > > being consistently
> > > > > > treated/named:
> > > > > > - In edk2, we have RiscVPkg/Library/RiscVOpensbiLib which
> implements
> > > > > >   class RiscVOpensbiLib.
> > > > > > - Here, we have U500Pkg/Library/OpenSbiPlatformLib
> > > > > > implementing
> > > the
> > > > > >   class OpenSbiPlatformLib.
> > > > > > - *Logically*, what we have is
> > > > > >   Platform/RiscV/Universal/Sec/SecMain.inf which depends on the
> > > > > >   OpensbiLib which depends on the OpenSbiPlatformLib.
> > > > > >   - However, there is no OpenSbiPlatformLib in edk2, which is very
> > > > > > unfortunate because that does not let us build edk2/RiscVPkg in
> > > > > > isolation (like we can with all the other packages in edk2).
> > > > > Will name it as Opensbi.
> > > > > >
> > > > > > Here is my preferred solution for untangling this:
> > > > > > 1) Standardise on OpenSbi or Opensbi. Opensbi follows the pattern
> we
> > > > > >already use for Openssl, so would be my preference.
> > > > > > 2) Standardise on RiscVOpensbi or Opensbi - both for filenames and
> > > > > >LibararyClasses. Either is fine, the former is less likely to 
> > > > > > clash
> > > > > >with other imported projects in the future (but I would estimate
> > > > > >this risk as *very* low to begin with).
> > > > > > 3) Implement a (RiscV)OpensbiPlatformLibNull in
> > > > > > edk2/RiscVPkg/Library,
> > > > > I will have OpensbiPlatformLibNull  in RiscVPlatformPkg/Library
> > > > >
> > > > > >containing only what is required to build/link
> > > > > >RiscVPkg/Library/(RiscV)OpensbiLib/.
> > > > > >3.5) Map that to OpensbiPlatformLib in RiscVPkg/RiscVPkg.dsc.
> > > > > >3.6) Add a depedency on OpensbiPlatformLib to
> > > > > > (RiscV)OpensbiLib.inf
> > > > > >3.7) Drop the dependency on OpensbiPlatformLib from
> > > > > > Platform/RiscV/Universal/Sec/SecMain.inf
> > > > >
> > > > > Above work for me
> > > >
> > > > I changed my mind. Due to SecMain is moved to RiscVPlatformPkg in
> > > > edk2 and requires both RiscVOpensbiPlatformLib and
> > > > RiscVOpensbLiib, SecMain.inf still has dependency with these two libs.
> > >
> > > I am not sure I understand.
> > >
> > > What I am saying is that OpensbiLib already has a dependency on
> > > OpensbiPlatformLib. So there is no benefit to adding the
> > > OpensbiPlatformLib dependency to SecMain. Or does that not work for
> some reason?
> >
> > In order to make those dependencies correct, below is the new changes,
> >
> > RiscVOpensbiPlatformLib has NO dependency with RiscVOpensbiLib.
> > RiscVOpensbiLib has NO dependency with RiscVOpensbiPlatformLib.
> > SecMain.inf has dependencies with both RiscVOpensbiPlatformLib and
> > RiscVOpensbiLib because SecMain.inf needs the functionalities of those
> > libs.
> 
> Ah, OK - this is new for v3 then?
> In that case, sure, the above sounds fine.
Yes, this will be in the next set of patches.
> 
> Regards,
> 
> Leif

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49224): https://edk2.groups.io/g/devel/message/49224
Mute This Topic: https://groups.io/mt/34196358/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms] [PATCH v3 1/4] BoardModulePkg: Add BIOS Info HOB

2019-10-17 Thread Kubacki, Michael A
Reviewed-by: Michael Kubacki 

> -Original Message-
> From: Agyeman, Prince 
> Sent: Thursday, October 17, 2019 5:02 PM
> To: devel@edk2.groups.io
> Cc: Sinha, Ankit ; Desimone, Nathaniel L
> ; Kubacki, Michael A
> 
> Subject: [edk2-platforms] [PATCH v3 1/4] BoardModulePkg: Add BIOS Info
> HOB
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2210
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2211
> 
> Added gBiosInfoGuid to be used in
> publishing the BIOS information HOB
> which is needed in FIT generation
> 
> Also added the BIOS Info header
> file BiosInfo.h that defines the
> BIOS info struct and GUID
> 
> Cc: Ankit Sinha 
> Cc: Nate DeSimone 
> Cc: Kubacki Michael A 
> 
> Signed-off-by: Prince Agyeman 
> ---
>  .../Intel/BoardModulePkg/BoardModulePkg.dec   |  3 +
>  .../BoardModulePkg/Include/Guid/BiosInfo.h| 61
> +++
>  2 files changed, 64 insertions(+)
>  create mode 100644
> Platform/Intel/BoardModulePkg/Include/Guid/BiosInfo.h
> 
> diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
> b/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
> index f96fb09aa1..f461cc7cab 100644
> --- a/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
> +++ b/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
> @@ -39,3 +39,6 @@
>  [Guids]
>## Include Include/Guid/BiosId.h
>gBiosIdGuid = { 0xC3E36D09, 0x8294, 0x4b97, { 0xA8, 0x57, 0xD5, 0x28, 0x8F,
> 0xE3, 0x3E, 0x28 } }
> +
> +  ## GUID to publish BIOS information HOB  gBiosInfoGuid = {
> + 0x09d0d15c, 0xe9f0, 0x4dfc, {0x9e, 0x0b, 0x39, 0x33, 0x1f, 0xca, 0x66,
> + 0x85} }
> diff --git a/Platform/Intel/BoardModulePkg/Include/Guid/BiosInfo.h
> b/Platform/Intel/BoardModulePkg/Include/Guid/BiosInfo.h
> new file mode 100644
> index 00..d73409ea6f
> --- /dev/null
> +++ b/Platform/Intel/BoardModulePkg/Include/Guid/BiosInfo.h
> @@ -0,0 +1,61 @@
> +/** @file
> +  Definitions and GUID for BIOS INFO.
> +
> +  Copyright (c) 2019, Intel Corporation. All rights reserved.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent **/
> +
> +#ifndef _BIOS_INFO_H_
> +#define _BIOS_INFO_H_
> +
> +//
> +// BIOS INFO data structure
> +// This is self contained data structure for BIOS info for TXT //
> +#pragma pack (1) #define BIOS_INFO_SIGNATURE  SIGNATURE_64 ('$', 'B',
> +'I', 'O', 'S', 'I', 'F', '$') typedef struct {
> +  UINT64Signature;
> +  UINT32EntryCount;
> +  UINT32Reserved;
> +//BIOS_INFO_STRUCT  Struct[EntryCount]; } BIOS_INFO_HEADER;
> +
> +//
> +// BIOS_INFO_STRUCT attributes
> +// bits[0:3] means general attributes
> +// bits[4:7] means type specific attributes // #define
> +BIOS_INFO_STRUCT_ATTRIBUTE_GENERAL_EXCLUDE_FROM_FIT  0x01
> +#define BIOS_INFO_STRUCT_ATTRIBUTE_MICROCODE_WHOLE_REGION
> 0x10
> +#define BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB 0x10
> +#define BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_NON_IBB  0x20
> +
> +typedef struct {
> +  //
> +  // FitTable entry type
> +  //
> +  UINT8Type;
> +  //
> +  // BIOS_INFO_STRUCT attributes
> +  //
> +  UINT8Attributes;
> +  //
> +  // FitTable entry version
> +  //
> +  UINT16   Version;
> +  //
> +  // FitTable entry real size
> +  //
> +  UINT32   Size;
> +  //
> +  // FitTable entry address
> +  //
> +  UINT64   Address;
> +} BIOS_INFO_STRUCT;
> +
> +extern EFI_GUID  gBiosInfoGuid;
> +
> +#pragma pack ()
> +
> +#endif
> --
> 2.19.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49214): https://edk2.groups.io/g/devel/message/49214
Mute This Topic: https://groups.io/mt/34950129/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms] [PATCH v3 3/4] WhiskeylakeOpenBoardPkg: Add BIOS Info PEIM

2019-10-17 Thread Kubacki, Michael A
Reviewed-by: Michael Kubacki 

> -Original Message-
> From: Agyeman, Prince 
> Sent: Thursday, October 17, 2019 5:02 PM
> To: devel@edk2.groups.io
> Cc: Sinha, Ankit ; Desimone, Nathaniel L
> ; Kubacki, Michael A
> 
> Subject: [edk2-platforms] [PATCH v3 3/4] WhiskeylakeOpenBoardPkg: Add
> BIOS Info PEIM
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2211
> 
> Added BIOS Info PEIM to publish Bios Info HOB. This PEIM currently publishes
> the microcode FV information.
> 
> Cc: Ankit Sinha 
> Cc: Nate DeSimone 
> Cc: Kubacki Michael A 
> 
> Signed-off-by: Prince Agyeman 
> ---
>  .../BiosInfo/BiosInfo.c   | 93 +++
>  .../BiosInfo/BiosInfo.inf | 49 ++
>  .../WhiskeylakeURvp/OpenBoardPkg.dsc  |  2 +
>  .../WhiskeylakeURvp/OpenBoardPkg.fdf  |  1 +
>  4 files changed, 145 insertions(+)
>  create mode 100644
> Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.c
>  create mode 100644
> Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.inf
> 
> diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.c
> b/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.c
> new file mode 100644
> index 00..578e66149e
> --- /dev/null
> +++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.c
> @@ -0,0 +1,93 @@
> +/** @file
> +  Driver for BIOS Info support.
> +
> +  Copyright (c) 2019, Intel Corporation. All rights reserved.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent **/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define INDEXPORT_TO_ADDRESS(x) (x)
> +#define DATAPORT_TO_ADDRESS(x)  ((x) << 16)
> +#define PORTWIDTH_TO_ADDRESS(x) ((x) << 32)
> +#define PORTBITNUMBER_TO_ADDRESS(x) ((x) << 40)
> +#define PORTINDEXNUMBER_TO_ADDRESS(x)   ((x) << 48)
> +
> +//
> +// Internal
> +//
> +#pragma pack (1)
> +
> +typedef struct {
> +  BIOS_INFO_HEADER  Header;
> +  BIOS_INFO_STRUCT  Entry[1];
> +} BIOS_INFO;
> +#pragma pack ()
> +
> +GLOBAL_REMOVE_IF_UNREFERENCED BIOS_INFO  mBiosInfo = {
> +  {
> +BIOS_INFO_SIGNATURE,
> +1,
> +0,
> +  },
> +  {
> +{
> +  FIT_TYPE_01_MICROCODE,
> +  BIOS_INFO_STRUCT_ATTRIBUTE_MICROCODE_WHOLE_REGION,
> +  0x0100,
> +  FixedPcdGet32 (PcdFlashMicrocodeFvSize),
> +  FixedPcdGet32 (PcdFlashMicrocodeFvBase)
> +}
> +  }
> +};
> +
> +GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR
> mBiosInfoPpiList
> += {
> +  EFI_PEI_PPI_DESCRIPTOR_PPI |
> EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
> +  ,
> +  
> +};
> +
> +/**
> +  Installs BiosInfo Ppi and builds BiosInfo HOB .
> +
> +  @param  FileHandle  Handle of the file being invoked.
> +  @param  PeiServices Describes the list of possible PEI Services.
> +
> +  @retval EFI_SUCCESS   Install the BiosInfo Ppi and HOB successfully.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +BiosInfoEntryPoint (
> +  IN   EFI_PEI_FILE_HANDLE  FileHandle,
> +  IN CONST EFI_PEI_SERVICES **PeiServices
> +  )
> +{
> +  EFI_STATUS  Status;
> +  VOID*HobData;
> +
> +  //
> +  // Install PPI, so that other PEI module can add dependency.
> +  //
> +  Status = PeiServicesInstallPpi ();  ASSERT_EFI_ERROR
> + (Status);
> +
> +  //
> +  // Build hob, so that DXE module can also get the data.
> +  //
> +  HobData = BuildGuidHob (, sizeof (mBiosInfo));  ASSERT
> + (HobData != NULL);  if (HobData == NULL) {
> +return EFI_OUT_OF_RESOURCES;
> +  }
> +  CopyMem (HobData, , sizeof (mBiosInfo));
> +
> +  return EFI_SUCCESS;
> +}
> diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.inf
> b/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.inf
> new file mode 100644
> index 00..a9687d93de
> --- /dev/null
> +++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.inf
> @@ -0,0 +1,49 @@
> +### @file
> +#  Module Information description file for BIOS Info Driver # #
> +Copyright (c) 2019, Intel Corporation. All rights reserved. #
> +SPDX-License-Identifier: BSD-2-Clause-Patent ###
> +
> +[Defines]
> +  INF_VERSION= 0x00010017
> +  BASE_NAME  = BiosInfo
> +  FILE_GUID  = A842B2D2-5C88-44E9-A9E2-4830F26662B7
> +  VERSION_STRING = 1.0
> +  MODULE_TYPE= PEIM
> +  ENTRY_POINT= BiosInfoEntryPoint
> +#
> +# The following information is for reference only and not required by the
> build tools.
> +#
> +# VALID_ARCHITECTURES IA32 X64
> +#
> +
> +[LibraryClasses]
> +  PeimEntryPoint
> +  PeiServicesLib
> +  HobLib
> +  BaseMemoryLib
> +  DebugLib
> +  PcdLib
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  IntelSiliconPkg/IntelSiliconPkg.dec
> +  CoffeelakeSiliconPkg/SiPkg.dec
> +  CoffeeLakeFspBinPkg/CoffeeLakeFspBinPkg.dec
> +  BoardModulePkg/BoardModulePkg.dec
> +  MinPlatformPkg/MinPlatformPkg.dec
> +
> +[Pcd]
> +  

Re: [edk2-devel] [edk2-platforms] [PATCH v3 2/4] KabylakeOpenBoardPkg: Add BIOS Info PEIM

2019-10-17 Thread Kubacki, Michael A
Reviewed-by: Michael Kubacki 

> -Original Message-
> From: Agyeman, Prince 
> Sent: Thursday, October 17, 2019 5:02 PM
> To: devel@edk2.groups.io
> Cc: Sinha, Ankit ; Desimone, Nathaniel L
> ; Kubacki, Michael A
> 
> Subject: [edk2-platforms] [PATCH v3 2/4] KabylakeOpenBoardPkg: Add BIOS
> Info PEIM
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2210
> 
> Added BIOS Info PEIM to KabylakeRvp3 and GalagoPro3 to publish the BIOS
> info HOB. This PEIM currently publishes the board's microcode region
> information.
> 
> Cc: Ankit Sinha 
> Cc: Nate DeSimone 
> Cc: Kubacki Michael A 
> 
> Signed-off-by: Prince Agyeman 
> ---
>  .../KabylakeOpenBoardPkg/BiosInfo/BiosInfo.c  | 93
> +++
>  .../BiosInfo/BiosInfo.inf | 49 ++
>  .../GalagoPro3/OpenBoardPkg.dsc   |  1 +
>  .../GalagoPro3/OpenBoardPkg.fdf   |  1 +
>  .../KabylakeRvp3/OpenBoardPkg.dsc |  1 +
>  .../KabylakeRvp3/OpenBoardPkg.fdf |  1 +
>  6 files changed, 146 insertions(+)
>  create mode 100644
> Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.c
>  create mode 100644
> Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.inf
> 
> diff --git a/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.c
> b/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.c
> new file mode 100644
> index 00..578e66149e
> --- /dev/null
> +++ b/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.c
> @@ -0,0 +1,93 @@
> +/** @file
> +  Driver for BIOS Info support.
> +
> +  Copyright (c) 2019, Intel Corporation. All rights reserved.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent **/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define INDEXPORT_TO_ADDRESS(x) (x)
> +#define DATAPORT_TO_ADDRESS(x)  ((x) << 16)
> +#define PORTWIDTH_TO_ADDRESS(x) ((x) << 32)
> +#define PORTBITNUMBER_TO_ADDRESS(x) ((x) << 40)
> +#define PORTINDEXNUMBER_TO_ADDRESS(x)   ((x) << 48)
> +
> +//
> +// Internal
> +//
> +#pragma pack (1)
> +
> +typedef struct {
> +  BIOS_INFO_HEADER  Header;
> +  BIOS_INFO_STRUCT  Entry[1];
> +} BIOS_INFO;
> +#pragma pack ()
> +
> +GLOBAL_REMOVE_IF_UNREFERENCED BIOS_INFO  mBiosInfo = {
> +  {
> +BIOS_INFO_SIGNATURE,
> +1,
> +0,
> +  },
> +  {
> +{
> +  FIT_TYPE_01_MICROCODE,
> +  BIOS_INFO_STRUCT_ATTRIBUTE_MICROCODE_WHOLE_REGION,
> +  0x0100,
> +  FixedPcdGet32 (PcdFlashMicrocodeFvSize),
> +  FixedPcdGet32 (PcdFlashMicrocodeFvBase)
> +}
> +  }
> +};
> +
> +GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR
> mBiosInfoPpiList
> += {
> +  EFI_PEI_PPI_DESCRIPTOR_PPI |
> EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
> +  ,
> +  
> +};
> +
> +/**
> +  Installs BiosInfo Ppi and builds BiosInfo HOB .
> +
> +  @param  FileHandle  Handle of the file being invoked.
> +  @param  PeiServices Describes the list of possible PEI Services.
> +
> +  @retval EFI_SUCCESS   Install the BiosInfo Ppi and HOB successfully.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +BiosInfoEntryPoint (
> +  IN   EFI_PEI_FILE_HANDLE  FileHandle,
> +  IN CONST EFI_PEI_SERVICES **PeiServices
> +  )
> +{
> +  EFI_STATUS  Status;
> +  VOID*HobData;
> +
> +  //
> +  // Install PPI, so that other PEI module can add dependency.
> +  //
> +  Status = PeiServicesInstallPpi ();  ASSERT_EFI_ERROR
> + (Status);
> +
> +  //
> +  // Build hob, so that DXE module can also get the data.
> +  //
> +  HobData = BuildGuidHob (, sizeof (mBiosInfo));  ASSERT
> + (HobData != NULL);  if (HobData == NULL) {
> +return EFI_OUT_OF_RESOURCES;
> +  }
> +  CopyMem (HobData, , sizeof (mBiosInfo));
> +
> +  return EFI_SUCCESS;
> +}
> diff --git a/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.inf
> b/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.inf
> new file mode 100644
> index 00..e5e40144a6
> --- /dev/null
> +++ b/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.inf
> @@ -0,0 +1,49 @@
> +### @file
> +#  Module Information description file for BIOS Info Driver # #
> +Copyright (c) 2019, Intel Corporation. All rights reserved. #
> +SPDX-License-Identifier: BSD-2-Clause-Patent ###
> +
> +[Defines]
> +  INF_VERSION= 0x00010017
> +  BASE_NAME  = BiosInfo
> +  FILE_GUID  = C83BCE0E-6F16-4D3C-8D9F-4D6F5A032929
> +  VERSION_STRING = 1.0
> +  MODULE_TYPE= PEIM
> +  ENTRY_POINT= BiosInfoEntryPoint
> +#
> +# The following information is for reference only and not required by the
> build tools.
> +#
> +# VALID_ARCHITECTURES IA32 X64
> +#
> +
> +[LibraryClasses]
> +  PeimEntryPoint
> +  PeiServicesLib
> +  HobLib
> +  BaseMemoryLib
> +  DebugLib
> +  PcdLib
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  IntelSiliconPkg/IntelSiliconPkg.dec
> +  KabylakeSiliconPkg/SiPkg.dec
> +  

Re: [edk2-devel] [edk2-platforms] [PATCH v3 1/4] BoardModulePkg: Add BIOS Info HOB

2019-10-17 Thread Nate DeSimone
Reviewed-by: Nate DeSimone 

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Agyeman, Prince
Sent: Thursday, October 17, 2019 5:02 PM
To: devel@edk2.groups.io
Cc: Sinha, Ankit ; Desimone, Nathaniel L 
; Kubacki, Michael A 

Subject: [edk2-devel] [edk2-platforms] [PATCH v3 1/4] BoardModulePkg: Add BIOS 
Info HOB

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2210
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2211

Added gBiosInfoGuid to be used in
publishing the BIOS information HOB
which is needed in FIT generation

Also added the BIOS Info header
file BiosInfo.h that defines the
BIOS info struct and GUID

Cc: Ankit Sinha 
Cc: Nate DeSimone 
Cc: Kubacki Michael A 

Signed-off-by: Prince Agyeman 
---
 .../Intel/BoardModulePkg/BoardModulePkg.dec   |  3 +
 .../BoardModulePkg/Include/Guid/BiosInfo.h| 61 +++
 2 files changed, 64 insertions(+)
 create mode 100644 Platform/Intel/BoardModulePkg/Include/Guid/BiosInfo.h

diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dec 
b/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
index f96fb09aa1..f461cc7cab 100644
--- a/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
+++ b/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
@@ -39,3 +39,6 @@
 [Guids]
   ## Include Include/Guid/BiosId.h
   gBiosIdGuid = { 0xC3E36D09, 0x8294, 0x4b97, { 0xA8, 0x57, 0xD5, 0x28, 0x8F, 
0xE3, 0x3E, 0x28 } }
+
+  ## GUID to publish BIOS information HOB  gBiosInfoGuid = { 
+ 0x09d0d15c, 0xe9f0, 0x4dfc, {0x9e, 0x0b, 0x39, 0x33, 0x1f, 0xca, 0x66, 
+ 0x85} }
diff --git a/Platform/Intel/BoardModulePkg/Include/Guid/BiosInfo.h 
b/Platform/Intel/BoardModulePkg/Include/Guid/BiosInfo.h
new file mode 100644
index 00..d73409ea6f
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/Include/Guid/BiosInfo.h
@@ -0,0 +1,61 @@
+/** @file
+  Definitions and GUID for BIOS INFO.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent **/
+
+#ifndef _BIOS_INFO_H_
+#define _BIOS_INFO_H_
+
+//
+// BIOS INFO data structure
+// This is self contained data structure for BIOS info for TXT // 
+#pragma pack (1) #define BIOS_INFO_SIGNATURE  SIGNATURE_64 ('$', 'B', 
+'I', 'O', 'S', 'I', 'F', '$') typedef struct {
+  UINT64Signature;
+  UINT32EntryCount;
+  UINT32Reserved;
+//BIOS_INFO_STRUCT  Struct[EntryCount]; } BIOS_INFO_HEADER;
+
+//
+// BIOS_INFO_STRUCT attributes
+// bits[0:3] means general attributes
+// bits[4:7] means type specific attributes // #define 
+BIOS_INFO_STRUCT_ATTRIBUTE_GENERAL_EXCLUDE_FROM_FIT  0x01
+#define BIOS_INFO_STRUCT_ATTRIBUTE_MICROCODE_WHOLE_REGION0x10
+#define BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB 0x10
+#define BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_NON_IBB  0x20
+
+typedef struct {
+  //
+  // FitTable entry type
+  //
+  UINT8Type;
+  //
+  // BIOS_INFO_STRUCT attributes
+  //
+  UINT8Attributes;
+  //
+  // FitTable entry version
+  //
+  UINT16   Version;
+  //
+  // FitTable entry real size
+  //
+  UINT32   Size;
+  //
+  // FitTable entry address
+  //
+  UINT64   Address;
+} BIOS_INFO_STRUCT;
+
+extern EFI_GUID  gBiosInfoGuid;
+
+#pragma pack ()
+
+#endif
--
2.19.1.windows.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49219): https://edk2.groups.io/g/devel/message/49219
Mute This Topic: https://groups.io/mt/34950129/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms] [PATCH v3 3/4] WhiskeylakeOpenBoardPkg: Add BIOS Info PEIM

2019-10-17 Thread Nate DeSimone
Reviewed-by: Nate DeSimone 

-Original Message-
From: Agyeman, Prince  
Sent: Thursday, October 17, 2019 5:02 PM
To: devel@edk2.groups.io
Cc: Sinha, Ankit ; Desimone, Nathaniel L 
; Kubacki, Michael A 

Subject: [edk2-platforms] [PATCH v3 3/4] WhiskeylakeOpenBoardPkg: Add BIOS Info 
PEIM

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2211

Added BIOS Info PEIM to publish Bios Info HOB. This PEIM currently publishes 
the microcode FV information.

Cc: Ankit Sinha 
Cc: Nate DeSimone 
Cc: Kubacki Michael A 

Signed-off-by: Prince Agyeman 
---
 .../BiosInfo/BiosInfo.c   | 93 +++
 .../BiosInfo/BiosInfo.inf | 49 ++
 .../WhiskeylakeURvp/OpenBoardPkg.dsc  |  2 +
 .../WhiskeylakeURvp/OpenBoardPkg.fdf  |  1 +
 4 files changed, 145 insertions(+)
 create mode 100644 Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.c
 create mode 100644 Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.inf

diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.c 
b/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.c
new file mode 100644
index 00..578e66149e
--- /dev/null
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.c
@@ -0,0 +1,93 @@
+/** @file
+  Driver for BIOS Info support.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent **/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define INDEXPORT_TO_ADDRESS(x) (x)
+#define DATAPORT_TO_ADDRESS(x)  ((x) << 16)
+#define PORTWIDTH_TO_ADDRESS(x) ((x) << 32)
+#define PORTBITNUMBER_TO_ADDRESS(x) ((x) << 40)
+#define PORTINDEXNUMBER_TO_ADDRESS(x)   ((x) << 48)
+
+//
+// Internal
+//
+#pragma pack (1)
+
+typedef struct {
+  BIOS_INFO_HEADER  Header;
+  BIOS_INFO_STRUCT  Entry[1];
+} BIOS_INFO;
+#pragma pack ()
+
+GLOBAL_REMOVE_IF_UNREFERENCED BIOS_INFO  mBiosInfo = {
+  {
+BIOS_INFO_SIGNATURE,
+1,
+0,
+  },
+  {
+{
+  FIT_TYPE_01_MICROCODE,
+  BIOS_INFO_STRUCT_ATTRIBUTE_MICROCODE_WHOLE_REGION,
+  0x0100,
+  FixedPcdGet32 (PcdFlashMicrocodeFvSize),
+  FixedPcdGet32 (PcdFlashMicrocodeFvBase)
+}
+  }
+};
+
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR  mBiosInfoPpiList 
+= {
+  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+  ,
+  
+};
+
+/**
+  Installs BiosInfo Ppi and builds BiosInfo HOB .
+
+  @param  FileHandle  Handle of the file being invoked.
+  @param  PeiServices Describes the list of possible PEI Services.
+
+  @retval EFI_SUCCESS   Install the BiosInfo Ppi and HOB successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+BiosInfoEntryPoint (
+  IN   EFI_PEI_FILE_HANDLE  FileHandle,
+  IN CONST EFI_PEI_SERVICES **PeiServices
+  )
+{
+  EFI_STATUS  Status;
+  VOID*HobData;
+
+  //
+  // Install PPI, so that other PEI module can add dependency.
+  //
+  Status = PeiServicesInstallPpi ();  ASSERT_EFI_ERROR 
+ (Status);
+
+  //
+  // Build hob, so that DXE module can also get the data.
+  //
+  HobData = BuildGuidHob (, sizeof (mBiosInfo));  ASSERT 
+ (HobData != NULL);  if (HobData == NULL) {
+return EFI_OUT_OF_RESOURCES;
+  }
+  CopyMem (HobData, , sizeof (mBiosInfo));
+
+  return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.inf 
b/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.inf
new file mode 100644
index 00..a9687d93de
--- /dev/null
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.inf
@@ -0,0 +1,49 @@
+### @file
+#  Module Information description file for BIOS Info Driver # #
+Copyright (c) 2019, Intel Corporation. All rights reserved. #
+SPDX-License-Identifier: BSD-2-Clause-Patent ###
+
+[Defines]
+  INF_VERSION= 0x00010017
+  BASE_NAME  = BiosInfo
+  FILE_GUID  = A842B2D2-5C88-44E9-A9E2-4830F26662B7
+  VERSION_STRING = 1.0
+  MODULE_TYPE= PEIM
+  ENTRY_POINT= BiosInfoEntryPoint
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+# VALID_ARCHITECTURES IA32 X64
+#
+
+[LibraryClasses]
+  PeimEntryPoint
+  PeiServicesLib
+  HobLib
+  BaseMemoryLib
+  DebugLib
+  PcdLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  IntelSiliconPkg/IntelSiliconPkg.dec
+  CoffeelakeSiliconPkg/SiPkg.dec
+  CoffeeLakeFspBinPkg/CoffeeLakeFspBinPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
+  MinPlatformPkg/MinPlatformPkg.dec
+
+[Pcd]
+  gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvBase## CONSUMES
+  gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvSize## CONSUMES
+
+[Sources]
+  BiosInfo.c
+
+[Guids]
+  gBiosInfoGuid ## PRODUCES
+
+[Depex]
+  TRUE
diff --git 

Re: [edk2-devel] [edk2-platforms] [PATCH v3 2/4] KabylakeOpenBoardPkg: Add BIOS Info PEIM

2019-10-17 Thread Nate DeSimone
Reviewed-by: Nate DeSimone 

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Agyeman, Prince
Sent: Thursday, October 17, 2019 5:02 PM
To: devel@edk2.groups.io
Cc: Sinha, Ankit ; Desimone, Nathaniel L 
; Kubacki, Michael A 

Subject: [edk2-devel] [edk2-platforms] [PATCH v3 2/4] KabylakeOpenBoardPkg: Add 
BIOS Info PEIM

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2210

Added BIOS Info PEIM to KabylakeRvp3 and GalagoPro3 to publish the BIOS info 
HOB. This PEIM currently publishes the board's microcode region information.

Cc: Ankit Sinha 
Cc: Nate DeSimone 
Cc: Kubacki Michael A 

Signed-off-by: Prince Agyeman 
---
 .../KabylakeOpenBoardPkg/BiosInfo/BiosInfo.c  | 93 +++
 .../BiosInfo/BiosInfo.inf | 49 ++
 .../GalagoPro3/OpenBoardPkg.dsc   |  1 +
 .../GalagoPro3/OpenBoardPkg.fdf   |  1 +
 .../KabylakeRvp3/OpenBoardPkg.dsc |  1 +
 .../KabylakeRvp3/OpenBoardPkg.fdf |  1 +
 6 files changed, 146 insertions(+)
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.inf

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.c 
b/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.c
new file mode 100644
index 00..578e66149e
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.c
@@ -0,0 +1,93 @@
+/** @file
+  Driver for BIOS Info support.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent **/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define INDEXPORT_TO_ADDRESS(x) (x)
+#define DATAPORT_TO_ADDRESS(x)  ((x) << 16)
+#define PORTWIDTH_TO_ADDRESS(x) ((x) << 32)
+#define PORTBITNUMBER_TO_ADDRESS(x) ((x) << 40)
+#define PORTINDEXNUMBER_TO_ADDRESS(x)   ((x) << 48)
+
+//
+// Internal
+//
+#pragma pack (1)
+
+typedef struct {
+  BIOS_INFO_HEADER  Header;
+  BIOS_INFO_STRUCT  Entry[1];
+} BIOS_INFO;
+#pragma pack ()
+
+GLOBAL_REMOVE_IF_UNREFERENCED BIOS_INFO  mBiosInfo = {
+  {
+BIOS_INFO_SIGNATURE,
+1,
+0,
+  },
+  {
+{
+  FIT_TYPE_01_MICROCODE,
+  BIOS_INFO_STRUCT_ATTRIBUTE_MICROCODE_WHOLE_REGION,
+  0x0100,
+  FixedPcdGet32 (PcdFlashMicrocodeFvSize),
+  FixedPcdGet32 (PcdFlashMicrocodeFvBase)
+}
+  }
+};
+
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR  mBiosInfoPpiList 
+= {
+  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+  ,
+  
+};
+
+/**
+  Installs BiosInfo Ppi and builds BiosInfo HOB .
+
+  @param  FileHandle  Handle of the file being invoked.
+  @param  PeiServices Describes the list of possible PEI Services.
+
+  @retval EFI_SUCCESS   Install the BiosInfo Ppi and HOB successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+BiosInfoEntryPoint (
+  IN   EFI_PEI_FILE_HANDLE  FileHandle,
+  IN CONST EFI_PEI_SERVICES **PeiServices
+  )
+{
+  EFI_STATUS  Status;
+  VOID*HobData;
+
+  //
+  // Install PPI, so that other PEI module can add dependency.
+  //
+  Status = PeiServicesInstallPpi ();  ASSERT_EFI_ERROR 
+ (Status);
+
+  //
+  // Build hob, so that DXE module can also get the data.
+  //
+  HobData = BuildGuidHob (, sizeof (mBiosInfo));  ASSERT 
+ (HobData != NULL);  if (HobData == NULL) {
+return EFI_OUT_OF_RESOURCES;
+  }
+  CopyMem (HobData, , sizeof (mBiosInfo));
+
+  return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.inf 
b/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.inf
new file mode 100644
index 00..e5e40144a6
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.inf
@@ -0,0 +1,49 @@
+### @file
+#  Module Information description file for BIOS Info Driver # #
+Copyright (c) 2019, Intel Corporation. All rights reserved. #
+SPDX-License-Identifier: BSD-2-Clause-Patent ###
+
+[Defines]
+  INF_VERSION= 0x00010017
+  BASE_NAME  = BiosInfo
+  FILE_GUID  = C83BCE0E-6F16-4D3C-8D9F-4D6F5A032929
+  VERSION_STRING = 1.0
+  MODULE_TYPE= PEIM
+  ENTRY_POINT= BiosInfoEntryPoint
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+# VALID_ARCHITECTURES IA32 X64
+#
+
+[LibraryClasses]
+  PeimEntryPoint
+  PeiServicesLib
+  HobLib
+  BaseMemoryLib
+  DebugLib
+  PcdLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  IntelSiliconPkg/IntelSiliconPkg.dec
+  KabylakeSiliconPkg/SiPkg.dec
+  KabylakeFspBinPkg/KabylakeFspBinPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
+  MinPlatformPkg/MinPlatformPkg.dec
+
+[Pcd]
+  gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvBase## CONSUMES
+  gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvSize## CONSUMES
+
+[Sources]
+  

Re: [edk2-devel] [edk2-platforms] [PATCH v3 4/4] Platform/Intel: Add FIT generation tool

2019-10-17 Thread Nate DeSimone
Reviewed-by: Nate DeSimone 

-Original Message-
From: Agyeman, Prince  
Sent: Thursday, October 17, 2019 5:02 PM
To: devel@edk2.groups.io
Cc: Sinha, Ankit ; Desimone, Nathaniel L 
; Kubacki, Michael A 

Subject: [edk2-platforms] [PATCH v3 4/4] Platform/Intel: Add FIT generation tool

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2210
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2211

Added FitGen tool build and FIT generation to the BIOS build process.

What was done:

- Build the FIT generation tool
- Added default/empty BIOS_INFO_GUID to the build.cfg
- Added BIOS_INFO_GUID to GalagoPro3,KabylakeRvp3 and WhiskeylakeURvp's 
build_config.cfg This allows a board to specify the GUID associated with the 
BIOS Info PEIM to be used in the board's FIT generation.

BIOS_INFO_GUID is passed as an argument to FitGen tool which allow the tool to 
locate the BIOS Info module to be used in FIT generation.

Cc: Ankit Sinha 
Cc: Nate DeSimone 
Cc: Michael Kubacki 

Signed-off-by: Prince Agyeman 
---
 .../GalagoPro3/build_config.cfg   |  1 +
 .../KabylakeRvp3/build_config.cfg |  1 +
 .../WhiskeylakeURvp/build_config.cfg  |  1 +
 Platform/Intel/build.cfg  |  1 +
 Platform/Intel/build_bios.py  | 57 +++
 5 files changed, 61 insertions(+)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/build_config.cfg 
b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/build_config.cfg
index 8c6c51abb4..458fe3d35d 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/build_config.cfg
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/build_config.cfg
@@ -31,3 +31,4 @@ FSP_PKG_NAME = KabylakeFspPkg  FSP_BINARY_BUILD = FALSE  
FSP_TEST_RELEASE = FALSE  SECURE_BOOT_ENABLE = FALSE
+BIOS_INFO_GUID = C83BCE0E-6F16-4D3C-8D9F-4D6F5A032929
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/build_config.cfg 
b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/build_config.cfg
index 78f808bfaf..f6ae4b342a 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/build_config.cfg
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/build_config.cfg
@@ -33,3 +33,4 @@ FSP_PKG_NAME = AmberLakeFspPkg  FSP_BINARY_BUILD = FALSE  
FSP_TEST_RELEASE = FALSE  SECURE_BOOT_ENABLE = FALSE
+BIOS_INFO_GUID = C83BCE0E-6F16-4D3C-8D9F-4D6F5A032929
diff --git 
a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/build_config.cfg 
b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/build_config.cfg
index 1b0619bc1c..1dfe5ffd10 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/build_config.cfg
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/build_confi
+++ g.cfg
@@ -31,3 +31,4 @@ FSP_PKG_NAME = CoffeelakeSiliconPkg  FSP_BINARY_BUILD = FALSE 
 FSP_TEST_RELEASE = FALSE  SECURE_BOOT_ENABLE = FALSE
+BIOS_INFO_GUID = A842B2D2-5C88-44E9-A9E2-4830F26662B7
diff --git a/Platform/Intel/build.cfg b/Platform/Intel/build.cfg index 
2040774d1b..6aee96694c 100644
--- a/Platform/Intel/build.cfg
+++ b/Platform/Intel/build.cfg
@@ -48,6 +48,7 @@ SECURE_BOOT_ENABLE = FALSE  REBUILD_MODE =  BUILD_ROM_ONLY =  
NUMBER_OF_PROCESSORS = 0
+BIOS_INFO_GUID =
 
 
 [PLATFORMS]
diff --git a/Platform/Intel/build_bios.py b/Platform/Intel/build_bios.py index 
46285df19a..ea098de705 100644
--- a/Platform/Intel/build_bios.py
+++ b/Platform/Intel/build_bios.py
@@ -196,6 +196,31 @@ def pre_build(build_config, build_type="DEBUG", 
silent=False, toolchain=None):
 if return_code != 0:
 build_failed(config)
 
+#
+# build platform silicon tools
+#
+# save the current workspace
+saved_work_directory = config["WORKSPACE"]
+# change the workspace to silicon tools directory
+config["WORKSPACE"] = os.path.join(config["WORKSPACE_SILICON"], 
+ "Tools")
+
+command = ["nmake"]
+if os.name == "posix":  # linux
+command = ["make"]
+# add path to generated FitGen binary to
+# environment path variable
+config["PATH"] += os.pathsep + \
+  os.path.join(config["BASE_TOOLS_PATH"],
+   "Source", "C", "bin")
+
+# build the silicon tools
+_, _, result, return_code = execute_script(command, config, shell=shell)
+if return_code != 0:
+build_failed(config)
+
+# restore WORKSPACE environment variable
+config["WORKSPACE"] = saved_work_directory
+
 config["SILENT_MODE"] = 'TRUE' if silent else 'FALSE'
 
 print("==")
@@ -404,6 +429,35 @@ def post_build(config):
 :returns: nothing
 """
 print("Running post_build to complete the build process.")
+board_fd = config["BOARD"].upper()
+final_fd = os.path.join(config["BUILD_DIR_PATH"], "FV",
+"{}.fd".format(board_fd))
+
+if config["BIOS_INFO_GUID"]:
+# Generate the fit table
+print("Generating FIT ...")
+if 

Re: [edk2-devel] [PATCH] MdeModulePkg/HiiDatabaseDxe: Add check for 'Private->Attribute >> 4'

2019-10-17 Thread Dandan Bi
> -Original Message-
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Zhang, Shenglei
> Sent: Thursday, October 17, 2019 2:21 PM
> To: devel@edk2.groups.io
> Cc: Bi, Dandan ; Dong, Eric 
> Subject: [edk2-devel] [PATCH] MdeModulePkg/HiiDatabaseDxe: Add check
> for 'Private->Attribute >> 4'
> 
> The size of mHiiEfiColors is 16.
> mHiiEfiColors[Private->Attribute >> 4] may be out of boundary.
> So add a check for that.
> 
> Cc: Dandan Bi 
> Cc: Eric Dong 
> Signed-off-by: Shenglei Zhang 
> ---
>  MdeModulePkg/Universal/HiiDatabaseDxe/Font.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
> b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
> index ca63df168c94..282a7a114d17 100644
> --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
> +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
> @@ -999,7 +999,12 @@ GetSystemFont (
>}
> 
>Info->ForegroundColor= mHiiEfiColors[Private->Attribute & 0x0f];
> -  Info->BackgroundColor= mHiiEfiColors[Private->Attribute >> 4];
> +  if ((Private->Attribute >> 4) < 16){
> +Info->BackgroundColor= mHiiEfiColors[Private->Attribute >> 4];
> +  } else {
> +return EFI_INVALID_PARAMETER;
> +  }
> +
Hi Shenglei,

Foreground and background color are saved in a single byte. Bits 0..3 are the 
foreground color and bits 4..6 are the background color.
If the Private->Attribute defined correctly, then (Private->Attribute >> 4) 
must less than 8. And in current code Private->Attribute is defined as 
EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK) in HiiDatabaseEntry.c, so the 
(Private->Attribute >> 4) will not overflow. I think we can add ASSERT code 
instead.


Thanks,
Dandan
>Info->FontInfoMask   = EFI_FONT_INFO_SYS_FONT |
> EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_SYS_STYLE;
>Info->FontInfo.FontStyle = 0;
>Info->FontInfo.FontSize  = EFI_GLYPH_HEIGHT;
> --
> 2.18.0.windows.1
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49218): https://edk2.groups.io/g/devel/message/49218
Mute This Topic: https://groups.io/mt/34685172/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [v9 v9] IntelSiliconPkg-Vtd: A new PMR interface

2019-10-17 Thread Chaganty, Rangasai V
Reviewed-by: Sai Chaganty 

-Original Message-
From: Wang, Iwen Evelyn 
Sent: Thursday, October 17, 2019 6:22 PM
To: devel@edk2.groups.io
Cc: Huang, Jenny ; Shih, More ; Ni, 
Ray ; Chaganty, Rangasai V ; 
Yao, Jiewen 
Subject: [v9 v9] IntelSiliconPkg-Vtd: A new PMR interface

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1770

1) IOMMU PMR feature should be generic to support different hardware 
architecture. Platforms may request no overlap between PMR regions and system 
reserve memory. Create an interface to publish PLMR/PHMR regions. It allows 
silicon code to adjust PLMR/PHMR region base on the project needs.

2) A new GetVtdPmrAlignmentLib for silicon code to get PMR alignment values.

Signed-off-by: Evelyn Wang 
Cc: Jenny Huang 
Cc: More Shih 
Cc: Ray Ni 
Cc: Rangasai V Chaganty 
Cc: Jiewen Yao 

---
In V2:
1) Fixed the EFIAPI is missing in library API issue
2) Logs will be provided to make sure the backwards compatibility
3) Replaced BIT0 with EFI_ACPI_DMAR_DRHD_FLAGS_INCLUDE_PCI_ALL
4) Renamed GetVtdPmrAlignmentLib to PeiGetVtdPmrAlignmentLib
5) Fixed the indent in IntelVTdPmrPei.c
6) Follow VTd spec to define the data type of the SYSTEM_MEM_INFO_HOB
   Applied few changes coordinately

---
In V3:
1) Fixed the EFIAPI is missing in library API issue
2) Fixed the S3 resume assert

---
In V4:
Fixed the missing EFIAPI in .h file and added few more comments

---
In V5:
In order to align with the future planning, changed the hob name from 
SYSTEM_MEM_INFO_HOB to VTD_PMR_INFO_HOB

---
In V6:
1) Revised comments
2) Moved VtdPmrInfoHob.h under Guid folder
3) Separated to few commits

---
In V7:
1) Only the functions declared in library header file should have EFIAPI
2) Added a few comments to avoid confusion
3) Fixed a case error

---
In V8:
1) Fixed a typo and commit message

---
In V9:
1) Fixed a typo and articles
---
 Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmr.c 
 |   4 ++--
 Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c  
 |  84 
+---
 
Silicon/Intel/IntelSiliconPkg/Library/PeiGetVtdPmrAlignmentLib/PeiGetVtdPmrAlignmentLib.c
   | 164 

 Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.inf
 |   5 -
 Silicon/Intel/IntelSiliconPkg/Include/Guid/VtdPmrInfoHob.h 
 |  29 +
 Silicon/Intel/IntelSiliconPkg/Include/Library/PeiGetVtdPmrAlignmentLib.h   
 |  22 ++
 Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec  
 |  11 +--
 Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dsc  
 |   3 ++-
 
Silicon/Intel/IntelSiliconPkg/Library/PeiGetVtdPmrAlignmentLib/PeiGetVtdPmrAlignmentLib.inf
 |  32 
 9 files changed, 325 insertions(+), 29 deletions(-)

diff --git 
a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmr.c 
b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmr.c
index 37283f0fab..9103e53922 100644
--- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmr.c
+++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdP
+++ mr.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2017 - 2019, Intel Corporation. All rights 
+ reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -294,7 +294,7 @@ SetDmaProtectedRange (
   UINTN   Index;
   EFI_STATUS  Status;
 
-  DEBUG ((DEBUG_INFO, "SetDmaProtectedRange(0x%lx) - [0x%x, 0x%x] [0x%lx, 
0x%lx]\n", EngineMask, LowMemoryBase, LowMemoryLength, HighMemoryBase, 
HighMemoryLength));
+  DEBUG ((DEBUG_INFO, "SetDmaProtectedRange(0x%lx) - [0x%x, 0x%x] 
+ [0x%016lx, 0x%016lx]\n", EngineMask, LowMemoryBase, LowMemoryLength, 
+ HighMemoryBase, HighMemoryLength));
 
   for (Index = 0; Index < VTdInfo->VTdEngineCount; Index++) {
 if ((EngineMask & LShiftU64(1, Index)) == 0) { diff --git 
a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c 
b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c
index ca099ed71d..ea944aa40c 100644
--- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c
+++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdP
+++ mrPei.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2017 - 2019, Intel Corporation. All rights 
+ reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -20,7 +20,7 @@
 #include 
 #include 
 #include 
-
+#include 
 #include "IntelVTdPmrPei.h"
 
 

Re: [edk2-devel] [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/BootMediaLib: Reduce library API

2019-10-17 Thread Nate DeSimone
Reviewed-by: Nate DeSimone 

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Kubacki, Michael 
A
Sent: Monday, October 14, 2019 2:26 PM
To: devel@edk2.groups.io
Cc: Chaganty, Rangasai V ; Ni, Ray 

Subject: [edk2-devel] [edk2-platforms][PATCH V1 1/1] 
IntelSiliconPkg/BootMediaLib: Reduce library API

Removes the following functions from FirmwareBootMediaLib.h:
 * FirmwareBootMediaIsSpi ()
 * FirmwareBootMediaIsUfs ()
 * FirmwareBootMediaIsEmmc ()
 * FirmwareBootMediaIsNvme ()

It is preferred to have a single method to retrieve the firmware boot media. To 
reduce overall maintenance effort over time, the FirmwareBootMediaIsXxx () 
pattern is removed in favor of returning the firmware boot media type via 
GetFirmwareBootMediaType ().

Cc: Sai Chaganty 
Cc: Ray Ni 
Signed-off-by: Michael Kubacki 
---
 
Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmmFirmwareBootMediaLib.inf
 |   1 -
 
Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFirmwareBootMediaLib.inf
|   1 -
 Silicon/Intel/IntelSiliconPkg/Include/Library/FirmwareBootMediaLib.h   
|  48 -
 
Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/FirmwareBootMediaLib.c
 | 109 
 4 files changed, 159 deletions(-)

diff --git 
a/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmmFirmwareBootMediaLib.inf
 
b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmmFirmwareBootMediaLib.inf
index 83ed5f04af..7e10b5f7a7 100644
--- 
a/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmmFirmwareBootMediaLib.inf
+++ b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmm
+++ FirmwareBootMediaLib.inf
@@ -27,7 +27,6 @@
 #
 
 [Sources]
-  FirmwareBootMediaLib.c
   DxeSmmFirmwareBootMediaLib.c
 
 [Packages]
diff --git 
a/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFirmwareBootMediaLib.inf
 
b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFirmwareBootMediaLib.inf
index 063c4027d3..ff1da31387 100644
--- 
a/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFirmwareBootMediaLib.inf
+++ b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFir
+++ mwareBootMediaLib.inf
@@ -22,7 +22,6 @@
   LIBRARY_CLASS= FirmwareBootMediaLib
 
 [Sources]
-  FirmwareBootMediaLib.c
   PeiFirmwareBootMediaLib.c
 
 [Packages]
diff --git 
a/Silicon/Intel/IntelSiliconPkg/Include/Library/FirmwareBootMediaLib.h 
b/Silicon/Intel/IntelSiliconPkg/Include/Library/FirmwareBootMediaLib.h
index aca9593a84..b36ebacf30 100644
--- a/Silicon/Intel/IntelSiliconPkg/Include/Library/FirmwareBootMediaLib.h
+++ b/Silicon/Intel/IntelSiliconPkg/Include/Library/FirmwareBootMediaLib
+++ .h
@@ -55,52 +55,4 @@ FirmwareBootMediaIsKnown (
   VOID
   );
 
-/**
-  Determines if the platform firmware is booting from SPI.
-
-  @retval TRUEPlatform firmware is booting from SPI
-  @retval FALSE   Platform firmware is booting from a non-SPI device or 
the boot media is unknown
-**/
-BOOLEAN
-EFIAPI
-FirmwareBootMediaIsSpi (
-  VOID
-  );
-
-/**
-  Determines if the platform firmware is booting from UFS.
-
-  @retval TRUEPlatform firmware is booting from UFS
-  @retval FALSE   Platform firmware is booting from a non-UFS device or 
the boot media is unknown
-**/
-BOOLEAN
-EFIAPI
-FirmwareBootMediaIsUfs (
-  VOID
-  );
-
-/**
-  Determines if the platform firmware is booting from eMMC.
-
-  @retval TRUEPlatform firmware is booting from eMMC
-  @retval FALSE   Platform firmware is booting from a non-eMMC device or 
the boot media is unknown
-**/
-BOOLEAN
-EFIAPI
-FirmwareBootMediaIsEmmc (
-  VOID
-  );
-
-/**
-  Determines if the platform firmware is booting from NVMe.
-
-  @retval TRUEPlatform firmware is booting from NVMe.
-  @retval FALSE   Platform firmware is booting from a non-NVMe device or 
the boot media is unknown
-**/
-BOOLEAN
-EFIAPI
-FirmwareBootMediaIsNvme (
-  VOID
-  );
-
 #endif
diff --git 
a/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/FirmwareBootMediaLib.c
 
b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/FirmwareBootMediaLib.c
deleted file mode 100644
index 11a14d172d..00
--- 
a/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/FirmwareBootMediaLib.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/** @file
-  This library identifies the firmware boot media device.
-
-  The firmware boot media device is used to make system initialization 
decisions in the boot flow dependent
-  upon firmware boot media. Note that the firmware boot media is the storage 
media that the boot firmware is stored on.
-  It is not the OS storage media which may be stored upon a different 
non-volatile storage device.
-
-  This file contains library implementation common to all boot phases.
-
-Copyright (c) 2019, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include 

Re: [edk2-devel] [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/BootMediaLib: Reduce library API

2019-10-17 Thread Nate DeSimone
Hi Ray,

This really comes down to a philosophical question of how much do we wish to 
shield the user of the BootMediaLib against the nuances of the library's 
underlying implementation.

The primary function of BootMediaLib is retrieval of state. All of the 
functions in BootMediaLib are accessors: BootMediaIsSpi(), GetBootMediaType(), 
etc. Since the purpose of the library is the manipulation of stateful data, it 
generally is assumed by most programmers that the data accessors themselves are 
stateless. In simpler words, most programmers expect to be able to call the 
BootMediaIsSpi() function without having to consider what the current 
environmental context is of the system.

In your proposal, the programmer must consider if they are writing PEI, DXE, 
SMM, and RuntimeDXE code when using the BootMediaLib. I consider it very 
confusing if I was required to call BootMediaIsSpi() everywhere in PEI, while 
at the same time I was required to only call BootMediaIsSpi() from the entry 
point for SMM or RuntimeDXE drivers. Michael's solution abstracts away this 
complexity and allows a single programming model to be used everywhere.

I agree with Michael that encapsulation of the environmental state is desirable 
especially for code that is used in the implementation of UEFI variable 
services. And I recommend that the code be merged as-is.

Regards,
Nate

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Ni, Ray
Sent: Tuesday, October 15, 2019 11:30 PM
To: Kubacki, Michael A ; devel@edk2.groups.io
Cc: Chaganty, Rangasai V 
Subject: Re: [edk2-devel] [edk2-platforms][PATCH V1 1/1] 
IntelSiliconPkg/BootMediaLib: Reduce library API

> My concerns with that approach:
> 
> 1. In general, I believe it is better if the library reads the value 
> once and caches it. The firmware boot media is fixed after power-on by 
> nature and in some platforms, boot media information may be provided 
> to the IBB in a temporary SRAM (or other volatile memory) early in the 
> boot flow that is temporary (e.g. not accessible after main memory 
> initialization). Here the HOB to global variable transition in DXE, 
> Runtime DXE, SMM is a transparent mechanism to the library consumers 
> to get the boot media information regardless of early boot memory properties.

I just feel that having two library instances increases the complexity.
There were already arguments around EDKII like there are so many instances for 
a library class and people don't know which one is being used.
But if you insist, I am ok with that. Removing unnecessary APIs resolved most 
of my concerns.

> 
> 2. Forcing library consumers to cache puts unnecessary burden on a 
> large number of library consumers to:
>   1.a. Understand the library implementation (lack of encapsulation).

In fact the value of single library instance I can see is caller doesn't need 
to dig into the details of the library implementation. All they need to know is 
the library gets the info from HOB every time the API is called.
With the two lib instances, consumers need to be aware of the different 
implementations.
I am not using this to support my point. Just providing my thought.

>   1.b. Understand the nuances of their driver type in relation to the 
> library implementation.

I think having a single instance avoids DSC writers to supply two instances for 
different modules. Might be different from what you think


>   1.c. Perform this evaluation every time the library is used.

Agree.

>   1.d. Implement overhead to manage the data in a global variable when 
> this could automatically be linked by the library.
Some callers may not be aware of the lib implementation details. So they may 
still choose to cache to global variables.
Some callers may use it only once. Having a lib global variable is also a waste.

> 
> 3. If the HOB is used, it blurs the implementation between the HOB 
> producer phase (PEI) and HOB consumer phase (DXE).

Don't understand.

> 
> We have many libraries with phase-specific instances. When it reduces 
> programming mistakes and eases integration I believe this is 
> beneficial. In this case, I feel the net result for library consumers 
> is better if they simply manage the instance in the DSC as opposed to 
> modifying source in drivers on a case-by-case basis dependent on the library 
> implementation.

If a single instance can support the real needs I tend to use single instances.
It makes the code logic easy to trace. I like the multiple instances idea but 
want to avoid over-using them.

Again I am just providing what I think. They are not here to support my point.
I am ok with current implementation. 

> 
> Thanks,
> Michael
> 
> > -Original Message-
> > From: Ni, Ray 
> > Sent: Monday, October 14, 2019 9:59 PM
> > To: Kubacki, Michael A ; 
> > devel@edk2.groups.io
> > Cc: Chaganty, Rangasai V 
> > Subject: RE: [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/BootMediaLib:
> > Reduce library API
> >
> > Mike,
> > I don't 

Re: [edk2-devel] [Patch v3 10/11] EmulatorPkg: Enable CLANG9 tool chain

2019-10-17 Thread Ni, Ray
Liming,
Emulator is using a generic SEC module. The host specific module is called 
"Host".
So I prefer to change the macro to "WIN_HOST_BUILD", with this change, 
Reviewed-by: Ray Ni 

> -Original Message-
> From: Gao, Liming 
> Sent: Thursday, October 17, 2019 2:56 PM
> To: devel@edk2.groups.io
> Cc: Justen, Jordan L ; Andrew Fish
> ; Ni, Ray 
> Subject: [Patch v3 10/11] EmulatorPkg: Enable CLANG9 tool chain
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603
> 1. Add WIN_SEC_BUILD macro check for CLANG9 tool chain build -p
> EmulatorPkg\EmulatorPkg.dsc -a IA32 -DWIN_SEC_BUILD=TRUE -t CLANG9
> build -p EmulatorPkg\EmulatorPkg.dsc -a X64 -DWIN_SEC_BUILD=TRUE -t
> CLANG9 2. Append CLANG CC and LINK flags to generate windows HOST.
> 3. Fix WinHost issue to call GetProcessAffinityMask() API.
>The input parameter should be UINTN pointer instead of UINT32 pointer.
> 
> Cc: Jordan Justen 
> Cc: Andrew Fish 
> Cc: Ray Ni 
> Signed-off-by: Liming Gao 
> ---
>  EmulatorPkg/Win/Host/WinHost.c   | 6 +++---
>  EmulatorPkg/EmulatorPkg.dsc  | 7 ++-
>  EmulatorPkg/Win/Host/WinHost.inf | 6 ++
>  3 files changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/EmulatorPkg/Win/Host/WinHost.c
> b/EmulatorPkg/Win/Host/WinHost.c index 9aba3c8959..e40ce32548 100644
> --- a/EmulatorPkg/Win/Host/WinHost.c
> +++ b/EmulatorPkg/Win/Host/WinHost.c
> @@ -356,7 +356,7 @@ Returns:
>  INTN
>  EFIAPI
>  main (
> -  IN  INTN  Argc,
> +  IN  INT  Argc,
>IN  CHAR8 **Argv,
>IN  CHAR8 **Envp
>)
> @@ -391,8 +391,8 @@ Returns:
>VOID  *SecFile;
>CHAR16*MemorySizeStr;
>CHAR16*FirmwareVolumesStr;
> -  UINT32ProcessAffinityMask;
> -  UINT32SystemAffinityMask;
> +  UINTN ProcessAffinityMask;
> +  UINTN SystemAffinityMask;
>INT32 LowBit;
> 
>//
> diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
> index 20f1187713..72532f5daf 100644
> --- a/EmulatorPkg/EmulatorPkg.dsc
> +++ b/EmulatorPkg/EmulatorPkg.dsc
> @@ -237,9 +237,10 @@
> 
>  [Components]
>  !if "IA32" in $(ARCH) || "X64" in $(ARCH)
> -  !if "MSFT" in $(FAMILY)
> +  !if "MSFT" in $(FAMILY) || $(WIN_SEC_BUILD) == TRUE
>  ##
>  #  Emulator, OS WIN application
> +#  CLANG9 is cross OS tool chain. It depends on WIN_SEC_BUILD macro.
>  ##
>  EmulatorPkg/Win/Host/WinHost.inf
>!else
> @@ -419,7 +420,11 @@
> 
>MSFT:DEBUG_*_*_CC_FLAGS = /Od /Oy-
>MSFT:NOOPT_*_*_CC_FLAGS = /Od /Oy-
> +  GCC:DEBUG_CLANG9_*_CC_FLAGS =-O0 -Wno-unused-command-line-
> argument
> + -Wno-incompatible-pointer-types -Wno-enum-conversion
> + -Wno-incompatible-pointer-types -Wno-sometimes-uninitialized
> + -Wno-constant-conversion -Wno-main-return-type
> 
>MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096 /FILEALIGN:4096
> /SUBSYSTEM:CONSOLE
>MSFT:DEBUG_*_*_DLINK_FLAGS =
> /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x1
>MSFT:NOOPT_*_*_DLINK_FLAGS =
> /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x1
> +  GCC:*_CLANG9_*_DLINK_FLAGS = /ALIGN:4096 /FILEALIGN:4096
> /SUBSYSTEM:CONSOLE
> +  GCC:DEBUG_CLANG9_*_DLINK_FLAGS =
> + /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x1
> + GCC:NOOPT_CLANG9_*_DLINK_FLAGS =
> + /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x1
> diff --git a/EmulatorPkg/Win/Host/WinHost.inf
> b/EmulatorPkg/Win/Host/WinHost.inf
> index 631d5a6470..1adca10d79 100644
> --- a/EmulatorPkg/Win/Host/WinHost.inf
> +++ b/EmulatorPkg/Win/Host/WinHost.inf
> @@ -95,3 +95,9 @@
>MSFT:*_VS2017_X64_DLINK_FLAGS  =
> /LIBPATH:"%VCToolsInstallDir%lib\x64"
> /LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64"
> /LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x64"
> /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP
> /OPT:REF /DEBUG /MACHINE:AMD64 /LTCG Kernel32.lib MSVCRTD.lib
> vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib
>MSFT:*_*_X64_ASM_FLAGS== /nologo /W3 /WX /c /Cx /Zd /W0 /Zi
>MSFT:*_*_X64_ASMLINK_FLAGS== /link /nologo
> +
> +  GCC:*_CLANG9_X64_DLINK_FLAGS ==
> /out:"$(BIN_DIR)\$(BASE_NAME).exe" /base:0x1000
> /pdb:"$(BIN_DIR)\$(BASE_NAME).pdb"
> /LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64"
> /LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x64"
> /LIBPATH:"%VCToolsInstallDir%lib\x64"   /NOLOGO /SUBSYSTEM:CONSOLE
> /NODEFAULTLIB /IGNORE:4086  /OPT:REF /DEBUG /MACHINE:AMD64
> Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib
> Winmm.lib Advapi32.lib /lldmap
> /EXPORT:InitializeDriver=_ModuleEntryPoint
> +  GCC:*_CLANG9_X64_CC_FLAGS == -m64 -g -fshort-wchar
> + -fno-strict-aliasing -Wall -c -include AutoGen.h -D
> + _CRT_SECURE_NO_WARNINGS -Wnonportable-include-path  -D UNICODE
> -D
> + _CRT_SECURE_NO_DEPRECATE
> +
> +  GCC:*_CLANG9_IA32_DLINK_FLAGS ==
> /out:"$(BIN_DIR)\$(BASE_NAME).exe" /base:0x1000
> 

[edk2-devel] [Patch v3 08/11] CryptoPkg: Append options to make CLANG9 tool chain pass build

2019-10-17 Thread Liming Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603
Disable warning reported from CLANG9.

Signed-off-by: Liming Gao 
Reviewed-by: Jian J Wang 
---
 CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf| 1 +
 CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf | 1 +
 CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf | 1 +
 CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf | 1 +
 CryptoPkg/Library/OpensslLib/OpensslLib.inf| 1 +
 CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf  | 1 +
 6 files changed, 6 insertions(+)

diff --git a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
index 8d4988e8c6..a98be2cd95 100644
--- a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
@@ -101,5 +101,6 @@
 
   GCC:*_CLANG35_*_CC_FLAGS = -std=c99
   GCC:*_CLANG38_*_CC_FLAGS = -std=c99
+  GCC:*_CLANG9_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
 
   XCODE:*_*_*_CC_FLAGS = -std=c99
diff --git a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
index 3da8bd8480..7b07dd13d2 100644
--- a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
@@ -96,5 +96,6 @@
 
   GCC:*_CLANG35_*_CC_FLAGS = -std=c99
   GCC:*_CLANG38_*_CC_FLAGS = -std=c99
+  GCC:*_CLANG9_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
 
   XCODE:*_*_*_CC_FLAGS = -std=c99
diff --git a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
index 21a481eb77..d9e29ef660 100644
--- a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
@@ -107,5 +107,6 @@
 
   GCC:*_CLANG35_*_CC_FLAGS = -std=c99
   GCC:*_CLANG38_*_CC_FLAGS = -std=c99
+  GCC:*_CLANG9_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
 
   XCODE:*_*_*_CC_FLAGS = -std=c99
diff --git a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
index 7c187e21b3..b4faaf3f80 100644
--- a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
@@ -104,3 +104,4 @@
 
   GCC:*_CLANG35_*_CC_FLAGS = -std=c99
   GCC:*_CLANG38_*_CC_FLAGS = -std=c99
+  GCC:*_CLANG9_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
diff --git a/CryptoPkg/Library/OpensslLib/OpensslLib.inf 
b/CryptoPkg/Library/OpensslLib/OpensslLib.inf
index 7432321fd4..b40d82783b 100644
--- a/CryptoPkg/Library/OpensslLib/OpensslLib.inf
+++ b/CryptoPkg/Library/OpensslLib/OpensslLib.inf
@@ -662,6 +662,7 @@
   GCC:*_*_AARCH64_CC_FLAGS = $(OPENSSL_FLAGS) -Wno-error=maybe-uninitialized 
-Wno-format -Wno-error=unused-but-set-variable
   GCC:*_CLANG35_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized
   GCC:*_CLANG38_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized
+  GCC:*_CLANG9_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized 
-Wno-error=incompatible-pointer-types -Wno-error=pointer-sign 
-Wno-error=implicit-function-declaration -Wno-error=ignored-pragma-optimize
 
   # suppress the following warnings in openssl so we don't break the build 
with warnings-as-errors:
   # 1295: Deprecated declaration  - give arg types
diff --git a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf 
b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
index 8134b45eda..0a60196c8a 100644
--- a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
+++ b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
@@ -610,6 +610,7 @@
   GCC:*_*_AARCH64_CC_FLAGS = $(OPENSSL_FLAGS) -Wno-error=maybe-uninitialized 
-Wno-format -Wno-error=unused-but-set-variable
   GCC:*_CLANG35_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized
   GCC:*_CLANG38_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized
+  GCC:*_CLANG9_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized 
-Wno-error=incompatible-pointer-types -Wno-error=pointer-sign 
-Wno-error=implicit-function-declaration -Wno-error=ignored-pragma-optimize
 
   # suppress the following warnings in openssl so we don't break the build 
with warnings-as-errors:
   # 1295: Deprecated declaration  - give arg types
-- 
2.13.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49165): https://edk2.groups.io/g/devel/message/49165
Mute This Topic: https://groups.io/mt/34694466/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch v3 04/11] MdePkg Base.h: Add definition for CLANG9 tool chain

2019-10-17 Thread Liming Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603
CLANG9 tool chain defines __clang__ macro only,
doesn't define __GNUC__ macro. But, it uses some same definitions with GCC.
So, update base definition for CLANG9 tool chain.

Signed-off-by: Liming Gao 
Cc: Michael Kinney 
Reviewed-by: Philippe Mathieu-Daude 
---
 MdePkg/Include/Base.h   | 6 +++---
 MdePkg/Include/Ia32/ProcessorBind.h | 4 ++--
 MdePkg/Include/X64/ProcessorBind.h  | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
index d94b8a5f93..4680e64136 100644
--- a/MdePkg/Include/Base.h
+++ b/MdePkg/Include/Base.h
@@ -621,9 +621,9 @@ typedef char* VA_LIST;
 #define VA_END(Marker)  (Marker = (VA_LIST) 0)
 #define VA_COPY(Dest, Start)((void)((Dest) = (Start)))
 
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) || defined(__clang__)
 
-#if defined(MDE_CPU_X64) && !defined(NO_MSABI_VA_FUNCS)
+#if defined(MDE_CPU_X64) && !defined(NO_MSABI_VA_FUNCS) && !defined(__clang__)
 //
 // X64 only. Use MS ABI version of GCC built-in macros for variable argument 
lists.
 //
@@ -1274,7 +1274,7 @@ typedef UINTN RETURN_STATUS;
 
   **/
   #define RETURN_ADDRESS(L) ((L == 0) ? _ReturnAddress() : (VOID *) 0)
-#elif defined(__GNUC__)
+#elif defined (__GNUC__) || defined (__clang__)
   void * __builtin_return_address (unsigned int level);
   /**
 Get the return address of the calling function.
diff --git a/MdePkg/Include/Ia32/ProcessorBind.h 
b/MdePkg/Include/Ia32/ProcessorBind.h
index 497c58b33b..fa4b7e8e98 100644
--- a/MdePkg/Include/Ia32/ProcessorBind.h
+++ b/MdePkg/Include/Ia32/ProcessorBind.h
@@ -281,7 +281,7 @@ typedef INT32   INTN;
   /// Microsoft* compiler specific method for EFIAPI calling convention.
   ///
   #define EFIAPI __cdecl
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) || defined(__clang__)
   ///
   /// GCC specific method for EFIAPI calling convention.
   ///
@@ -294,7 +294,7 @@ typedef INT32   INTN;
   #define EFIAPI
 #endif
 
-#if defined(__GNUC__)
+#if defined(__GNUC__) || defined(__clang__)
   ///
   /// For GNU assembly code, .global or .globl can declare global symbols.
   /// Define this macro to unify the usage.
diff --git a/MdePkg/Include/X64/ProcessorBind.h 
b/MdePkg/Include/X64/ProcessorBind.h
index 6f65acd609..387e9c5c9c 100644
--- a/MdePkg/Include/X64/ProcessorBind.h
+++ b/MdePkg/Include/X64/ProcessorBind.h
@@ -313,7 +313,7 @@ typedef INT64   INTN;
   #define EFIAPI
 #endif
 
-#if defined(__GNUC__)
+#if defined(__GNUC__) || defined(__clang__)
   ///
   /// For GNU assembly code, .global or .globl can declare global symbols.
   /// Define this macro to unify the usage.
-- 
2.13.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49161): https://edk2.groups.io/g/devel/message/49161
Mute This Topic: https://groups.io/mt/34694443/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch v3 10/11] EmulatorPkg: Enable CLANG9 tool chain

2019-10-17 Thread Liming Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603
1. Add WIN_SEC_BUILD macro check for CLANG9 tool chain
build -p EmulatorPkg\EmulatorPkg.dsc -a IA32 -DWIN_SEC_BUILD=TRUE -t CLANG9
build -p EmulatorPkg\EmulatorPkg.dsc -a X64 -DWIN_SEC_BUILD=TRUE -t CLANG9
2. Append CLANG CC and LINK flags to generate windows HOST.
3. Fix WinHost issue to call GetProcessAffinityMask() API.
   The input parameter should be UINTN pointer instead of UINT32 pointer.

Cc: Jordan Justen 
Cc: Andrew Fish 
Cc: Ray Ni 
Signed-off-by: Liming Gao 
---
 EmulatorPkg/Win/Host/WinHost.c   | 6 +++---
 EmulatorPkg/EmulatorPkg.dsc  | 7 ++-
 EmulatorPkg/Win/Host/WinHost.inf | 6 ++
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c
index 9aba3c8959..e40ce32548 100644
--- a/EmulatorPkg/Win/Host/WinHost.c
+++ b/EmulatorPkg/Win/Host/WinHost.c
@@ -356,7 +356,7 @@ Returns:
 INTN
 EFIAPI
 main (
-  IN  INTN  Argc,
+  IN  INT  Argc,
   IN  CHAR8 **Argv,
   IN  CHAR8 **Envp
   )
@@ -391,8 +391,8 @@ Returns:
   VOID  *SecFile;
   CHAR16*MemorySizeStr;
   CHAR16*FirmwareVolumesStr;
-  UINT32ProcessAffinityMask;
-  UINT32SystemAffinityMask;
+  UINTN ProcessAffinityMask;
+  UINTN SystemAffinityMask;
   INT32 LowBit;
 
   //
diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index 20f1187713..72532f5daf 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -237,9 +237,10 @@
 
 [Components]
 !if "IA32" in $(ARCH) || "X64" in $(ARCH)
-  !if "MSFT" in $(FAMILY)
+  !if "MSFT" in $(FAMILY) || $(WIN_SEC_BUILD) == TRUE
 ##
 #  Emulator, OS WIN application
+#  CLANG9 is cross OS tool chain. It depends on WIN_SEC_BUILD macro.
 ##
 EmulatorPkg/Win/Host/WinHost.inf
   !else
@@ -419,7 +420,11 @@
 
   MSFT:DEBUG_*_*_CC_FLAGS = /Od /Oy-
   MSFT:NOOPT_*_*_CC_FLAGS = /Od /Oy-
+  GCC:DEBUG_CLANG9_*_CC_FLAGS =-O0 -Wno-unused-command-line-argument 
-Wno-incompatible-pointer-types -Wno-enum-conversion 
-Wno-incompatible-pointer-types -Wno-sometimes-uninitialized 
-Wno-constant-conversion -Wno-main-return-type
 
   MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096 /FILEALIGN:4096 /SUBSYSTEM:CONSOLE
   MSFT:DEBUG_*_*_DLINK_FLAGS = /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) 
/BASE:0x1
   MSFT:NOOPT_*_*_DLINK_FLAGS = /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) 
/BASE:0x1
+  GCC:*_CLANG9_*_DLINK_FLAGS = /ALIGN:4096 /FILEALIGN:4096 
/SUBSYSTEM:CONSOLE
+  GCC:DEBUG_CLANG9_*_DLINK_FLAGS = 
/EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x1
+  GCC:NOOPT_CLANG9_*_DLINK_FLAGS = 
/EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x1
diff --git a/EmulatorPkg/Win/Host/WinHost.inf b/EmulatorPkg/Win/Host/WinHost.inf
index 631d5a6470..1adca10d79 100644
--- a/EmulatorPkg/Win/Host/WinHost.inf
+++ b/EmulatorPkg/Win/Host/WinHost.inf
@@ -95,3 +95,9 @@
   MSFT:*_VS2017_X64_DLINK_FLAGS  = /LIBPATH:"%VCToolsInstallDir%lib\x64" 
/LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64" 
/LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x64" /NOLOGO 
/SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG 
/MACHINE:AMD64 /LTCG Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib 
Gdi32.lib User32.lib Winmm.lib Advapi32.lib
   MSFT:*_*_X64_ASM_FLAGS== /nologo /W3 /WX /c /Cx /Zd /W0 /Zi
   MSFT:*_*_X64_ASMLINK_FLAGS== /link /nologo
+
+  GCC:*_CLANG9_X64_DLINK_FLAGS == /out:"$(BIN_DIR)\$(BASE_NAME).exe" 
/base:0x1000 /pdb:"$(BIN_DIR)\$(BASE_NAME).pdb"  
/LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64" 
/LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x64" 
/LIBPATH:"%VCToolsInstallDir%lib\x64"   /NOLOGO /SUBSYSTEM:CONSOLE 
/NODEFAULTLIB /IGNORE:4086  /OPT:REF /DEBUG /MACHINE:AMD64 Kernel32.lib 
MSVCRTD.lib vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib Winmm.lib 
Advapi32.lib /lldmap  /EXPORT:InitializeDriver=_ModuleEntryPoint
+  GCC:*_CLANG9_X64_CC_FLAGS == -m64 -g -fshort-wchar -fno-strict-aliasing 
-Wall -c -include AutoGen.h -D _CRT_SECURE_NO_WARNINGS 
-Wnonportable-include-path  -D UNICODE -D _CRT_SECURE_NO_DEPRECATE
+
+  GCC:*_CLANG9_IA32_DLINK_FLAGS == /out:"$(BIN_DIR)\$(BASE_NAME).exe" 
/base:0x1000 /pdb:"$(BIN_DIR)\$(BASE_NAME).pdb" 
/LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x86" 
/LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x86" 
/LIBPATH:"%VCToolsInstallDir%ib\x86"   /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB 
/IGNORE:4086  /OPT:REF /DEBUG /MACHINE:I386 Kernel32.lib MSVCRTD.lib 
vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib /lldmap  
/EXPORT:InitializeDriver=_ModuleEntryPoint
+  GCC:*_CLANG9_IA32_CC_FLAGS == -m32 -g -fshort-wchar -fno-strict-aliasing 
-Wall -c -include AutoGen.h -D _CRT_SECURE_NO_WARNINGS 
-Wnonportable-include-path  -D UNICODE -D _CRT_SECURE_NO_DEPRECATE
-- 

[edk2-devel] [Patch v3 05/11] MdePkg BaseIoLibIntrinsic: Remove __inline__ attribute for IO functions

2019-10-17 Thread Liming Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603
__inline__ has no functional difference effect with the GCC48 / GCC49 / GCC5
toolchains, but it breaks the build with CLANG9. Remove __inline__.

Signed-off-by: Liming Gao 
Acked-by: Laszlo Ersek 
Cc: Michael Kinney 
Reviewed-by: Philippe Mathieu-Daude 
---
 MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c 
b/MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c
index 055f0a947e..b3a1a20256 100644
--- a/MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c
+++ b/MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c
@@ -32,7 +32,6 @@
   @return The value read.
 
 **/
-__inline__
 UINT8
 EFIAPI
 IoRead8 (
@@ -60,7 +59,6 @@ IoRead8 (
   @return The value written the I/O port.
 
 **/
-__inline__
 UINT8
 EFIAPI
 IoWrite8 (
@@ -87,7 +85,6 @@ IoWrite8 (
   @return The value read.
 
 **/
-__inline__
 UINT16
 EFIAPI
 IoRead16 (
@@ -117,7 +114,6 @@ IoRead16 (
   @return The value written the I/O port.
 
 **/
-__inline__
 UINT16
 EFIAPI
 IoWrite16 (
@@ -145,7 +141,6 @@ IoWrite16 (
   @return The value read.
 
 **/
-__inline__
 UINT32
 EFIAPI
 IoRead32 (
@@ -175,7 +170,6 @@ IoRead32 (
   @return The value written the I/O port.
 
 **/
-__inline__
 UINT32
 EFIAPI
 IoWrite32 (
-- 
2.13.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49162): https://edk2.groups.io/g/devel/message/49162
Mute This Topic: https://groups.io/mt/34694448/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch v3 01/11] BaseTools tools_def.template: Remove unnecessary $(DEST_DIR_DEBUG) path

2019-10-17 Thread Liming Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603
$(DEST_DIR_DEBUG) path is in Include directory.
It is not required to be specified again.

Signed-off-by: Liming Gao 
Reviewed-by: Bob Feng 
---
 BaseTools/Conf/tools_def.template | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index 88a6764f43..fd6fca542d 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -350,8 +350,8 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
 # *_*_EBC_SLINK_PATH = C:\Program Files\Intel\EBC\Bin\link.exe
 #
 # *_*_EBC_SLINK_FLAGS= /lib /NOLOGO /MACHINE:EBC
-# *_*_EBC_PP_FLAGS   = /nologo /E /TC 
/FI$(DEST_DIR_DEBUG)/AutoGen.h
-# *_*_EBC_CC_FLAGS   = /nologo /FAcs /c /W3 /WX 
/FI$(DEST_DIR_DEBUG)/AutoGen.h
+# *_*_EBC_PP_FLAGS   = /nologo /E /TC /FIAutoGen.h
+# *_*_EBC_CC_FLAGS   = /nologo /FAcs /c /W3 /WX /FIAutoGen.h
 # *_*_EBC_DLINK_FLAGS= "C:\Program 
Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /MACHINE:EBC /OPT:REF /NODEFAULTLIB 
/ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /ALIGN:32 /DRIVER
 #
 

@@ -1906,13 +1906,13 @@ DEFINE GCC_IA32_X64_ASLDLINK_FLAGS = 
DEF(GCC_IA32_X64_DLINK_COMMON) --entry _Ref
 DEFINE GCC_ARM_ASLDLINK_FLAGS  = DEF(GCC_ARM_DLINK_FLAGS) 
-Wl,--entry,ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT) 
DEF(GCC_ARM_AARCH64_ASLDLINK_FLAGS)
 DEFINE GCC_AARCH64_ASLDLINK_FLAGS  = DEF(GCC_AARCH64_DLINK_FLAGS) 
-Wl,--entry,ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT) 
DEF(GCC_ARM_AARCH64_ASLDLINK_FLAGS)
 DEFINE GCC_IA32_X64_DLINK_FLAGS= DEF(GCC_IA32_X64_DLINK_COMMON) --entry 
_$(IMAGE_ENTRY_POINT) --file-alignment 0x20 --section-alignment 0x20 -Map 
$(DEST_DIR_DEBUG)/$(BASE_NAME).map
-DEFINE GCC_ASM_FLAGS   = -c -x assembler -imacros 
$(DEST_DIR_DEBUG)/AutoGen.h
-DEFINE GCC_PP_FLAGS= -E -x assembler-with-cpp -include 
$(DEST_DIR_DEBUG)/AutoGen.h
-DEFINE GCC_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE --include 
$(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
+DEFINE GCC_ASM_FLAGS   = -c -x assembler -imacros AutoGen.h
+DEFINE GCC_PP_FLAGS= -E -x assembler-with-cpp -include 
AutoGen.h
+DEFINE GCC_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE --include 
$(MODULE_NAME)StrDefs.h
 DEFINE GCC_ASLPP_FLAGS = -x c -E -include AutoGen.h
 DEFINE GCC_ASLCC_FLAGS = -x c
 DEFINE GCC_WINDRES_FLAGS   = -J rc -O coff
-DEFINE GCC_DTCPP_FLAGS = -E -x assembler-with-cpp -imacros 
$(DEST_DIR_DEBUG)/AutoGen.h -nostdinc -undef
+DEFINE GCC_DTCPP_FLAGS = -E -x assembler-with-cpp -imacros 
AutoGen.h -nostdinc -undef
 DEFINE GCC_IA32_RC_FLAGS   = -I binary -O elf32-i386  -B i386  
  --rename-section .data=.hii
 DEFINE GCC_X64_RC_FLAGS= -I binary -O elf64-x86-64-B i386  
  --rename-section .data=.hii
 DEFINE GCC_ARM_RC_FLAGS= -I binary -O elf32-littlearm -B arm   
  --rename-section .data=.hii
@@ -2772,8 +2772,8 @@ RELEASE_XCODE5_X64_DLINK_FLAGS  = -arch x86_64 -u 
_$(IMAGE_ENTRY_POINT) -e _
   NOOPT_XCODE5_X64_ASM_FLAGS  = -arch x86_64 -g
 RELEASE_XCODE5_X64_ASM_FLAGS  = -arch x86_64
   *_XCODE5_X64_NASM_FLAGS = -f macho64
-*_XCODE5_*_PP_FLAGS = -E -x assembler-with-cpp -include 
$(DEST_DIR_DEBUG)/AutoGen.h
-*_XCODE5_*_VFRPP_FLAGS  = -x c -E -P -DVFRCOMPILE -include 
$(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
+*_XCODE5_*_PP_FLAGS = -E -x assembler-with-cpp -include AutoGen.h
+*_XCODE5_*_VFRPP_FLAGS  = -x c -E -P -DVFRCOMPILE -include 
$(MODULE_NAME)StrDefs.h
 
   DEBUG_XCODE5_X64_CC_FLAGS   = -target x86_64-pc-win32-macho -c -g -gdwarf 
-Os   -Wall -Werror -Wextra -include AutoGen.h -funsigned-char 
-fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar 
-mno-implicit-float -mms-bitfields -Wno-unused-parameter -Wno-missing-braces 
-Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare 
-Wno-varargs 
-ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D 
NO_MSABI_VA_FUNCS $(PLATFORM_FLAGS)
   NOOPT_XCODE5_X64_CC_FLAGS   = -target x86_64-pc-win32-macho -c -g -gdwarf 
-O0   -Wall -Werror -Wextra -include AutoGen.h -funsigned-char 
-fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar 
-mno-implicit-float -mms-bitfields -Wno-unused-parameter -Wno-missing-braces 
-Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare 
-Wno-varargs 
-ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D 
NO_MSABI_VA_FUNCS $(PLATFORM_FLAGS)
@@ -2812,7 +2812,7 @@ RELEASE_RVCT_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) 
DEF(RVCT_ALL_DLINK_FLAGS)
 
 *_RVCT_ARM_ASM_FLAGS   = $(ARCHASM_FLAGS) 

[edk2-devel] [Patch v3 03/11] BaseTools GenFw: Fix the issue to update the wrong size as SectionSize

2019-10-17 Thread Liming Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603
CLANG9 generated PE image exposes below two issues.
1. SectionSize is used to copy PE section data. It should be smaller than
section raw size.
2. The real data is required to be copied. So, copy the min size of
VirtualSize and SizeOfRawData.

Signed-off-by: Liming Gao 
Cc: Bob Feng 
Reviewed-by: Philippe Mathieu-Daude 
---
 BaseTools/Source/C/GenFw/GenFw.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c
index c99782b78e..8cab70ba4d 100644
--- a/BaseTools/Source/C/GenFw/GenFw.c
+++ b/BaseTools/Source/C/GenFw/GenFw.c
@@ -653,7 +653,11 @@ PeCoffConvertImageToXip (
 //
 // Make the size of raw data in section header alignment.
 //
-SectionHeader->SizeOfRawData = (SectionHeader->Misc.VirtualSize + 
PeHdr->Pe32.OptionalHeader.FileAlignment - 1) & 
(~(PeHdr->Pe32.OptionalHeader.FileAlignment - 1));
+SectionSize = (SectionHeader->Misc.VirtualSize + 
PeHdr->Pe32.OptionalHeader.FileAlignment - 1) & 
(~(PeHdr->Pe32.OptionalHeader.FileAlignment - 1));
+if (SectionSize < SectionHeader->SizeOfRawData) {
+  SectionHeader->SizeOfRawData = SectionSize;
+}
+
 SectionHeader->PointerToRawData = SectionHeader->VirtualAddress;
   }
 
@@ -999,7 +1003,7 @@ Returns:
 CopyMem (
   FileBuffer + SectionHeader->PointerToRawData,
   (VOID*) (UINTN) (ImageContext.ImageAddress + 
SectionHeader->VirtualAddress),
-  SectionHeader->SizeOfRawData
+  SectionHeader->SizeOfRawData < SectionHeader->Misc.VirtualSize ? 
SectionHeader->SizeOfRawData : SectionHeader->Misc.VirtualSize
   );
   }
 
-- 
2.13.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49160): https://edk2.groups.io/g/devel/message/49160
Mute This Topic: https://groups.io/mt/34694437/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms] [PATCH v2 4/4] Platform/Intel: Add FIT generation tool

2019-10-17 Thread Nate DeSimone
Reviewed-by: Nate DeSimone 

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Agyeman, Prince
Sent: Tuesday, October 15, 2019 3:51 PM
To: devel@edk2.groups.io
Cc: Sinha, Ankit ; Desimone, Nathaniel L 
; Kubacki, Michael A 

Subject: [edk2-devel] [edk2-platforms] [PATCH v2 4/4] Platform/Intel: Add FIT 
generation tool

Added FitGen tool build and FIT generation to the BIOS build process.

What was done:

- Build the FIT generation tool
- Added default/empty BIOS_INFO_GUID to the build.cfg
- Added BIOS_INFO_GUID to GalagoPro3,KabylakeRvp3 and WhiskeylakeURvp's 
build_config.cfg This allows a board to specify the GUID associated with the 
BIOS Info PEIM to be used in the board's FIT generation.

BIOS_INFO_GUID is passed as an argument to FitGen tool which allow the tool to 
locate the BIOS Info module to be used in FIT generation.

Cc: Ankit Sinha 
Cc: Nate DeSimone 
Cc: Michael Kubacki 

Signed-off-by: Prince Agyeman 
---
 .../GalagoPro3/build_config.cfg   |  1 +
 .../KabylakeRvp3/build_config.cfg |  1 +
 .../WhiskeylakeURvp/build_config.cfg  |  1 +
 Platform/Intel/build.cfg  |  1 +
 Platform/Intel/build_bios.py  | 57 +++
 5 files changed, 61 insertions(+)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/build_config.cfg 
b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/build_config.cfg
index 8c6c51abb4..458fe3d35d 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/build_config.cfg
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/build_config.cfg
@@ -31,3 +31,4 @@ FSP_PKG_NAME = KabylakeFspPkg  FSP_BINARY_BUILD = FALSE  
FSP_TEST_RELEASE = FALSE  SECURE_BOOT_ENABLE = FALSE
+BIOS_INFO_GUID = C83BCE0E-6F16-4D3C-8D9F-4D6F5A032929
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/build_config.cfg 
b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/build_config.cfg
index 78f808bfaf..f6ae4b342a 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/build_config.cfg
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/build_config.cfg
@@ -33,3 +33,4 @@ FSP_PKG_NAME = AmberLakeFspPkg  FSP_BINARY_BUILD = FALSE  
FSP_TEST_RELEASE = FALSE  SECURE_BOOT_ENABLE = FALSE
+BIOS_INFO_GUID = C83BCE0E-6F16-4D3C-8D9F-4D6F5A032929
diff --git 
a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/build_config.cfg 
b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/build_config.cfg
index 1b0619bc1c..1dfe5ffd10 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/build_config.cfg
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/build_confi
+++ g.cfg
@@ -31,3 +31,4 @@ FSP_PKG_NAME = CoffeelakeSiliconPkg  FSP_BINARY_BUILD = FALSE 
 FSP_TEST_RELEASE = FALSE  SECURE_BOOT_ENABLE = FALSE
+BIOS_INFO_GUID = A842B2D2-5C88-44E9-A9E2-4830F26662B7
diff --git a/Platform/Intel/build.cfg b/Platform/Intel/build.cfg index 
2040774d1b..6aee96694c 100644
--- a/Platform/Intel/build.cfg
+++ b/Platform/Intel/build.cfg
@@ -48,6 +48,7 @@ SECURE_BOOT_ENABLE = FALSE  REBUILD_MODE =  BUILD_ROM_ONLY =  
NUMBER_OF_PROCESSORS = 0
+BIOS_INFO_GUID =
 
 
 [PLATFORMS]
diff --git a/Platform/Intel/build_bios.py b/Platform/Intel/build_bios.py index 
46285df19a..ea098de705 100644
--- a/Platform/Intel/build_bios.py
+++ b/Platform/Intel/build_bios.py
@@ -196,6 +196,31 @@ def pre_build(build_config, build_type="DEBUG", 
silent=False, toolchain=None):
 if return_code != 0:
 build_failed(config)
 
+#
+# build platform silicon tools
+#
+# save the current workspace
+saved_work_directory = config["WORKSPACE"]
+# change the workspace to silicon tools directory
+config["WORKSPACE"] = os.path.join(config["WORKSPACE_SILICON"], 
+ "Tools")
+
+command = ["nmake"]
+if os.name == "posix":  # linux
+command = ["make"]
+# add path to generated FitGen binary to
+# environment path variable
+config["PATH"] += os.pathsep + \
+  os.path.join(config["BASE_TOOLS_PATH"],
+   "Source", "C", "bin")
+
+# build the silicon tools
+_, _, result, return_code = execute_script(command, config, shell=shell)
+if return_code != 0:
+build_failed(config)
+
+# restore WORKSPACE environment variable
+config["WORKSPACE"] = saved_work_directory
+
 config["SILENT_MODE"] = 'TRUE' if silent else 'FALSE'
 
 print("==")
@@ -404,6 +429,35 @@ def post_build(config):
 :returns: nothing
 """
 print("Running post_build to complete the build process.")
+board_fd = config["BOARD"].upper()
+final_fd = os.path.join(config["BUILD_DIR_PATH"], "FV",
+"{}.fd".format(board_fd))
+
+if config["BIOS_INFO_GUID"]:
+# Generate the fit table
+print("Generating FIT ...")
+if os.path.isfile(final_fd):
+temp_fd = os.path.join(config["BUILD_DIR_PATH"], 

Re: [edk2-devel] [edk2-platforms] [PATCH v2 1/4] BoardModulePkg: Add BIOS Info HOB

2019-10-17 Thread Nate DeSimone
Reviewed-by: Nate DeSimone 

-Original Message-
From: Agyeman, Prince  
Sent: Tuesday, October 15, 2019 3:51 PM
To: devel@edk2.groups.io
Cc: Sinha, Ankit ; Desimone, Nathaniel L 
; Kubacki, Michael A 

Subject: [edk2-platforms] [PATCH v2 1/4] BoardModulePkg: Add BIOS Info HOB

Added gBiosInfoGuid to be used in
publishing the BIOS information HOB
which is needed in FIT generation

Also added the BIOS Info header
file BiosInfo.h that defines the
BIOS info struct and GUID

Cc: Ankit Sinha 
Cc: Nate DeSimone 
Cc: Kubacki Michael A 

Signed-off-by: Prince Agyeman 
---
 .../Intel/BoardModulePkg/BoardModulePkg.dec   |  3 +
 .../BoardModulePkg/Include/Guid/BiosInfo.h| 61 +++
 2 files changed, 64 insertions(+)
 create mode 100644 Platform/Intel/BoardModulePkg/Include/Guid/BiosInfo.h

diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dec 
b/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
index f96fb09aa1..f461cc7cab 100644
--- a/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
+++ b/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
@@ -39,3 +39,6 @@
 [Guids]
   ## Include Include/Guid/BiosId.h
   gBiosIdGuid = { 0xC3E36D09, 0x8294, 0x4b97, { 0xA8, 0x57, 0xD5, 0x28, 0x8F, 
0xE3, 0x3E, 0x28 } }
+
+  ## GUID to publish BIOS information HOB  gBiosInfoGuid = { 
+ 0x09d0d15c, 0xe9f0, 0x4dfc, {0x9e, 0x0b, 0x39, 0x33, 0x1f, 0xca, 0x66, 
+ 0x85} }
diff --git a/Platform/Intel/BoardModulePkg/Include/Guid/BiosInfo.h 
b/Platform/Intel/BoardModulePkg/Include/Guid/BiosInfo.h
new file mode 100644
index 00..d73409ea6f
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/Include/Guid/BiosInfo.h
@@ -0,0 +1,61 @@
+/** @file
+  Definitions and GUID for BIOS INFO.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent **/
+
+#ifndef _BIOS_INFO_H_
+#define _BIOS_INFO_H_
+
+//
+// BIOS INFO data structure
+// This is self contained data structure for BIOS info for TXT // 
+#pragma pack (1) #define BIOS_INFO_SIGNATURE  SIGNATURE_64 ('$', 'B', 
+'I', 'O', 'S', 'I', 'F', '$') typedef struct {
+  UINT64Signature;
+  UINT32EntryCount;
+  UINT32Reserved;
+//BIOS_INFO_STRUCT  Struct[EntryCount]; } BIOS_INFO_HEADER;
+
+//
+// BIOS_INFO_STRUCT attributes
+// bits[0:3] means general attributes
+// bits[4:7] means type specific attributes // #define 
+BIOS_INFO_STRUCT_ATTRIBUTE_GENERAL_EXCLUDE_FROM_FIT  0x01
+#define BIOS_INFO_STRUCT_ATTRIBUTE_MICROCODE_WHOLE_REGION0x10
+#define BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB 0x10
+#define BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_NON_IBB  0x20
+
+typedef struct {
+  //
+  // FitTable entry type
+  //
+  UINT8Type;
+  //
+  // BIOS_INFO_STRUCT attributes
+  //
+  UINT8Attributes;
+  //
+  // FitTable entry version
+  //
+  UINT16   Version;
+  //
+  // FitTable entry real size
+  //
+  UINT32   Size;
+  //
+  // FitTable entry address
+  //
+  UINT64   Address;
+} BIOS_INFO_STRUCT;
+
+extern EFI_GUID  gBiosInfoGuid;
+
+#pragma pack ()
+
+#endif
--
2.19.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49155): https://edk2.groups.io/g/devel/message/49155
Mute This Topic: https://groups.io/mt/34551481/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch v3 06/11] MdeModulePkg LzmaCustomDecompressLib: Update macro to be same in CLANG tool

2019-10-17 Thread Liming Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603
Define the same macro in the different OS. It can make CLANG generate the same
image in the different host OS.

Signed-off-by: Liming Gao 
Reviewed-by: Hao A Wu 
---
 MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zTypes.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zTypes.h 
b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zTypes.h
index ac06278002..c89b5c2433 100644
--- a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zTypes.h
+++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zTypes.h
@@ -118,7 +118,7 @@ typedef int Bool;
 #define MY_STD_CALL
 #endif
 
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && !defined(__clang__)
 
 #if _MSC_VER >= 1300
 #define MY_NO_INLINE __declspec(noinline)
-- 
2.13.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49163): https://edk2.groups.io/g/devel/message/49163
Mute This Topic: https://groups.io/mt/34694453/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch v3 02/11] BaseTools tools_def: Add CLANG9 tool chain to directly generate PE image

2019-10-17 Thread Liming Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603

Signed-off-by: Liming Gao 
Cc: Bob Feng 
---
 BaseTools/Conf/build_rule.template |  26 ++
 BaseTools/Conf/tools_def.template  | 102 +
 2 files changed, 118 insertions(+), 10 deletions(-)

diff --git a/BaseTools/Conf/build_rule.template 
b/BaseTools/Conf/build_rule.template
index db06d3a6b4..3a58ac8015 100755
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -260,7 +260,7 @@
 
 $(OUTPUT_DIR)(+)$(MODULE_NAME).lib
 
-
+
 "$(SLINK)" $(SLINK_FLAGS) /OUT:${dst} @$(OBJECT_FILES_LIST)
 
 
@@ -291,6 +291,9 @@
 "$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK2_FLAGS) $(DLINK_SPATH) 
@$(STATIC_LIBRARY_FILES_LIST)
 "$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK_SPATH) 
@$(STATIC_LIBRARY_FILES_LIST)
 
+
+"$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK_SPATH) 
@$(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
+
 
 "$(DLINK)" -o ${dst} $(DLINK_FLAGS) 
-Wl,--start-group,@$(STATIC_LIBRARY_FILES_LIST),--end-group $(CC_FLAGS) 
$(DLINK2_FLAGS)
 "$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
@@ -331,7 +334,7 @@
 
 $(DEBUG_DIR)(+)$(MODULE_NAME)
 
-
+
 "$(DLINK)" $(DLINK_FLAGS) $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST)
 
 
@@ -355,7 +358,7 @@
 
 $(OUTPUT_DIR)(+)$(MODULE_NAME).efi
 
-
+
 "$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
 $(CP) ${dst} $(DEBUG_DIR)
 $(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
@@ -460,9 +463,14 @@
 
 
 "$(ASLCC)" -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) 
$(ASLCC_FLAGS) $(INC) ${src}
-"$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll 
$(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+"$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll 
$(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) 
$(ASLCC_FLAGS)
 "$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll 
$(GENFW_FLAGS)
-
+
+
+"$(ASLCC)" -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) 
$(ASLCC_FLAGS) $(INC) ${src}
+"$(ASLDLINK)" /OUT:$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll 
$(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+"$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll 
$(GENFW_FLAGS)
+
 
 "$(ASLCC)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj  $(ASLCC_FLAGS) 
$(INC) ${src}
 "$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll 
$(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
@@ -622,21 +630,19 @@
 
 *.hpk
 
-
+
 $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.lib
 
 
 $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc
 
-
+
 "$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) 
--hiipackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS)
 "$(RC)" /Fo${dst} $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc
 
 
 "$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) 
--hiibinpackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS)
 "$(RC)" $(RC_FLAGS) $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc ${dst}
-
+
 
 GenFw -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) 
--hiibinpackage $(HII_BINARY_PACKAGES)
-
-
diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index fd6fca542d..b4bc27ab25 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -268,6 +268,15 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
 # Required to build platforms or ACPI tables:
 #   Intel(r) ACPI Compiler from
 #   https://acpica.org/downloads
+#   CLANG9   -Linux, Windows, Mac-  Requires:
+# Clang 9 or above from http://releases.llvm.org/
+#Optional:
+# Required to compile nasm source:
+#   nasm compiler from
+#   NASM -- http://www.nasm.us/
+# Required to build platforms or ACPI tables:
+#   Intel(r) ACPI Compiler from
+#   https://acpica.org/downloads
 #   VS2008x86   -win64-  Requires:
 # Microsoft Visual Studio 2008 (x86)
 # Microsoft Windows Server 2003 Driver Development 
Kit (Microsoft WINDDK) version 3790.1830
@@ -2698,6 +2707,99 @@ DEFINE CLANG38_AARCH64_DLINK_FLAGS  = 
DEF(CLANG38_AARCH64_TARGET) DEF(GCC_AARCH6
 RELEASE_CLANG38_AARCH64_CC_FLAGS= DEF(CLANG38_AARCH64_CC_FLAGS) 
$(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -flto -O3
 RELEASE_CLANG38_AARCH64_DLINK_FLAGS = DEF(CLANG38_AARCH64_DLINK_FLAGS) -flto 
-Wl,-O3 -L$(WORKSPACE)/ArmPkg/Library/GccLto 

[edk2-devel] [Patch v3 00/11] New Cross OS tool chain CLANG9

2019-10-17 Thread Liming Gao
In v3, add the detail commit message for patch 3. 
Update the fix in EmulatorPkg based on the comments.

In v2, drop patch 12, and update commit message for 5 & 11.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603
Code: https://github.com/lgao4/edk2/tree/CLANG9
Wiki: https://github.com/lgao4/edk2/wiki/CLANG9-Tools-Chain

CLANG9 tool chain is added to directly generate PE/COFF image (EFI image).
This tool chain uses LLVM clang C compiler and lld linker, generates PE/COFF
image and PDB compatible debug symbol format. Now, it supports IA32/X64 Archs.
It must use LLVM 9 or above release. LLVM 9 is ready on 
http://releases.llvm.org/download.html#9.0.0.

CLANG9 is the cross OS tool chain. It can work on Windows/Linux/Mac host OS. 
For the same source code, with the same version LLVM tool chain, 
CLANG9 can generate the same binary image. So, the developer can 
choose the different development environment and work on the same 
code base. Besides, EDKII project build also requires third party 
tools: nasm and iasl. They both keep the same version. If so, the same 
binary image can be generated on the different host OS.

LLVM tool chain provides the compiler and linker. To build EDK2 project, 
some other tools are still required. On Windows OS, nmake and Visual Studio 
are required to call Makefile and compile BaseTools C tools. 
On Linux/Mac, binutils and gcc are required to make and compile BaseTools 
C tools. Because VS or GCC are mainly used to compile BaseTools and provide 
nmake/make tool, they can keep on the stable version without update.

To build source code, CLANG9 tool chain (-t CLANG9) can be specified
on Windows OS, set CLANG_HOST_BIN=n, set CLANG9_BIN=LLVM installed directory
CLANG_HOST_BIN is used CLANG_HOST_PREFIX. Prefix n is for nmake.
For example:
*  set CLANG_HOST_BIN=n
*  set CLANG9_BIN=C:\Program Files\LLVM\bin\
*  set IASL_PREFIX=C:\Asl\

On Linux/Mac, export CLANG9_BIN=LLVM installed directory, CLANG_HOST_BIN is 
not required, because there is no prefix for make.
For example:
*  export CLANG9_BIN=/home/clang9/bin/

Now, CLANG9 tool chain has been verified in Edk2 packages and Ovmf/Emulator
with LLVM 9.0.0 on Windows and Linux OS. 
OVMF IA32/X64/IA32X64 all boots to Shell on Windows and Linux OS. 
Emulator can boot to Shell on Windows only with CLANG9.
OVMF Ia32X64 RELEASE build generates the same BIOS images on Windows and Linux 
OS.

Cc: Jiewen Yao 
Cc: Steven Shi 
Cc: Jordan Justen 
Cc: Laszlo Ersek 
Cc: Andrew Fish 
Cc: Ray Ni 
Cc: Ard Biesheuvel 
Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Bob Feng 
Cc: Michael D Kinney 

Liming Gao (11):
  BaseTools tools_def.template: Remove unnecessary $(DEST_DIR_DEBUG)
path
  BaseTools tools_def: Add CLANG9 tool chain to directly generate PE
image
  BaseTools GenFw: Fix the issue to update the wrong size as SectionSize
  MdePkg Base.h: Add definition for CLANG9 tool chain
  MdePkg BaseIoLibIntrinsic: Remove __inline__ attribute for IO
functions
  MdeModulePkg LzmaCustomDecompressLib: Update macro to be same in CLANG
tool
  MdeModulePkg RegularExpressionDxe: Disable warning for CLANG9 tool
chain
  CryptoPkg: Append options to make CLANG9 tool chain pass build
  CryptoPkg IntrinsicLib: Make _fltused always be used
  EmulatorPkg: Enable CLANG9 tool chain
  OvmfPkg: Enable CLANG9 tool chain

 BaseTools/Source/C/GenFw/GenFw.c   |   8 +-
 CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c  |  10 +-
 EmulatorPkg/Win/Host/WinHost.c |   6 +-
 MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c   |   6 -
 BaseTools/Conf/build_rule.template |  26 +++--
 BaseTools/Conf/tools_def.template  | 124 +++--
 CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf|   1 +
 CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf |   1 +
 CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf |   1 +
 CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf |   1 +
 CryptoPkg/Library/OpensslLib/OpensslLib.inf|   1 +
 CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf  |   1 +
 EmulatorPkg/EmulatorPkg.dsc|   7 +-
 EmulatorPkg/Win/Host/WinHost.inf   |   6 +
 .../LzmaCustomDecompressLib/Sdk/C/7zTypes.h|   2 +-
 .../RegularExpressionDxe/RegularExpressionDxe.inf  |   3 +
 MdePkg/Include/Base.h  |   6 +-
 MdePkg/Include/Ia32/ProcessorBind.h|   4 +-
 MdePkg/Include/X64/ProcessorBind.h |   2 +-
 OvmfPkg/OvmfPkgIa32.dsc|   4 +-
 OvmfPkg/OvmfPkgIa32X64.dsc |   4 +-
 OvmfPkg/OvmfPkgX64.dsc |   4 +-
 22 files changed, 183 insertions(+), 45 deletions(-)

-- 
2.13.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49157): https://edk2.groups.io/g/devel/message/49157
Mute This Topic: https://groups.io/mt/34694424/21656
Group Owner: 

[edk2-devel] [Patch v3 09/11] CryptoPkg IntrinsicLib: Make _fltused always be used

2019-10-17 Thread Liming Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603
With this change, global variable _fltused will not be removed by LTO

Signed-off-by: Liming Gao 
Reviewed-by: Jian J Wang 
Reviewed-by: Philippe Mathieu-Daude 
---
 CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c 
b/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
index 6e4d4a68cc..94fe341bec 100644
--- a/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
+++ b/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
@@ -2,7 +2,7 @@
   Intrinsic Memory Routines Wrapper Implementation for OpenSSL-based
   Cryptographic Library.
 
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -13,9 +13,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 typedef UINTN  size_t;
 
+#if defined(__GNUC__) || defined(__clang__)
+  #define GLOBAL_USED __attribute__((used))
+#else
+  #define GLOBAL_USED
+#endif
+
 /* OpenSSL will use floating point support, and C compiler produces the 
_fltused
symbol by default. Simply define this symbol here to satisfy the linker. */
-int _fltused = 1;
+int  GLOBAL_USED _fltused = 1;
 
 /* Sets buffers to a specified character */
 void * memset (void *dest, int ch, size_t count)
-- 
2.13.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49166): https://edk2.groups.io/g/devel/message/49166
Mute This Topic: https://groups.io/mt/34694470/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch v3 07/11] MdeModulePkg RegularExpressionDxe: Disable warning for CLANG9 tool chain

2019-10-17 Thread Liming Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603

Signed-off-by: Liming Gao 
Reviewed-by: Hao A Wu 
---
 MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf | 3 +++
 1 file changed, 3 insertions(+)

diff --git 
a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf 
b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
index 883d5f1127..e9c885465d 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf
@@ -107,6 +107,9 @@
   # Oniguruma: tag_end in parse_callout_of_name
   GCC:*_*_*_CC_FLAGS = -Wno-error=maybe-uninitialized
 
+  # Oniguruma: implicit conversion from 'UINTN' (aka 'unsigned long long') to 
'long'
+  GCC:*_CLANG9_*_CC_FLAGS = -Wno-error=constant-conversion
+
   # Not add -Wno-error=maybe-uninitialized option for XCODE
   # XCODE doesn't know this option
   XCODE:*_*_*_CC_FLAGS =
-- 
2.13.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49164): https://edk2.groups.io/g/devel/message/49164
Mute This Topic: https://groups.io/mt/34694459/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch v3 11/11] OvmfPkg: Enable CLANG9 tool chain

2019-10-17 Thread Liming Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603
1. Apply CLANG9 Linker option.
2. Exclude -mno-mmx -mno-sse compiler option for CLANG9
These two options will cause CLANG Linker crush.

Signed-off-by: Liming Gao 
Reviewed-by: Laszlo Ersek 
---
 OvmfPkg/OvmfPkgIa32.dsc| 4 +++-
 OvmfPkg/OvmfPkgIa32X64.dsc | 4 +++-
 OvmfPkg/OvmfPkgX64.dsc | 4 +++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 66e944436a..0fde8e6e84 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -66,7 +66,7 @@
   GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
   INTEL:RELEASE_*_*_CC_FLAGS   = /D MDEPKG_NDEBUG
   MSFT:RELEASE_*_*_CC_FLAGS= /D MDEPKG_NDEBUG
-!if $(TOOL_CHAIN_TAG) != "XCODE5"
+!if $(TOOL_CHAIN_TAG) != "XCODE5" && $(TOOL_CHAIN_TAG) != "CLANG9"
   GCC:*_*_*_CC_FLAGS   = -mno-mmx -mno-sse
 !endif
 
@@ -80,12 +80,14 @@
 [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
   GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
   XCODE:*_*_*_DLINK_FLAGS =
+  CLANGPE: *_*_*_DLINK_FLAGS = /ALIGN:4096
 
 # Force PE/COFF sections to be aligned at 4KB boundaries to support page level
 # protection of DXE_SMM_DRIVER/SMM_CORE modules
 [BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE]
   GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
   XCODE:*_*_*_DLINK_FLAGS =
+  CLANGPE: *_*_*_DLINK_FLAGS = /ALIGN:4096
 
 

 #
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 51c2bfb44f..c17329878e 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -66,7 +66,7 @@
   GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
   INTEL:RELEASE_*_*_CC_FLAGS   = /D MDEPKG_NDEBUG
   MSFT:RELEASE_*_*_CC_FLAGS= /D MDEPKG_NDEBUG
-!if $(TOOL_CHAIN_TAG) != "XCODE5"
+!if $(TOOL_CHAIN_TAG) != "XCODE5" && $(TOOL_CHAIN_TAG) != "CLANG9"
   GCC:*_*_*_CC_FLAGS   = -mno-mmx -mno-sse
 !endif
 !ifdef $(SOURCE_DEBUG_ENABLE)
@@ -85,12 +85,14 @@
 [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
   GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
   XCODE:*_*_*_DLINK_FLAGS =
+  CLANGPE: *_*_*_DLINK_FLAGS = /ALIGN:4096
 
 # Force PE/COFF sections to be aligned at 4KB boundaries to support page level
 # protection of DXE_SMM_DRIVER/SMM_CORE modules
 [BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE]
   GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
   XCODE:*_*_*_DLINK_FLAGS =
+  CLANGPE: *_*_*_DLINK_FLAGS = /ALIGN:4096
 
 

 #
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index ba7a758844..af91265d05 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -66,7 +66,7 @@
   GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
   INTEL:RELEASE_*_*_CC_FLAGS   = /D MDEPKG_NDEBUG
   MSFT:RELEASE_*_*_CC_FLAGS= /D MDEPKG_NDEBUG
-!if $(TOOL_CHAIN_TAG) != "XCODE5"
+!if $(TOOL_CHAIN_TAG) != "XCODE5" && $(TOOL_CHAIN_TAG) != "CLANG9"
   GCC:*_*_*_CC_FLAGS   = -mno-mmx -mno-sse
 !endif
 !ifdef $(SOURCE_DEBUG_ENABLE)
@@ -85,12 +85,14 @@
 [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
   GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
   XCODE:*_*_*_DLINK_FLAGS =
+  CLANGPE: *_*_*_DLINK_FLAGS = /ALIGN:4096
 
 # Force PE/COFF sections to be aligned at 4KB boundaries to support page level
 # protection of DXE_SMM_DRIVER/SMM_CORE modules
 [BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE]
   GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
   XCODE:*_*_*_DLINK_FLAGS =
+  CLANGPE: *_*_*_DLINK_FLAGS = /ALIGN:4096
 
 

 #
-- 
2.13.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49168): https://edk2.groups.io/g/devel/message/49168
Mute This Topic: https://groups.io/mt/34694482/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] Upcoming Event: TianoCore Design Meeting - APAC/NAMO - Thu, 10/17/2019 6:30pm-7:30pm #cal-reminder

2019-10-17 Thread devel@edk2.groups.io Calendar
*Reminder:* TianoCore Design Meeting - APAC/NAMO

*When:* Thursday, 17 October 2019, 6:30pm to 7:30pm, (GMT-07:00) America/Los 
Angeles

*Where:* BlueJeans Meeting

View Event ( https://edk2.groups.io/g/devel/viewevent?eventid=503246 )

*Organizer:* Stephano Cetola stephano.cet...@intel.com ( 
stephano.cet...@intel.com?subject=Re:%20Event:%20TianoCore%20Design%20Meeting%20-%20APAC%2FNAMO
 )

*Description:*

*TOPIC: PCIe FW Measurement (Jiewen Yao)*

For more info, see here:

https://www.tianocore.org/design-meeting/

To join the meeting on a computer or mobile phone:

https://bluejeans.com/889357567?src=calendarLink ( 
https://bluejeans.com/889357567?src=calendarLink )

Phone Dial-in

+1.408.740.7256 (US (San Jose))

+1.408.317.9253 (US (Primary, San Jose))

Global Numbers: https://www.bluejeans.com/numbers ( 
https://www.bluejeans.com/numbers )

Meeting ID: 889 357 567

Room System

199.48.152.152 or bjn.vc

Meeting ID: 889 357 567

Want to test your video connection?

https://bluejeans.com/111 ( https://bluejeans.com/111 )

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49210): https://edk2.groups.io/g/devel/message/49210
Mute This Topic: https://groups.io/mt/34954414/21656
Mute #cal-reminder: https://groups.io/mk?hashtag=cal-reminder=3846945
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 1/3] BaseTools: Let the GetMaintainer.py script be executable

2019-10-17 Thread Bob Feng
Hi Phil,

To make python script to be executable, I think only change file permission 
would not be enough. There also need to be a shebang
#!/usr/bin/env python at the top of this script.

But from the patch 3/3, I see in the GitCcCmd.sh, GetMaintainer.py is called by 
"python ${EDK_TOOLS_PATH}/Scripts/GetMaintainer.py --quiet"
Python interpreter is called explicit, so I think it's not necessary to change 
GetMaintainer.py permission.

Thanks,
Bob


-Original Message-
From: Philippe Mathieu-Daude [mailto:phi...@redhat.com] 
Sent: Wednesday, October 16, 2019 10:10 PM
To: Leif Lindholm ; devel@edk2.groups.io
Cc: Feng, Bob C ; Gao, Liming ; 
Laszlo Ersek ; Philippe Mathieu-Daude 
Subject: [PATCH 1/3] BaseTools: Let the GetMaintainer.py script be executable

The GetMaintainer.py script use the "if __name__ == '__main__'"
evaluation so it expects to be run as a standalone program.

We have other Python scripts with the executable permission, let this one be 
executable too.

Signed-off-by: Philippe Mathieu-Daude 
---
 BaseTools/Scripts/GetMaintainer.py | 0
 1 file changed, 0 insertions(+), 0 deletions(-)  mode change 100644 => 100755 
BaseTools/Scripts/GetMaintainer.py

diff --git a/BaseTools/Scripts/GetMaintainer.py 
b/BaseTools/Scripts/GetMaintainer.py
old mode 100644
new mode 100755
--
2.21.0


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49211): https://edk2.groups.io/g/devel/message/49211
Mute This Topic: https://groups.io/mt/34560654/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-test] [PATCH V4] uefi-sct/SctPkg: Auto gen result of "EFICompliantTest".

2019-10-17 Thread Eric Jin
Pushed at bd239933cf41f882a9342d39fcca65266a6280ad

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Eric Jin
Sent: Wednesday, October 16, 2019 2:46 PM
To: Chen, ArvinX ; devel@edk2.groups.io
Subject: Re: [edk2-devel] [edk2-test] [PATCH V4] uefi-sct/SctPkg: Auto gen 
result of "EFICompliantTest".

Adjust the prefix to [edk2-devel] [edk2-test] [PATCH V4] in subject

Reviewed-by: Eric Jin 

> -Original Message-
> From: Chen, ArvinX 
> Sent: Wednesday, October 16, 2019 2:33 PM
> To: devel@edk2.groups.io
> Cc: Jin, Eric 
> Subject: [PATCH] uefi-sct/SctPkg: Auto gen result of "EFICompliantTest".
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2155
> 
>   Now the test item "EFICompliantTest" will be gen in the XXX.csv.
> However, I find most of the SCT user will not know what platform 
> config they test is, so I think  we can independently generate a file 
> of the "EFICompliantTest" tests, then the SCT tester can send this 
> file to the platform owner and let them directly handle the compliant issue.
> 
> This patch will auto gen a file in path SCT\Report\PlatformConfig.ini 
> once tester retest again, system will delete the current 
> PlatformConfig.ini and create a new one. If tester want to ignore test 
> results in *.csv, tester can modify EfiCompliant.ini to control it.
> 
> Cc: Eric Jin 
> Signed-off-by: ArvinX Chen 
> ---
>  .../Dependency/Config/EfiCompliant.ini |  13 +-
>  .../BlackBoxTest/EfiCompliantBBTestPlatform_uefi.c | 498
> -
>  2 files changed, 509 insertions(+), 2 deletions(-)
> 
> diff --git a/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Generic/EfiCompliant/BlackBoxTest/Depende
> ncy/Config/EfiCompliant.ini b/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Generic/EfiCompliant/BlackBoxTest/Depende
> ncy/Config/EfiCompliant.ini
> index d234d87a..4deaae3b 100644
> --- a/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Generic/EfiCompliant/BlackBoxTest/Depende
> ncy/Config/EfiCompliant.ini
> +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/EfiCompliant/BlackBoxT
> +++ es t/Dependency/Config/EfiCompliant.ini
> @@ -1,6 +1,6 @@
>  ## @file
>  #
> -#  Copyright 2006 - 2016 Unified EFI, Inc.
> +#  Copyright 2006 - 2019 Unified EFI, Inc.
>  #  Copyright (c) 2010 - 2019, Intel Corporation. All rights 
> reserved.  #  # This program and the accompanying materials @@ 
> -24,6 +24,14 @@  #  #
> Notes:
>  #
> +###  [Test Configuration Specific]
> +#
> +#   GEN_CONFIG_INI_FILE_ON=  the report folder>
> +#
> +#   IGNORE_COMPLIANT_TEST_CSV =  be generated in the report/*.csv file, but if GEN_CONFIG_INI_FILE_ON 
> is "no", this item will aways be no.>
> +#
> +###  [Platform Specific]
> +#
>  #   ConsoleDevices=  devices>
>  #
>  #   HiiConfigSupport  =  Support>
> @@ -91,6 +99,9 @@
>  #   IPSecSupport  =  network>
>  #
>  #--*/
> +[Test Configuration Specific]
> +GEN_CONFIG_INI_FILE_ON= yes
> +IGNORE_COMPLIANT_TEST_CSV = no
> 
>  [Platform Specific]
>  ConsoleDevices= yes
> diff --git a/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Generic/EfiCompliant/BlackBoxTest/EfiComp
> li
> antBBTestPlatform_uefi.c b/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Generic/EfiCompliant/BlackBoxTest/EfiComp
> li
> antBBTestPlatform_uefi.c
> index ae76c909..be06d139 100644
> --- a/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/Generic/EfiCompliant/BlackBoxTest/EfiComp
> li
> antBBTestPlatform_uefi.c
> +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Generic/EfiCompliant/BlackBoxT
> +++ es t/EfiCompliantBBTestPlatform_uefi.c
> @@ -28,7 +28,7 @@ Abstract:
>  // Includes
>  //
> 
> -#include "SctLib.h"
> +#include "SctLib.h"
>  #include "EfiCompliantBbTestMain_uefi.h"
>  #include EFI_PROTOCOL_DEFINITION (SimpleTextIn)  #include 
> EFI_PROTOCOL_DEFINITION (SimpleTextInEx) @@ -87,6 +87,9 @@ extern 
> EFI_GUID gGlobalVariableGuid;  //
> 
>  #define SECTION_NAME_PLATFORM_SPECIFIC  L"Platform Specific"
> +#define SECTION_NAME_CONFIGURATION_SPECIFIC L"Test Configuration
> Specific"
> +#define CONFIN_TITLE_STRING L"|=
> Configuration Environment  =|"
> +#define MAX_SIZE0xFF
> 
>  #define EFI_DHCP6_SERVICE_BINDING_PROTOCOL_GUID \
>   { 0x9fb9a8a1, 0x2f4a, 0x43a6, {0x88, 0x9c, 0xd0, 0xf7, 0xb6, 0xc4, 
> 0x7a,
> 0xd5 }} @@ -170,6 +173,12 @@ EFI_GUID
> gEfiBlueToothAttributeProtocolGuid = { 0x898890e9, 0x84b2, 0x4f3a, { 
> 0x
> 
>  EFI_GUID gEfiBlueToothLEConfigProtocolGuid = { 0x8f76da58, 0x1f99, 
> 0x4275, { 0xa4, 0xec, 0x47, 0x56, 0x51, 0x5b, 0x1c, 0xe8 }};
> 
> +typedef struct CONFIG_ERROR_DATA {
> +  UINT8ErrorCount;
> +  CHAR16   *TitleString;
> +  EFI_INI_FILE_HANDLE  ConfigINI;
> +} CONFIG_ERROR_DATA;
> +
>  //
>  // The Max length of pre-defined string value(yes or no)  // in the 
> EfiCompliant.ini @@ -381,6 +390,25 @@ CheckIPSecProtocols (
>IN EFI_INI_FILE_HANDLE  IniFile
>);
> 
> +CONFIG_ERROR_DATA*
> +ConstructionAndAcquisition (
> +  IN 

Re: [edk2-devel] [PATCH V5 00/10] UEFI Variable SMI Reduction

2019-10-17 Thread Wang, Jian J


For the whole patch series (1-10),
Reviewed-by: Jian J Wang 


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Kubacki,
> Michael A
> Sent: Friday, October 18, 2019 8:14 AM
> To: devel@edk2.groups.io
> Cc: Bi, Dandan ; Ard Biesheuvel
> ; Dong, Eric ; Laszlo Ersek
> ; Gao, Liming ; Kinney, Michael D
> ; Ni, Ray ; Wang, Jian J
> ; Wu, Hao A ; Yao, Jiewen
> 
> Subject: [edk2-devel] [PATCH V5 00/10] UEFI Variable SMI Reduction
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2220
> 
> V5 Changes:
>  [PATCH V4 07/10] MdeModulePkg/Variable: Add RT GetVariable() cache support
>  * Increased validation of the runtime buffers passed in the SMM comm buffer
>SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT
> structure to the
>SMM_VARIABLE_FUNCTION_INIT_RUNTIME_VARIABLE_CACHE_CONTEXT
> function in
>SmmVariableHandler () in VariableSmm.c.
>  * Most notably, each runtime buffer given is checked to ensure its memory
>range does not overlap with SMRAM ranges via
> VariableSmmIsBufferOutsideSmmValid ().
> 
> V4 Changes:
>  [PATCH V3 7/9] MdeModulePkg/Variable: Add RT GetVariable() cache support
>  * Set gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache to
> FALSE
>by default in MdeModulePkg.dec.
> 
>  * Added a new patch to set
> gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache
>to TRUE at the end of the patch series. This allows someone to bisect an 
> issue
> at
>patch #7 or patch #8 in the series with no change in variable caching 
> behavior.
> The
>runtime cache variable logic would be applied explicitly in V4 patch #10.
> 
> V3 Changes:
>  [PATCH V2 1/9] MdeModulePkg/Variable: Consolidate common parsing
> functions
>  * Removed GUIDs added to VariableStandaloneMm.inf that are not required.
>  * Added more details to the commit message describing the criteria of
>moving the chosen functions to VariableParsing.c.
> 
>  [PATCH V2 2/9] MdeModulePkg/Variable: Parameterize GetNextVariableEx()
> store list
>  * RenamedGetNextVariableEx () to VariableServiceGetNextVariableInternal ()
>  * Updated comments in VariableServiceGetNextVariableInternal () to refer to
>"FindVariablEx ()" instead of "FindVariable ()" since FindVariableEx ()
>is not used in the function.
> 
>  [PATCH V2 3/9] MdeModulePkg/Variable: Parameterize
> VARIABLE_INFO_ENTRY buffer
>  * Updated the commit message to clarify the message "structure can be
> updated
>outside the fixed global variable".
> 
>  [edk2-devel] [PATCH V2 4/9] MdeModulePkg/Variable: Add local auth status in
> VariableParsing
>  * Remove the function InitVariableParsing ()
>  * Remove the mAuthFormat global variable and instead add a BOOLEAN
> parameter
>to all functions that require variable authentication information  to
>indicate if authenticated variables are used.
>* This allows the authenticated variable status to be tracked in one place 
> in
>  each variable driver in the SMM variable solution (VariableSmmRuntimeDxe
>  and VariableSmm).
> 
>  [edk2-devel] [PATCH V2 5/9] MdeModulePkg/Variable: Add a file for NV
> variable functions
>  * Added the following non-volatile related functions to VariableNonVolatile.c
>from Variable.c:
>* InitRealNonVolatileVariableStore ()
>* InitEmuNonVolatileVariableStore ()
>* InitNonVolatileVariableStore ()
> 
>  [edk2-devel] [PATCH V2 7/9] MdeModulePkg/Variable: Add RT GetVariable()
> cache support
>  * Added a FeaturePCD to control enabling the runtime variable cache -
>gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache.
>  * Removed usage of the TimerLib and the wait to acquire
>mVariableRuntimeCacheReadLock. Can rely on the UEFI specification
>restrictions on Runtime Services callers.
>  * Removed the EFIAPI keyword from internal functions.
>  * Removed PCDs in VariableSmmRuntimeDxe.inf not required.
>  * Removed the HobVariableBackupBase variable no longer required.
>  * Renamed SynchronizeRuntimeVariableCacheEx () to better reflect usage.
>  * Renamed functions in VariableRuntimeCache.c to better reflect usage.
>  * Introduced a local variable in FlushPendingRuntimeVariableCacheUpdates ()
>to reduce duplication of
>mVariableModuleGlobal->VariableGlobal.VariableRuntimeCacheContext.
>  * Corrected the macro used in SmmVariableHandler () to
>SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT.
>  * Remove usage of the EDKII_PI_SMM_COMMUNICATION_REGION_TABLE to
> acquire a
>CommBuffer from the EFI System Table and use the same runtime
> CommBuffer
>allocated for variable SMM communicate calls.
> 
>  [PATCH V2 8/9] MdeModulePkg/Variable: Add RT GetNextVariableName()
> cache support
>  * Removed usage of the TimerLib and the wait to acquire
>mVariableRuntimeCacheReadLock. Can rely on the UEFI specification
> restrictions
>on Runtime Services callers.
> 
>  * Added a new patch to disable
> gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache

[edk2-devel] [PATCH] MdeModulePkg/SdBlockIoPei: Add check for DeviceIndex

2019-10-17 Thread Zhang, Shenglei
DeviceIndex is used as index in Slot[]. The max size of Slot[]
is SD_PEIM_MAX_SLOTS. So DeviceIndex should be checked before used.

Cc: Hao A Wu 
Cc: Ray Ni 
Signed-off-by: Shenglei Zhang 
---
 MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c 
b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c
index 8fa58d65b22c..25530dcb34ce 100644
--- a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c
+++ b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c
@@ -174,7 +174,7 @@ SdBlockIoPeimGetMediaInfo (
 
   Private   = GET_SD_PEIM_HC_PRIVATE_DATA_FROM_THIS (This);
 
-  if ((DeviceIndex == 0) || (DeviceIndex > Private->TotalBlkIoDevices)) {
+  if ((DeviceIndex == 0) || (DeviceIndex > Private->TotalBlkIoDevices) || 
(DeviceIndex > (SD_PEIM_MAX_SLOTS - 1))) {
 return EFI_INVALID_PARAMETER;
   }
 
@@ -252,7 +252,7 @@ SdBlockIoPeimReadBlocks (
 return EFI_SUCCESS;
   }
 
-  if ((DeviceIndex == 0) || (DeviceIndex > Private->TotalBlkIoDevices)) {
+  if ((DeviceIndex == 0) || (DeviceIndex > Private->TotalBlkIoDevices) || 
(DeviceIndex > (SD_PEIM_MAX_SLOTS - 1))) {
 return EFI_INVALID_PARAMETER;
   }
 
-- 
2.18.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49154): https://edk2.groups.io/g/devel/message/49154
Mute This Topic: https://groups.io/mt/34685173/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH] MdeModulePkg/HiiDatabaseDxe: Add check for 'Private->Attribute >> 4'

2019-10-17 Thread Zhang, Shenglei
The size of mHiiEfiColors is 16.
mHiiEfiColors[Private->Attribute >> 4] may be out of boundary.
So add a check for that.

Cc: Dandan Bi 
Cc: Eric Dong 
Signed-off-by: Shenglei Zhang 
---
 MdeModulePkg/Universal/HiiDatabaseDxe/Font.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c 
b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
index ca63df168c94..282a7a114d17 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
@@ -999,7 +999,12 @@ GetSystemFont (
   }
 
   Info->ForegroundColor= mHiiEfiColors[Private->Attribute & 0x0f];
-  Info->BackgroundColor= mHiiEfiColors[Private->Attribute >> 4];
+  if ((Private->Attribute >> 4) < 16){
+Info->BackgroundColor= mHiiEfiColors[Private->Attribute >> 4];
+  } else {
+return EFI_INVALID_PARAMETER;
+  }
+  
   Info->FontInfoMask   = EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_SYS_SIZE | 
EFI_FONT_INFO_SYS_STYLE;
   Info->FontInfo.FontStyle = 0;
   Info->FontInfo.FontSize  = EFI_GLYPH_HEIGHT;
-- 
2.18.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49153): https://edk2.groups.io/g/devel/message/49153
Mute This Topic: https://groups.io/mt/34685172/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [RFC v1 5/4] CryptoPkg/TlsLib: accept peer certs via both DNS names and IP addresses

2019-10-17 Thread Laszlo Ersek
Jiaxin,

On 10/16/19 17:25, David Woodhouse wrote:
> On Wed, 2019-10-16 at 16:43 +0200, Laszlo Ersek wrote:
>> Regarding the current edk2 patch set, I think we should do the following:
>>
>> - use X509_VERIFY_PARAM_set1_ip() rather than
>> X509_VERIFY_PARAM_set1_ip_asc()
>>
>> - incorporate "StdLib/BsdSocketLib/inet_pton.c" from the edk2-libc
>> project (which used to be part of edk2 itself) into TlsLib, and call
>> inet_pton() for parsing the address as both IPv4 and IPv6.
> 
> That makes sense.

Please wait a little before starting work on this. I've been made aware,
in , of the practices of various
certificate authorities:

[1] https://www.geocerts.com/support/ip-address-in-ssl-certificate
[2]
https://www.leaderssl.com/articles/381-issuing-ssl-certificate-for-an-ip-address
[3]
https://support.globalsign.com/customer/en/portal/articles/1216536-securing-a-public-ip-address---ssl-certificates

What's most worrisome is [3], which writes:

If you are targeting Windows 10 and later, you can populate the IP
address in either field. If however, you are targeting Windows 8.1
and earlier, you should only specify the IP address as the common
name.

Keyword being "only".

Assuming the above quote precisely reflects reality: if we made edk2
strictly insist on the IP address being in the SAN.iPAddress field, then
edk2 could not HTTPS-boot from such web servers that intend to serve
Windows clients up to 8.1.

Reference [2] advises to put the IP address in both CN and SAN.iPAddress
for best compatibility, and that would be fine, for
X509_VERIFY_PARAM_set1_ip(). But the word "only" in [3] is really bad
for X509_VERIFY_PARAM_set1_ip().

Thanks
Laszlo

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49182): https://edk2.groups.io/g/devel/message/49182
Mute This Topic: https://groups.io/mt/34551672/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH V4 07/10] MdeModulePkg/Variable: Add RT GetVariable() cache support

2019-10-17 Thread Wang, Jian J
> 
> Again, I would like to ask for help from other reviewers to look at this patch
> (patch 7/10) and the next one (patch 8/10) (at least from the security
> perspective). Any help will be appreciated, thanks in advance.
>

I'm trying to do a simple analysis below from security perspective. Please 
correct me
if anything wrong.

The patch added 3 new SMI variable Functions
  f(a): SMM_VARIABLE_FUNCTION_INIT_RUNTIME_VARIABLE_CACHE_CONTEXT
  f(b): SMM_VARIABLE_FUNCTION_SYNC_RUNTIME_CACHE
  f(c): SMM_VARIABLE_FUNCTION_GET_RUNTIME_CACHE_INFO

f(a) communication buffer is type of 
  SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT

which is defined as
  typedef struct {
BOOLEAN *ReadLock;
BOOLEAN *PendingUpdate;
BOOLEAN *HobFlushComplete;
VARIABLE_STORE_HEADER   *RuntimeHobCache;
   VARIABLE_STORE_HEADER   *RuntimeNvCache;
VARIABLE_STORE_HEADER   *RuntimeVolatileCache;
  } SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT;

There're 6 fields (all pointers) in the buffer. SMM will handle them in 
following ways
- ReadLock and PendingUpdate are used to avoid race condition between smm and
  non-smm code. I don't think there's security breach here.
- RuntimeHobCache, RuntimeNvCache and RuntimeVolatileCache are buffers passed
  to smm  code to simply store variable content. Smm code will not read its 
content.
  I think this won't bring any security risk.

The SmmVariableHandler() will call VariableSmmIsBufferOutsideSmmValid()
to make sure the communication buffer is outside of smram. But the handler will
not check the above 6 pointers passed through communication buffer to see if 
they
are in non-smram scope. This leaves potential security hole to allow smram 
buffer
to be passed in from non-smm code.

f(b) doesn't use communication buffer. It's just used to flush variable cache. 
Then
no security risk here.

f(c) uses communication buffer with type of

  typedef struct {
UINTN   TotalHobStorageSize;
UINTN   TotalNvStorageSize;
UINTN   TotalVolatileStorageSize;
BOOLEAN AuthenticatedVariableUsage;
  } SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO;

There's no pointer in the buffer and the SMI handler doesn't read its content 
but
just store data into it. I think there's no security risk here.

I also checked data flow newly introduced between smm and non-smm boundary.
Most of the data flow is just from smm to non-smm. The only exception is 
ReadLock
mentioned above. Generally speaking, I don't find security issue in this patch 
series
except to above pointers passed by communication buffer.

Regards,
Jian

> -Original Message-
> From: Wu, Hao A 
> Sent: Wednesday, October 16, 2019 3:57 PM
> To: Kubacki, Michael A ; devel@edk2.groups.io
> Cc: Bi, Dandan ; Ard Biesheuvel
> ; Dong, Eric ; Laszlo Ersek
> ; Gao, Liming ; Kinney, Michael D
> ; Ni, Ray ; Wang, Jian J
> ; Yao, Jiewen 
> Subject: RE: [PATCH V4 07/10] MdeModulePkg/Variable: Add RT GetVariable()
> cache support
> 
> Again, I would like to ask for help from other reviewers to look at this patch
> (patch 7/10) and the next one (patch 8/10) (at least from the security
> perspective). Any help will be appreciated, thanks in advance.
> 
> 
> One comment inherited from the feedback on the V2 series:
> I saw AtRuntime() is still being added in file VariableSmmRuntimeDxe.c, could
> you help to double confirm?
> 
> Another general level comment is that:
> Please help to update the MdeModulePkg.uni file as well for the introduce of
> the new PCD.
> 
> Inline comments below:
> 
> 
> > -Original Message-
> > From: Kubacki, Michael A
> > Sent: Tuesday, October 15, 2019 7:30 AM
> > To: devel@edk2.groups.io
> > Cc: Bi, Dandan; Ard Biesheuvel; Dong, Eric; Laszlo Ersek; Gao, Liming; 
> > Kinney,
> > Michael D; Ni, Ray; Wang, Jian J; Wu, Hao A; Yao, Jiewen
> > Subject: [PATCH V4 07/10] MdeModulePkg/Variable: Add RT GetVariable()
> > cache support
> >
> > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2220
> >
> > This change reduces SMIs for GetVariable () by maintaining a
> > UEFI variable cache in Runtime DXE in addition to the pre-
> > existing cache in SMRAM. When the Runtime Service GetVariable()
> > is invoked, a Runtime DXE cache is used instead of triggering an
> > SMI to VariableSmm. This can improve overall system performance
> > by servicing variable read requests without rendezvousing all
> > cores into SMM.
> >
> > The runtime cache  can be disabled with by setting the FeaturePCD
> > gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache
> > to FALSE. If the PCD is set to FALSE, the runtime cache will not be
> > used and an SMI will be triggered for Runtime Service
> > GetVariable () and GetNextVariableName () invocations.
> >
> > The following are important points regarding the behavior of the
> > variable drivers when the variable runtime cache is enabled.
> >
> > 1. All of 

Re: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 10/14] U500Pkg/Library: Library instances of U500 platform library

2019-10-17 Thread Leif Lindholm
On Thu, Oct 17, 2019 at 07:44:47AM +, Abner Chang wrote:
> > -Original Message-
> > From: Chang, Abner (HPS SW/FW Technologist)
> > Sent: Thursday, October 17, 2019 10:21 AM
> > To: devel@edk2.groups.io; leif.lindh...@linaro.org; Chen, Gilbert
> > 
> > Cc: Palmer Dabbelt 
> > Subject: RE: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 10/14]
> > U500Pkg/Library: Library instances of U500 platform library

> > > Seeing this, I have a bit of a feeling that this Opensbi isn't being
> > > consistently
> > > treated/named:
> > > - In edk2, we have RiscVPkg/Library/RiscVOpensbiLib which implements
> > >   class RiscVOpensbiLib.
> > > - Here, we have U500Pkg/Library/OpenSbiPlatformLib implementing the
> > >   class OpenSbiPlatformLib.
> > > - *Logically*, what we have is
> > >   Platform/RiscV/Universal/Sec/SecMain.inf which depends on the
> > >   OpensbiLib which depends on the OpenSbiPlatformLib.
> > >   - However, there is no OpenSbiPlatformLib in edk2, which is very
> > > unfortunate because that does not let us build edk2/RiscVPkg in
> > > isolation (like we can with all the other packages in edk2).
> > Will name it as Opensbi.
> > >
> > > Here is my preferred solution for untangling this:
> > > 1) Standardise on OpenSbi or Opensbi. Opensbi follows the pattern we
> > >already use for Openssl, so would be my preference.
> > > 2) Standardise on RiscVOpensbi or Opensbi - both for filenames and
> > >LibararyClasses. Either is fine, the former is less likely to clash
> > >with other imported projects in the future (but I would estimate
> > >this risk as *very* low to begin with).
> > > 3) Implement a (RiscV)OpensbiPlatformLibNull in edk2/RiscVPkg/Library,
> > I will have OpensbiPlatformLibNull  in RiscVPlatformPkg/Library
> > 
> > >containing only what is required to build/link
> > >RiscVPkg/Library/(RiscV)OpensbiLib/.
> > >3.5) Map that to OpensbiPlatformLib in RiscVPkg/RiscVPkg.dsc.
> > >3.6) Add a depedency on OpensbiPlatformLib to
> > > (RiscV)OpensbiLib.inf
> > >3.7) Drop the dependency on OpensbiPlatformLib from
> > > Platform/RiscV/Universal/Sec/SecMain.inf
> >
> > Above work for me
>
> I changed my mind. Due to SecMain is moved to RiscVPlatformPkg in
> edk2 and requires both RiscVOpensbiPlatformLib and RiscVOpensbLiib,
> SecMain.inf still has dependency with these two libs.

I am not sure I understand.

What I am saying is that OpensbiLib already has a dependency on
OpensbiPlatformLib. So there is no benefit to adding the
OpensbiPlatformLib dependency to SecMain. Or does that not work for
some reason?

Regards,

Leif

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49179): https://edk2.groups.io/g/devel/message/49179
Mute This Topic: https://groups.io/mt/34196358/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [Patch v3 02/11] BaseTools tools_def: Add CLANG9 tool chain to directly generate PE image

2019-10-17 Thread Bob Feng
Reviewed-by: Bob Feng  

-Original Message-
From: Gao, Liming 
Sent: Thursday, October 17, 2019 2:56 PM
To: devel@edk2.groups.io
Cc: Feng, Bob C 
Subject: [Patch v3 02/11] BaseTools tools_def: Add CLANG9 tool chain to 
directly generate PE image

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603

Signed-off-by: Liming Gao 
Cc: Bob Feng 
---
 BaseTools/Conf/build_rule.template |  26 ++  
BaseTools/Conf/tools_def.template  | 102 +
 2 files changed, 118 insertions(+), 10 deletions(-)

diff --git a/BaseTools/Conf/build_rule.template 
b/BaseTools/Conf/build_rule.template
index db06d3a6b4..3a58ac8015 100755
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -260,7 +260,7 @@
 
 $(OUTPUT_DIR)(+)$(MODULE_NAME).lib
 
-
+
 "$(SLINK)" $(SLINK_FLAGS) /OUT:${dst} @$(OBJECT_FILES_LIST)
 
 
@@ -291,6 +291,9 @@
 "$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK2_FLAGS) $(DLINK_SPATH) 
@$(STATIC_LIBRARY_FILES_LIST)
 "$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK_SPATH) 
@$(STATIC_LIBRARY_FILES_LIST)
 
+
+"$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK_SPATH) 
+ @$(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
+
 
 "$(DLINK)" -o ${dst} $(DLINK_FLAGS) 
-Wl,--start-group,@$(STATIC_LIBRARY_FILES_LIST),--end-group $(CC_FLAGS) 
$(DLINK2_FLAGS)
 "$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst} @@ -331,7 +334,7 @@
 
 $(DEBUG_DIR)(+)$(MODULE_NAME)
 
-
+
 "$(DLINK)" $(DLINK_FLAGS) $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST)
 
 
@@ -355,7 +358,7 @@
 
 $(OUTPUT_DIR)(+)$(MODULE_NAME).efi
 
-
+
 "$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
 $(CP) ${dst} $(DEBUG_DIR)
 $(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
@@ -460,9 +463,14 @@
 
 
 "$(ASLCC)" -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) 
$(ASLCC_FLAGS) $(INC) ${src}
-"$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll 
$(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+"$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll 
+ $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) 
+ $(ASLCC_FLAGS)
 "$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll 
$(GENFW_FLAGS)
-
+
+
+"$(ASLCC)" -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) 
$(ASLCC_FLAGS) $(INC) ${src}
+"$(ASLDLINK)" /OUT:$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll 
$(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+"$(GENFW)" -o ${dst} -c 
+ $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
+
 
 "$(ASLCC)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj  $(ASLCC_FLAGS) 
$(INC) ${src}
 "$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll 
$(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
@@ -622,21 +630,19 @@
 
 *.hpk
 
-
+
 $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.lib
 
 
 $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc
 
-
+
 "$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) 
--hiipackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS)
 "$(RC)" /Fo${dst} $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc
 
 
 "$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) 
--hiibinpackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS)
 "$(RC)" $(RC_FLAGS) $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc ${dst}
-
+
 
 GenFw -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) 
--hiibinpackage $(HII_BINARY_PACKAGES)
-
-
diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index fd6fca542d..b4bc27ab25 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -268,6 +268,15 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
 # Required to build platforms or ACPI tables:
 #   Intel(r) ACPI Compiler from
 #   https://acpica.org/downloads
+#   CLANG9   -Linux, Windows, Mac-  Requires:
+# Clang 9 or above from http://releases.llvm.org/
+#Optional:
+# Required to compile nasm source:
+#   nasm compiler from
+#   NASM -- http://www.nasm.us/
+# Required to build platforms or ACPI tables:
+#   Intel(r) ACPI Compiler from
+#   https://acpica.org/downloads
 #   VS2008x86   -win64-  Requires:
 # Microsoft Visual Studio 2008 (x86)
 # Microsoft Windows Server 2003 Driver Development 
Kit (Microsoft WINDDK) version 3790.1830
@@ -2698,6 +2707,99 @@ DEFINE CLANG38_AARCH64_DLINK_FLAGS  = 
DEF(CLANG38_AARCH64_TARGET) DEF(GCC_AARCH6
 

Re: [edk2-devel] [Patch v3 03/11] BaseTools GenFw: Fix the issue to update the wrong size as SectionSize

2019-10-17 Thread Bob Feng
Reviewed-by: Bob Feng 

-Original Message-
From: Gao, Liming 
Sent: Thursday, October 17, 2019 2:56 PM
To: devel@edk2.groups.io
Cc: Feng, Bob C 
Subject: [Patch v3 03/11] BaseTools GenFw: Fix the issue to update the wrong 
size as SectionSize

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603
CLANG9 generated PE image exposes below two issues.
1. SectionSize is used to copy PE section data. It should be smaller than 
section raw size.
2. The real data is required to be copied. So, copy the min size of VirtualSize 
and SizeOfRawData.

Signed-off-by: Liming Gao 
Cc: Bob Feng 
Reviewed-by: Philippe Mathieu-Daude 
---
 BaseTools/Source/C/GenFw/GenFw.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c
index c99782b78e..8cab70ba4d 100644
--- a/BaseTools/Source/C/GenFw/GenFw.c
+++ b/BaseTools/Source/C/GenFw/GenFw.c
@@ -653,7 +653,11 @@ PeCoffConvertImageToXip (
 //
 // Make the size of raw data in section header alignment.
 //
-SectionHeader->SizeOfRawData = (SectionHeader->Misc.VirtualSize + 
PeHdr->Pe32.OptionalHeader.FileAlignment - 1) & 
(~(PeHdr->Pe32.OptionalHeader.FileAlignment - 1));
+SectionSize = (SectionHeader->Misc.VirtualSize + 
PeHdr->Pe32.OptionalHeader.FileAlignment - 1) & 
(~(PeHdr->Pe32.OptionalHeader.FileAlignment - 1));
+if (SectionSize < SectionHeader->SizeOfRawData) {
+  SectionHeader->SizeOfRawData = SectionSize;
+}
+
 SectionHeader->PointerToRawData = SectionHeader->VirtualAddress;
   }
 
@@ -999,7 +1003,7 @@ Returns:
 CopyMem (
   FileBuffer + SectionHeader->PointerToRawData,
   (VOID*) (UINTN) (ImageContext.ImageAddress + 
SectionHeader->VirtualAddress),
-  SectionHeader->SizeOfRawData
+  SectionHeader->SizeOfRawData < SectionHeader->Misc.VirtualSize ? 
+ SectionHeader->SizeOfRawData : SectionHeader->Misc.VirtualSize
   );
   }
 
--
2.13.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49174): https://edk2.groups.io/g/devel/message/49174
Mute This Topic: https://groups.io/mt/34694437/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 10/14] U500Pkg/Library: Library instances of U500 platform library

2019-10-17 Thread Abner Chang



> -Original Message-
> From: Chang, Abner (HPS SW/FW Technologist)
> Sent: Thursday, October 17, 2019 10:21 AM
> To: devel@edk2.groups.io; leif.lindh...@linaro.org; Chen, Gilbert
> 
> Cc: Palmer Dabbelt 
> Subject: RE: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 10/14]
> U500Pkg/Library: Library instances of U500 platform library
> 
> 
> 
> > -Original Message-
> > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> > Leif Lindholm
> > Sent: Friday, October 4, 2019 12:32 AM
> > To: devel@edk2.groups.io; Chen, Gilbert 
> > Cc: Palmer Dabbelt 
> > Subject: Re: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 10/14]
> > U500Pkg/Library: Library instances of U500 platform library
> >
> > On Thu, Sep 19, 2019 at 11:51:27AM +0800, Gilbert Chen wrote:
> > > OpneSbiPlatformLib
> > > - In order to reduce the dependencies with RISC-V OpenSBI project
> > > (https://github.com/riscv/opensbi) and less burdens to EDK2 build
> > > process, the implementation of RISC-V EDK2 platform is leverage
> > > platform source code from OpenSBI code tree. The "platform.c"
> > >  under OpenSbiPlatformLib is cloned from RISC-V OpenSBI code tree
> > > (in
> > > EDK2 RiscVPkg) and built based on EDK2 build environment.
> > >
> > > PeiCoreInfoHobLib
> > > - This is the library to create RISC-V core characteristics for
> > > building  up RISC-V related SMBIOS records to support the unified
> > > boot loader  and OS image.
> > >
> > > - RiscVPlatformTimerLib
> > > This is U500 platform timer library which has the platform-specific
> > > timer implementation.
> > >
> > > - SerialPortLib
> > > U500 serial port platform library
> >
> > Please split this up into the 4 logical commits.
> > And add the specific header files with those commits.
> >
> > > Signed-off-by: Gilbert Chen 
> > > ---
> > >  .../OpenSbiPlatformLib/OpenSbiPlatformLib.inf  |  47 
> > >  .../U500Pkg/Library/OpenSbiPlatformLib/platform.c  | 214
> > ++
> > >  .../Library/PeiCoreInfoHobLib/CoreInfoHob.c| 195
> > +
> > >  .../PeiCoreInfoHobLib/PeiCoreInfoHobLib.inf|  58 +
> > >  .../RiscVPlatformTimerLib/RiscVPlatformTimerLib.S  |  48 
> > >  .../RiscVPlatformTimerLib.inf  |  39 
> > >  .../U500Pkg/Library/SerialIoLib/SerialIoLib.inf|  31 +++
> > >  .../U500Pkg/Library/SerialIoLib/SerialPortLib.c| 241
> > +
> > >  .../Library/SerialIoLib/U500SerialPortLib.uni  |  16 ++
> > >  9 files changed, 889 insertions(+)
> > >  create mode 100644
> > >
> >
> Platform/RiscV/SiFive/U500Pkg/Library/OpenSbiPlatformLib/OpenSbiPlatfo
> > > rmLib.inf  create mode 100644
> > > Platform/RiscV/SiFive/U500Pkg/Library/OpenSbiPlatformLib/platform.c
> > >  create mode 100644
> > > Platform/RiscV/SiFive/U500Pkg/Library/PeiCoreInfoHobLib/CoreInfoHob.
> > > c
> > >  create mode 100644
> > >
> >
> Platform/RiscV/SiFive/U500Pkg/Library/PeiCoreInfoHobLib/PeiCoreInfoHob
> > > Lib.inf  create mode 100644
> > > Platform/RiscV/SiFive/U500Pkg/Library/RiscVPlatformTimerLib/RiscVPla
> > > tf
> > > ormTimerLib.S  create mode 100644
> > > Platform/RiscV/SiFive/U500Pkg/Library/RiscVPlatformTimerLib/RiscVPla
> > > tf
> > > ormTimerLib.inf  create mode 100644
> > > Platform/RiscV/SiFive/U500Pkg/Library/SerialIoLib/SerialIoLib.inf
> > >  create mode 100644
> > > Platform/RiscV/SiFive/U500Pkg/Library/SerialIoLib/SerialPortLib.c
> > >  create mode 100644
> > > Platform/RiscV/SiFive/U500Pkg/Library/SerialIoLib/U500SerialPortLib.
> > > un
> > > i
> > >
> > > diff --git
> > >
> >
> a/Platform/RiscV/SiFive/U500Pkg/Library/OpenSbiPlatformLib/OpenSbiPlat
> > > formLib.inf
> > >
> >
> b/Platform/RiscV/SiFive/U500Pkg/Library/OpenSbiPlatformLib/OpenSbiPlat
> > > formLib.inf
> > > new file mode 100644
> > > index ..473386d2
> > > --- /dev/null
> > > +++
> > b/Platform/RiscV/SiFive/U500Pkg/Library/OpenSbiPlatformLib/OpenSbi
> > > +++ PlatformLib.inf
> > > @@ -0,0 +1,47 @@
> > > +## @file
> > > +#  RISC-V OpenSbi Platform Library
> > > +#  This is the the required library which provides platform
> >
> > Please don't use the word required. (If it wasn't, why would you
> > include it at
> > all?)
> >
> > > +#  level opensbi functions follow RISC-V opensbi implementation.
> > > +#
> > > +#  Copyright (c) 2019, Hewlett Packard Enterprise Development LP.
> > > +All rights reserved. # #  SPDX-License-Identifier:
> > > +BSD-2-Clause-Patent # ##
> > > +
> > > +[Defines]
> > > +  INF_VERSION= 0x00010005
> >
> > Please bump specification version.
> >
> > > +  BASE_NAME  = OpenSbiPlatformLib
> > > +  FILE_GUID  = 9424ED54-EBDA-4FB5-8FF6-8291B07BB151
> > > +  MODULE_TYPE= SEC
> > > +  VERSION_STRING = 1.0
> > > +  LIBRARY_CLASS  = OpenSbiPlatformLib
> >
> > Seeing this, I have a bit of a feeling that this Opensbi isn't being
> > consistently
> > treated/named:
> > - In 

Re: [edk2-devel] [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/BootMediaLib: Reduce library API

2019-10-17 Thread Ni, Ray
Nate,
I remember that I've agreed with current implementation.

I agree with you the library helps caller in a certain way. But another problem 
we need to solve is how to simplify platform DSC with so many library 
instances. I don't strongly prefer to merge the two library instances for this 
specific case. But we need to keep in mind that any addition of library APIs, 
library instances is actually a burden to platform developers because they need 
to make choices. (This is why I like iPhone over Android because Android opens 
so many settings to end-users.)

Thanks,
Ray

> -Original Message-
> From: Desimone, Nathaniel L 
> Sent: Thursday, October 17, 2019 3:27 PM
> To: devel@edk2.groups.io; Ni, Ray ; Kubacki, Michael A
> 
> Cc: Chaganty, Rangasai V 
> Subject: RE: [edk2-devel] [edk2-platforms][PATCH V1 1/1]
> IntelSiliconPkg/BootMediaLib: Reduce library API
> 
> Hi Ray,
> 
> This really comes down to a philosophical question of how much do we wish
> to shield the user of the BootMediaLib against the nuances of the library's
> underlying implementation.
> 
> The primary function of BootMediaLib is retrieval of state. All of the 
> functions
> in BootMediaLib are accessors: BootMediaIsSpi(), GetBootMediaType(), etc.
> Since the purpose of the library is the manipulation of stateful data, it
> generally is assumed by most programmers that the data accessors
> themselves are stateless. In simpler words, most programmers expect to be
> able to call the BootMediaIsSpi() function without having to consider what
> the current environmental context is of the system.
> 
> In your proposal, the programmer must consider if they are writing PEI, DXE,
> SMM, and RuntimeDXE code when using the BootMediaLib. I consider it very
> confusing if I was required to call BootMediaIsSpi() everywhere in PEI, while
> at the same time I was required to only call BootMediaIsSpi() from the entry
> point for SMM or RuntimeDXE drivers. Michael's solution abstracts away this
> complexity and allows a single programming model to be used everywhere.
> 
> I agree with Michael that encapsulation of the environmental state is
> desirable especially for code that is used in the implementation of UEFI
> variable services. And I recommend that the code be merged as-is.
> 
> Regards,
> Nate
> 
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Ni, Ray
> Sent: Tuesday, October 15, 2019 11:30 PM
> To: Kubacki, Michael A ;
> devel@edk2.groups.io
> Cc: Chaganty, Rangasai V 
> Subject: Re: [edk2-devel] [edk2-platforms][PATCH V1 1/1]
> IntelSiliconPkg/BootMediaLib: Reduce library API
> 
> > My concerns with that approach:
> >
> > 1. In general, I believe it is better if the library reads the value
> > once and caches it. The firmware boot media is fixed after power-on by
> > nature and in some platforms, boot media information may be provided
> > to the IBB in a temporary SRAM (or other volatile memory) early in the
> > boot flow that is temporary (e.g. not accessible after main memory
> > initialization). Here the HOB to global variable transition in DXE,
> > Runtime DXE, SMM is a transparent mechanism to the library consumers
> > to get the boot media information regardless of early boot memory
> properties.
> 
> I just feel that having two library instances increases the complexity.
> There were already arguments around EDKII like there are so many instances
> for a library class and people don't know which one is being used.
> But if you insist, I am ok with that. Removing unnecessary APIs resolved most
> of my concerns.
> 
> >
> > 2. Forcing library consumers to cache puts unnecessary burden on a
> > large number of library consumers to:
> >   1.a. Understand the library implementation (lack of encapsulation).
> 
> In fact the value of single library instance I can see is caller doesn't need 
> to
> dig into the details of the library implementation. All they need to know is
> the library gets the info from HOB every time the API is called.
> With the two lib instances, consumers need to be aware of the different
> implementations.
> I am not using this to support my point. Just providing my thought.
> 
> >   1.b. Understand the nuances of their driver type in relation to the
> > library implementation.
> 
> I think having a single instance avoids DSC writers to supply two instances 
> for
> different modules. Might be different from what you think
> 
> 
> >   1.c. Perform this evaluation every time the library is used.
> 
> Agree.
> 
> >   1.d. Implement overhead to manage the data in a global variable when
> > this could automatically be linked by the library.
> Some callers may not be aware of the lib implementation details. So they
> may still choose to cache to global variables.
> Some callers may use it only once. Having a lib global variable is also a 
> waste.
> 
> >
> > 3. If the HOB is used, it blurs the implementation between the HOB
> > producer phase (PEI) and HOB consumer phase (DXE).
> 
> Don't 

Re: [edk2-devel] [PATCH 2/4] MdeModulePkg/HiiDatabaseDxe: Add check for StringPtr

2019-10-17 Thread Dandan Bi
> -Original Message-
> From: Zhang, Shenglei
> Sent: Thursday, October 17, 2019 11:31 AM
> To: devel@edk2.groups.io
> Cc: Bi, Dandan ; Dong, Eric 
> Subject: [PATCH 2/4] MdeModulePkg/HiiDatabaseDxe: Add check for
> StringPtr
> 
> If the target string doesn't appear in the searched string, StringPtr will be
> NULL. So add a check for that.
> 
> Cc: Dandan Bi 
> Cc: Eric Dong 
> Signed-off-by: Shenglei Zhang 
> ---
>  MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> index 71ea25bc19bf..f786da8e370a 100644
> --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> @@ -909,6 +909,10 @@ CompareAndMergeDefaultString (
>// To find the  with AltConfigHdr in AltCfgResp, ignore other
>  which follow it.
>//
>StringPtr = StrStr (*AltCfgResp, AltConfigHdr);
> +  if (StringPtr == NULL) {
> +Status = EFI_NOT_FOUND;
> +goto Exit;
> +  }
Hi Shenglei,
I think we can add  ASSERT (StringPtr != NULL); here.
Since when call this function, the AltCfgResp and DefaultAltCfgResp must have 
contained the AltConfigHdr.
The caller of the CompareAndMergeDefaultString have done the check.

Thanks,
Dandan
>StringPtrNext = StrStr (StringPtr + 1, L"");
>if (StringPtrNext != NULL) {
>  TempCharA = *StringPtrNext;
> --
> 2.18.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49176): https://edk2.groups.io/g/devel/message/49176
Mute This Topic: https://groups.io/mt/34668864/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [v7 v7] IntelSiliconPkg-Vtd: A new PMR interface

2019-10-17 Thread Evelyn Wang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1770

1) IOMMU PMR feature should be generic to support different hardware
architecture. Platforms may request no overlap between PMR regions
and system reserve memory. Create an interface to control PLMR/PHMR
regions. It allows silicon code to adjust PLMR/PHMR region base on
the project needs.

2) A new GetVtdPmrAlignmentLib for silicon code to get
PMR alignment values.

Signed-off-by: Evelyn Wang 
Cc: Jenny Huang 
Cc: More Shih 
Cc: Ray Ni 
Cc: Rangasai V Chaganty 
Cc: Jiewen Yao 

---
In V2:
1) Fixed the EFIAPI is missing in library API issue
2) Logs will be provided to make sure the backwards compatibility
3) Replaced BIT0 with EFI_ACPI_DMAR_DRHD_FLAGS_INCLUDE_PCI_ALL
4) Renamed GetVtdPmrAlignmentLib to PeiGetVtdPmrAlignmentLib
5) Fixed the indent in IntelVTdPmrPei.c
6) Follow VTd spec to define the data type of the SYSTEM_MEM_INFO_HOB
   Applied few changes coordinately

---
In V3:
1) Fixed the EFIAPI is missing in library API issue
2) Fixed the S3 resume assert

---
In V4:
Fixed the missing EFIAPI in .h file and added few more comments

---
In V5:
In order to align with the future planning,
changed the hob name from SYSTEM_MEM_INFO_HOB to VTD_PMR_INFO_HOB

---
In V6:
1) Revised comments
2) Moved VtdPmrInfoHob.h under Guid folder
3) Separated to few commits

---
In V7:
1) Only the functions declared in library header file should have EFIAPI
2) Added a few comments to avoid confusion
3) Fixed a case error
---
 Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmr.c 
 |   4 ++--
 Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c  
 |  84 
+---
 
Silicon/Intel/IntelSiliconPkg/Library/PeiGetVtdPmrAlignmentLib/PeiGetVtdPmrAlignmentLib.c
   | 164 

 Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.inf
 |   5 -
 Silicon/Intel/IntelSiliconPkg/Include/Guid/VtdPmrInfoHob.h 
 |  29 +
 Silicon/Intel/IntelSiliconPkg/Include/Library/PeiGetVtdPmrAlignmentLib.h   
 |  22 ++
 Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec  
 |  11 +--
 Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dsc  
 |   3 ++-
 
Silicon/Intel/IntelSiliconPkg/Library/PeiGetVtdPmrAlignmentLib/PeiGetVtdPmrAlignmentLib.inf
 |  32 
 9 files changed, 325 insertions(+), 29 deletions(-)

diff --git 
a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmr.c 
b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmr.c
index 37283f0fab..9103e53922 100644
--- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmr.c
+++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmr.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -294,7 +294,7 @@ SetDmaProtectedRange (
   UINTN   Index;
   EFI_STATUS  Status;
 
-  DEBUG ((DEBUG_INFO, "SetDmaProtectedRange(0x%lx) - [0x%x, 0x%x] [0x%lx, 
0x%lx]\n", EngineMask, LowMemoryBase, LowMemoryLength, HighMemoryBase, 
HighMemoryLength));
+  DEBUG ((DEBUG_INFO, "SetDmaProtectedRange(0x%lx) - [0x%x, 0x%x] [0x%016lx, 
0x%016lx]\n", EngineMask, LowMemoryBase, LowMemoryLength, HighMemoryBase, 
HighMemoryLength));
 
   for (Index = 0; Index < VTdInfo->VTdEngineCount; Index++) {
 if ((EngineMask & LShiftU64(1, Index)) == 0) {
diff --git 
a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c 
b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c
index ca099ed71d..ea944aa40c 100644
--- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c
+++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -20,7 +20,7 @@
 #include 
 #include 
 #include 
-
+#include 
 #include "IntelVTdPmrPei.h"
 
 EFI_GUID mVTdInfoGuid = {
@@ -424,37 +424,79 @@ InitDmaProtection (
   UINTN   MemoryAlignment;
   UINTN   LowBottom;
   UINTN   LowTop;
-  UINTN   HighBottom;
+  UINT64  HighBottom;
   UINT64  HighTop;
   DMA_BUFFER_INFO *DmaBufferInfo;
   VOID  

Re: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 02/14] Silicon/SiFive: Add library module of SiFive RISC-V cores

2019-10-17 Thread Leif Lindholm
On Wed, Oct 16, 2019 at 01:36:07AM +, Chang, Abner (HPS SW/FW Technologist) 
wrote:
> > -Original Message-
> > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> > Leif Lindholm
> > Sent: Wednesday, October 2, 2019 5:15 AM
> > To: devel@edk2.groups.io; Chen, Gilbert 
> > Subject: Re: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 02/14]
> > Silicon/SiFive: Add library module of SiFive RISC-V cores
> > 
> > On Thu, Sep 19, 2019 at 11:51:19AM +0800, Gilbert Chen wrote:
> > > Initial version of SiFive RISC-V core libraries. Library of each core
> > > creates processor core SMBIOS data hob for building SMBIOS  records in
> > > DXE phase.
> > 
> > So yes, this implementation needs to change.
> > These should all implement the same LibraryClass.
>
> No. It shouldn't be the same library class (If you were saying the
> same LibraryClass). RISC-V SoC could be the combination of different
> RISC-V cores, or even the cores from different vendors. This depends
> on how SoC vendor combine those IPs.

Ah, OK. Sorry, did not realise this aspect.

> Either U54 or E51 could be a standalone SoC, while U54MC is the
> combination of 4 x U54 core and one E51 core.
> 
> U5MC under Platform/SiFive could be 1-8 U5 core and optionally
> support E5 core.  This is the special case for U500 VC707 platform
> because the core number could be customized.
> 
> > Also, U54 appears to be a simple superset of U51.
> U54 is a single core. 
> 
> > 
> > What I would suggest is creating a
> > Silicon/SiFive/Library/SiFiveCoreInfoLib, which calls into a
> > SiFiveSoCCoreInfoLib in Silicon/SiFive//Library, providing the acual 
> > SoC-
> > specific bits.
> 
> Platform system firmware integrator just pull in the necessary core
> libraries from Silicon/{vendor}  and invoke the function to create
> specific core bits.
>
> I think this implementation is well and flexible which has no need to change.

Oh, my criticism was that it was *too* flexible (with resulting code
overhead). I still feel the very small source differences, especially
between E51/U54, indicate that these could be implemented by the same
source file but different .inf files.

But this is not something that needs to be addressed before this patch
goes into -staging.

Regards,

Leif

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49178): https://edk2.groups.io/g/devel/message/49178
Mute This Topic: https://groups.io/mt/34196349/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [Patch v3 10/11] EmulatorPkg: Enable CLANG9 tool chain

2019-10-17 Thread Andrew Fish via Groups.Io
Ray,

Sorry I'm coming a little late to this and I'm confused. I have some questions?
1) Does CLANG9 imply CLANGPE? 
2) Does CLANGPE work on Linux and macOS? Can you pass the Windows style 
arguments to CLANGPE linker on Linux and macOS?
3) For the EmulatorPkg don't you have the extra requirement that compiler needs 
a standard C lib (or platform specific libs) to function?
a) GCC:*_CLANG9_*_DLINK_FLAGS in EmulatorPkg.dsc seems to imply the 
Linux and macOS systems will have a Windows SKD dir and a lot of Windows DLLs? 
Does all that come when you install CLANG9 when you install it on Linux or 
macOS?

So I guess I'm asking is the linker really the same for CLANG9 on all systems? 
I guess the answer could be yes, but it seems the C lib for the Host App is 
still an App for that OS and is OS dependent? 

Sorry if I'm missing something fundamental and this is a dumb question. 

Thanks,

Andrew Fish



> On Oct 17, 2019, at 12:27 AM, Ni, Ray  wrote:
> 
> Liming,
> Emulator is using a generic SEC module. The host specific module is called 
> "Host".
> So I prefer to change the macro to "WIN_HOST_BUILD", with this change, 
> Reviewed-by: Ray Ni 
> 
>> -Original Message-
>> From: Gao, Liming 
>> Sent: Thursday, October 17, 2019 2:56 PM
>> To: devel@edk2.groups.io
>> Cc: Justen, Jordan L ; Andrew Fish
>> ; Ni, Ray 
>> Subject: [Patch v3 10/11] EmulatorPkg: Enable CLANG9 tool chain
>> 
>> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603
>> 1. Add WIN_SEC_BUILD macro check for CLANG9 tool chain build -p
>> EmulatorPkg\EmulatorPkg.dsc -a IA32 -DWIN_SEC_BUILD=TRUE -t CLANG9
>> build -p EmulatorPkg\EmulatorPkg.dsc -a X64 -DWIN_SEC_BUILD=TRUE -t
>> CLANG9 2. Append CLANG CC and LINK flags to generate windows HOST.
>> 3. Fix WinHost issue to call GetProcessAffinityMask() API.
>>   The input parameter should be UINTN pointer instead of UINT32 pointer.
>> 
>> Cc: Jordan Justen 
>> Cc: Andrew Fish 
>> Cc: Ray Ni 
>> Signed-off-by: Liming Gao 
>> ---
>> EmulatorPkg/Win/Host/WinHost.c   | 6 +++---
>> EmulatorPkg/EmulatorPkg.dsc  | 7 ++-
>> EmulatorPkg/Win/Host/WinHost.inf | 6 ++
>> 3 files changed, 15 insertions(+), 4 deletions(-)
>> 
>> diff --git a/EmulatorPkg/Win/Host/WinHost.c
>> b/EmulatorPkg/Win/Host/WinHost.c index 9aba3c8959..e40ce32548 100644
>> --- a/EmulatorPkg/Win/Host/WinHost.c
>> +++ b/EmulatorPkg/Win/Host/WinHost.c
>> @@ -356,7 +356,7 @@ Returns:
>> INTN
>> EFIAPI
>> main (
>> -  IN  INTN  Argc,
>> +  IN  INT  Argc,
>>   IN  CHAR8 **Argv,
>>   IN  CHAR8 **Envp
>>   )
>> @@ -391,8 +391,8 @@ Returns:
>>   VOID  *SecFile;
>>   CHAR16*MemorySizeStr;
>>   CHAR16*FirmwareVolumesStr;
>> -  UINT32ProcessAffinityMask;
>> -  UINT32SystemAffinityMask;
>> +  UINTN ProcessAffinityMask;
>> +  UINTN SystemAffinityMask;
>>   INT32 LowBit;
>> 
>>   //
>> diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
>> index 20f1187713..72532f5daf 100644
>> --- a/EmulatorPkg/EmulatorPkg.dsc
>> +++ b/EmulatorPkg/EmulatorPkg.dsc
>> @@ -237,9 +237,10 @@
>> 
>> [Components]
>> !if "IA32" in $(ARCH) || "X64" in $(ARCH)
>> -  !if "MSFT" in $(FAMILY)
>> +  !if "MSFT" in $(FAMILY) || $(WIN_SEC_BUILD) == TRUE
>> ##
>> #  Emulator, OS WIN application
>> +#  CLANG9 is cross OS tool chain. It depends on WIN_SEC_BUILD macro.
>> ##
>> EmulatorPkg/Win/Host/WinHost.inf
>>   !else
>> @@ -419,7 +420,11 @@
>> 
>>   MSFT:DEBUG_*_*_CC_FLAGS = /Od /Oy-
>>   MSFT:NOOPT_*_*_CC_FLAGS = /Od /Oy-
>> +  GCC:DEBUG_CLANG9_*_CC_FLAGS =-O0 -Wno-unused-command-line-
>> argument
>> + -Wno-incompatible-pointer-types -Wno-enum-conversion
>> + -Wno-incompatible-pointer-types -Wno-sometimes-uninitialized
>> + -Wno-constant-conversion -Wno-main-return-type
>> 
>>   MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096 /FILEALIGN:4096
>> /SUBSYSTEM:CONSOLE
>>   MSFT:DEBUG_*_*_DLINK_FLAGS =
>> /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x1
>>   MSFT:NOOPT_*_*_DLINK_FLAGS =
>> /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x1
>> +  GCC:*_CLANG9_*_DLINK_FLAGS = /ALIGN:4096 /FILEALIGN:4096
>> /SUBSYSTEM:CONSOLE
>> +  GCC:DEBUG_CLANG9_*_DLINK_FLAGS =
>> + /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x1
>> + GCC:NOOPT_CLANG9_*_DLINK_FLAGS =
>> + /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x1
>> diff --git a/EmulatorPkg/Win/Host/WinHost.inf
>> b/EmulatorPkg/Win/Host/WinHost.inf
>> index 631d5a6470..1adca10d79 100644
>> --- a/EmulatorPkg/Win/Host/WinHost.inf
>> +++ b/EmulatorPkg/Win/Host/WinHost.inf
>> @@ -95,3 +95,9 @@
>>   MSFT:*_VS2017_X64_DLINK_FLAGS  =
>> /LIBPATH:"%VCToolsInstallDir%lib\x64"
>> /LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64"
>> /LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x64"
>> /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP
>> /OPT:REF /DEBUG /MACHINE:AMD64 /LTCG Kernel32.lib MSVCRTD.lib

Re: [edk2-devel] [RFC v1 5/4] CryptoPkg/TlsLib: accept peer certs via both DNS names and IP addresses

2019-10-17 Thread David Woodhouse
On Thu, 2019-10-17 at 17:35 +0200, Laszlo Ersek wrote:
> Reference [2] advises to put the IP address in both CN and
> SAN.iPAddress
> for best compatibility, and that would be fine, for
> X509_VERIFY_PARAM_set1_ip(). But the word "only" in [3] is really bad
> for X509_VERIFY_PARAM_set1_ip().

I don't believe it's true, and it conflicts with what's in [2] which
suggests that you do it properly *and* put it in the legacy CN for the
benefit of broken clients.

None of this convinces me that EDK2 should deliberately be one of those
"broken clients". Just fix it. Let people worry about compatibility
with historical buggy versions of proprietary operating systems when
they issue their certs.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49183): https://edk2.groups.io/g/devel/message/49183
Mute This Topic: https://groups.io/mt/34551672/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



smime.p7s
Description: S/MIME cryptographic signature


Re: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 10/14] U500Pkg/Library: Library instances of U500 platform library

2019-10-17 Thread Abner Chang



> -Original Message-
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Leif Lindholm
> Sent: Thursday, October 17, 2019 7:19 PM
> To: devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist)
> 
> Cc: Chen, Gilbert ; Palmer Dabbelt
> 
> Subject: Re: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 10/14]
> U500Pkg/Library: Library instances of U500 platform library
> 
> On Thu, Oct 17, 2019 at 07:44:47AM +, Abner Chang wrote:
> > > -Original Message-
> > > From: Chang, Abner (HPS SW/FW Technologist)
> > > Sent: Thursday, October 17, 2019 10:21 AM
> > > To: devel@edk2.groups.io; leif.lindh...@linaro.org; Chen, Gilbert
> > > 
> > > Cc: Palmer Dabbelt 
> > > Subject: RE: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 10/14]
> > > U500Pkg/Library: Library instances of U500 platform library
> 
> > > > Seeing this, I have a bit of a feeling that this Opensbi isn't
> > > > being consistently
> > > > treated/named:
> > > > - In edk2, we have RiscVPkg/Library/RiscVOpensbiLib which implements
> > > >   class RiscVOpensbiLib.
> > > > - Here, we have U500Pkg/Library/OpenSbiPlatformLib implementing
> the
> > > >   class OpenSbiPlatformLib.
> > > > - *Logically*, what we have is
> > > >   Platform/RiscV/Universal/Sec/SecMain.inf which depends on the
> > > >   OpensbiLib which depends on the OpenSbiPlatformLib.
> > > >   - However, there is no OpenSbiPlatformLib in edk2, which is very
> > > > unfortunate because that does not let us build edk2/RiscVPkg in
> > > > isolation (like we can with all the other packages in edk2).
> > > Will name it as Opensbi.
> > > >
> > > > Here is my preferred solution for untangling this:
> > > > 1) Standardise on OpenSbi or Opensbi. Opensbi follows the pattern we
> > > >already use for Openssl, so would be my preference.
> > > > 2) Standardise on RiscVOpensbi or Opensbi - both for filenames and
> > > >LibararyClasses. Either is fine, the former is less likely to clash
> > > >with other imported projects in the future (but I would estimate
> > > >this risk as *very* low to begin with).
> > > > 3) Implement a (RiscV)OpensbiPlatformLibNull in
> > > > edk2/RiscVPkg/Library,
> > > I will have OpensbiPlatformLibNull  in RiscVPlatformPkg/Library
> > >
> > > >containing only what is required to build/link
> > > >RiscVPkg/Library/(RiscV)OpensbiLib/.
> > > >3.5) Map that to OpensbiPlatformLib in RiscVPkg/RiscVPkg.dsc.
> > > >3.6) Add a depedency on OpensbiPlatformLib to
> > > > (RiscV)OpensbiLib.inf
> > > >3.7) Drop the dependency on OpensbiPlatformLib from
> > > > Platform/RiscV/Universal/Sec/SecMain.inf
> > >
> > > Above work for me
> >
> > I changed my mind. Due to SecMain is moved to RiscVPlatformPkg in
> > edk2 and requires both RiscVOpensbiPlatformLib and RiscVOpensbLiib,
> > SecMain.inf still has dependency with these two libs.
> 
> I am not sure I understand.
> 
> What I am saying is that OpensbiLib already has a dependency on
> OpensbiPlatformLib. So there is no benefit to adding the OpensbiPlatformLib
> dependency to SecMain. Or does that not work for some reason?

In order to make those dependencies correct, below is the new changes,

RiscVOpensbiPlatformLib has NO dependency with RiscVOpensbiLib.
RiscVOpensbiLib has NO dependency with RiscVOpensbiPlatformLib.
SecMain.inf has dependencies with both RiscVOpensbiPlatformLib and 
RiscVOpensbiLib because SecMain.inf needs the functionalities of those libs.
Abner
> 
> Regards,
> 
> Leif
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49184): https://edk2.groups.io/g/devel/message/49184
Mute This Topic: https://groups.io/mt/34196358/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-1 PATCH V4] MdePkg/Protocols: New interface, EFI encodings to PCI Plat protocol

2019-10-17 Thread Javeed, Ashraf
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1954

New interface added to PCI Platform Protocol / PCI Override Protocol to
retrieve device-specific platform policy for the following PCI standard
features, like Maximum Payload Size (MPS), Maximum Read Request Size
(MRRS),Extended Tags, Relax Order, No-Snoop, Active State Power Management
(ASPM),Latency Time Reporting (LTR), AtomicOp, Reference Clock
Configuration, Extended SYNCH, PTM support, and Completion Timeout (CTO).
New source files added with enhanced definitions are in:
MdePkg/Include/Protocol/PciPlatform2.h,
MdePkg/Include/Protocol/PciOverride2.h

Signed-off-by: Ashraf Javeed 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Ray Ni 
---

In V4: Redefinition of the existing interfaces in the EFI_PCI_PLATFORM_-
PROTOCOL2, to avoid type casting and to avoid further future change

In V3: License update in the header sections of source files

In V2: Correction made to header sections of source files
---
 MdePkg/Include/Protocol/PciOverride2.h |  37 
+
 MdePkg/Include/Protocol/PciPlatform2.h | 524 

 MdePkg/MdePkg.dec  |   6 ++
 3 files changed, 567 insertions(+)

diff --git a/MdePkg/Include/Protocol/PciOverride2.h 
b/MdePkg/Include/Protocol/PciOverride2.h
new file mode 100644
index 00..7e878a4f1e
--- /dev/null
+++ b/MdePkg/Include/Protocol/PciOverride2.h
@@ -0,0 +1,37 @@
+/** @file
+  This file declares EFI PCI Override protocol which provides the interface 
between
+  the PCI bus driver/PCI Host Bridge Resource Allocation driver and an 
implementation's
+  driver to describe the unique features of a platform.
+  This protocol is optional.
+
+Copyright (c) 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+
+**/
+
+#ifndef _PCI_OVERRIDE2_H_
+#define _PCI_OVERRIDE2_H_
+
+///
+/// EFI_PCI_OVERRIDE_PROTOCOL has the same structure with 
EFI_PCI_PLATFORM_PROTOCOL
+///
+#include 
+
+///
+/// Global ID for the EFI_PCI_OVERRIDE_PROTOCOL
+///
+#define EFI_PCI_OVERRIDE2_GUID \
+  { \
+0xb9d5ea1, 0x66cb, 0x4546, {0xb0, 0xbb, 0x5c, 0x6d, 0xae, 0xd9, 0x42, 
0x47} \
+  }
+
+///
+/// Declaration for EFI_PCI_OVERRIDE_PROTOCOL
+///
+typedef EFI_PCI_PLATFORM_PROTOCOL2 EFI_PCI_OVERRIDE_PROTOCOL2;
+
+
+extern EFI_GUID   gEfiPciOverrideProtocol2Guid;
+
+#endif
diff --git a/MdePkg/Include/Protocol/PciPlatform2.h 
b/MdePkg/Include/Protocol/PciPlatform2.h
new file mode 100644
index 00..6dcae70d6d
--- /dev/null
+++ b/MdePkg/Include/Protocol/PciPlatform2.h
@@ -0,0 +1,524 @@
+/** @file
+  This file declares PCI Platform Protocol that provide the interface between
+  the PCI bus driver/PCI Host Bridge Resource Allocation driver and a 
platform-specific
+  driver to describe the unique features of a platform.
+  This protocol is optional.
+
+Copyright (c) 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+
+**/
+
+#ifndef _PCI_PLATFORM2_H_
+#define _PCI_PLATFORM2_H_
+
+///
+/// This file must be included because the EFI_PCI_PLATFORM_PROTOCOL2 uses
+/// EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE.
+///
+#include 
+
+///
+/// This file is included to reuse the existing PCI Platform data structure
+/// definitions of EFI_PCI_EXECUTION_PHASE,EFI_PCI_PLATFORM_POLICY
+///
+#include 
+
+///
+/// Global ID for the EFI_PCI_PLATFORM_PROTOCOL2.
+///
+#define EFI_PCI_PLATFORM_PROTOCOL2_GUID \
+  { \
+0x787b0367, 0xa945, 0x4d60, {0x8d, 0x34, 0xb9, 0xd1, 0x88, 0xd2, 0xd0, 
0xb6} \
+  }
+
+///
+/// As per the present definition and specification of this protocol, the major
+/// version is 1, and minor version is 1. Any driver utilizing this protocol
+/// shall use these versions number to maintain the backward compatibility as
+/// per its specification changes in future.
+///
+enum EfiPciPlatformProtocolVersion {
+  EFI_PCI_PLATFORM_PROTOCOL_MAJOR_VERSION = 1,
+  EFI_PCI_PLATFORM_PROTOCOL_MINOR_VERSION = 1
+};
+
+///
+/// Forward declaration for EFI_PCI_PLATFORM_PROTOCOL2.
+///
+typedef struct _EFI_PCI_PLATFORM_PROTOCOL2 EFI_PCI_PLATFORM_PROTOCOL2;
+
+///
+/// Related Definitions
+///
+
+///
+/// Following are the data types for EFI_PCI_PLATYFORM_EXTENDED_POLICY
+/// each for the PCI standard feature and its corresponding bitmask
+/// representing the valid combinations of PCI attributes
+///
+
+///
+/// This data type is to retrieve the PCI device platform policy for the PCI-
+/// compliant feature Maximum 

Re: [edk2-devel] [edk2-platforms][PATCH 1/1] SfcPkg: Add new package

2019-10-17 Thread Leif Lindholm
First of all, could you respin this to align more with what's
described in
https://github.com/tianocore/edk2-platforms/blob/about/Readme.md
?

Specifically, it should be visible from the Readme.md (not just the
Maintainers.txt history) who owns the branch (you).

Secondly, I would prefer SolarFlarePkg - the one redeeming factor of
CamelCase is that it eliminates guessing.

Some Bikeshedding and nitpicking below:

On Thu, Oct 17, 2019 at 05:19:44PM +0100, Tomas Pilar wrote:
> This package is for Solarflare Communications drivers and utilities.
> 
> Signed-off-by: Tomas Pilar 
> Cc: Leif Lindholm 
> Cc: Michael D Kinney 
> ---
>  Drivers/SfcPkg/Readme.md | 11 +++
>  Maintainers.txt  |  4 
>  Readme.md|  7 +++
>  3 files changed, 22 insertions(+)
>  create mode 100644 Drivers/SfcPkg/Readme.md
> 
> diff --git a/Drivers/SfcPkg/Readme.md b/Drivers/SfcPkg/Readme.md
> new file mode 100644
> index 00..b26b0bbc8c
> --- /dev/null
  > +++ b/Drivers/SfcPkg/Readme.md
> @@ -0,0 +1,11 @@
> +Drivers and utilities for Solarflare Communications network adapters
> +
> +## Contact
> +
> +* [Website] (www.solarflare.com)
> +* [Support] (supp...@solarflare.com)

Umm...
Is your support department aware that they are now supporting an
in-progress version of an open source UEFI driver?

> +
> +## Licence
> +
> +The contents are licenced under BSD-2-Clause-Patent licence. +See top level
> Licence.txt in the edk2-platforms repository.

Link to it, markdown-style.

> \ No newline at end of file

*cough*

> diff --git a/Maintainers.txt b/Maintainers.txt
> index 1260c8d246..a293e7ebaa 100644
> --- a/Maintainers.txt
> +++ b/Maintainers.txt
> @@ -52,6 +52,10 @@ M: Leif Lindholm 
>  M: Ard Bieshuevel 
>  R: Andy Hayes 
>  +Drivers/SfcPkg

How did that happen? The '+' should have one fewer indent.
Preferably add a blank line before this section.

> +M: Leif Lindholm 
> +R: Tomas Pilar 
> +
>  Platform
>  M: Ard Biesheuvel 
>  M: Leif Lindholm 
> diff --git a/Readme.md b/Readme.md
> index 2b54b8e0b4..4de427bc69 100644
> --- a/Readme.md
> +++ b/Readme.md
> @@ -247,6 +247,13 @@ For more information, see the
>  ## Socionext
>  * [SynQuacer](Platform/Socionext/DeveloperBox)
>  +# IHV Drivers

More weird indentation.
Ah:
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 
Thunderbird/60.8.0

Yeah, you need to submit patches with git send-email. I'll also take
them on a publicly accessible branch, as long as the email copy isn't
badly enough corrupted that it complicates review.

Best Regards,

Leif

> +
> +These are independent hardware vendor products currently supported by
> +fimware, drivers and utilities in this tree.
> +
> +## Solarflare Communications
> +
>  # Maintainers
>   See [Maintainers.txt](Maintainers.txt).
> -- 
> 2.21.0
> 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49191): https://edk2.groups.io/g/devel/message/49191
Mute This Topic: https://groups.io/mt/34704345/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms][PATCH 0/1] New pkg for Solarflare Communications

2019-10-17 Thread Tomas Pilar (tpilar)

I would like to add a new package to support Solarflare Communications
adapters. This package will eventually host drivers and utilities for
a number of products, most of them network adapters.

Ideally, I would like this to start with a devel-sfc branch. Leif
helpfully offered to do git lifting for me.

Tomas Pilar (1):
  SfcPkg: Add new package

 Drivers/SfcPkg/Readme.md | 11 +++
 Maintainers.txt  |  4 
 Readme.md|  7 +++
 3 files changed, 22 insertions(+)
 create mode 100644 Drivers/SfcPkg/Readme.md

--
2.21.0


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49185): https://edk2.groups.io/g/devel/message/49185
Mute This Topic: https://groups.io/mt/34704344/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [Patch v3 00/11] New Cross OS tool chain CLANG9

2019-10-17 Thread Leif Lindholm
Hi Liming,

I had missed that this set was out for review (I would appreciate a cc
on any future revisions).

On Thu, Oct 17, 2019 at 02:55:44PM +0800, Liming Gao wrote:
> In v3, add the detail commit message for patch 3. 
> Update the fix in EmulatorPkg based on the comments.
> 
> In v2, drop patch 12, and update commit message for 5 & 11.
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603
> Code: https://github.com/lgao4/edk2/tree/CLANG9

This branch does not appear to have been updated since 5 September, so
it does not contain the version of the code sent out in this set. (And
I can find no other obvious branch in that repository that may hold
it.) Could you push an updated one please?

One thing that strikes me as problematic with the version on the
branch is that the set imports bits from GCC48 *and* GCC5. That seems
like a maintenance hazard, but may no longer be the case for the
current version of the set?

Best Regards,

Leif

> Wiki: https://github.com/lgao4/edk2/wiki/CLANG9-Tools-Chain
> 
> CLANG9 tool chain is added to directly generate PE/COFF image (EFI image).
> This tool chain uses LLVM clang C compiler and lld linker, generates PE/COFF
> image and PDB compatible debug symbol format. Now, it supports IA32/X64 Archs.
> It must use LLVM 9 or above release. LLVM 9 is ready on 
> http://releases.llvm.org/download.html#9.0.0.
> 
> CLANG9 is the cross OS tool chain. It can work on Windows/Linux/Mac host OS. 
> For the same source code, with the same version LLVM tool chain, 
> CLANG9 can generate the same binary image. So, the developer can 
> choose the different development environment and work on the same 
> code base. Besides, EDKII project build also requires third party 
> tools: nasm and iasl. They both keep the same version. If so, the same 
> binary image can be generated on the different host OS.
> 
> LLVM tool chain provides the compiler and linker. To build EDK2 project, 
> some other tools are still required. On Windows OS, nmake and Visual Studio 
> are required to call Makefile and compile BaseTools C tools. 
> On Linux/Mac, binutils and gcc are required to make and compile BaseTools 
> C tools. Because VS or GCC are mainly used to compile BaseTools and provide 
> nmake/make tool, they can keep on the stable version without update.
> 
> To build source code, CLANG9 tool chain (-t CLANG9) can be specified
> on Windows OS, set CLANG_HOST_BIN=n, set CLANG9_BIN=LLVM installed directory
> CLANG_HOST_BIN is used CLANG_HOST_PREFIX. Prefix n is for nmake.
> For example:
> *  set CLANG_HOST_BIN=n
> *  set CLANG9_BIN=C:\Program Files\LLVM\bin\
> *  set IASL_PREFIX=C:\Asl\
> 
> On Linux/Mac, export CLANG9_BIN=LLVM installed directory, CLANG_HOST_BIN is 
> not required, because there is no prefix for make.
> For example:
> *  export CLANG9_BIN=/home/clang9/bin/
> 
> Now, CLANG9 tool chain has been verified in Edk2 packages and Ovmf/Emulator
> with LLVM 9.0.0 on Windows and Linux OS. 
> OVMF IA32/X64/IA32X64 all boots to Shell on Windows and Linux OS. 
> Emulator can boot to Shell on Windows only with CLANG9.
> OVMF Ia32X64 RELEASE build generates the same BIOS images on Windows and 
> Linux OS.
> 
> Cc: Jiewen Yao 
> Cc: Steven Shi 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> Cc: Andrew Fish 
> Cc: Ray Ni 
> Cc: Ard Biesheuvel 
> Cc: Jian J Wang 
> Cc: Hao A Wu 
> Cc: Bob Feng 
> Cc: Michael D Kinney 
> 
> Liming Gao (11):
>   BaseTools tools_def.template: Remove unnecessary $(DEST_DIR_DEBUG)
> path
>   BaseTools tools_def: Add CLANG9 tool chain to directly generate PE
> image
>   BaseTools GenFw: Fix the issue to update the wrong size as SectionSize
>   MdePkg Base.h: Add definition for CLANG9 tool chain
>   MdePkg BaseIoLibIntrinsic: Remove __inline__ attribute for IO
> functions
>   MdeModulePkg LzmaCustomDecompressLib: Update macro to be same in CLANG
> tool
>   MdeModulePkg RegularExpressionDxe: Disable warning for CLANG9 tool
> chain
>   CryptoPkg: Append options to make CLANG9 tool chain pass build
>   CryptoPkg IntrinsicLib: Make _fltused always be used
>   EmulatorPkg: Enable CLANG9 tool chain
>   OvmfPkg: Enable CLANG9 tool chain
> 
>  BaseTools/Source/C/GenFw/GenFw.c   |   8 +-
>  CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c  |  10 +-
>  EmulatorPkg/Win/Host/WinHost.c |   6 +-
>  MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c   |   6 -
>  BaseTools/Conf/build_rule.template |  26 +++--
>  BaseTools/Conf/tools_def.template  | 124 
> +++--
>  CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf|   1 +
>  CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf |   1 +
>  CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf |   1 +
>  CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf |   1 +
>  CryptoPkg/Library/OpensslLib/OpensslLib.inf|   1 +
>  CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf  |   1 +
>  EmulatorPkg/EmulatorPkg.dsc|   7 +-
> 

[edk2-devel] [edk2-platforms][PATCH 1/1] SfcPkg: Add new package

2019-10-17 Thread Tomas Pilar (tpilar)

This package is for Solarflare Communications drivers and utilities.

Signed-off-by: Tomas Pilar 
Cc: Leif Lindholm 
Cc: Michael D Kinney 
---
 Drivers/SfcPkg/Readme.md | 11 +++
 Maintainers.txt  |  4 
 Readme.md|  7 +++
 3 files changed, 22 insertions(+)
 create mode 100644 Drivers/SfcPkg/Readme.md

diff --git a/Drivers/SfcPkg/Readme.md b/Drivers/SfcPkg/Readme.md
new file mode 100644
index 00..b26b0bbc8c
--- /dev/null
+++ b/Drivers/SfcPkg/Readme.md
@@ -0,0 +1,11 @@
+Drivers and utilities for Solarflare Communications network adapters
+
+## Contact
+
+* [Website] (www.solarflare.com)
+* [Support] (supp...@solarflare.com)
+
+## Licence
+
+The contents are licenced under BSD-2-Clause-Patent licence. +See top 
level Licence.txt in the edk2-platforms repository.

\ No newline at end of file
diff --git a/Maintainers.txt b/Maintainers.txt
index 1260c8d246..a293e7ebaa 100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -52,6 +52,10 @@ M: Leif Lindholm 
 M: Ard Bieshuevel 
 R: Andy Hayes 
 +Drivers/SfcPkg
+M: Leif Lindholm 
+R: Tomas Pilar 
+
 Platform
 M: Ard Biesheuvel 
 M: Leif Lindholm 
diff --git a/Readme.md b/Readme.md
index 2b54b8e0b4..4de427bc69 100644
--- a/Readme.md
+++ b/Readme.md
@@ -247,6 +247,13 @@ For more information, see the
 ## Socionext
 * [SynQuacer](Platform/Socionext/DeveloperBox)
 +# IHV Drivers
+
+These are independent hardware vendor products currently supported by
+fimware, drivers and utilities in this tree.
+
+## Solarflare Communications
+
 # Maintainers
  See [Maintainers.txt](Maintainers.txt).
--
2.21.0


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49186): https://edk2.groups.io/g/devel/message/49186
Mute This Topic: https://groups.io/mt/34704345/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 10/14] U500Pkg/Library: Library instances of U500 platform library

2019-10-17 Thread Leif Lindholm
On Thu, Oct 17, 2019 at 04:09:44PM +, Abner Chang wrote:
> > -Original Message-
> > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> > Leif Lindholm
> > Sent: Thursday, October 17, 2019 7:19 PM
> > To: devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist)
> > 
> > Cc: Chen, Gilbert ; Palmer Dabbelt
> > 
> > Subject: Re: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 10/14]
> > U500Pkg/Library: Library instances of U500 platform library
> > 
> > On Thu, Oct 17, 2019 at 07:44:47AM +, Abner Chang wrote:
> > > > -Original Message-
> > > > From: Chang, Abner (HPS SW/FW Technologist)
> > > > Sent: Thursday, October 17, 2019 10:21 AM
> > > > To: devel@edk2.groups.io; leif.lindh...@linaro.org; Chen, Gilbert
> > > > 
> > > > Cc: Palmer Dabbelt 
> > > > Subject: RE: [edk2-devel] [plaforms/devel-riscv-v2 PATCHv2 10/14]
> > > > U500Pkg/Library: Library instances of U500 platform library
> > 
> > > > > Seeing this, I have a bit of a feeling that this Opensbi isn't
> > > > > being consistently
> > > > > treated/named:
> > > > > - In edk2, we have RiscVPkg/Library/RiscVOpensbiLib which implements
> > > > >   class RiscVOpensbiLib.
> > > > > - Here, we have U500Pkg/Library/OpenSbiPlatformLib implementing
> > the
> > > > >   class OpenSbiPlatformLib.
> > > > > - *Logically*, what we have is
> > > > >   Platform/RiscV/Universal/Sec/SecMain.inf which depends on the
> > > > >   OpensbiLib which depends on the OpenSbiPlatformLib.
> > > > >   - However, there is no OpenSbiPlatformLib in edk2, which is very
> > > > > unfortunate because that does not let us build edk2/RiscVPkg in
> > > > > isolation (like we can with all the other packages in edk2).
> > > > Will name it as Opensbi.
> > > > >
> > > > > Here is my preferred solution for untangling this:
> > > > > 1) Standardise on OpenSbi or Opensbi. Opensbi follows the pattern we
> > > > >already use for Openssl, so would be my preference.
> > > > > 2) Standardise on RiscVOpensbi or Opensbi - both for filenames and
> > > > >LibararyClasses. Either is fine, the former is less likely to clash
> > > > >with other imported projects in the future (but I would estimate
> > > > >this risk as *very* low to begin with).
> > > > > 3) Implement a (RiscV)OpensbiPlatformLibNull in
> > > > > edk2/RiscVPkg/Library,
> > > > I will have OpensbiPlatformLibNull  in RiscVPlatformPkg/Library
> > > >
> > > > >containing only what is required to build/link
> > > > >RiscVPkg/Library/(RiscV)OpensbiLib/.
> > > > >3.5) Map that to OpensbiPlatformLib in RiscVPkg/RiscVPkg.dsc.
> > > > >3.6) Add a depedency on OpensbiPlatformLib to
> > > > > (RiscV)OpensbiLib.inf
> > > > >3.7) Drop the dependency on OpensbiPlatformLib from
> > > > > Platform/RiscV/Universal/Sec/SecMain.inf
> > > >
> > > > Above work for me
> > >
> > > I changed my mind. Due to SecMain is moved to RiscVPlatformPkg in
> > > edk2 and requires both RiscVOpensbiPlatformLib and RiscVOpensbLiib,
> > > SecMain.inf still has dependency with these two libs.
> > 
> > I am not sure I understand.
> > 
> > What I am saying is that OpensbiLib already has a dependency on
> > OpensbiPlatformLib. So there is no benefit to adding the OpensbiPlatformLib
> > dependency to SecMain. Or does that not work for some reason?
> 
> In order to make those dependencies correct, below is the new changes,
> 
> RiscVOpensbiPlatformLib has NO dependency with RiscVOpensbiLib.
> RiscVOpensbiLib has NO dependency with RiscVOpensbiPlatformLib.
> SecMain.inf has dependencies with both RiscVOpensbiPlatformLib and
> RiscVOpensbiLib because SecMain.inf needs the functionalities of
> those libs.

Ah, OK - this is new for v3 then?
In that case, sure, the above sounds fine.

Regards,

Leif

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49188): https://edk2.groups.io/g/devel/message/49188
Mute This Topic: https://groups.io/mt/34196358/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH V4 07/10] MdeModulePkg/Variable: Add RT GetVariable() cache support

2019-10-17 Thread Kubacki, Michael A
Jian, thanks a lot your analysis. The intention was very much to constrain the 
flow of information
from SMM to the non-SMM environment and not vice versa during runtime cache 
operation.

I agree that the buffers pointed to in 
SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT
should be checked with VariableSmmIsBufferOutsideSmmValid (). I will send a V5 
with this change.

Thanks,
Michael

> -Original Message-
> From: Wang, Jian J 
> Sent: Thursday, October 17, 2019 7:23 AM
> To: Wu, Hao A ; Kubacki, Michael A
> ; devel@edk2.groups.io
> Cc: Bi, Dandan ; Ard Biesheuvel
> ; Dong, Eric ; Laszlo Ersek
> ; Gao, Liming ; Kinney, Michael
> D ; Ni, Ray ; Yao, Jiewen
> 
> Subject: RE: [PATCH V4 07/10] MdeModulePkg/Variable: Add RT
> GetVariable() cache support
> 
> >
> > Again, I would like to ask for help from other reviewers to look at this 
> > patch
> > (patch 7/10) and the next one (patch 8/10) (at least from the security
> > perspective). Any help will be appreciated, thanks in advance.
> >
> 
> I'm trying to do a simple analysis below from security perspective. Please
> correct me
> if anything wrong.
> 
> The patch added 3 new SMI variable Functions
>   f(a):
> SMM_VARIABLE_FUNCTION_INIT_RUNTIME_VARIABLE_CACHE_CONTEXT
>   f(b): SMM_VARIABLE_FUNCTION_SYNC_RUNTIME_CACHE
>   f(c): SMM_VARIABLE_FUNCTION_GET_RUNTIME_CACHE_INFO
> 
> f(a) communication buffer is type of
>   SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT
> 
> which is defined as
>   typedef struct {
> BOOLEAN *ReadLock;
> BOOLEAN *PendingUpdate;
> BOOLEAN *HobFlushComplete;
> VARIABLE_STORE_HEADER   *RuntimeHobCache;
>VARIABLE_STORE_HEADER   *RuntimeNvCache;
> VARIABLE_STORE_HEADER   *RuntimeVolatileCache;
>   }
> SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT;
> 
> There're 6 fields (all pointers) in the buffer. SMM will handle them in
> following ways
> - ReadLock and PendingUpdate are used to avoid race condition between
> smm and
>   non-smm code. I don't think there's security breach here.
> - RuntimeHobCache, RuntimeNvCache and RuntimeVolatileCache are buffers
> passed
>   to smm  code to simply store variable content. Smm code will not read its
> content.
>   I think this won't bring any security risk.
> 
> The SmmVariableHandler() will call VariableSmmIsBufferOutsideSmmValid()
> to make sure the communication buffer is outside of smram. But the handler
> will
> not check the above 6 pointers passed through communication buffer to see
> if they
> are in non-smram scope. This leaves potential security hole to allow smram
> buffer
> to be passed in from non-smm code.
> 
> f(b) doesn't use communication buffer. It's just used to flush variable cache.
> Then
> no security risk here.
> 
> f(c) uses communication buffer with type of
> 
>   typedef struct {
> UINTN   TotalHobStorageSize;
> UINTN   TotalNvStorageSize;
> UINTN   TotalVolatileStorageSize;
> BOOLEAN AuthenticatedVariableUsage;
>   } SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO;
> 
> There's no pointer in the buffer and the SMI handler doesn't read its content
> but
> just store data into it. I think there's no security risk here.
> 
> I also checked data flow newly introduced between smm and non-smm
> boundary.
> Most of the data flow is just from smm to non-smm. The only exception is
> ReadLock
> mentioned above. Generally speaking, I don't find security issue in this patch
> series
> except to above pointers passed by communication buffer.
> 
> Regards,
> Jian
> 
> > -Original Message-
> > From: Wu, Hao A 
> > Sent: Wednesday, October 16, 2019 3:57 PM
> > To: Kubacki, Michael A ;
> devel@edk2.groups.io
> > Cc: Bi, Dandan ; Ard Biesheuvel
> > ; Dong, Eric ; Laszlo
> Ersek
> > ; Gao, Liming ; Kinney,
> Michael D
> > ; Ni, Ray ; Wang, Jian J
> > ; Yao, Jiewen 
> > Subject: RE: [PATCH V4 07/10] MdeModulePkg/Variable: Add RT
> GetVariable()
> > cache support
> >
> > Again, I would like to ask for help from other reviewers to look at this 
> > patch
> > (patch 7/10) and the next one (patch 8/10) (at least from the security
> > perspective). Any help will be appreciated, thanks in advance.
> >
> >
> > One comment inherited from the feedback on the V2 series:
> > I saw AtRuntime() is still being added in file VariableSmmRuntimeDxe.c,
> could
> > you help to double confirm?
> >
> > Another general level comment is that:
> > Please help to update the MdeModulePkg.uni file as well for the introduce
> of
> > the new PCD.
> >
> > Inline comments below:
> >
> >
> > > -Original Message-
> > > From: Kubacki, Michael A
> > > Sent: Tuesday, October 15, 2019 7:30 AM
> > > To: devel@edk2.groups.io
> > > Cc: Bi, Dandan; Ard Biesheuvel; Dong, Eric; Laszlo Ersek; Gao, Liming;
> Kinney,
> > > Michael D; Ni, Ray; Wang, Jian J; Wu, Hao A; Yao, Jiewen
> > > Subject: [PATCH V4 07/10] MdeModulePkg/Variable: 

[edk2-devel] Upcoming Event: TianoCore Bug Triage - APAC / NAMO - Thu, 10/17/2019 5:00pm-5:30pm #cal-reminder

2019-10-17 Thread devel@edk2.groups.io Calendar
*Reminder:* TianoCore Bug Triage - APAC / NAMO

*When:* Thursday, 17 October 2019, 5:00pm to 5:30pm, (GMT-07:00) America/Los 
Angeles

*Where:* https://bluejeans.com/889357567?src=calendarLink

View Event ( https://edk2.groups.io/g/devel/viewevent?eventid=503254 )

*Organizer:* Stephano Cetola stephano.cet...@intel.com ( 
stephano.cet...@intel.com?subject=Re:%20Event:%20TianoCore%20Bug%20Triage%20-%20APAC%20%2F%20NAMO
 )

*Description:*

For more info please see:

https://www.tianocore.org/bug-triage

To join the meeting on a computer or mobile phone:

https://bluejeans.com/889357567?src=calendarLink ( 
https://bluejeans.com/889357567?src=calendarLink )

Phone Dial-in

+1.408.740.7256 (US (San Jose))

+1.408.317.9253 (US (Primary, San Jose))

Global Numbers: https://www.bluejeans.com/numbers ( 
https://www.bluejeans.com/numbers )

Meeting ID: 889 357 567

Room System

199.48.152.152 or bjn.vc

Meeting ID: 889 357 567

Want to test your video connection?

https://bluejeans.com/111 ( https://bluejeans.com/111 )

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49193): https://edk2.groups.io/g/devel/message/49193
Mute This Topic: https://groups.io/mt/34949971/21656
Mute #cal-reminder: https://groups.io/mk?hashtag=cal-reminder=3846945
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms] [PATCH v3 3/4] WhiskeylakeOpenBoardPkg: Add BIOS Info PEIM

2019-10-17 Thread Agyeman, Prince
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2211

Added BIOS Info PEIM to publish Bios Info
HOB. This PEIM currently publishes the microcode
FV information.

Cc: Ankit Sinha 
Cc: Nate DeSimone 
Cc: Kubacki Michael A 

Signed-off-by: Prince Agyeman 
---
 .../BiosInfo/BiosInfo.c   | 93 +++
 .../BiosInfo/BiosInfo.inf | 49 ++
 .../WhiskeylakeURvp/OpenBoardPkg.dsc  |  2 +
 .../WhiskeylakeURvp/OpenBoardPkg.fdf  |  1 +
 4 files changed, 145 insertions(+)
 create mode 100644 Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.c
 create mode 100644 Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.inf

diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.c 
b/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.c
new file mode 100644
index 00..578e66149e
--- /dev/null
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.c
@@ -0,0 +1,93 @@
+/** @file
+  Driver for BIOS Info support.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define INDEXPORT_TO_ADDRESS(x) (x)
+#define DATAPORT_TO_ADDRESS(x)  ((x) << 16)
+#define PORTWIDTH_TO_ADDRESS(x) ((x) << 32)
+#define PORTBITNUMBER_TO_ADDRESS(x) ((x) << 40)
+#define PORTINDEXNUMBER_TO_ADDRESS(x)   ((x) << 48)
+
+//
+// Internal
+//
+#pragma pack (1)
+
+typedef struct {
+  BIOS_INFO_HEADER  Header;
+  BIOS_INFO_STRUCT  Entry[1];
+} BIOS_INFO;
+#pragma pack ()
+
+GLOBAL_REMOVE_IF_UNREFERENCED BIOS_INFO  mBiosInfo = {
+  {
+BIOS_INFO_SIGNATURE,
+1,
+0,
+  },
+  {
+{
+  FIT_TYPE_01_MICROCODE,
+  BIOS_INFO_STRUCT_ATTRIBUTE_MICROCODE_WHOLE_REGION,
+  0x0100,
+  FixedPcdGet32 (PcdFlashMicrocodeFvSize),
+  FixedPcdGet32 (PcdFlashMicrocodeFvBase)
+}
+  }
+};
+
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR  mBiosInfoPpiList = {
+  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+  ,
+  
+};
+
+/**
+  Installs BiosInfo Ppi and builds BiosInfo HOB .
+
+  @param  FileHandle  Handle of the file being invoked.
+  @param  PeiServices Describes the list of possible PEI Services.
+
+  @retval EFI_SUCCESS   Install the BiosInfo Ppi and HOB successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+BiosInfoEntryPoint (
+  IN   EFI_PEI_FILE_HANDLE  FileHandle,
+  IN CONST EFI_PEI_SERVICES **PeiServices
+  )
+{
+  EFI_STATUS  Status;
+  VOID*HobData;
+
+  //
+  // Install PPI, so that other PEI module can add dependency.
+  //
+  Status = PeiServicesInstallPpi ();
+  ASSERT_EFI_ERROR (Status);
+
+  //
+  // Build hob, so that DXE module can also get the data.
+  //
+  HobData = BuildGuidHob (, sizeof (mBiosInfo));
+  ASSERT (HobData != NULL);
+  if (HobData == NULL) {
+return EFI_OUT_OF_RESOURCES;
+  }
+  CopyMem (HobData, , sizeof (mBiosInfo));
+
+  return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.inf 
b/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.inf
new file mode 100644
index 00..a9687d93de
--- /dev/null
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.inf
@@ -0,0 +1,49 @@
+### @file
+#  Module Information description file for BIOS Info Driver
+#
+#  Copyright (c) 2019, Intel Corporation. All rights reserved.
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+###
+
+[Defines]
+  INF_VERSION= 0x00010017
+  BASE_NAME  = BiosInfo
+  FILE_GUID  = A842B2D2-5C88-44E9-A9E2-4830F26662B7
+  VERSION_STRING = 1.0
+  MODULE_TYPE= PEIM
+  ENTRY_POINT= BiosInfoEntryPoint
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+# VALID_ARCHITECTURES IA32 X64
+#
+
+[LibraryClasses]
+  PeimEntryPoint
+  PeiServicesLib
+  HobLib
+  BaseMemoryLib
+  DebugLib
+  PcdLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  IntelSiliconPkg/IntelSiliconPkg.dec
+  CoffeelakeSiliconPkg/SiPkg.dec
+  CoffeeLakeFspBinPkg/CoffeeLakeFspBinPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
+  MinPlatformPkg/MinPlatformPkg.dec
+
+[Pcd]
+  gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvBase## CONSUMES
+  gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvSize## CONSUMES
+
+[Sources]
+  BiosInfo.c
+
+[Guids]
+  gBiosInfoGuid ## PRODUCES
+
+[Depex]
+  TRUE
diff --git 
a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc 
b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc
index 423fa88c12..8e0ea2d5ce 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc
@@ -314,6 +314,7 

[edk2-devel] [edk2-platforms] [PATCH v3 1/4] BoardModulePkg: Add BIOS Info HOB

2019-10-17 Thread Agyeman, Prince
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2210
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2211

Added gBiosInfoGuid to be used in
publishing the BIOS information HOB
which is needed in FIT generation

Also added the BIOS Info header
file BiosInfo.h that defines the
BIOS info struct and GUID

Cc: Ankit Sinha 
Cc: Nate DeSimone 
Cc: Kubacki Michael A 

Signed-off-by: Prince Agyeman 
---
 .../Intel/BoardModulePkg/BoardModulePkg.dec   |  3 +
 .../BoardModulePkg/Include/Guid/BiosInfo.h| 61 +++
 2 files changed, 64 insertions(+)
 create mode 100644 Platform/Intel/BoardModulePkg/Include/Guid/BiosInfo.h

diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dec 
b/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
index f96fb09aa1..f461cc7cab 100644
--- a/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
+++ b/Platform/Intel/BoardModulePkg/BoardModulePkg.dec
@@ -39,3 +39,6 @@
 [Guids]
   ## Include Include/Guid/BiosId.h
   gBiosIdGuid = { 0xC3E36D09, 0x8294, 0x4b97, { 0xA8, 0x57, 0xD5, 0x28, 0x8F, 
0xE3, 0x3E, 0x28 } }
+
+  ## GUID to publish BIOS information HOB
+  gBiosInfoGuid = { 0x09d0d15c, 0xe9f0, 0x4dfc, {0x9e, 0x0b, 0x39, 0x33, 0x1f, 
0xca, 0x66, 0x85} }
diff --git a/Platform/Intel/BoardModulePkg/Include/Guid/BiosInfo.h 
b/Platform/Intel/BoardModulePkg/Include/Guid/BiosInfo.h
new file mode 100644
index 00..d73409ea6f
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/Include/Guid/BiosInfo.h
@@ -0,0 +1,61 @@
+/** @file
+  Definitions and GUID for BIOS INFO.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef _BIOS_INFO_H_
+#define _BIOS_INFO_H_
+
+//
+// BIOS INFO data structure
+// This is self contained data structure for BIOS info for TXT
+//
+#pragma pack (1)
+#define BIOS_INFO_SIGNATURE  SIGNATURE_64 ('$', 'B', 'I', 'O', 'S', 'I', 'F', 
'$')
+typedef struct {
+  UINT64Signature;
+  UINT32EntryCount;
+  UINT32Reserved;
+//BIOS_INFO_STRUCT  Struct[EntryCount];
+} BIOS_INFO_HEADER;
+
+//
+// BIOS_INFO_STRUCT attributes
+// bits[0:3] means general attributes
+// bits[4:7] means type specific attributes
+//
+#define BIOS_INFO_STRUCT_ATTRIBUTE_GENERAL_EXCLUDE_FROM_FIT  0x01
+#define BIOS_INFO_STRUCT_ATTRIBUTE_MICROCODE_WHOLE_REGION0x10
+#define BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB 0x10
+#define BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_NON_IBB  0x20
+
+typedef struct {
+  //
+  // FitTable entry type
+  //
+  UINT8Type;
+  //
+  // BIOS_INFO_STRUCT attributes
+  //
+  UINT8Attributes;
+  //
+  // FitTable entry version
+  //
+  UINT16   Version;
+  //
+  // FitTable entry real size
+  //
+  UINT32   Size;
+  //
+  // FitTable entry address
+  //
+  UINT64   Address;
+} BIOS_INFO_STRUCT;
+
+extern EFI_GUID  gBiosInfoGuid;
+
+#pragma pack ()
+
+#endif
-- 
2.19.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49195): https://edk2.groups.io/g/devel/message/49195
Mute This Topic: https://groups.io/mt/34950129/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms] [PATCH v3 4/4] Platform/Intel: Add FIT generation tool

2019-10-17 Thread Agyeman, Prince
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2210
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2211

Added FitGen tool build and FIT generation
to the BIOS build process.

What was done:

- Build the FIT generation tool
- Added default/empty BIOS_INFO_GUID to the build.cfg
- Added BIOS_INFO_GUID to GalagoPro3,KabylakeRvp3
and WhiskeylakeURvp's build_config.cfg
This allows a board to specify the GUID
associated with the BIOS Info PEIM to be used
in the board's FIT generation.

BIOS_INFO_GUID is passed as an argument to
FitGen tool which allow the tool to locate
the BIOS Info module to be used in FIT generation.

Cc: Ankit Sinha 
Cc: Nate DeSimone 
Cc: Michael Kubacki 

Signed-off-by: Prince Agyeman 
---
 .../GalagoPro3/build_config.cfg   |  1 +
 .../KabylakeRvp3/build_config.cfg |  1 +
 .../WhiskeylakeURvp/build_config.cfg  |  1 +
 Platform/Intel/build.cfg  |  1 +
 Platform/Intel/build_bios.py  | 57 +++
 5 files changed, 61 insertions(+)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/build_config.cfg 
b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/build_config.cfg
index 8c6c51abb4..458fe3d35d 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/build_config.cfg
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/build_config.cfg
@@ -31,3 +31,4 @@ FSP_PKG_NAME = KabylakeFspPkg
 FSP_BINARY_BUILD = FALSE
 FSP_TEST_RELEASE = FALSE
 SECURE_BOOT_ENABLE = FALSE
+BIOS_INFO_GUID = C83BCE0E-6F16-4D3C-8D9F-4D6F5A032929
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/build_config.cfg 
b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/build_config.cfg
index 78f808bfaf..f6ae4b342a 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/build_config.cfg
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/build_config.cfg
@@ -33,3 +33,4 @@ FSP_PKG_NAME = AmberLakeFspPkg
 FSP_BINARY_BUILD = FALSE
 FSP_TEST_RELEASE = FALSE
 SECURE_BOOT_ENABLE = FALSE
+BIOS_INFO_GUID = C83BCE0E-6F16-4D3C-8D9F-4D6F5A032929
diff --git 
a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/build_config.cfg 
b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/build_config.cfg
index 1b0619bc1c..1dfe5ffd10 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/build_config.cfg
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/build_config.cfg
@@ -31,3 +31,4 @@ FSP_PKG_NAME = CoffeelakeSiliconPkg
 FSP_BINARY_BUILD = FALSE
 FSP_TEST_RELEASE = FALSE
 SECURE_BOOT_ENABLE = FALSE
+BIOS_INFO_GUID = A842B2D2-5C88-44E9-A9E2-4830F26662B7
diff --git a/Platform/Intel/build.cfg b/Platform/Intel/build.cfg
index 2040774d1b..6aee96694c 100644
--- a/Platform/Intel/build.cfg
+++ b/Platform/Intel/build.cfg
@@ -48,6 +48,7 @@ SECURE_BOOT_ENABLE = FALSE
 REBUILD_MODE =
 BUILD_ROM_ONLY =
 NUMBER_OF_PROCESSORS = 0
+BIOS_INFO_GUID =
 
 
 [PLATFORMS]
diff --git a/Platform/Intel/build_bios.py b/Platform/Intel/build_bios.py
index 46285df19a..ea098de705 100644
--- a/Platform/Intel/build_bios.py
+++ b/Platform/Intel/build_bios.py
@@ -196,6 +196,31 @@ def pre_build(build_config, build_type="DEBUG", 
silent=False, toolchain=None):
 if return_code != 0:
 build_failed(config)
 
+#
+# build platform silicon tools
+#
+# save the current workspace
+saved_work_directory = config["WORKSPACE"]
+# change the workspace to silicon tools directory
+config["WORKSPACE"] = os.path.join(config["WORKSPACE_SILICON"], "Tools")
+
+command = ["nmake"]
+if os.name == "posix":  # linux
+command = ["make"]
+# add path to generated FitGen binary to
+# environment path variable
+config["PATH"] += os.pathsep + \
+  os.path.join(config["BASE_TOOLS_PATH"],
+   "Source", "C", "bin")
+
+# build the silicon tools
+_, _, result, return_code = execute_script(command, config, shell=shell)
+if return_code != 0:
+build_failed(config)
+
+# restore WORKSPACE environment variable
+config["WORKSPACE"] = saved_work_directory
+
 config["SILENT_MODE"] = 'TRUE' if silent else 'FALSE'
 
 print("==")
@@ -404,6 +429,35 @@ def post_build(config):
 :returns: nothing
 """
 print("Running post_build to complete the build process.")
+board_fd = config["BOARD"].upper()
+final_fd = os.path.join(config["BUILD_DIR_PATH"], "FV",
+"{}.fd".format(board_fd))
+
+if config["BIOS_INFO_GUID"]:
+# Generate the fit table
+print("Generating FIT ...")
+if os.path.isfile(final_fd):
+temp_fd = os.path.join(config["BUILD_DIR_PATH"], "FV",
+   "{}_.fd".format(board_fd))
+shell = True
+command = ["FitGen", "-D",
+   final_fd, temp_fd, "-NA",
+   "-I", config["BIOS_INFO_GUID"]]
+
+   

[edk2-devel] [edk2-platforms] [PATCH v3 0/4] Add FIT support using FitGen

2019-10-17 Thread Agyeman, Prince
Changes in v3:
- Added PcdLib to BiosInfo.inf's LibraryClasses section
- Cleaned up OpenBoardPkg.dscs for all three platforms
- Added bugzilla references

Changes in v2:
- Moved BIOS Info PEIM to KabylakeOpenBoardPkg
  shared by both KabylakeRvp3, GalagoPro3
- Moved BIOS Info PEIM to WhiskeylakeOpenBoardPkg
  used by WhiskeylakeURvp
- Moved BiosInfo.h to BoardModulePkg/Include/Guid
- Fixed typos, cleaned up commit messages and comments

Prince Agyeman (4):
  BoardModulePkg: Add BIOS Info HOB
  KabylakeOpenBoardPkg: Add BIOS Info PEIM
  WhiskeylakeOpenBoardPkg: Add BIOS Info PEIM
  Platform/Intel: Add FIT generation tool

 .../Intel/BoardModulePkg/BoardModulePkg.dec   |  3 +
 .../BoardModulePkg/Include/Guid/BiosInfo.h| 61 
 .../KabylakeOpenBoardPkg/BiosInfo/BiosInfo.c  | 93 +++
 .../BiosInfo/BiosInfo.inf | 49 ++
 .../GalagoPro3/OpenBoardPkg.dsc   |  1 +
 .../GalagoPro3/OpenBoardPkg.fdf   |  1 +
 .../GalagoPro3/build_config.cfg   |  1 +
 .../KabylakeRvp3/OpenBoardPkg.dsc |  1 +
 .../KabylakeRvp3/OpenBoardPkg.fdf |  1 +
 .../KabylakeRvp3/build_config.cfg |  1 +
 .../BiosInfo/BiosInfo.c   | 93 +++
 .../BiosInfo/BiosInfo.inf | 49 ++
 .../WhiskeylakeURvp/OpenBoardPkg.dsc  |  2 +
 .../WhiskeylakeURvp/OpenBoardPkg.fdf  |  1 +
 .../WhiskeylakeURvp/build_config.cfg  |  1 +
 Platform/Intel/build.cfg  |  1 +
 Platform/Intel/build_bios.py  | 57 
 17 files changed, 416 insertions(+)
 create mode 100644 Platform/Intel/BoardModulePkg/Include/Guid/BiosInfo.h
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.inf
 create mode 100644 Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.c
 create mode 100644 Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.inf

-- 
2.19.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49194): https://edk2.groups.io/g/devel/message/49194
Mute This Topic: https://groups.io/mt/34950128/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms] [PATCH v3 2/4] KabylakeOpenBoardPkg: Add BIOS Info PEIM

2019-10-17 Thread Agyeman, Prince
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2210

Added BIOS Info PEIM to KabylakeRvp3 and GalagoPro3
to publish the BIOS info HOB. This PEIM currently publishes
the board's microcode region information.

Cc: Ankit Sinha 
Cc: Nate DeSimone 
Cc: Kubacki Michael A 

Signed-off-by: Prince Agyeman 
---
 .../KabylakeOpenBoardPkg/BiosInfo/BiosInfo.c  | 93 +++
 .../BiosInfo/BiosInfo.inf | 49 ++
 .../GalagoPro3/OpenBoardPkg.dsc   |  1 +
 .../GalagoPro3/OpenBoardPkg.fdf   |  1 +
 .../KabylakeRvp3/OpenBoardPkg.dsc |  1 +
 .../KabylakeRvp3/OpenBoardPkg.fdf |  1 +
 6 files changed, 146 insertions(+)
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.inf

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.c 
b/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.c
new file mode 100644
index 00..578e66149e
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.c
@@ -0,0 +1,93 @@
+/** @file
+  Driver for BIOS Info support.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define INDEXPORT_TO_ADDRESS(x) (x)
+#define DATAPORT_TO_ADDRESS(x)  ((x) << 16)
+#define PORTWIDTH_TO_ADDRESS(x) ((x) << 32)
+#define PORTBITNUMBER_TO_ADDRESS(x) ((x) << 40)
+#define PORTINDEXNUMBER_TO_ADDRESS(x)   ((x) << 48)
+
+//
+// Internal
+//
+#pragma pack (1)
+
+typedef struct {
+  BIOS_INFO_HEADER  Header;
+  BIOS_INFO_STRUCT  Entry[1];
+} BIOS_INFO;
+#pragma pack ()
+
+GLOBAL_REMOVE_IF_UNREFERENCED BIOS_INFO  mBiosInfo = {
+  {
+BIOS_INFO_SIGNATURE,
+1,
+0,
+  },
+  {
+{
+  FIT_TYPE_01_MICROCODE,
+  BIOS_INFO_STRUCT_ATTRIBUTE_MICROCODE_WHOLE_REGION,
+  0x0100,
+  FixedPcdGet32 (PcdFlashMicrocodeFvSize),
+  FixedPcdGet32 (PcdFlashMicrocodeFvBase)
+}
+  }
+};
+
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR  mBiosInfoPpiList = {
+  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+  ,
+  
+};
+
+/**
+  Installs BiosInfo Ppi and builds BiosInfo HOB .
+
+  @param  FileHandle  Handle of the file being invoked.
+  @param  PeiServices Describes the list of possible PEI Services.
+
+  @retval EFI_SUCCESS   Install the BiosInfo Ppi and HOB successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+BiosInfoEntryPoint (
+  IN   EFI_PEI_FILE_HANDLE  FileHandle,
+  IN CONST EFI_PEI_SERVICES **PeiServices
+  )
+{
+  EFI_STATUS  Status;
+  VOID*HobData;
+
+  //
+  // Install PPI, so that other PEI module can add dependency.
+  //
+  Status = PeiServicesInstallPpi ();
+  ASSERT_EFI_ERROR (Status);
+
+  //
+  // Build hob, so that DXE module can also get the data.
+  //
+  HobData = BuildGuidHob (, sizeof (mBiosInfo));
+  ASSERT (HobData != NULL);
+  if (HobData == NULL) {
+return EFI_OUT_OF_RESOURCES;
+  }
+  CopyMem (HobData, , sizeof (mBiosInfo));
+
+  return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.inf 
b/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.inf
new file mode 100644
index 00..e5e40144a6
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.inf
@@ -0,0 +1,49 @@
+### @file
+#  Module Information description file for BIOS Info Driver
+#
+#  Copyright (c) 2019, Intel Corporation. All rights reserved.
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+###
+
+[Defines]
+  INF_VERSION= 0x00010017
+  BASE_NAME  = BiosInfo
+  FILE_GUID  = C83BCE0E-6F16-4D3C-8D9F-4D6F5A032929
+  VERSION_STRING = 1.0
+  MODULE_TYPE= PEIM
+  ENTRY_POINT= BiosInfoEntryPoint
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+# VALID_ARCHITECTURES IA32 X64
+#
+
+[LibraryClasses]
+  PeimEntryPoint
+  PeiServicesLib
+  HobLib
+  BaseMemoryLib
+  DebugLib
+  PcdLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  IntelSiliconPkg/IntelSiliconPkg.dec
+  KabylakeSiliconPkg/SiPkg.dec
+  KabylakeFspBinPkg/KabylakeFspBinPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
+  MinPlatformPkg/MinPlatformPkg.dec
+
+[Pcd]
+  gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvBase## CONSUMES
+  gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvSize## CONSUMES
+
+[Sources]
+  BiosInfo.c
+
+[Guids]
+  gBiosInfoGuid ## PRODUCES
+
+[Depex]
+  TRUE
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc 
b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
index b6f9807e7e..f59248bba4 100644
--- 

[edk2-devel] [PATCH V5 03/10] MdeModulePkg/Variable: Parameterize VARIABLE_INFO_ENTRY buffer

2019-10-17 Thread Kubacki, Michael A
UpdateVariableInfo () currently accepts parameters regarding updates
to be made to a global variable of type VARIABLE_INFO_ENTRY. This
change passes the structure by pointer to UpdateVariableInfo ()
so structures other than the fixed global variable can be updated.

Cc: Dandan Bi 
Cc: Ard Biesheuvel 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Ray Ni 
Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Jiewen Yao 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h | 18 +
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c| 14 +++
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c | 41 
+++-
 3 files changed, 39 insertions(+), 34 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h
index 6555316f52..1777ce0e69 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h
@@ -286,13 +286,14 @@ VariableServiceGetNextVariableInternal (
   the transaction. Data is allocated by this routine, but never
   freed.
 
-  @param[in] VariableName   Name of the Variable to track.
-  @param[in] VendorGuid Guid of the Variable to track.
-  @param[in] Volatile   TRUE if volatile FALSE if non-volatile.
-  @param[in] Read   TRUE if GetVariable() was called.
-  @param[in] Write  TRUE if SetVariable() was called.
-  @param[in] Delete TRUE if deleted via SetVariable().
-  @param[in] Cache  TRUE for a cache hit.
+  @param[in]  VariableName   Name of the Variable to track.
+  @param[in]  VendorGuid Guid of the Variable to track.
+  @param[in]  Volatile   TRUE if volatile FALSE if non-volatile.
+  @param[in]  Read   TRUE if GetVariable() was called.
+  @param[in]  Write  TRUE if SetVariable() was called.
+  @param[in]  Delete TRUE if deleted via SetVariable().
+  @param[in]  Cache  TRUE for a cache hit.
+  @param[in,out]  VariableInfo   Pointer to a pointer of VARIABLE_INFO_ENTRY 
structures.
 
 **/
 VOID
@@ -303,7 +304,8 @@ UpdateVariableInfo (
   IN  BOOLEAN Read,
   IN  BOOLEAN Write,
   IN  BOOLEAN Delete,
-  IN  BOOLEAN Cache
+  IN  BOOLEAN Cache,
+  IN OUT VARIABLE_INFO_ENTRY  **VariableInfo
   );
 
 #endif
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 70af86db24..5cc12c2ae0 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -1641,7 +1641,7 @@ UpdateVariable (
 // go to delete this variable in variable HOB and
 // try to flush other variables from HOB to flash.
 //
-UpdateVariableInfo (VariableName, VendorGuid, FALSE, FALSE, FALSE, 
TRUE, FALSE);
+UpdateVariableInfo (VariableName, VendorGuid, FALSE, FALSE, FALSE, 
TRUE, FALSE, );
 FlushHobVariableToFlash (VariableName, VendorGuid);
 return EFI_SUCCESS;
   }
@@ -1758,7 +1758,7 @@ UpdateVariable (
  
  );
   if (!EFI_ERROR (Status)) {
-UpdateVariableInfo (VariableName, VendorGuid, Variable->Volatile, 
FALSE, FALSE, TRUE, FALSE);
+UpdateVariableInfo (VariableName, VendorGuid, Variable->Volatile, 
FALSE, FALSE, TRUE, FALSE, );
 if (!Variable->Volatile) {
   CacheVariable->CurrPtr->State = State;
   FlushHobVariableToFlash (VariableName, VendorGuid);
@@ -1777,7 +1777,7 @@ UpdateVariable (
   //
   // Variable content unchanged and no need to update timestamp, just 
return.
   //
-  UpdateVariableInfo (VariableName, VendorGuid, Variable->Volatile, FALSE, 
TRUE, FALSE, FALSE);
+  UpdateVariableInfo (VariableName, VendorGuid, Variable->Volatile, FALSE, 
TRUE, FALSE, FALSE, );
   Status = EFI_SUCCESS;
   goto Done;
 } else if ((CacheVariable->CurrPtr->State == VAR_ADDED) ||
@@ -2006,7 +2006,7 @@ UpdateVariable (
   CacheVariable->CurrPtr = (VARIABLE_HEADER *)((UINTN) 
CacheVariable->StartPtr + ((UINTN) Variable->CurrPtr - (UINTN) 
Variable->StartPtr));
   CacheVariable->InDeletedTransitionPtr = NULL;
 }
-UpdateVariableInfo (VariableName, VendorGuid, FALSE, FALSE, TRUE, 
FALSE, FALSE);
+UpdateVariableInfo (VariableName, VendorGuid, FALSE, FALSE, TRUE, 
FALSE, FALSE, );
 FlushHobVariableToFlash (VariableName, VendorGuid);
   } else {
 if (IsCommonUserVariable && ((VarSize + 
mVariableModuleGlobal->CommonUserVariableTotalSize) > 
mVariableModuleGlobal->CommonMaxUserVariableSpace)) {
@@ -2156,7 +2156,7 @@ UpdateVariable (
   CacheVariable->CurrPtr = (VARIABLE_HEADER *)((UINTN) 
CacheVariable->StartPtr + ((UINTN) 

[edk2-devel] [PATCH V5 01/10] MdeModulePkg/Variable: Consolidate common parsing functions

2019-10-17 Thread Kubacki, Michael A
This change moves the following functions into a dedicated file
so they may be used in other variable files as needed. These are
commonly needed for basic variable data structure parsing
operations. The functions are grouped together in VariableParsing.c
to support cohesiveness for these operations in the file.
Furthermore, it reduces the overall size of the common Variable.c
file.

 * DataSizeOfVariable ()
 * FindVariableEx ()
 * GetEndPointer ()
 * GetNextVariablePtr ()
 * GetStartPointer ()
 * GetVariableDataOffset ()
 * GetVariableDataPtr ()
 * GetVariableHeaderSize ()
 * GetVariableNamePtr ()
 * GetVariableStoreStatus ()
 * GetVendorGuidPtr ()
 * IsValidVariableHeader ()
 * NameSizeOfVariable ()
 * SetDataSizeOfVariable ()
 * SetNameSizeOfVariable ()
 * UpdateVariableInfo ()
 * VariableCompareTimeStampInternal ()
 * VariableServiceGetNextVariableInternal ()

Cc: Dandan Bi 
Cc: Ard Biesheuvel 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Ray Ni 
Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Jiewen Yao 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf   |   2 +
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf  |   2 +
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf |   2 +
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h   | 119 
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h| 306 

 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c   | 726 
+--
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableExLib.c  |   3 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c| 731 

 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c|   1 +
 9 files changed, 1047 insertions(+), 845 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
index 641376c9c5..c35e5fe787 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
@@ -36,6 +36,8 @@
   Variable.c
   VariableDxe.c
   Variable.h
+  VariableParsing.c
+  VariableParsing.h
   PrivilegePolymorphic.h
   Measurement.c
   TcgMorLockDxe.c
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
index 0a160d269d..626738b9c7 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
@@ -45,6 +45,8 @@
   Variable.c
   VariableTraditionalMm.c
   VariableSmm.c
+  VariableParsing.c
+  VariableParsing.h
   VarCheck.c
   Variable.h
   PrivilegePolymorphic.h
diff --git 
a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
index 21bc81163b..ff714b193a 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
@@ -45,6 +45,8 @@
   Variable.c
   VariableSmm.c
   VariableStandaloneMm.c
+  VariableParsing.c
+  VariableParsing.h
   VarCheck.c
   Variable.h
   PrivilegePolymorphic.h
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
index 9eac43759f..fb574b2e32 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
@@ -179,89 +179,6 @@ FindVariable (
   IN  BOOLEAN IgnoreRtCheck
   );
 
-/**
-
-  Gets the pointer to the end of the variable storage area.
-
-  This function gets pointer to the end of the variable storage
-  area, according to the input variable store header.
-
-  @param VarStoreHeader  Pointer to the Variable Store Header.
-
-  @return Pointer to the end of the variable storage area.
-
-**/
-VARIABLE_HEADER *
-GetEndPointer (
-  IN VARIABLE_STORE_HEADER   *VarStoreHeader
-  );
-
-/**
-  This code gets the size of variable header.
-
-  @return Size of variable header in bytes in type UINTN.
-
-**/
-UINTN
-GetVariableHeaderSize (
-  VOID
-  );
-
-/**
-
-  This code gets the pointer to the variable name.
-
-  @param VariablePointer to the Variable Header.
-
-  @return Pointer to Variable Name which is Unicode encoding.
-
-**/
-CHAR16 *
-GetVariableNamePtr (
-  IN  VARIABLE_HEADER   *Variable
-  );
-
-/**
-  This code gets the pointer to the variable guid.
-
-  @param Variable   Pointer to the Variable Header.
-
-  @return A EFI_GUID* pointer to Vendor Guid.
-
-**/
-EFI_GUID *
-GetVendorGuidPtr (
-  IN VARIABLE_HEADER*Variable
-  );
-
-/**
-
-  This code gets the pointer to the variable data.
-
-  @param VariablePointer to the Variable Header.
-
-  @return Pointer to Variable Data.
-
-**/
-UINT8 *

[edk2-devel] [PATCH V5 07/10] MdeModulePkg/Variable: Add RT GetVariable() cache support

2019-10-17 Thread Kubacki, Michael A
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2220

This change reduces SMIs for GetVariable () by maintaining a
UEFI variable cache in Runtime DXE in addition to the pre-
existing cache in SMRAM. When the Runtime Service GetVariable()
is invoked, a Runtime DXE cache is used instead of triggering an
SMI to VariableSmm. This can improve overall system performance
by servicing variable read requests without rendezvousing all
cores into SMM.

The runtime cache  can be disabled with by setting the FeaturePCD
gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache
to FALSE. If the PCD is set to FALSE, the runtime cache will not be
used and an SMI will be triggered for Runtime Service
GetVariable () and GetNextVariableName () invocations.

The following are important points regarding the behavior of the
variable drivers when the variable runtime cache is enabled.

1. All of the non-volatile storage contents are loaded into the
   cache upon driver load. This one time load operation from storage
   is preferred as opposed to building the cache on demand. An on-
   demand cache would require a fallback SMI to load data into the
   cache as variables are requested.

2. SetVariable () requests will continue to always trigger an SMI.
   This occurs regardless of whether the variable is volatile or
   non-volatile.

3. Both volatile and non-volatile variables are cached in a runtime
   buffer. As is the case in the current EDK II variable driver, they
   continue to be cached in separate buffers.

4. The cache in Runtime DXE and SMM are intended to be exact copies
   of one another. All SMM variable accesses only return data from the
   SMM cache. The runtime caches are only updated after the variable I/O
   operation is successful in SMM. The runtime caches are only updated
   from SMM.

5. Synchronization mechanisms are in place to ensure the runtime cache
   content integrity with the SMM cache. These may result in updates to
   runtime cache that are the same in content but different in offset and
   size from updates to the SMM cache.

When using SMM variables with runtime cache enabled, two caches will now
be present.
1. "Runtime Cache" - Maintained in VariableSmmRuntimeDxe. Used to service
   Runtime Services GetVariable () and GetNextVariableName () callers.
2. "SMM Cache" - Maintained in VariableSmm to service SMM GetVariable ()
   and GetNextVariableName () callers.
   a. This cache is retained so SMM modules do not operate on data outside
  SMRAM.

Because a race condition can occur if an SMI occurs during the execution
of runtime code reading from the runtime cache, a runtime cache read lock
is introduced that explicitly moves pending updates from SMM to the runtime
cache if an SMM update occurs while the runtime cache is locked. Note that
it is not expected a Runtime services call will interrupt SMM processing
since all CPU cores rendezvous in SMM.

It is possible to view UEFI variable read and write statistics by setting
the gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics FeaturePcd
to TRUE and using the VariableInfo UEFI application in MdeModulePkg to dump
variable statistics to the console. By doing so, a user can view the number
of GetVariable () hits from the Runtime DXE variable driver (Runtime Cache
hits) and the SMM variable driver (SMM Cache hits). SMM Cache hits for
GetVariable () will occur when SMM modules invoke GetVariable ().

Cc: Dandan Bi 
Cc: Ard Biesheuvel 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Ray Ni 
Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Jiewen Yao 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/MdeModulePkg.dec|  12 +
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf|   2 +
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf   |   2 +
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf |  20 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf  |   2 +
 MdeModulePkg/Include/Guid/SmmVariableCommon.h|  29 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h|  32 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeCache.h|  51 ++
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c|  50 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeCache.c| 153 
++
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c | 190 
+++-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c   | 512 
+++-
 12 files changed, 1014 insertions(+), 41 deletions(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index d6bac974da..3ef8fe7644 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -641,6 +641,18 @@
   # @Prompt Enable Device Path From Text support.
   

[edk2-devel] [PATCH V5 05/10] MdeModulePkg/Variable: Add a file for NV variable functions

2019-10-17 Thread Kubacki, Michael A
This change adds a dedicated file for variable operations specific
to non-volatile variables. This decreases the overall length of the
relatively large Variable.c file.

Cc: Dandan Bi 
Cc: Ard Biesheuvel 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Ray Ni 
Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Jiewen Yao 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf   |   2 +
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf  |   2 +
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf |   2 +
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.h|  67 
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c   | 317 
+--
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c| 334 

 6 files changed, 408 insertions(+), 316 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
index c35e5fe787..08a5490787 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
@@ -36,6 +36,8 @@
   Variable.c
   VariableDxe.c
   Variable.h
+  VariableNonVolatile.c
+  VariableNonVolatile.h
   VariableParsing.c
   VariableParsing.h
   PrivilegePolymorphic.h
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
index 626738b9c7..6dc2721b81 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
@@ -45,6 +45,8 @@
   Variable.c
   VariableTraditionalMm.c
   VariableSmm.c
+  VariableNonVolatile.c
+  VariableNonVolatile.h
   VariableParsing.c
   VariableParsing.h
   VarCheck.c
diff --git 
a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
index ff714b193a..f8a3742959 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
@@ -45,6 +45,8 @@
   Variable.c
   VariableSmm.c
   VariableStandaloneMm.c
+  VariableNonVolatile.c
+  VariableNonVolatile.h
   VariableParsing.c
   VariableParsing.h
   VarCheck.c
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.h 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.h
new file mode 100644
index 00..43653f27e6
--- /dev/null
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.h
@@ -0,0 +1,67 @@
+/** @file
+  Common variable non-volatile store routines.
+
+Copyright (c) 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _VARIABLE_NON_VOLATILE_H_
+#define _VARIABLE_NON_VOLATILE_H_
+
+#include "Variable.h"
+
+/**
+  Get non-volatile maximum variable size.
+
+  @return Non-volatile maximum variable size.
+
+**/
+UINTN
+GetNonVolatileMaxVariableSize (
+  VOID
+  );
+
+/**
+  Init emulated non-volatile variable store.
+
+  @param[out] VariableStoreBase Output pointer to emulated non-volatile 
variable store base.
+
+  @retval EFI_SUCCESS   Function successfully executed.
+  @retval EFI_OUT_OF_RESOURCES  Fail to allocate enough memory resource.
+
+**/
+EFI_STATUS
+InitEmuNonVolatileVariableStore (
+  EFI_PHYSICAL_ADDRESS  *VariableStoreBase
+  );
+
+/**
+  Init real non-volatile variable store.
+
+  @param[out] VariableStoreBase Output pointer to real non-volatile variable 
store base.
+
+  @retval EFI_SUCCESS   Function successfully executed.
+  @retval EFI_OUT_OF_RESOURCES  Fail to allocate enough memory resource.
+  @retval EFI_VOLUME_CORRUPTED  Variable Store or Firmware Volume for Variable 
Store is corrupted.
+
+**/
+EFI_STATUS
+InitRealNonVolatileVariableStore (
+  OUT EFI_PHYSICAL_ADDRESS  *VariableStoreBase
+  );
+
+/**
+  Init non-volatile variable store.
+
+  @retval EFI_SUCCESS   Function successfully executed.
+  @retval EFI_OUT_OF_RESOURCES  Fail to allocate enough memory resource.
+  @retval EFI_VOLUME_CORRUPTED  Variable Store or Firmware Volume for Variable 
Store is corrupted.
+
+**/
+EFI_STATUS
+InitNonVolatileVariableStore (
+  VOID
+  );
+
+#endif
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 2e32905dfe..0bd2f22e1a 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -23,6 +23,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
 #include "Variable.h"
+#include "VariableNonVolatile.h"
 #include "VariableParsing.h"
 
 VARIABLE_MODULE_GLOBAL  *mVariableModuleGlobal;
@@ -3079,25 +3080,6 @@ ReclaimForOS(
   }
 }
 
-/**
-  Get non-volatile maximum 

[edk2-devel] [PATCH V5 02/10] MdeModulePkg/Variable: Parameterize GetNextVariableInternal () stores

2019-10-17 Thread Kubacki, Michael A
The majority of logic related to GetNextVariableName () is currently
implemented in VariableServiceGetNextVariableInternal (). The list
of variable stores to search for the given variable name and variable
GUID is defined in the function body. This change adds a new parameter
so that the caller must pass in the list of variable stores to be used
in the variable search.

Cc: Dandan Bi 
Cc: Ard Biesheuvel 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Ray Ni 
Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Jiewen Yao 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h | 13 ++--
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c| 12 ++-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableExLib.c   |  6 ++
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c | 82 

 4 files changed, 73 insertions(+), 40 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h
index b0d7f76bd8..6555316f52 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h
@@ -248,18 +248,20 @@ FindVariableEx (
   );
 
 /**
-  This code Finds the Next available variable.
+  This code finds the next available variable.
 
   Caution: This function may receive untrusted input.
   This function may be invoked in SMM mode. This function will do basic 
validation, before parse the data.
 
-  @param[in]  VariableName  Pointer to variable name.
-  @param[in]  VendorGuidVariable Vendor Guid.
-  @param[out] VariablePtr   Pointer to variable header address.
+  @param[in]  VariableName  Pointer to variable name.
+  @param[in]  VendorGuidVariable Vendor Guid.
+  @param[in]  VariableStoreList A list of variable stores that should be used 
to get the next variable.
+The maximum number of entries is the max value 
of VARIABLE_STORE_TYPE.
+  @param[out] VariablePtr   Pointer to variable header address.
 
   @retval EFI_SUCCESS   The function completed successfully.
   @retval EFI_NOT_FOUND The next variable was not found.
-  @retval EFI_INVALID_PARAMETER If VariableName is not an empty string, while 
VendorGuid is NULL.
+  @retval EFI_INVALID_PARAMETER If VariableName is nt an empty string, while 
VendorGuid is NULL.
   @retval EFI_INVALID_PARAMETER The input values of VariableName and 
VendorGuid are not a name and
 GUID of an existing variable.
 
@@ -269,6 +271,7 @@ EFIAPI
 VariableServiceGetNextVariableInternal (
   IN  CHAR16*VariableName,
   IN  EFI_GUID  *VendorGuid,
+  IN  VARIABLE_STORE_HEADER **VariableStoreList,
   OUT VARIABLE_HEADER   **VariablePtr
   );
 
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 76536308e6..70af86db24 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -2358,6 +2358,7 @@ VariableServiceGetNextVariableName (
   UINTN   MaxLen;
   UINTN   VarNameSize;
   VARIABLE_HEADER *VariablePtr;
+  VARIABLE_STORE_HEADER   *VariableStoreHeader[VariableStoreTypeMax];
 
   if (VariableNameSize == NULL || VariableName == NULL || VendorGuid == NULL) {
 return EFI_INVALID_PARAMETER;
@@ -2377,7 +2378,16 @@ VariableServiceGetNextVariableName (
 
   
AcquireLockOnlyAtBootTime(>VariableGlobal.VariableServicesLock);
 
-  Status = VariableServiceGetNextVariableInternal (VariableName, VendorGuid, 
);
+  //
+  // 0: Volatile, 1: HOB, 2: Non-Volatile.
+  // The index and attributes mapping must be kept in this order as 
FindVariable
+  // makes use of this mapping to implement search algorithm.
+  //
+  VariableStoreHeader[VariableStoreTypeVolatile] = (VARIABLE_STORE_HEADER *) 
(UINTN) mVariableModuleGlobal->VariableGlobal.VolatileVariableBase;
+  VariableStoreHeader[VariableStoreTypeHob]  = (VARIABLE_STORE_HEADER *) 
(UINTN) mVariableModuleGlobal->VariableGlobal.HobVariableBase;
+  VariableStoreHeader[VariableStoreTypeNv]   = mNvVariableCache;
+
+  Status = VariableServiceGetNextVariableInternal (VariableName, VendorGuid, 
VariableStoreHeader, );
   if (!EFI_ERROR (Status)) {
 VarNameSize = NameSizeOfVariable (VariablePtr);
 ASSERT (VarNameSize != 0);
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableExLib.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableExLib.c
index dc78f68fa9..c787ddba5b 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableExLib.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableExLib.c
@@ -98,10 +98,16 @@ VariableExLibFindNextVariable (
   EFI_STATUSStatus;
   VARIABLE_HEADER   *VariablePtr;
   AUTHENTICATED_VARIABLE_HEADER 

[edk2-devel] [PATCH V5 00/10] UEFI Variable SMI Reduction

2019-10-17 Thread Kubacki, Michael A
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2220

V5 Changes:
 [PATCH V4 07/10] MdeModulePkg/Variable: Add RT GetVariable() cache support
 * Increased validation of the runtime buffers passed in the SMM comm buffer
   SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT structure to the
   SMM_VARIABLE_FUNCTION_INIT_RUNTIME_VARIABLE_CACHE_CONTEXT function in
   SmmVariableHandler () in VariableSmm.c.
 * Most notably, each runtime buffer given is checked to ensure its memory
   range does not overlap with SMRAM ranges via 
VariableSmmIsBufferOutsideSmmValid ().

V4 Changes:
 [PATCH V3 7/9] MdeModulePkg/Variable: Add RT GetVariable() cache support
 * Set gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache to FALSE
   by default in MdeModulePkg.dec.

 * Added a new patch to set 
gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache
   to TRUE at the end of the patch series. This allows someone to bisect an 
issue at
   patch #7 or patch #8 in the series with no change in variable caching 
behavior. The
   runtime cache variable logic would be applied explicitly in V4 patch #10.

V3 Changes:
 [PATCH V2 1/9] MdeModulePkg/Variable: Consolidate common parsing functions
 * Removed GUIDs added to VariableStandaloneMm.inf that are not required.
 * Added more details to the commit message describing the criteria of
   moving the chosen functions to VariableParsing.c.

 [PATCH V2 2/9] MdeModulePkg/Variable: Parameterize GetNextVariableEx() store 
list
 * RenamedGetNextVariableEx () to VariableServiceGetNextVariableInternal ()
 * Updated comments in VariableServiceGetNextVariableInternal () to refer to
   "FindVariablEx ()" instead of "FindVariable ()" since FindVariableEx ()
   is not used in the function.

 [PATCH V2 3/9] MdeModulePkg/Variable: Parameterize VARIABLE_INFO_ENTRY buffer
 * Updated the commit message to clarify the message "structure can be updated
   outside the fixed global variable".

 [edk2-devel] [PATCH V2 4/9] MdeModulePkg/Variable: Add local auth status in 
VariableParsing
 * Remove the function InitVariableParsing ()
 * Remove the mAuthFormat global variable and instead add a BOOLEAN parameter
   to all functions that require variable authentication information  to
   indicate if authenticated variables are used.
   * This allows the authenticated variable status to be tracked in one place in
 each variable driver in the SMM variable solution (VariableSmmRuntimeDxe
 and VariableSmm).

 [edk2-devel] [PATCH V2 5/9] MdeModulePkg/Variable: Add a file for NV variable 
functions
 * Added the following non-volatile related functions to VariableNonVolatile.c
   from Variable.c:
   * InitRealNonVolatileVariableStore ()
   * InitEmuNonVolatileVariableStore ()
   * InitNonVolatileVariableStore ()

 [edk2-devel] [PATCH V2 7/9] MdeModulePkg/Variable: Add RT GetVariable() cache 
support
 * Added a FeaturePCD to control enabling the runtime variable cache -
   gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache.
 * Removed usage of the TimerLib and the wait to acquire
   mVariableRuntimeCacheReadLock. Can rely on the UEFI specification
   restrictions on Runtime Services callers.
 * Removed the EFIAPI keyword from internal functions.
 * Removed PCDs in VariableSmmRuntimeDxe.inf not required.
 * Removed the HobVariableBackupBase variable no longer required.
 * Renamed SynchronizeRuntimeVariableCacheEx () to better reflect usage.
 * Renamed functions in VariableRuntimeCache.c to better reflect usage.
 * Introduced a local variable in FlushPendingRuntimeVariableCacheUpdates ()
   to reduce duplication of 
   mVariableModuleGlobal->VariableGlobal.VariableRuntimeCacheContext.
 * Corrected the macro used in SmmVariableHandler () to
   SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT.
 * Remove usage of the EDKII_PI_SMM_COMMUNICATION_REGION_TABLE to acquire a
   CommBuffer from the EFI System Table and use the same runtime CommBuffer
   allocated for variable SMM communicate calls.

 [PATCH V2 8/9] MdeModulePkg/Variable: Add RT GetNextVariableName() cache 
support
 * Removed usage of the TimerLib and the wait to acquire
   mVariableRuntimeCacheReadLock. Can rely on the UEFI specification 
restrictions
   on Runtime Services callers.

 * Added a new patch to disable 
gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache
   for all OvmfPkg package builds as requested by maintainer Laszlo Ersek.

V2 Changes:

Patch #1 in V1 both moved functions to VariableParsing.c and modified some
functionality in those functions. In V2, the functions are first moved and
then functionality is modified in subsequent patches. This resulted in the
following new patches in the V2 patch series:

 1. MdeModulePkg/Variable: Parameterize GetNextVariableEx() store list
 2. MdeModulePkg/Variable: Parameterize VARIABLE_INFO_ENTRY buffer
 3. MdeModulePkg/Variable: Add local auth status in VariableParsing
 4. MdeModulePkg/Variable: Add a file for NV variable functions

Apart from this 

[edk2-devel] [PATCH V5 06/10] MdeModulePkg VariableInfo: Always consider RT DXE and SMM stats

2019-10-17 Thread Kubacki, Michael A
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2220

The current VariableInfo application only checks for variable
statistics from SMM if the variable information entries are
not present in the UEFI System Configuration table as published
by the DXE UEFI variable driver (VariableRuntimeDxe).

This change first checks for variable information entries in the
UEFI System Configuration but always checks for entries in SMM
as well. If the SMM variable driver is not present, an instance of
EFI_SMM_VARIABLE_PROTOCOL will not be found and the search for
SMM variable statistics will be aborted (an SW SMI to get variable
statistics will not be triggered).

In the case variable statistics are provided by both a Runtime DXE
driver (e.g. VariableSmmRuntimeDxe) and a SMM driver (VariableSmm),
this change will clearly identify statistics from each respective
driver.

Cc: Dandan Bi 
Cc: Ard Biesheuvel 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Ray Ni 
Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Jiewen Yao 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Application/VariableInfo/VariableInfo.c | 37 ++--
 1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/MdeModulePkg/Application/VariableInfo/VariableInfo.c 
b/MdeModulePkg/Application/VariableInfo/VariableInfo.c
index f213471e9a..c04ba18213 100644
--- a/MdeModulePkg/Application/VariableInfo/VariableInfo.c
+++ b/MdeModulePkg/Application/VariableInfo/VariableInfo.c
@@ -3,7 +3,7 @@
   this utility will print out the statistics information. You can use console
   redirection to capture the data.
 
-  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -126,7 +126,7 @@ PrintInfoFromSmm (
   ASSERT (CommBuffer != NULL);
   ZeroMem (CommBuffer, RealCommSize);
 
-  Print (L"Non-Volatile SMM Variables:\n");
+  Print (L"SMM Driver Non-Volatile Variables:\n");
   do {
 CommSize = RealCommSize;
 Status = GetVariableStatisticsData (CommBuffer, );
@@ -155,7 +155,7 @@ PrintInfoFromSmm (
 }
   } while (TRUE);
 
-  Print (L"Volatile SMM Variables:\n");
+  Print (L"SMM Driver Volatile Variables:\n");
   ZeroMem (CommBuffer, RealCommSize);
   do {
 CommSize = RealCommSize;
@@ -207,24 +207,18 @@ UefiMain (
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
-  EFI_STATUSStatus;
+  EFI_STATUSRuntimeDxeStatus;
+  EFI_STATUSSmmStatus;
   VARIABLE_INFO_ENTRY   *VariableInfo;
   VARIABLE_INFO_ENTRY   *Entry;
 
-  Status = EfiGetSystemConfigurationTable (, (VOID **));
-  if (EFI_ERROR (Status) || (Entry == NULL)) {
-Status = EfiGetSystemConfigurationTable (, 
(VOID **));
+  RuntimeDxeStatus = EfiGetSystemConfigurationTable (, (VOID 
**) );
+  if (EFI_ERROR (RuntimeDxeStatus) || (Entry == NULL)) {
+RuntimeDxeStatus = EfiGetSystemConfigurationTable 
(, (VOID **) );
   }
 
-  if (EFI_ERROR (Status) || (Entry == NULL)) {
-Status = PrintInfoFromSmm ();
-if (!EFI_ERROR (Status)) {
-  return Status;
-}
-  }
-
-  if (!EFI_ERROR (Status) && (Entry != NULL)) {
-Print (L"Non-Volatile EFI Variables:\n");
+  if (!EFI_ERROR (RuntimeDxeStatus) && (Entry != NULL)) {
+Print (L"Runtime DXE Driver Non-Volatile EFI Variables:\n");
 VariableInfo = Entry;
 do {
   if (!VariableInfo->Volatile) {
@@ -242,7 +236,7 @@ UefiMain (
   VariableInfo = VariableInfo->Next;
 } while (VariableInfo != NULL);
 
-Print (L"Volatile EFI Variables:\n");
+Print (L"Runtime DXE Driver Volatile EFI Variables:\n");
 VariableInfo = Entry;
 do {
   if (VariableInfo->Volatile) {
@@ -258,14 +252,19 @@ UefiMain (
   }
   VariableInfo = VariableInfo->Next;
 } while (VariableInfo != NULL);
+  }
 
-  } else {
+  SmmStatus = PrintInfoFromSmm ();
+
+  if (EFI_ERROR (RuntimeDxeStatus) && EFI_ERROR (SmmStatus)) {
 Print (L"Warning: Variable Dxe/Smm driver doesn't enable the feature of 
statistical information!\n");
 Print (L"If you want to see this info, please:\n");
 Print (L"  1. Set PcdVariableCollectStatistics as TRUE\n");
 Print (L"  2. Rebuild Variable Dxe/Smm driver\n");
 Print (L"  3. Run \"VariableInfo\" cmd again\n");
+
+return EFI_NOT_FOUND;
   }
 
-  return Status;
+  return EFI_SUCCESS;
 }
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49205): https://edk2.groups.io/g/devel/message/49205
Mute This Topic: https://groups.io/mt/34950255/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH V5 04/10] MdeModulePkg/Variable: Parameterize auth status in VariableParsing

2019-10-17 Thread Kubacki, Michael A
The file VariableParsing.c provides generic functionality related
to parsing variable related structures and information. In order to
calculate offsets for certain operations, the functions must know if
authenticated variables are enabled as this increases the size of
variable headers.

This change removes linking against a global variable in an external file
in favor of passing the authenticated variable status as a parameter to
the variable parsing functions.

Cc: Dandan Bi 
Cc: Ard Biesheuvel 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Ray Ni 
Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Jiewen Yao 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h |  82 +--
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c| 258 
++--
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableExLib.c   |  15 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c | 146 +++
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c |   5 +-
 5 files changed, 339 insertions(+), 167 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h
index 1777ce0e69..92a729d140 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h
@@ -49,53 +49,65 @@ GetVariableStoreStatus (
 /**
   This code gets the size of variable header.
 
+  @param[in]  AuthFormatTRUE indicates authenticated variables are used.
+FALSE indicates authenticated variables are not 
used.
+
   @return Size of variable header in bytes in type UINTN.
 
 **/
 UINTN
 GetVariableHeaderSize (
-  VOID
+  IN  BOOLEAN   AuthFormat
   );
 
 /**
 
   This code gets the size of name of variable.
 
-  @param VariablePointer to the Variable Header.
+  @param[in]  Variable  Pointer to the variable header.
+  @param[in]  AuthFormatTRUE indicates authenticated variables are used.
+FALSE indicates authenticated variables are not 
used.
 
   @return UINTN  Size of variable in bytes.
 
 **/
 UINTN
 NameSizeOfVariable (
-  IN  VARIABLE_HEADER   *Variable
+  IN  VARIABLE_HEADER   *Variable,
+  IN  BOOLEAN   AuthFormat
   );
 
 /**
   This code sets the size of name of variable.
 
-  @param[in] Variable   Pointer to the Variable Header.
-  @param[in] NameSize   Name size to set.
+  @param[in]  Variable  Pointer to the Variable Header.
+  @param[in]  NameSize  Name size to set.
+  @param[in]  AuthFormatTRUE indicates authenticated variables are used.
+FALSE indicates authenticated variables are not 
used.
 
 **/
 VOID
 SetNameSizeOfVariable (
   IN VARIABLE_HEADER*Variable,
-  IN UINTN  NameSize
+  IN UINTN  NameSize,
+  IN BOOLEANAuthFormat
   );
 
 /**
 
   This code gets the size of variable data.
 
-  @param VariablePointer to the Variable Header.
+  @param[in]  Variable  Pointer to the Variable Header.
+  @param[in]  AuthFormatTRUE indicates authenticated variables are used.
+FALSE indicates authenticated variables are not 
used.
 
   @return Size of variable in bytes.
 
 **/
 UINTN
 DataSizeOfVariable (
-  IN  VARIABLE_HEADER   *Variable
+  IN  VARIABLE_HEADER   *Variable,
+  IN  BOOLEAN   AuthFormat
   );
 
 /**
@@ -103,80 +115,98 @@ DataSizeOfVariable (
 
   @param[in] Variable   Pointer to the Variable Header.
   @param[in] DataSize   Data size to set.
+  @param[in] AuthFormat TRUE indicates authenticated variables are used.
+FALSE indicates authenticated variables are not used.
 
 **/
 VOID
 SetDataSizeOfVariable (
-  IN VARIABLE_HEADER*Variable,
-  IN UINTN  DataSize
+  IN  VARIABLE_HEADER   *Variable,
+  IN  UINTN DataSize,
+  IN  BOOLEAN   AuthFormat
   );
 
 /**
 
   This code gets the pointer to the variable name.
 
-  @param VariablePointer to the Variable Header.
+  @param[in] Variable Pointer to the Variable Header.
+  @param[in] AuthFormat   TRUE indicates authenticated variables are used.
+  FALSE indicates authenticated variables are not used.
 
   @return Pointer to Variable Name which is Unicode encoding.
 
 **/
 CHAR16 *
 GetVariableNamePtr (
-  IN  VARIABLE_HEADER   *Variable
+  IN  VARIABLE_HEADER   *Variable,
+  IN  BOOLEAN   AuthFormat
   );
 
 /**
   This code gets the pointer to the variable guid.
 
-  @param Variable   Pointer to the Variable Header.
+  @param[in] Variable Pointer to the Variable Header.
+  @param[in] AuthFormat   TRUE indicates authenticated variables are used.
+  FALSE indicates authenticated variables are not used.
 
   @return A EFI_GUID* pointer to Vendor Guid.
 
 **/
 EFI_GUID *
 

[edk2-devel] [PATCH V5 09/10] OvmfPkg: Disable variable runtime cache

2019-10-17 Thread Kubacki, Michael A
Sets gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache
to FALSE in OvmfPkgIa32.dsc, OvmfPkgIa32X64.dsc, and OvmfPkgX64.dsc
so that when SMM_REQUIRE is TRUE, the SMM variable driver will not
use the runtime variable cache.

This is done for OvmfPkg because it currently depends upon a SMM
variable GetVariable ()implementation as a simple method to exercise
the SMM driver stack. This allows the following commands to be used
for variables such as Boot, BootOrder, and BootNext to test SMM
timing and stability differences on the BSP (e.g. CPU#0) vs an
AP (e.g. CPU#1).
 # taskset -c 0 efibootmgr
 # taskset -c 1 efibootmgr

Cc: Ard Biesheuvel 
Cc: Laszlo Ersek 
Cc: Liming Gao 
Cc: Jordan Justen 
Cc: Hao A Wu 
Signed-off-by: Michael Kubacki 
---
 OvmfPkg/OvmfPkgIa32.dsc| 1 +
 OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
 OvmfPkg/OvmfPkgX64.dsc | 1 +
 3 files changed, 3 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 66e944436a..4861e2342b 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -428,6 +428,7 @@
 !if $(SMM_REQUIRE) == TRUE
   gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE
   gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|FALSE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
 !endif
 
 [PcdsFixedAtBuild]
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 51c2bfb44f..f316d97d6a 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -433,6 +433,7 @@
 !if $(SMM_REQUIRE) == TRUE
   gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE
   gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|FALSE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
 !endif
 
 [PcdsFixedAtBuild]
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index ba7a758844..546649f0a2 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -433,6 +433,7 @@
 !if $(SMM_REQUIRE) == TRUE
   gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE
   gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|FALSE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
 !endif
 
 [PcdsFixedAtBuild]
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49208): https://edk2.groups.io/g/devel/message/49208
Mute This Topic: https://groups.io/mt/34950260/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH V5 08/10] MdeModulePkg/Variable: Add RT GetNextVariableName() cache support

2019-10-17 Thread Kubacki, Michael A
https://bugzilla.tianocore.org/show_bug.cgi?id=2220

This change implements the Runtime Service GetNextVariableName()
using the runtime cache in VariableSmmRuntimeDxe. Runtime Service
calls to GetNextVariableName() will no longer trigger a SW SMI
when gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache
is set to TRUE (default value).

Overall system performance and stability will be improved by
eliminating an SMI for these calls as they typically result in a
relatively large number of invocations to retrieve all variable
names in all variable stores present.

Cc: Dandan Bi 
Cc: Ard Biesheuvel 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Ray Ni 
Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Jiewen Yao 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c | 137 
++--
 1 file changed, 128 insertions(+), 9 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
index e236ddff33..a795b9fcab 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
@@ -823,7 +823,7 @@ RuntimeServiceGetVariable (
 }
 
 /**
-  This code Finds the Next available variable.
+  Finds the next available variable in a runtime cache variable store.
 
   @param[in, out] VariableNameSize   Size of the variable name.
   @param[in, out] VariableName   Pointer to variable name.
@@ -836,8 +836,81 @@ RuntimeServiceGetVariable (
 
 **/
 EFI_STATUS
-EFIAPI
-RuntimeServiceGetNextVariableName (
+GetNextVariableNameInRuntimeCache (
+  IN OUT  UINTN *VariableNameSize,
+  IN OUT  CHAR16*VariableName,
+  IN OUT  EFI_GUID  *VendorGuid
+  )
+{
+  EFI_STATUS  Status;
+  UINTN   VarNameSize;
+  VARIABLE_HEADER *VariablePtr;
+  VARIABLE_STORE_HEADER   *VariableStoreHeader[VariableStoreTypeMax];
+
+  Status = EFI_NOT_FOUND;
+
+  //
+  // The UEFI specification restricts Runtime Services callers from invoking 
the same or certain other Runtime Service
+  // functions prior to completion and return from a previous Runtime Service 
call. These restrictions prevent
+  // a GetVariable () or GetNextVariable () call from being issued until a 
prior call has returned. The runtime
+  // cache read lock should always be free when entering this function.
+  //
+  ASSERT (!mVariableRuntimeCacheReadLock);
+
+  CheckForRuntimeCacheSync ();
+
+  mVariableRuntimeCacheReadLock = TRUE;
+  if (!mVariableRuntimeCachePendingUpdate) {
+//
+// 0: Volatile, 1: HOB, 2: Non-Volatile.
+// The index and attributes mapping must be kept in this order as 
FindVariable
+// makes use of this mapping to implement search algorithm.
+//
+VariableStoreHeader[VariableStoreTypeVolatile] = 
mVariableRuntimeVolatileCacheBuffer;
+VariableStoreHeader[VariableStoreTypeHob]  = 
mVariableRuntimeHobCacheBuffer;
+VariableStoreHeader[VariableStoreTypeNv]   = 
mVariableRuntimeNvCacheBuffer;
+
+Status =  VariableServiceGetNextVariableInternal (
+VariableName,
+VendorGuid,
+VariableStoreHeader,
+,
+mVariableAuthFormat
+);
+if (!EFI_ERROR (Status)) {
+  VarNameSize = NameSizeOfVariable (VariablePtr, mVariableAuthFormat);
+  ASSERT (VarNameSize != 0);
+  if (VarNameSize <= *VariableNameSize) {
+CopyMem (VariableName, GetVariableNamePtr (VariablePtr, 
mVariableAuthFormat), VarNameSize);
+CopyMem (VendorGuid, GetVendorGuidPtr (VariablePtr, 
mVariableAuthFormat), sizeof (EFI_GUID));
+Status = EFI_SUCCESS;
+  } else {
+Status = EFI_BUFFER_TOO_SMALL;
+  }
+
+  *VariableNameSize = VarNameSize;
+}
+  }
+  mVariableRuntimeCacheReadLock = FALSE;
+
+  return Status;
+}
+
+/**
+  Finds the next available variable in a SMM variable store.
+
+  @param[in, out] VariableNameSize   Size of the variable name.
+  @param[in, out] VariableName   Pointer to variable name.
+  @param[in, out] VendorGuid Variable Vendor Guid.
+
+  @retval EFI_INVALID_PARAMETER  Invalid parameter.
+  @retval EFI_SUCCESSFind the specified variable.
+  @retval EFI_NOT_FOUND  Not found.
+  @retval EFI_BUFFER_TO_SMALLDataSize is too small for the result.
+
+**/
+EFI_STATUS
+GetNextVariableNameInSmm (
   IN OUT  UINTN *VariableNameSize,
   IN OUT  CHAR16*VariableName,
   IN OUT  EFI_GUID  *VendorGuid
@@ -849,10 +922,6 @@ RuntimeServiceGetNextVariableName (
   UINTN   OutVariableNameSize;
   UINTN   InVariableNameSize;
 
-  if 

[edk2-devel] [PATCH V5 10/10] MdeModulePkg: Enable variable runtime cache by default

2019-10-17 Thread Kubacki, Michael A
This change enables the variable runtime cache by default by setting
gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache in
MdeModulePkg.dec to TRUE.

Cc: Dandan Bi 
Cc: Ard Biesheuvel 
Cc: Eric Dong 
Cc: Laszlo Ersek 
Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Ray Ni 
Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Jiewen Yao 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/MdeModulePkg.dec | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 3ef8fe7644..1e964f5903 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -651,7 +651,7 @@
   #   TRUE  - The UEFI variable runtime cache is enabled.
   #   FALSE - The UEFI variable runtime cache is disabled.
   # @Prompt Enable the UEFI variable runtime cache.
-  
gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE|BOOLEAN|0x00010039
+  
gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|TRUE|BOOLEAN|0x00010039
 
   ## Indicates if the statistics about variable usage will be collected. This 
information is
   #  stored as a vendor configuration table into the EFI system table.
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#49209): https://edk2.groups.io/g/devel/message/49209
Mute This Topic: https://groups.io/mt/34950263/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-