Re: [edk2-devel] [PATCH v3 1/1] MdeModulePkg: Fix issue with ACPI table creation

2023-11-28 Thread Pedro Falcato
On Mon, Nov 20, 2023 at 4:24 AM Dhaval Sharma  wrote:
>
> As per ACPI Spec 6.5+ Table 5-9 if xDSDT is avaialble,

nit: available

> it should be used first. Handle required flow when xDSDT
> is abscent or present.

nit: absent

Separate nit: Please update the patch's subject to something more
descriptive. "Fix issue with ..." is really generic and useless for
anyone reading the log/blame.
Maybe something like "MdeModulePkg/AcpiTableDxe: Prefer xDSDT over
DSDT when installing tables"?

>
> Test: Tested on RISCV64 Qemu platform with xDSDT and booted to
> linux kernel.
>
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> Cc: Dandan Bi 
> Signed-off-by: Dhaval Sharma 
> ---
>
> Notes:
> v2:
> - Added proper indentation for else if
>
>  MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 22 
> +---
>  1 file changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c 
> b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> index e09bc9b704f5..ead8376177c9 100644
> --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> @@ -1892,14 +1892,22 @@ InstallAcpiTableFromHob (
>}
>  }
>
> -if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)ChildTable)->Dsdt 
> != 0) {
> +//
> +// First check if xDSDT is available that is preferred as per

nit: available, as that is preferred...

> +// ACPI Spec 6.5+ Table 5-9 X_DSDT definition
> +//
> +if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)ChildTable)->XDsdt 
> != 0) {
> +  TableToInstall = (VOID 
> *)(UINTN)((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)ChildTable)->XDsdt;

(+CC Gerd for qemu)
Is it possible that XDsdt may come filled out with a > 32-bit address
on 32-bit platforms/builds? In other words, is truncation of the
address a problem here? Assuming all of these tables are coming from
qemu + OvmfPkg/AcpiPlatformDxe, that is. I would not expect real
platforms to ever do such a thing.

For what it's worth, I checked the spec, and it clearly mentions that
the *OSPM* must ignore DSDT over X_DSDT. But we're not OSPM, so we're
not exactly bound by their constraints.

-- 
Pedro


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111837): https://edk2.groups.io/g/devel/message/111837
Mute This Topic: https://groups.io/mt/102702109/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH 1/1] BaseTools/Scripts/PatchCheck.py: Check for Change-id

2023-11-28 Thread Pedro Falcato
On Wed, Nov 29, 2023 at 12:56 AM Ni, Ray  wrote:
>
> It's good. But I am curious why --ignore-change-id is needed?

I didn't ask, but presumably, if you have an internal gerrit instance
that runs CI before pushing, PatchCheck.py may be part of the CI
workflow; in those cases, we don't want it to error out.
So the CI would be adapted to do PatchCheck.py --ignore-change-id, and
all is well.

-- 
Pedro


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111836): https://edk2.groups.io/g/devel/message/111836
Mute This Topic: https://groups.io/mt/102748141/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v1 1/1] BaseTools/Conf/target.template: Use VS2019 as default tool chain

2023-11-28 Thread Yuwei Chen
Reviewed-by: Yuwei Chen 

> -Original Message-
> From: mikub...@linux.microsoft.com 
> Sent: Wednesday, November 29, 2023 3:49 AM
> To: devel@edk2.groups.io
> Cc: Feng, Bob C ; Gao, Liming
> ; Rebecca Cran ; Chen,
> Christine 
> Subject: [PATCH v1 1/1] BaseTools/Conf/target.template: Use VS2019 as
> default tool chain
> 
> From: Michael Kubacki 
> 
> Updates the default tool chain from VS2015x86 to VS2019.
> 
> This is the VS tool chain used in CI and more likely to be installed on
> developer's systems. This is used in stuart commands when a toolchain is not
> explicitly specified.
> 
> Cc: Bob Feng 
> Cc: Liming Gao 
> Cc: Rebecca Cran 
> Cc: Yuwei Chen 
> Signed-off-by: Michael Kubacki 
> ---
>  BaseTools/Conf/target.template | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/BaseTools/Conf/target.template b/BaseTools/Conf/target.template
> index d4a3b53b7f3e..592febf55762 100644
> --- a/BaseTools/Conf/target.template
> +++ b/BaseTools/Conf/target.template
> @@ -22,8 +22,8 @@ ACTIVE_PLATFORM   = EmulatorPkg/EmulatorPkg.dsc
>  #  TARGETList   OptionalZero or more of the 
> following: DEBUG,
> RELEASE, NOOPT
>  #   UserDefined; separated by a 
> space character.
>  #   If the line is missing or no 
> value is specified, all
> -#   valid targets specified in 
> the platform description
> file
> -#   will attempt to be built. 
> The following line will
> build
> +#   valid targets specified in 
> the platform description
> file
> +#   will attempt to be built. 
> The following line will
> build
>  #   DEBUG platform target.
>  TARGET= DEBUG
> 
> @@ -32,7 +32,7 @@ TARGET= DEBUG
>  #   or AArch64.
>  #   Multiple values can be 
> specified on a single line,
> using
>  #   space characters to separate 
> the values.  These
> are used
> -#   during the parsing of a 
> platform description file,
> +#   during the parsing of a 
> platform description file,
>  #   restricting the build output 
> target(s.)
>  #   The Build Target ARCH is 
> determined by
> (precedence high to low):
>  # Command-line: -a ARCH 
> option
> @@ -51,7 +51,7 @@ TOOL_CHAIN_CONF   = Conf/tools_def.txt
>  #  TAGNAME   List  Optional   Specify the name(s) of the 
> tools_def.txt
> TagName to use.
>  # If not specified, all 
> applicable TagName tools will
> be
>  # used for the build.  The list 
> uses space character
> separation.
> -TOOL_CHAIN_TAG= VS2015x86
> +TOOL_CHAIN_TAG= VS2019
> 
>  # MAX_CONCURRENT_THREAD_NUMBER  NUMBER  Optional  The number
> of concurrent threads. If not specified or set
>  # to zero, tool 
> automatically detect number of
> processor
> @@ -64,7 +64,7 @@ TOOL_CHAIN_TAG= VS2015x86
> 
> 
>  # BUILD_RULE_CONF  Filename Optional  Specify the file name to use for the
> build rules that are followed
> -# when generating Makefiles. If not 
> specified, the file:
> +# when generating Makefiles. If not 
> specified, the file:
>  # WORKSPACE/Conf/build_rule.txt will be 
> used
>  BUILD_RULE_CONF = Conf/build_rule.txt
> 
> --
> 2.42.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111835): https://edk2.groups.io/g/devel/message/111835
Mute This Topic: https://groups.io/mt/102858057/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 09/39] MdePkg: Add a new library named PeiServicesTablePointerLibReg

2023-11-28 Thread Chao Li

Hi Mike and Liming,

Ping for review, I'd love to know your opinion, as the last email saied, 
your opinion can decide the direction, so please review the new patches 
of MdePkg for this series, please...



Thanks,
Chao
On 2023/11/27 11:27, Chao Li wrote:


Hi Mike and Liming,

You opinion is very important, it will decide the direction. I will 
send the V4 this week, so can you please review the new patch of 
MdePkg for this series?


On 2023/11/24 19:35, Laszlo Ersek wrote:

On 11/22/23 02:47, Chao Li wrote:

Hi Laszlo,


Thanks,
Chao
On 2023/11/21 22:37, Laszlo Ersek wrote:

On 11/17/23 10:59, Chao Li wrote:

Since some ARCH or platform not require execute code on memory during
PEI phase, some values may transferred via CPU registers.

Adding PeiServcieTablePointerLibReg to allow set and get the PEI service
table pointer depend by a CPU register, this library can accommodate lot
of platforms who not require execte code on memory during PEI phase.

Adding PeiServiceTablePointerLibReg to allows setting and getting the
PEI service table pointer via CPU registers, and the library can
accommodate many platforms that do not need to execute code on memory
during the PEI phase.

The idea of this library is derived from
ArmPkg/Library/PeiServicesTablePointerLib/

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

Cc: Michael D Kinney
Cc: Liming Gao
Cc: Zhiguang Liu
Cc: Leif Lindholm
Cc: Ard Biesheuvel
Cc: Sami Mujawar
Cc: Laszlo Ersek
Cc: Sunil V L
Signed-off-by: Chao Li
---
  .../Library/PeiServicesTablePointerLib.h  | 37 +++-
  .../PeiServicesTablePointer.c | 86 +++
  .../PeiServicesTablePointerLib.uni| 20 +
  .../PeiServicesTablePointerLibReg.inf | 40 +
  MdePkg/MdePkg.dsc |  1 +
  5 files changed, 180 insertions(+), 4 deletions(-)
  create mode 100644 
MdePkg/Library/PeiServicesTablePointerLibReg/PeiServicesTablePointer.c
  create mode 100644 
MdePkg/Library/PeiServicesTablePointerLibReg/PeiServicesTablePointerLib.uni
  create mode 100644 
MdePkg/Library/PeiServicesTablePointerLibReg/PeiServicesTablePointerLibReg.inf

In my opinion, the PeiServicesTablePointerLib class header should not be
extended with new interfaces. I understand that the generality is
attractive, but it is not put to use; only the loongarch architecture
applies the new interfaces (in the subsequent patch), and for example
the ARM code (ArmPkg/Library/PeiServicesTablePointerLib) is not reworked
in terms of these new interfaces.

This libarary have ability of accommodate more ARCH why not? I checked
the PI SPEC, all ARCH except IA32 and X64 using the register mechanism,
if this library can be approved, all of them can moved into this
libraryso that code con be reused more, I think this library is fine.

The library may be fine from a design point of view, but without
actually putting the extra generality to use, it's a waste. It's a
maintenance burden. There's a name for this anti-pattern: it is called
"speculative generality". "It might be useful down the road."

The new generality is only useful if it carries its own weight; namely,
if other platform code (aarch64, x64) is converted to it immediately, in
the same series. (I'm not asking for this series to be longer. You could
even split it up into multiple "waves" of series.) Just saying that
"could prove useful later" is a prime way to generate technical debt.


What's more, the new library interfaces, even though they are exposed in
the lib class header, are not implemented for other architectures, so
they aren't even callable on those arches.

The patch 10 in this series has added LoongArch instance of this
library, please check.

Yes, I'm aware. That's not the point.

When you extend a library *class* with a new API, that means all
*clients* of the library class can stat calling that API. Which in turn
means that *all* existent instances of the library class must implement
the API as well.

Your series extends the lib class with a new API, but (IIUC) only
implements the new API in one (new) lib instance, and not in the other
(existent) instances. This has the potential to cause linkage errors,
dependent on the actual library instance that a platform DSC chooses.



I'm commenting on this patch and the subsequent patch in the series
together, as seen squashed together. NB I'm not an MdePkg maintainer, so
this is just my opinion.

So, Mike and Liming, what do your think?

(1) As noted above, the library class should not be modified.

(2) Modifying the *comments* in
"MdePkg/Include/Library/PeiServicesTablePointerLib.h" is welcome, I
think, but then we might want to add a (separate!) patch for removing
the Itanium language, as edk2 no longer supports Itanium.

(3) The PeiServicesTablePointerLibReg instance should be called
PeiServicesTablePointerLibCsrKs0 or just PeiServicesTablePointerLibKs0.

This library will be a public libray which using the reigster mechanism,
so the name like 

Re: [edk2-devel] [PATCH 1/1] BaseTools/Scripts/PatchCheck.py: Check for Change-id

2023-11-28 Thread Yuwei Chen
Ray do you mean set it as default checking?
It is a good point.

> -Original Message-
> From: Ni, Ray 
> Sent: Wednesday, November 29, 2023 8:56 AM
> To: devel@edk2.groups.io; Chen, Christine ; Pierre
> Gondois 
> Cc: Rebecca Cran ; Gao, Liming
> ; Feng, Bob C ; Sami
> Mujawar ; yeoreum@arm.com
> Subject: RE: [edk2-devel] [PATCH 1/1] BaseTools/Scripts/PatchCheck.py: Check
> for Change-id
> 
> It's good. But I am curious why --ignore-change-id is needed?
> 
> Thanks,
> Ray
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Yuwei
> > Chen
> > Sent: Wednesday, November 29, 2023 8:23 AM
> > To: Pierre Gondois ; devel@edk2.groups.io
> > Cc: Rebecca Cran ; Gao, Liming
> > ; Feng, Bob C ; Sami
> > Mujawar ; yeoreum@arm.com
> > Subject: Re: [edk2-devel] [PATCH 1/1] BaseTools/Scripts/PatchCheck.py:
> > Check for Change-id
> >
> > The patch is good for me.
> >
> > Reviewed-by: Yuwei Chen 
> >
> > > -Original Message-
> > > From: Pierre Gondois 
> > > Sent: Wednesday, November 22, 2023 9:15 PM
> > > To: devel@edk2.groups.io
> > > Cc: Rebecca Cran ; Gao, Liming
> > > ; Feng, Bob C ;
> > > Chen, Christine ; Sami Mujawar
> > > ; yeoreum@arm.com
> > > Subject: [PATCH 1/1] BaseTools/Scripts/PatchCheck.py: Check for
> > > Change-id
> > >
> > > Code review tools like gerrit might use a 'Change-id' tag to track
> > > the evolution of patches. This tag should be removed before
> > > submitting a patch to the mailing-list.
> > > It has been observed that contributors sometimes forget to remove this
> tag.
> > > Add a check in PatchCheck.py to automate this.
> > >
> > > Also add a '--ignore-change-id' command line parameter to ignore the
> > > above check.
> > >
> > > Signed-off-by: Pierre Gondois 
> > > ---
> > >  BaseTools/Scripts/PatchCheck.py | 18 +-
> > >  1 file changed, 17 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/BaseTools/Scripts/PatchCheck.py
> > > b/BaseTools/Scripts/PatchCheck.py index 7f372d40b570..7770d1e37318
> > > 100755
> > > --- a/BaseTools/Scripts/PatchCheck.py
> > > +++ b/BaseTools/Scripts/PatchCheck.py
> > > @@ -3,7 +3,7 @@
> > >  # #  Copyright (c) 2015 - 2021, Intel Corporation. All rights
> > > reserved. # Copyright (C) 2020, Red Hat, Inc.-#  Copyright
> > > (c) 2020, ARM Ltd. All
> > rights
> > > reserved.+#  Copyright (c) 2020 - 2023, Arm Limited. All rights
> > > reserved. # #  SPDX-License-Identifier: BSD-2-Clause-Patent #@@
> > > -26,6
> > > +26,9 @@ class Verbose:
> > >  SILENT, ONELINE, NORMAL = range(3) level = NORMAL +class
> > > PatchCheckConf:+ignore_change_id = False+ class EmailAddressCheck:
> > > """Checks an email address.""" @@ -111,6 +114,8 @@ class
> > > CommitMessageCheck:
> > >  self.check_signed_off_by() 
> > > self.check_misc_signatures()
> > > self.check_overall_format()+if not
> PatchCheckConf.ignore_change_id:+
> > > self.check_change_id_format() self.report_message_result()  
> > > url =
> > > 'https://github.com/tianocore/tianocore.github.io/wiki/Commit-Messag
> > > e- Format'@@ -307,6 +312,12 @@ class CommitMessageCheck:
> > >  break last_sig_line = line.strip() +def
> > > check_change_id_format(self):+cid='Change-Id:'+if
> > > self.msg.find(cid) != -1:+self.error('\"%s\" found in commit
> > message:' %
> > > cid)+return+ (START, PRE_PATCH, PATCH) = range(3)  class
> > > GitDiffCheck:@@ -780,11 +791,16 @@ class PatchCheckApp:
> > >  group.add_argument("--silent",
> > > action="store_true",
> > > help="Print nothing")+group.add_argument("--ignore-change-id",+
> > > action="store_true",+   help="Ignore the presence 
> > > of
> 'Change-
> > > id:' tags in commit message") self.args = parser.parse_args() 
> > > if
> > > self.args.oneline: Verbose.level = Verbose.ONELINE if
> > > self.args.silent: Verbose.level = Verbose.SILENT+if
> > > self.args.ignore_change_id:+PatchCheckConf.ignore_change_id =
> True
> > > if __name__ == "__main__": sys.exit(PatchCheckApp().retval)--
> > > 2.25.1
> >
> >
> >
> > 
> >



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111833): https://edk2.groups.io/g/devel/message/111833
Mute This Topic: https://groups.io/mt/102748141/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH 1/1] BaseTools/Scripts/PatchCheck.py: Check for Change-id

2023-11-28 Thread Ni, Ray
It's good. But I am curious why --ignore-change-id is needed?

Thanks,
Ray
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Yuwei
> Chen
> Sent: Wednesday, November 29, 2023 8:23 AM
> To: Pierre Gondois ; devel@edk2.groups.io
> Cc: Rebecca Cran ; Gao, Liming
> ; Feng, Bob C ; Sami
> Mujawar ; yeoreum@arm.com
> Subject: Re: [edk2-devel] [PATCH 1/1] BaseTools/Scripts/PatchCheck.py:
> Check for Change-id
> 
> The patch is good for me.
> 
> Reviewed-by: Yuwei Chen 
> 
> > -Original Message-
> > From: Pierre Gondois 
> > Sent: Wednesday, November 22, 2023 9:15 PM
> > To: devel@edk2.groups.io
> > Cc: Rebecca Cran ; Gao, Liming
> > ; Feng, Bob C ; Chen,
> > Christine ; Sami Mujawar
> > ; yeoreum@arm.com
> > Subject: [PATCH 1/1] BaseTools/Scripts/PatchCheck.py: Check for Change-id
> >
> > Code review tools like gerrit might use a 'Change-id' tag to track the 
> > evolution
> > of patches. This tag should be removed before submitting a patch to the
> > mailing-list.
> > It has been observed that contributors sometimes forget to remove this tag.
> > Add a check in PatchCheck.py to automate this.
> >
> > Also add a '--ignore-change-id' command line parameter to ignore the above
> > check.
> >
> > Signed-off-by: Pierre Gondois 
> > ---
> >  BaseTools/Scripts/PatchCheck.py | 18 +-
> >  1 file changed, 17 insertions(+), 1 deletion(-)
> >
> > diff --git a/BaseTools/Scripts/PatchCheck.py
> > b/BaseTools/Scripts/PatchCheck.py index 7f372d40b570..7770d1e37318
> > 100755
> > --- a/BaseTools/Scripts/PatchCheck.py
> > +++ b/BaseTools/Scripts/PatchCheck.py
> > @@ -3,7 +3,7 @@
> >  # #  Copyright (c) 2015 - 2021, Intel Corporation. All rights 
> > reserved. #
> > Copyright (C) 2020, Red Hat, Inc.-#  Copyright (c) 2020, ARM Ltd. All
> rights
> > reserved.+#  Copyright (c) 2020 - 2023, Arm Limited. All rights
> > reserved. # #  SPDX-License-Identifier: BSD-2-Clause-Patent #@@ -26,6
> > +26,9 @@ class Verbose:
> >  SILENT, ONELINE, NORMAL = range(3) level = NORMAL +class
> > PatchCheckConf:+ignore_change_id = False+ class EmailAddressCheck:
> > """Checks an email address.""" @@ -111,6 +114,8 @@ class
> > CommitMessageCheck:
> >  self.check_signed_off_by() 
> > self.check_misc_signatures()
> > self.check_overall_format()+if not 
> > PatchCheckConf.ignore_change_id:+
> > self.check_change_id_format() self.report_message_result()  url 
> > =
> > 'https://github.com/tianocore/tianocore.github.io/wiki/Commit-Message-
> > Format'@@ -307,6 +312,12 @@ class CommitMessageCheck:
> >  break last_sig_line = line.strip() +def
> > check_change_id_format(self):+cid='Change-Id:'+if
> > self.msg.find(cid) != -1:+self.error('\"%s\" found in commit
> message:' %
> > cid)+return+ (START, PRE_PATCH, PATCH) = range(3)  class
> > GitDiffCheck:@@ -780,11 +791,16 @@ class PatchCheckApp:
> >  group.add_argument("--silent",
> > action="store_true",
> > help="Print nothing")+group.add_argument("--ignore-change-id",+
> > action="store_true",+   help="Ignore the presence 
> > of 'Change-
> > id:' tags in commit message") self.args = parser.parse_args()   
> >   if
> > self.args.oneline: Verbose.level = Verbose.ONELINE if
> > self.args.silent: Verbose.level = Verbose.SILENT+if
> > self.args.ignore_change_id:+PatchCheckConf.ignore_change_id = 
> > True
> > if __name__ == "__main__": sys.exit(PatchCheckApp().retval)--
> > 2.25.1
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111832): https://edk2.groups.io/g/devel/message/111832
Mute This Topic: https://groups.io/mt/102748141/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: 
https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH V1 1/1] SecurityPkg/DxeTpm2MeasureBootLib: Check the Integer overflow

2023-11-28 Thread Min Xu
Reviewed-by: Min Xu 

> -Original Message-
> From: Sun, CepingX 
> Sent: Monday, November 27, 2023 8:41 AM
> To: devel@edk2.groups.io
> Cc: Sun, CepingX ; Yao, Jiewen
> ; Xu, Min M 
> Subject: [PATCH V1 1/1] SecurityPkg/DxeTpm2MeasureBootLib: Check the
> Integer overflow
> 
> From: Ceping Sun 
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4604
> 
> Fields of NumberOfPartitionEntries and SizeOfPartitionEntry in PrimaryHeader
> are both UINT32. UINT32 * UINT32 produce UINT32 but it may overflow. So
> The result should be checked if it is overflow.
> 
> Cc: Jiewen Yao 
> Signed-off-by: Min Xu 
> Signed-off-by: Ceping Sun 
> ---
>  .../Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c| 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git
> a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
> b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
> index 36a256a7af50..1f891ae7f216 100644
> ---
> a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
> +++
> b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
> @@ -210,6 +210,11 @@ Tcg2MeasureGptTable (
>  return EFI_BAD_BUFFER_SIZE;
>}
> 
> +  if (PrimaryHeader->NumberOfPartitionEntries > MAX_UINT32 /
> PrimaryHeader->SizeOfPartitionEntry) {
> +DEBUG ((DEBUG_ERROR, "Overflow of PrimaryHeader-
> >NumberOfPartitionEntries(%d) * PrimaryHeader-
> >SizeOfPartitionEntry(%d)\n", PrimaryHeader->NumberOfPartitionEntries,
> PrimaryHeader->SizeOfPartitionEntry));
> +return EFI_INVALID_PARAMETER;
> +  }
> +
>//
>// Read the partition entry.
>//
> --
> 2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111831): https://edk2.groups.io/g/devel/message/111831
Mute This Topic: https://groups.io/mt/102820849/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH 1/1] BaseTools/Scripts/PatchCheck.py: Check for Change-id

2023-11-28 Thread Yuwei Chen
The patch is good for me.

Reviewed-by: Yuwei Chen 

> -Original Message-
> From: Pierre Gondois 
> Sent: Wednesday, November 22, 2023 9:15 PM
> To: devel@edk2.groups.io
> Cc: Rebecca Cran ; Gao, Liming
> ; Feng, Bob C ; Chen,
> Christine ; Sami Mujawar
> ; yeoreum@arm.com
> Subject: [PATCH 1/1] BaseTools/Scripts/PatchCheck.py: Check for Change-id
> 
> Code review tools like gerrit might use a 'Change-id' tag to track the 
> evolution
> of patches. This tag should be removed before submitting a patch to the
> mailing-list.
> It has been observed that contributors sometimes forget to remove this tag.
> Add a check in PatchCheck.py to automate this.
> 
> Also add a '--ignore-change-id' command line parameter to ignore the above
> check.
> 
> Signed-off-by: Pierre Gondois 
> ---
>  BaseTools/Scripts/PatchCheck.py | 18 +-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Scripts/PatchCheck.py
> b/BaseTools/Scripts/PatchCheck.py index 7f372d40b570..7770d1e37318
> 100755
> --- a/BaseTools/Scripts/PatchCheck.py
> +++ b/BaseTools/Scripts/PatchCheck.py
> @@ -3,7 +3,7 @@
>  # #  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved. #
> Copyright (C) 2020, Red Hat, Inc.-#  Copyright (c) 2020, ARM Ltd. All 
> rights
> reserved.+#  Copyright (c) 2020 - 2023, Arm Limited. All rights
> reserved. # #  SPDX-License-Identifier: BSD-2-Clause-Patent #@@ -26,6
> +26,9 @@ class Verbose:
>  SILENT, ONELINE, NORMAL = range(3) level = NORMAL +class
> PatchCheckConf:+ignore_change_id = False+ class EmailAddressCheck:
> """Checks an email address.""" @@ -111,6 +114,8 @@ class
> CommitMessageCheck:
>  self.check_signed_off_by() 
> self.check_misc_signatures()
> self.check_overall_format()+if not 
> PatchCheckConf.ignore_change_id:+
> self.check_change_id_format() self.report_message_result()  url =
> 'https://github.com/tianocore/tianocore.github.io/wiki/Commit-Message-
> Format'@@ -307,6 +312,12 @@ class CommitMessageCheck:
>  break last_sig_line = line.strip() +def
> check_change_id_format(self):+cid='Change-Id:'+if
> self.msg.find(cid) != -1:+self.error('\"%s\" found in commit 
> message:' %
> cid)+return+ (START, PRE_PATCH, PATCH) = range(3)  class
> GitDiffCheck:@@ -780,11 +791,16 @@ class PatchCheckApp:
>  group.add_argument("--silent",
> action="store_true",
> help="Print nothing")+group.add_argument("--ignore-change-id",+
> action="store_true",+   help="Ignore the presence of 
> 'Change-
> id:' tags in commit message") self.args = parser.parse_args() 
> if
> self.args.oneline: Verbose.level = Verbose.ONELINE if
> self.args.silent: Verbose.level = Verbose.SILENT+if
> self.args.ignore_change_id:+PatchCheckConf.ignore_change_id = True
> if __name__ == "__main__": sys.exit(PatchCheckApp().retval)--
> 2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111830): https://edk2.groups.io/g/devel/message/111830
Mute This Topic: https://groups.io/mt/102748141/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 v1] WhitleyOpenBoardPkg: Replace Python Interpreter Name

2023-11-28 Thread Nate DeSimone
Pushed as 7528798

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Nate DeSimone
Sent: Friday, November 17, 2023 10:36 PM
To: devel@edk2.groups.io
Cc: Chiu, Chasel 
Subject: [edk2-devel] [edk2-platforms][PATCH v1] WhitleyOpenBoardPkg: Replace 
Python Interpreter Name

Removes the assumption that the python interpreter will have the name python.

Cc: Chasel Chiu 
Signed-off-by: Nate DeSimone 
+# Copyright (c) 2021 - 2023, Intel Corporation. All rights 
+reserved.
 # Copyright (c) 2022, American Megatrends International LLC.   # 
SPDX-License-Identifier: BSD-2-Clause-Patent  # @@ -107,7 +107,7 @@ def 
pre_build_ex(config, functions):
 if not os.path.exists(out_file_dir):
 os.mkdir(out_file_dir)
 
-command = ["python",
+command = [sys.executable,
os.path.join(config["MIN_PACKAGE_TOOLS"], "AmlGenOffset", 
"AmlGenOffset.py"),
"-d", "--aml_filter", config["AML_FILTER"],
"-o", out_file_path,
diff --git a/Platform/Intel/WhitleyOpenBoardPkg/JunctionCity/build_board.py 
b/Platform/Intel/WhitleyOpenBoardPkg/JunctionCity/build_board.py
index ccf7a8c55a..61b893686c 100644
--- a/Platform/Intel/WhitleyOpenBoardPkg/JunctionCity/build_board.py
+++ b/Platform/Intel/WhitleyOpenBoardPkg/JunctionCity/build_board.py
@@ -2,7 +2,7 @@
 # Extensions for building JunctionCity using build_bios.py  #  # -# Copyright 
(c) 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2021 - 2023, Intel Corporation. All rights 
+reserved.
 # Copyright (c) 2021, American Megatrends International LLC.   # 
SPDX-License-Identifier: BSD-2-Clause-Patent  # @@ -107,7 +107,7 @@ def 
pre_build_ex(config, functions):
 if not os.path.exists(out_file_dir):
 os.mkdir(out_file_dir)
 
-command = ["python",
+command = [sys.executable,
os.path.join(config["MIN_PACKAGE_TOOLS"], "AmlGenOffset", 
"AmlGenOffset.py"),
"-d", "--aml_filter", config["AML_FILTER"],
"-o", out_file_path,
diff --git a/Platform/Intel/WhitleyOpenBoardPkg/WilsonCityRvp/build_board.py 
b/Platform/Intel/WhitleyOpenBoardPkg/WilsonCityRvp/build_board.py
index e2d32d3e13..8d62dd43b8 100644
--- a/Platform/Intel/WhitleyOpenBoardPkg/WilsonCityRvp/build_board.py
+++ b/Platform/Intel/WhitleyOpenBoardPkg/WilsonCityRvp/build_board.py
@@ -1,7 +1,7 @@
 # @ build_board.py
 # Extensions for building WilsonCityRvp using build_bios.py  # -# Copyright 
(c) 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2021 - 2023, Intel Corporation. All rights 
+reserved.
 # SPDX-License-Identifier: BSD-2-Clause-Patent  #
 
@@ -105,7 +105,7 @@ def pre_build_ex(config, functions):
 if not os.path.exists(out_file_dir):
 os.mkdir(out_file_dir)
 
-command = ["python",
+command = [sys.executable,
os.path.join(config["MIN_PACKAGE_TOOLS"], "AmlGenOffset", 
"AmlGenOffset.py"),
"-d", "--aml_filter", config["AML_FILTER"],
"-o", out_file_path,
--
2.34.1








-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111829): https://edk2.groups.io/g/devel/message/111829
Mute This Topic: https://groups.io/mt/102862612/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 v1] MinPlatformPkg: Remove usage of PYTHON_HOME

2023-11-28 Thread Nate DeSimone
Pushed as 073fbeb

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Nate DeSimone
Sent: Friday, November 17, 2023 10:36 PM
To: devel@edk2.groups.io
Cc: Chiu, Chasel ; Gao, Liming 
; Dong, Eric 
Subject: [edk2-devel] [edk2-platforms][PATCH v1] MinPlatformPkg: Remove usage 
of PYTHON_HOME

Removes usage PYTHON_HOME from RebaseFspBinBaseAddress.py

Cc: Chasel Chiu 
Cc: Liming Gao 
Cc: Eric Dong 
Signed-off-by: Nate DeSimone 
---
 .../MinPlatformPkg/Tools/Fsp/RebaseFspBinBaseAddress.py   | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseFspBinBaseAddress.py 
b/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseFspBinBaseAddress.py
index b7e4bcf5f9..32db9eb1c4 100644
--- a/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseFspBinBaseAddress.py
+++ b/Platform/Intel/MinPlatformPkg/Tools/Fsp/RebaseFspBinBaseAddress.py
@@ -1,6 +1,6 @@
 ## @ RebaseFspBinBaseAddress.py
 #
-# Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2019 - 2023, Intel Corporation. All rights 
+reserved.
 # SPDX-License-Identifier: BSD-2-Clause-Patent  #
 
@@ -65,11 +65,7 @@ file.close()
 # Get FSP-M Size, in order to calculate the FSP-T Base. Used SplitFspBin.py 
script  # to dump the header, and get the ImageSize in FSP-M section  # 
-pythontool = 'python'
-if 'PYTHON_HOME' in os.environ:
-pythontool = os.environ['PYTHON_HOME'] + os.sep + 'python'
-else:
-pythontool = sys.executable
+pythontool = sys.executable
 Process = subprocess.Popen([pythontool, splitFspBinPath, 
"info","-f",fspBinFilePath], stdout=subprocess.PIPE)  Output = 
Process.communicate()[0]  FsptInfo = Output.rsplit(b"FSP_M", 1);
--
2.34.1








-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111828): https://edk2.groups.io/g/devel/message/111828
Mute This Topic: https://groups.io/mt/102667304/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 v1] PurleyOpenBoardPkg: Replace Python Interpreter Name

2023-11-28 Thread Nate DeSimone
Pushed as 15e9fae

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Nate DeSimone
Sent: Friday, November 17, 2023 10:36 PM
To: devel@edk2.groups.io
Cc: Chiu, Chasel 
Subject: [edk2-devel] [edk2-platforms][PATCH v1] PurleyOpenBoardPkg: Replace 
Python Interpreter Name

Removes the assumption that the python interpreter will have the name python.

Cc: Chasel Chiu 
Signed-off-by: Nate DeSimone 
---
 .../PurleyOpenBoardPkg/BoardMtOlympus/build_board.py   |  8 
 .../PurleyOpenBoardPkg/BoardTiogaPass/build_board.py   | 10 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/Platform/Intel/PurleyOpenBoardPkg/BoardMtOlympus/build_board.py 
b/Platform/Intel/PurleyOpenBoardPkg/BoardMtOlympus/build_board.py
index 2ba615d3e4..ffe762e289 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardMtOlympus/build_board.py
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardMtOlympus/build_board.py
@@ -1,7 +1,7 @@
 # @ build_board.py
 # This adds additional functions to the build_bios.py  # -# Copyright (c) 
2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2019 - 2023, Intel Corporation. All rights 
+reserved.
 # SPDX-License-Identifier: BSD-2-Clause-Patent  #
 
@@ -48,7 +48,7 @@ def pre_build_ex(config, functions):
 print("AML_FILTER= ", config.get("AML_FILTER"))
 
 # build the command with arguments
-command = ["python",
+command = [sys.executable,
os.path.join(config["MIN_PACKAGE_TOOLS"],
 "AmlGenOffset",
 "AmlGenOffset.py"), @@ -110,7 +110,7 @@ def 
post_build_ex(config, functions):
 print("post_build_ex Error")
 sys.exit(1)
 
-common_patch_command = [os.path.join(config["PYTHON_HOME"], "python"),
+common_patch_command = [sys.executable,
 os.path.join(config["MIN_PACKAGE_TOOLS"],
  "PatchFv", "PatchBinFv.py"),
 config["TARGET"], @@ -131,7 +131,7 @@ def 
post_build_ex(config, functions):
 print("Patch Error!")
 sys.exit(1)
 
-common_rebase_command = [os.path.join(config["PYTHON_HOME"], "python"),
+common_rebase_command = [sys.executable,
  os.path.join(config["MIN_PACKAGE_TOOLS"],
   "PatchFv", "RebaseBinFv.py"),
  config["TARGET"], diff --git 
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/build_board.py 
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/build_board.py
index 46fd389ef1..3b66df7115 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/build_board.py
+++ b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/build_board.py
@@ -1,7 +1,7 @@
 # @ build_board.py
 # This adds additional functions to the build_bios.py  # -# Copyright (c) 
2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2018 - 2023, Intel Corporation. All rights 
+reserved.
 # Copyright (c) 2021, American Megatrends International LLC.  # 
SPDX-License-Identifier: BSD-2-Clause-Patent  # @@ -49,7 +49,7 @@ def 
pre_build_ex(config, functions):
 print("AML_FILTER= ", config.get("AML_FILTER"))
 
 # build the command with arguments
-command = ["python",
+command = [sys.executable,
os.path.join(config["MIN_PACKAGE_TOOLS"],
 "AmlGenOffset",
 "AmlGenOffset.py"), @@ -111,7 +111,7 @@ def 
post_build_ex(config, functions):
 print("post_build_ex Error")
 sys.exit(1)
 
-common_patch_command = [os.path.join(config["PYTHON_HOME"], "python"),
+common_patch_command = [sys.executable,
 os.path.join(config["MIN_PACKAGE_TOOLS"],
  "PatchFv", "PatchBinFv.py"),
 config["TARGET"], @@ -132,7 +132,7 @@ def 
post_build_ex(config, functions):
 print("Patch Error!")
 sys.exit(1)
 
-common_rebase_command = [os.path.join(config["PYTHON_HOME"], "python"),
+common_rebase_command = [sys.executable,
  os.path.join(config["MIN_PACKAGE_TOOLS"],
   "PatchFv", "RebaseBinFv.py"),
  config["TARGET"], @@ -161,7 +161,7 @@ def 
post_build_ex(config, functions):
 print("Patch Error!")
 sys.exit(1)
 
-common_patchbfv_command = [os.path.join(config["PYTHON_HOME"], "python"),
+common_patchbfv_command = [sys.executable,
os.path.join(config["MIN_PACKAGE_TOOLS"],
   "PatchFv", "PatchBfv.py"),
os.path.join(config["BUILD_DIR_PATH"],
--
2.34.1








-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111827): https://edk2.groups.io/g/devel/message/111827
Mute This Topic: 

[edk2-devel] [PATCH v2 1/1] SecurityPkg/Tpm2CommandLib: Add new digest list copy and size functions

2023-11-28 Thread Michael Kubacki
From: Michael Kubacki 

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

Adds two new helper functions.

Currently, a function exists in Tpm2CommandLib to copy a digest list
to a buffer. A function to perform the inverse operation - copying
from a buffer to a digest list is added.

A function is also added to compute the total digest size for a given
hash algorithm mask.

Cc: Jiewen Yao 
Cc: Rahul Kumar 
Signed-off-by: Michael Kubacki 
---

Notes:
v2 change:

- ECC non-functional fix in
  GetDigestListSizeFromHashAlgorithmMask().

 SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 87 
 SecurityPkg/Include/Library/Tpm2CommandLib.h  | 33 
 2 files changed, 120 insertions(+)

diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c 
b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
index e7f30b673f0e..796971bb1599 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
@@ -290,6 +290,67 @@ CopyDigestListToBuffer (
   return Buffer;
 }
 
+/**
+  Copy a buffer into a TPML_DIGEST_VALUES structure.
+
+  @param[in] Buffer Buffer to hold TPML_DIGEST_VALUES compact 
binary.
+  @param[in] BufferSize Size of Buffer.
+  @param[out]DigestList TPML_DIGEST_VALUES.
+
+  @retval EFI_SUCCESS   Buffer was succesfully copied to Digest 
List.
+  @retval EFI_BAD_BUFFER_SIZE   Bad buffer size passed to function.
+  @retval EFI_INVALID_PARAMETER Invalid parameter passed to function: NULL 
pointer or
+BufferSize bigger than TPML_DIGEST_VALUES
+**/
+EFI_STATUS
+EFIAPI
+CopyBufferToDigestList (
+  IN CONST  VOID*Buffer,
+  INUINTN   BufferSize,
+  OUT   TPML_DIGEST_VALUES  *DigestList
+  )
+{
+  EFI_STATUS   Status;
+  UINTNIndex;
+  UINT16   DigestSize;
+  CONST UINT8  *BufferPtr;
+
+  Status = EFI_INVALID_PARAMETER;
+
+  if ((Buffer == NULL) || (DigestList == NULL) || (BufferSize > sizeof 
(TPML_DIGEST_VALUES))) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  DigestList->count = SwapBytes32 (ReadUnaligned32 ((CONST UINT32 *)Buffer));
+  if (DigestList->count > HASH_COUNT) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  BufferPtr = (CONST UINT8 *)Buffer +  sizeof (UINT32);
+  for (Index = 0; Index < DigestList->count; Index++) {
+if (BufferPtr - (CONST UINT8 *)Buffer + sizeof (UINT16) > BufferSize) {
+  Status = EFI_BAD_BUFFER_SIZE;
+  break;
+} else {
+  DigestList->digests[Index].hashAlg = SwapBytes16 (ReadUnaligned16 
((CONST UINT16 *)BufferPtr));
+}
+
+BufferPtr += sizeof (UINT16);
+DigestSize = GetHashSizeFromAlgo (DigestList->digests[Index].hashAlg);
+if (BufferPtr - (CONST UINT8 *)Buffer + (UINTN)DigestSize > BufferSize) {
+  Status = EFI_BAD_BUFFER_SIZE;
+  break;
+} else {
+  CopyMem (>digests[Index].digest, BufferPtr, DigestSize);
+}
+
+BufferPtr += DigestSize;
+Status = EFI_SUCCESS;
+  }
+
+  return Status;
+}
+
 /**
   Get TPML_DIGEST_VALUES data size.
 
@@ -316,6 +377,32 @@ GetDigestListSize (
   return TotalSize;
 }
 
+/**
+  Get the total digest size from a hash algorithm mask.
+
+  @param[in] HashAlgorithmMask.
+
+  @return Digest size in bytes.
+**/
+UINT32
+EFIAPI
+GetDigestListSizeFromHashAlgorithmMask (
+  IN UINT32  HashAlgorithmMask
+  )
+{
+  UINTN   Index;
+  UINT32  TotalSize;
+
+  TotalSize = sizeof (UINT32);
+  for (Index = 0; Index < ARRAY_SIZE (mHashInfo); Index++) {
+if ((mHashInfo[Index].HashMask & HashAlgorithmMask) != 0) {
+  TotalSize += sizeof (TPMI_ALG_HASH) + mHashInfo[Index].HashSize;
+}
+  }
+
+  return TotalSize;
+}
+
 /**
   This function get digest from digest list.
 
diff --git a/SecurityPkg/Include/Library/Tpm2CommandLib.h 
b/SecurityPkg/Include/Library/Tpm2CommandLib.h
index a2fb97f18dfe..8b0fe8328516 100644
--- a/SecurityPkg/Include/Library/Tpm2CommandLib.h
+++ b/SecurityPkg/Include/Library/Tpm2CommandLib.h
@@ -1082,6 +1082,26 @@ CopyDigestListToBuffer (
   IN UINT32  HashAlgorithmMask
   );
 
+/**
+  Copy a buffer into A TPML_DIGEST_VALUES structure.
+
+  @param[in] Buffer Buffer to hold TPML_DIGEST_VALUES compact 
binary.
+  @param[in] BufferSize Size of Buffer.
+  @param[out]DigestList TPML_DIGEST_VALUES.
+
+  @retval EFI_SUCCESS   Buffer was successfully copied to Digest 
List.
+  @retval EFI_BAD_BUFFER_SIZE   Bad buffer size passed to function.
+  @retval EFI_INVALID_PARAMETER Invalid parameter passed to function: NULL 
pointer or
+BufferSize bigger than TPML_DIGEST_VALUES
+**/
+EFI_STATUS
+EFIAPI
+CopyBufferToDigestList (
+  IN CONST  VOID*Buffer,
+  INUINTN   BufferSize,
+  OUT   TPML_DIGEST_VALUES  *DigestList
+  );
+
 /**
   Get TPML_DIGEST_VALUES data size.
 
@@ -1095,6 +1115,19 @@ GetDigestListSize (
  

[edk2-devel] [PATCH v1 1/1] BaseTools/Conf/target.template: Use VS2019 as default tool chain

2023-11-28 Thread Michael Kubacki
From: Michael Kubacki 

Updates the default tool chain from VS2015x86 to VS2019.

This is the VS tool chain used in CI and more likely to be installed
on developer's systems. This is used in stuart commands when a
toolchain is not explicitly specified.

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Rebecca Cran 
Cc: Yuwei Chen 
Signed-off-by: Michael Kubacki 
---
 BaseTools/Conf/target.template | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Conf/target.template b/BaseTools/Conf/target.template
index d4a3b53b7f3e..592febf55762 100644
--- a/BaseTools/Conf/target.template
+++ b/BaseTools/Conf/target.template
@@ -22,8 +22,8 @@ ACTIVE_PLATFORM   = EmulatorPkg/EmulatorPkg.dsc
 #  TARGETList   OptionalZero or more of the following: 
DEBUG, RELEASE, NOOPT
 #   UserDefined; separated by a 
space character.
 #   If the line is missing or no 
value is specified, all
-#   valid targets specified in the 
platform description file 
-#   will attempt to be built. The 
following line will build 
+#   valid targets specified in the 
platform description file
+#   will attempt to be built. The 
following line will build
 #   DEBUG platform target.
 TARGET= DEBUG
 
@@ -32,7 +32,7 @@ TARGET= DEBUG
 #   or AArch64.
 #   Multiple values can be 
specified on a single line, using
 #   space characters to separate 
the values.  These are used
-#   during the parsing of a 
platform description file, 
+#   during the parsing of a 
platform description file,
 #   restricting the build output 
target(s.)
 #   The Build Target ARCH is 
determined by (precedence high to low):
 # Command-line: -a ARCH option
@@ -51,7 +51,7 @@ TOOL_CHAIN_CONF   = Conf/tools_def.txt
 #  TAGNAME   List  Optional   Specify the name(s) of the 
tools_def.txt TagName to use.
 # If not specified, all applicable 
TagName tools will be
 # used for the build.  The list 
uses space character separation.
-TOOL_CHAIN_TAG= VS2015x86
+TOOL_CHAIN_TAG= VS2019
 
 # MAX_CONCURRENT_THREAD_NUMBER  NUMBER  Optional  The number of concurrent 
threads. If not specified or set
 # to zero, tool automatically 
detect number of processor
@@ -64,7 +64,7 @@ TOOL_CHAIN_TAG= VS2015x86
 
 
 # BUILD_RULE_CONF  Filename Optional  Specify the file name to use for the 
build rules that are followed
-# when generating Makefiles. If not 
specified, the file: 
+# when generating Makefiles. If not 
specified, the file:
 # WORKSPACE/Conf/build_rule.txt will be 
used
 BUILD_RULE_CONF = Conf/build_rule.txt
 
-- 
2.42.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111825): https://edk2.groups.io/g/devel/message/111825
Mute This Topic: https://groups.io/mt/102858057/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel][edk2-staging] DeviceSimPkg branch creation

2023-11-28 Thread Michael D Kinney
Hi Maciej,

Reviewed-by: Michael D Kinney 

I have invited you to the EDK II Staging Maintainer team that
allows you to create this new branch in the edk2-staging repo.

Mike

> -Original Message-
> From: Czajkowski, Maciej 
> Sent: Monday, November 13, 2023 7:09 AM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D 
> Subject: [edk2-devel][edk2-staging] DeviceSimPkg branch creation
> 
> Hello,
> 
> I would like to announce DeviceSimPkg branch creation in edk2-staging
> repository.
> Branch will be used to develop DeviceSimPkg, a package for developing OS
> executable tests
> for device focused code.
> 
> Branch owner: Maciej Czajkowski , GitHub ID:
> 81293748 (https://github.com/mczaj)
> 
> Signed-off-by: Maciej Czajkowski 
> Cc: Michael D Kinney 
> ---
>  Readme.md | 37 +
>  1 file changed, 37 insertions(+)
>  create mode 100644 Readme.md
> 
> diff --git a/Readme.md b/Readme.md
> new file mode 100644
> index ..96077d0a478c
> --- /dev/null
> +++ b/Readme.md
> @@ -0,0 +1,37 @@
> +# DeviceSimPkg
> +
> +## Introduction
> +
> +DeviceSimPkg is a package aimed at providing an environment to write OS-
> executable unit tests for code that interacts directly with devices.
> +This code is referred to as driver code below although code under test
> doesn't have to follow UEFI driver model. \
> +Branch owner: Maciej Czajkowski <>
> +
> +## How to use it
> +### Using the code
> +
> +You can refer to UnitTest modules to see the usage details. In general
> you will need to link to package libraries (instead of the ones normally
> provided by MdePkg/MdeModulePkg) and initialize your device access.
> Details of initialization will vary based on which
> REGISTER_ACCESS_INTERFACE implementer library you will
> +choose. Please refer to corresponding libraries Readmes for details.
> +
> +## General architecture
> +
> +On high-level package consists of:
> +
> +* REGISTER_ACCESS_INTERFACE - interface between device model and driver
> code
> +* REGISTER_ACCESS_INTERFACE wrappers - libraries that wrap
> REGISTER_ACCESS_INTERFACE and present it as a standard UEFI library
> +* REGISTER_ACCESS_INTERFACE implementers - libraries that implement
> REGISTER_ACCESS_INTERFACE interface
> +
> +## Wrapper libraries
> +
> +Currently package implements following wrappers:
> +
> +* IoLib in
> [RegisterAccessIoLib](DeviceSimPkg/Library/RegisterAccessIoLib/Readme.md)
> +* PciSegmentLib in RegisterAccessPciSegmentLib
> +* PCI_IO_PROTOCOL in RegisterAccessPciIoLib
> +
> +## REGISTER_ACCESS_INTERFACE implementations
> +
> +Currently only a single implementation is fully supported -
> FakeRegisterSpaceLib. Please see its Readme for more details on how to use
> it.
> +
> +## GMOCK support
> +
> +DeviceSim implements Gmock based mock object for the IoLib functions.
> Please see GmockIoLib [Readme](DeviceSimPkg/Library/MockIoLib//Readme.md)
> for details.
> --
> 2.39.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111824): https://edk2.groups.io/g/devel/message/111824
Mute This Topic: https://groups.io/mt/102563078/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: 
https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v3 1/1] MdeModulePkg: Fix issue with ACPI table creation

2023-11-28 Thread Chiu, Chasel


Thanks for update! Change looks good to me.
Acked-by: Chasel Chiu 


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Dhaval
> Sharma
> Sent: Sunday, November 19, 2023 8:24 PM
> To: devel@edk2.groups.io
> Cc: Gao, Liming ; Liu, Zhiguang
> ; Bi, Dandan 
> Subject: [edk2-devel] [PATCH v3 1/1] MdeModulePkg: Fix issue with ACPI table
> creation
> 
> As per ACPI Spec 6.5+ Table 5-9 if xDSDT is avaialble, it should be used 
> first.
> Handle required flow when xDSDT is abscent or present.
> 
> Test: Tested on RISCV64 Qemu platform with xDSDT and booted to linux kernel.
> 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> Cc: Dandan Bi 
> Signed-off-by: Dhaval Sharma 
> ---
> 
> Notes:
> v2:
> - Added proper indentation for else if
> 
>  MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 22
> +---
>  1 file changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> index e09bc9b704f5..ead8376177c9 100644
> --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> @@ -1892,14 +1892,22 @@ InstallAcpiTableFromHob (
>} } -if 
> (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE
> *)ChildTable)->Dsdt != 0) {+//+// First check if xDSDT is 
> available that is
> preferred as per+// ACPI Spec 6.5+ Table 5-9 X_DSDT definition+   
>  //+
> if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)ChildTable)->XDsdt != 0)
> {+  TableToInstall = (VOID
> *)(UINTN)((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)ChildTable)-
> >XDsdt;+} else if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE
> *)ChildTable)->Dsdt != 0) {   TableToInstall = (VOID
> *)(UINTN)((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)ChildTable)-
> >Dsdt;-  Status = AddTableToList (AcpiTableInstance, 
> >TableToInstall,
> TRUE, Version, TRUE, );-  if (EFI_ERROR (Status)) {- 
>DEBUG
> ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add ACPI table DSDT\n"));-
> ASSERT_EFI_ERROR (Status);-break;-  }+} else {+
> break;+}+Status = AddTableToList (AcpiTableInstance, 
> TableToInstall,
> TRUE, Version, TRUE, );+if (EFI_ERROR (Status)) {+  
> DEBUG
> ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add ACPI table DSDT\n"));+
> ASSERT_EFI_ERROR (Status);+  break; }   } }--
> 2.39.2
> 
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#111451): https://edk2.groups.io/g/devel/message/111451
> Mute This Topic: https://groups.io/mt/102702109/1777047
> Group Owner: devel+ow...@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [chasel.c...@intel.com] -=-
> =-=-=-=-=
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111823): https://edk2.groups.io/g/devel/message/111823
Mute This Topic: https://groups.io/mt/102702109/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [Proposed Fix][PATCH v1 1/1] MdeModulePkg/DxeCapsuleLibFmp: Fix crash with VirtualAddressMap omitted

2023-11-28 Thread Ard Biesheuvel
On Tue, 28 Nov 2023 at 16:15, gaoliming via groups.io
 wrote:
>
> Reviewed-by: Liming Gao 
>

Thanks I'll queue this up.



> > -邮件原件-
> > 发件人: devel@edk2.groups.io  代表 Ard
> > Biesheuvel
> > 发送时间: 2023年11月23日 16:36
> > 收件人: Nhi Pham 
> > 抄送: devel@edk2.groups.io; gaolim...@byosoft.com.cn;
> > ardb+tianoc...@kernel.org
> > 主题: Re: [edk2-devel] [Proposed Fix][PATCH v1 1/1]
> > MdeModulePkg/DxeCapsuleLibFmp: Fix crash with VirtualAddressMap
> > omitted
> >
> > On Thu, 23 Nov 2023 at 05:49, Nhi Pham 
> > wrote:
> > >
> > > If the SetVirtualAddressMap() is not called, mIsVirtualAddrConverted
> > > is FALSE and the kernel crash occurs in IsNestedFmpCapsule() when
> > > executing gBS->LocateProtocol () in the else case.
> > >
> > > To serve the omitted SetVirtualAddressMap() call, we could just check
> > > mEsrtTable presence instead of relying on mIsVirtualAddrConverted.
> > >
> > > Signed-off-by: Nhi Pham 
> >
> > Agreed: SetVirtualAddressMap() is optional, so whether it has been
> > called or not should not be used as a proxy to decide whether or not
> > we are still running in the boot services context.
> >
> > Reviewed-by: Ard Biesheuvel 
> >
> >
> > > ---
> > >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 17
> > +++--
> > >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c |  2 --
> > >  2 files changed, 7 insertions(+), 12 deletions(-)
> > >
> > > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > > index 197af267aff3..2433c76a8c6f 100644
> > > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > > @@ -41,8 +41,7 @@
> > >  #include 
> > >  #include 
> > >
> > > -EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable = NULL;
> > > -BOOLEANmIsVirtualAddrConverted = FALSE;
> > > +EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable = NULL;
> > >
> > >  BOOLEANmDxeCapsuleLibEndOfDxe  = FALSE;
> > >  EFI_EVENT  mDxeCapsuleLibEndOfDxeEvent = NULL;
> > > @@ -1394,14 +1393,12 @@ IsNestedFmpCapsule (
> > >EFI_SYSTEM_RESOURCE_ENTRY  Entry;
> > >
> > >EsrtGuidFound = FALSE;
> > > -  if (mIsVirtualAddrConverted) {
> > > -if (mEsrtTable != NULL) {
> > > -  EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);
> > > -  for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++,
> > EsrtEntry++) {
> > > -if (CompareGuid (>FwClass,
> > >CapsuleGuid)) {
> > > -  EsrtGuidFound = TRUE;
> > > -  break;
> > > -}
> > > +  if (mEsrtTable != NULL) {
> > > +EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);
> > > +for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++,
> > EsrtEntry++) {
> > > +  if (CompareGuid (>FwClass,
> > >CapsuleGuid)) {
> > > +EsrtGuidFound = TRUE;
> > > +break;
> > >}
> > >  }
> > >} else {
> > > diff --git
> > a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > > index 9ceb44fe4d79..44f30c16c284 100644
> > > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > > @@ -21,7 +21,6 @@
> > >  #include 
> > >
> > >  extern EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable;
> > > -extern BOOLEANmIsVirtualAddrConverted;
> > >  EFI_EVENT
> > mDxeRuntimeCapsuleLibVirtualAddressChangeEvent = NULL;
> > >  EFI_EVENT
> > mDxeRuntimeCapsuleLibReadyToBootEvent  = NULL;
> > >
> > > @@ -40,7 +39,6 @@ DxeCapsuleLibVirtualAddressChangeEvent (
> > >)
> > >  {
> > >gRT->ConvertPointer (EFI_OPTIONAL_PTR, (VOID **));
> > > -  mIsVirtualAddrConverted = TRUE;
> > >  }
> > >
> > >  /**
> > > --
> > > 2.25.1
> > >
> >
> >
> >
> >
>
>
>
>
>
> 
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111822): https://edk2.groups.io/g/devel/message/111822
Mute This Topic: https://groups.io/mt/102855986/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH edk2-non-osi 1/1] Qemu/Sbsa: Update TF-A binaries to v2.10

2023-11-28 Thread Ard Biesheuvel
On Tue, 28 Nov 2023 at 18:47, Marcin Juszkiewicz
 wrote:
>
> Update the TF-A binaries:
>
> - v2.10 release
> - Neoverse-N2 errata fix
>   https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/24936
>   (check for SCU before accessing DSU registers)
>
> v2.10 brought change on how we enable cpu features to have one binary
> working on v8.0 (a57/a72), v8.2 (n1), v8.4 (v1) and v9.0 (n2) cpu cores.
> Base setup is v8.0 with all newer features enabled with runtime checks.
>
> Neoverse-N2 fix makes sure that there presence of DSU is checked before
> used (QEMU does not emulate DSU).
>
> With all those changes we have all cores booting into Linux and *BSD.
>
> Signed-off-by: Marcin Juszkiewicz 

Pushed as ddae61c..542b0f6  master -> master

Thanks!

> ---
>  Platform/Qemu/Sbsa/bl1.bin | Bin 22933 -> 23029 bytes
>  Platform/Qemu/Sbsa/fip.bin | Bin 82722 -> 82722 bytes
>  2 files changed, 0 insertions(+), 0 deletions(-)
>  mode change 100755 => 100644 Platform/Qemu/Sbsa/bl1.bin
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111821): https://edk2.groups.io/g/devel/message/111821
Mute This Topic: https://groups.io/mt/102855349/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH edk2-non-osi 1/1] Qemu/Sbsa: Update TF-A binaries to v2.10

2023-11-28 Thread Marcin Juszkiewicz
Update the TF-A binaries:

- v2.10 release
- Neoverse-N2 errata fix
  https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/24936
  (check for SCU before accessing DSU registers)

v2.10 brought change on how we enable cpu features to have one binary
working on v8.0 (a57/a72), v8.2 (n1), v8.4 (v1) and v9.0 (n2) cpu cores.
Base setup is v8.0 with all newer features enabled with runtime checks.

Neoverse-N2 fix makes sure that there presence of DSU is checked before
used (QEMU does not emulate DSU).

With all those changes we have all cores booting into Linux and *BSD.

Signed-off-by: Marcin Juszkiewicz 
---
 Platform/Qemu/Sbsa/bl1.bin | Bin 22933 -> 23029 bytes
 Platform/Qemu/Sbsa/fip.bin | Bin 82722 -> 82722 bytes
 2 files changed, 0 insertions(+), 0 deletions(-)
 mode change 100755 => 100644 Platform/Qemu/Sbsa/bl1.bin

diff --git a/Platform/Qemu/Sbsa/bl1.bin b/Platform/Qemu/Sbsa/bl1.bin
old mode 100755
new mode 100644
index 
22875fe6fc7b471c909fa25f0e57bfd763eec991..e436d077113b340c606069b575c0717775fa6d82
GIT binary patch
delta 5992
zcmZ`+3v`pmm7bA=E!#4dY=Nv`kbarq2Y$Z+6HAT*c6ixfULh$Kj{prRIFQ8Wq>E*s
zN!pOczpwY0(rja%wj?%9+=a%XB_W6LP(ZE{+h5K1jEBmSx&>tZ`h&>Ro70bFvg!;He@v**VraE}@
z4K44*mG9-19^W%M)_x$-IlvcT{e9^1HM1XHW31&!OO$iK#f^hXpUFNSath?qE
zG1(*Uw8T0C4*kBijdpg`gPde^wpDCrS2<_(I=jcGVNLJoSQp08_3}{PYAp8sM>y8C
zbbI^!5r=3PQdU(iHLjAFCew}E#@QvG`xh+mnO2+Gu%87yQO>~T{idFlO-xiouSW0j
zO@(Zu-Eh<>U%egd*mft_aRt^J3)5#ak8hKw^O_dJZob_#;$WKIW_|OuErXrcB+P;R
zaQldaA4BUC{R5#%AsYO4I8govO#WuxEIt-t{{id|$
zVN{!=Sfg9Z>NOr`AT%jMQ(Gl#YQwqoc4=6@x?l~sI2@C6C8qe*g%}iE-k8s8O7XWO
zkNH{*D#8OzFxPjZ@c;W_4Of)1WXQnq)rpn*ojP_v44VqMW
zHCBM<`&9w4q@ml^o+@8Ju3=MEAY_j@WT6TFzX<-6L+%&@xL#K1-}
zcx+Zv@tUf@33M8}8!TpwO|U_;oMcRT>3k}e2T>EndP?Ybg2iKL_k9b5ykw)r_@
zw=kdQojrEvEI-Gu-B3AVGq9^)V3F<`d?e1#VRuQ#_8ZGns((6++j3p8=rko5Jl?=Ie(dBPUzCoSFQQivFLB0MzwS+L
zyo9xKK^xV3(8z|r#P;9udl)$en{a`{taB=s9R)fs3ekusw##U2SwPXRK9XQ)I4Z
zxRThe#kK*yvM-osbOvr>ar0#7zbL+oxW_ID4{haV;gdM-f`8IOa{uN$#2F8XCd1uJ+h;KW&`0dUqi`kFR)GiB
zETOfMuojWy!C8(tIqIUxQ6-xawZ(x^GhpxREGbv?!#LT5a|tsD)4)5sw7`m%gwZX8
z(+HCgUC5gV6A;~K$8(sPHVazk=%M!hTFaNXz2T{~I4Fs9Ok!cPxC6uzaGl5ZKMa#W
z^b=xPgeIjy?$6kk5dWLBvxGtm`62#c5~uo|A`UOKQ2*bNeL}$~-*1HgPtGZiZAn)$
zbLEDX=hHb?VqLkk5BW$v0H*X8W2JnBa+id>~x-@xbTSuy*#k>O+xJ`VR~yupuy
zH>0rm0&@Kgu-F}lTKr1a%l!5f=ZF;L@!1(%E|8hzE;UY~vqAVIlrO
zAkORq!rv3(uuKaSm(?KMCB0rK22Usn`s#JNt5y9$yah
z@wIK+@qW|eOLceU4A_w4UhsbhoPnCazLAP4>?+=U^)=ktr@_jt!6k|nIsZ%S&%YnE
z9edbql{0wkOJ8VXdJF5EJ*!N!;QgFw+zA8K11{zlYF>|p83kMU2hdVbitl#=1+Vj;!efOm@SX5^;U0YZTVIr=X|wdb
zP~_!_3u=hR1q*SMY7;Yy3iE$zJf3>GXd><0B&4=IQirVf)u%2P9rb;}z9mzE1xn
zws(ackXVMs3e{nOPM?kK+^_=@@n|Hd4&`P#j$AtxR*aDt%%mE)lAK_Od)wU3G
z!1k}n1`iT1qw$LB@Brq3?OkC9B$lDELUpLX9I%}mc0eK?jRYc^J^0=(K1cNms=qH1
zKT4?buaZ3xtuRMp6l^8CELO1}C2S=;MpzW5=$93HB|A-mLSwa%?Ib)w9VYNuBR*#c
zTM4TPZk0=p9wGYnOruW@!qYw6~b+7k@&@bGBXuCL;UI0
zid_wLRW_H(_N(kY-beolU$64;cGZeLPl=spsG-_b>7GyrRbC8iQoZ;7Lv~A;#qi)M
zNe=rf$ulO>x5Ru!bLUuNmW;ov7C8m)vGo*Hczmi{{{e
zy75I8>zG67F$Kha;olniTmsW#OU(qS@4gnP-XeZrFtp1~|HGP8jt;q<=
zlj=ggMC!DGP>qDuQQ*}U>upk(>9c+a0MIp{2?w!EpkS7;u{_2&|K2VE+hfIP1kwtN)iYN}c+37Rasyw4I#gRpeZD7BJq#_Vc9OdEb-M@=9=#jhM)eq}
zukVl|)c0T<)j?8sl}2vS88FpaYKBzR6FSr3$fLwR^j;)CM*NwNBKb?;sX-rgU;Fhj}Y27v|^X0oCWaDR
z_=w7i`J5h6pM!UGsWog7n}=>03O@vVZE4KV62+PTnT$LTJvy4nisK*d=w_)`ZZb?aJP)DozRqw6M>b#eV`1%$9b_T0Ra*f6_q=H@-p(0d82vyrj#
zu*!pcOGhE$%?7+A=t)$M)zJ7Wa*<^d}vz|O`iLOWN-50s+4r6EDNkjesp
z17nz;P?Ekl9UJM5J{0ZaUi1#@S%eQD*vtP^V=b}B)%S@=1
z4APDSSTAMIuqP_bpM-!EAgF$1c-JS%;q-^bAl5!D>
zlTu?aBJMdX_v;aPBFb=rmUWtUZ!QWRu6m^_Z@!?
z{vKb!m%+q@<$NYICA9L>@Xv(V{0PX2i}<6kF>y8q`D0=!{~3IOzY8HL>4`}L6k|Zw
zdl?@{#J2X=^jdVRc|T+I7+-Jghqsfq@d21MzK##Le?2~%x8iK}oY(LkUgh$(YFVc!
z0e^SfZh!FN4~+50+fwYk4rZ+oWwA5H-dn|zXE1i(%T?=2;fl8E+5F*FChm)yhU)
zI8IfvefR1OY?O0WueG|o8rJf%mUUw+ZI2XNIkY;l25bA_ry6&%fM3JY@?A0ZfODt*
zfTVMI+tx6#l06(YCR-B?6O_wWf_pY!4emJyzfCSpT;uBcf$i9EQf5*Qj3ig`e~V>;
zIr_x%OaBS(@ng?(3HHF%?Qieji$WhdoeVihuI$ehm-mr!4fN+8V=}`y^H`
zx$FUrwsL4~LCr}AYuTO4G(B309noUq*od_ZlH&)csz54ETJyzPkl@b2btO`p{|
zgjFgEEu6E^iZl9N>~=Sc}+RyGecGMAV6%|lL~8Mj;|-sYh$#4bcG
zn}=ldapElxn}@y%J228duuHFU
z?EY11J2&{OO5b&9KjhAw_>o3Gj1}tF
zr1khT#vW;$%lk20O+TI3GC{eRA?CP$|8s7?sf_D#la<=b!9DLnX2xp%8+b6IL$=F`
zI6lG)Fb6jx9#exH`Qe8(C6W#D&6Cs8aDXr^vHjlR3>IKE__=wuR6iN^njeyO%8-*O
zYc-dHMmUt2S$0QtAQvmb!dSC71={27m#tW5UC0lA!4y9pO!=q_tr3q!>70>95J
zE4ZaP5KjVjDDOf$+#%(<4tGKz)7Chgtz5>3+Jad(KA)|u#3FIsRUHts8ahZl*~-6=
zYiy_vglt!~A~fMI3aW8Uw(^?5n^pZ>o#Q|i9>StDh2Lpt%W5fKQXM#kPQGiwa>m#Q
zYcwdS$*H@BbGYI`P1N%{Lcba;_f4?}CSazXB{1DGi+=$dEg32QzH_bTIjflPUC{XR~p
zkL}#$#W^#4iC*6z^KXeg>gm`)6<^JPJE5+AMySg^=ruW!F|@Xvlim!@EBO&
zOHo4D%ZJJ}O>7Tm>>T{G}r?du(o-+y|)d|7|!gy
zJ`K+owZoVzC4}g6iG2J)ONGk08{|j0=_$?(4xG&=34ce}2^X@L@-}efOr5eFIXn7@
ze&6Hs-NW(KiDzCSV}l*e3?@hfmzxJibJCMmq5lZ_iB-BC{5h7nwaCb5Ehk)t
z$Z=;aMI0M>{@BQUS!!e%=H@oY1)>Xv$S1TBPA1HSS8^+g)6kMJFuH~?g)kY>f&6
zL_{ar@sK%boAE3bLF9qtY#P=^4`hI|lM-7`F(@_GsJ!ysgTNO+v^eL@L+Pf+`v
zF!7vJ5R>4@V2jo8}eS@2ca*o6mw^#yqvL^#RcxpP_~De!{JYPUL?{_GZF+2saVlO}K=Y;DJ
zMgKKqHzGRFzKd{`ijwyZOf|>2Y;2l*j!1LlC0RprUfEhI!r)966BZIqLzI!9N_IB3

Re: [edk2-devel] [PATCH v2 1/1] ArmPkg/Drivers/CpuDxe: Use lower and upper attributes

2023-11-28 Thread Ard Biesheuvel
On Tue, 28 Nov 2023 at 18:12,  wrote:
>
> From: Michael Kubacki 
>
> GetNextEntryAttribute() is currently applying a 64-bit mask
> (TT_ATTRIBUTES_MASK) to a 32-bit descriptor value (EntryType).
> The original descriptor was 64 bits containing the upper and
> lower attributes which are included in TT_ATTRIBUTES_MASK.
>
> The PrevEntryAttribute parameter is also a UINT32, but passed to
> PageAttributeToGcdAttribute() for a UINT64 parameter where the
> function checks masks in the upper 32 bits of the integer value:
>
>   PageAttributeToGcdAttribute (*PrevEntryAttribute)
>   ...
>   STATIC
>   UINT64
>   PageAttributeToGcdAttribute (
> IN UINT64  PageAttributes
> )
>   ...
>   if ((PageAttributes & (TT_PXN_MASK | TT_UXN_MASK)) != 0) {
> GcdAttributes |= EFI_MEMORY_XP;
>   }
>   ...
>   #define TT_PXN_MASK  BIT53
>   #define TT_UXN_MASK  BIT54  // EL1&0
>
> This change removes UINT32 intermediary values. For EntryType,
> eliminating an unncessary cast. For EntryAttribute, preserving the
> upper and lower attributes for evaluation in
> PageAttributeToGcdAttribute().
>
> This also resolves the following compiler warning previously present
> on Visual Studio for the assignment to the previously 32-bit local
> variables.
>
>   '=': conversion from 'UINT64' to 'UINT32', possible loss of data
>
> Cc: Ard Biesheuvel 
> Cc: Leif Lindholm 
> Cc: Sami Mujawar 
> Signed-off-by: Michael Kubacki 


Reviewed-by: Ard Biesheuvel 

Queued up now - thanks.


> ---
>  ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c 
> b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> index e14eb47ce4c6..ff14c2f814b2 100644
> --- a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> +++ b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> @@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>  #include 
>  #include "CpuDxe.h"
>
> -#define INVALID_ENTRY  ((UINT32)~0)
> +#define INVALID_ENTRY  ((UINT64)~0)
>
>  #define MIN_T0SZ16
>  #define BITS_PER_LEVEL  9
> @@ -169,14 +169,14 @@ GetNextEntryAttribute (
>IN UINTN   EntryCount,
>IN UINTN   TableLevel,
>IN UINT64  BaseAddress,
> -  IN OUT UINT32  *PrevEntryAttribute,
> +  IN OUT UINT64  *PrevEntryAttribute,
>IN OUT UINT64  *StartGcdRegion
>)
>  {
>UINTNIndex;
>UINT64   Entry;
> -  UINT32   EntryAttribute;
> -  UINT32   EntryType;
> +  UINT64   EntryAttribute;
> +  UINT64   EntryType;
>EFI_STATUS   Status;
>UINTNNumberOfDescriptors;
>EFI_GCD_MEMORY_SPACE_DESCRIPTOR  *MemorySpaceMap;
> @@ -271,7 +271,7 @@ SyncCacheConfig (
>)
>  {
>EFI_STATUS   Status;
> -  UINT32   PageAttribute;
> +  UINT64   PageAttribute;
>UINT64   *FirstLevelTableAddress;
>UINTNTableLevel;
>UINTNTableCount;
> --
> 2.42.0.windows.2
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111819): https://edk2.groups.io/g/devel/message/111819
Mute This Topic: https://groups.io/mt/102854549/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v1 0/2] ArmPkg/CpuDxe: Use upper and lower attributes

2023-11-28 Thread Ard Biesheuvel
On Tue, 28 Nov 2023 at 18:15, Michael Kubacki
 wrote:
>
> On 11/28/2023 4:51 AM, Ard Biesheuvel wrote:
> > On Tue, 28 Nov 2023 at 01:15,  wrote:
> >>
> >> From: Michael Kubacki 
> >>
> >> This series contains two changes:
> >>
> >> 1. To fix a compiler warning with the current state of code.
> >> 2. To update the code to pass the integer width needed for a
> >> comparison to set EFI_MEMORY_XP in the GCD attribute returned
> >> for a given page attribute.
> >>
> >> Cc: Leif Lindholm 
> >> Cc: Ard Biesheuvel 
> >> Cc: Sami Mujawar 
> >>
> >> Michael Kubacki (2):
> >>ArmPkg/Drivers/CpuDxe: Explicitly cast table entry
> >>ArmPkg/Drivers/CpuDxe: Use lower and upper attributes
> >>
> >
> > Thanks for the fixes. This code is in a rather poor state, unfortunately.
> >
> > I don't quite get the motivation for fixing this using two different
> > patches: the implicit UINT32 cast obviously loses some attributes (the
> > ones in the 12 upper bits, notably UXN and PXN), so making it explicit
> > removes the warning but preserves the bug. (If GCC had better
> > diagnostics, we'd spotted this problem years ago)
> >
> > Maybe it is sufficient to simply squash the two patches together?
> >
> I wanted to leave that open to discussion and maintainer discretion. I
> think a squash is fine and sent a v2 with it done.
>

Thanks. I'll go and merge that.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111818): https://edk2.groups.io/g/devel/message/111818
Mute This Topic: https://groups.io/mt/102841999/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v1 1/1] SecurityPkg/Tpm2CommandLib: Add new digest list copy and size functions

2023-11-28 Thread Michael Kubacki
From: Michael Kubacki 

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

Adds two new helper functions.

Currently, a function exists in Tpm2CommandLib to copy a digest list
to a buffer. A function to perform the inverse operation - copying
from a buffer to a digest list is added.

A function is also added to compute the total digest size for a given
hash algorithm mask.

Cc: Jiewen Yao 
Cc: Rahul Kumar 
Signed-off-by: Michael Kubacki 
---
 SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 87 
 SecurityPkg/Include/Library/Tpm2CommandLib.h  | 33 
 2 files changed, 120 insertions(+)

diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c 
b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
index e7f30b673f0e..b450cae0defd 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
@@ -290,6 +290,67 @@ CopyDigestListToBuffer (
   return Buffer;
 }
 
+/**
+  Copy a buffer into a TPML_DIGEST_VALUES structure.
+
+  @param[in] Buffer Buffer to hold TPML_DIGEST_VALUES compact 
binary.
+  @param[in] BufferSize Size of Buffer.
+  @param[out]DigestList TPML_DIGEST_VALUES.
+
+  @retval EFI_SUCCESS   Buffer was succesfully copied to Digest 
List.
+  @retval EFI_BAD_BUFFER_SIZE   Bad buffer size passed to function.
+  @retval EFI_INVALID_PARAMETER Invalid parameter passed to function: NULL 
pointer or
+BufferSize bigger than TPML_DIGEST_VALUES
+**/
+EFI_STATUS
+EFIAPI
+CopyBufferToDigestList (
+  IN CONST  VOID*Buffer,
+  INUINTN   BufferSize,
+  OUT   TPML_DIGEST_VALUES  *DigestList
+  )
+{
+  EFI_STATUS   Status;
+  UINTNIndex;
+  UINT16   DigestSize;
+  CONST UINT8  *BufferPtr;
+
+  Status = EFI_INVALID_PARAMETER;
+
+  if ((Buffer == NULL) || (DigestList == NULL) || (BufferSize > sizeof 
(TPML_DIGEST_VALUES))) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  DigestList->count = SwapBytes32 (ReadUnaligned32 ((CONST UINT32 *)Buffer));
+  if (DigestList->count > HASH_COUNT) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  BufferPtr = (CONST UINT8 *)Buffer +  sizeof (UINT32);
+  for (Index = 0; Index < DigestList->count; Index++) {
+if (BufferPtr - (CONST UINT8 *)Buffer + sizeof (UINT16) > BufferSize) {
+  Status = EFI_BAD_BUFFER_SIZE;
+  break;
+} else {
+  DigestList->digests[Index].hashAlg = SwapBytes16 (ReadUnaligned16 
((CONST UINT16 *)BufferPtr));
+}
+
+BufferPtr += sizeof (UINT16);
+DigestSize = GetHashSizeFromAlgo (DigestList->digests[Index].hashAlg);
+if (BufferPtr - (CONST UINT8 *)Buffer + (UINTN)DigestSize > BufferSize) {
+  Status = EFI_BAD_BUFFER_SIZE;
+  break;
+} else {
+  CopyMem (>digests[Index].digest, BufferPtr, DigestSize);
+}
+
+BufferPtr += DigestSize;
+Status = EFI_SUCCESS;
+  }
+
+  return Status;
+}
+
 /**
   Get TPML_DIGEST_VALUES data size.
 
@@ -316,6 +377,32 @@ GetDigestListSize (
   return TotalSize;
 }
 
+/**
+  Get the total digest size from a hash algorithm mask.
+
+  @param[in] HashAlgorithmMask.
+
+  @return Digest size in bytes.
+**/
+UINT32
+EFIAPI
+GetDigestListSizeFromHashAlgorithmMask (
+  IN UINT32  HashAlgorithmMask
+  )
+{
+  UINTN   Index;
+  UINT32  TotalSize;
+
+  TotalSize = sizeof (UINT32);
+  for (Index = 0; Index < ARRAY_SIZE (mHashInfo); Index++) {
+if (mHashInfo[Index].HashMask & HashAlgorithmMask) {
+  TotalSize += sizeof (TPMI_ALG_HASH) + mHashInfo[Index].HashSize;
+}
+  }
+
+  return TotalSize;
+}
+
 /**
   This function get digest from digest list.
 
diff --git a/SecurityPkg/Include/Library/Tpm2CommandLib.h 
b/SecurityPkg/Include/Library/Tpm2CommandLib.h
index a2fb97f18dfe..8b0fe8328516 100644
--- a/SecurityPkg/Include/Library/Tpm2CommandLib.h
+++ b/SecurityPkg/Include/Library/Tpm2CommandLib.h
@@ -1082,6 +1082,26 @@ CopyDigestListToBuffer (
   IN UINT32  HashAlgorithmMask
   );
 
+/**
+  Copy a buffer into A TPML_DIGEST_VALUES structure.
+
+  @param[in] Buffer Buffer to hold TPML_DIGEST_VALUES compact 
binary.
+  @param[in] BufferSize Size of Buffer.
+  @param[out]DigestList TPML_DIGEST_VALUES.
+
+  @retval EFI_SUCCESS   Buffer was successfully copied to Digest 
List.
+  @retval EFI_BAD_BUFFER_SIZE   Bad buffer size passed to function.
+  @retval EFI_INVALID_PARAMETER Invalid parameter passed to function: NULL 
pointer or
+BufferSize bigger than TPML_DIGEST_VALUES
+**/
+EFI_STATUS
+EFIAPI
+CopyBufferToDigestList (
+  IN CONST  VOID*Buffer,
+  INUINTN   BufferSize,
+  OUT   TPML_DIGEST_VALUES  *DigestList
+  );
+
 /**
   Get TPML_DIGEST_VALUES data size.
 
@@ -1095,6 +1115,19 @@ GetDigestListSize (
   IN TPML_DIGEST_VALUES  *DigestList
   );
 
+/**
+  Get the total digest size from a hash algorithm mask.
+
+  

[edk2-devel] [PATCH v2 1/1] ArmPkg/Drivers/CpuDxe: Use lower and upper attributes

2023-11-28 Thread Michael Kubacki
From: Michael Kubacki 

GetNextEntryAttribute() is currently applying a 64-bit mask
(TT_ATTRIBUTES_MASK) to a 32-bit descriptor value (EntryType).
The original descriptor was 64 bits containing the upper and
lower attributes which are included in TT_ATTRIBUTES_MASK.

The PrevEntryAttribute parameter is also a UINT32, but passed to
PageAttributeToGcdAttribute() for a UINT64 parameter where the
function checks masks in the upper 32 bits of the integer value:

  PageAttributeToGcdAttribute (*PrevEntryAttribute)
  ...
  STATIC
  UINT64
  PageAttributeToGcdAttribute (
IN UINT64  PageAttributes
)
  ...
  if ((PageAttributes & (TT_PXN_MASK | TT_UXN_MASK)) != 0) {
GcdAttributes |= EFI_MEMORY_XP;
  }
  ...
  #define TT_PXN_MASK  BIT53
  #define TT_UXN_MASK  BIT54  // EL1&0

This change removes UINT32 intermediary values. For EntryType,
eliminating an unncessary cast. For EntryAttribute, preserving the
upper and lower attributes for evaluation in
PageAttributeToGcdAttribute().

This also resolves the following compiler warning previously present
on Visual Studio for the assignment to the previously 32-bit local
variables.

  '=': conversion from 'UINT64' to 'UINT32', possible loss of data

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Sami Mujawar 
Signed-off-by: Michael Kubacki 
---
 ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c 
b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
index e14eb47ce4c6..ff14c2f814b2 100644
--- a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
+++ b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
@@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include "CpuDxe.h"
 
-#define INVALID_ENTRY  ((UINT32)~0)
+#define INVALID_ENTRY  ((UINT64)~0)
 
 #define MIN_T0SZ16
 #define BITS_PER_LEVEL  9
@@ -169,14 +169,14 @@ GetNextEntryAttribute (
   IN UINTN   EntryCount,
   IN UINTN   TableLevel,
   IN UINT64  BaseAddress,
-  IN OUT UINT32  *PrevEntryAttribute,
+  IN OUT UINT64  *PrevEntryAttribute,
   IN OUT UINT64  *StartGcdRegion
   )
 {
   UINTNIndex;
   UINT64   Entry;
-  UINT32   EntryAttribute;
-  UINT32   EntryType;
+  UINT64   EntryAttribute;
+  UINT64   EntryType;
   EFI_STATUS   Status;
   UINTNNumberOfDescriptors;
   EFI_GCD_MEMORY_SPACE_DESCRIPTOR  *MemorySpaceMap;
@@ -271,7 +271,7 @@ SyncCacheConfig (
   )
 {
   EFI_STATUS   Status;
-  UINT32   PageAttribute;
+  UINT64   PageAttribute;
   UINT64   *FirstLevelTableAddress;
   UINTNTableLevel;
   UINTNTableCount;
-- 
2.42.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111815): https://edk2.groups.io/g/devel/message/111815
Mute This Topic: https://groups.io/mt/102854549/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 0/1] ArmPkg/CpuDxe: Use upper and lower attributes

2023-11-28 Thread Michael Kubacki
From: Michael Kubacki 

This series contains two changes:

1. To fix a compiler warning with the current state of code.
2. To update the code to pass the integer width needed for a
   comparison to set EFI_MEMORY_XP in the GCD attribute returned
   for a given page attribute.

v2 changes:

Squashed the two patches into a single patch. Made minor updates
to the patch commit message due to the squash.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Cc: Sami Mujawar 

Michael Kubacki (1):
  ArmPkg/Drivers/CpuDxe: Use lower and upper attributes

 ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

-- 
2.42.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111814): https://edk2.groups.io/g/devel/message/111814
Mute This Topic: https://groups.io/mt/102854542/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




回复: [edk2-devel] [PATCH 1/1] MdeModulePkg: Optimize CoreInstallMultipleProtocolInterfaces

2023-11-28 Thread gaoliming via groups.io
Jin:

 This change is good to me. Reviewed-by: Liming Gao


 

Thanks

Liming

发件人: devel@edk2.groups.io  代表 Zhi Jin
发送时间: 2023年11月27日 14:54
收件人: Ni, Ray ; devel@edk2.groups.io; Gao, Liming

抄送: Wang, Jian J ; Bi, Dandan 
主题: Re: [edk2-devel] [PATCH 1/1] MdeModulePkg: Optimize
CoreInstallMultipleProtocolInterfaces

 

Hi   @Liming Gao,

 

  Would you please help to review this patch? Thanks!

 

BRs

Zhi Jin

 

From: Ni, Ray mailto:ray...@intel.com> > 
Sent: Thursday, November 09, 2023 10:36 AM
To: Jin, Zhi mailto:zhi@intel.com> >;
devel@edk2.groups.io  
Cc: Wang, Jian J mailto:jian.j.w...@intel.com> >;
Gao, Liming mailto:gaolim...@byosoft.com.cn> >;
Bi, Dandan mailto:dandan...@intel.com> >
Subject: Re: [PATCH 1/1] MdeModulePkg: Optimize
CoreInstallMultipleProtocolInterfaces

 

Reviewed-by: Ray Ni mailto:ray...@intel.com> >

 

Thanks,

Ray

  _  

From: Jin, Zhi mailto:zhi@intel.com> >
Sent: Thursday, November 9, 2023 9:46 AM
To: devel@edk2.groups.io 
mailto:devel@edk2.groups.io> >
Cc: Jin, Zhi mailto:zhi@intel.com> >; Wang, Jian J
mailto:jian.j.w...@intel.com> >; Gao, Liming
mailto:gaolim...@byosoft.com.cn> >; Bi, Dandan
mailto:dandan...@intel.com> >; Ni, Ray
mailto:ray...@intel.com> >
Subject: [PATCH 1/1] MdeModulePkg: Optimize
CoreInstallMultipleProtocolInterfaces 

 

CoreLocateDevicePath is used in CoreInstallMultipleProtocolInterfaces to
check if a Device Path Protocol instance with the same device path is
alreay installed.
CoreLocateDevicePath is a generic API, and would introduce some
unnecessary overhead for such usage.

The optimization is:
1. Implement IsDevicePathInstalled to loop all the Device Path
   Protocols installed and check if any of them matchs the given device
   path.
2. Replace CoreLocateDevicePath with IsDevicePathInstalled in
   CoreInstallMultipleProtocolInterfaces.

This optimization could save several seconds in PCI enumeration on a
system with many PCI devices.

Cc: Jian J Wang mailto:jian.j.w...@intel.com> >
Cc: Liming Gao mailto:gaolim...@byosoft.com.cn> >
Cc: Dandan Bi mailto:dandan...@intel.com> >
Cc: Ray Ni mailto:ray...@intel.com> >
Signed-off-by: Zhi Jin mailto:zhi@intel.com> >
---
 MdeModulePkg/Core/Dxe/Hand/Handle.c | 74 +
 1 file changed, 64 insertions(+), 10 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c
b/MdeModulePkg/Core/Dxe/Hand/Handle.c
index bd6c57843e..a08cf19bfd 100644
--- a/MdeModulePkg/Core/Dxe/Hand/Handle.c
+++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c
@@ -197,6 +197,66 @@ CoreFindProtocolInterface (
   return Prot;
 }
 
+/**
+  Check if the given device path is already installed
+
+  @param  DevicePathThe given device path
+
+  @retval TRUE  The device path is already installed
+  @retval FALSE The device path is not installed
+
+**/
+BOOLEAN
+IsDevicePathInstalled (
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePath
+  )
+{
+  UINTN SourceSize;
+  UINTN Size;
+  BOOLEAN   Found;
+  LIST_ENTRY*Link;
+  PROTOCOL_ENTRY*ProtEntry;
+  PROTOCOL_INTERFACE*Prot;
+
+  if (DevicePath == NULL) {
+return FALSE;
+  }
+
+  Found = FALSE;
+  SourceSize= GetDevicePathSize (DevicePath);
+  ASSERT (SourceSize >= END_DEVICE_PATH_LENGTH);
+
+  CoreAcquireProtocolLock ();
+  //
+  // Look up the protocol entry
+  //
+  ProtEntry = CoreFindProtocolEntry (, FALSE);
+  if (ProtEntry == NULL) {
+goto Done;
+  }
+
+  for (Link = ProtEntry->Protocols.ForwardLink; Link !=
>Protocols; Link = Link->ForwardLink) {
+//
+// Loop on the DevicePathProtocol interfaces
+//
+Prot = CR (Link, PROTOCOL_INTERFACE, ByProtocol,
PROTOCOL_INTERFACE_SIGNATURE);
+
+//
+// Check if DevicePath is same as this interface
+//
+Size = GetDevicePathSize (Prot->Interface);
+ASSERT (Size >= END_DEVICE_PATH_LENGTH);
+if ((Size == SourceSize) && (CompareMem (DevicePath, Prot->Interface,
Size - END_DEVICE_PATH_LENGTH) == 0)) {
+  Found = TRUE;
+  break;
+}
+  }
+
+Done:
+  CoreReleaseProtocolLock ();
+  return Found;
+}
+
 /**
   Removes an event from a register protocol notify list on a protocol.
 
@@ -517,8 +577,6 @@ CoreInstallMultipleProtocolInterfaces (
   EFI_TPL   OldTpl;
   UINTN Index;
   EFI_HANDLEOldHandle;
-  EFI_HANDLEDeviceHandle;
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
 
   if (Handle == NULL) {
 return EFI_INVALID_PARAMETER;
@@ -548,14 +606,10 @@ CoreInstallMultipleProtocolInterfaces (
 //
 // Make sure you are installing on top a device path that has already
been added.
 //
-if (CompareGuid (Protocol, )) {
-  DeviceHandle = NULL;
-  DevicePath   = Interface;
-  Status   = CoreLocateDevicePath (,
, );
-  if (!EFI_ERROR 

回复: [edk2-devel] [Proposed Fix][PATCH v1 1/1] MdeModulePkg/DxeCapsuleLibFmp: Fix crash with VirtualAddressMap omitted

2023-11-28 Thread gaoliming via groups.io
Reviewed-by: Liming Gao 

> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Ard
> Biesheuvel
> 发送时间: 2023年11月23日 16:36
> 收件人: Nhi Pham 
> 抄送: devel@edk2.groups.io; gaolim...@byosoft.com.cn;
> ardb+tianoc...@kernel.org
> 主题: Re: [edk2-devel] [Proposed Fix][PATCH v1 1/1]
> MdeModulePkg/DxeCapsuleLibFmp: Fix crash with VirtualAddressMap
> omitted
> 
> On Thu, 23 Nov 2023 at 05:49, Nhi Pham 
> wrote:
> >
> > If the SetVirtualAddressMap() is not called, mIsVirtualAddrConverted
> > is FALSE and the kernel crash occurs in IsNestedFmpCapsule() when
> > executing gBS->LocateProtocol () in the else case.
> >
> > To serve the omitted SetVirtualAddressMap() call, we could just check
> > mEsrtTable presence instead of relying on mIsVirtualAddrConverted.
> >
> > Signed-off-by: Nhi Pham 
> 
> Agreed: SetVirtualAddressMap() is optional, so whether it has been
> called or not should not be used as a proxy to decide whether or not
> we are still running in the boot services context.
> 
> Reviewed-by: Ard Biesheuvel 
> 
> 
> > ---
> >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 17
> +++--
> >  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c |  2 --
> >  2 files changed, 7 insertions(+), 12 deletions(-)
> >
> > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > index 197af267aff3..2433c76a8c6f 100644
> > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> > @@ -41,8 +41,7 @@
> >  #include 
> >  #include 
> >
> > -EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable = NULL;
> > -BOOLEANmIsVirtualAddrConverted = FALSE;
> > +EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable = NULL;
> >
> >  BOOLEANmDxeCapsuleLibEndOfDxe  = FALSE;
> >  EFI_EVENT  mDxeCapsuleLibEndOfDxeEvent = NULL;
> > @@ -1394,14 +1393,12 @@ IsNestedFmpCapsule (
> >EFI_SYSTEM_RESOURCE_ENTRY  Entry;
> >
> >EsrtGuidFound = FALSE;
> > -  if (mIsVirtualAddrConverted) {
> > -if (mEsrtTable != NULL) {
> > -  EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);
> > -  for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++,
> EsrtEntry++) {
> > -if (CompareGuid (>FwClass,
> >CapsuleGuid)) {
> > -  EsrtGuidFound = TRUE;
> > -  break;
> > -}
> > +  if (mEsrtTable != NULL) {
> > +EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);
> > +for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++,
> EsrtEntry++) {
> > +  if (CompareGuid (>FwClass,
> >CapsuleGuid)) {
> > +EsrtGuidFound = TRUE;
> > +break;
> >}
> >  }
> >} else {
> > diff --git
> a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > index 9ceb44fe4d79..44f30c16c284 100644
> > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c
> > @@ -21,7 +21,6 @@
> >  #include 
> >
> >  extern EFI_SYSTEM_RESOURCE_TABLE  *mEsrtTable;
> > -extern BOOLEANmIsVirtualAddrConverted;
> >  EFI_EVENT
> mDxeRuntimeCapsuleLibVirtualAddressChangeEvent = NULL;
> >  EFI_EVENT
> mDxeRuntimeCapsuleLibReadyToBootEvent  = NULL;
> >
> > @@ -40,7 +39,6 @@ DxeCapsuleLibVirtualAddressChangeEvent (
> >)
> >  {
> >gRT->ConvertPointer (EFI_OPTIONAL_PTR, (VOID **));
> > -  mIsVirtualAddrConverted = TRUE;
> >  }
> >
> >  /**
> > --
> > 2.25.1
> >
> 
> 
> 
> 





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111812): https://edk2.groups.io/g/devel/message/111812
Mute This Topic: https://groups.io/mt/102851947/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] Pcd to set Boot0000 at build time

2023-11-28 Thread Hugues Morisset
Hello,

I wrote a patch that make it possible to set Boot at build time using a
pcd.

For example with build option
`--pcd=gEfiMdeModulePkgTokenSpaceGuid.PcdPlatformBootBoot=Lshell.efi`,
I can make sure that efi shell will boot first for a newly build firmware
image.

Thanks,
Hugues


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111811): https://edk2.groups.io/g/devel/message/111811
Mute This Topic: https://groups.io/mt/102851815/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


From e987ac0881d4a5587e445edf1ddeda87bb2ffc03 Mon Sep 17 00:00:00 2001
From: Hugues Morisset 
Date: Sun, 26 Nov 2023 22:46:21 +0100
Subject: [PATCH] BdsDxe: Add at build user provided Boot entry

When building existing platforms descriptions, it is hard for a user
to choose a default boot option at build time.
This patch adds a Pcd that set Boot entry at boot.

Signed-off-by: Hugues Morisset 
---
 MdeModulePkg/MdeModulePkg.dec|  4 +++
 MdeModulePkg/Universal/BdsDxe/BdsDxe.inf |  1 +
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 32 
 3 files changed, 37 insertions(+)

diff --git MdeModulePkg/MdeModulePkg.dec MdeModulePkg/MdeModulePkg.dec
index 0ff058b..2202b9e 100644
--- MdeModulePkg/MdeModulePkg.dec
+++ MdeModulePkg/MdeModulePkg.dec
@@ -2151,6 +2151,10 @@
   # @Prompt The value is use for Usb Network rate limiting supported.
   gEfiMdeModulePkgTokenSpaceGuid.PcdUsbNetworkRateLimitingFactor|100|UINT32|0x1028
 
+  ## Indicate the first boot entry, does not set bootorder
+  # @Prompt First boot entry.
+  gEfiMdeModulePkgTokenSpaceGuid.PcdPlatformBootBoot|""|VOID*|0x012e
+
 [PcdsPatchableInModule]
   ## Specify memory size with page number for PEI code when
   #  Loading Module at Fixed Address feature is enabled.
diff --git MdeModulePkg/Universal/BdsDxe/BdsDxe.inf MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
index 5bac635..557c236 100644
--- MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
+++ MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
@@ -98,6 +98,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed   ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleOnDiskSupport  ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdPlatformRecoverySupport   ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdPlatformBootBoot  ## CONSUMES
 
 [Depex]
   TRUE
diff --git MdeModulePkg/Universal/BdsDxe/BdsEntry.c MdeModulePkg/Universal/BdsDxe/BdsEntry.c
index 72de8d3..70fd1e2 100644
--- MdeModulePkg/Universal/BdsDxe/BdsEntry.c
+++ MdeModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -692,6 +692,9 @@ BdsEntry (
   EFI_STATUS  BootManagerMenuStatus;
   EFI_BOOT_MANAGER_LOAD_OPTIONPlatformDefaultBootOption;
   BOOLEAN PlatformDefaultBootOptionValid;
+  EFI_BOOT_MANAGER_LOAD_OPTIONPlatformDefaultBoot;
+  BOOLEAN PlatformDefaultBootValid;
+  CONST CHAR16*Boot;
 
   HotkeyTriggered = NULL;
   Status  = EFI_SUCCESS;
@@ -799,6 +802,35 @@ BdsEntry (
 BootNext = NULL;
   }
 
+
+  Boot = ((CONST CHAR16 *) PcdGetPtr (PcdPlatformBootBoot));
+  if (Boot && Boot[0]) {
+FilePath = ConvertTextToDevicePath(Boot);
+if (FilePath == NULL) {
+  DEBUG ((DEBUG_ERROR, "Fail to allocate memory for default boot file path. Unable to boot.\n"));
+  CpuDeadLoop ();
+}
+
+PlatformDefaultBootValid = EfiBootManagerInitializeLoadOption (
+  ,
+  0,
+  LoadOptionTypeBoot,
+  LOAD_OPTION_ACTIVE,
+  L"Default PlatformBoot",
+  FilePath,
+  NULL,
+  0
+  ) == EFI_SUCCESS;
+
+DEBUG ((DEBUG_ERROR, "%d\n", PlatformDefaultBootValid));
+ASSERT (PlatformDefaultBootValid == TRUE);
+if (PlatformDefaultBootValid) {
+  EfiBootManagerLoadOptionToVariable();
+  EfiBootManagerFreeLoadOption ();
+}
+FreePool (FilePath);
+  }
+
   //
   // Initialize the platform language variables
   //
-- 
2.43.0



Re: [edk2-devel] [PATCH 1/2] UefiCpuPkg/MpInitLib: Use AsmCpuidEx() for CPUID_EXTENDED_TOPOLOGY leaf

2023-11-28 Thread Lendacky, Thomas via groups.io

On 11/6/23 17:15, Tom Lendacky wrote:

On 11/6/23 16:45, Lendacky, Thomas via groups.io wrote:

The CPUID_EXTENDED_TOPOLOGY CPUID leaf takes a subleaf as input when
returning CPUID information. However, the AsmCpuid() function does not
zero out ECX before the CPUID instruction, so the input leaf is used as
the sub-leaf for the CPUID request and returns erroneous/invalid CPUID
data, since the intent of the request was to get data related to sub-leaf
0. Instead, use AsmCpuidEx() for the CPUID_EXTENDED_TOPOLOGY leaf.


Alternatively, the AsmCpuid() function could be changed to XOR ECX before 
invoking the CPUID instruction. This would ensure that the 0 sub-leaf is 
returned for any CPUID leaves that support sub-leaves. Thoughts?


Adding some additional maintainers for their thoughts, too.


Any thoughts on this approach (as a separate, unrelated patch) to 
eliminate future issues that could pop up?


Seems like zeroing out ECX before calling CPUID would be an appropriate 
thing to do, but I'm not sure if that will have any impact on the existing 
code base... it shouldn't, but you never know.


Thanks,
Tom



Thanks,
Tom



Fixes: d4d7c9ad5fe5 ("UefiCpuPkg/MpInitLib: use BSP to do extended ...")
Signed-off-by: Tom Lendacky 
---
  UefiCpuPkg/Library/MpInitLib/AmdSev.c | 9 -
  1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/AmdSev.c 
b/UefiCpuPkg/Library/MpInitLib/AmdSev.c

index bda4960f6fd3..d34f9513e002 100644
--- a/UefiCpuPkg/Library/MpInitLib/AmdSev.c
+++ b/UefiCpuPkg/Library/MpInitLib/AmdSev.c
@@ -256,7 +256,14 @@ FillExchangeInfoDataSevEs (
    if (StdRangeMax >= CPUID_EXTENDED_TOPOLOGY) {
  CPUID_EXTENDED_TOPOLOGY_EBX  ExtTopoEbx;
-    AsmCpuid (CPUID_EXTENDED_TOPOLOGY, NULL, , NULL, 
NULL);

+    AsmCpuidEx (
+  CPUID_EXTENDED_TOPOLOGY,
+  0,
+  NULL,
+  ,
+  NULL,
+  NULL
+  );
  ExchangeInfo->ExtTopoAvail = !!ExtTopoEbx.Bits.LogicalProcessors;
    }
  }



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111810): https://edk2.groups.io/g/devel/message/111810
Mute This Topic: https://groups.io/mt/102432782/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v2 1/1] MdeModulePkg: Fix issue with ACPI table creation

2023-11-28 Thread Dhaval Sharma
Sent an updated patch already.

On Sat, Nov 18, 2023 at 3:27 AM Laszlo Ersek  wrote:

> On 11/17/23 18:50, Chiu, Chasel wrote:
> >
> > Hi Dhaval,
> >
> > Just a small feedback,
> > the only difference will be TableToInstall between XDsdt and Dsdt, could
> we optimize the code flow to reduce duplicate lines?
>
> since a v3 is being requested, let me ask for even more:
>
> - can we specify the precise ACPI spec location in the commit message?
>
> - s/abscent/absent/
>
> thanks!
> Laszlo
>
> >
> > Thanks,
> > Chasel
> >
> >
> >> -Original Message-
> >> From: devel@edk2.groups.io  On Behalf Of Dhaval
> >> Sharma
> >> Sent: Friday, November 17, 2023 3:35 AM
> >> To: devel@edk2.groups.io
> >> Cc: Gao, Liming ; Liu, Zhiguang
> >> ; Bi, Dandan 
> >> Subject: [edk2-devel] [PATCH v2 1/1] MdeModulePkg: Fix issue with ACPI
> table
> >> creation
> >>
> >> As per spec if xDSDT is avaialble, it should be used first.
> >> Handle required flow when xDSDT is abscent or present.
> >>
> >> Test: Tested on RISCV64 Qemu platform with xDSDT and booted to linux
> kernel.
> >>
> >> Cc: Liming Gao 
> >> Cc: Zhiguang Liu 
> >> Cc: Dandan Bi 
> >> Signed-off-by: Dhaval Sharma 
> >> ---
> >>
> >> Notes:
> >> v2:
> >> - Added proper indentation for else if
> >>
> >>  MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 13
> >> -
> >>  1 file changed, 12 insertions(+), 1 deletion(-)
> >>
> >> diff --git
> a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> >> b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> >> index e09bc9b704f5..11097ed4c3be 100644
> >> --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> >> +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> >> @@ -1892,7 +1892,18 @@ InstallAcpiTableFromHob (
> >>} } -if
> (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE
> >> *)ChildTable)->Dsdt != 0) {+//+// First check if xDSDT
> is available that is
> >> preferred+//+if
> (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE
> >> *)ChildTable)->XDsdt != 0) {+  TableToInstall = (VOID
> >> *)(UINTN)((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)ChildTable)-
> >>> XDsdt;+  Status = AddTableToList (AcpiTableInstance,
> TableToInstall,
> >> TRUE, Version, TRUE, );+  if (EFI_ERROR (Status)) {+
>   DEBUG
> >> ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add ACPI table
> xDSDT\n"));+
> >> ASSERT_EFI_ERROR (Status);+break;+  }+}
> else if
> >> (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)ChildTable)->Dsdt != 0)
> >> {   TableToInstall = (VOID
> >> *)(UINTN)((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)ChildTable)-
> >>> Dsdt;   Status = AddTableToList (AcpiTableInstance,
> TableToInstall,
> >> TRUE, Version, TRUE, );   if (EFI_ERROR (Status)) {--
> >> 2.39.2
> >>
> >>
> >>
> >> -=-=-=-=-=-=
> >> Groups.io Links: You receive all messages sent to this group.
> >> View/Reply Online (#111395):
> https://edk2.groups.io/g/devel/message/111395
> >> Mute This Topic: https://groups.io/mt/102645488/1777047
> >> Group Owner: devel+ow...@edk2.groups.io
> >> Unsubscribe: https://edk2.groups.io/g/devel/unsub [
> chasel.c...@intel.com] -=-
> >> =-=-=-=-=
> >>
> >
> >
> >
> > 
> >
> >
>
>

-- 
Thanks!
=D


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111809): https://edk2.groups.io/g/devel/message/111809
Mute This Topic: https://groups.io/mt/102645488/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 0/2] OvmfPkg: Enable measured direct boot on AMD SEV-SNP

2023-11-28 Thread Ard Biesheuvel
On Mon, 27 Nov 2023 at 21:04, Tom Lendacky  wrote:
>
> On 3/20/23 05:06, Gerd Hoffmann wrote:
> > On Thu, Mar 02, 2023 at 09:15:30AM +, Dov Murik wrote:
> >> AMD SEV and SEV-ES support measured direct boot with
> >> kernel/initrd/cmdline hashes injected by QEMU and verified by OVMF
> >> during boot.
> >>
> >> To enable the same approach for AMD SEV-SNP, we declare the kernel
> >> hashes page in the SNP metadata list as a new region type.  When QEMU
> >> encounters that region in the list, it will insert the hashes of
> >> kernel/initrd/cmdline and encrypt the page (or, if the user turned off
> >> kernel hashes, it will validate the page as a zero page).
> >>
> >> The first patch rearranges the pages in AmdSevX64's MEMFD so they are in
> >> the same order both as in the main target (OvmfPkgX64), with the
> >> exception of the SEV Launch Secret page which isn't defined in
> >> OvmfPkgX64.
> >>
> >> The second patch modifies the SNP metadata structure such that on
> >> AmdSev target the SEV Launch Secret page is explicitly defined in SNP
> >> metadata list, and therefore it is not included in the ranges that are
> >> pre-validated (zero pages) by the VMM; instead the VMM will insert
> >> content into this page (the hashes table), or mark it explicitly as a
> >> zero page if no hashes are added.
> >>
> >> This series is available at:
> >> https://github.com/confidential-containers-demo/edk2/tree/snp-kernel-hashes-v3
> >>
> >> A corresponding QEMU RFC series will be published soon in qemu-devel, or
> >> use this tree:
> >> https://github.com/confidential-containers-demo/qemu/tree/snp-kernel-hashes-v3
> >
> > For the series:
> > Acked-by: Gerd Hoffmann 
>
> I've noticed that series was never picked up. Any chance that this can be
> merged?
>

Queued up now

Apologies for the delay.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111808): https://edk2.groups.io/g/devel/message/111808
Mute This Topic: https://groups.io/mt/97335488/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v1 1/1] ArmPkg/ArmMmuLib: Use function pointer type

2023-11-28 Thread Ard Biesheuvel
On Tue, 28 Nov 2023 at 00:58,  wrote:
>
> From: Michael Kubacki 
>
> mReplaceLiveEntryFunc is a function pointer but assigned as a VOID*
> pointer:
>
>   mReplaceLiveEntryFunc = *(VOID **)GET_GUID_HOB_DATA (Hob);
>
> This leads to the Visual Studio warning:
>
>   nonstandard extension, function/data pointer conversion in
>   expression
>
> This change updates the assignment to avoid using a data pointer and
> defines a type for the function pointer to succinctly and accurately
> refer to the type when it is used in the library code.
>
> Cc: Ard Biesheuvel 
> Cc: Leif Lindholm 
> Cc: Sami Mujawar 
> Signed-off-by: Michael Kubacki 

Merged, thanks.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111807): https://edk2.groups.io/g/devel/message/111807
Mute This Topic: https://groups.io/mt/102841630/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH 2/2] UefiCpuPkg/MpInitLib: Copy SEV-ES save area pointer during APIC ID sorting

2023-11-28 Thread Ni, Ray
Reviewed-by: Ray Ni 

Thanks,
Ray
> -Original Message-
> From: Tom Lendacky 
> Sent: Tuesday, November 7, 2023 6:46 AM
> To: devel@edk2.groups.io
> Cc: Dong, Eric ; Ni, Ray ; Kumar,
> Rahul R ; Gerd Hoffmann ;
> Ard Biesheuvel ; Michael Roth
> 
> Subject: [PATCH 2/2] UefiCpuPkg/MpInitLib: Copy SEV-ES save area pointer
> during APIC ID sorting
> 
> With SEV-SNP, the SEV-ES save area for a vCPU should be unique to that
> vCPU. After commit 3323359a811a, the VMSA allocation was re-used, but
> when
> sorting the CPUs by APIC ID, the save area was not updated to follow the
> original CPU. Similar to the StartupApSignal address, the SevEsSaveArea
> address should be updated when sorting the CPUs.
> 
> This does not cause an issue at this time because all APs are in HLT state
> and then are (re)started at the same time, with the same VMSA contents.
> However, this should be fixed to account for any change in future
> behavior.
> 
> Fixes: 3323359a811a ("UefiCpuPkg/MpInitLib: Reuse VMSA allocation to ...")
> Signed-off-by: Tom Lendacky 
> ---
>  UefiCpuPkg/Library/MpInitLib/MpLib.c | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 9a6ec5db5ce9..a41b9e5701af 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -370,6 +370,7 @@ SortApicId (
>UINT32   ApCount;
>CPU_INFO_IN_HOB  *CpuInfoInHob;
>volatile UINT32  *StartupApSignal;
> +  VOID *SevEsSaveArea;
> 
>ApCount  = CpuMpData->CpuCount - 1;
>CpuInfoInHob = (CPU_INFO_IN_HOB
> *)(UINTN)CpuMpData->CpuInfoInHob;
> @@ -397,12 +398,17 @@ SortApicId (
>  CopyMem ([Index1], , sizeof
> (CPU_INFO_IN_HOB));
> 
>  //
> -// Also exchange the StartupApSignal.
> +// Also exchange the StartupApSignal and SevEsSaveArea.
>  //
>  StartupApSignal=
> CpuMpData->CpuData[Index3].StartupApSignal;
>  CpuMpData->CpuData[Index3].StartupApSignal =
>CpuMpData->CpuData[Index1].StartupApSignal;
>  CpuMpData->CpuData[Index1].StartupApSignal = StartupApSignal;
> +
> +SevEsSaveArea=
> CpuMpData->CpuData[Index3].SevEsSaveArea;
> +CpuMpData->CpuData[Index3].SevEsSaveArea =
> +  CpuMpData->CpuData[Index1].SevEsSaveArea;
> +CpuMpData->CpuData[Index1].SevEsSaveArea = SevEsSaveArea;
>}
>  }
> 
> --
> 2.42.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111806): https://edk2.groups.io/g/devel/message/111806
Mute This Topic: https://groups.io/mt/102432047/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: 
https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH 1/2] UefiCpuPkg/MpInitLib: Use AsmCpuidEx() for CPUID_EXTENDED_TOPOLOGY leaf

2023-11-28 Thread Ni, Ray
Reviewed-by: Ray Ni 

Thanks,
Ray
> -Original Message-
> From: Tom Lendacky 
> Sent: Tuesday, November 7, 2023 6:46 AM
> To: devel@edk2.groups.io
> Cc: Dong, Eric ; Ni, Ray ; Kumar,
> Rahul R ; Gerd Hoffmann ;
> Ard Biesheuvel ; Michael Roth
> 
> Subject: [PATCH 1/2] UefiCpuPkg/MpInitLib: Use AsmCpuidEx() for
> CPUID_EXTENDED_TOPOLOGY leaf
> 
> The CPUID_EXTENDED_TOPOLOGY CPUID leaf takes a subleaf as input when
> returning CPUID information. However, the AsmCpuid() function does not
> zero out ECX before the CPUID instruction, so the input leaf is used as
> the sub-leaf for the CPUID request and returns erroneous/invalid CPUID
> data, since the intent of the request was to get data related to sub-leaf
> 0. Instead, use AsmCpuidEx() for the CPUID_EXTENDED_TOPOLOGY leaf.
> 
> Fixes: d4d7c9ad5fe5 ("UefiCpuPkg/MpInitLib: use BSP to do extended ...")
> Signed-off-by: Tom Lendacky 
> ---
>  UefiCpuPkg/Library/MpInitLib/AmdSev.c | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/UefiCpuPkg/Library/MpInitLib/AmdSev.c
> b/UefiCpuPkg/Library/MpInitLib/AmdSev.c
> index bda4960f6fd3..d34f9513e002 100644
> --- a/UefiCpuPkg/Library/MpInitLib/AmdSev.c
> +++ b/UefiCpuPkg/Library/MpInitLib/AmdSev.c
> @@ -256,7 +256,14 @@ FillExchangeInfoDataSevEs (
>if (StdRangeMax >= CPUID_EXTENDED_TOPOLOGY) {
>  CPUID_EXTENDED_TOPOLOGY_EBX  ExtTopoEbx;
> 
> -AsmCpuid (CPUID_EXTENDED_TOPOLOGY, NULL, ,
> NULL, NULL);
> +AsmCpuidEx (
> +  CPUID_EXTENDED_TOPOLOGY,
> +  0,
> +  NULL,
> +  ,
> +  NULL,
> +  NULL
> +  );
>  ExchangeInfo->ExtTopoAvail = !!ExtTopoEbx.Bits.LogicalProcessors;
>}
>  }
> --
> 2.42.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111805): https://edk2.groups.io/g/devel/message/111805
Mute This Topic: https://groups.io/mt/102432043/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: 
https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v5 00/16] Add ImagePropertiesRecordLib and Fix MAT Bugs​

2023-11-28 Thread Ni, Ray
Taylor,
Thanks for spending time on removing the duplicated code in DxeCore and SmmCore.

I am ok with your current patch series. But I do have some suggestions that you 
or someone else could possibly enhance the lib API in future:

In MdeModulePkg\Core\Dxe\Misc\MemoryAttributesTable.c, InsertImageRecord() is 
implemented to call the new ImagePropertiesRecordLib as follows:
1. CreateImagePropertiesRecord() to create the IMAGE_PROPERTIES_RECORD instance.
  1.a. The lib parses the PE-COFF header to extract all the sections.
  Should we update PeCoffLib to add the missing capability that extracts 
the section info?
  I am ok to keep the section extraction code in ImagePropertiesRecordLib 
as the comments below are more cared by me.

2. if no code section, error
  2.a. Can we update CreateImagePropertiesRecord() to return failure status if 
no code section is found?
 We only need the lib API to return success for no-code-section case when 
caller does require to handle it differently.

3. IsImageRecordCodeSectionValid() to check if code sections are valid.
  Should we update the lib implementation to do the check before 
CreateImagePropertiesRecord() returns? This could reduce one API interface. 
Also this makes the caller easier to write.

4. Insert the IMAGE_PROPERTIES_RECORD instance to ImageRecordList.
  Should we rename CreateImagePropertiesRecord() to 
InsertImagePropertiesRecord() so that the insertion is done before 
InsertImagePropertiesRecord() returns?

5. Sort the ImageRecordList.
  Should we update the CreateImagePropertiesRecord() 
/InsertImagePropertiesRecord() to sort the list internally before it returns?


In summary, we could design the library API in a way that caller could call as 
follows:

LIST_ENTRY mImageList;
VOID *ImagePropertiesRecord;

InitializeListHead ();
InsertImagePropertiesRecord (, ImageBase, ImageSize, 
);
// caller doesn't know what's stored for one image properties record. It only 
knows a "handle" to the image properties record.
Saves ImagePropertiesRecord in EFI_RUNTIME_IMAGE_ENTRY for later unload.

If any error happens later on:
  DeleteImagePropertiesRecord (ImagePropertiesRecord);


So, following APIs can be eliminated:
* Structure IMAGE_PROPERTIES_RECORD_CODE_SECTION
* Structure IMAGE_PROPERTIES_RECORD
* SortImageRecordCodeSection()
* IsImageRecordCodeSectionValid()
* SortImageRecord()
* SwapImageRecord()
* SwapImageRecordCodeSection()
* FindImageRecord()

And only following APIs are needed:
* InsertImagePropertiesRecord()
* DeleteImagePropertiesRecord()
* SplitMemoryDescriptors() or SplitTable()
* DumpImageRecords()



Thanks,
Ray
> -Original Message-
> From: Ard Biesheuvel 
> Sent: Tuesday, November 28, 2023 2:40 AM
> To: Taylor Beebe 
> Cc: devel@edk2.groups.io; Andrew Fish ; Ard Biesheuvel
> ; Bi, Dandan ; Dong,
> Eric ; Gerd Hoffmann ; Dong,
> Guo ; Guo, Gua ; Lu, James
> ; Wang, Jian J ; Yao, Jiewen
> ; Justen, Jordan L ; Leif
> Lindholm ; Gao, Liming
> ; Kumar, Rahul R ; Ni,
> Ray ; Sami Mujawar ; Rhodes,
> Sean ; Lazlo Ersek 
> Subject: Re: [PATCH v5 00/16] Add ImagePropertiesRecordLib and Fix MAT
> Bugs​
> 
> On Mon, 27 Nov 2023 at 19:18, Taylor Beebe 
> wrote:
> >
> > v5:
> > This version is purely an update of commit messages and orientation.
> > No code changes were made.
> > - Split patch 9 into 3 separate patches so each fix is in its own
> >   commit.
> > - Updated the commit comment of patch 11 to add context.
> >
> 
> Thanks for sticking with this.
> 
> For the series,
> 
> Reviewed-by: Ard Biesheuvel 
> 
> 
> 
> > v4:
> > - Expose additional functions in the Library API
> > - Add NULL checks to library functions and return a
> >   status where applicable.
> >
> > v3:
> > - Refactor patch series so the transition of logic from the DXE
> >   MAT logic to the new library is more clear.
> > - Update function headers to improve clarity and follow EDK2
> >   standards.
> > - Add Create and Delete functions for Image Properties Records
> >   and redirect some of the SMM and DXE MAT code to use these
> >   functions.
> > - Update/Add DumpImageRecords() to print the image name and code
> >   sections of each runtime image which will be put in the MAT.
> >   The DXE and SMM MAT logic will now invoke the DumpImageRecords()
> >   on DEBUG builds at the EndOfDxe event to install the MAT.
> >
> > v2:
> > - A one-line change in patch 3 was moved to patch 9 for correctness.
> >
> > Reference: https://github.com/tianocore/edk2/pull/4590
> > Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=4492
> >
> > The UEFI and SMM MAT logic contains duplicate logic for manipulating
> image
> > properties records which is used to track runtime images.
> > This patch series adds a new library, ImagePropertiesRecordLib,
> > which consolidates this logic and fixes the bugs which currently exist in
> > the MAT logic.
> >
> > The first patch adds the ImagePropertiesRecordLib implementation which
> > is a copy of the UEFI MAT logic with minor 

Re: [edk2-devel] [PATCH v1 0/2] ArmPkg/CpuDxe: Use upper and lower attributes

2023-11-28 Thread Ard Biesheuvel
On Tue, 28 Nov 2023 at 01:15,  wrote:
>
> From: Michael Kubacki 
>
> This series contains two changes:
>
> 1. To fix a compiler warning with the current state of code.
> 2. To update the code to pass the integer width needed for a
>comparison to set EFI_MEMORY_XP in the GCD attribute returned
>for a given page attribute.
>
> Cc: Leif Lindholm 
> Cc: Ard Biesheuvel 
> Cc: Sami Mujawar 
>
> Michael Kubacki (2):
>   ArmPkg/Drivers/CpuDxe: Explicitly cast table entry
>   ArmPkg/Drivers/CpuDxe: Use lower and upper attributes
>

Thanks for the fixes. This code is in a rather poor state, unfortunately.

I don't quite get the motivation for fixing this using two different
patches: the implicit UINT32 cast obviously loses some attributes (the
ones in the 12 upper bits, notably UXN and PXN), so making it explicit
removes the warning but preserves the bug. (If GCC had better
diagnostics, we'd spotted this problem years ago)

Maybe it is sufficient to simply squash the two patches together?


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111803): https://edk2.groups.io/g/devel/message/111803
Mute This Topic: https://groups.io/mt/102841999/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] UefiCpuPkg/PiSmmCpuDxeSmm: Use NonSmm BSP as default SMM BSP.

2023-11-28 Thread Ni, Ray
Reviewed-by: Ray Ni 

Thanks,
Ray
> -Original Message-
> From: Liu, Zhiguang 
> Sent: Thursday, November 23, 2023 11:23 AM
> To: devel@edk2.groups.io
> Cc: Liu, Zhiguang ; Ni, Ray ;
> Kumar, Rahul R ; Gerd Hoffmann
> ; Laszlo Ersek 
> Subject: [PATCH v3] UefiCpuPkg/PiSmmCpuDxeSmm: Use NonSmm BSP as
> default SMM BSP.
> 
> Currently, if BSP election is not enabled, will use Core0 as SMM BSP.
> However, Core0 does not always have the highest performance.
> So, we can used NonSmm BSP as default BSP.
> This will take effect in normal SMM init flow and S3 boot flow.
> In normal SMM flow, the code is executed in Non-SMM mode.
> In S3 flow, the code is executed in Non-SMM BSP's first SMI, where the
> gSmmCpuPrivate keeps the data from last boot.
> 
> V3:
> Add more commit message explaining S3 flow.
> 
> Cc: Ray Ni 
> Cc: Rahul Kumar 
> Cc: Gerd Hoffmann 
> Cc: Laszlo Ersek 
> Signed-off-by: Zhiguang Liu 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> index 25d058c5b9..b279f5dfcc 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> @@ -1953,6 +1953,16 @@ InitializeMpSyncData (
>// Enable BSP election by setting BspIndex to -1
>//
>mSmmMpSyncData->BspIndex = (UINT32)-1;
> +} else {
> +  //
> +  // Use NonSMM BSP as SMM BSP
> +  //
> +  for (CpuIndex = 0; CpuIndex <
> gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; CpuIndex++) {
> +if (GetApicId () ==
> gSmmCpuPrivate->ProcessorInfo[CpuIndex].ProcessorId) {
> +  mSmmMpSyncData->BspIndex = (UINT32)CpuIndex;
> +  break;
> +}
> +  }
>  }
> 
>  mSmmMpSyncData->EffectiveSyncMode = mCpuSmmSyncMode;
> --
> 2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111802): https://edk2.groups.io/g/devel/message/111802
Mute This Topic: https://groups.io/mt/102761712/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: 
https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v2] UefiCpuPkg/PiSmmCpuDxeSmm: Use NonSmm BSP as default SMM BSP.

2023-11-28 Thread Ni, Ray
Reviewed-by: Ray Ni 

Thanks,
Ray
> -Original Message-
> From: Liu, Zhiguang 
> Sent: Monday, November 20, 2023 11:10 AM
> To: devel@edk2.groups.io
> Cc: Liu, Zhiguang ; Ni, Ray ;
> Kumar, Rahul R ; Gerd Hoffmann
> ; Laszlo Ersek 
> Subject: [PATCH v2] UefiCpuPkg/PiSmmCpuDxeSmm: Use NonSmm BSP as
> default SMM BSP.
> 
> Currently, if BSP election is not enabled, will use Core0 as SMM BSP.
> However, Core0 does not always have the highest performance.
> So, we can used NonSmm BSP as default BSP.
> This will take effect in normal SMM init flow and S3 boot flow
> 
> Cc: Ray Ni 
> Cc: Rahul Kumar 
> Cc: Gerd Hoffmann 
> Cc: Laszlo Ersek 
> Signed-off-by: Zhiguang Liu 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> index 25d058c5b9..b279f5dfcc 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> @@ -1953,6 +1953,16 @@ InitializeMpSyncData (
>// Enable BSP election by setting BspIndex to -1
>//
>mSmmMpSyncData->BspIndex = (UINT32)-1;
> +} else {
> +  //
> +  // Use NonSMM BSP as SMM BSP
> +  //
> +  for (CpuIndex = 0; CpuIndex <
> gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; CpuIndex++) {
> +if (GetApicId () ==
> gSmmCpuPrivate->ProcessorInfo[CpuIndex].ProcessorId) {
> +  mSmmMpSyncData->BspIndex = (UINT32)CpuIndex;
> +  break;
> +}
> +  }
>  }
> 
>  mSmmMpSyncData->EffectiveSyncMode = mCpuSmmSyncMode;
> --
> 2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111801): https://edk2.groups.io/g/devel/message/111801
Mute This Topic: https://groups.io/mt/102701170/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: 
https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH 0/7] Add VirtMmCommunication driver, enable for OVMF and ArmVirt.

2023-11-28 Thread Ard Biesheuvel
On Thu, 23 Nov 2023 at 16:02, Gerd Hoffmann  wrote:
>
> This is the edk2 side of the qemu patch series posted last week to
> qemu-devel:
>   https://lists.gnu.org/archive/html/qemu-devel/2023-11/msg03714.html
>
> The driver forwards MM calls to the virtualization host instead of the
> MM code running in SMM (x64) or el3 (arm) mode.  The functionality
> traditionally implemented by the SMM code is provided by qemu instead.
>
> This allows to provide persistent variable support without an
> (virtual) flash device and it also allows to support secure
> boot without depending on SMM or el3 emulation support in the
> hypervisor.
>

I like this a lot - not only for QEMU + OVMF/ArmVirt, but also for
other VM firmware projects (I am working on a minimal UEFI
implementation in Rust for ArmVirt, and variable support is much
easier to implement using this paravirt interface)


> Gerd Hoffmann (7):
>   OvmfPkg: add IndustryStandard/QemuUefiVars.h
>   OvmfPkg: add new VirtMmCommunicationDxe driver
>   OvmfPkg/OvmfPkgX64: add QEMU_VARS option
>   OvmfPkg: add PcdQemuVarsRequire
>   OvmfPkg/VirtMmCommunicationDxe: stop on init failure
>   OvmfPkg/VirtMmCommunicationDxe: add arm support
>   ArmVirtPkg/ArmVirtQemu: add QEMU_VARS option
>
>  OvmfPkg/OvmfPkg.dec   |   3 +
>  ArmVirtPkg/ArmVirt.dsc.inc|   3 +
>  ArmVirtPkg/ArmVirtQemu.dsc|  11 +
>  ArmVirtPkg/ArmVirtQemuKernel.dsc  |  11 +
>  OvmfPkg/OvmfPkgX64.dsc|  17 +-
>  OvmfPkg/OvmfPkgX64.fdf|  12 +-
>  OvmfPkg/PlatformPei/PlatformPei.inf   |   1 +
>  .../VirtMmCommunication.inf   |  67 +++
>  .../Include/IndustryStandard/QemuUefiVars.h   |  41 ++
>  .../VirtMmCommunication.h |  37 ++
>  OvmfPkg/PlatformPei/Platform.c|   4 +
>  OvmfPkg/VirtMmCommunicationDxe/QemuFdt.c  | 208 ++
>  OvmfPkg/VirtMmCommunicationDxe/QemuX64.c  | 106 +
>  .../VirtMmCommunication.c | 390 ++
>  ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc  |   5 +
>  15 files changed, 914 insertions(+), 2 deletions(-)
>  create mode 100644 OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.inf
>  create mode 100644 OvmfPkg/Include/IndustryStandard/QemuUefiVars.h
>  create mode 100644 OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.h
>  create mode 100644 OvmfPkg/VirtMmCommunicationDxe/QemuFdt.c
>  create mode 100644 OvmfPkg/VirtMmCommunicationDxe/QemuX64.c
>  create mode 100644 OvmfPkg/VirtMmCommunicationDxe/VirtMmCommunication.c
>
> --
> 2.42.0
>
>
>
> 
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111800): https://edk2.groups.io/g/devel/message/111800
Mute This Topic: https://groups.io/mt/102767943/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-