Re: [edk2-devel] [PATCH v2 0/3] BaseTools: Add support for gdb and lldb

2022-04-08 Thread Bob Feng
Created the PR.
https://github.com/tianocore/edk2/pull/2758

-Original Message-
From: Rebecca Cran  
Sent: Thursday, April 7, 2022 6:34 AM
To: devel@edk2.groups.io; Leif Lindholm ; Kinney, 
Michael D ; Wu, Hao A ; Feng, 
Bob C ; Gao, Liming ; Chen, 
Christine 
Cc: Andrew Fish 
Subject: Re: [PATCH v2 0/3] BaseTools: Add support for gdb and lldb

Could I have some more reviews on this please? I'd like to get this into the 
tree soon.

--
Rebecca Cran

On 3/21/22 14:20, Rebecca Cran wrote:
> This patch set adds debugging support for gdb and lldb.
> It also adds generic debugging classes that use a file like object to 
> make it easy to import into any debugger that supports Python.
>
> Changes from v1 to v2:
> - Moved scripts from the root of the repo into BaseTools/Scripts.
> - Fixed typo of "RISCV" as "RISKV".
>
> Testing:
> - Tested gdb on Ubuntu and lldb on macOS for IA32 and X64.
> - Tested gdb on openSUSE for AARCH64.
>
> Rebecca Cran (3):
>BaseTools: efi_debugging.py: Add debugger agnostic dbg Python Classes
>BaseTools: Scripts/efi_gdb.py: Add gdb EFI commands and pretty Print
>BaseTools: Scripts/efi_lldb.py: Add lldb EFI commands and pretty 
> Print
>
>   BaseTools/Scripts/efi_debugging.py | 2185 
>   BaseTools/Scripts/efi_gdb.py   |  918 
>   BaseTools/Scripts/efi_lldb.py  | 1044 ++
>   3 files changed, 4147 insertions(+)
>   create mode 100755 BaseTools/Scripts/efi_debugging.py
>   create mode 100755 BaseTools/Scripts/efi_gdb.py
>   create mode 100755 BaseTools/Scripts/efi_lldb.py
>



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88661): https://edk2.groups.io/g/devel/message/88661
Mute This Topic: https://groups.io/mt/89937670/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 3/3] BaseTools: Scripts/efi_lldb.py: Add lldb EFI commands and pretty Print

2022-04-08 Thread Bob Feng
Reviewed-by: Bob Feng 

On Tue, Mar 22, 2022 at 04:21 AM, Rebecca Cran wrote:

> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=3500
> 
> Use efi_debugging.py Python Classes to implement EFI gdb commands:
> efi_symbols, guid, table, hob, and devicepath
> 
> You can attach to any standard gdb or kdp remote server and get EFI
> symbols. No modifications of EFI are required.
> 
> Example usage:
> OvmfPkg/build.sh qemu -gdb tcp::9000
> lldb -o "gdb-remote localhost:9000" -o "command script import efi_lldb.py"
> 
> Note you may also have to teach lldb about QEMU:
> -o "settings set plugin.process.gdb-remote.target-definition-file
> x86_64_target_definition.py"
> 
> Cc: Leif Lindholm 
> Cc: Michael D Kinney 
> Cc: Hao A Wu 
> Cc: Bob Feng 
> Cc: Liming Gao 
> Cc: Yuwei Chen 
> Signed-off-by: Rebecca Cran 
> ---
> BaseTools/Scripts/efi_lldb.py | 1044 
> 1 file changed, 1044 insertions(+)
> 
> diff --git a/BaseTools/Scripts/efi_lldb.py b/BaseTools/Scripts/efi_lldb.py
> 
> new file mode 100755
> index ..089b6ba58ab8
> --- /dev/null
> +++ b/BaseTools/Scripts/efi_lldb.py
> @@ -0,0 +1,1044 @@
> +#!/usr/bin/python3
> +'''
> +Copyright (c) Apple Inc. 2021
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +Example usage:
> +OvmfPkg/build.sh qemu -gdb tcp::9000
> +lldb -o "gdb-remote localhost:9000" -o "command script import
> efi_lldb.py"
> +'''
> +
> +import optparse
> +import shlex
> +import subprocess
> +import uuid
> +import sys
> +import os
> +from pathlib import Path
> +from efi_debugging import EfiDevicePath, EfiConfigurationTable, EfiTpl
> +from efi_debugging import EfiHob, GuidNames, EfiStatusClass, EfiBootMode
> +from efi_debugging import PeTeImage, patch_ctypes
> +
> +try:
> + # Just try for LLDB in case PYTHONPATH is already correctly setup
> + import lldb
> +except ImportError:
> + try:
> + env = os.environ.copy()
> + env['LLDB_DEFAULT_PYTHON_VERSION'] = str(sys.version_info.major)
> + lldb_python_path = subprocess.check_output(
> + ["xcrun", "lldb", "-P"], env=env).decode("utf-8").strip()
> + sys.path.append(lldb_python_path)
> + import lldb
> + except ValueError:
> + print("Couldn't find LLDB.framework from lldb -P")
> + print("PYTHONPATH should match the currently selected lldb")
> + sys.exit(-1)
> +
> +
> +class LldbFileObject(object):
> + '''
> + Class that fakes out file object to abstract lldb from the generic code.
> 
> + For lldb this is memory so we don't have a concept of the end of the
> file.
> + '''
> +
> + def __init__(self, process):
> + # _exe_ctx is lldb.SBExecutionContext
> + self._process = process
> + self._offset = 0
> + self._SBError = lldb.SBError()
> +
> + def tell(self):
> + return self._offset
> +
> + def read(self, size=-1):
> + if size == -1:
> + # arbitrary default size
> + size = 0x100
> +
> + data = self._process.ReadMemory(self._offset, size, self._SBError)
> + if self._SBError.fail:
> + raise MemoryError(
> + f'lldb could not read memory 0x{size:x} '
> + f' bytes from 0x{self._offset:08x}')
> + else:
> + return data
> +
> + def readable(self):
> + return True
> +
> + def seek(self, offset, whence=0):
> + if whence == 0:
> + self._offset = offset
> + elif whence == 1:
> + self._offset += offset
> + else:
> + # whence == 2 is seek from end
> + raise NotImplementedError
> +
> + def seekable(self):
> + return True
> +
> + def write(self, data):
> + result = self._process.WriteMemory(self._offset, data, self._SBError)
> + if self._SBError.fail:
> + raise MemoryError(
> + f'lldb could not write memory to 0x{self._offset:08x}')
> + return result
> +
> + def writable(self):
> + return True
> +
> + def truncate(self, size=None):
> + raise NotImplementedError
> +
> + def flush(self):
> + raise NotImplementedError
> +
> + def fileno(self):
> + raise NotImplementedError
> +
> +
> +class EfiSymbols:
> + """
> + Class to manage EFI Symbols
> + You need to pass file, and exe_ctx to load symbols.
> + You can print(EfiSymbols()) to see the currently loaded symbols
> + """
> +
> + loaded = {}
> + stride = None
> + range = None
> + verbose = False
> +
> + def __init__(self, target=None):
> + if target:
> + EfiSymbols.target = target
> + EfiSymbols._file = LldbFileObject(target.process)
> +
> + @ classmethod
> + def __str__(cls):
> + return ''.join(f'{pecoff}\n' for (pecoff, _) in cls.loaded.values())
> +
> + @ classmethod
> + def configure_search(cls, stride, range, verbose=False):
> + cls.stride = stride
> + cls.range = range
> + cls.verbose = verbose
> +
> + @ classmethod
> + def clear(cls):
> + cls.loaded = {}
> +
> + @ classmethod
> + def add_symbols_for_pecoff(cls, pecoff):
> + '''Tell lldb the location of the .text and .data sections.'''
> +
> + if pecoff.LoadAddress in cls.loaded:
> + return 'Already Loaded: '
> +
> + module = cls.target.AddModule(None, None, str(pecoff.CodeViewUuid))
> + if not module:
> + module = cls.target.AddModule(pecoff.CodeViewPdb,
> + None,
> + str(pecoff.CodeViewUuid))
> + if module.IsValid():
> + SBError = 

Re: [edk2-devel] [PATCH v3 0/3] BaseTools: fix gcc workaround

2022-04-08 Thread Bob Feng
Hi Gerd,

Your patches are great but I think we can't take them because of the 
incompatible license.
I think the new Toolchain definition, like GCC12, can not resolve this issue 
because Toolchain is not used for building BaseTools.
So I'd prefer the second option of using 'gcc -dumpversion'.

And also we have the task to convert the tools implemented by C to python 
implementation. After we have done that, there will be no BaseTools build issue.
https://github.com/tianocore/edk2-staging/tree/PyBaseTools

@Gao, Liming @Chen, Christine
Could you review the corresponding patch?

Thanks,
Bob

-Original Message-
From: Gerd Hoffmann  
Sent: Thursday, April 7, 2022 6:12 PM
To: Pedro Falcato 
Cc: edk2-devel-groups-io ; Chen, Christine 
; Gao, Liming ; Pawel Polawski 
; Feng, Bob C ; Oliver Steffen 
; Rebecca Cran 
Subject: Re: [edk2-devel] [PATCH v3 0/3] BaseTools: fix gcc workaround

On Mon, Apr 04, 2022 at 04:18:56PM +0100, Pedro Falcato wrote:
> Hi Gerd,
> 
> These patches are a great idea but I don't know if we can take GPLv2 
> code like that. Are they even mergeable into the main edk2 repo (as 
> it's not compatible with BSD-2-clause)?

It's build system, doesn't end up being linked into firmware code, so not sure 
license compatibility is actually a problem here.

In any case I strongly prefer to fix that in some automatic way which does 
*not* require a new GCC12 tool chain definition.

So, any comments how to move forward with this?
Can we take the series as-is?
If not, other suggestions?
Second-best idea I've seen on the list is using 'gcc -dumpversion'.

Is it an option to just raise the minimum required gcc version to something 
newer?  gcc5 was released almost 7 years ago ...

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88659): https://edk2.groups.io/g/devel/message/88659
Mute This Topic: https://groups.io/mt/90237796/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/3] Add Variable Flash Info HOB

2022-04-08 Thread Michael Kubacki

Hi Hao,

I addressed all of your feedback including abstraction of the 
information with a library API in v2. It did help clean up the 
consumption code quite a bit.


https://edk2.groups.io/g/devel/message/88649

Thanks,
Michael

On 4/7/2022 7:56 PM, Michael Kubacki wrote:
Yes, I considered that as well but I was not sure if it was worth adding 
a new library just for that. I agree though that the code should not be 
duplicated. I will look into it and include your other suggestions in a 
v2 series.


Thanks,
Michael

On 4/6/2022 11:31 PM, Wu, Hao A wrote:

Sorry for a question:
GetVariableFlashInfo() seems being defined multiple times across 
modules, do you see value in abstracting it as a library API?


Best Regards,
Hao Wu


-Original Message-
From: devel@edk2.groups.io  On Behalf Of Michael
Kubacki
Sent: Thursday, April 7, 2022 12:27 AM
To: devel@edk2.groups.io
Cc: Wang, Jian J ; Wu, Hao A 
;

Gao, Liming 
Subject: [edk2-devel] [PATCH v1 0/3] Add Variable Flash Info HOB

From: Michael Kubacki 

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

The UEFI variable drivers such as VariableRuntimeDxe, VariableSmm,
VariableStandaloneMm, etc. (and their dependent protocol/library
stack), typically acquire UEFI variable store flash information
with PCDs declared in MdeModulePkg.

For example:
[Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize

These PCDs work as-is in the StandaloneMm driver if they are not
dynamic such as Dynamic or DynamicEx because PCD services are not
readily available in the Standalone MM environment. Platforms that
use Standalone MM today, must define these PCDs as FixedAtBuild in
their platform build. However, the PCDs do allow platforms to treat
the PCDs as Dynamic/DynamicEx and being able to support that is
currently a gap for Standalone MM.

This patch series introduces a HOB that can be produced by the
platform to provide the same information. The HOB list is
available to Standalone MM.

The PCD declarations are left as-is in MdeModulePkg for backward
compatibility. This means unless a platform wants to use the HOB,
their code will continue to work with no change (they do not need
to produce the HOB). Only if the HOB is found, is its value used
instead of the PCDs.

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Liming Gao 
Signed-off-by: Michael Kubacki   
MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c  
|

111 +---
  MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
|   7 +-
  MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.c
|  92 ++--
  
MdeModulePkg/Universal/Variable/Pei/Variable.c  
|  66

+++-
  
MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c   
|  42


  
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
|

25 -
  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c
|  20 +++-
  
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
|

20 +++-
  
MdeModulePkg/Include/Guid/VariableFlashInfo.h   
|  36

+++
  
MdeModulePkg/MdeModulePkg.dec   
|   4 +

  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h
|   9 +-
  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
|  11 +-
  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
|  11 +-

MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandalon
eMm.inf |  11 +-
  MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf
|  10 +-
  
MdeModulePkg/Universal/Variable/Pei/Variable.h  
|   2 +
  
MdeModulePkg/Universal/Variable/Pei/VariablePei.inf 
|   6 +-
  
MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h   
|  17

+++
  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
|   6 +-
  
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf  
|

6 +-
  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
|   6 +-
  21 files changed, 455 insertions(+), 63 deletions(-)
  create mode 100644 MdeModulePkg/Include/Guid/VariableFlashInfo.h

--
2.28.0.windows.1



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88461): https://edk2.groups.io/g/devel/message/88461
Mute This Topic: https://groups.io/mt/90293658/1768737
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [hao.a...@intel.com]
-=-=-=-=-=-=










-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88658): 

[edk2-devel] [PATCH v2 8/8] UefiPayloadPkg: Add VariableFlashInfoLib

2022-04-08 Thread Michael Kubacki
From: Michael Kubacki 

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

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Maurice Ma 
Cc: Benjamin You 
Cc: Sean Rhodes 
Signed-off-by: Michael Kubacki 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index e2ea48348257..170c5a1db4b2 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -272,6 +272,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
   VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
   
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
 
-- 
2.28.0.windows.1



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




[edk2-devel] [PATCH v2 7/8] OvmfPkg: Add VariableFlashInfoLib

2022-04-08 Thread Michael Kubacki
From: Michael Kubacki 

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

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Anthony Perard 
Cc: Ard Biesheuvel 
Cc: Brijesh Singh 
Cc: Erdem Aktas 
Cc: Gerd Hoffmann 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Julien Grall 
Cc: Min Xu 
Cc: Peter Grehan 
Cc: Rebecca Cran 
Cc: Sebastien Boeuf 
Cc: Tom Lendacky 
Signed-off-by: Michael Kubacki 
---
 OvmfPkg/AmdSev/AmdSevX64.dsc | 1 +
 OvmfPkg/Bhyve/BhyveX64.dsc   | 1 +
 OvmfPkg/CloudHv/CloudHvX64.dsc   | 1 +
 OvmfPkg/IntelTdx/IntelTdxX64.dsc | 1 +
 OvmfPkg/Microvm/MicrovmX64.dsc   | 1 +
 OvmfPkg/OvmfPkgIa32.dsc  | 1 +
 OvmfPkg/OvmfPkgIa32X64.dsc   | 1 +
 OvmfPkg/OvmfPkgX64.dsc   | 1 +
 OvmfPkg/OvmfXen.dsc  | 1 +
 9 files changed, 9 insertions(+)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
index fcdc3efab204..3868c577fe39 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -195,6 +195,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
 
 !if $(BUILD_SHELL) == TRUE
   ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index e1b6b8e15f36..3df49e54de8a 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -206,6 +206,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
 
   #
   # Network libraries
diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
index 20f3bc340807..19b84275eba3 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.dsc
+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
@@ -216,6 +216,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
 
 
   #
diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
index 245155d41b30..f21a33ed6ba3 100644
--- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
+++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
@@ -184,6 +184,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
 
   ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
   ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf
diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index 59580ccd4691..d8603f016a0c 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -206,6 +206,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
 
 
   #
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index e4218b01f0fc..c689d4707046 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -213,6 +213,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
 
 
   #
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index a80cdaacb8bc..44c75639aa5d 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -217,6 +217,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   

[edk2-devel] [PATCH v2 6/8] EmulatorPkg: Add VariableFlashInfoLib

2022-04-08 Thread Michael Kubacki
From: Michael Kubacki 

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

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Andrew Fish 
Cc: Ray Ni 
Cc: Abner Chang 
Cc: Nickle Wang 
Signed-off-by: Michael Kubacki 
---
 EmulatorPkg/EmulatorPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index 554c13ddb500..4cf886b9eac7 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -122,6 +122,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLibRuntimeDxe.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
   SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf
   ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
   FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
-- 
2.28.0.windows.1



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




[edk2-devel] [PATCH v2 5/8] ArmVirtPkg/ArmVirt.dsc.inc: Add VariableFlashInfoLib

2022-04-08 Thread Michael Kubacki
From: Michael Kubacki 

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

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Sami Mujawar 
Cc: Gerd Hoffmann 
Cc: Julien Grall 
Signed-off-by: Michael Kubacki 
---
 ArmVirtPkg/ArmVirt.dsc.inc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index ba711deac025..988c1eb75529 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -177,6 +177,7 @@ [LibraryClasses.common]
   
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
 !endif
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
   
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
-- 
2.28.0.windows.1



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




[edk2-devel] [PATCH v2 4/8] MdeModulePkg/FaultTolerantWrite: Consume Variable Flash Info

2022-04-08 Thread Michael Kubacki
From: Michael Kubacki 

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

Adds support to the UEFI variable fault tolerant write (FTW) drivers
to receive FTW base and size information dynamically via the Variable
Flash Information library.

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Liming Gao 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c 
 | 41 +---
 MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c  
 |  7 +++-
 MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.c   
 | 28 -
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h  
 |  7 +++-
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf 
 | 10 +
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf 
 | 10 +
 
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf 
| 10 +
 MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf 
 | 10 +
 8 files changed, 63 insertions(+), 60 deletions(-)

diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c
index 661e1487673b..f1335870e797 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c
@@ -987,22 +987,43 @@ InitFtwDevice (
   OUT EFI_FTW_DEVICE  **FtwData
   )
 {
-  EFI_FTW_DEVICE  *FtwDevice;
+  EFI_STATUSStatus;
+  EFI_PHYSICAL_ADDRESS  WorkSpaceAddress;
+  UINT64Size;
+  UINTN FtwWorkingSize;
+  EFI_FTW_DEVICE*FtwDevice;
+
+  FtwWorkingSize = 0;
+
+  Status = GetVariableFlashFtwWorkingInfo (, );
+  ASSERT_EFI_ERROR (Status);
+
+  Status = SafeUint64ToUintn (Size, );
+  // This driver currently assumes the size will be UINTN so assert the value 
is safe for now.
+  ASSERT_EFI_ERROR (Status);
 
   //
   // Allocate private data of this driver,
   // Including the FtwWorkSpace[FTW_WORK_SPACE_SIZE].
   //
-  FtwDevice = AllocateZeroPool (sizeof (EFI_FTW_DEVICE) + PcdGet32 
(PcdFlashNvStorageFtwWorkingSize));
+  FtwDevice = AllocateZeroPool (sizeof (EFI_FTW_DEVICE) + FtwWorkingSize);
   if (FtwDevice == NULL) {
 return EFI_OUT_OF_RESOURCES;
   }
 
+  FtwDevice->WorkSpaceAddress = WorkSpaceAddress;
+  FtwDevice->WorkSpaceLength  = FtwWorkingSize;
+
+  Status = GetVariableFlashFtwSpareInfo (>SpareAreaAddress, );
+  ASSERT_EFI_ERROR (Status);
+
+  Status = SafeUint64ToUintn (Size, >SpareAreaLength);
+  // This driver currently assumes the size will be UINTN so assert the value 
is safe for now.
+  ASSERT_EFI_ERROR (Status);
+
   //
   // Initialize other parameters, and set WorkSpace as FTW_ERASED_BYTE.
   //
-  FtwDevice->WorkSpaceLength = (UINTN)PcdGet32 
(PcdFlashNvStorageFtwWorkingSize);
-  FtwDevice->SpareAreaLength = (UINTN)PcdGet32 (PcdFlashNvStorageFtwSpareSize);
   if ((FtwDevice->WorkSpaceLength == 0) || (FtwDevice->SpareAreaLength == 0)) {
 DEBUG ((DEBUG_ERROR, "Ftw: Workspace or Spare block does not exist!\n"));
 FreePool (FtwDevice);
@@ -1015,16 +1036,6 @@ InitFtwDevice (
   FtwDevice->FtwWorkSpaceLba = (EFI_LBA)(-1);
   FtwDevice->FtwSpareLba = (EFI_LBA)(-1);
 
-  FtwDevice->WorkSpaceAddress = (EFI_PHYSICAL_ADDRESS)PcdGet64 
(PcdFlashNvStorageFtwWorkingBase64);
-  if (FtwDevice->WorkSpaceAddress == 0) {
-FtwDevice->WorkSpaceAddress = (EFI_PHYSICAL_ADDRESS)PcdGet32 
(PcdFlashNvStorageFtwWorkingBase);
-  }
-
-  FtwDevice->SpareAreaAddress = (EFI_PHYSICAL_ADDRESS)PcdGet64 
(PcdFlashNvStorageFtwSpareBase64);
-  if (FtwDevice->SpareAreaAddress == 0) {
-FtwDevice->SpareAreaAddress = (EFI_PHYSICAL_ADDRESS)PcdGet32 
(PcdFlashNvStorageFtwSpareBase);
-  }
-
   *FtwData = FtwDevice;
   return EFI_SUCCESS;
 }
@@ -1277,7 +1288,7 @@ InitFtwProtocol (
   FtwDevice->FtwLastWriteHeader = NULL;
   FtwDevice->FtwLastWriteRecord = NULL;
 
-  InitializeLocalWorkSpaceHeader ();
+  InitializeLocalWorkSpaceHeader (FtwDevice->WorkSpaceLength);
 
   //
   // Refresh the working space data from working block
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
index 61e7a92ccea1..fd563643eb63 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
@@ -16,10 +16,13 @@ EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER  
mWorkingBlockHeader = { ZERO_GUID, 0, 0
 
   Since Signature and WriteQueueSize have been known, Crc can be calculated 
out,
   then the work space header will be fixed.
+
+  @param[in]  WorkSpaceLength Length in bytes of the FTW workspace area.
+
 **/
 VOID
 InitializeLocalWorkSpaceHeader (
-  VOID
+  IN  UINTN  WorkSpaceLength
   )
 {
   //
@@ -46,7 +49,7 @@ InitializeLocalWorkSpaceHeader (
 ,
 sizeof (EFI_GUID)

[edk2-devel] [PATCH v2 3/8] MdeModulePkg/Variable: Consume Variable Flash Info

2022-04-08 Thread Michael Kubacki
From: Michael Kubacki 

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

Updates VariableRuntimeDxe, VariableSmm, and VariableStandaloneMm
to acquire variable flash information from the Variable Flash
Information library.

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Liming Gao 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Universal/Variable/Pei/Variable.c  | 14 
+-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c| 16 

 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c| 14 
++
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c| 17 
+
 MdeModulePkg/Universal/Variable/Pei/Variable.h  |  2 ++
 MdeModulePkg/Universal/Variable/Pei/VariablePei.inf |  5 ++---
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h   |  7 
++-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf   |  5 ++---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf  |  5 ++---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf |  5 ++---
 10 files changed, 56 insertions(+), 34 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/Pei/Variable.c 
b/MdeModulePkg/Universal/Variable/Pei/Variable.c
index b36dd0de67b2..26a4c73b45a5 100644
--- a/MdeModulePkg/Universal/Variable/Pei/Variable.c
+++ b/MdeModulePkg/Universal/Variable/Pei/Variable.c
@@ -567,11 +567,13 @@ GetVariableStore (
   OUT VARIABLE_STORE_INFO  *StoreInfo
   )
 {
+  EFI_STATUSStatus;
   EFI_HOB_GUID_TYPE *GuidHob;
   EFI_FIRMWARE_VOLUME_HEADER*FvHeader;
   VARIABLE_STORE_HEADER *VariableStoreHeader;
   EFI_PHYSICAL_ADDRESS  NvStorageBase;
   UINT32NvStorageSize;
+  UINT64NvStorageSize64;
   FAULT_TOLERANT_WRITE_LAST_WRITE_DATA  *FtwLastWriteData;
   UINT32BackUpOffset;
 
@@ -591,11 +593,13 @@ GetVariableStore (
 // Emulated non-volatile variable mode is not enabled.
 //
 
-NvStorageSize = PcdGet32 (PcdFlashNvStorageVariableSize);
-NvStorageBase = (EFI_PHYSICAL_ADDRESS)(PcdGet64 
(PcdFlashNvStorageVariableBase64) != 0 ?
-   PcdGet64 
(PcdFlashNvStorageVariableBase64) :
-   PcdGet32 
(PcdFlashNvStorageVariableBase)
-   );
+Status = GetVariableFlashNvStorageInfo (, 
);
+ASSERT_EFI_ERROR (Status);
+
+Status = SafeUint64ToUint32 (NvStorageSize64, );
+// This driver currently assumes the size will be UINT32 so assert the 
value is safe for now.
+ASSERT_EFI_ERROR (Status);
+
 ASSERT (NvStorageBase != 0);
 
 //
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
index 03fec3048dc4..d5c409c914d1 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
@@ -423,6 +423,8 @@ FtwNotificationEvent (
   EFI_PHYSICAL_ADDRESSVariableStoreBase;
   UINT64  VariableStoreLength;
   UINTN   FtwMaxBlockSize;
+  UINT32  NvStorageVariableSize;
+  UINT64  NvStorageVariableSize64;
 
   //
   // Ensure FTW protocol is installed.
@@ -432,14 +434,20 @@ FtwNotificationEvent (
 return;
   }
 
+  Status = GetVariableFlashNvStorageInfo (, 
);
+  ASSERT_EFI_ERROR (Status);
+
+  Status = SafeUint64ToUint32 (NvStorageVariableSize64, 
);
+  // This driver currently assumes the size will be UINT32 so assert the value 
is safe for now.
+  ASSERT_EFI_ERROR (Status);
+
+  VariableStoreBase = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;
+
   Status = FtwProtocol->GetMaxBlockSize (FtwProtocol, );
   if (!EFI_ERROR (Status)) {
-ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);
+ASSERT (NvStorageVariableSize <= FtwMaxBlockSize);
   }
 
-  NvStorageVariableBase = NV_STORAGE_VARIABLE_BASE;
-  VariableStoreBase = NvStorageVariableBase + 
mNvFvHeaderCache->HeaderLength;
-
   //
   // Let NonVolatileVariableBase point to flash variable store base directly 
after FTW ready.
   //
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c
index 5e9d40b67ac2..9e2d8fe0fe0c 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c
@@ -142,6 +142,7 @@ InitRealNonVolatileVariableStore (
   EFI_PHYSICAL_ADDRESS  NvStorageBase;
   UINT8 *NvStorageData;
 

[edk2-devel] [PATCH v2 2/8] MdeModulePkg/VariableFlashInfoLib: Add initial library

2022-04-08 Thread Michael Kubacki
From: Michael Kubacki 

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

Adds a new library class VariableFlashInfoLib that abstracts access
to variable flash information. The instance provided first attempts
to retrieve information from the Variable Flash Info HOB. If that
HOB is not present, it falls back to the PCDs defined in
MdeModulePkg.

This fall back behavior provides backward compatibility for platforms
that only provide PCDs but also allows platforms that need to
dynamically provide the information using the Variable Flash Info HOB
to do so at runtime.

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Liming Gao 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.c   | 
178 
 MdeModulePkg/Include/Library/VariableFlashInfoLib.h|  
68 
 MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf |  
48 ++
 MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.uni |  
12 ++
 MdeModulePkg/MdeModulePkg.dec  |   
4 +
 MdeModulePkg/MdeModulePkg.dsc  |   
2 +
 6 files changed, 312 insertions(+)

diff --git 
a/MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.c 
b/MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.c
new file mode 100644
index ..8e3c6e75c957
--- /dev/null
+++ b/MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.c
@@ -0,0 +1,178 @@
+/** @file
+  Variable Flash Information Library
+
+  Copyright (c) Microsoft Corporation
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/**
+  Get the HOB that contains variable flash information.
+
+  @param[out] VariableFlashInfo   Pointer to a pointer to set to the variable 
flash information structure.
+
+  @retval EFI_SUCCESS Variable flash information was found 
successfully.
+  @retval EFI_INVALID_PARAMETER   The VariableFlashInfo pointer given is NULL.
+  @retval EFI_NOT_FOUND   Variable flash information could not be 
found.
+
+**/
+EFI_STATUS
+GetVariableFlashInfoFromHob (
+  OUT VARIABLE_FLASH_INFO  **VariableFlashInfo
+  )
+{
+  EFI_HOB_GUID_TYPE  *GuidHob;
+
+  if (VariableFlashInfo == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  GuidHob = GetFirstGuidHob ();
+  if (GuidHob == NULL) {
+return EFI_NOT_FOUND;
+  }
+
+  *VariableFlashInfo = GET_GUID_HOB_DATA (GuidHob);
+
+  //
+  // Assert if more than one variable flash information HOB is present.
+  //
+  DEBUG_CODE (
+if ((GetNextGuidHob (, GET_NEXT_HOB (GuidHob)) 
!= NULL)) {
+DEBUG ((DEBUG_ERROR, "ERROR: Found two variable flash information 
HOBs\n"));
+ASSERT (FALSE);
+  }
+
+);
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Get the base address and size for the NV storage area used for UEFI variable 
storage.
+
+  @param[out] BaseAddressThe NV storage base address.
+  @param[out] Length The NV storage length in bytes.
+
+  @retval EFI_SUCCESS NV storage information was found 
successfully.
+  @retval EFI_INVALID_PARAMETER   A required pointer parameter is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+GetVariableFlashNvStorageInfo (
+  OUT EFI_PHYSICAL_ADDRESS  *BaseAddress,
+  OUT UINT64*Length
+  )
+{
+  EFI_STATUS   Status;
+  VARIABLE_FLASH_INFO  *VariableFlashInfo;
+
+  if ((BaseAddress == NULL) || (Length == NULL)) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  Status = GetVariableFlashInfoFromHob ();
+  if (!EFI_ERROR (Status)) {
+*BaseAddress = VariableFlashInfo->NvStorageBaseAddress;
+*Length  = VariableFlashInfo->NvStorageLength;
+  } else {
+*BaseAddress = (EFI_PHYSICAL_ADDRESS)(PcdGet64 
(PcdFlashNvStorageVariableBase64) != 0 ?
+  PcdGet64 
(PcdFlashNvStorageVariableBase64) :
+  PcdGet32 
(PcdFlashNvStorageVariableBase)
+  );
+*Length = (UINT64)PcdGet32 (PcdFlashNvStorageVariableSize);
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Get the base address and size for the fault tolerant write (FTW) spare
+  area used for UEFI variable storage.
+
+  @param[out] BaseAddressThe FTW spare base address.
+  @param[out] Length The FTW spare length in bytes.
+
+  @retval EFI_SUCCESS FTW spare information was found successfully.
+  @retval EFI_INVALID_PARAMETER   A required pointer parameter is NULL.
+  @retval EFI_NOT_FOUND   FTW spare information could not be found.
+
+**/
+EFI_STATUS
+EFIAPI
+GetVariableFlashFtwSpareInfo (
+  OUT EFI_PHYSICAL_ADDRESS  *BaseAddress,
+  OUT UINT64*Length
+  )
+{
+  EFI_STATUS   Status;
+  VARIABLE_FLASH_INFO  *VariableFlashInfo;
+
+  if ((BaseAddress == NULL) || (Length == NULL)) {
+return EFI_INVALID_PARAMETER;
+  }
+
+ 

[edk2-devel] [PATCH v2 1/8] MdeModulePkg: Add Variable Flash Info HOB

2022-04-08 Thread Michael Kubacki
From: Michael Kubacki 

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

Adds a new GUID that is used to identify a HOB that passes variable
flash information to UEFI variable drivers in HOB consumption phases
such as DXE, Traditional MM, and Standalone MM.

This information was previously passed directly with PCDs such
as EfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
and gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize.

However, the Standalone MM variable driver instance does not have
direct access to the PCD database. Therefore, this HOB will first
be considered as the source for variable flash information and
if platforms do not produce the HOB, reading the information from
the PCDs directly will be a backup to provide backward
compatibility.

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Liming Gao 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Include/Guid/VariableFlashInfo.h | 39 
 MdeModulePkg/MdeModulePkg.dec |  4 ++
 2 files changed, 43 insertions(+)

diff --git a/MdeModulePkg/Include/Guid/VariableFlashInfo.h 
b/MdeModulePkg/Include/Guid/VariableFlashInfo.h
new file mode 100644
index ..e526e362aab9
--- /dev/null
+++ b/MdeModulePkg/Include/Guid/VariableFlashInfo.h
@@ -0,0 +1,39 @@
+/** @file
+  This file defines the GUID and data structure used to pass information about
+  a variable store mapped on flash (i.e. a MMIO firmware volume) to the DXE 
and MM environment.
+
+  Copyright (c) Microsoft Corporation.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef VARIABLE_FLASH_INFO_H_
+#define VARIABLE_FLASH_INFO_H_
+
+#define VARIABLE_FLASH_INFO_HOB_GUID \
+  { 0x5d11c653, 0x8154, 0x4ac3, { 0xa8, 0xc2, 0xfb, 0xa2, 0x89, 0x20, 0xfc, 
0x90 }}
+
+#define VARIABLE_FLASH_INFO_HOB_VERSION  1
+
+extern EFI_GUID  gVariableFlashInfoHobGuid;
+
+#pragma pack (push, 1)
+
+///
+/// This structure can be used to describe UEFI variable
+/// flash information.
+///
+typedef struct {
+  UINT32  Version;
+  EFI_PHYSICAL_ADDRESSNvStorageBaseAddress;
+  UINT64  NvStorageLength;
+  EFI_PHYSICAL_ADDRESSFtwSpareBaseAddress;
+  UINT64  FtwSpareLength;
+  EFI_PHYSICAL_ADDRESSFtwWorkingBaseAddress;
+  UINT64  FtwWorkingLength;
+} VARIABLE_FLASH_INFO;
+
+#pragma pack (pop)
+
+#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index cf79292ec877..4e82f5836096 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -226,6 +226,10 @@ [Guids]
   #  Include/Guid/SmmVariableCommon.h
   gSmmVariableWriteGuid  = { 0x93ba1826, 0xdffb, 0x45dd, { 0x82, 0xa7, 0xe7, 
0xdc, 0xaa, 0x3b, 0xbd, 0xf3 }}
 
+  ## Guid of the variable flash information HOB.
+  #  Include/Guid/VariableFlashInfo.h
+  gVariableFlashInfoHobGuid = { 0x5d11c653, 0x8154, 0x4ac3, { 0xa8, 0xc2, 
0xfb, 0xa2, 0x89, 0x20, 0xfc, 0x90 }}
+
   ## Performance protocol guid that also acts as the performance HOB guid and 
performance variable GUID
   #  Include/Guid/Performance.h
   gPerformanceProtocolGuid   = { 0x76B6BDFA, 0x2ACD, 0x4462, { 0x9E, 0x3F, 
0xCB, 0x58, 0xC9, 0x69, 0xD9, 0x37 } }
-- 
2.28.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88650): https://edk2.groups.io/g/devel/message/88650
Mute This Topic: https://groups.io/mt/90345653/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/8] Add Variable Flash Info HOB

2022-04-08 Thread Michael Kubacki
From: Michael Kubacki 

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

The UEFI variable drivers such as VariableRuntimeDxe, VariableSmm,
VariableStandaloneMm, etc. (and their dependent protocol/library
stack), typically acquire UEFI variable store flash information
with PCDs declared in MdeModulePkg.

For example:
[Pcd]
  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64
  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize

These PCDs work as-is in the StandaloneMm driver if they are not
dynamic such as Dynamic or DynamicEx because PCD services are not
readily available in the Standalone MM environment. Platforms that
use Standalone MM today, must define these PCDs as FixedAtBuild in
their platform build. However, the PCDs do allow platforms to treat
the PCDs as Dynamic/DynamicEx and being able to support that is
currently a gap for Standalone MM.

This patch series introduces a HOB that can be produced by the
platform to provide the same information. The HOB list is
available to Standalone MM.

The PCD declarations are left as-is in MdeModulePkg for backward
compatibility. This means unless a platform wants to use the HOB,
their code will continue to work with no change (they do not need
to produce the HOB). Only if the HOB is found, is its value used
instead of the PCDs.

Due to the large number of consumers of this information, access
to the base address and size values is abstracted in a new library
class (as requested in the v1 series) called VariableFlashInfoLib.

The API of VariableFlashInfoLib does not bind the underlying data
structure to the information returned to library users to allow
flexibility in the library implementation in the future.

V2 changes:
1. Abstracted flash info data access with VariableFlashInfoLib.
2. Updated package builds in the repo that build the variable and
   FTW drivers to include VariableFlashInfoLib.
3. Removed a redundant variable assignment in VariableSmm.c.
4. Updated comments in FtwMisc.c and FaultTolerantWritePei.c to
   indicate driver assumption is UINTN (not UINT32)
5. Added a version field to the VARIABLE_FLASH_INFO structure.

Cc: Abner Chang 
Cc: Andrew Fish 
Cc: Anthony Perard 
Cc: Ard Biesheuvel 
Cc: Benjamin You 
Cc: Brijesh Singh 
Cc: Erdem Aktas 
Cc: Gerd Hoffmann 
Cc: Guo Dong 
Cc: Hao A Wu 
Cc: James Bottomley 
Cc: Jian J Wang 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Julien Grall 
Cc: Leif Lindholm 
Cc: Liming Gao 
Cc: Maurice Ma 
Cc: Min Xu 
Cc: Nickle Wang 
Cc: Peter Grehan 
Cc: Ray Ni 
Cc: Rebecca Cran 
Cc: Sami Mujawar 
Cc: Sean Rhodes 
Cc: Sebastien Boeuf 
Cc: Tom Lendacky 
Signed-off-by: Michael Kubacki 

Michael Kubacki (8):
  MdeModulePkg: Add Variable Flash Info HOB
  MdeModulePkg/VariableFlashInfoLib: Add initial library
  MdeModulePkg/Variable: Consume Variable Flash Info
  MdeModulePkg/FaultTolerantWrite: Consume Variable Flash Info
  ArmVirtPkg/ArmVirt.dsc.inc: Add VariableFlashInfoLib
  EmulatorPkg: Add VariableFlashInfoLib
  OvmfPkg: Add VariableFlashInfoLib
  UefiPayloadPkg: Add VariableFlashInfoLib

 MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.c   
 | 178 
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c 
 |  41 +++--
 MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c  
 |   7 +-
 MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.c   
 |  28 +--
 MdeModulePkg/Universal/Variable/Pei/Variable.c 
 |  14 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c   
 |  16 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c   
 |  14 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c   
 |  17 +-
 ArmVirtPkg/ArmVirt.dsc.inc 
 |   1 +
 EmulatorPkg/EmulatorPkg.dsc
 |   1 +
 MdeModulePkg/Include/Guid/VariableFlashInfo.h  
 |  39 +
 MdeModulePkg/Include/Library/VariableFlashInfoLib.h
 |  68 
 MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf 
 |  48 ++
 MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.uni 
 |  12 ++
 MdeModulePkg/MdeModulePkg.dec  
 |   8 +
 MdeModulePkg/MdeModulePkg.dsc  
 |   2 +
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h  
 |   7 +-
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf 
 |  10 +-
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf 
 |  10 +-
 
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf 
|  10 +-
 

Re: [edk2-devel] [PATCH v2] OvmfPkg/BhyveBhfPkg: add support for QemuFwCfg

2022-04-08 Thread Pedro Falcato
Is this a laptop? Things may not work there because video output is done
through the Intel GPU, even when using the Nvidia GPU, although I'm not
sure.

On Fri, Apr 8, 2022 at 6:49 PM Mario Marietto 
wrote:

> im trying to test the patch on my pc,that has two graphic cards,the intel
> coffee lake and the nvidia. i tried to start the pc from the nvidia card
> and ive configured the xorg.conf file giving the proper bus id value. in
> addition ive loaded the kernel.ko file from the boot loader.conf i have
> removed the intel and the drm drivers used by the Intel graphic card.
> unfortunately my pc wont boot from the nvidia card. my mouse and keyboard
> freezes just before the desktop manager (xfce and kde5) starts.
>
> Il gio 7 apr 2022, 18:46 Rebecca Cran  ha scritto:
>
>> I've just looked at the patch and it looks good, though I haven't tested
>> it.
>>
>> So yes, please add:
>>
>>
>> Acked-by: Rebecca Cran 
>>
>>
>> On 4/6/22 23:24, Corvin Köhne wrote:
>> > Hi Peter and Rebecca,
>> >
>> > thanks for your feedback. This patch is backward compatible. It checks
>> > if QemuFwCfg is available and if QemuFwCfg is missing it falls
>> > back to BhyveFwCtl.
>> >
>> > So, should I add Reviewed-by (or Acked-by?) Peter and Rebecca to the
>> > commit message?
>> >
>> >
>> > Thanks
>> > Corvin
>> >
>> > Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans
>> Beckhoff
>> > Registered office: Verl, Germany | Register court: Guetersloh HRA 7075
>> >
>> >
>> >
>>
>> 
>
>

-- 
Pedro Falcato


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




Re: [edk2-devel] GSoC 2022: Add S3 resume support to MinPlatform

2022-04-08 Thread Benjamin Doron
Hi Nate,
Thanks! I've looked at the basics of I2C, but I've seen from the iGFX PRM that 
GMBUS implements some registers and error handling the NAKs differently, but I 
guess that I'll be dealing with that later.

Yeah, I was thinking that if we wanted debug up as soon as possible, then the 
iGFX BAR and P2SB GPIOs would have to be programmed, so that sounds about 
right. Synchronising with the FSP's config is probably important too, but I 
suppose you implemented that/we'll see?

For now, I have a proposal at 
https://docs.google.com/document/d/1CyyerMfPwvZxkBjfE_-H1OlkZPxH98uqpmb9tBAV_ps.

Best regards,
Benjamin


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




Re: [edk2-devel] [edk2-libc Patch 1/1] AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI environment

2022-04-08 Thread Michael D Kinney
Thanks JP.

That makes sense.  Bypass all the OS specific services in UEFI environment and 
generate UUID using time and random number.

Reviewed-by: Michael D Kinney 

Mike


> -Original Message-
> From: Jayaprakash, N 
> Sent: Friday, April 8, 2022 10:19 AM
> To: devel@edk2.groups.io; Jayaprakash, N ; Kinney, 
> Michael D 
> Cc: Frinzell, Aaron 
> Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] 
> AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI
> environment
> 
> + Aaron
> 
> Regards,
> JP
> 
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Jayaprakash, N
> Sent: 08 April 2022 22:12
> To: Kinney, Michael D ; devel@edk2.groups.io
> Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] 
> AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI
> environment
> 
> The UUID generation is done through the random number generation & time unix 
> time stamp features available through the built-in
> python modules 'random' and 'time' respectively.
> The random number & time (unix time stamp or epoch) based method of 
> generating the UUID is already there in uuid.py module,
> with this patch request enabled this path to take effect for UEFI invocation 
> of this module.
> 
> There are some OS specific ways to generate the UUID's such as by using the 
> libuuid on Linux kind of OS, windll.rpcrt4 library
> on windows.
> These will not work for UEFI and hence added appropriate platform check to 
> ensure that this path is not taken for UEFI
> invocation.
> 
> Besides this there are MAC address based algorithms available in uuid.py 
> module.
> These algorism are based on reading MAC address through various OS supported 
> methods such as ipconfig command processing,
> NetBIOS calls on Windows, using netstat command in Linux, lanscan in Unix, 
> from arp - address resolution protocol in Linux,
> NetBSD and other flavours of Linux.
> These are currently not enabled for UEFI invocation of the uuid module. This 
> has been done through platform check added at
> appropriate place in the uuid.py module code.
> 
> Regards,
> JP
> -Original Message-
> From: Kinney, Michael D 
> Sent: 08 April 2022 21:14
> To: devel@edk2.groups.io; Jayaprakash, N ; Kinney, 
> Michael D 
> Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] 
> AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI
> environment
> 
> How is a UUID generated in UEFI env?  Is there a dependency on MAC address or 
> random number generator?
> 
> Can you add a description of the technique to the BZ and the commit message?
> 
> Thanks,
> 
> Mike
> 
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of
> > Jayaprakash, N
> > Sent: Friday, April 8, 2022 4:52 AM
> > To: devel@edk2.groups.io
> > Subject: [edk2-devel] [edk2-libc Patch 1/1]
> > AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for
> > UEFI environment
> >
> >  REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3899
> >
> >  This is commit contains the UEFI port of uuid.py module. Made
> > necessary  changes required to uuid.py module to support UEFI environment.
> >  Porting of this module to UEFI is required for open source tools such
> > as Chipsec to function properly.
> >
> >  Cc: Rebecca Cran 
> >  Cc: Michael D Kinney 
> >  Signed-off-by: Jayaprakash N 
> > ---
> >  .../Python/Python-3.6.8/Lib/uuid.py   | 94 ++-
> >  1 file changed, 50 insertions(+), 44 deletions(-)
> >
> > diff --git a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> > b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> > index db8b2ef..84ed0b8 100644
> > --- a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> > +++ b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> > @@ -471,57 +471,61 @@ def _netbios_getnode():
> >  continue
> >  return int.from_bytes(bytes, 'big')
> >
> > +
> >  # Thanks to Thomas Heller for ctypes and for his help with its use here.
> >
> >  # If ctypes is available, use it to find system routines for UUID 
> > generation.
> >  # XXX This makes the module non-thread-safe!
> >  _uuid_generate_time = _UuidCreate = None
> > -try:
> > -import ctypes, ctypes.util
> > -import sys
> > -
> > -# The uuid_generate_* routines are provided by libuuid on at least
> > -# Linux and FreeBSD, and provided by libc on Mac OS X.
> > -_libnames = ['uuid']
> > -if not sys.platform.startswith('win'):
> > -_libnames.append('c')
> > -for libname in _libnames:
> > -try:
> > -lib = ctypes.CDLL(ctypes.util.find_library(libname))
> > -except Exception:
> > -continue
> > -if hasattr(lib, 'uuid_generate_time'):
> > -_uuid_generate_time = lib.uuid_generate_time
> > -break
> > -del _libnames
> > -
> > -# The uuid_generate_* functions are broken on MacOS X 10.5, as noted
> > -# in issue #8621 the function generates the same sequence of 

[edk2-devel] [edk2-non-osi] [PATCH V2] ElkhartlakeSiliconBinPkg: Update EHL microcode

2022-04-08 Thread kokweich
Updated "production" microcode version m0190661_0016

Signed-off-by: kokweich 
Cc: Nate DeSimone 
Cc: Sai Chaganty 
Cc: jinjhuli 
---
 .../Microcode/IntelMicrocodeLicense.txt |   8 
 .../Microcode/MicrocodeUpdates.inf  |   4 ++--
 .../Microcode/m0190661_0015.mcb | Bin 20480 -> 0 bytes
 .../Microcode/m0190661_0016.mcb | Bin 0 -> 20480 bytes
 4 files changed, 6 insertions(+), 6 deletions(-)
 delete mode 100644 
Silicon/Intel/ElkhartlakeSiliconBinPkg/Microcode/m0190661_0015.mcb
 create mode 100644 
Silicon/Intel/ElkhartlakeSiliconBinPkg/Microcode/m0190661_0016.mcb

diff --git 
a/Silicon/Intel/ElkhartlakeSiliconBinPkg/Microcode/IntelMicrocodeLicense.txt 
b/Silicon/Intel/ElkhartlakeSiliconBinPkg/Microcode/IntelMicrocodeLicense.txt
index 78536ba..cd2b6bc 100644
--- a/Silicon/Intel/ElkhartlakeSiliconBinPkg/Microcode/IntelMicrocodeLicense.txt
+++ b/Silicon/Intel/ElkhartlakeSiliconBinPkg/Microcode/IntelMicrocodeLicense.txt
@@ -1,7 +1,7 @@
-Copyright (c) 2018 - 2021 Intel Corporation.
-All rights reserved.
-
-Redistribution.
+Copyright (c) 2018 - 2022 Intel Corporation.
+All rights reserved.
+
+Redistribution.
 
 Redistribution and use in binary form, without modification, are permitted,
 provided that the following conditions are met:
diff --git 
a/Silicon/Intel/ElkhartlakeSiliconBinPkg/Microcode/MicrocodeUpdates.inf 
b/Silicon/Intel/ElkhartlakeSiliconBinPkg/Microcode/MicrocodeUpdates.inf
index f99f0a5..2c03f79 100644
--- a/Silicon/Intel/ElkhartlakeSiliconBinPkg/Microcode/MicrocodeUpdates.inf
+++ b/Silicon/Intel/ElkhartlakeSiliconBinPkg/Microcode/MicrocodeUpdates.inf
@@ -1,7 +1,7 @@
 ### @file
 #  Component information file for AcpiPlatform module
 #
-# Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -15,4 +15,4 @@
   MODULE_TYPE= USER_DEFINED
 
 [Sources]
-  m0190661_0015.mcb
+  m0190661_0016.mcb
diff --git 
a/Silicon/Intel/ElkhartlakeSiliconBinPkg/Microcode/m0190661_0015.mcb 
b/Silicon/Intel/ElkhartlakeSiliconBinPkg/Microcode/m0190661_0015.mcb
deleted file mode 100644
index 
06548466d37a06c1342c79f66f149d648dccf40e..
GIT binary patch
literal 0
HcmV?d1

literal 20480
zcmaI7V~{R96D>NnZQJ%Uwr$(CZJT>+?6Ez2Y}>Z2^M3c|tvY8_t)#k=r
z2nY!MKN1rWLmNRr197G`qX7SB|BrJD{|$=&@|7>6&(Era5^nYupKtO2F#6K#23n^p~}zQ!~T^a`o2B(Af0nn^(J=
zvt`*9B@2+axz&>=PEhig96OHEyi7*_vy=!4kMz3ZmVaw$VkSJkI*pWaBY)p;*{A
zMXkeDf%Nz9BQuzQm*9yh!rffS5jGl$gNJuowxvI9s
z9v-REkDbEqz=EyR21R*C?8e=6
zs{YwbhpQ8Oh#*E@u&{8)f>u3P`n*L^f#~_I4y^rxGjJbK=I-p|9Ilr$CA)W
zT%TDf5)V>rWd+$i$eq)ghKRA1YN5
zsyNkR$r4L*7#Ao>IKj+uInQy+j*Ss<*Lmm0YTPHOB_xMC?VSr}Cp|h@A?4;?tMX
z)h~=_CXKBN|uD;11Jln+%Y=o)plpr^^ATQDA20*NO`toQRc|LrFrPqc-*kQ
z6TG8tp%Ca*%Z5I7b0^#hSTh}Z=gB8eY=3(NP{uJmF@|hpj9b$LG%p-%>+6ci+8q_p
zfS8Q)_KO8H4>fQ5lEBkPk8eJSW5$8Xm-t*;8wnR{IW!K;ek~JFZt}9<*PuOZYYT(c
z!bZ?}*5%oA>qY#}NEdc2%++`pn*e>gq^3DP(>XL~4!F2UygJY!C}mB!U^V|N;zrIl
ze$TZg`=?7Dq-!D@QAt72PFlHbrM~9FniMJmHnoMHx33p5%NRpC?k@Zt=F!@kSx7Q%Gv+7HjD^KT^DV#(}O0B7)vFo$qAbdC%0jj=mbYQ<{P
z-7#eSAx=IUSQ-O*$Jlc;)(dxQ&@WT4qMbyV4fk^;IP^J!4zsL4krKm
zXhMQv%{xirM<-A@S-mFnKa2+ql;1i@TR5$PWDN9Bm73uy!mD4|KRNwhry4NU@g+Jf
z3P2~RlRh|zFoAIwoe=5jMnpl@r!oDl9*)+tJjgWj0xAhw%NY=;RI9
z)MvM{w`Dz8D7TjRNK-AI5`i=0ePkMoQ%tPXqRQ=9_7O{9+Rj=pBC<@BZ>Ja%GeL8_
z8~^ZD{3A3$#E&)vvkaZ=exZmxj$*t}1z>D@GNCMB2Kt7bwcDYhuHrTHH`xhw0(7vt!s2(@S9f_-nw6Nj!`RY51eGUYxR0ipaetVy~e
zO#Ur><4*?IvO@Sh59MSMjd!y7iBD$A^lqjFiFe*qdBQ$5?XnvbnjHR62=(0v5-Ho!
zhvHIu)Sb6zB#Njpr1+;QKd}v*;
zcSL;<#SldR^QN=?wDuM1m1*V%H7~4R4N`m@4}SzScRum>ut|W@C=3{nxPFf
z=rgj#eRO%v)T|1XYEx6^cu`+$-pYS+bm}Jz`}|hvQOc12tByQkUR?!54a?OqA(N
zll@s7qg%2VcCj?ZxS>OB7oqL&)t>-X5$RO*D4i|020pj1g*)SW>}7hHLc(^8(lAyK
zYX7yFiyNO?y39l9#CDqUdMR%V5(YfgvwZO*T3DFIFzD6aUwlZz9+(g1l*8O!ojmkqe>G6e_&)DHyDne+AUF^lsgRhY$B?FbUywLJF^*z@*h2Sic~
zB;-Hr-)Ex7S%@=J6b*!!DB2CyDC2J*4ESl58Ru>mJ{~9Z+-F(Ed>Cm0WJXG!E2sSS
zenXOY4~OwM#pYFdw%!7A`^P}8*YJg|Ee77-@x;~*2euV__uHiIbHAx6ej@YZd_fgs
zrA`aBgJ;`S2P?sPFrmkP;?!YOhhfz`(L?gO`lRT`r#|aPN=M$KRT+HpxpPn^F>wwFgENLOhIa7Ly?c
zN*?S8uj=z$`e$jl^xIl<#R^Y(`iN^wAhfSH&@#%AqVK)pmg*Kcc=dfE93zwQ
zJi4^Wq^j~?CvPS7-PGUttIE^@~p4iv|{gmB*S?8mqBVCw}a99T+?
z!R6lwV)i)C=Xu7E#Rm}{BvOab@znn)BRs)JY6rwo*|qG-*8B`!(d@xtm2+1??I}sm
zeS`^J^3#bU>LybyV0CTJXgy+juaZzC**=%laTzCeQ!zh3f-4
z8FbJhdlV}Ui6tGXM5hBMnNhEZpgnwtCrMTc4uNe%t4)USa>I|~J|)MT7AN=iu3
z?D_G~k+^OSWVAM=YZ~hDGr6=nNwh1aMD^8u+xlns7qxaYG(mY1m;^f~S`no7VM(#!
z^ZazfSAw8eO$hiAn1vE|*6JO&`VOkr>3krIoZtxEn(@5(9IGhe4i)wlVNa3=^b
zFww7J>N|6VZsDM}rG$@^?15aX3)xZ55UPL?TcnHp2CAOfq&+(hgh-
zWU5*zW5w%{xwF%JF*?g}SKyQ!_AbfLkZ{QL!8u^QRl2~L@7J7no@-TTynL9K
zsMU{wI3nYskTP;GJmIN#qxv-n9>~~gPv;a~i2kj0cqnUX
zrQ{QV!{WPwUyPe~7vF?nbfwNd?uNPDx7MgG!(Eb^3GNlpelkDlq|RN=*NdonQl=7N
z!}i9WLCJ0;l)oMgqlyS7OfCK*!cxGeXxT~l)yC=47Waf5Y%pGAT=#y-oB`$;p>Ht?3J@`gKN#G
z8y(F9xm+je{7$USHlfqSzGms$K36l~2$MF1g+c{ar&_B7)CQLdCH}!9USuXSu

[edk2-devel] [PATCH] MdeModulePkg/dec: update the PcdCpuStackGuard property

2022-04-08 Thread Chen, Gang C
Update the PcdCpuStackGuard from PcdsFixedAtBuild to PcdsDynamicEx.

Meanwhile, remove the duplicate check for PcdCpuStackGuard for
some limitation, which has been checked at the entry of
InitializeMpExceptionStackSwitchHandlers.

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

Cc: Jian J Wang 
Cc: Liming Gao 
Cc: devel@edk2.groups.io
Cc: Eric Dong 
Cc: Ray Ni 

Signed-off-by: Gang Chen 
---
 MdeModulePkg/MdeModulePkg.dec  | 14 +++---
 .../CpuExceptionHandlerLib/PeiCpuException.c   |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 463e889e9a..72e7e2eced 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1070,13 +1070,6 @@
   # @Prompt The Heap Guard feature mask
   gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask|0x0|UINT8|0x30001054
 
-  ## Indicates if UEFI Stack Guard will be enabled.
-  #  If enabled, stack overflow in UEFI can be caught, preventing chaotic 
consequences.
-  #   TRUE  - UEFI Stack Guard will be enabled.
-  #   FALSE - UEFI Stack Guard will be disabled.
-  # @Prompt Enable UEFI Stack Guard.
-  gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055
-
 [PcdsFixedAtBuild, PcdsPatchableInModule]
   ## Dynamic type PCD can be registered callback function for Pcd setting 
action.
   #  PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of 
callback function
@@ -2079,6 +2072,13 @@
   # @Prompt Enable PCIe Resizable BAR Capability support.
   
gEfiMdeModulePkgTokenSpaceGuid.PcdPcieResizableBarSupport|FALSE|BOOLEAN|0x1024
 
+  ## Indicates if UEFI Stack Guard will be enabled.
+  #  If enabled, stack overflow in UEFI can be caught, preventing chaotic 
consequences.
+  #   TRUE  - UEFI Stack Guard will be enabled.
+  #   FALSE - UEFI Stack Guard will be disabled.
+  # @Prompt Enable UEFI Stack Guard.
+  gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x00010025
+
 [PcdsPatchableInModule]
   ## Specify memory size with page number for PEI code when
   #  Loading Module at Fixed Address feature is enabled.
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
index 687fc4177f..bcd4175ffa 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
@@ -254,7 +254,7 @@ InitializeCpuExceptionHandlersEx (
 //
 // Initializing stack switch is only necessary for Stack Guard 
functionality.
 //
-if (PcdGetBool (PcdCpuStackGuard) && (InitData != NULL)) {
+if (InitData != NULL) {
   Status = ArchSetupExceptionStack (InitData);
 }
   }
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88644): https://edk2.groups.io/g/devel/message/88644
Mute This Topic: https://groups.io/mt/90341216/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] OvmfPkg/BhyveBhfPkg: add support for QemuFwCfg

2022-04-08 Thread Mario Marietto
im trying to test the patch on my pc,that has two graphic cards,the intel
coffee lake and the nvidia. i tried to start the pc from the nvidia card
and ive configured the xorg.conf file giving the proper bus id value. in
addition ive loaded the kernel.ko file from the boot loader.conf i have
removed the intel and the drm drivers used by the Intel graphic card.
unfortunately my pc wont boot from the nvidia card. my mouse and keyboard
freezes just before the desktop manager (xfce and kde5) starts.

Il gio 7 apr 2022, 18:46 Rebecca Cran  ha scritto:

> I've just looked at the patch and it looks good, though I haven't tested
> it.
>
> So yes, please add:
>
>
> Acked-by: Rebecca Cran 
>
>
> On 4/6/22 23:24, Corvin Köhne wrote:
> > Hi Peter and Rebecca,
> >
> > thanks for your feedback. This patch is backward compatible. It checks
> > if QemuFwCfg is available and if QemuFwCfg is missing it falls
> > back to BhyveFwCtl.
> >
> > So, should I add Reviewed-by (or Acked-by?) Peter and Rebecca to the
> > commit message?
> >
> >
> > Thanks
> > Corvin
> >
> > Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans
> Beckhoff
> > Registered office: Verl, Germany | Register court: Guetersloh HRA 7075
> >
> >
> >
>
>


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




Re: [edk2-devel] [edk2-libc Patch 1/1] AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI environment

2022-04-08 Thread Jayaprakash, N
+ Aaron

Regards,
JP

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Jayaprakash, N
Sent: 08 April 2022 22:12
To: Kinney, Michael D ; devel@edk2.groups.io
Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] 
AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI 
environment

The UUID generation is done through the random number generation & time unix 
time stamp features available through the built-in python modules 'random' and 
'time' respectively.
The random number & time (unix time stamp or epoch) based method of generating 
the UUID is already there in uuid.py module, with this patch request enabled 
this path to take effect for UEFI invocation of this module.

There are some OS specific ways to generate the UUID's such as by using the 
libuuid on Linux kind of OS, windll.rpcrt4 library on windows. 
These will not work for UEFI and hence added appropriate platform check to 
ensure that this path is not taken for UEFI invocation. 

Besides this there are MAC address based algorithms available in uuid.py 
module. 
These algorism are based on reading MAC address through various OS supported 
methods such as ipconfig command processing, NetBIOS calls on Windows, using 
netstat command in Linux, lanscan in Unix, from arp - address resolution 
protocol in Linux, NetBSD and other flavours of Linux.
These are currently not enabled for UEFI invocation of the uuid module. This 
has been done through platform check added at appropriate place in the uuid.py 
module code. 

Regards,
JP
-Original Message-
From: Kinney, Michael D 
Sent: 08 April 2022 21:14
To: devel@edk2.groups.io; Jayaprakash, N ; Kinney, 
Michael D 
Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] 
AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI 
environment

How is a UUID generated in UEFI env?  Is there a dependency on MAC address or 
random number generator?

Can you add a description of the technique to the BZ and the commit message?

Thanks,

Mike

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of 
> Jayaprakash, N
> Sent: Friday, April 8, 2022 4:52 AM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [edk2-libc Patch 1/1]
> AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for 
> UEFI environment
> 
>  REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3899
> 
>  This is commit contains the UEFI port of uuid.py module. Made 
> necessary  changes required to uuid.py module to support UEFI environment.
>  Porting of this module to UEFI is required for open source tools such 
> as Chipsec to function properly.
> 
>  Cc: Rebecca Cran 
>  Cc: Michael D Kinney 
>  Signed-off-by: Jayaprakash N 
> ---
>  .../Python/Python-3.6.8/Lib/uuid.py   | 94 ++-
>  1 file changed, 50 insertions(+), 44 deletions(-)
> 
> diff --git a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> index db8b2ef..84ed0b8 100644
> --- a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> +++ b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> @@ -471,57 +471,61 @@ def _netbios_getnode():
>  continue
>  return int.from_bytes(bytes, 'big')
> 
> +
>  # Thanks to Thomas Heller for ctypes and for his help with its use here.
> 
>  # If ctypes is available, use it to find system routines for UUID generation.
>  # XXX This makes the module non-thread-safe!
>  _uuid_generate_time = _UuidCreate = None
> -try:
> -import ctypes, ctypes.util
> -import sys
> -
> -# The uuid_generate_* routines are provided by libuuid on at least
> -# Linux and FreeBSD, and provided by libc on Mac OS X.
> -_libnames = ['uuid']
> -if not sys.platform.startswith('win'):
> -_libnames.append('c')
> -for libname in _libnames:
> -try:
> -lib = ctypes.CDLL(ctypes.util.find_library(libname))
> -except Exception:
> -continue
> -if hasattr(lib, 'uuid_generate_time'):
> -_uuid_generate_time = lib.uuid_generate_time
> -break
> -del _libnames
> -
> -# The uuid_generate_* functions are broken on MacOS X 10.5, as noted
> -# in issue #8621 the function generates the same sequence of values
> -# in the parent process and all children created using fork (unless
> -# those children use exec as well).
> -#
> -# Assume that the uuid_generate functions are broken from 10.5 onward,
> -# the test can be adjusted when a later version is fixed.
> -if sys.platform == 'darwin':
> -if int(os.uname().release.split('.')[0]) >= 9:
> -_uuid_generate_time = None
> -
> -# On Windows prior to 2000, UuidCreate gives a UUID containing the
> -# hardware address.  On Windows 2000 and later, UuidCreate makes a
> -# random UUID and UuidCreateSequential gives a UUID containing the
> -# hardware address.  These routines are provided by the RPC runtime.
> -# 

Re: [edk2-devel] [edk2-libc Patch 1/1] AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI environment

2022-04-08 Thread Jayaprakash, N
The UUID generation is done through the random number generation & time unix 
time stamp features available through the built-in python modules 'random' and 
'time' respectively.
The random number & time (unix time stamp or epoch) based method of generating 
the UUID is already there in uuid.py module, with this patch request enabled 
this path to take effect for UEFI invocation of this module.

There are some OS specific ways to generate the UUID's such as by using the 
libuuid on Linux kind of OS, windll.rpcrt4 library on windows. 
These will not work for UEFI and hence added appropriate platform check to 
ensure that this path is not taken for UEFI invocation. 

Besides this there are MAC address based algorithms available in uuid.py 
module. 
These algorism are based on reading MAC address through various OS supported 
methods such as ipconfig command processing, NetBIOS calls on Windows, 
using netstat command in Linux, lanscan in Unix, from arp - address resolution 
protocol in Linux, NetBSD and other flavours of Linux.
These are currently not enabled for UEFI invocation of the uuid module. This 
has been done through platform check added at appropriate place in the uuid.py 
module code. 

Regards,
JP
-Original Message-
From: Kinney, Michael D  
Sent: 08 April 2022 21:14
To: devel@edk2.groups.io; Jayaprakash, N ; Kinney, 
Michael D 
Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] 
AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI 
environment

How is a UUID generated in UEFI env?  Is there a dependency on MAC address or 
random number generator?

Can you add a description of the technique to the BZ and the commit message?

Thanks,

Mike

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of 
> Jayaprakash, N
> Sent: Friday, April 8, 2022 4:52 AM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [edk2-libc Patch 1/1] 
> AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for 
> UEFI environment
> 
>  REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3899
> 
>  This is commit contains the UEFI port of uuid.py module. Made 
> necessary  changes required to uuid.py module to support UEFI environment.
>  Porting of this module to UEFI is required for open source tools such  
> as Chipsec to function properly.
> 
>  Cc: Rebecca Cran 
>  Cc: Michael D Kinney 
>  Signed-off-by: Jayaprakash N 
> ---
>  .../Python/Python-3.6.8/Lib/uuid.py   | 94 ++-
>  1 file changed, 50 insertions(+), 44 deletions(-)
> 
> diff --git a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py 
> b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> index db8b2ef..84ed0b8 100644
> --- a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> +++ b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> @@ -471,57 +471,61 @@ def _netbios_getnode():
>  continue
>  return int.from_bytes(bytes, 'big')
> 
> +
>  # Thanks to Thomas Heller for ctypes and for his help with its use here.
> 
>  # If ctypes is available, use it to find system routines for UUID generation.
>  # XXX This makes the module non-thread-safe!
>  _uuid_generate_time = _UuidCreate = None
> -try:
> -import ctypes, ctypes.util
> -import sys
> -
> -# The uuid_generate_* routines are provided by libuuid on at least
> -# Linux and FreeBSD, and provided by libc on Mac OS X.
> -_libnames = ['uuid']
> -if not sys.platform.startswith('win'):
> -_libnames.append('c')
> -for libname in _libnames:
> -try:
> -lib = ctypes.CDLL(ctypes.util.find_library(libname))
> -except Exception:
> -continue
> -if hasattr(lib, 'uuid_generate_time'):
> -_uuid_generate_time = lib.uuid_generate_time
> -break
> -del _libnames
> -
> -# The uuid_generate_* functions are broken on MacOS X 10.5, as noted
> -# in issue #8621 the function generates the same sequence of values
> -# in the parent process and all children created using fork (unless
> -# those children use exec as well).
> -#
> -# Assume that the uuid_generate functions are broken from 10.5 onward,
> -# the test can be adjusted when a later version is fixed.
> -if sys.platform == 'darwin':
> -if int(os.uname().release.split('.')[0]) >= 9:
> -_uuid_generate_time = None
> -
> -# On Windows prior to 2000, UuidCreate gives a UUID containing the
> -# hardware address.  On Windows 2000 and later, UuidCreate makes a
> -# random UUID and UuidCreateSequential gives a UUID containing the
> -# hardware address.  These routines are provided by the RPC runtime.
> -# NOTE:  at least on Tim's WinXP Pro SP2 desktop box, while the last
> -# 6 bytes returned by UuidCreateSequential are fixed, they don't appear
> -# to bear any relationship to the MAC address of any network device
> -# on the box.
> +if os.name != 'edk2':
> +# This code is not meant to run on 

[edk2-devel] [PATCH] ShellPkg: Update smbiosview type 41 with SMBIOS 3.5 fields

2022-04-08 Thread Bo Chang Ke
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3900

update smbiosview type 41 related fileds.

Signed-off-by: Bo Chang Ke 
Cc: Dandan Bi 
Cc: Star Zeng 
---
 .../SmbiosView/QueryTable.c   | 24 +++
 1 file changed, 24 insertions(+)

diff --git 
a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
index c4a6acb167..7ec6d2b5f1 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
@@ -1766,6 +1766,30 @@ TABLE_ITEM  OnboardDeviceTypesTable[] = {
 0x0A,
 L"  Sas Controller"
   },
+  {
+0x0B,
+L"  Wireless LAN"
+  },
+  {
+0x0C,
+L"  Bluetooth"
+  },
+  {
+0x0D,
+L"  WWAN"
+  },
+  {
+0x0E,
+L"  embedded Multi-Media Controller"
+  },
+  {
+0x0F,
+L"  NVMe Controller"
+  },
+  {
+0x10,
+L"  UFS Controller"
+  }
 };
 
 TABLE_ITEM  SELTypesTable[] = {
-- 
2.32.0.windows.1



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




Re: [edk2-devel] [GSoC 2022] Introducing myself & seeking for project ideas

2022-04-08 Thread Théo Jehl
Hello Nate,
Thanks a lot for your answer ! I got myself a copy of "Beyond BIOS" to 
understand how UEFI works.

The project sound very interesting, so if I understand correctly, OVMF only 
implements some of the services needed for QEMU support, porting what's present 
to MinPlatform and then improving it with the required services will result in 
QemuOpenBoardPkg, is that right? So the goal is to allow MinPlatform testing 
inside QEMU instead of getting a specific board supported by MinPlatform?

I'll use the upcoming months to get up to pace with UEFI with the ressources 
you gave me 
Before starting to write my application I have a few questions, especially on 
the prerequisites, on the project page the only one listed is C knowledge, is 
anything else required or recommended ? In case I need to get up to pace with 
something specific :)

And thanks for welcoming me in the project !

Best regards,
Théo


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




Re: [edk2-devel] [edk2-libc Patch 1/1] AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI environment

2022-04-08 Thread Michael D Kinney
How is a UUID generated in UEFI env?  Is there a dependency on MAC address or 
random number generator?

Can you add a description of the technique to the BZ and the commit message?

Thanks,

Mike

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Jayaprakash, N
> Sent: Friday, April 8, 2022 4:52 AM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [edk2-libc Patch 1/1] 
> AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI
> environment
> 
>  REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3899
> 
>  This is commit contains the UEFI port of uuid.py module. Made necessary
>  changes required to uuid.py module to support UEFI environment.
>  Porting of this module to UEFI is required for open source tools such
>  as Chipsec to function properly.
> 
>  Cc: Rebecca Cran 
>  Cc: Michael D Kinney 
>  Signed-off-by: Jayaprakash N 
> ---
>  .../Python/Python-3.6.8/Lib/uuid.py   | 94 ++-
>  1 file changed, 50 insertions(+), 44 deletions(-)
> 
> diff --git a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py 
> b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> index db8b2ef..84ed0b8 100644
> --- a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> +++ b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> @@ -471,57 +471,61 @@ def _netbios_getnode():
>  continue
>  return int.from_bytes(bytes, 'big')
> 
> +
>  # Thanks to Thomas Heller for ctypes and for his help with its use here.
> 
>  # If ctypes is available, use it to find system routines for UUID generation.
>  # XXX This makes the module non-thread-safe!
>  _uuid_generate_time = _UuidCreate = None
> -try:
> -import ctypes, ctypes.util
> -import sys
> -
> -# The uuid_generate_* routines are provided by libuuid on at least
> -# Linux and FreeBSD, and provided by libc on Mac OS X.
> -_libnames = ['uuid']
> -if not sys.platform.startswith('win'):
> -_libnames.append('c')
> -for libname in _libnames:
> -try:
> -lib = ctypes.CDLL(ctypes.util.find_library(libname))
> -except Exception:
> -continue
> -if hasattr(lib, 'uuid_generate_time'):
> -_uuid_generate_time = lib.uuid_generate_time
> -break
> -del _libnames
> -
> -# The uuid_generate_* functions are broken on MacOS X 10.5, as noted
> -# in issue #8621 the function generates the same sequence of values
> -# in the parent process and all children created using fork (unless
> -# those children use exec as well).
> -#
> -# Assume that the uuid_generate functions are broken from 10.5 onward,
> -# the test can be adjusted when a later version is fixed.
> -if sys.platform == 'darwin':
> -if int(os.uname().release.split('.')[0]) >= 9:
> -_uuid_generate_time = None
> -
> -# On Windows prior to 2000, UuidCreate gives a UUID containing the
> -# hardware address.  On Windows 2000 and later, UuidCreate makes a
> -# random UUID and UuidCreateSequential gives a UUID containing the
> -# hardware address.  These routines are provided by the RPC runtime.
> -# NOTE:  at least on Tim's WinXP Pro SP2 desktop box, while the last
> -# 6 bytes returned by UuidCreateSequential are fixed, they don't appear
> -# to bear any relationship to the MAC address of any network device
> -# on the box.
> +if os.name != 'edk2':
> +# This code is not meant to run on UEFI environment
>  try:
> -lib = ctypes.windll.rpcrt4
> +import ctypes, ctypes.util
> +import sys
> +
> +# The uuid_generate_* routines are provided by libuuid on at least
> +# Linux and FreeBSD, and provided by libc on Mac OS X.
> +_libnames = ['uuid']
> +if not sys.platform.startswith('win'):
> +_libnames.append('c')
> +for libname in _libnames:
> +try:
> +lib = ctypes.CDLL(ctypes.util.find_library(libname))
> +except Exception:
> +continue
> +if hasattr(lib, 'uuid_generate_time'):
> +_uuid_generate_time = lib.uuid_generate_time
> +break
> +del _libnames
> +
> +# The uuid_generate_* functions are broken on MacOS X 10.5, as noted
> +# in issue #8621 the function generates the same sequence of values
> +# in the parent process and all children created using fork (unless
> +# those children use exec as well).
> +#
> +# Assume that the uuid_generate functions are broken from 10.5 
> onward,
> +# the test can be adjusted when a later version is fixed.
> +if sys.platform == 'darwin':
> +if int(os.uname().release.split('.')[0]) >= 9:
> +_uuid_generate_time = None
> +
> +# On Windows prior to 2000, UuidCreate gives a UUID containing the
> +# hardware address.  On Windows 2000 and later, UuidCreate 

Re: [edk2-devel] Applying for GSoC 2022: Add Rust Support to EDK II

2022-04-08 Thread Ayush Singh
Hi Nate

Thanks for the response.

For the std implementation, I do have some idea how to go about
implementing it now. The most important thing I realized is that most of
the std isn't actually std. For example, std::collection, Vector, Box, Rc,
etc are all actually part of alloc and not std. The things that really are
part of std include threads, i/o, etc.

I have taken a look at some other people's projects who have tried
implementing libstd for other targets and it seems it is possible to write
an implementation without libc. It's just very difficult since in most OS
besides Linux, the syscall ABI is not stable enough and using libc is just
easier and recommended.

As for my earlier patches, Jiewen told me that edkii-rust branch is no
longer maintained and that they are now using a different uefi rust
implementation for their work.

I did also find that it will be possible to make the std with stable Rust
even though if internals use nightly, so that's cool. Some useful projects
about writing libstd for new platform that I found are below:
- https://github.com/betrusted-io/rust/tree/1.54.0.5
- https://github.com/japaric/steed

Ayush Singh

On Fri, 8 Apr, 2022, 2:33 am Desimone, Nathaniel L, <
nathaniel.l.desim...@intel.com> wrote:

> Hi Ayush,
>
> Great to meet you and welcome to the TianoCore project! Great to hear you
> are interested! Apologize for the tardiness in my response. Implementing
> Rust support sounds like a wonderful project and one that would really help
> advance the state of the art for UEFI firmware development! I am looking
> for someone with Rust experience that can help mentor this project. My
> usage of Rust at time of writing has not advanced very far beyond "Hello
> World." While I can give a great deal of knowledge and background on UEFI
> and EDK II, my ability to recommend how that be applied to a Rust binding
> is limited. However, I do know enough to suspect the vast majority of the
> work will be figuring out how to integrate the vast array of libraries that
> EDK II provides into a coherent and clean Rust binding. The one aspect of
> this project that I think will be interesting is figuring out is what to do
> about std:: in Rust. From what I have seen of the functionality there more
> or less assumes the existence of a libc implementation for the platform,
> which is not necessarily true for DXE and is absolutely not true for PEI. I
> would be interested in hearing your thought on how to handle that elegantly.
>
> I'm sorry that your patches haven't gotten much attention thus far. Once I
> find mentor(s) for the Rust project I'll make sure they pick those up and
> take a look at the work you have done thus far.
>
> Hope this helps and welcome to the project!
>
> With Best Regards,
> Nate
>
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Ayush Singh
> Sent: Monday, April 4, 2022 10:18 AM
> To: devel@edk2.groups.io
> Cc: bret.barke...@microsoft.com; Desimone, Nathaniel L <
> nathaniel.l.desim...@intel.com>; mhaeu...@posteo.de
> Subject: [edk2-devel] Applying for GSoC 2022: Add Rust Support to EDK II
>
> Hello everyone, I am a 2nd-year University Student from India. I am
> interested in applying for adding Rust support to EDK2. I have already
> introduced myself to the mailing list earlier
> (https://edk2.groups.io/g/devel/message/87637) and have even submitted
> some patches for the edkii-rust branch in edk2-staging (which were not
> merged since that branch seems to be abandoned now).
> - https://edk2.groups.io/g/devel/message/87753
> - https://edk2.groups.io/g/devel/message/87754
> - https://edk2.groups.io/g/devel/message/87755
> - https://edk2.groups.io/g/devel/message/87756
>
> Anyway, since no mentor has been listed for this project, I was wondering
> who should I discuss the proposal with? Normally, I think one is supposed
> to discuss the proposal details with a mentor in form of a google doc or
> something before submitting an application. So should I directly start by
> submitting a proposal through the GSoC application portal? Or is there
> someone I should contact first?
>
> Ayush Singh
>
>
> 
>
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88637): https://edk2.groups.io/g/devel/message/88637
Mute This Topic: https://groups.io/mt/90247496/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 7/8] CryptoPkg/CrtLibSupport: fix strcpy

2022-04-08 Thread Yao, Jiewen
Can we remove inline keyword?

I don't think it is really needed in EDKII project.

Thank you
Yao Jiewen

> -Original Message-
> From: Gerd Hoffmann 
> Sent: Friday, April 8, 2022 7:16 PM
> To: devel@edk2.groups.io
> Cc: Oliver Steffen ; Yao, Jiewen
> ; Jiang, Guomin ; Wang, Jian
> J ; Xiaoyu Lu ; Pawel Polawski
> ; Gerd Hoffmann 
> Subject: [PATCH v2 7/8] CryptoPkg/CrtLibSupport: fix strcpy
> 
> strcpy() returns a pointer to the destination string, AsciiStrCpyS()
> does not.  So a simple #define does not work.  Create a inline function
> instead.
> 
> Signed-off-by: Gerd Hoffmann 
> ---
>  CryptoPkg/Library/Include/CrtLibSupport.h | 11 ++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h
> b/CryptoPkg/Library/Include/CrtLibSupport.h
> index 287d7f76bfb3..7c1bc7755b1c 100644
> --- a/CryptoPkg/Library/Include/CrtLibSupport.h
> +++ b/CryptoPkg/Library/Include/CrtLibSupport.h
> @@ -395,6 +395,16 @@ inet_pton   (
>void *
>);
> 
> +static inline char *
> +strcpy (
> +  char *restrict  strDest,
> +  const char  *strSource
> +  )
> +{
> +  AsciiStrCpyS (strDest, MAX_STRING_SIZE, strSource);
> +  return strDest;
> +}
> +
>  //
>  // Macros that directly map functions to BaseLib, BaseMemoryLib, and
> DebugLib functions
>  //
> @@ -404,7 +414,6 @@ inet_pton   (
>  #define memcmp(buf1, buf2, count)
> (int)(CompareMem(buf1,buf2,(UINTN)(count)))
>  #define memmove(dest, source, count)
> CopyMem(dest,source,(UINTN)(count))
>  #define strlen(str) 
> (size_t)(AsciiStrnLenS(str,MAX_STRING_SIZE))
> -#define strcpy(strDest, strSource)
> AsciiStrCpyS(strDest,MAX_STRING_SIZE,strSource)
>  #define strncpy(strDest, strSource, count)
> AsciiStrnCpyS(strDest,MAX_STRING_SIZE,strSource,(UINTN)count)
>  #define strcat(strDest, strSource)
> AsciiStrCatS(strDest,MAX_STRING_SIZE,strSource)
>  #define strncmp(string1, string2, count)
> (int)(AsciiStrnCmp(string1,string2,(UINTN)(count)))
> --
> 2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88636): https://edk2.groups.io/g/devel/message/88636
Mute This Topic: https://groups.io/mt/90333060/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 0/8] CryptoPkg updates for openssl 3.0

2022-04-08 Thread Yao, Jiewen
With inline keyword removed in patch-7/8,
Series reviewed-by: Jiewen Yao 



> -Original Message-
> From: Gerd Hoffmann 
> Sent: Friday, April 8, 2022 7:16 PM
> To: devel@edk2.groups.io
> Cc: Oliver Steffen ; Yao, Jiewen
> ; Jiang, Guomin ; Wang, Jian
> J ; Xiaoyu Lu ; Pawel Polawski
> ; Gerd Hoffmann 
> Subject: [PATCH v2 0/8] CryptoPkg updates for openssl 3.0
> 
> First batch of patches which update CrtLibSupport so it has everything
> needed to build openssl3.  Also a testcase update for openssl3.
> 
> This does not update the openssl submodule, that'll happen in a
> followup patch series.
> 
> v2:
>  - rebase to latest master.
>  - add codestyle exception for fcntl.h.
> 
> Gerd Hoffmann (8):
>   CryptoPkg/CrtLibSupport: add fcntl.h
>   CryptoPkg/CrtLibSupport: add strstr()
>   CryptoPkg/CrtLibSupport: add INT_MIN
>   CryptoPkg/CrtLibSupport: add UINT_MAX
>   CryptoPkg/CrtLibSupport: add MODULESDIR
>   CryptoPkg/CrtLibSupport: add off_t
>   CryptoPkg/CrtLibSupport: fix strcpy
>   CryptoPkg/UnitTest: fix DH testcase
> 
>  CryptoPkg/Library/Include/CrtLibSupport.h| 16 +++-
>  CryptoPkg/Library/Include/fcntl.h|  9 +
>  .../Test/UnitTest/Library/BaseCryptLib/DhTests.c |  6 +++---
>  CryptoPkg/CryptoPkg.ci.yaml  |  1 +
>  4 files changed, 28 insertions(+), 4 deletions(-)
>  create mode 100644 CryptoPkg/Library/Include/fcntl.h
> 
> --
> 2.35.1



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




[edk2-devel] [edk2-libc Patch 1/1] AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI environment

2022-04-08 Thread Jayaprakash, N
 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3899

 This is commit contains the UEFI port of uuid.py module. Made necessary
 changes required to uuid.py module to support UEFI environment.
 Porting of this module to UEFI is required for open source tools such
 as Chipsec to function properly.

 Cc: Rebecca Cran 
 Cc: Michael D Kinney 
 Signed-off-by: Jayaprakash N 
---
 .../Python/Python-3.6.8/Lib/uuid.py   | 94 ++-
 1 file changed, 50 insertions(+), 44 deletions(-)

diff --git a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py 
b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
index db8b2ef..84ed0b8 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
+++ b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
@@ -471,57 +471,61 @@ def _netbios_getnode():
 continue
 return int.from_bytes(bytes, 'big')
 
+
 # Thanks to Thomas Heller for ctypes and for his help with its use here.
 
 # If ctypes is available, use it to find system routines for UUID generation.
 # XXX This makes the module non-thread-safe!
 _uuid_generate_time = _UuidCreate = None
-try:
-import ctypes, ctypes.util
-import sys
-
-# The uuid_generate_* routines are provided by libuuid on at least
-# Linux and FreeBSD, and provided by libc on Mac OS X.
-_libnames = ['uuid']
-if not sys.platform.startswith('win'):
-_libnames.append('c')
-for libname in _libnames:
-try:
-lib = ctypes.CDLL(ctypes.util.find_library(libname))
-except Exception:
-continue
-if hasattr(lib, 'uuid_generate_time'):
-_uuid_generate_time = lib.uuid_generate_time
-break
-del _libnames
-
-# The uuid_generate_* functions are broken on MacOS X 10.5, as noted
-# in issue #8621 the function generates the same sequence of values
-# in the parent process and all children created using fork (unless
-# those children use exec as well).
-#
-# Assume that the uuid_generate functions are broken from 10.5 onward,
-# the test can be adjusted when a later version is fixed.
-if sys.platform == 'darwin':
-if int(os.uname().release.split('.')[0]) >= 9:
-_uuid_generate_time = None
-
-# On Windows prior to 2000, UuidCreate gives a UUID containing the
-# hardware address.  On Windows 2000 and later, UuidCreate makes a
-# random UUID and UuidCreateSequential gives a UUID containing the
-# hardware address.  These routines are provided by the RPC runtime.
-# NOTE:  at least on Tim's WinXP Pro SP2 desktop box, while the last
-# 6 bytes returned by UuidCreateSequential are fixed, they don't appear
-# to bear any relationship to the MAC address of any network device
-# on the box.
+if os.name != 'edk2':
+# This code is not meant to run on UEFI environment
 try:
-lib = ctypes.windll.rpcrt4
+import ctypes, ctypes.util
+import sys
+
+# The uuid_generate_* routines are provided by libuuid on at least
+# Linux and FreeBSD, and provided by libc on Mac OS X.
+_libnames = ['uuid']
+if not sys.platform.startswith('win'):
+_libnames.append('c')
+for libname in _libnames:
+try:
+lib = ctypes.CDLL(ctypes.util.find_library(libname))
+except Exception:
+continue
+if hasattr(lib, 'uuid_generate_time'):
+_uuid_generate_time = lib.uuid_generate_time
+break
+del _libnames
+
+# The uuid_generate_* functions are broken on MacOS X 10.5, as noted
+# in issue #8621 the function generates the same sequence of values
+# in the parent process and all children created using fork (unless
+# those children use exec as well).
+#
+# Assume that the uuid_generate functions are broken from 10.5 onward,
+# the test can be adjusted when a later version is fixed.
+if sys.platform == 'darwin':
+if int(os.uname().release.split('.')[0]) >= 9:
+_uuid_generate_time = None
+
+# On Windows prior to 2000, UuidCreate gives a UUID containing the
+# hardware address.  On Windows 2000 and later, UuidCreate makes a
+# random UUID and UuidCreateSequential gives a UUID containing the
+# hardware address.  These routines are provided by the RPC runtime.
+# NOTE:  at least on Tim's WinXP Pro SP2 desktop box, while the last
+# 6 bytes returned by UuidCreateSequential are fixed, they don't appear
+# to bear any relationship to the MAC address of any network device
+# on the box.
+try:
+lib = ctypes.windll.rpcrt4
+except:
+lib = None
+_UuidCreate = getattr(lib, 'UuidCreateSequential',
+  getattr(lib, 'UuidCreate', None))
 except:
-lib = None
-

[edk2-devel] [edk2-libc Patch 0/1] added support for uuid.py module for uefi environment

2022-04-08 Thread Jayaprakash, N
This patch contains the uuid.py updated module with the changes required to 
support it working on uefi environment.

Jayaprakash Nevara (1):
  AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for
UEFI environment

 .../Python/Python-3.6.8/Lib/uuid.py   | 94 ++-
 1 file changed, 50 insertions(+), 44 deletions(-)

-- 
2.32.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88633): https://edk2.groups.io/g/devel/message/88633
Mute This Topic: https://groups.io/mt/90333424/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] UEFI-SCT: SctPkg: Updated the check for monotonic count after restart

2022-04-08 Thread G Edhaya Chandran
Hi Barton,

Thank you for the review.
Could you please upstream the patch.

With Warm Regards,
Edhay


> -Original Message-
> From: Gao Jie 
> Sent: 08 April 2022 12:03
> To: devel@edk2.groups.io; G Edhaya Chandran 
> Subject: 回复: [edk2-devel] [PATCH 1/1] UEFI-SCT: SctPkg: Updated the check
> for monotonic count after restart
>
> Hi Eday,
>
> The patch looks good to me.
>
> Reviewed-by: Barton Gao 
>
> Thanks
> Barton
>
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 G Edhaya
> Chandran
> 发送时间: 2022年3月3日 16:59
> 收件人: devel@edk2.groups.io
> 主题: [edk2-devel] [PATCH 1/1] UEFI-SCT: SctPkg: Updated the check for
> monotonic count after restart
>
> Updated the check for montonic count in the case of after restart
>
> From the UEFI Spec:
> "The platform’s monotonic counter is comprised of two parts: the high 32 bits
> and the low 32 bits.
> The low 32-bit value is volatile and is reset to zero on every system reset.
> It is increased by 1 on every call to GetNextMonotonicCount().
> The high 32-bit value is nonvolatile and is increased by one on whenever the
> system resets or the low 32-bit counter overflows."
>
> It was found in one case where the higher 32-bit increased by 2 presumably
> due to the overflow of lower 32-bit counter.
> Update the logic to handle this case and to print a warning.
>
> Please find more details in the ticket:
> https://bugzilla.tianocore.org/show_bug.cgi?id=2774
>
> Cc: Barton Gao 
> Cc: Carolyn Gjertsen 
> Cc: Heinrich Schuchardt 
> Cc: Samer El-Haj-Mahmoud 
>
> Signed-off-by: G Edhaya Chandran
> ---
>  .../MiscBootServicesBBTestFunction.c  | 20 +--
>  1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/Mi
> scBootServicesBBTestFunction.c b/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/Mi
> scBootServicesBBTestFunction.c
> index 5d631c16d58b..12703d46f98c 100644
> --- a/uefi-
> sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/Mi
> scBootServicesBBTestFunction.c
> +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/Bl
> +++ ackBoxTest/MiscBootServicesBBTestFunction.c
> @@ -1707,12 +1707,20 @@ GetNextMonotonicCountStep2:
> TplArray[Index]
> );
>
> -if (SctRShiftU64 (Count2, 32) == SctRShiftU64 (Count, 32) + 1) {
> -  AssertionType = EFI_TEST_ASSERTION_PASSED;
> -} else {
> -  AssertionType = EFI_TEST_ASSERTION_FAILED;
> -}
> -StandardLib->RecordAssertion (
> +//The new count of upper 32 bits must be atleast 1 more than the old 
> count.
> +//Pass case: new count is equal to old count + 1
> +if (SctRShiftU64 (Count2, 32) <= SctRShiftU64 (Count, 32)) {
> +  AssertionType = EFI_TEST_ASSERTION_FAILED;
> +} else {
> +  //If new count is more that old count + 1, then print warning.
> +  if (SctRShiftU64 (Count2, 32) > SctRShiftU64 (Count, 32) + 1) {
> +AssertionType = EFI_TEST_ASSERTION_WARNING;
> +  } else {
> +//new count == old count + 1
> +AssertionType = EFI_TEST_ASSERTION_PASSED;
> +  }
> +   }
> +   StandardLib->RecordAssertion (
> StandardLib,
> AssertionType,
> Index==0? \
> --
> 2.17.1
>
>
>
> 
>
>
>

IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.


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




Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 25/33] MdePkg/BaseCpuLib: LoongArch Base CPU library implementation.

2022-04-08 Thread Abner Chang
Recently there is a work to migrate UefiCpuLib to CpuLib (patch attached), you 
may want to sync up your changes with that patch set. RISC-V will do the same 
work later.

Thanks
Abner

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chao Li
> Sent: Wednesday, February 9, 2022 2:56 PM
> To: devel@edk2.groups.io
> Cc: Michael D Kinney ; Liming Gao
> ; Zhiguang Liu 
> Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 25/33]
> MdePkg/BaseCpuLib: LoongArch Base CPU library implementation.
> 
> Implement LoongArch CPU related functions in BaseCpuLib.
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> 
> Signed-off-by: Chao Li 
> ---
>  MdePkg/Library/BaseCpuLib/BaseCpuLib.inf  |  7 ++-
>  MdePkg/Library/BaseCpuLib/BaseCpuLib.uni  |  5 +++--
>  MdePkg/Library/BaseCpuLib/LoongArch/CpuFlushTlb.S | 15
> +++
>  MdePkg/Library/BaseCpuLib/LoongArch/CpuSleep.S| 15
> +++
>  4 files changed, 39 insertions(+), 3 deletions(-)
>  create mode 100644 MdePkg/Library/BaseCpuLib/LoongArch/CpuFlushTlb.S
>  create mode 100644 MdePkg/Library/BaseCpuLib/LoongArch/CpuSleep.S
> 
> diff --git a/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
> b/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
> index 950f5229b2..3101fc656e 100644
> --- a/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
> +++ b/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
> @@ -8,6 +8,7 @@
>  #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
>  #  Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
>  #  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights
> reserved.
> +#  Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All
> rights reserved.
>  #
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
>  #
> @@ -25,7 +26,7 @@
> 
> 
>  #
> -#  VALID_ARCHITECTURES   = IA32 X64 EBC ARM AARCH64 RISCV64
> +#  VALID_ARCHITECTURES   = IA32 X64 EBC ARM AARCH64 RISCV64
> LOONGARCH64
>  #
> 
>  [Sources.IA32]
> @@ -63,6 +64,10 @@
>  [Sources.RISCV64]
>RiscV/Cpu.S
> 
> +[Sources.LOONGARCH64]
> +  LoongArch/CpuFlushTlb.S | GCC
> +  LoongArch/CpuSleep.S| GCC
> +
>  [Packages]
>MdePkg/MdePkg.dec
> 
> diff --git a/MdePkg/Library/BaseCpuLib/BaseCpuLib.uni
> b/MdePkg/Library/BaseCpuLib/BaseCpuLib.uni
> index 80dc495786..7c5c8dfb37 100644
> --- a/MdePkg/Library/BaseCpuLib/BaseCpuLib.uni
> +++ b/MdePkg/Library/BaseCpuLib/BaseCpuLib.uni
> @@ -1,13 +1,14 @@
>  // /** @file
>  // Instance of CPU Library for various architecture.
>  //
> -// CPU Library implemented using ASM functions for IA-32, X64 and RISCV64,
> +// CPU Library implemented using ASM functions for IA-32, X64, RISCV64
> and LoongArch64,
>  // PAL CALLs for IPF, and empty functions for EBC.
>  //
>  // Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
>  // Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
>  // Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
>  // Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights
> reserved.
> +// Portions Copyright (c) 2022, Loongson Technology Corporation Limited.
> All rights reserved.
>  //
>  // SPDX-License-Identifier: BSD-2-Clause-Patent
>  //
> @@ -16,5 +17,5 @@
> 
>  #string STR_MODULE_ABSTRACT #language en-US "Instance of CPU
> Library for various architectures"
> 
> -#string STR_MODULE_DESCRIPTION  #language en-US "CPU Library
> implemented using ASM functions for IA-32, X64 and RISCV64, PAL CALLs for
> IPF, and empty functions for EBC."
> +#string STR_MODULE_DESCRIPTION  #language en-US "CPU Library
> implemented using ASM functions for IA-32, X64, RISCV64 and LoongArch64,
> PAL CALLs for IPF, and empty functions for EBC."
> 
> diff --git a/MdePkg/Library/BaseCpuLib/LoongArch/CpuFlushTlb.S
> b/MdePkg/Library/BaseCpuLib/LoongArch/CpuFlushTlb.S
> new file mode 100644
> index 00..8b792f0a37
> --- /dev/null
> +++ b/MdePkg/Library/BaseCpuLib/LoongArch/CpuFlushTlb.S
> @@ -0,0 +1,15 @@
> +#--
> +#
> +# CpuFlushTlb() for LoongArch64
> +#
> +# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> reserved.
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +#--
> +ASM_GLOBAL ASM_PFX(CpuFlushTlb)
> +
> +ASM_PFX(CpuFlushTlb):
> +  tlbflush
> +  jirl $zero, $ra, 0
> +  .end
> diff --git a/MdePkg/Library/BaseCpuLib/LoongArch/CpuSleep.S
> b/MdePkg/Library/BaseCpuLib/LoongArch/CpuSleep.S
> new file mode 100644
> index 00..eb31b10714
> --- /dev/null
> +++ b/MdePkg/Library/BaseCpuLib/LoongArch/CpuSleep.S
> @@ -0,0 +1,15 @@
> +#--
> +#
> +# CpuSleep() for LoongArch64
> +#
> +# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> 

Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 32/33] BaseTools: Add LoongArch64 binding.

2022-04-08 Thread Abner Chang



> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chao Li
> Sent: Wednesday, February 9, 2022 4:02 PM
> To: devel@edk2.groups.io
> Cc: Bob Feng ; Liming Gao
> ; Yuwei Chen ; Baoqi
> Zhang 
> Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 32/33]
> BaseTools: Add LoongArch64 binding.
> 
> Add LoongArch64 ProcessorBin.h and add LoongArch to Makefiles.
> 
> Cc: Bob Feng 
> Cc: Liming Gao 
> Cc: Yuwei Chen 
> 
> Signed-off-by: Chao Li 
> Co-authored-by: Baoqi Zhang 
> ---
>  BaseTools/Source/C/GNUmakefile|  3 +
>  .../C/Include/LoongArch64/ProcessorBind.h | 80 +++
>  2 files changed, 83 insertions(+)
>  create mode 100644
> BaseTools/Source/C/Include/LoongArch64/ProcessorBind.h
> 
> diff --git a/BaseTools/Source/C/GNUmakefile
> b/BaseTools/Source/C/GNUmakefile
> index 8c191e0c38..5275f657ef 100644
> --- a/BaseTools/Source/C/GNUmakefile
> +++ b/BaseTools/Source/C/GNUmakefile
> @@ -29,6 +29,9 @@ ifndef HOST_ARCH
>ifneq (,$(findstring riscv64,$(uname_m)))
>  HOST_ARCH=RISCV64
>endif
> +  ifneq (,$(findstring loongarch64,$(uname_m)))
> +HOST_ARCH=LOONGARCH64
> +  endif
>ifndef HOST_ARCH
>  $(info Could not detected HOST_ARCH from uname results)
>  $(error HOST_ARCH is not defined!)
> diff --git a/BaseTools/Source/C/Include/LoongArch64/ProcessorBind.h
> b/BaseTools/Source/C/Include/LoongArch64/ProcessorBind.h
> new file mode 100644
> index 00..84c6b8ea7a
> --- /dev/null
> +++ b/BaseTools/Source/C/Include/LoongArch64/ProcessorBind.h
> @@ -0,0 +1,80 @@
> +/** @file
> +  Processor or Compiler specific defines and types for LoongArch
> +
> +  Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> reserved.
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +#ifndef __PROCESSOR_BIND_H__
> +#define __PROCESSOR_BIND_H__
Please remove the leading "__" and keep only one trailing "_".

Abner
> +
> +//
> +// Define the processor type so other code can make processor based
> choices
> +//
> +#define MDE_CPU_LOONGARCH64
> +
> +#define EFIAPI
> +
> +//
> +// Make sure we are using the correct packing rules per EFI specification
> +//
> +#ifndef __GNUC__
> +#pragma pack()
> +#endif
> +
> +//
> +// Use ANSI C 2000 stdint.h integer width declarations
> +//
> +#include 
> +typedef uint8_t   BOOLEAN;
> +typedef int8_tINT8;
> +typedef uint8_t   UINT8;
> +typedef int16_t   INT16;
> +typedef uint16_t  UINT16;
> +typedef int32_t   INT32;
> +typedef uint32_t  UINT32;
> +typedef int64_t   INT64;
> +typedef uint64_t  UINT64;
> +typedef char  CHAR8;
> +typedef uint16_t  CHAR16;
> +
> +//
> +// Signed value of native width.  (4 bytes on supported 32-bit processor
> instructions,
> +// 8 bytes on supported 64-bit processor instructions)
> +//
> +typedef INT64   INTN;
> +
> +//
> +// Unsigned value of native width.  (4 bytes on supported 32-bit processor
> instructions,
> +// 8 bytes on supported 64-bit processor instructions)
> +//
> +typedef UINT64  UINTN;
> +
> +//
> +// Processor specific defines
> +//
> +
> +//
> +// A value of native width with the highest bit set.
> +//
> +#define MAX_BIT 0x8000ULL
> +//
> +// A value of native width with the two highest bits set.
> +//
> +#define MAX_2_BITS  0xC000ULL
> +
> +#if defined(__GNUC__)
> +  //
> +  // For GNU assembly code, .global or .globl can declare global symbols.
> +  // Define this macro to unify the usage.
> +  //
> +  #define ASM_GLOBAL .globl
> +#endif
> +
> +//
> +// The stack alignment required for LoongArch
> +//
> +#define CPU_STACK_ALIGNMENT   16
> +
> +#endif
> --
> 2.27.0
> 
> 
> 
> 
> 



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




[edk2-devel] [PATCH v2 8/8] CryptoPkg/UnitTest: fix DH testcase

2022-04-08 Thread Gerd Hoffmann
openssl 3.0 wants at least 512 bytes, otherwise it throws an error:

error:0280007E:Diffie-Hellman routines::modulus too small

Signed-off-by: Gerd Hoffmann 
---
 CryptoPkg/Test/UnitTest/Library/BaseCryptLib/DhTests.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/DhTests.c 
b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/DhTests.c
index 5cfe8d70535b..29e892a1514c 100644
--- a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/DhTests.c
+++ b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/DhTests.c
@@ -53,7 +53,7 @@ TestVerifyDhGenerateKey (
   UNIT_TEST_CONTEXT  Context
   )
 {
-  UINT8Prime[64];
+  UINT8Prime[512];
   UINT8PublicKey1[64];
   UINTNPublicKey1Length;
   UINT8PublicKey2[64];
@@ -72,10 +72,10 @@ TestVerifyDhGenerateKey (
   Key1Length   = sizeof (Key1);
   Key2Length   = sizeof (Key2);
 
-  Status = DhGenerateParameter (mDh1, 2, 64, Prime);
+  Status = DhGenerateParameter (mDh1, 2, sizeof (Prime), Prime);
   UT_ASSERT_TRUE (Status);
 
-  Status = DhSetParameter (mDh2, 2, 64, Prime);
+  Status = DhSetParameter (mDh2, 2, sizeof (Prime), Prime);
   UT_ASSERT_TRUE (Status);
 
   Status = DhGenerateKey (mDh1, PublicKey1, );
-- 
2.35.1



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




[edk2-devel] [PATCH v2 3/8] CryptoPkg/CrtLibSupport: add INT_MIN

2022-04-08 Thread Gerd Hoffmann
Add #define for INT_MIN.
Will be needed by openssl 3.0.

Signed-off-by: Gerd Hoffmann 
---
 CryptoPkg/Library/Include/CrtLibSupport.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h 
b/CryptoPkg/Library/Include/CrtLibSupport.h
index a47befbb907e..b1db70a269ff 100644
--- a/CryptoPkg/Library/Include/CrtLibSupport.h
+++ b/CryptoPkg/Library/Include/CrtLibSupport.h
@@ -79,6 +79,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #define EINVAL22  /* Invalid argument */
 #define EAFNOSUPPORT  47  /* Address family not supported by 
protocol family */
 #define INT_MAX   0x7FFF  /* Maximum (signed) int value */
+#define INT_MIN   (-INT_MAX-1)/* Minimum (signed) int value */
 #define LONG_MAX  0X7FFFL /* max value for a long */
 #define LONG_MIN  (-LONG_MAX-1)   /* min value for a long */
 #define ULONG_MAX 0x  /* Maximum unsigned long value */
-- 
2.35.1



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




[edk2-devel] [PATCH v2 7/8] CryptoPkg/CrtLibSupport: fix strcpy

2022-04-08 Thread Gerd Hoffmann
strcpy() returns a pointer to the destination string, AsciiStrCpyS()
does not.  So a simple #define does not work.  Create a inline function
instead.

Signed-off-by: Gerd Hoffmann 
---
 CryptoPkg/Library/Include/CrtLibSupport.h | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h 
b/CryptoPkg/Library/Include/CrtLibSupport.h
index 287d7f76bfb3..7c1bc7755b1c 100644
--- a/CryptoPkg/Library/Include/CrtLibSupport.h
+++ b/CryptoPkg/Library/Include/CrtLibSupport.h
@@ -395,6 +395,16 @@ inet_pton   (
   void *
   );
 
+static inline char *
+strcpy (
+  char *restrict  strDest,
+  const char  *strSource
+  )
+{
+  AsciiStrCpyS (strDest, MAX_STRING_SIZE, strSource);
+  return strDest;
+}
+
 //
 // Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib 
functions
 //
@@ -404,7 +414,6 @@ inet_pton   (
 #define memcmp(buf1, buf2, count)   
(int)(CompareMem(buf1,buf2,(UINTN)(count)))
 #define memmove(dest, source, count)CopyMem(dest,source,(UINTN)(count))
 #define strlen(str) 
(size_t)(AsciiStrnLenS(str,MAX_STRING_SIZE))
-#define strcpy(strDest, strSource)  
AsciiStrCpyS(strDest,MAX_STRING_SIZE,strSource)
 #define strncpy(strDest, strSource, count)  
AsciiStrnCpyS(strDest,MAX_STRING_SIZE,strSource,(UINTN)count)
 #define strcat(strDest, strSource)  
AsciiStrCatS(strDest,MAX_STRING_SIZE,strSource)
 #define strncmp(string1, string2, count)
(int)(AsciiStrnCmp(string1,string2,(UINTN)(count)))
-- 
2.35.1



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




[edk2-devel] [PATCH v2 6/8] CryptoPkg/CrtLibSupport: add off_t

2022-04-08 Thread Gerd Hoffmann
Add typedef for off_t.
Will be needed by openssl 3.0.

Signed-off-by: Gerd Hoffmann 
---
 CryptoPkg/Library/Include/CrtLibSupport.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h 
b/CryptoPkg/Library/Include/CrtLibSupport.h
index 9829ec010aee..287d7f76bfb3 100644
--- a/CryptoPkg/Library/Include/CrtLibSupport.h
+++ b/CryptoPkg/Library/Include/CrtLibSupport.h
@@ -104,6 +104,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 // Basic types mapping
 //
 typedef UINTN   size_t;
+typedef UINTN   off_t;
 typedef UINTN   u_int;
 typedef INTNptrdiff_t;
 typedef INTNssize_t;
-- 
2.35.1



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




[edk2-devel] [PATCH v2 5/8] CryptoPkg/CrtLibSupport: add MODULESDIR

2022-04-08 Thread Gerd Hoffmann
Add dummy MODULESDIR #define
Will be needed by openssl 3.0.

Signed-off-by: Gerd Hoffmann 
---
 CryptoPkg/Library/Include/CrtLibSupport.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h 
b/CryptoPkg/Library/Include/CrtLibSupport.h
index aed21932278e..9829ec010aee 100644
--- a/CryptoPkg/Library/Include/CrtLibSupport.h
+++ b/CryptoPkg/Library/Include/CrtLibSupport.h
@@ -18,6 +18,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 #define OPENSSLDIR  ""
 #define ENGINESDIR  ""
+#define MODULESDIR  ""
 
 #define MAX_STRING_SIZE  0x1000
 
-- 
2.35.1



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




[edk2-devel] [PATCH v2 4/8] CryptoPkg/CrtLibSupport: add UINT_MAX

2022-04-08 Thread Gerd Hoffmann
Add define for UINT_MAX.
Will be needed by openssl 3.0.

Signed-off-by: Gerd Hoffmann 
---
 CryptoPkg/Library/Include/CrtLibSupport.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h 
b/CryptoPkg/Library/Include/CrtLibSupport.h
index b1db70a269ff..aed21932278e 100644
--- a/CryptoPkg/Library/Include/CrtLibSupport.h
+++ b/CryptoPkg/Library/Include/CrtLibSupport.h
@@ -82,6 +82,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #define INT_MIN   (-INT_MAX-1)/* Minimum (signed) int value */
 #define LONG_MAX  0X7FFFL /* max value for a long */
 #define LONG_MIN  (-LONG_MAX-1)   /* min value for a long */
+#define UINT_MAX  0x  /* Maximum unsigned int value */
 #define ULONG_MAX 0x  /* Maximum unsigned long value */
 #define CHAR_BIT  8   /* Number of bits in a char */
 
-- 
2.35.1



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




[edk2-devel] [PATCH v2 2/8] CryptoPkg/CrtLibSupport: add strstr()

2022-04-08 Thread Gerd Hoffmann
Add #define for strstr().
Will be needed by openssl 3.0.

Signed-off-by: Gerd Hoffmann 
---
 CryptoPkg/Library/Include/CrtLibSupport.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h 
b/CryptoPkg/Library/Include/CrtLibSupport.h
index 75172b920b67..a47befbb907e 100644
--- a/CryptoPkg/Library/Include/CrtLibSupport.h
+++ b/CryptoPkg/Library/Include/CrtLibSupport.h
@@ -405,6 +405,7 @@ inet_pton   (
 #define strcat(strDest, strSource)  
AsciiStrCatS(strDest,MAX_STRING_SIZE,strSource)
 #define strncmp(string1, string2, count)
(int)(AsciiStrnCmp(string1,string2,(UINTN)(count)))
 #define strcasecmp(str1, str2)  (int)AsciiStriCmp(str1,str2)
+#define strstr(s1, s2)  AsciiStrStr(s1,s2)
 #define sprintf(buf, ...)   
AsciiSPrint(buf,MAX_STRING_SIZE,__VA_ARGS__)
 #define localtime(timer)NULL
 #define assert(expression)
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88623): https://edk2.groups.io/g/devel/message/88623
Mute This Topic: https://groups.io/mt/90333052/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/8] CryptoPkg updates for openssl 3.0

2022-04-08 Thread Gerd Hoffmann
First batch of patches which update CrtLibSupport so it has everything
needed to build openssl3.  Also a testcase update for openssl3.

This does not update the openssl submodule, that'll happen in a
followup patch series.

v2:
 - rebase to latest master.
 - add codestyle exception for fcntl.h.

Gerd Hoffmann (8):
  CryptoPkg/CrtLibSupport: add fcntl.h
  CryptoPkg/CrtLibSupport: add strstr()
  CryptoPkg/CrtLibSupport: add INT_MIN
  CryptoPkg/CrtLibSupport: add UINT_MAX
  CryptoPkg/CrtLibSupport: add MODULESDIR
  CryptoPkg/CrtLibSupport: add off_t
  CryptoPkg/CrtLibSupport: fix strcpy
  CryptoPkg/UnitTest: fix DH testcase

 CryptoPkg/Library/Include/CrtLibSupport.h| 16 +++-
 CryptoPkg/Library/Include/fcntl.h|  9 +
 .../Test/UnitTest/Library/BaseCryptLib/DhTests.c |  6 +++---
 CryptoPkg/CryptoPkg.ci.yaml  |  1 +
 4 files changed, 28 insertions(+), 4 deletions(-)
 create mode 100644 CryptoPkg/Library/Include/fcntl.h

-- 
2.35.1



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




[edk2-devel] [PATCH v2 1/8] CryptoPkg/CrtLibSupport: add fcntl.h

2022-04-08 Thread Gerd Hoffmann
Add fcntl.h header file.
Will be needed by openssl 3.0.

Signed-off-by: Gerd Hoffmann 
---
 CryptoPkg/Library/Include/fcntl.h | 9 +
 CryptoPkg/CryptoPkg.ci.yaml   | 1 +
 2 files changed, 10 insertions(+)
 create mode 100644 CryptoPkg/Library/Include/fcntl.h

diff --git a/CryptoPkg/Library/Include/fcntl.h 
b/CryptoPkg/Library/Include/fcntl.h
new file mode 100644
index ..040ecfa5193d
--- /dev/null
+++ b/CryptoPkg/Library/Include/fcntl.h
@@ -0,0 +1,9 @@
+/** @file
+  Include file to support building the third-party cryptographic library.
+
+Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
diff --git a/CryptoPkg/CryptoPkg.ci.yaml b/CryptoPkg/CryptoPkg.ci.yaml
index e21fafac1efe..396ca93dbe49 100644
--- a/CryptoPkg/CryptoPkg.ci.yaml
+++ b/CryptoPkg/CryptoPkg.ci.yaml
@@ -36,6 +36,7 @@
 "Library/Include/CrtLibSupport.h",
 # This has OpenSSL interfaces that aren't UEFI spec compliant
 "Library/BaseCryptLib/Hash/CryptParallelHash.h",
+"Library/Include/fcntl.h",
 # These directories contain auto-generated OpenSSL content
 "Library/OpensslLib",
 "Library/IntrinsicLib",
-- 
2.35.1



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




Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 30/33] MdeModulePkg/DxeIplPeim : LoongArch DxeIPL implementation.

2022-04-08 Thread Abner Chang
DxeLoadFunc.c is almost the same as RISC-V instance. However, I don't have idea 
how to leverage it because DxeLoadFunc is currently in the architecture-based 
folder.

Acked-by: Abner Chang 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chao Li
> Sent: Wednesday, February 9, 2022 4:02 PM
> To: devel@edk2.groups.io
> Cc: Liming Gao ; Guomin Jiang
> ; Baoqi Zhang 
> Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 30/33]
> MdeModulePkg/DxeIplPeim : LoongArch DxeIPL implementation.
> 
> Implement LoongArch DxeIPL instance.
> 
> Cc: Liming Gao 
> Cc: Guomin Jiang 
> 
> Signed-off-by: Chao Li 
> Co-authored-by: Baoqi Zhang 
> ---
>  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf   |  6 +-
>  .../Core/DxeIplPeim/LoongArch64/DxeLoadFunc.c | 61
> +++
>  2 files changed, 66 insertions(+), 1 deletion(-)
>  create mode 100644
> MdeModulePkg/Core/DxeIplPeim/LoongArch64/DxeLoadFunc.c
> 
> diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> index 19b8a4c8ae..052ea0ec1a 100644
> --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> @@ -8,6 +8,7 @@
>  #  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
>  #  Copyright (c) 2017, AMD Incorporated. All rights reserved.
>  #  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights
> reserved.
> +#  Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> reserved.
>  #
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
>  #
> @@ -26,7 +27,7 @@
>  #
>  # The following information is for reference only and not required by the
> build tools.
>  #
> -#  VALID_ARCHITECTURES   = IA32 X64 EBC (EBC is for build only)
> AARCH64 RISCV64
> +#  VALID_ARCHITECTURES   = IA32 X64 EBC (EBC is for build only)
> AARCH64 RISCV64 LOONGARCH64
>  #
> 
>  [Sources]
> @@ -53,6 +54,9 @@
>  [Sources.RISCV64]
>RiscV64/DxeLoadFunc.c
> 
> +[Sources.LOONGARCH64]
> +  LoongArch64/DxeLoadFunc.c
> +
>  [Packages]
>MdePkg/MdePkg.dec
>MdeModulePkg/MdeModulePkg.dec
> diff --git a/MdeModulePkg/Core/DxeIplPeim/LoongArch64/DxeLoadFunc.c
> b/MdeModulePkg/Core/DxeIplPeim/LoongArch64/DxeLoadFunc.c
> new file mode 100644
> index 00..27ffc072d0
> --- /dev/null
> +++ b/MdeModulePkg/Core/DxeIplPeim/LoongArch64/DxeLoadFunc.c
> @@ -0,0 +1,61 @@
> +/** @file
> +  LoongArch specifc functionality for DxeLoad.
> +
> +  Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> reserved.
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "DxeIpl.h"
> +
> +/**
> +   Transfers control to DxeCore.
> +
> +   This function performs a CPU architecture specific operations to execute
> +   the entry point of DxeCore with the parameters of HobList.
> +   It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase.
> +
> +   @param DxeCoreEntryPoint The entry point of DxeCore.
> +   @param HobList   The start of HobList passed to DxeCore.
> +
> +**/
> +VOID
> +HandOffToDxeCore (
> +  IN EFI_PHYSICAL_ADDRESS   DxeCoreEntryPoint,
> +  IN EFI_PEI_HOB_POINTERS   HobList
> +  )
> +{
> +  VOID*BaseOfStack;
> +  VOID*TopOfStack;
> +  EFI_STATUS  Status;
> +
> +  //
> +  // Allocate 128KB for the Stack
> +  //
> +  BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));
> +  ASSERT (BaseOfStack != NULL);
> +  //
> +  // Compute the top of the stack we were allocated. Pre-allocate a UINTN
> +  // for safety.
> +  //
> +  TopOfStack = (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES
> (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
> +  TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
> +  //
> +  // End of PEI phase singal
> +  //
> +  Status = PeiServicesInstallPpi ();
> +  ASSERT_EFI_ERROR (Status);
> +
> +  //
> +  // Update the contents of BSP stack HOB to reflect the real stack info
> passed to DxeCore.
> +  //
> +  UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN) BaseOfStack,
> STACK_SIZE);
> +
> +  SwitchStack (
> +(SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,
> +HobList.Raw,
> +NULL,
> +TopOfStack
> +);
> +}
> --
> 2.27.0
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 27/33] MdePkg/BaseSafeIntLib: Add LoongArch64 architecture for BaseSafeIntLib.

2022-04-08 Thread Abner Chang
Acked-by: Abner Chang 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chao Li
> Sent: Wednesday, February 9, 2022 2:56 PM
> To: devel@edk2.groups.io
> Cc: Michael D Kinney ; Liming Gao
> ; Zhiguang Liu 
> Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 27/33]
> MdePkg/BaseSafeIntLib: Add LoongArch64 architecture for BaseSafeIntLib.
> 
> Add LoongArch64 architecture for BaseSafeIntLib library.
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> 
> Signed-off-by: Chao Li 
> ---
>  MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
> b/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
> index 40017ec88b..9d039f2e5b 100644
> --- a/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
> +++ b/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
> @@ -4,9 +4,10 @@
>  # This library provides helper functions to prevent integer overflow during
>  # type conversion, addition, subtraction, and multiplication.
>  #
> -#  Copyright (c) 2018, Intel Corporation. All rights reserved.
> +# Copyright (c) 2018, Intel Corporation. All rights reserved.
>  # Copyright (c) 2017, Microsoft Corporation
> -#  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights
> reserved.
> +# Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights
> reserved.
> +# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> reserved.
> 
>  #
>  # All rights reserved.
> @@ -25,7 +26,7 @@
>  #
>  # The following information is for reference only and not required by the
> build tools.
>  #
> -#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64 RISCV64
> +#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64 RISCV64
> LOONGARCH64
>  #
> 
>  [Sources]
> @@ -34,7 +35,7 @@
>  [Sources.Ia32, Sources.ARM]
>SafeIntLib32.c
> 
> -[Sources.X64, Sources.AARCH64, Sources.RISCV64]
> +[Sources.X64, Sources.AARCH64, Sources.RISCV64, Sources.LOONGARCH64]
>SafeIntLib64.c
> 
>  [Sources.EBC]
> --
> 2.27.0
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 26/33] MdePkg/BaseSynchronizationLib: LoongArch cache related code.

2022-04-08 Thread Abner Chang



> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chao Li
> Sent: Wednesday, February 9, 2022 2:56 PM
> To: devel@edk2.groups.io
> Cc: Michael D Kinney ; Liming Gao
> ; Zhiguang Liu ; Baoqi
> Zhang 
> Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 26/33]
> MdePkg/BaseSynchronizationLib: LoongArch cache related code.
> 
> Support LoongArch cache related functions.
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> 
> Signed-off-by: Chao Li 
> Co-authored-by: Baoqi Zhang 
> ---
>  .../BaseSynchronizationLib.inf|   5 +
>  .../LoongArch64/Synchronization.c | 239 ++
>  2 files changed, 244 insertions(+)
>  create mode 100644
> MdePkg/Library/BaseSynchronizationLib/LoongArch64/Synchronization.c
> 
> diff --git
> a/MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
> b/MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
> index 83d5b8ed7c..3cf5b6d4b1 100755
> --- a/MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
> +++ b/MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
> @@ -4,6 +4,7 @@
>  #  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
>  #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
>  #  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights
> reserved.
> +#  Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> reserved.
>  #
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
>  #
> @@ -83,6 +84,10 @@
>Synchronization.c
>RiscV64/Synchronization.S
> 
> +[Sources.LOONGARCH64]
> +  Synchronization.c
> +  LoongArch64/Synchronization.c
> +
>  [Packages]
>MdePkg/MdePkg.dec
> 
> diff --git
> a/MdePkg/Library/BaseSynchronizationLib/LoongArch64/Synchronization.c
> b/MdePkg/Library/BaseSynchronizationLib/LoongArch64/Synchronization.c
> new file mode 100644
> index 00..a191a50c81
> --- /dev/null
> +++
> b/MdePkg/Library/BaseSynchronizationLib/LoongArch64/Synchronization.c
> @@ -0,0 +1,239 @@
> +/** @file
> +  LoongArch synchronization functions.
> +
> +  Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> reserved.
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include 
> +
> +/**
> +  Performs an atomic compare exchange operation on a 16-bit
> +  unsigned integer.
> +
> +  Performs an atomic compare exchange operation on the 16-bit
> +  unsigned integer specified by Value.  If Value is equal to
> +  CompareValue, then Value is set to ExchangeValue and
> +  CompareValue is returned.  If Value is not equal to
> +  CompareValue, then Value is returned. The compare exchange
> +  operation must be performed using MP safe mechanisms.
> +
> +  @param  Value A pointer to the 16-bit value for the
> +compare exchange operation.
> +  @param  CompareValue  16-bit value used in compare operation.
> +  @param  ExchangeValue 16-bit value used in exchange operation.
> +
> +  @return The original *Value before exchange.
I see the modifiers (e.g., IN and/or OUT) are not assigned to @param of 
arguments in the function header across the source files in this patch set. I 
know some old source files don't have modifiers neither, however, we should 
have those in the new source file according to the coding standard.

> +
> +**/
> +UINT16
> +EFIAPI
> +InternalSyncCompareExchange16 (
> +  IN  volatile UINT16   *Value,
> +  IN  UINT16CompareValue,
> +  IN  UINT16ExchangeValue
> +  )
> +{
> +  UINT32 RetValue, Temp, Shift;
> +  UINT64 Mask, LocalCompareValue, LocalExchangeValue;
> +  volatile UINT32 *Ptr32;
I can't find the statement in the edk2 C coding standard spec, however as I can 
remember each local variable should start at a new line.
> +
> +  /* Check that ptr is naturally aligned */
> +  ASSERT(!((UINT64)Value & (sizeof(Value) - 1)));
Please use double back slash for the comment.
> +
> +  /* Mask inputs to the correct size. */
> +  Mask = (((~0UL) - (1UL << (0)) + 1) & (~0UL >> (64 - 1 - ((sizeof(UINT16) 
> * 8)
> - 1;
> +  LocalCompareValue = ((UINT64)CompareValue) & Mask;
> +  LocalExchangeValue = ((UINT64)ExchangeValue) & Mask;
> +
> +  /*
> +   * Calculate a shift & mask that correspond to the value we wish to
> +   * compare & exchange within the naturally aligned 4 byte integer
> +   * that includes it.
> +   */
> +  Shift = (UINT64)Value & 0x3;
> +  Shift *= 8; /* BITS_PER_BYTE */
> +  LocalCompareValue <<= Shift;
> +  LocalExchangeValue <<= Shift;
> +  Mask <<= Shift;
> +
> +  /*
> +   * Calculate a pointer to the naturally aligned 4 byte integer that
> +   * includes our byte of interest, and load its value.
> +   */
> +  Ptr32 = (UINT32 *)((UINT64)Value & ~0x3);
> +
> +  __asm__ __volatile__ (
> +"1:   \n"
> +"ll.w  %0, %3 \n"
> +"and   %1, %0, %4 \n"
> +"bne   %1, %5, 2f \n"
> +"or%1, 

Re: [edk2-devel] Intel NUC platform firmware -- no serial I/O support?

2022-04-08 Thread Laszlo Ersek
On 04/08/22 11:48, Gerd Hoffmann wrote:
> 
>   Hi,
>  
>> And It Just Works (TM), with the following two commands in the UEFI
>> shell (after I copied the binaries to the USB stick, alongside the UEFI
>> Shell binary I built earlier):
>>
>>> Shell> fs0:
>>> FS0:\> cd efi\boot
>>> FS0:\efi\boot\> load SerialDxe.efi
>>> Image 'FS0:\EFI\BOOT\SerialDxe.efi' loaded at 2C801000 - Success
>>> FS0:\efi\boot\> load TerminalDxe.efi
>>> Image 'FS0:\EFI\BOOT\TerminalDxe.efi' loaded at 2C7FB000 - Success
>>> FS0:\efi\boot\>
>>
>> At this point, the UEFI console is properly multiplexed to both serial
>> and HDMI+USB.
> 
> Neat.  /me makes a mental note that one can load drivers like this.
> Can this be automated to run on each boot?  With a startup.nsh script?

Yes, that's what I did:
.

Even better would have been to copy the SerialDxe and TerminalDxe
drivers to the hard disk's EFI system partition, and then register them
as Driver / DriverOrder. I tried that with "bcfg driver addp", and
then validated with "bcfg driver dump -v" -- however, alas, this system
seems to ignore Driver* in platform BDS.

Regarding the startup.nsh script: the contents are like this:

load hd0c0b:\efi\boot\SerialDxe.efi
load hd0c0b:\efi\boot\TerminalDxe.efi

The "hd0c0b:" filesystem identifier is the "consistent naming" kind
(printed by "map -c"), as opposed to FS0: and friends. Without an FS
identifier, the script wouldn't work (the shell wouldn't know on what FS
to look for the pathname \efi\boot\SerialDxe.efi, because, at startup,
there would not be a "current" filesystem). And given that I had to
specify the filesystem, the "consistent" naming looked better. The UEFI
Shell spec explains what the consistent naming rules are -- in brief, as
long as I plug the stick in the same USB port, the FS identifier will work.

Thanks,
Laszlo



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




Re: [edk2-devel] Intel NUC platform firmware -- no serial I/O support?

2022-04-08 Thread Gerd Hoffmann


  Hi,
 
> And It Just Works (TM), with the following two commands in the UEFI
> shell (after I copied the binaries to the USB stick, alongside the UEFI
> Shell binary I built earlier):
> 
> > Shell> fs0:
> > FS0:\> cd efi\boot
> > FS0:\efi\boot\> load SerialDxe.efi
> > Image 'FS0:\EFI\BOOT\SerialDxe.efi' loaded at 2C801000 - Success
> > FS0:\efi\boot\> load TerminalDxe.efi
> > Image 'FS0:\EFI\BOOT\TerminalDxe.efi' loaded at 2C7FB000 - Success
> > FS0:\efi\boot\>
> 
> At this point, the UEFI console is properly multiplexed to both serial
> and HDMI+USB.

Neat.  /me makes a mental note that one can load drivers like this.
Can this be automated to run on each boot?  With a startup.nsh script?

take care,
  Gerd



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




Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 24/33] MdePkg/BasePeCoff: Add LoongArch PE/Coff related code.

2022-04-08 Thread Abner Chang



> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chao Li
> Sent: Wednesday, February 9, 2022 2:56 PM
> To: devel@edk2.groups.io
> Cc: Michael D Kinney ; Liming Gao
> ; Zhiguang Liu ; Baoqi
> Zhang 
> Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 24/33]
> MdePkg/BasePeCoff: Add LoongArch PE/Coff related code.
> 
> Add LoongArch image relocation.
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> 
> Signed-off-by: Chao Li 
> Co-authored-by: Baoqi Zhang 
> ---
>  MdePkg/Library/BasePeCoffLib/BasePeCoff.c |   3 +-
>  .../Library/BasePeCoffLib/BasePeCoffLib.inf   |   5 +
>  .../Library/BasePeCoffLib/BasePeCoffLib.uni   |   2 +
>  .../BasePeCoffLib/LoongArch/PeCoffLoaderEx.c  | 132
> ++
>  4 files changed, 141 insertions(+), 1 deletion(-)
>  create mode 100644
> MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c
> 
> diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> index 6d8d9faeb8..97a8aaf8c7 100644
> --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> @@ -1,6 +1,6 @@
>  /** @file
>Base PE/COFF loader supports loading any PE32/PE32+ or TE image, but
> -  only supports relocating IA32, x64, IPF, ARM, RISC-V and EBC images.
> +  only supports relocating IA32, x64, IPF, ARM, RISC-V, LoongArch and EBC
> images.
> 
>Caution: This file requires additional review when modified.
>This library will have external input - PE/COFF image.
> @@ -18,6 +18,7 @@
>Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
>Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
>Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP.
> All rights reserved.
> +  Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All
> rights reserved.
>SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  **/
> diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
> b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
> index 110b6d5a09..3b8b8eb191 100644
> --- a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
> +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
> @@ -4,6 +4,7 @@
>  #  The IA32 version library support loading IA32, X64 and EBC PE/COFF images.
>  #  The X64 version library support loading IA32, X64 and EBC PE/COFF images.
>  #  The RISC-V version library support loading RISC-V images.
> +#  The LoongArch version library support loading LoongArch images.
>  #
>  #  Caution: This module requires additional review when modified.
>  #  This library will have external input - PE/COFF image.
> @@ -13,6 +14,7 @@
>  #  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
>  #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
>  #  Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP.
> All rights reserved.
> +#  Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All
> rights reserved.
>  #
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
>  #
> @@ -46,6 +48,9 @@
>  [Sources.RISCV64]
>RiscV/PeCoffLoaderEx.c
> 
> +[Sources.LOONGARCH64]
> +  LoongArch/PeCoffLoaderEx.c
> +
>  [Packages]
>MdePkg/MdePkg.dec
> 
> diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni
> b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni
> index 55417029f2..1f731344e1 100644
> --- a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni
> +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni
> @@ -5,6 +5,7 @@
>  // The IA32 version library support loading IA32, X64 and EBC PE/COFF
> images.
>  // The X64 version library support loading IA32, X64 and EBC PE/COFF images.
>  // The RISC-V version library support loading RISC-V32 and RISC-V64 PE/COFF
> images.
> +// The LoongArch version library support loading LoongArch32 and
> LoongArch64 PE/COFF images.
>  //
>  // Caution: This module requires additional review when modified.
>  // This library will have external input - PE/COFF image.
> @@ -14,6 +15,7 @@
>  // Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
>  // Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
>  // Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP.
> All rights reserved.
> +// Portions Copyright (c) 2022, Loongson Technology Corporation Limited.
> All rights reserved.
>  //
>  // SPDX-License-Identifier: BSD-2-Clause-Patent
>  //
> diff --git a/MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c
> b/MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c
> new file mode 100644
> index 00..ec572c2dd6
> --- /dev/null
> +++ b/MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c
> @@ -0,0 +1,132 @@
> +/** @file
> +  PE/Coff loader for LoongArch PE image
> +
> +  Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> reserved.
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +**/
> +
> +#include 

Re: [edk2-devel] Intel NUC platform firmware -- no serial I/O support?

2022-04-08 Thread Laszlo Ersek
On 04/08/22 00:16, Desimone, Nathaniel L wrote:
> Hi Laszlo,
> 
>> -Original Message-
>> From: devel@edk2.groups.io  On Behalf Of Laszlo
>> Ersek
>> Sent: Thursday, April 7, 2022 12:46 AM
>> To: edk2-devel-groups-io 
>> Cc: r, ramesh ; Sivaraman Nainar
>> ; KARPAGAVINAYAGAM, MANICKAVASAKAM
>> 
>> Subject: [edk2-devel] Intel NUC platform firmware -- no serial I/O support?
>>
>> Hi List,
>>
>> my toolbox has been extended with an Intel NUC, the base kit model being
>> NUC8i3PNH. The NUC has a serial port connector on the back, and indeed
>> Serial I/O works fine once an OS starts.
>>
>> However, the UEFI platform firmware seems to have no support for Serial
>> I/O. I've built a fresh UEFI Shell binary from edk2 master and poked around 
>> in
>> the protocol database, with "drivers" and "dh". The necessary drivers seem
>> to be included, however they do not appear to bind the hardware that's
>> inside the chassis. ("connect -r" makes no difference in this regard, so 
>> it's not
>> just BDS policy.)
> 
> Yeah you are right the Super I/O stuff is barrels of fun. However it is 
> actually a spec defined protocol, it is just in the PI spec not the UEFI 
> spec. The PI spec also counts for addition to MdePkg. On the MinPlatform side 
> we built a small/simple Super I/O bus driver for UARTs and PS/2 
> keyboard/mouse: 
> https://github.com/tianocore/edk2-platforms/tree/master/Platform/Intel/BoardModulePkg/LegacySioDxe
> 
> Volume 5, Chapter 14 of the PI spec waxes rather poetic about how to build a 
> full ISA plug-and-play capable DXE driver stack for a system that 
> incorporates both a Super I/O and physical ISA slots.

I always forget that the PI spec can very well define protocols to be
used by UEFI drivers...

> I can say is that the NUC team has opted to build their systems with AMI 
> Aptio instead of starting with the Intel reference UEFI firmware. I'm not 
> privy to the conversation there. Accordingly, there might be some Aptio 
> specific drivers as you note in your listing of the driver handle database. 
> I'm afraid I have as much knowledge about how that driver stack works as you 
> do.

Thanks for responding!

Yesterday I played a bit more with the NUC. I placed the UEFI shell as
EFI\BOOT\BOOTX64.EFI on a USB stick, together with SerialDxe.efi,
TerminalDxe.efi, and a "startup.nsh" script that loads SerialDxe and
TerminalDxe using the "consistent shell drive names" scheme. This way,
when I boot the NUC off the stick, I get a shell on serial at once.

Another experiment I tried was "bcfg driver". Unfortunately, the
platform BDS on the NUC seems to ignore Driver and DriverOrder.

Then I build UiApp.efi in separation too, and started it from the shell
-- it was then really strange to see the "Front Page" tab in the
graphical setup TUI :)

Now, while that was somewhat useful (as it extended the NUC's setup UI
with some nifty features that I'd become used to with OVMF), I actually
wanted the inverse: to get all the original NUC setup stuff exposed over
serial. But I guess for that, I'd have to replace (override) the
graphical setup browser and/or the display engine DXE drivers of the
platform firmware... I guess I'll have to give up there.

Thanks!
Laszlo



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




Re: [edk2-devel] Intel NUC platform firmware -- no serial I/O support?

2022-04-08 Thread Laszlo Ersek
Hi Manic,

On 04/07/22 19:04, Manickavasakam Karpagavinayagam wrote:
> Laszlo/Gred :
> 
> Can you please let us know the GITHUB project location from where you have 
> downloaded the source ?

I didn't download any new source code. I've just had my local edk2 clone
as always, and the small patch at the bottom (adding "NucSerialPkg",
just for the sake of buildig SerialDxe and TerminalDxe in separation)
applies on top of current master.

Thanks
Laszlo

> 
> Thank you
> 
> -Manic
> 
> -Original Message-
> From: Laszlo Ersek 
> Sent: Thursday, April 7, 2022 10:12 AM
> To: Gerd Hoffmann 
> Cc: devel@edk2.groups.io; Ramesh R. ; Sivaraman Nainar 
> ; Manickavasakam Karpagavinayagam 
> 
> Subject: [EXTERNAL] Re: [edk2-devel] Intel NUC platform firmware -- no serial 
> I/O support?
> 
> 
> **CAUTION: The e-mail below is from an external source. Please exercise 
> caution before opening attachments, clicking links, or following guidance.**
> 
> On 04/07/22 14:50, Gerd Hoffmann wrote:
> 
>> Well, it at least looks like 16550 / ide hardware.  Not sure how this
>> is actually implemented, I suspect it is virtual, maybe port access
>> traps into SMM and it's emulated there.  Or the management engine can
>> intercept those port accesses somehow.
> 
>> If today's hardware still works the same way I'd expect you have a
>> little driver taking the role of SioBusDxe, but binding to
>> PCI_CLASS_COMMUNICATION_SERIAL devices instead of a LPC bridge with
>> isa serial ports behind it.  Possibly the AMI drivers you've seen are
>> just that.
>>
>> Does the NUC accept unsigned firmware updates?  If so we can maybe
>> just add a SioBusDxe driver variant customized for the NUC hardware
> 
> You are spot on, but reality is even simpler than this. :)
> 
> Here's what I've done:
> 
> (1) I cross-referenced three lists of PCI IDs:
> 
> (1.1) The supported IDs in the windows UART driver INF file, downloaded from 
> Intel, for this NUC.
> 
> (1.2) The "lspci" output on the NUC.
> 
> (1.3) The "drivers/mfd/intel-lpss-pci.c" file in the Linux tree.
> 
> Result: there is no separate PCI device on this NUC that stands for a serial 
> controller. Furthermore, "intel-lpss-pci.c" suggests all the "LPSS" serial 
> ports (UARTs) are 16550 compatible -- see the reference chain
> 
>  -> spt_uart_info -> uart_node -> uart_properties -> 
> "snps,uart-16550-compatible".
> 
> (2) While navigating the (graphical) Setup UI, I noticed that HII debug 
> messages *were* sent to the serial port, by this nice, graphical, Setup 
> Browser.
> 
> (3) The particular (non-Linux) kernel that I booted on this NUC could 
> flawlessly drive the serial port for input and output just by my 
> specification of the bog standard params baud-rate=115200, 8 data bits, no 
> parity, 1 stop bit.
> 
> That gave me the following idea:
> 
>> commit 0e794fe273b77830532ffb003b0d5539d7ae9823 (HEAD ->
>> nuc_serial_pkg)
>> Author: Laszlo Ersek 
>> Date:   Thu Apr 7 14:37:13 2022 +0200
>>
>> add NucSerialPkg: build SerialDxe and TerminalDxe for the
>> NUC8i3PNH
>>
>> Signed-off-by: Laszlo Ersek 
>>
>> diff --git a/NucSerialPkg/NucSerialPkg.dec
>> b/NucSerialPkg/NucSerialPkg.dec new file mode 100644 index
>> ..b077cde229c0
>> --- /dev/null
>> +++ b/NucSerialPkg/NucSerialPkg.dec
>> @@ -0,0 +1,13 @@
>> +## @file
>> +#  UART 16650 serial port driver build for the NUC8i3PNH.
>> +#
>> +#  Copyright (c) 2022, Red Hat, Inc.
>> +#
>> +#  SPDX-License-Identifier: BSD-2-Clause-Patent ##
>> +
>> +[Defines]
>> +  DEC_SPECIFICATION  = 1.29
>> +  PACKAGE_NAME   = NucSerialPkg
>> +  PACKAGE_GUID   = afdaaf17-4a06-4d97-a456-1ede0db46bc0
>> +  PACKAGE_VERSION= 0.1
>> diff --git a/NucSerialPkg/NucSerialPkg.dsc
>> b/NucSerialPkg/NucSerialPkg.dsc new file mode 100644 index
>> ..971fb2f96a43
>> --- /dev/null
>> +++ b/NucSerialPkg/NucSerialPkg.dsc
>> @@ -0,0 +1,46 @@
>> +## @file
>> +#  UART 16650 serial port driver build for the NUC8i3PNH.
>> +#
>> +#  Copyright (c) 2022, Red Hat, Inc.
>> +#
>> +#  SPDX-License-Identifier: BSD-2-Clause-Patent ##
>> +
>> +[Defines]
>> +  PLATFORM_NAME  = NucSerial
>> +  PLATFORM_GUID  = 30c397cf-a446-4f41-858f-9ae677547094
>> +  PLATFORM_VERSION   = 0.1
>> +  DSC_SPECIFICATION  = 1.30
>> +  OUTPUT_DIRECTORY   = Build/NucSerial
>> +  SUPPORTED_ARCHITECTURES= X64
>> +  BUILD_TARGETS  = NOOPT|DEBUG|RELEASE
>> +  SKUID_IDENTIFIER   = DEFAULT
>> +
>> +[BuildOptions]
>> +  GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
>> +  RELEASE_*_*_GENFW_FLAGS  = --zero
>> +  GCC:*_*_*_CC_FLAGS   = -D DISABLE_NEW_DEPRECATED_INTERFACES
>> +
>> +[LibraryClasses]
>> +  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
>> +  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
>> +  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
>> +
>> 

Re: 回复: [edk2-devel] [PATCH v3 0/5] Http Fixes (Take Two)

2022-04-08 Thread Maciej Rabeda

Alright.

Reviewed-by: Maciej Rabeda 

Merge soon.

On 7 kwi 2022 14:55, Oliver Steffen wrote:

On Thu, Apr 7, 2022 at 2:46 PM Rabeda, Maciej
 wrote:


1. In HttpResponseWorker():

  if (AsciiStrnCmp (HttpHeaders, "HTTP/1.0", AsciiStrLen
("HTTP/1.0")) == 0) {
DEBUG ((DEBUG_VERBOSE, "HTTP: Server version is 1.0. Setting
Connection close.\n"));
HttpInstance->ConnectionClose = TRUE;
  }

I'd change AsciiStrLen ("HTTP/1.0") to sizeof("HTTP/1.0") - 1. No need
to call a AsciiStrLen every time this flow is executed, it is easily a
compile-time thing.

Yes, of course.


2. In HttpResponseWorker(), index -> Index, coding standard.

Sorry, I missed that one.


I can merge this patch with changes above one I get an ACK from you.

Sounds good to me. Thank you!

-- Oliver









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




[edk2-devel] [PATCH v3 4/6] OvmfPkg/VirtioGpuDxe: use GopQueryMode in GopSetMode

2022-04-08 Thread Gerd Hoffmann
Call GopQueryMode() in GopSetMode(), use the ModeInfo returned when
setting the mode.  This is needed to properly handle modes which are
not on the static mGopResolutions list.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/VirtioGpuDxe/Gop.c | 60 --
 1 file changed, 31 insertions(+), 29 deletions(-)

diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c
index 2c15d542e3b1..337a7e19bffa 100644
--- a/OvmfPkg/VirtioGpuDxe/Gop.c
+++ b/OvmfPkg/VirtioGpuDxe/Gop.c
@@ -234,19 +234,22 @@ GopSetMode (
   IN  UINT32ModeNumber
   )
 {
-  VGPU_GOP  *VgpuGop;
-  UINT32NewResourceId;
-  UINTN NewNumberOfBytes;
-  UINTN NewNumberOfPages;
-  VOID  *NewBackingStore;
-  EFI_PHYSICAL_ADDRESS  NewBackingStoreDeviceAddress;
-  VOID  *NewBackingStoreMap;
+  VGPU_GOP  *VgpuGop;
+  UINT32NewResourceId;
+  UINTN NewNumberOfBytes;
+  UINTN NewNumberOfPages;
+  VOID  *NewBackingStore;
+  EFI_PHYSICAL_ADDRESS  NewBackingStoreDeviceAddress;
+  VOID  *NewBackingStoreMap;
+  UINTN SizeOfInfo;
+  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *GopModeInfo;
 
   EFI_STATUS  Status;
   EFI_STATUS  Status2;
 
-  if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) {
-return EFI_UNSUPPORTED;
+  Status = GopQueryMode (This, ModeNumber, , );
+  if (Status != EFI_SUCCESS) {
+return Status;
   }
 
   VgpuGop = VGPU_GOP_FROM_GOP (This);
@@ -292,8 +295,8 @@ GopSetMode (
  VgpuGop->ParentBus,// VgpuDev
  NewResourceId, // ResourceId
  VirtioGpuFormatB8G8R8X8Unorm,  // Format
- mGopResolutions[ModeNumber].Width, // Width
- mGopResolutions[ModeNumber].Height // Height
+ GopModeInfo->HorizontalResolution, // Width
+ GopModeInfo->VerticalResolution// Height
  );
   if (EFI_ERROR (Status)) {
 return Status;
@@ -303,8 +306,8 @@ GopSetMode (
   // Allocate, zero and map guest backing store, for bus master common buffer
   // operation.
   //
-  NewNumberOfBytes = mGopResolutions[ModeNumber].Width *
- mGopResolutions[ModeNumber].Height * sizeof (UINT32);
+  NewNumberOfBytes = GopModeInfo->HorizontalResolution *
+ GopModeInfo->VerticalResolution * sizeof (UINT32);
   NewNumberOfPages = EFI_SIZE_TO_PAGES (NewNumberOfBytes);
   Status   = VirtioGpuAllocateZeroAndMapBackingStore (
VgpuGop->ParentBus,// VgpuDev
@@ -337,8 +340,8 @@ GopSetMode (
  VgpuGop->ParentBus, // VgpuDev
  0,  // X
  0,  // Y
- mGopResolutions[ModeNumber].Width,  // Width
- mGopResolutions[ModeNumber].Height, // Height
+ GopModeInfo->HorizontalResolution,  // Width
+ GopModeInfo->VerticalResolution,// Height
  0,  // ScanoutId
  NewResourceId   // ResourceId
  );
@@ -356,8 +359,8 @@ GopSetMode (
VgpuGop->ParentBus, // VgpuDev
0,  // X
0,  // Y
-   mGopResolutions[ModeNumber].Width,  // Width
-   mGopResolutions[ModeNumber].Height, // Height
+   GopModeInfo->HorizontalResolution,  // Width
+   GopModeInfo->VerticalResolution,// Height
NewResourceId   // ResourceId
);
 if (EFI_ERROR (Status)) {
@@ -367,13 +370,13 @@ GopSetMode (
   // therefore non-recoverable.
   //
   Status2 = VirtioGpuSetScanout (
-  VgpuGop->ParentBus,   // VgpuDev
-  0,// X
-  0,// Y
-  mGopResolutions[This->Mode->Mode].Width,  // Width
-  mGopResolutions[This->Mode->Mode].Height, // Height
-  0,// ScanoutId
-  VgpuGop->ResourceId   // ResourceId
+  VgpuGop->ParentBus,// VgpuDev
+  0, // X
+  0, // Y
+  VgpuGop->GopModeInfo.HorizontalResolution, // Width
+  VgpuGop->GopModeInfo.VerticalResolution,   // Height
+  0,  

[edk2-devel] [PATCH v3 6/6] OvmfPkg/VirtioGpuDxe: query native display resolution from host

2022-04-08 Thread Gerd Hoffmann
Try query native display resolution from the host.  When successfull
setup PcdVideoHorizontalResolution and PcdVideoVerticalResolution
accordingly and add the video mode to the GOP mode list if needed.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/VirtioGpuDxe/VirtioGpu.inf |  6 ++
 OvmfPkg/VirtioGpuDxe/VirtioGpu.h   |  6 ++
 OvmfPkg/VirtioGpuDxe/Gop.c | 92 --
 3 files changed, 99 insertions(+), 5 deletions(-)

diff --git a/OvmfPkg/VirtioGpuDxe/VirtioGpu.inf 
b/OvmfPkg/VirtioGpuDxe/VirtioGpu.inf
index 9e66bcd4b97f..d88c87e129f0 100644
--- a/OvmfPkg/VirtioGpuDxe/VirtioGpu.inf
+++ b/OvmfPkg/VirtioGpuDxe/VirtioGpu.inf
@@ -25,6 +25,7 @@ [Sources]
 
 [Packages]
   MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
   OvmfPkg/OvmfPkg.dec
 
 [LibraryClasses]
@@ -43,3 +44,8 @@ [Protocols]
   gEfiGraphicsOutputProtocolGuid ## BY_START
   gEfiPciIoProtocolGuid  ## TO_START
   gVirtioDeviceProtocolGuid  ## TO_START
+
+[Pcd]
+  gUefiOvmfPkgTokenSpaceGuid.PcdVideoResolutionSource
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution
diff --git a/OvmfPkg/VirtioGpuDxe/VirtioGpu.h b/OvmfPkg/VirtioGpuDxe/VirtioGpu.h
index 1d781088bb3f..45da56415297 100644
--- a/OvmfPkg/VirtioGpuDxe/VirtioGpu.h
+++ b/OvmfPkg/VirtioGpuDxe/VirtioGpu.h
@@ -151,6 +151,12 @@ struct VGPU_GOP_STRUCT {
   // BackingStore is non-NULL.
   //
   VOID*BackingStoreMap;
+
+  //
+  // native display resolution
+  //
+  UINT32  NativeXRes;
+  UINT32  NativeYRes;
 };
 
 //
diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c
index 05daefcbfbc8..70a81c10c8b5 100644
--- a/OvmfPkg/VirtioGpuDxe/Gop.c
+++ b/OvmfPkg/VirtioGpuDxe/Gop.c
@@ -9,6 +9,7 @@
 **/
 
 #include 
+#include 
 
 #include "VirtioGpu.h"
 
@@ -192,6 +193,47 @@ STATIC CONST GOP_RESOLUTION  mGopResolutions[] = {
 #define VGPU_GOP_FROM_GOP(GopPointer) \
   CR (GopPointer, VGPU_GOP, Gop, VGPU_GOP_SIG)
 
+STATIC
+VOID
+EFIAPI
+GopNativeResolution (
+  IN  VGPU_GOP  *VgpuGop,
+  OUT UINT32*XRes,
+  OUT UINT32*YRes
+  )
+{
+  volatile VIRTIO_GPU_RESP_DISPLAY_INFO  DisplayInfo;
+  EFI_STATUS Status;
+  UINTN  Index;
+
+  Status = VirtioGpuGetDisplayInfo (VgpuGop->ParentBus, );
+  if (Status != EFI_SUCCESS) {
+return;
+  }
+
+  for (Index = 0; Index < VIRTIO_GPU_MAX_SCANOUTS; Index++) {
+if (!DisplayInfo.Pmodes[Index].Enabled ||
+!DisplayInfo.Pmodes[Index].Rectangle.Width ||
+!DisplayInfo.Pmodes[Index].Rectangle.Height)
+{
+  continue;
+}
+
+DEBUG ((
+  DEBUG_INFO,
+  "%a: #%d: %dx%d\n",
+  __FUNCTION__,
+  Index,
+  DisplayInfo.Pmodes[Index].Rectangle.Width,
+  DisplayInfo.Pmodes[Index].Rectangle.Height
+  ));
+if ((*XRes == 0) || (*YRes == 0)) {
+  *XRes = DisplayInfo.Pmodes[Index].Rectangle.Width;
+  *YRes = DisplayInfo.Pmodes[Index].Rectangle.Height;
+}
+  }
+}
+
 STATIC
 VOID
 EFIAPI
@@ -199,7 +241,9 @@ GopInitialize (
   IN  EFI_GRAPHICS_OUTPUT_PROTOCOL  *This
   )
 {
-  VGPU_GOP  *VgpuGop;
+  VGPU_GOP*VgpuGop;
+  EFI_STATUS  Status;
+  UINT32  XRes = 0, YRes = 0, Index;
 
   VgpuGop = VGPU_GOP_FROM_GOP (This);
 
@@ -216,6 +260,37 @@ GopInitialize (
   VgpuGop->GopMode.SizeOfInfo = sizeof VgpuGop->GopModeInfo;
 
   VgpuGop->GopModeInfo.PixelFormat = PixelBltOnly;
+
+  //
+  // query host for display resolution
+  //
+  GopNativeResolution (VgpuGop, , );
+  if ((XRes == 0) || (YRes == 0)) {
+return;
+  }
+
+  if (PcdGet8 (PcdVideoResolutionSource) == 0) {
+Status = PcdSet32S (PcdVideoHorizontalResolution, XRes);
+ASSERT_RETURN_ERROR (Status);
+Status = PcdSet32S (PcdVideoVerticalResolution, YRes);
+ASSERT_RETURN_ERROR (Status);
+Status = PcdSet8S (PcdVideoResolutionSource, 2);
+ASSERT_RETURN_ERROR (Status);
+  }
+
+  VgpuGop->NativeXRes = XRes;
+  VgpuGop->NativeYRes = YRes;
+  for (Index = 0; Index < ARRAY_SIZE (mGopResolutions); Index++) {
+if ((mGopResolutions[Index].Width == XRes) &&
+(mGopResolutions[Index].Height == YRes))
+{
+  // native resolution already is in mode list
+  return;
+}
+  }
+
+  // add to mode list
+  VgpuGop->GopMode.MaxMode++;
 }
 
 //
@@ -242,10 +317,17 @@ GopQueryMode (
 return EFI_OUT_OF_RESOURCES;
   }
 
-  GopModeInfo->HorizontalResolution = mGopResolutions[ModeNumber].Width;
-  GopModeInfo->VerticalResolution   = mGopResolutions[ModeNumber].Height;
-  GopModeInfo->PixelFormat  = PixelBltOnly;
-  GopModeInfo->PixelsPerScanLine= mGopResolutions[ModeNumber].Width;
+  if (ModeNumber < ARRAY_SIZE (mGopResolutions)) {
+GopModeInfo->HorizontalResolution = mGopResolutions[ModeNumber].Width;
+GopModeInfo->VerticalResolution   = mGopResolutions[ModeNumber].Height;
+  } else {
+VGPU_GOP  *VgpuGop = 

[edk2-devel] [PATCH v3 5/6] OvmfPkg/VirtioGpuDxe: move code to GopInitialize

2022-04-08 Thread Gerd Hoffmann
Add new function to initialize the GOP, move over setup code.  Handle
initialization first, specifically before calling GopQueryMode(), so
GopQueryMode is never called before GopInitialize() did complete.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/VirtioGpuDxe/Gop.c | 47 ++
 1 file changed, 32 insertions(+), 15 deletions(-)

diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c
index 337a7e19bffa..05daefcbfbc8 100644
--- a/OvmfPkg/VirtioGpuDxe/Gop.c
+++ b/OvmfPkg/VirtioGpuDxe/Gop.c
@@ -192,6 +192,32 @@ STATIC CONST GOP_RESOLUTION  mGopResolutions[] = {
 #define VGPU_GOP_FROM_GOP(GopPointer) \
   CR (GopPointer, VGPU_GOP, Gop, VGPU_GOP_SIG)
 
+STATIC
+VOID
+EFIAPI
+GopInitialize (
+  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL  *This
+  )
+{
+  VGPU_GOP  *VgpuGop;
+
+  VgpuGop = VGPU_GOP_FROM_GOP (This);
+
+  //
+  // Set up the Gop -> GopMode -> GopModeInfo pointer chain, and the other
+  // (nonzero) constant fields.
+  //
+  // No direct framebuffer access is supported, only Blt() is.
+  //
+  VgpuGop->Gop.Mode = >GopMode;
+
+  VgpuGop->GopMode.MaxMode= (UINT32)(ARRAY_SIZE (mGopResolutions));
+  VgpuGop->GopMode.Info   = >GopModeInfo;
+  VgpuGop->GopMode.SizeOfInfo = sizeof VgpuGop->GopModeInfo;
+
+  VgpuGop->GopModeInfo.PixelFormat = PixelBltOnly;
+}
+
 //
 // EFI_GRAPHICS_OUTPUT_PROTOCOL member functions.
 //
@@ -207,7 +233,7 @@ GopQueryMode (
 {
   EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *GopModeInfo;
 
-  if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) {
+  if (ModeNumber >= This->Mode->MaxMode) {
 return EFI_INVALID_PARAMETER;
   }
 
@@ -247,6 +273,11 @@ GopSetMode (
   EFI_STATUS  Status;
   EFI_STATUS  Status2;
 
+  if (!This->Mode) {
+// SetMode() call in InitVgpuGop() triggers this.
+GopInitialize (This);
+  }
+
   Status = GopQueryMode (This, ModeNumber, , );
   if (Status != EFI_SUCCESS) {
 return Status;
@@ -259,20 +290,6 @@ GopSetMode (
   // calls.
   //
   if (VgpuGop->ResourceId == 0) {
-//
-// Set up the Gop -> GopMode -> GopModeInfo pointer chain, and the other
-// (nonzero) constant fields.
-//
-// No direct framebuffer access is supported, only Blt() is.
-//
-VgpuGop->Gop.Mode = >GopMode;
-
-VgpuGop->GopMode.MaxMode= (UINT32)(ARRAY_SIZE (mGopResolutions));
-VgpuGop->GopMode.Info   = >GopModeInfo;
-VgpuGop->GopMode.SizeOfInfo = sizeof VgpuGop->GopModeInfo;
-
-VgpuGop->GopModeInfo.PixelFormat = PixelBltOnly;
-
 //
 // This is the first time we create a host side resource.
 //
-- 
2.35.1



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




[edk2-devel] [PATCH v3 2/6] OvmfPkg/VirtioGpuDxe: add GetDisplayInfo to virtio-gpu spec header.

2022-04-08 Thread Gerd Hoffmann
Add GetDisplayInfo command, reply and data struct to the
virtio-gpu specification header file.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/Include/IndustryStandard/VirtioGpu.h | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/Include/IndustryStandard/VirtioGpu.h 
b/OvmfPkg/Include/IndustryStandard/VirtioGpu.h
index 12559ccef5b1..13f719d4c0f2 100644
--- a/OvmfPkg/Include/IndustryStandard/VirtioGpu.h
+++ b/OvmfPkg/Include/IndustryStandard/VirtioGpu.h
@@ -37,6 +37,7 @@ typedef enum {
   //
   // - create/release a host-side 2D resource,
   //
+  VirtioGpuCmdGetDisplayInfo   = 0x0100,
   VirtioGpuCmdResourceCreate2d = 0x0101,
   VirtioGpuCmdResourceUnref= 0x0102,
   //
@@ -64,7 +65,8 @@ typedef enum {
   //
   // Success code for all of the above commands.
   //
-  VirtioGpuRespOkNodata = 0x1100,
+  VirtioGpuRespOkNodata  = 0x1100,
+  VirtioGpuRespOkDisplayInfo = 0x1101,
 } VIRTIO_GPU_CONTROL_TYPE;
 
 //
@@ -207,4 +209,19 @@ typedef struct {
 } VIRTIO_GPU_RESOURCE_FLUSH;
 #pragma pack ()
 
+//
+// Response structure for VirtioGpuCmdGetDisplayInfo
+//
+#define VIRTIO_GPU_MAX_SCANOUTS  16
+#pragma pack (1)
+typedef struct {
+  VIRTIO_GPU_CONTROL_HEADERHeader;
+  struct {
+VIRTIO_GPU_RECTANGLERectangle;
+UINT32  Enabled;
+UINT32  Flags;
+  } Pmodes[VIRTIO_GPU_MAX_SCANOUTS];
+} VIRTIO_GPU_RESP_DISPLAY_INFO;
+#pragma pack ()
+
 #endif // _VIRTIO_GPU_H_
-- 
2.35.1



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




[edk2-devel] [PATCH v3 3/6] OvmfPkg/VirtioGpuDxe: add VirtioGpuGetDisplayInfo

2022-04-08 Thread Gerd Hoffmann
Add support for sending a GetDisplayInfo command.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/VirtioGpuDxe/VirtioGpu.h |  6 ++
 OvmfPkg/VirtioGpuDxe/Commands.c  | 20 
 2 files changed, 26 insertions(+)

diff --git a/OvmfPkg/VirtioGpuDxe/VirtioGpu.h b/OvmfPkg/VirtioGpuDxe/VirtioGpu.h
index 2155b261d43e..1d781088bb3f 100644
--- a/OvmfPkg/VirtioGpuDxe/VirtioGpu.h
+++ b/OvmfPkg/VirtioGpuDxe/VirtioGpu.h
@@ -366,6 +366,12 @@ VirtioGpuResourceFlush (
   IN UINT32ResourceId
   );
 
+EFI_STATUS
+VirtioGpuGetDisplayInfo (
+  IN OUT VGPU_DEV*VgpuDev,
+  volatile VIRTIO_GPU_RESP_DISPLAY_INFO  *Response
+  );
+
 /**
   Release guest-side and host-side resources that are related to an initialized
   VGPU_GOP.Gop.
diff --git a/OvmfPkg/VirtioGpuDxe/Commands.c b/OvmfPkg/VirtioGpuDxe/Commands.c
index b9a3ea923021..4318d3d771c5 100644
--- a/OvmfPkg/VirtioGpuDxe/Commands.c
+++ b/OvmfPkg/VirtioGpuDxe/Commands.c
@@ -828,3 +828,23 @@ VirtioGpuResourceFlush (
sizeof Request
);
 }
+
+EFI_STATUS
+VirtioGpuGetDisplayInfo (
+  IN OUT VGPU_DEV*VgpuDev,
+  volatile VIRTIO_GPU_RESP_DISPLAY_INFO  *Response
+  )
+{
+  volatile VIRTIO_GPU_CONTROL_HEADER  Request;
+
+  return VirtioGpuSendCommandWithReply (
+   VgpuDev,
+   VirtioGpuCmdGetDisplayInfo,
+   FALSE, // Fence
+   ,
+   sizeof Request,
+   VirtioGpuRespOkDisplayInfo,
+   >Header,
+   sizeof *Response
+   );
+}
-- 
2.35.1



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




[edk2-devel] [PATCH v3 0/6] OvmfPkg/VirtioGpuDxe: use host display resolution

2022-04-08 Thread Gerd Hoffmann
QemuVideoDxe recently got support for picking up
display resolution configuration from the host.
This series does the same for VirtioGpuDxe.

v3:
 - rebase to latest master.

Gerd Hoffmann (6):
  OvmfPkg/VirtioGpuDxe: add VirtioGpuSendCommandWithReply
  OvmfPkg/VirtioGpuDxe: add GetDisplayInfo to virtio-gpu spec header.
  OvmfPkg/VirtioGpuDxe: add VirtioGpuGetDisplayInfo
  OvmfPkg/VirtioGpuDxe: use GopQueryMode in GopSetMode
  OvmfPkg/VirtioGpuDxe: move code to GopInitialize
  OvmfPkg/VirtioGpuDxe: query native display resolution from host

 OvmfPkg/VirtioGpuDxe/VirtioGpu.inf   |   6 +
 OvmfPkg/Include/IndustryStandard/VirtioGpu.h |  19 +-
 OvmfPkg/VirtioGpuDxe/VirtioGpu.h |  12 ++
 OvmfPkg/VirtioGpuDxe/Commands.c  |  95 +++--
 OvmfPkg/VirtioGpuDxe/Gop.c   | 197 ++-
 5 files changed, 262 insertions(+), 67 deletions(-)

-- 
2.35.1



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




[edk2-devel] [PATCH v3 1/6] OvmfPkg/VirtioGpuDxe: add VirtioGpuSendCommandWithReply

2022-04-08 Thread Gerd Hoffmann
Extend VirtioGpuSendCommand() to support commands which return data,
rename the function to VirtioGpuSendCommandWithReply() to indicate that.

Add a new VirtioGpuSendCommand() function which is just a thin wrapper
around VirtioGpuSendCommandWithReply() so existing code continues to
work without changes.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/VirtioGpuDxe/Commands.c | 75 +
 1 file changed, 57 insertions(+), 18 deletions(-)

diff --git a/OvmfPkg/VirtioGpuDxe/Commands.c b/OvmfPkg/VirtioGpuDxe/Commands.c
index 873a71656700..b9a3ea923021 100644
--- a/OvmfPkg/VirtioGpuDxe/Commands.c
+++ b/OvmfPkg/VirtioGpuDxe/Commands.c
@@ -393,6 +393,14 @@ VirtioGpuExitBoot (
   @param[in] RequestSize  Size of the entire caller-allocated request object,
   including the leading VIRTIO_GPU_CONTROL_HEADER.
 
+  @param[in] ResponseType The type of the response (VirtioGpuResp*).
+
+  @param[in,out] Response Pointer to the caller-allocated response object. The
+  request must start with VIRTIO_GPU_CONTROL_HEADER.
+
+  @param[in] ResponseSize Size of the entire caller-allocated response object,
+  including the leading VIRTIO_GPU_CONTROL_HEADER.
+
   @retval EFI_SUCCESSOperation successful.
 
   @retval EFI_DEVICE_ERROR   The host rejected the request. The host error
@@ -404,22 +412,24 @@ VirtioGpuExitBoot (
 **/
 STATIC
 EFI_STATUS
-VirtioGpuSendCommand (
+VirtioGpuSendCommandWithReply (
   IN OUT VGPU_DEV*VgpuDev,
   IN VIRTIO_GPU_CONTROL_TYPE RequestType,
   IN BOOLEAN Fence,
   IN OUT volatile VIRTIO_GPU_CONTROL_HEADER  *Header,
-  IN UINTN   RequestSize
+  IN UINTN   RequestSize,
+  IN VIRTIO_GPU_CONTROL_TYPE ResponseType,
+  IN OUT volatile VIRTIO_GPU_CONTROL_HEADER  *Response,
+  IN UINTN   ResponseSize
   )
 {
-  DESC_INDICESIndices;
-  volatile VIRTIO_GPU_CONTROL_HEADER  Response;
-  EFI_STATUS  Status;
-  UINT32  ResponseSize;
-  EFI_PHYSICAL_ADDRESSRequestDeviceAddress;
-  VOID*RequestMap;
-  EFI_PHYSICAL_ADDRESSResponseDeviceAddress;
-  VOID*ResponseMap;
+  DESC_INDICES  Indices;
+  EFI_STATUSStatus;
+  UINT32ResponseSizeRet;
+  EFI_PHYSICAL_ADDRESS  RequestDeviceAddress;
+  VOID  *RequestMap;
+  EFI_PHYSICAL_ADDRESS  ResponseDeviceAddress;
+  VOID  *ResponseMap;
 
   //
   // Initialize Header.
@@ -457,8 +467,8 @@ VirtioGpuSendCommand (
   Status = VirtioMapAllBytesInSharedBuffer (
  VgpuDev->VirtIo,
  VirtioOperationBusMasterWrite,
- (VOID *),
- sizeof Response,
+ (VOID *)Response,
+ ResponseSize,
  ,
  
  );
@@ -480,7 +490,7 @@ VirtioGpuSendCommand (
   VirtioAppendDesc (
 >Ring,
 ResponseDeviceAddress,
-(UINT32)sizeof Response,
+(UINT32)ResponseSize,
 VRING_DESC_F_WRITE,
 
 );
@@ -493,7 +503,7 @@ VirtioGpuSendCommand (
  VIRTIO_GPU_CONTROL_QUEUE,
  >Ring,
  ,
- 
+ 
  );
   if (EFI_ERROR (Status)) {
 goto UnmapResponse;
@@ -502,7 +512,7 @@ VirtioGpuSendCommand (
   //
   // Verify response size.
   //
-  if (ResponseSize != sizeof Response) {
+  if (ResponseSize != ResponseSizeRet) {
 DEBUG ((
   DEBUG_ERROR,
   "%a: malformed response to Request=0x%x\n",
@@ -531,16 +541,17 @@ VirtioGpuSendCommand (
   //
   // Parse the response.
   //
-  if (Response.Type == VirtioGpuRespOkNodata) {
+  if (Response->Type == (UINT32)ResponseType) {
 return EFI_SUCCESS;
   }
 
   DEBUG ((
 DEBUG_ERROR,
-"%a: Request=0x%x Response=0x%x\n",
+"%a: Request=0x%x Response=0x%x (expected 0x%x)\n",
 __FUNCTION__,
 (UINT32)RequestType,
-Response.Type
+Response->Type,
+ResponseType
 ));
   return EFI_DEVICE_ERROR;
 
@@ -553,6 +564,34 @@ VirtioGpuSendCommand (
   return Status;
 }
 
+/**
+  Simplified version of VirtioGpuSendCommandWithReply() for commands
+  which do not send back any data.
+**/
+STATIC
+EFI_STATUS
+VirtioGpuSendCommand (
+  IN OUT VGPU_DEV*VgpuDev,
+  IN VIRTIO_GPU_CONTROL_TYPE RequestType,
+  IN BOOLEAN Fence,
+  IN OUT volatile VIRTIO_GPU_CONTROL_HEADER  *Header,
+  IN UINTN   RequestSize
+  )
+{
+  volatile VIRTIO_GPU_CONTROL_HEADER  Response;
+
+  return VirtioGpuSendCommandWithReply (
+   VgpuDev,
+   RequestType,
+   Fence,
+   Header,
+   RequestSize,
+   

[edk2-devel] [PATCH 1/1] OvmfPkg: restore CompatImageLoaderDxe chunk

2022-04-08 Thread Gerd Hoffmann
Was dropped by accident.

Fixes: b47575801e19 ("OvmfPkg: move tcg configuration to dsc and fdf include 
files")
Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/OvmfPkgIa32.dsc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index e4218b01f0fc..073e67d94ed1 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -1004,3 +1004,6 @@ [Components]
   #
 !include OvmfPkg/OvmfTpmComponentsDxe.dsc.inc
 
+!if $(LOAD_X64_ON_IA32_ENABLE) == TRUE
+  OvmfPkg/CompatImageLoaderDxe/CompatImageLoaderDxe.inf
+!endif
-- 
2.35.1



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




[edk2-devel] [PATCH v4] OvmfPkg/BhyveBhfPkg: add support for QemuFwCfg

2022-04-08 Thread Corvin Köhne
From: Corvin Köhne 

QemuFwCfg is much more powerful than BhyveFwCtl. Sadly, BhyveFwCtl
decided to use the same IO ports as QemuFwCfg. It's not possible to use
both interfaces simultaneously. So, prefer QemuFwCfg over BhyveFwCtl.

Signed-off-by: Corvin Köhne 
Acked-by: Gerd Hoffmann 
Acked-by: Rebecca Cran 
Acked-by: Peter Grehan 
Acked-by: Jiewen Yao 
CC: Ard Biesheuvel 
CC: Jordan Justen 
CC: devel@edk2.groups.io
CC: FreeBSD Virtualization 
---
 OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf |  1 +
 OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c | 41 ---
 OvmfPkg/Bhyve/BhyveX64.dsc|  4 +--
 3 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf 
b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
index 595fd055f9..94c65f32dc 100644
--- a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
+++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
@@ -43,6 +43,7 @@
   MemoryAllocationLib
   OrderedCollectionLib
   PcdLib
+  QemuFwCfgLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
   UefiLib
diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c 
b/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c
index 8e80aa33e1..e216a21bfa 100644
--- a/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c
+++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c
@@ -11,6 +11,41 @@
 #include 
 #include 
 #include 
+#include  // QemuFwCfgFindFile()
+
+STATIC
+EFI_STATUS
+EFIAPI
+BhyveGetCpuCount (
+  OUT UINT32  *CpuCount
+  )
+{
+  FIRMWARE_CONFIG_ITEM  Item;
+  UINTN Size;
+
+  if (QemuFwCfgIsAvailable ()) {
+if (EFI_ERROR (QemuFwCfgFindFile ("opt/bhyve/hw.ncpu", , ))) {
+  return EFI_NOT_FOUND;
+} else if (Size != sizeof (*CpuCount)) {
+  return EFI_BAD_BUFFER_SIZE;
+}
+
+QemuFwCfgSelectItem (Item);
+QemuFwCfgReadBytes (Size, CpuCount);
+
+return EFI_SUCCESS;
+  }
+
+  //
+  // QemuFwCfg not available, try BhyveFwCtl.
+  //
+  Size = sizeof (*CpuCount);
+  if (BhyveFwCtlGet ("hw.ncpu", CpuCount, ) == RETURN_SUCCESS) {
+return EFI_SUCCESS;
+  }
+
+  return EFI_UNSUPPORTED;
+}
 
 STATIC
 EFI_STATUS
@@ -23,7 +58,6 @@ BhyveInstallAcpiMadtTable (
   )
 {
   UINT32   CpuCount;
-  UINTNcSize;
   UINTNNewBufferSize;
   EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER  *Madt;
   EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC_STRUCTURE  *LocalApic;
@@ -36,9 +70,8 @@ BhyveInstallAcpiMadtTable (
   ASSERT (AcpiTableBufferSize >= sizeof (EFI_ACPI_DESCRIPTION_HEADER));
 
   // Query the host for the number of vCPUs
-  CpuCount = 0;
-  cSize= sizeof (CpuCount);
-  if (BhyveFwCtlGet ("hw.ncpu", , ) == RETURN_SUCCESS) {
+  Status = BhyveGetCpuCount ();
+  if (!EFI_ERROR (Status)) {
 DEBUG ((DEBUG_INFO, "Retrieved CpuCount %d\n", CpuCount));
 ASSERT (CpuCount >= 1);
   } else {
diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index 5fa08bebd7..14070fd6dd 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -163,8 +163,7 @@
   
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
   UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
   
SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf
-  QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibNull.inf
-  QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf
+  QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxeLib.inf
   BhyveFwCtlLib|OvmfPkg/Library/BhyveFwCtlLib/BhyveFwCtlLib.inf
   VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
@@ -355,6 +354,7 @@
 !endif
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
   MpInitLib|UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.inf
+  QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
 
 [LibraryClasses.common.UEFI_APPLICATION]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-- 
2.11.0

Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Beckhoff
Registered office: Verl, Germany | Register court: Guetersloh HRA 7075





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88603): https://edk2.groups.io/g/devel/message/88603
Mute This Topic: https://groups.io/mt/90331362/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 4/8] OvmfPkg/IntelTdx: Measure Td HobList and Configuration FV

2022-04-08 Thread Min Xu
On April 8, 2022 3:44 PM, Yao Jiewen wrote:
> 
> Can we use a SecMeasurementLib here? Instead of implementing all things in
> Startup.
> 
Yes. SecMeasurementLib will be provided in the next version.

Thanks
Min


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88602): https://edk2.groups.io/g/devel/message/88602
Mute This Topic: https://groups.io/mt/90330666/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/8] Security: Add HashLibBaseCryptoRouterTdx

2022-04-08 Thread Min Xu
On April 8, 2022 3:42 PM, Yao Jiewen wrote:
> 
> I am not sure if we really need router here.
> TDX only supports SHA384. What if we just provide HashLibTdx?
>
Sure. It will be updated in the next version.

Thanks
Min


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88601): https://edk2.groups.io/g/devel/message/88601
Mute This Topic: https://groups.io/mt/90330662/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 2/8] CryptoPkg: Add SecCryptLib

2022-04-08 Thread Min Xu
On April 8, 2022 3:36 PM, Yao Jiewen wrote:
> 
> Hi
> The rule for lib instance is: It must provide all interfaces defined in .h 
> file.
> 
> As such, please use NULL version other algorithms in SEC instance.
> 
Thanks for reminder. It will be updated in the next version.

Thanks
Min



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




Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 23/33] MdePkg/BaseIoLibIntrinsic: IoLibNoIo for LoongArch architecture.

2022-04-08 Thread Abner Chang
Acked-by: Abner Chang 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chao Li
> Sent: Wednesday, February 9, 2022 2:56 PM
> To: devel@edk2.groups.io
> Cc: Michael D Kinney ; Liming Gao
> ; Zhiguang Liu 
> Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 23/33]
> MdePkg/BaseIoLibIntrinsic: IoLibNoIo for LoongArch architecture.
> 
> LoongArch MMIO library instance, use the IoLibNoIo.
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> 
> Signed-off-by: Chao Li 
> ---
>  .../Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf  | 10 +++---
>  MdePkg/Library/BaseIoLibIntrinsic/IoLibNoIo.c  |  3 ++-
>  2 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
> b/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
> index 97eeada065..f668d4f2d7 100644
> --- a/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
> +++ b/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
> @@ -4,13 +4,14 @@
>  #  I/O Library that uses compiler intrinsics to perform IN and OUT 
> instructions
>  #  for IA-32 and x64.  On IPF, I/O port requests are translated into MMIO
> requests.
>  #  MMIO requests are forwarded directly to memory.  For EBC, I/O port
> requests
> -#  ASSERT(). For ARM, AARCH64 and RISCV64, this I/O library only provides
> non I/O
> -#  read and write.
> +#  ASSERT(). For ARM, AARCH64, RISCV64 and LoongArch, this I/O library
> only provides
> +#  non I/O read and write.
>  #
>  #  Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.
>  #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
>  #  Copyright (c) 2017, AMD Incorporated. All rights reserved.
>  #  Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP.
> All rights reserved.
> +#  Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All
> rights reserved.
>  #
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
>  #
> @@ -27,7 +28,7 @@
> 
> 
>  #
> -#  VALID_ARCHITECTURES   = IA32 X64 EBC ARM AARCH64 RISCV64
> +#  VALID_ARCHITECTURES   = IA32 X64 EBC ARM AARCH64 RISCV64
> LOONGARCH64
>  #
> 
>  [Sources]
> @@ -60,6 +61,9 @@
>  [Sources.RISCV64]
>IoLibNoIo.c
> 
> +[Sources.LOONGARCH64]
> +  IoLibNoIo.c
> +
>  [Packages]
>MdePkg/MdePkg.dec
> 
> diff --git a/MdePkg/Library/BaseIoLibIntrinsic/IoLibNoIo.c
> b/MdePkg/Library/BaseIoLibIntrinsic/IoLibNoIo.c
> index c71f45b22e..c51e5da39b 100644
> --- a/MdePkg/Library/BaseIoLibIntrinsic/IoLibNoIo.c
> +++ b/MdePkg/Library/BaseIoLibIntrinsic/IoLibNoIo.c
> @@ -1,11 +1,12 @@
>  /** @file
>I/O library for non I/O read and write access (memory map I/O read and
> -  write only) architecture, such as ARM and RISC-V processor.
> +  write only) architecture, such as ARM, RISC-V and LoongArch processor.
> 
>Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
>Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
>Copyright (c) 2017, AMD Incorporated. All rights reserved.
>Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights
> reserved.
> +  Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> reserved.
> 
>SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> --
> 2.27.0
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 22/33] MdePkg/BaseCacheMaintenanceLib: LoongArch cache maintenance implementation.

2022-04-08 Thread Abner Chang
Acked-by: Abner Chang 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chao Li
> Sent: Wednesday, February 9, 2022 2:56 PM
> To: devel@edk2.groups.io
> Cc: Michael D Kinney ; Liming Gao
> ; Zhiguang Liu 
> Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 22/33]
> MdePkg/BaseCacheMaintenanceLib: LoongArch cache maintenance
> implementation.
> 
> Implement LoongArch cache maintenance functions in
> BaseCacheMaintenanceLib.
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> 
> Signed-off-by: Chao Li 
> ---
>  .../BaseCacheMaintenanceLib.inf   |   4 +
>  .../BaseCacheMaintenanceLib/LoongArchCache.c  | 253
> ++
>  2 files changed, 257 insertions(+)
>  create mode 100644
> MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> 
> diff --git
> a/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.in
> f
> b/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.in
> f
> index 33114243d5..e103705b2c 100644
> ---
> a/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.in
> f
> +++
> b/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.in
> f
> @@ -7,6 +7,7 @@
>  #  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
>  #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
>  #  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights
> reserved.
> +#  Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> reserved.
>  #
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
>  #
> @@ -45,6 +46,9 @@
>  [Sources.RISCV64]
>RiscVCache.c
> 
> +[Sources.LOONGARCH64]
> +  LoongArchCache.c
> +
>  [Packages]
>MdePkg/MdePkg.dec
> 
> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> new file mode 100644
> index 00..4dcba9ecff
> --- /dev/null
> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> @@ -0,0 +1,253 @@
> +/** @file
> +  Cache Maintenance Functions for LoongArch.
> +  LoongArch cache maintenance functions has not yet been completed, and
> will added in later.
> +  Functions are null functions now.
> +
> +  Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> reserved.
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +//
> +// Include common header file for this module.
> +//
> +#include 
> +#include 
> +#include 
> +
> +/**
> +  Invalidates the entire instruction cache in cache coherency domain of the
> +  calling CPU.
> +
> +**/
> +VOID
> +EFIAPI
> +InvalidateInstructionCache (
> +  VOID
> +  )
> +{
> +  __asm__ __volatile__(
> +"ibar 0\n"
> +:
> +:
> +  );
> +}
> +
> +/**
> +  Invalidates a range of instruction cache lines in the cache coherency
> domain
> +  of the calling CPU.
> +
> +  Invalidates the instruction cache lines specified by Address and Length. If
> +  Address is not aligned on a cache line boundary, then entire instruction
> +  cache line containing Address is invalidated. If Address + Length is not
> +  aligned on a cache line boundary, then the entire instruction cache line
> +  containing Address + Length -1 is invalidated. This function may choose to
> +  invalidate the entire instruction cache if that is more efficient than
> +  invalidating the specified range. If Length is 0, the no instruction cache
> +  lines are invalidated. Address is returned.
> +
> +  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
> +
> +  @param  Address The base address of the instruction cache lines to
> +  invalidate. If the CPU is in a physical addressing mode, 
> then
> +  Address is a physical address. If the CPU is in a virtual
> +  addressing mode, then Address is a virtual address.
> +
> +  @param  Length  The number of bytes to invalidate from the instruction
> cache.
> +
> +  @return Address.
> +
> +**/
> +VOID *
> +EFIAPI
> +InvalidateInstructionCacheRange (
> +  IN  VOID  *Address,
> +  IN  UINTN Length
> +  )
> +{
> +  __asm__ __volatile__(
> +"ibar 0\n"
> +:
> +:
> +  );
> +  return Address;
> +}
> +
> +/**
> +  Writes Back and Invalidates the entire data cache in cache coherency
> domain
> +  of the calling CPU.
> +
> +  Writes Back and Invalidates the entire data cache in cache coherency
> domain
> +  of the calling CPU. This function guarantees that all dirty cache lines are
> +  written back to system memory, and also invalidates all the data cache
> lines
> +  in the cache coherency domain of the calling CPU.
> +
> +**/
> +VOID
> +EFIAPI
> +WriteBackInvalidateDataCache (
> +  VOID
> +  )
> +{
> +  DEBUG((DEBUG_ERROR, "%a: Not currently implemented on
> LoongArch.\n", __FUNCTION__));
> +}
> +
> +/**
> +  Writes Back and Invalidates a range of data cache lines in the cache
> +  coherency domain of the calling CPU.
> +
> +  

Re: [edk2-devel] [PATCH V2 4/8] OvmfPkg/IntelTdx: Measure Td HobList and Configuration FV

2022-04-08 Thread Yao, Jiewen
Can we use a SecMeasurementLib here? Instead of implementing all things in 
Startup.



> -Original Message-
> From: Xu, Min M 
> Sent: Friday, April 8, 2022 2:39 PM
> To: devel@edk2.groups.io
> Cc: Xu, Min M ; Ard Biesheuvel
> ; Yao, Jiewen ; Justen,
> Jordan L ; Brijesh Singh ;
> Aktas, Erdem ; James Bottomley
> ; Tom Lendacky ; Gerd
> Hoffmann 
> Subject: [PATCH V2 4/8] OvmfPkg/IntelTdx: Measure Td HobList and
> Configuration FV
> 
> RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853
> 
> TdHobList and Configuration FV are external data provided by Host VMM.
> These are not trusted in Td guest. So they should be validated , measured
> and extended to Td RTMR registers. In the meantime 2 EFI_CC_EVENT_HOB are
> created. These 2 GUIDed HOBs carry the hash value of TdHobList and
> Configuration FV. In DXE phase EFI_CC_EVENT can be created based on these
> 2 GUIDed HOBs.
> 
> Cc: Ard Biesheuvel 
> Cc: Jiewen Yao 
> Cc: Jordan Justen 
> Cc: Brijesh Singh 
> Cc: Erdem Aktas 
> Cc: James Bottomley 
> Cc: Jiewen Yao 
> Cc: Tom Lendacky 
> Cc: Gerd Hoffmann 
> Signed-off-by: Min Xu 
> ---
>  OvmfPkg/IntelTdx/IntelTdxX64.dsc  |   3 +
>  OvmfPkg/Library/PeilessStartupLib/IntelTdx.c  | 498 ++
>  .../PeilessStartupLib/PeilessStartup.c|  30 ++
>  .../PeilessStartupInternal.h  |  57 ++
>  .../PeilessStartupLib/PeilessStartupLib.inf   |   7 +-
>  5 files changed, 593 insertions(+), 2 deletions(-)
>  create mode 100644 OvmfPkg/Library/PeilessStartupLib/IntelTdx.c
> 
> diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> index 245155d41b30..caae49d524f9 100644
> --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> @@ -520,6 +520,9 @@
>OvmfPkg/IntelTdx/Sec/SecMain.inf {
>  
> 
> NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecom
> pressLib.inf
> +  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
> +
> HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRout
> erTdx.inf
> +
> NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf
>}
> 
>#
> diff --git a/OvmfPkg/Library/PeilessStartupLib/IntelTdx.c
> b/OvmfPkg/Library/PeilessStartupLib/IntelTdx.c
> new file mode 100644
> index ..bb905cf5cd6a
> --- /dev/null
> +++ b/OvmfPkg/Library/PeilessStartupLib/IntelTdx.c
> @@ -0,0 +1,498 @@
> +/** @file
> +  Copyright (c) 2022, Intel Corporation. All rights reserved.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +**/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "PeilessStartupInternal.h"
> +
> +#pragma pack(1)
> +
> +typedef struct {
> +  UINT32   count;
> +  TPMI_ALG_HASHhashAlg;
> +  BYTE sha384[SHA384_DIGEST_SIZE];
> +} TDX_DIGEST_VALUE;
> +
> +#define HANDOFF_TABLE_DESC  "TdxTable"
> +typedef struct {
> +  UINT8  TableDescriptionSize;
> +  UINT8  TableDescription[sizeof (HANDOFF_TABLE_DESC)];
> +  UINT64 NumberOfTables;
> +  EFI_CONFIGURATION_TABLETableEntry[1];
> +} TDX_HANDOFF_TABLE_POINTERS2;
> +
> +#define FV_HANDOFF_TABLE_DESC  "Fv(----
> )"
> +typedef struct {
> +  UINT8   BlobDescriptionSize;
> +  UINT8   BlobDescription[sizeof (FV_HANDOFF_TABLE_DESC)];
> +  EFI_PHYSICAL_ADDRESSBlobBase;
> +  UINT64  BlobLength;
> +} FV_HANDOFF_TABLE_POINTERS2;
> +
> +#pragma pack()
> +
> +#define INVALID_PCR2MR_INDEX  0xFF
> +
> +/**
> +RTMR[0]  => PCR[1,7]
> +RTMR[1]  => PCR[2,3,4,5]
> +RTMR[2]  => PCR[8~15]
> +RTMR[3]  => NA
> +  Note:
> +PCR[0] is mapped to MRTD and should not appear here.
> +PCR[6] is reserved for OEM. It is not used.
> +**/
> +UINT8
> +GetMappedRtmrIndex (
> +  UINT32  PCRIndex
> +  )
> +{
> +  UINT8  RtmrIndex;
> +
> +  if ((PCRIndex == 6) || (PCRIndex == 0) || (PCRIndex > 15)) {
> +DEBUG ((DEBUG_ERROR, "Invalid PCRIndex(%d) map to MR Index.\n",
> PCRIndex));
> +ASSERT (FALSE);
> +return INVALID_PCR2MR_INDEX;
> +  }
> +
> +  RtmrIndex = 0;
> +  if ((PCRIndex == 1) || (PCRIndex == 7)) {
> +RtmrIndex = 0;
> +  } else if ((PCRIndex >= 2) && (PCRIndex < 6)) {
> +RtmrIndex = 1;
> +  } else if ((PCRIndex >= 8) && (PCRIndex <= 15)) {
> +RtmrIndex = 2;
> +  }
> +
> +  return RtmrIndex;
> +}
> +
> +/**
> +  Tpm measure and log data, and extend the measurement result into a specific
> PCR.
> +  @param[in]  PcrIndex PCR Index.
> +  @param[in]  EventTypeEvent type.
> +  @param[in]  EventLog Measurement event log.
> +  @param[in]  LogLen   Event log length in bytes.
> +  @param[in]  HashData The start of the data buffer to be hashed,
> extended.
> +  @param[in]  HashDataLen  The length, in bytes, of the buffer 

Re: [edk2-devel] [PATCH V2 1/8] Security: Add HashLibBaseCryptoRouterTdx

2022-04-08 Thread Yao, Jiewen
I am not sure if we really need router here.
TDX only supports SHA384. What if we just provide HashLibTdx?


If we really want to provide a router, then it should be HashLibCCRouter. And 
TDX should be the NULL instance.

Thank you
Yao Jiewen


> -Original Message-
> From: Xu, Min M 
> Sent: Friday, April 8, 2022 2:39 PM
> To: devel@edk2.groups.io
> Cc: Xu, Min M ; Yao, Jiewen ;
> Wang, Jian J ; Gerd Hoffmann 
> Subject: [PATCH V2 1/8] Security: Add HashLibBaseCryptoRouterTdx
> 
> RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853
> 
> This library provides hash service by registered hash handler in Td
> guest. It redirects hash request to each individual hash handler
> (currently only SHA384 is supported). After that the hash value is
> extended to Td RTMR registers which is similar to TPM PCRs.
> 
> Cc: Jiewen Yao 
> Cc: Jian J Wang 
> Cc: Gerd Hoffmann 
> Signed-off-by: Min Xu 
> ---
>  .../HashLibBaseCryptoRouterTdx.c  | 214 ++
>  .../HashLibBaseCryptoRouterTdx.inf|  41 
>  SecurityPkg/SecurityPkg.dsc   |  10 +
>  3 files changed, 265 insertions(+)
>  create mode 100644
> SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterTdx.c
>  create mode 100644
> SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterTdx.inf
> 
> diff --git
> a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterTdx.
> c
> b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterTdx.
> c
> new file mode 100644
> index ..77e2a14c19be
> --- /dev/null
> +++
> b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterTdx.
> c
> @@ -0,0 +1,214 @@
> +/** @file
> +  This library is BaseCrypto router for Tdx.
> +
> +Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved. 
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "HashLibBaseCryptoRouterCommon.h"
> +
> +//
> +// Currently TDX supports SHA384.
> +//
> +#define TDX_HASH_COUNT  1
> +HASH_INTERFACE  mHashInterface[TDX_HASH_COUNT] = {
> +  {
> +{ 0 }, NULL, NULL, NULL
> +  }
> +};
> +
> +UINTNmHashInterfaceCount  = 0;
> +HASH_HANDLE  mHashCtx[TDX_HASH_COUNT] = { 0 };
> +
> +/**
> +  Start hash sequence.
> +
> +  @param HashHandle Hash handle.
> +
> +  @retval EFI_SUCCESS  Hash sequence start and HandleHandle returned.
> +  @retval EFI_OUT_OF_RESOURCES No enough resource to start hash.
> +**/
> +EFI_STATUS
> +EFIAPI
> +HashStart (
> +  OUT HASH_HANDLE  *HashHandle
> +  )
> +{
> +  HASH_HANDLE  *HashCtx;
> +
> +  if (mHashInterfaceCount == 0) {
> +ASSERT (FALSE);
> +return EFI_UNSUPPORTED;
> +  }
> +
> +  HashCtx = mHashCtx;
> +  mHashInterface[0].HashInit ([0]);
> +
> +  *HashHandle = (HASH_HANDLE)HashCtx;
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/**
> +  Update hash sequence data.
> +
> +  @param HashHandleHash handle.
> +  @param DataToHashData to be hashed.
> +  @param DataToHashLen Data size.
> +
> +  @retval EFI_SUCCESS Hash sequence updated.
> +**/
> +EFI_STATUS
> +EFIAPI
> +HashUpdate (
> +  IN HASH_HANDLE  HashHandle,
> +  IN VOID *DataToHash,
> +  IN UINTNDataToHashLen
> +  )
> +{
> +  HASH_HANDLE  *HashCtx;
> +
> +  if (mHashInterfaceCount == 0) {
> +ASSERT (FALSE);
> +return EFI_UNSUPPORTED;
> +  }
> +
> +  HashCtx = (HASH_HANDLE *)HashHandle;
> +  mHashInterface[0].HashUpdate (HashCtx[0], DataToHash, DataToHashLen);
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/**
> +  Hash sequence complete and extend to PCR.
> +
> +  @param HashHandleHash handle.
> +  @param PcrIndex  PCR to be extended.
> +  @param DataToHashData to be hashed.
> +  @param DataToHashLen Data size.
> +  @param DigestListDigest list.
> +
> +  @retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
> +**/
> +EFI_STATUS
> +EFIAPI
> +HashCompleteAndExtend (
> +  IN HASH_HANDLE  HashHandle,
> +  IN TPMI_DH_PCR  PcrIndex,
> +  IN VOID *DataToHash,
> +  IN UINTNDataToHashLen,
> +  OUT TPML_DIGEST_VALUES  *DigestList
> +  )
> +{
> +  TPML_DIGEST_VALUES  Digest;
> +  HASH_HANDLE *HashCtx;
> +  EFI_STATUS  Status;
> +
> +  if (mHashInterfaceCount == 0) {
> +ASSERT (FALSE);
> +return EFI_UNSUPPORTED;
> +  }
> +
> +  HashCtx = (HASH_HANDLE *)HashHandle;
> +  ZeroMem (DigestList, sizeof (*DigestList));
> +
> +  mHashInterface[0].HashUpdate (HashCtx[0], DataToHash, DataToHashLen);
> +  mHashInterface[0].HashFinal (HashCtx[0], );
> +  Tpm2SetHashToDigestList (DigestList, );
> +
> +  ASSERT (DigestList->count == 1 && DigestList->digests[0].hashAlg ==
> TPM_ALG_SHA384);
> +
> +  Status = TdExtendRtmr (
> + (UINT32 *)DigestList->digests[0].digest.sha384,
> + SHA384_DIGEST_SIZE,
> + (UINT8)PcrIndex
> + );
> +
> +  ASSERT 

Re: [edk2-devel] [PATCH V2 5/8] OvmfPkg: Add PCDs for LAML/LASA field in CC EVENTLOG ACPI table

2022-04-08 Thread Yao, Jiewen
Reiewed-by: Jiewen Yao 

> -Original Message-
> From: Xu, Min M 
> Sent: Friday, April 8, 2022 2:39 PM
> To: devel@edk2.groups.io
> Cc: Xu, Min M ; Brijesh Singh ;
> Aktas, Erdem ; James Bottomley
> ; Yao, Jiewen ; Tom Lendacky
> ; Lu, Ken ; Sami Mujawar
> ; Gerd Hoffmann 
> Subject: [PATCH V2 5/8] OvmfPkg: Add PCDs for LAML/LASA field in CC
> EVENTLOG ACPI table
> 
> RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853
> 
> Add PCDs to records LAML/LASA field in CC EVENTLOG ACPI table.
> 
> Cc: Brijesh Singh 
> Cc: Erdem Aktas 
> Cc: James Bottomley 
> Cc: Jiewen Yao 
> Cc: Tom Lendacky 
> Cc: Ken Lu 
> Cc: Sami Mujawar 
> Cc: Gerd Hoffmann 
> Signed-off-by: Min Xu 
> ---
>  OvmfPkg/OvmfPkg.dec | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
> index b9ca44120289..f471f3bbeec2 100644
> --- a/OvmfPkg/OvmfPkg.dec
> +++ b/OvmfPkg/OvmfPkg.dec
> @@ -436,6 +436,12 @@
>#2 - set by GOP Driver.
>gUefiOvmfPkgTokenSpaceGuid.PcdVideoResolutionSource|0|UINT8|0x64
> 
> +  ## This PCD records LAML field in CC EVENTLOG ACPI table.
> +  gUefiOvmfPkgTokenSpaceGuid.PcdCcEventlogAcpiTableLaml|0|UINT32|0x66
> +
> +  ## This PCD records LASA field in CC EVENTLOG ACPI table.
> +  gUefiOvmfPkgTokenSpaceGuid.PcdCcEventlogAcpiTableLasa|0|UINT64|0x67
> +
>  [PcdsFeatureFlag]
> 
> gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOL
> EAN|0x1c
> 
> gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|FALSE|BO
> OLEAN|0x1d
> --
> 2.29.2.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88595): https://edk2.groups.io/g/devel/message/88595
Mute This Topic: https://groups.io/mt/90330665/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 6/8] MdePkg: Define CC Measure EventLog ACPI Table

2022-04-08 Thread Yao, Jiewen
Reviewed-by: Jiewen Yao 

> -Original Message-
> From: Xu, Min M 
> Sent: Friday, April 8, 2022 2:39 PM
> To: devel@edk2.groups.io
> Cc: Xu, Min M ; Kinney, Michael D
> ; Gao, Liming ; Liu,
> Zhiguang ; Yao, Jiewen ;
> Wang, Jian J ; Lu, Ken ; Sami
> Mujawar ; Gerd Hoffmann 
> Subject: [PATCH V2 6/8] MdePkg: Define CC Measure EventLog ACPI Table
> 
> RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853
> 
> TDVF set up an ACPI table (EFI_CC_EVENTLOG_ACPI_TABLE) to pass the
> event-log information. The event log created by the TD owner contains
> the hashes to reconstruct the MRTD and RTMR registers.
> 
> Please refer to Sec 4.3.3 in blow link:
> https://www.intel.com/content/dam/develop/external/us/en/documents/
> intel-tdx-guest-hypervisor-communication-interface-1.0-344426-002.pdf
> 
> Please be noted, the definition of EFI_CC_EVENTLOG_ACPI_TABLE is a
> little different from the above document. This difference is based on
> below discussion:
> - https://edk2.groups.io/g/devel/message/87396
> - https://edk2.groups.io/g/devel/message/87402
> 
> This change will be reflected in the next version of the above document.
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> Cc: Jiewen Yao 
> Cc: Jian J Wang 
> Cc: Ken Lu 
> Cc: Sami Mujawar 
> Cc: Gerd Hoffmann 
> Signed-off-by: Min Xu 
> ---
>  MdePkg/Include/Protocol/CcMeasurement.h | 21 +
>  1 file changed, 21 insertions(+)
> 
> diff --git a/MdePkg/Include/Protocol/CcMeasurement.h
> b/MdePkg/Include/Protocol/CcMeasurement.h
> index 68029e977fac..58123ca72163 100644
> --- a/MdePkg/Include/Protocol/CcMeasurement.h
> +++ b/MdePkg/Include/Protocol/CcMeasurement.h
> @@ -299,4 +299,25 @@ typedef struct {
> 
>  extern EFI_GUID  gEfiCcFinalEventsTableGuid;
> 
> +//
> +// Define the CC Measure EventLog ACPI Table
> +//
> +#pragma pack(1)
> +
> +typedef struct {
> +  EFI_ACPI_DESCRIPTION_HEADERHeader;
> +  EFI_CC_TYPECcType;
> +  UINT32 Rsvd;
> +  UINT64 Laml;
> +  UINT64 Lasa;
> +} EFI_CC_EVENTLOG_ACPI_TABLE;
> +
> +#pragma pack()
> +
> +//
> +// Define the signature and revision of CC Measurement EventLog ACPI Table
> +//
> +#define EFI_CC_EVENTLOG_ACPI_TABLE_SIGNATURE  SIGNATURE_32('C', 'C',
> 'E', 'L')
> +#define EFI_CC_EVENTLOG_ACPI_TABLE_REVISION   1
> +
>  #endif
> --
> 2.29.2.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88594): https://edk2.groups.io/g/devel/message/88594
Mute This Topic: https://groups.io/mt/90330667/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 3/8] SecurityPkg: Add definition of EFI_CC_EVENT_HOB_GUID

2022-04-08 Thread Yao, Jiewen
Reviewed-by: Jiewen Yao 

> -Original Message-
> From: Xu, Min M 
> Sent: Friday, April 8, 2022 2:39 PM
> To: devel@edk2.groups.io
> Cc: Xu, Min M ; Gerd Hoffmann ;
> Yao, Jiewen ; Sami Mujawar
> ; Wang, Jian J 
> Subject: [PATCH V2 3/8] SecurityPkg: Add definition of
> EFI_CC_EVENT_HOB_GUID
> 
> RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853
> 
> EFI_CC_EVENT_HOB_GUID is the global ID of a GUIDed HOB used to pass
> TDX_DIGEST_VALUE from SEC to a DXE Driver ( This DXE driver will
> be introduced in the following commit in this patch-sets ). In that
> DXE driver this GUIDed HOB will be parsed and the TDX_DIGEST_VALUE
> then will be extracted. After that a EFI_CC_EVENT will be created
> based on it.
> 
> Cc: Gerd Hoffmann 
> Cc: Jiewen Yao 
> Cc: Sami Mujawar 
> Cc: Jian J Wang 
> Signed-off-by: Min Xu 
> ---
>  SecurityPkg/Include/Guid/CcEventHob.h | 22 ++
>  SecurityPkg/SecurityPkg.dec   |  4 
>  2 files changed, 26 insertions(+)
>  create mode 100644 SecurityPkg/Include/Guid/CcEventHob.h
> 
> diff --git a/SecurityPkg/Include/Guid/CcEventHob.h
> b/SecurityPkg/Include/Guid/CcEventHob.h
> new file mode 100644
> index ..072999ce92de
> --- /dev/null
> +++ b/SecurityPkg/Include/Guid/CcEventHob.h
> @@ -0,0 +1,22 @@
> +/** @file
> +  Defines the HOB GUID used to pass a CC_EVENT from SEC to
> +  a CC DXE Driver. A GUIDed HOB is generated for each measurement
> +  made in the SEC Phase.
> +
> +Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved.
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef CC_EVENT_HOB_H_
> +#define CC_EVENT_HOB_H_
> +
> +//
> +// The Global ID of a GUIDed HOB used to pass a CC_EVENT from SEC to a CC
> DXE Driver.
> +//
> +#define EFI_CC_EVENT_HOB_GUID \
> +  { 0x20f8fd36, 0x6d00, 0x40fb, { 0xb7, 0x04, 0xd1, 0x2c, 0x15, 0x3c, 0x62,
> 0xeb } }
> +
> +extern EFI_GUID  gCcEventEntryHobGuid;
> +
> +#endif
> diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec
> index 9f7a032d60d5..0ee75efc1a97 100644
> --- a/SecurityPkg/SecurityPkg.dec
> +++ b/SecurityPkg/SecurityPkg.dec
> @@ -136,6 +136,10 @@
>## Include/Guid/TcgEventHob.h
>gTcgEvent2EntryHobGuid = { 0xd26c221e, 0x2430, 0x4c8a, { 0x91, 
> 0x70,
> 0x3f, 0xcb, 0x45, 0x0, 0x41, 0x3f }}
> 
> +  ## Hob GUID used to pass a CC_EVENT from SEC to a CC DXE Driver.
> +  ## Include/Guid/CcEventHob.h
> +  gCcEventEntryHobGuid   = { 0x20f8fd36, 0x6d00, 0x40fb, { 0xb7, 
> 0x04,
> 0xd1, 0x2c, 0x15, 0x3c, 0x62, 0xeb }}
> +
>## HOB GUID used to record TPM device error.
>#  Include/Guid/TcgEventHob.h
>gTpmErrorHobGuid   = { 0xef598499, 0xb25e, 0x473a, { 0xbf, 
> 0xaf,
> 0xe7, 0xe5, 0x7d, 0xce, 0x82, 0xc4 }}
> --
> 2.29.2.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88593): https://edk2.groups.io/g/devel/message/88593
Mute This Topic: https://groups.io/mt/90330663/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 2/8] CryptoPkg: Add SecCryptLib

2022-04-08 Thread Yao, Jiewen
Hi
The rule for lib instance is: It must provide all interfaces defined in .h file.

As such, please use NULL version other algorithms in SEC instance.

Thank you
Yao Jiewen


> -Original Message-
> From: Xu, Min M 
> Sent: Friday, April 8, 2022 2:39 PM
> To: devel@edk2.groups.io
> Cc: Xu, Min M ; Yao, Jiewen ;
> Wang, Jian J ; Lu, Xiaoyu1 ;
> Jiang, Guomin ; Gerd Hoffmann 
> Subject: [PATCH V2 2/8] CryptoPkg: Add SecCryptLib
> 
> RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853
> 
> This is the Cryptographic library instance for SEC. The motivation of
> this library is to support SHA384 in SEC phase for Td guest. So only
> Hash/CryptSha512.c is included which supports SHA384 and SHA512.
> 
> Cc: Jiewen Yao 
> Cc: Jian J Wang 
> Cc: Xiaoyu Lu 
> Cc: Guomin Jiang 
> Cc: Gerd Hoffmann 
> Signed-off-by: Min Xu 
> ---
>  CryptoPkg/CryptoPkg.dsc   |  4 ++
>  .../Library/BaseCryptLib/SecCryptLib.inf  | 67 +++
>  2 files changed, 71 insertions(+)
>  create mode 100644 CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
> 
> diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc
> index 0aa72ed87846..b814e9616454 100644
> --- a/CryptoPkg/CryptoPkg.dsc
> +++ b/CryptoPkg/CryptoPkg.dsc
> @@ -109,6 +109,9 @@
>  [LibraryClasses.ARM]
>ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf
> 
> +[LibraryClasses.common.SEC]
> +  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
> +
>  [LibraryClasses.common.PEIM]
>PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
> 
> ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiRepo
> rtStatusCodeLib.inf
> @@ -236,6 +239,7 @@
>  !if $(CRYPTO_SERVICES) == PACKAGE
>  [Components]
>CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
> +  CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
>CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
>CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
>CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
> diff --git a/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
> b/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
> new file mode 100644
> index ..6ef2f67e35dd
> --- /dev/null
> +++ b/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
> @@ -0,0 +1,67 @@
> +## @file
> +#  Cryptographic Library Instance for SEC.
> +#
> +#  Caution: This module requires additional review when modified.
> +#  This library will have external input - signature.
> +#  This external input must be validated carefully to avoid security issues 
> such
> as
> +#  buffer overflow or integer overflow.
> +#
> +#  Copyright (c) 2021, Intel Corporation. All rights reserved.
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION= 0x00010005
> +  BASE_NAME  = SecCryptLib
> +  FILE_GUID  = 3689D343-0D32-4284-8053-BF10537990E8
> +  MODULE_TYPE= BASE
> +  VERSION_STRING = 1.0
> +  LIBRARY_CLASS  = BaseCryptLib|SEC
> +
> +#
> +# The following information is for reference only and not required by the 
> build
> tools.
> +#
> +#  VALID_ARCHITECTURES   = IA32 X64
> +#
> +
> +[Sources]
> +  InternalCryptLib.h
> +  Hash/CryptSha512.c
> +
> +  SysCall/CrtWrapper.c
> +  SysCall/ConstantTimeClock.c
> +  SysCall/BaseMemAllocation.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  CryptoPkg/CryptoPkg.dec
> +
> +[LibraryClasses]
> +  BaseLib
> +  BaseMemoryLib
> +  MemoryAllocationLib
> +  DebugLib
> +  OpensslLib
> +  IntrinsicLib
> +
> +#
> +# Remove these [BuildOptions] after this library is cleaned up
> +#
> +[BuildOptions]
> +  #
> +  # suppress the following warnings so we do not break the build with 
> warnings-
> as-errors:
> +  # C4090: 'function' : different 'const' qualifiers
> +  # C4718: 'function call' : recursive call has no side effects, deleting
> +  #
> +  MSFT:*_*_*_CC_FLAGS = /wd4090 /wd4718
> +
> +  # -JCryptoPkg/Include : To disable the use of the system includes provided 
> by
> RVCT
> +  # --diag_remark=1 : Reduce severity of "#1-D: last line of file ends 
> without a
> newline"
> +  RVCT:*_*_ARM_CC_FLAGS = -JCryptoPkg/Include --diag_remark=1
> +
> +  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
> +  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
> +  GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-
> pointer-types
> +
> +  XCODE:*_*_*_CC_FLAGS = -std=c99
> --
> 2.29.2.windows.2



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




Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 21/33] MdePkg/BaseLib: BaseLib for LOONGARCH64 architecture.

2022-04-08 Thread Abner Chang
Acked-by: Abner Chang 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chao Li
> Sent: Wednesday, February 9, 2022 2:56 PM
> To: devel@edk2.groups.io
> Cc: Michael D Kinney ; Liming Gao
> ; Zhiguang Liu ; Baoqi
> Zhang 
> Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 21/33]
> MdePkg/BaseLib: BaseLib for LOONGARCH64 architecture.
> 
> Add LoongArch LOONGARCH64 BaseLib functions.
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> 
> Signed-off-by: Chao Li 
> Co-authored-by: Baoqi Zhang 
> ---
>  MdePkg/Include/Library/BaseLib.h  |  24 ++
>  MdePkg/Library/BaseLib/BaseLib.inf|  13 +
>  .../BaseLib/LoongArch64/CpuBreakpoint.S   |  24 ++
>  MdePkg/Library/BaseLib/LoongArch64/CpuPause.S |  31 +++
>  .../BaseLib/LoongArch64/DisableInterrupts.S   |  21 ++
>  .../BaseLib/LoongArch64/EnableInterrupts.S|  21 ++
>  .../BaseLib/LoongArch64/GetInterruptState.S   |  35 +++
>  .../BaseLib/LoongArch64/InternalSwitchStack.c |  58 +
>  .../Library/BaseLib/LoongArch64/MemoryFence.S |  19 ++
>  .../BaseLib/LoongArch64/SetJumpLongJump.S |  49 
>  .../Library/BaseLib/LoongArch64/SwitchStack.S |  39 +++
>  .../Library/BaseLib/LoongArch64/Unaligned.c   | 244 ++
>  12 files changed, 578 insertions(+)
>  create mode 100644
> MdePkg/Library/BaseLib/LoongArch64/CpuBreakpoint.S
>  create mode 100644 MdePkg/Library/BaseLib/LoongArch64/CpuPause.S
>  create mode 100644
> MdePkg/Library/BaseLib/LoongArch64/DisableInterrupts.S
>  create mode 100644
> MdePkg/Library/BaseLib/LoongArch64/EnableInterrupts.S
>  create mode 100644
> MdePkg/Library/BaseLib/LoongArch64/GetInterruptState.S
>  create mode 100644
> MdePkg/Library/BaseLib/LoongArch64/InternalSwitchStack.c
>  create mode 100644
> MdePkg/Library/BaseLib/LoongArch64/MemoryFence.S
>  create mode 100644
> MdePkg/Library/BaseLib/LoongArch64/SetJumpLongJump.S
>  create mode 100644 MdePkg/Library/BaseLib/LoongArch64/SwitchStack.S
>  create mode 100644 MdePkg/Library/BaseLib/LoongArch64/Unaligned.c
> 
> diff --git a/MdePkg/Include/Library/BaseLib.h
> b/MdePkg/Include/Library/BaseLib.h
> index 6aa0d97218..3c27e2ea93 100644
> --- a/MdePkg/Include/Library/BaseLib.h
> +++ b/MdePkg/Include/Library/BaseLib.h
> @@ -6,6 +6,7 @@ Copyright (c) 2006 - 2021, Intel Corporation. All rights
> reserved.
>  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
>  Copyright (c) Microsoft Corporation.
>  Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All
> rights reserved.
> +Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All
> rights reserved.
> 
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -152,6 +153,29 @@ typedef struct {
> 
>  #endif // defined (MDE_CPU_RISCV64)
> 
> +#if defined (MDE_CPU_LOONGARCH64)
> +///
> +/// The LoongArch architecture context buffer used by SetJump() and
> LongJump()
> +///
> +typedef struct {
> +  UINT64S0;
> +  UINT64S1;
> +  UINT64S2;
> +  UINT64S3;
> +  UINT64S4;
> +  UINT64S5;
> +  UINT64S6;
> +  UINT64S7;
> +  UINT64S8;
> +  UINT64SP;
> +  UINT64FP;
> +  UINT64RA;
> +} BASE_LIBRARY_JUMP_BUFFER;
> +
> +#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
> +
> +#endif // defined (MDE_CPU_LOONGARCH64)
> +
>  //
>  // String Services
>  //
> diff --git a/MdePkg/Library/BaseLib/BaseLib.inf
> b/MdePkg/Library/BaseLib/BaseLib.inf
> index cebda3b210..4c9b6b50dd 100644
> --- a/MdePkg/Library/BaseLib/BaseLib.inf
> +++ b/MdePkg/Library/BaseLib/BaseLib.inf
> @@ -409,6 +409,19 @@
>RiscV64/RiscVInterrupt.S  | GCC
>RiscV64/FlushCache.S  | GCC
> 
> +[Sources.LOONGARCH64]
> +  Math64.c
> +  LoongArch64/Unaligned.c
> +  LoongArch64/InternalSwitchStack.c
> +  LoongArch64/GetInterruptState.S   | GCC
> +  LoongArch64/EnableInterrupts.S| GCC
> +  LoongArch64/DisableInterrupts.S   | GCC
> +  LoongArch64/MemoryFence.S | GCC
> +  LoongArch64/CpuBreakpoint.S   | GCC
> +  LoongArch64/CpuPause.S| GCC
> +  LoongArch64/SetJumpLongJump.S | GCC
> +  LoongArch64/SwitchStack.S | GCC
> +
>  [Packages]
>MdePkg/MdePkg.dec
> 
> diff --git a/MdePkg/Library/BaseLib/LoongArch64/CpuBreakpoint.S
> b/MdePkg/Library/BaseLib/LoongArch64/CpuBreakpoint.S
> new file mode 100644
> index 00..4e022e9bb5
> --- /dev/null
> +++ b/MdePkg/Library/BaseLib/LoongArch64/CpuBreakpoint.S
> @@ -0,0 +1,24 @@
> +#--
> +#
> +# CpuBreakpoint for LoongArch
> +#
> +# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> reserved.
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +#--
> +
> +ASM_GLOBAL ASM_PFX(CpuBreakpoint)
> +
> +#/**
> +#  Generates a breakpoint on the CPU.
> +#
> +#  Generates a breakpoint on the CPU. The breakpoint must be
> implemented such
> 

Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 16/33] BaseTools: Enable LoongArch64 architecture for LoongArch64 EDK2 CI.

2022-04-08 Thread Abner Chang
Acked-by: Abner Chang 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chao Li
> Sent: Wednesday, February 9, 2022 2:55 PM
> To: devel@edk2.groups.io
> Cc: Bob Feng ; Liming Gao
> ; Yuwei Chen 
> Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 16/33]
> BaseTools: Enable LoongArch64 architecture for LoongArch64 EDK2 CI.
> 
> EDK CI for LoongArch64 architecture
> 
> Enable LoongArch64 architecture for LoongArch64 EDK2 CI testing.
> 
> Cc: Bob Feng 
> Cc: Liming Gao 
> Cc: Yuwei Chen 
> 
> Signed-off-by: Chao Li 
> ---
>  ...gcc_loongarch64_unknown_linux_ext_dep.yaml | 22 +
>  .../LinuxGcc5ToolChain/LinuxGcc5ToolChain.py  | 31
> +++
>  2 files changed, 53 insertions(+)
>  create mode 100644
> BaseTools/Bin/gcc_loongarch64_unknown_linux_ext_dep.yaml
> 
> diff --git a/BaseTools/Bin/gcc_loongarch64_unknown_linux_ext_dep.yaml
> b/BaseTools/Bin/gcc_loongarch64_unknown_linux_ext_dep.yaml
> new file mode 100644
> index 00..6bdd7388f8
> --- /dev/null
> +++ b/BaseTools/Bin/gcc_loongarch64_unknown_linux_ext_dep.yaml
> @@ -0,0 +1,22 @@
> +## @file
> +# Download GCC LoongArch64 compiler from LoongArch GitHub release site
> +# Set shell variable GCC5_LOONGARCH64_INSTALL to this folder
> +#
> +# This is only downloaded when a build activates scope
> gcc_loongarch64_unknown_linux
> +#
> +# Copyright (c) Microsoft Corporation.
> +# Copyright (c) 2022 Loongson Technology Corporation Limited. All rights
> reserved.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +##
> +{
> +  "scope": "gcc_loongarch64_unknown_linux",
> +  "type": "web",
> +  "name": "gcc_loongarch64_unknown_linux",
> +  "source": "https://github.com/loongson/build-
> tools/releases/download/2021.12.21/loongarch64-clfs-2021-12-18-cross-
> tools-gcc-full.tar.xz",
> +  "version": "12.0.0 20210810",
> +  "sha256":
> "07f4e93423e76c57c775390099c76273b67cde2e441ed78192a2f4da9168c65a",
> +  "compression_type": "tar",
> +  "internal_path": "/cross-tools/",
> +  "flags": ["set_shell_var", ],
> +  "var_name": "GCC5_LOONGARCH64_INSTALL"
> +}
> diff --git a/BaseTools/Plugin/LinuxGcc5ToolChain/LinuxGcc5ToolChain.py
> b/BaseTools/Plugin/LinuxGcc5ToolChain/LinuxGcc5ToolChain.py
> index f0685d8040..5615f8bb35 100644
> --- a/BaseTools/Plugin/LinuxGcc5ToolChain/LinuxGcc5ToolChain.py
> +++ b/BaseTools/Plugin/LinuxGcc5ToolChain/LinuxGcc5ToolChain.py
> @@ -5,6 +5,7 @@
>  #
>  # Copyright (c) Microsoft Corporation
>  # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights
> reserved.
> +# Copyright (c) 2022 Loongson Technology Corporation Limited. All rights
> reserved.
>  # SPDX-License-Identifier: BSD-2-Clause-Patent
>  ##
>  import os
> @@ -43,6 +44,12 @@ class LinuxGcc5ToolChain(IUefiBuildPlugin):
>  self.Logger.critical("Failed in check riscv64")
>  return ret
> 
> +# Check LoongArch64 compiler
> +ret = self._check_loongarch64()
> +if ret != 0:
> +self.Logger.critical("Failed in check loongarch64")
> +return ret
> +
>  return 0
> 
>  def _check_arm(self):
> @@ -121,3 +128,27 @@ class LinuxGcc5ToolChain(IUefiBuildPlugin):
> 
> shell_environment.GetEnvironment().set_shell_var("LD_LIBRARY_PATH",
> prefix)
> 
>  return 0
> +
> +def _check_loongarch64(self):
> +# check to see if full path already configured
> +if
> shell_environment.GetEnvironment().get_shell_var("GCC5_LOONGARCH64
> _PREFIX") is not None:
> +self.Logger.info("GCC5_LOONGARCH64_PREFIX is already set.")
> +
> +else:
> +# now check for install dir.  If set then set the Prefix
> +install_path = shell_environment.GetEnvironment(
> +).get_shell_var("GCC5_LOONGARCH64_INSTALL")
> +if install_path is None:
> +return 0
> +
> +# make GCC5_AARCH64_PREFIX to align with tools_def.txt
> +prefix = os.path.join(install_path, "bin", 
> "loongarch64-unknown-linux-
> gnu-")
> +
> shell_environment.GetEnvironment().set_shell_var("GCC5_LOONGARCH64
> _PREFIX", prefix)
> +
> +# now confirm it exists
> +if not
> os.path.exists(shell_environment.GetEnvironment().get_shell_var("GCC5_L
> OONGARCH64_PREFIX") + "gcc"):
> +self.Logger.error(
> +"Path for GCC5_LOONGARCH64_PREFIX toolchain is invalid")
> +return -2
> +
> +return 0
> --
> 2.27.0
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 15/33] BaseTools: BaseTools changes for LoongArch platform.

2022-04-08 Thread Abner Chang
Acked-by: Abner Chang 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chao Li
> Sent: Wednesday, February 9, 2022 2:55 PM
> To: devel@edk2.groups.io
> Cc: Bob Feng ; Liming Gao
> ; Yuwei Chen ; Baoqi
> Zhang 
> Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 15/33]
> BaseTools: BaseTools changes for LoongArch platform.
> 
> Python code changes for building EDK2 LoongArch platform.
> 
> Cc: Bob Feng 
> Cc: Liming Gao 
> Cc: Yuwei Chen 
> 
> Signed-off-by: Chao Li 
> Co-authored-by: Baoqi Zhang 
> ---
>  BaseTools/Source/Python/Common/DataType.py| 21 ++--
>  .../Source/Python/UPT/Library/DataType.py | 24 ++-
>  BaseTools/Source/Python/build/buildoptions.py |  3 ++-
>  3 files changed, 44 insertions(+), 4 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/Common/DataType.py
> b/BaseTools/Source/Python/Common/DataType.py
> index dc4962..48dbf16495 100644
> --- a/BaseTools/Source/Python/Common/DataType.py
> +++ b/BaseTools/Source/Python/Common/DataType.py
> @@ -4,6 +4,7 @@
>  # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
>  # Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
>  # Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP.
> All rights reserved.
> +# Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All
> rights reserved.
>  # SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  ##
> @@ -52,10 +53,10 @@ TAB_ARCH_X64 = 'X64'
>  TAB_ARCH_ARM = 'ARM'
>  TAB_ARCH_EBC = 'EBC'
>  TAB_ARCH_AARCH64 = 'AARCH64'
> -
>  TAB_ARCH_RISCV64 = 'RISCV64'
> +TAB_ARCH_LOONGARCH64 = 'LOONGARCH64'
> 
> -ARCH_SET_FULL = {TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_ARM,
> TAB_ARCH_EBC, TAB_ARCH_AARCH64, TAB_ARCH_RISCV64,
> TAB_ARCH_COMMON}
> +ARCH_SET_FULL = {TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_ARM,
> TAB_ARCH_EBC, TAB_ARCH_AARCH64, TAB_ARCH_RISCV64,
> TAB_ARCH_LOONGARCH64, TAB_ARCH_COMMON}
> 
>  SUP_MODULE_BASE = 'BASE'
>  SUP_MODULE_SEC = 'SEC'
> @@ -138,6 +139,7 @@ TAB_SOURCES_X64 = TAB_SOURCES + TAB_SPLIT +
> TAB_ARCH_X64
>  TAB_SOURCES_ARM = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_ARM
>  TAB_SOURCES_EBC = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_EBC
>  TAB_SOURCES_AARCH64 = TAB_SOURCES + TAB_SPLIT +
> TAB_ARCH_AARCH64
> +TAB_SOURCES_LOONGARCH64 = TAB_SOURCES + TAB_SPLIT +
> TAB_ARCH_LOONGARCH64
> 
>  TAB_BINARIES = 'Binaries'
>  TAB_BINARIES_COMMON = TAB_BINARIES + TAB_SPLIT +
> TAB_ARCH_COMMON
> @@ -146,6 +148,7 @@ TAB_BINARIES_X64 = TAB_BINARIES + TAB_SPLIT +
> TAB_ARCH_X64
>  TAB_BINARIES_ARM = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_ARM
>  TAB_BINARIES_EBC = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_EBC
>  TAB_BINARIES_AARCH64 = TAB_BINARIES + TAB_SPLIT +
> TAB_ARCH_AARCH64
> +TAB_BINARIES_LOONGARCH64 = TAB_BINARIES + TAB_SPLIT +
> TAB_ARCH_LOONGARCH64
> 
>  TAB_INCLUDES = 'Includes'
>  TAB_INCLUDES_COMMON = TAB_INCLUDES + TAB_SPLIT +
> TAB_ARCH_COMMON
> @@ -154,6 +157,7 @@ TAB_INCLUDES_X64 = TAB_INCLUDES + TAB_SPLIT +
> TAB_ARCH_X64
>  TAB_INCLUDES_ARM = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_ARM
>  TAB_INCLUDES_EBC = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_EBC
>  TAB_INCLUDES_AARCH64 = TAB_INCLUDES + TAB_SPLIT +
> TAB_ARCH_AARCH64
> +TAB_INCLUDES_LOONGARCH64 = TAB_INCLUDES + TAB_SPLIT +
> TAB_ARCH_LOONGARCH64
> 
>  TAB_GUIDS = 'Guids'
>  TAB_GUIDS_COMMON = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_COMMON
> @@ -162,6 +166,7 @@ TAB_GUIDS_X64 = TAB_GUIDS + TAB_SPLIT +
> TAB_ARCH_X64
>  TAB_GUIDS_ARM = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_ARM
>  TAB_GUIDS_EBC = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_EBC
>  TAB_GUIDS_AARCH64 = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_AARCH64
> +TAB_GUIDS_LOONGARCH64 = TAB_GUIDS + TAB_SPLIT +
> TAB_ARCH_LOONGARCH64
> 
>  TAB_PROTOCOLS = 'Protocols'
>  TAB_PROTOCOLS_COMMON = TAB_PROTOCOLS + TAB_SPLIT +
> TAB_ARCH_COMMON
> @@ -170,6 +175,7 @@ TAB_PROTOCOLS_X64 = TAB_PROTOCOLS +
> TAB_SPLIT + TAB_ARCH_X64
>  TAB_PROTOCOLS_ARM = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_ARM
>  TAB_PROTOCOLS_EBC = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_EBC
>  TAB_PROTOCOLS_AARCH64 = TAB_PROTOCOLS + TAB_SPLIT +
> TAB_ARCH_AARCH64
> +TAB_PROTOCOLS_LOONGARCH64 = TAB_PROTOCOLS + TAB_SPLIT +
> TAB_ARCH_LOONGARCH64
> 
>  TAB_PPIS = 'Ppis'
>  TAB_PPIS_COMMON = TAB_PPIS + TAB_SPLIT + TAB_ARCH_COMMON
> @@ -178,6 +184,7 @@ TAB_PPIS_X64 = TAB_PPIS + TAB_SPLIT +
> TAB_ARCH_X64
>  TAB_PPIS_ARM = TAB_PPIS + TAB_SPLIT + TAB_ARCH_ARM
>  TAB_PPIS_EBC = TAB_PPIS + TAB_SPLIT + TAB_ARCH_EBC
>  TAB_PPIS_AARCH64 = TAB_PPIS + TAB_SPLIT + TAB_ARCH_AARCH64
> +TAB_PPIS_LOONGARCH64 = TAB_PPIS + TAB_SPLIT +
> TAB_ARCH_LOONGARCH64
> 
>  TAB_LIBRARY_CLASSES = 'LibraryClasses'
>  TAB_LIBRARY_CLASSES_COMMON = TAB_LIBRARY_CLASSES + TAB_SPLIT +
> TAB_ARCH_COMMON
> @@ -186,6 +193,7 @@ TAB_LIBRARY_CLASSES_X64 = TAB_LIBRARY_CLASSES
> + TAB_SPLIT + TAB_ARCH_X64
>  TAB_LIBRARY_CLASSES_ARM = TAB_LIBRARY_CLASSES + TAB_SPLIT +
> TAB_ARCH_ARM
>  TAB_LIBRARY_CLASSES_EBC = TAB_LIBRARY_CLASSES + TAB_SPLIT +
> TAB_ARCH_EBC
>  TAB_LIBRARY_CLASSES_AARCH64 = 

[edk2-devel] [PATCH V2 8/8] OvmfPkg/IntelTdx: Enable RTMR based measurement and measure boot

2022-04-08 Thread Min Xu
RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

Enable RTMR based measurement and measure boot for Td guest.

Cc: Brijesh Singh 
Cc: Erdem Aktas 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Tom Lendacky 
Cc: Ken Lu 
Cc: Sami Mujawar 
Cc: Gerd Hoffmann 
Signed-off-by: Min Xu 
---
 OvmfPkg/IntelTdx/IntelTdxX64.dsc | 12 +++-
 OvmfPkg/IntelTdx/IntelTdxX64.fdf |  5 +
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
index caae49d524f9..774e2aee50a1 100644
--- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
+++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
@@ -192,7 +192,7 @@
   
OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
 
   
Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf
-  
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
+  
TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
 
 [LibraryClasses.common]
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
@@ -548,6 +548,7 @@
 !if $(SECURE_BOOT_ENABLE) == TRUE
   
NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
 !endif
+  NULL|SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf
   }
 
   MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
@@ -722,3 +723,12 @@
 
   NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
   }
+
+  #
+  # Cc Measurement Protocol for Td guest
+  #
+OvmfPkg/IntelTdx/TdTcg2Dxe/TdTcg2Dxe.inf {
+  
+
HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterTdx.inf
+NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf
+}
diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.fdf b/OvmfPkg/IntelTdx/IntelTdxX64.fdf
index 9e290ea78f61..b7eb217847b8 100644
--- a/OvmfPkg/IntelTdx/IntelTdxX64.fdf
+++ b/OvmfPkg/IntelTdx/IntelTdxX64.fdf
@@ -292,6 +292,11 @@ INF  OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
 INF  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
 INF  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
 
+#
+# EFI_CC_MEASUREMENT_PROTOCOL
+#
+INF OvmfPkg/IntelTdx/TdTcg2Dxe/TdTcg2Dxe.inf
+
 

 
 [FV.FVMAIN_COMPACT]
-- 
2.29.2.windows.2



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




[edk2-devel] [PATCH V2 7/8] OvmfPkg/IntelTdx: Add TdTcg2Dxe

2022-04-08 Thread Min Xu
RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

TdTcg2Dxe mimics the Security/Tcg/Tcg2Dxe. It does below tasks:
 - Set up and install CC_EVENTLOG ACPI table
 - Parse the GUIDed HOB (gCcEventEntryHobGuid) and create CC event log
 - Measure handoff tables, Boot# variables etc
 - Measure Exit Boot Service failed
 - Install CcMeasurement Protocol

Cc: Brijesh Singh 
Cc: Erdem Aktas 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Tom Lendacky 
Cc: Ken Lu 
Cc: Sami Mujawar 
Cc: Gerd Hoffmann 
Signed-off-by: Min Xu 
---
 .../IntelTdx/TdTcg2Dxe/MeasureBootPeCoff.c|  407 +++
 OvmfPkg/IntelTdx/TdTcg2Dxe/TdTcg2Dxe.c| 2489 +
 OvmfPkg/IntelTdx/TdTcg2Dxe/TdTcg2Dxe.inf  |  101 +
 3 files changed, 2997 insertions(+)
 create mode 100644 OvmfPkg/IntelTdx/TdTcg2Dxe/MeasureBootPeCoff.c
 create mode 100644 OvmfPkg/IntelTdx/TdTcg2Dxe/TdTcg2Dxe.c
 create mode 100644 OvmfPkg/IntelTdx/TdTcg2Dxe/TdTcg2Dxe.inf

diff --git a/OvmfPkg/IntelTdx/TdTcg2Dxe/MeasureBootPeCoff.c 
b/OvmfPkg/IntelTdx/TdTcg2Dxe/MeasureBootPeCoff.c
new file mode 100644
index ..4d542156badd
--- /dev/null
+++ b/OvmfPkg/IntelTdx/TdTcg2Dxe/MeasureBootPeCoff.c
@@ -0,0 +1,407 @@
+/** @file
+  This module implements measuring PeCoff image for Tcg2 Protocol.
+
+  Caution: This file requires additional review when modified.
+  This driver will have external input - PE/COFF image.
+  This external input must be validated carefully to avoid security issue like
+  buffer overflow, integer overflow.
+
+Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+UINTN  mTcg2DxeImageSize = 0;
+
+/**
+  Reads contents of a PE/COFF image in memory buffer.
+
+  Caution: This function may receive untrusted input.
+  PE/COFF image is external input, so this function will make sure the PE/COFF 
image content
+  read is within the image buffer.
+
+  @param  FileHandle  Pointer to the file handle to read the PE/COFF image.
+  @param  FileOffset  Offset into the PE/COFF image to begin the read 
operation.
+  @param  ReadSizeOn input, the size in bytes of the requested read 
operation.
+  On output, the number of bytes actually read.
+  @param  Buffer  Output buffer that contains the data read from the 
PE/COFF image.
+
+  @retval EFI_SUCCESS The specified portion of the PE/COFF image was read 
and the size
+**/
+EFI_STATUS
+EFIAPI
+Tcg2DxeImageRead (
+  IN VOID   *FileHandle,
+  IN UINTN  FileOffset,
+  IN OUT UINTN  *ReadSize,
+  OUTVOID   *Buffer
+  )
+{
+  UINTN  EndPosition;
+
+  if ((FileHandle == NULL) || (ReadSize == NULL) || (Buffer == NULL)) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  if (MAX_ADDRESS - FileOffset < *ReadSize) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  EndPosition = FileOffset + *ReadSize;
+  if (EndPosition > mTcg2DxeImageSize) {
+*ReadSize = (UINT32)(mTcg2DxeImageSize - FileOffset);
+  }
+
+  if (FileOffset >= mTcg2DxeImageSize) {
+*ReadSize = 0;
+  }
+
+  CopyMem (Buffer, (UINT8 *)((UINTN)FileHandle + FileOffset), *ReadSize);
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Measure PE image into TPM log based on the authenticode image hashing in
+  PE/COFF Specification 8.0 Appendix A.
+
+  Caution: This function may receive untrusted input.
+  PE/COFF image is external input, so this function will validate its data 
structure
+  within this image buffer before use.
+
+  Notes: PE/COFF image is checked by BasePeCoffLib PeCoffLoaderGetImageInfo().
+
+  @param[in]  RtmrIndex  Rtmr index
+  @param[in]  ImageAddress   Start address of image buffer.
+  @param[in]  ImageSize  Image size
+  @param[out] DigestList Digest list of this image.
+
+  @retval EFI_SUCCESSSuccessfully measure image.
+  @retval EFI_OUT_OF_RESOURCES   No enough resource to measure image.
+  @retval other error value
+**/
+EFI_STATUS
+MeasurePeImageAndExtend (
+  IN  UINT32RtmrIndex,
+  IN  EFI_PHYSICAL_ADDRESS  ImageAddress,
+  IN  UINTN ImageSize,
+  OUT TPML_DIGEST_VALUES*DigestList
+  )
+{
+  EFI_STATUS   Status;
+  EFI_IMAGE_DOS_HEADER *DosHdr;
+  UINT32   PeCoffHeaderOffset;
+  EFI_IMAGE_SECTION_HEADER *Section;
+  UINT8*HashBase;
+  UINTNHashSize;
+  UINTNSumOfBytesHashed;
+  EFI_IMAGE_SECTION_HEADER *SectionHeader;
+  UINTNIndex;
+  UINTNPos;
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION  Hdr;
+  UINT32   NumberOfRvaAndSizes;
+  UINT32   CertSize;
+  HASH_HANDLE  HashHandle;
+  PE_COFF_LOADER_IMAGE_CONTEXT 

[edk2-devel] [PATCH V2 6/8] MdePkg: Define CC Measure EventLog ACPI Table

2022-04-08 Thread Min Xu
RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

TDVF set up an ACPI table (EFI_CC_EVENTLOG_ACPI_TABLE) to pass the
event-log information. The event log created by the TD owner contains
the hashes to reconstruct the MRTD and RTMR registers.

Please refer to Sec 4.3.3 in blow link:
https://www.intel.com/content/dam/develop/external/us/en/documents/
intel-tdx-guest-hypervisor-communication-interface-1.0-344426-002.pdf

Please be noted, the definition of EFI_CC_EVENTLOG_ACPI_TABLE is a
little different from the above document. This difference is based on
below discussion:
- https://edk2.groups.io/g/devel/message/87396
- https://edk2.groups.io/g/devel/message/87402

This change will be reflected in the next version of the above document.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Ken Lu 
Cc: Sami Mujawar 
Cc: Gerd Hoffmann 
Signed-off-by: Min Xu 
---
 MdePkg/Include/Protocol/CcMeasurement.h | 21 +
 1 file changed, 21 insertions(+)

diff --git a/MdePkg/Include/Protocol/CcMeasurement.h 
b/MdePkg/Include/Protocol/CcMeasurement.h
index 68029e977fac..58123ca72163 100644
--- a/MdePkg/Include/Protocol/CcMeasurement.h
+++ b/MdePkg/Include/Protocol/CcMeasurement.h
@@ -299,4 +299,25 @@ typedef struct {
 
 extern EFI_GUID  gEfiCcFinalEventsTableGuid;
 
+//
+// Define the CC Measure EventLog ACPI Table
+//
+#pragma pack(1)
+
+typedef struct {
+  EFI_ACPI_DESCRIPTION_HEADERHeader;
+  EFI_CC_TYPECcType;
+  UINT32 Rsvd;
+  UINT64 Laml;
+  UINT64 Lasa;
+} EFI_CC_EVENTLOG_ACPI_TABLE;
+
+#pragma pack()
+
+//
+// Define the signature and revision of CC Measurement EventLog ACPI Table
+//
+#define EFI_CC_EVENTLOG_ACPI_TABLE_SIGNATURE  SIGNATURE_32('C', 'C', 'E', 'L')
+#define EFI_CC_EVENTLOG_ACPI_TABLE_REVISION   1
+
 #endif
-- 
2.29.2.windows.2



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




[edk2-devel] [PATCH V2 5/8] OvmfPkg: Add PCDs for LAML/LASA field in CC EVENTLOG ACPI table

2022-04-08 Thread Min Xu
RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

Add PCDs to records LAML/LASA field in CC EVENTLOG ACPI table.

Cc: Brijesh Singh 
Cc: Erdem Aktas 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Tom Lendacky 
Cc: Ken Lu 
Cc: Sami Mujawar 
Cc: Gerd Hoffmann 
Signed-off-by: Min Xu 
---
 OvmfPkg/OvmfPkg.dec | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index b9ca44120289..f471f3bbeec2 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -436,6 +436,12 @@
   #2 - set by GOP Driver.
   gUefiOvmfPkgTokenSpaceGuid.PcdVideoResolutionSource|0|UINT8|0x64
 
+  ## This PCD records LAML field in CC EVENTLOG ACPI table.
+  gUefiOvmfPkgTokenSpaceGuid.PcdCcEventlogAcpiTableLaml|0|UINT32|0x66
+
+  ## This PCD records LASA field in CC EVENTLOG ACPI table.
+  gUefiOvmfPkgTokenSpaceGuid.PcdCcEventlogAcpiTableLasa|0|UINT64|0x67
+
 [PcdsFeatureFlag]
   gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOLEAN|0x1c
   gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|FALSE|BOOLEAN|0x1d
-- 
2.29.2.windows.2



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




[edk2-devel] [PATCH V2 4/8] OvmfPkg/IntelTdx: Measure Td HobList and Configuration FV

2022-04-08 Thread Min Xu
RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

TdHobList and Configuration FV are external data provided by Host VMM.
These are not trusted in Td guest. So they should be validated , measured
and extended to Td RTMR registers. In the meantime 2 EFI_CC_EVENT_HOB are
created. These 2 GUIDed HOBs carry the hash value of TdHobList and
Configuration FV. In DXE phase EFI_CC_EVENT can be created based on these
2 GUIDed HOBs.

Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Brijesh Singh 
Cc: Erdem Aktas 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Tom Lendacky 
Cc: Gerd Hoffmann 
Signed-off-by: Min Xu 
---
 OvmfPkg/IntelTdx/IntelTdxX64.dsc  |   3 +
 OvmfPkg/Library/PeilessStartupLib/IntelTdx.c  | 498 ++
 .../PeilessStartupLib/PeilessStartup.c|  30 ++
 .../PeilessStartupInternal.h  |  57 ++
 .../PeilessStartupLib/PeilessStartupLib.inf   |   7 +-
 5 files changed, 593 insertions(+), 2 deletions(-)
 create mode 100644 OvmfPkg/Library/PeilessStartupLib/IntelTdx.c

diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
index 245155d41b30..caae49d524f9 100644
--- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
+++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
@@ -520,6 +520,9 @@
   OvmfPkg/IntelTdx/Sec/SecMain.inf {
 
   
NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
+  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
+  
HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterTdx.inf
+  NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf
   }
 
   #
diff --git a/OvmfPkg/Library/PeilessStartupLib/IntelTdx.c 
b/OvmfPkg/Library/PeilessStartupLib/IntelTdx.c
new file mode 100644
index ..bb905cf5cd6a
--- /dev/null
+++ b/OvmfPkg/Library/PeilessStartupLib/IntelTdx.c
@@ -0,0 +1,498 @@
+/** @file
+  Copyright (c) 2022, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "PeilessStartupInternal.h"
+
+#pragma pack(1)
+
+typedef struct {
+  UINT32   count;
+  TPMI_ALG_HASHhashAlg;
+  BYTE sha384[SHA384_DIGEST_SIZE];
+} TDX_DIGEST_VALUE;
+
+#define HANDOFF_TABLE_DESC  "TdxTable"
+typedef struct {
+  UINT8  TableDescriptionSize;
+  UINT8  TableDescription[sizeof (HANDOFF_TABLE_DESC)];
+  UINT64 NumberOfTables;
+  EFI_CONFIGURATION_TABLETableEntry[1];
+} TDX_HANDOFF_TABLE_POINTERS2;
+
+#define FV_HANDOFF_TABLE_DESC  "Fv(----)"
+typedef struct {
+  UINT8   BlobDescriptionSize;
+  UINT8   BlobDescription[sizeof (FV_HANDOFF_TABLE_DESC)];
+  EFI_PHYSICAL_ADDRESSBlobBase;
+  UINT64  BlobLength;
+} FV_HANDOFF_TABLE_POINTERS2;
+
+#pragma pack()
+
+#define INVALID_PCR2MR_INDEX  0xFF
+
+/**
+RTMR[0]  => PCR[1,7]
+RTMR[1]  => PCR[2,3,4,5]
+RTMR[2]  => PCR[8~15]
+RTMR[3]  => NA
+  Note:
+PCR[0] is mapped to MRTD and should not appear here.
+PCR[6] is reserved for OEM. It is not used.
+**/
+UINT8
+GetMappedRtmrIndex (
+  UINT32  PCRIndex
+  )
+{
+  UINT8  RtmrIndex;
+
+  if ((PCRIndex == 6) || (PCRIndex == 0) || (PCRIndex > 15)) {
+DEBUG ((DEBUG_ERROR, "Invalid PCRIndex(%d) map to MR Index.\n", PCRIndex));
+ASSERT (FALSE);
+return INVALID_PCR2MR_INDEX;
+  }
+
+  RtmrIndex = 0;
+  if ((PCRIndex == 1) || (PCRIndex == 7)) {
+RtmrIndex = 0;
+  } else if ((PCRIndex >= 2) && (PCRIndex < 6)) {
+RtmrIndex = 1;
+  } else if ((PCRIndex >= 8) && (PCRIndex <= 15)) {
+RtmrIndex = 2;
+  }
+
+  return RtmrIndex;
+}
+
+/**
+  Tpm measure and log data, and extend the measurement result into a specific 
PCR.
+  @param[in]  PcrIndex PCR Index.
+  @param[in]  EventTypeEvent type.
+  @param[in]  EventLog Measurement event log.
+  @param[in]  LogLen   Event log length in bytes.
+  @param[in]  HashData The start of the data buffer to be hashed, 
extended.
+  @param[in]  HashDataLen  The length, in bytes, of the buffer referenced 
by HashData
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_UNSUPPORTED   TPM device not available.
+  @retval EFI_OUT_OF_RESOURCES  Out of memory.
+  @retval EFI_DEVICE_ERROR  The operation was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+TdxMeasureAndLogData (
+  IN UINT32  PcrIndex,
+  IN UINT32  EventType,
+  IN VOID*EventLog,
+  IN UINT32  LogLen,
+  IN VOID*HashData,
+  IN UINT64  HashDataLen
+  )
+{
+  EFI_STATUS  Status;
+  UINT32  RtmrIndex;
+  VOID*EventHobData;
+  TCG_PCR_EVENT2  *TcgPcrEvent2;
+  UINT8   *DigestBuffer;
+  TDX_DIGEST_VALUE*TdxDigest;
+  TPML_DIGEST_VALUES  DigestList;
+  

[edk2-devel] [PATCH V2 2/8] CryptoPkg: Add SecCryptLib

2022-04-08 Thread Min Xu
RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

This is the Cryptographic library instance for SEC. The motivation of
this library is to support SHA384 in SEC phase for Td guest. So only
Hash/CryptSha512.c is included which supports SHA384 and SHA512.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Guomin Jiang 
Cc: Gerd Hoffmann 
Signed-off-by: Min Xu 
---
 CryptoPkg/CryptoPkg.dsc   |  4 ++
 .../Library/BaseCryptLib/SecCryptLib.inf  | 67 +++
 2 files changed, 71 insertions(+)
 create mode 100644 CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf

diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc
index 0aa72ed87846..b814e9616454 100644
--- a/CryptoPkg/CryptoPkg.dsc
+++ b/CryptoPkg/CryptoPkg.dsc
@@ -109,6 +109,9 @@
 [LibraryClasses.ARM]
   ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf
 
+[LibraryClasses.common.SEC]
+  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
+
 [LibraryClasses.common.PEIM]
   PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
   
ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
@@ -236,6 +239,7 @@
 !if $(CRYPTO_SERVICES) == PACKAGE
 [Components]
   CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+  CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
   CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
   CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
   CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
diff --git a/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
new file mode 100644
index ..6ef2f67e35dd
--- /dev/null
+++ b/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
@@ -0,0 +1,67 @@
+## @file
+#  Cryptographic Library Instance for SEC.
+#
+#  Caution: This module requires additional review when modified.
+#  This library will have external input - signature.
+#  This external input must be validated carefully to avoid security issues 
such as
+#  buffer overflow or integer overflow.
+#
+#  Copyright (c) 2021, Intel Corporation. All rights reserved.
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = SecCryptLib
+  FILE_GUID  = 3689D343-0D32-4284-8053-BF10537990E8
+  MODULE_TYPE= BASE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = BaseCryptLib|SEC
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64
+#
+
+[Sources]
+  InternalCryptLib.h
+  Hash/CryptSha512.c
+
+  SysCall/CrtWrapper.c
+  SysCall/ConstantTimeClock.c
+  SysCall/BaseMemAllocation.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  CryptoPkg/CryptoPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  MemoryAllocationLib
+  DebugLib
+  OpensslLib
+  IntrinsicLib
+
+#
+# Remove these [BuildOptions] after this library is cleaned up
+#
+[BuildOptions]
+  #
+  # suppress the following warnings so we do not break the build with 
warnings-as-errors:
+  # C4090: 'function' : different 'const' qualifiers
+  # C4718: 'function call' : recursive call has no side effects, deleting
+  #
+  MSFT:*_*_*_CC_FLAGS = /wd4090 /wd4718
+
+  # -JCryptoPkg/Include : To disable the use of the system includes provided 
by RVCT
+  # --diag_remark=1 : Reduce severity of "#1-D: last line of file ends 
without a newline"
+  RVCT:*_*_ARM_CC_FLAGS = -JCryptoPkg/Include --diag_remark=1
+
+  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
+  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
+  GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
+
+  XCODE:*_*_*_CC_FLAGS = -std=c99
-- 
2.29.2.windows.2



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




[edk2-devel] [PATCH V2 1/8] Security: Add HashLibBaseCryptoRouterTdx

2022-04-08 Thread Min Xu
RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

This library provides hash service by registered hash handler in Td
guest. It redirects hash request to each individual hash handler
(currently only SHA384 is supported). After that the hash value is
extended to Td RTMR registers which is similar to TPM PCRs.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Gerd Hoffmann 
Signed-off-by: Min Xu 
---
 .../HashLibBaseCryptoRouterTdx.c  | 214 ++
 .../HashLibBaseCryptoRouterTdx.inf|  41 
 SecurityPkg/SecurityPkg.dsc   |  10 +
 3 files changed, 265 insertions(+)
 create mode 100644 
SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterTdx.c
 create mode 100644 
SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterTdx.inf

diff --git 
a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterTdx.c 
b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterTdx.c
new file mode 100644
index ..77e2a14c19be
--- /dev/null
+++ b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterTdx.c
@@ -0,0 +1,214 @@
+/** @file
+  This library is BaseCrypto router for Tdx.
+
+Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved. 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "HashLibBaseCryptoRouterCommon.h"
+
+//
+// Currently TDX supports SHA384.
+//
+#define TDX_HASH_COUNT  1
+HASH_INTERFACE  mHashInterface[TDX_HASH_COUNT] = {
+  {
+{ 0 }, NULL, NULL, NULL
+  }
+};
+
+UINTNmHashInterfaceCount  = 0;
+HASH_HANDLE  mHashCtx[TDX_HASH_COUNT] = { 0 };
+
+/**
+  Start hash sequence.
+
+  @param HashHandle Hash handle.
+
+  @retval EFI_SUCCESS  Hash sequence start and HandleHandle returned.
+  @retval EFI_OUT_OF_RESOURCES No enough resource to start hash.
+**/
+EFI_STATUS
+EFIAPI
+HashStart (
+  OUT HASH_HANDLE  *HashHandle
+  )
+{
+  HASH_HANDLE  *HashCtx;
+
+  if (mHashInterfaceCount == 0) {
+ASSERT (FALSE);
+return EFI_UNSUPPORTED;
+  }
+
+  HashCtx = mHashCtx;
+  mHashInterface[0].HashInit ([0]);
+
+  *HashHandle = (HASH_HANDLE)HashCtx;
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Update hash sequence data.
+
+  @param HashHandleHash handle.
+  @param DataToHashData to be hashed.
+  @param DataToHashLen Data size.
+
+  @retval EFI_SUCCESS Hash sequence updated.
+**/
+EFI_STATUS
+EFIAPI
+HashUpdate (
+  IN HASH_HANDLE  HashHandle,
+  IN VOID *DataToHash,
+  IN UINTNDataToHashLen
+  )
+{
+  HASH_HANDLE  *HashCtx;
+
+  if (mHashInterfaceCount == 0) {
+ASSERT (FALSE);
+return EFI_UNSUPPORTED;
+  }
+
+  HashCtx = (HASH_HANDLE *)HashHandle;
+  mHashInterface[0].HashUpdate (HashCtx[0], DataToHash, DataToHashLen);
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Hash sequence complete and extend to PCR.
+
+  @param HashHandleHash handle.
+  @param PcrIndex  PCR to be extended.
+  @param DataToHashData to be hashed.
+  @param DataToHashLen Data size.
+  @param DigestListDigest list.
+
+  @retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
+**/
+EFI_STATUS
+EFIAPI
+HashCompleteAndExtend (
+  IN HASH_HANDLE  HashHandle,
+  IN TPMI_DH_PCR  PcrIndex,
+  IN VOID *DataToHash,
+  IN UINTNDataToHashLen,
+  OUT TPML_DIGEST_VALUES  *DigestList
+  )
+{
+  TPML_DIGEST_VALUES  Digest;
+  HASH_HANDLE *HashCtx;
+  EFI_STATUS  Status;
+
+  if (mHashInterfaceCount == 0) {
+ASSERT (FALSE);
+return EFI_UNSUPPORTED;
+  }
+
+  HashCtx = (HASH_HANDLE *)HashHandle;
+  ZeroMem (DigestList, sizeof (*DigestList));
+
+  mHashInterface[0].HashUpdate (HashCtx[0], DataToHash, DataToHashLen);
+  mHashInterface[0].HashFinal (HashCtx[0], );
+  Tpm2SetHashToDigestList (DigestList, );
+
+  ASSERT (DigestList->count == 1 && DigestList->digests[0].hashAlg == 
TPM_ALG_SHA384);
+
+  Status = TdExtendRtmr (
+ (UINT32 *)DigestList->digests[0].digest.sha384,
+ SHA384_DIGEST_SIZE,
+ (UINT8)PcrIndex
+ );
+
+  ASSERT (!EFI_ERROR (Status));
+  return Status;
+}
+
+/**
+  Hash data and extend to RTMR.
+
+  @param PcrIndex  PCR to be extended.
+  @param DataToHashData to be hashed.
+  @param DataToHashLen Data size.
+  @param DigestListDigest list.
+
+  @retval EFI_SUCCESS Hash data and DigestList is returned.
+**/
+EFI_STATUS
+EFIAPI
+HashAndExtend (
+  IN TPMI_DH_PCR  PcrIndex,
+  IN VOID *DataToHash,
+  IN UINTNDataToHashLen,
+  OUT TPML_DIGEST_VALUES  *DigestList
+  )
+{
+  HASH_HANDLE  HashHandle;
+  EFI_STATUS   Status;
+
+  if (mHashInterfaceCount == 0) {
+ASSERT (FALSE);
+return EFI_UNSUPPORTED;
+  }
+
+  ASSERT (TdIsEnabled ());
+
+  HashStart ();
+  HashUpdate (HashHandle, DataToHash, DataToHashLen);
+  Status = HashCompleteAndExtend (HashHandle, PcrIndex, NULL, 

[edk2-devel] [PATCH V2 3/8] SecurityPkg: Add definition of EFI_CC_EVENT_HOB_GUID

2022-04-08 Thread Min Xu
RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

EFI_CC_EVENT_HOB_GUID is the global ID of a GUIDed HOB used to pass
TDX_DIGEST_VALUE from SEC to a DXE Driver ( This DXE driver will
be introduced in the following commit in this patch-sets ). In that
DXE driver this GUIDed HOB will be parsed and the TDX_DIGEST_VALUE
then will be extracted. After that a EFI_CC_EVENT will be created
based on it.

Cc: Gerd Hoffmann 
Cc: Jiewen Yao 
Cc: Sami Mujawar 
Cc: Jian J Wang 
Signed-off-by: Min Xu 
---
 SecurityPkg/Include/Guid/CcEventHob.h | 22 ++
 SecurityPkg/SecurityPkg.dec   |  4 
 2 files changed, 26 insertions(+)
 create mode 100644 SecurityPkg/Include/Guid/CcEventHob.h

diff --git a/SecurityPkg/Include/Guid/CcEventHob.h 
b/SecurityPkg/Include/Guid/CcEventHob.h
new file mode 100644
index ..072999ce92de
--- /dev/null
+++ b/SecurityPkg/Include/Guid/CcEventHob.h
@@ -0,0 +1,22 @@
+/** @file
+  Defines the HOB GUID used to pass a CC_EVENT from SEC to
+  a CC DXE Driver. A GUIDed HOB is generated for each measurement
+  made in the SEC Phase.
+
+Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef CC_EVENT_HOB_H_
+#define CC_EVENT_HOB_H_
+
+//
+// The Global ID of a GUIDed HOB used to pass a CC_EVENT from SEC to a CC DXE 
Driver.
+//
+#define EFI_CC_EVENT_HOB_GUID \
+  { 0x20f8fd36, 0x6d00, 0x40fb, { 0xb7, 0x04, 0xd1, 0x2c, 0x15, 0x3c, 0x62, 
0xeb } }
+
+extern EFI_GUID  gCcEventEntryHobGuid;
+
+#endif
diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec
index 9f7a032d60d5..0ee75efc1a97 100644
--- a/SecurityPkg/SecurityPkg.dec
+++ b/SecurityPkg/SecurityPkg.dec
@@ -136,6 +136,10 @@
   ## Include/Guid/TcgEventHob.h
   gTcgEvent2EntryHobGuid = { 0xd26c221e, 0x2430, 0x4c8a, { 0x91, 
0x70, 0x3f, 0xcb, 0x45, 0x0, 0x41, 0x3f }}
 
+  ## Hob GUID used to pass a CC_EVENT from SEC to a CC DXE Driver.
+  ## Include/Guid/CcEventHob.h
+  gCcEventEntryHobGuid   = { 0x20f8fd36, 0x6d00, 0x40fb, { 0xb7, 
0x04, 0xd1, 0x2c, 0x15, 0x3c, 0x62, 0xeb }}
+
   ## HOB GUID used to record TPM device error.
   #  Include/Guid/TcgEventHob.h
   gTpmErrorHobGuid   = { 0xef598499, 0xb25e, 0x473a, { 0xbf, 
0xaf, 0xe7, 0xe5, 0x7d, 0xce, 0x82, 0xc4 }}
-- 
2.29.2.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88582): https://edk2.groups.io/g/devel/message/88582
Mute This Topic: https://groups.io/mt/90330663/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/8] Enable RTMR based measurement and measure boot for Td guest

2022-04-08 Thread Min Xu
RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3853

Intel's Trust Domain Extensions (Intel TDX) refers to an Intel technology
that extends Virtual Machines Extensions (VMX) and Multi-Key Total Memory
Encryption (MKTME) with a new kind of virutal machines guest called a
Trust Domain (TD). A TD is desinged to run in a CPU mode that protects the
confidentiality of TD memory contents and the TD's CPU state from other
software, including the hosting Virtual-Machine Monitor (VMM), unless
explicitly shared by the TD itself.

There are 2 configurations for TDVF to upstream. See below link for
the definitions of the 2 configurations.
https://edk2.groups.io/g/devel/message/76367

This patch-set is to enable below features of Config-B in OvmfPkg.
 - Enable RTMR based measurement and measured boot
 - Install CC_MEASUREMENT_PROTOCOL instance in Td guest

The measurement for the other components, such as kernel image, initrd,
will be in the following patch-sets.

Patch 1:
HashLibBaseCryptoRouterTdx provides SHA384 service and extend to 
RTMR registers.

Patch 2:
SecCryptLib is the cryptographic library instance for SEC.

Patch 3 - 7:
These 5 patches are related to RTMR based measurement and
CC Eventlog ACPI table.

Patch 8:
Update IntelTdxX64.dsc/IntelTdxX64.fdf to support RTMR based
measurement and measured boot.

Code at: https://github.com/mxu9/edk2/tree/tdvf_wave4.v2

v2 changes:
 - Move the definition of EFI_CC_EVENT_HOB_GUID from MdePkg to
   SecurityPkg.
 - Update the definition of EFI_CC_EVENTLOG_ACPI_TABLE based
   on below discussion:
   https://edk2.groups.io/g/devel/message/87396
   https://edk2.groups.io/g/devel/message/87402
 - Update the code base to 94f905b3bf.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Gerd Hoffmann 
Cc: Xiaoyu Lu 
Cc: Guomin Jiang 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Sami Mujawar 
Cc: Ken Lu 
Cc: Ard Biesheuvel 
Cc: Jordan Justen 
Cc: Brijesh Singh 
Cc: Erdem Aktas 
Cc: James Bottomley 
Cc: Tom Lendacky 
Signed-off-by: Min Xu 

Min Xu (8):
  Security: Add HashLibBaseCryptoRouterTdx
  CryptoPkg: Add SecCryptLib
  SecurityPkg: Add definition of EFI_CC_EVENT_HOB_GUID
  OvmfPkg/IntelTdx: Measure Td HobList and Configuration FV
  OvmfPkg: Add PCDs for LAML/LASA field in CC EVENTLOG ACPI table
  MdePkg: Define CC Measure EventLog ACPI Table
  OvmfPkg/IntelTdx: Add TdTcg2Dxe
  OvmfPkg/IntelTdx: Enable RTMR based measurement and measure boot

 CryptoPkg/CryptoPkg.dsc   |4 +
 .../Library/BaseCryptLib/SecCryptLib.inf  |   67 +
 MdePkg/Include/Protocol/CcMeasurement.h   |   21 +
 OvmfPkg/IntelTdx/IntelTdxX64.dsc  |   15 +-
 OvmfPkg/IntelTdx/IntelTdxX64.fdf  |5 +
 .../IntelTdx/TdTcg2Dxe/MeasureBootPeCoff.c|  407 +++
 OvmfPkg/IntelTdx/TdTcg2Dxe/TdTcg2Dxe.c| 2489 +
 OvmfPkg/IntelTdx/TdTcg2Dxe/TdTcg2Dxe.inf  |  101 +
 OvmfPkg/Library/PeilessStartupLib/IntelTdx.c  |  498 
 .../PeilessStartupLib/PeilessStartup.c|   30 +
 .../PeilessStartupInternal.h  |   57 +
 .../PeilessStartupLib/PeilessStartupLib.inf   |7 +-
 OvmfPkg/OvmfPkg.dec   |6 +
 SecurityPkg/Include/Guid/CcEventHob.h |   22 +
 .../HashLibBaseCryptoRouterTdx.c  |  214 ++
 .../HashLibBaseCryptoRouterTdx.inf|   41 +
 SecurityPkg/SecurityPkg.dec   |4 +
 SecurityPkg/SecurityPkg.dsc   |   10 +
 18 files changed, 3995 insertions(+), 3 deletions(-)
 create mode 100644 CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
 create mode 100644 OvmfPkg/IntelTdx/TdTcg2Dxe/MeasureBootPeCoff.c
 create mode 100644 OvmfPkg/IntelTdx/TdTcg2Dxe/TdTcg2Dxe.c
 create mode 100644 OvmfPkg/IntelTdx/TdTcg2Dxe/TdTcg2Dxe.inf
 create mode 100644 OvmfPkg/Library/PeilessStartupLib/IntelTdx.c
 create mode 100644 SecurityPkg/Include/Guid/CcEventHob.h
 create mode 100644 
SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterTdx.c
 create mode 100644 
SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterTdx.inf

-- 
2.29.2.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88580): https://edk2.groups.io/g/devel/message/88580
Mute This Topic: https://groups.io/mt/90330661/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] UEFI-SCT: SctPkg: Updated the check for monotonic count after restart

2022-04-08 Thread Gao Jie
Hi Eday,

The patch looks good to me.

Reviewed-by: Barton Gao 

Thanks
Barton

-邮件原件-
发件人: devel@edk2.groups.io  代表 G Edhaya Chandran
发送时间: 2022年3月3日 16:59
收件人: devel@edk2.groups.io
主题: [edk2-devel] [PATCH 1/1] UEFI-SCT: SctPkg: Updated the check for monotonic 
count after restart

Updated the check for montonic count in the case of after restart

>From the UEFI Spec:
"The platform’s monotonic counter is comprised of two parts: the high 32 bits 
and the low 32 bits.
The low 32-bit value is volatile and is reset to zero on every system reset.
It is increased by 1 on every call to GetNextMonotonicCount().
The high 32-bit value is nonvolatile and is increased by one on
whenever the system resets or the low 32-bit counter overflows."

It was found in one case where the higher 32-bit increased by 2
presumably due to the overflow of lower 32-bit counter.
Update the logic to handle this case and to print a warning.

Please find more details in the ticket: 
https://bugzilla.tianocore.org/show_bug.cgi?id=2774

Cc: Barton Gao 
Cc: Carolyn Gjertsen 
Cc: Heinrich Schuchardt 
Cc: Samer El-Haj-Mahmoud 

Signed-off-by: G Edhaya Chandran
---
 .../MiscBootServicesBBTestFunction.c  | 20 +--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
index 5d631c16d58b..12703d46f98c 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
@@ -1707,12 +1707,20 @@ GetNextMonotonicCountStep2:
TplArray[Index]
);
 
-if (SctRShiftU64 (Count2, 32) == SctRShiftU64 (Count, 32) + 1) {
-  AssertionType = EFI_TEST_ASSERTION_PASSED;
-} else {
-  AssertionType = EFI_TEST_ASSERTION_FAILED;
-}
-StandardLib->RecordAssertion (
+//The new count of upper 32 bits must be atleast 1 more than the old count.
+//Pass case: new count is equal to old count + 1
+if (SctRShiftU64 (Count2, 32) <= SctRShiftU64 (Count, 32)) {
+  AssertionType = EFI_TEST_ASSERTION_FAILED;
+} else {
+  //If new count is more that old count + 1, then print warning.
+  if (SctRShiftU64 (Count2, 32) > SctRShiftU64 (Count, 32) + 1) {
+AssertionType = EFI_TEST_ASSERTION_WARNING;
+  } else {
+//new count == old count + 1
+AssertionType = EFI_TEST_ASSERTION_PASSED;
+  }
+   }
+   StandardLib->RecordAssertion (
StandardLib,
AssertionType,
Index==0? \
-- 
2.17.1










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




Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 14/33] BaseTools: BaseTools changes for LoongArch platform.

2022-04-08 Thread Abner Chang
Acked-by: Abner Chang 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chao Li
> Sent: Wednesday, February 9, 2022 2:55 PM
> To: devel@edk2.groups.io
> Cc: Bob Feng ; Liming Gao
> ; Yuwei Chen ; Baoqi
> Zhang 
> Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 14/33]
> BaseTools: BaseTools changes for LoongArch platform.
> 
> BaseTools define template files changes for building EDK2 LoongArch
> platform.
> 
> Cc: Bob Feng 
> Cc: Liming Gao 
> Cc: Yuwei Chen 
> 
> Signed-off-by: Chao Li 
> Co-authored-by: Baoqi Zhang 
> ---
>  BaseTools/Conf/tools_def.template | 43
> ++-
>  1 file changed, 42 insertions(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Conf/tools_def.template
> b/BaseTools/Conf/tools_def.template
> index 85b8afbb2d..67b6c69dcf 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -4,6 +4,7 @@
>  #  Portions copyright (c) 2011 - 2019, ARM Ltd. All rights reserved.
>  #  Copyright (c) 2015, Hewlett-Packard Development Company, L.P.
>  #  (C) Copyright 2020, Hewlett Packard Enterprise Development LP
> +#  Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> reserved.
>  #  Copyright (c) Microsoft Corporation
>  #
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
> @@ -267,7 +268,7 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
>  #   Intel(r) ACPI Compiler from
>  #   https://acpica.org/downloads
>  #   GCC5-Linux,Windows-  Requires:
> -# GCC 5 with LTO support, targeting 
> x86_64-linux-gnu,
> aarch64-linux-gnu, arm-linux-gnueabi or riscv64-linux-gnu
> +# GCC 5 with LTO support, targeting 
> x86_64-linux-gnu,
> aarch64-linux-gnu, arm-linux-gnueabi, riscv64-linux-gnu ro loongarch64-linux-
> gnu
>  #Optional:
>  # Required to build platforms or ACPI tables:
>  #   Intel(r) ACPI Compiler from
> @@ -1871,6 +1872,7 @@ DEFINE GCC_ALL_CC_FLAGS= -g -Os -fshort-
> wchar -fno-builtin -fno-stri
>  DEFINE GCC_IA32_CC_FLAGS   = DEF(GCC_ALL_CC_FLAGS) -m32 -
> malign-double -freorder-blocks -freorder-blocks-and-partition -O2 -mno-
> stack-arg-probe
>  DEFINE GCC_X64_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mno-red-
> zone -Wno-address -mno-stack-arg-probe
>  DEFINE GCC_ARM_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mlittle-
> endian -mabi=aapcs -fno-short-enums -funsigned-char -ffunction-sections -
> fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-
> abi=soft -fno-pic -fno-pie
> +DEFINE GCC_LOONGARCH64_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -
> march=loongarch64 -mabi=lp64d -Wa,-mla-global-with-abs -fno-plt -Wno-
> address -fno-short-enums -fsigned-char -ffunction-sections -fdata-sections
>  DEFINE GCC_ARM_CC_XIPFLAGS = -mno-unaligned-access
>  DEFINE GCC_AARCH64_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) -mlittle-
> endian -fno-short-enums -fverbose-asm -funsigned-char  -ffunction-sections
> -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-
> unwind-tables -fno-pic -fno-pie -ffixed-x18
>  DEFINE GCC_AARCH64_CC_XIPFLAGS = -mstrict-align -mgeneral-regs-only
> @@ -1878,12 +1880,15 @@ DEFINE GCC_DLINK_FLAGS_COMMON  = -
> nostdlib --pie
>  DEFINE GCC_DLINK2_FLAGS_COMMON = -Wl,--
> script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
>  DEFINE GCC_IA32_X64_DLINK_COMMON   =
> DEF(GCC_DLINK_FLAGS_COMMON) --gc-sections
>  DEFINE GCC_ARM_AARCH64_DLINK_COMMON= -Wl,--emit-relocs -nostdlib
> -Wl,--gc-sections -u $(IMAGE_ENTRY_POINT) -Wl,-
> e,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map
> +DEFINE GCC_LOONGARCH64_DLINK_COMMON= -Wl,--emit-relocs -
> nostdlib -Wl,--gc-sections -u $(IMAGE_ENTRY_POINT) -Wl,-
> e,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map
>  DEFINE GCC_ARM_DLINK_FLAGS =
> DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20 -
> Wl,--pic-veneer
>  DEFINE GCC_AARCH64_DLINK_FLAGS =
> DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20
> +DEFINE GCC_LOONGARCH64_DLINK_FLAGS =
> DEF(GCC_LOONGARCH64_DLINK_COMMON) -z common-page-size=0x20
>  DEFINE GCC_ARM_AARCH64_ASLDLINK_FLAGS = -Wl,--
> defsym=PECOFF_HEADER_SIZE=0 DEF(GCC_DLINK2_FLAGS_COMMON) -z
> common-page-size=0x20
>  DEFINE GCC_IA32_X64_ASLDLINK_FLAGS =
> DEF(GCC_IA32_X64_DLINK_COMMON) --entry _ReferenceAcpiTable -u
> $(IMAGE_ENTRY_POINT)
>  DEFINE GCC_ARM_ASLDLINK_FLAGS  = DEF(GCC_ARM_DLINK_FLAGS) -
> Wl,--entry,ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT)
> DEF(GCC_ARM_AARCH64_ASLDLINK_FLAGS)
>  DEFINE GCC_AARCH64_ASLDLINK_FLAGS  =
> DEF(GCC_AARCH64_DLINK_FLAGS) -Wl,--entry,ReferenceAcpiTable -u
> $(IMAGE_ENTRY_POINT) DEF(GCC_ARM_AARCH64_ASLDLINK_FLAGS)
> +DEFINE GCC_LOONGARCH64_ASLDLINK_FLAGS =
> DEF(GCC_LOONGARCH64_DLINK_FLAGS) --entry ReferenceAcpiTable -u
> $(IMAGE_ENTRY_POINT)
>  DEFINE 

Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 13/33] BaseTools: BaseTools changes for LoongArch platform.

2022-04-08 Thread Abner Chang



> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chao Li
> Sent: Wednesday, February 9, 2022 2:55 PM
> To: devel@edk2.groups.io
> Cc: Bob Feng ; Liming Gao
> ; Yuwei Chen ; Baoqi
> Zhang 
> Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 13/33]
> BaseTools: BaseTools changes for LoongArch platform.
> 
> C code changes for building EDK2 LoongArch platform.
> 
> Cc: Bob Feng 
> Cc: Liming Gao 
> Cc: Yuwei Chen 
> 
> Signed-off-by: Chao Li 
> Co-authored-by: Baoqi Zhang 
> ---
>  BaseTools/Source/C/Common/BasePeCoff.c|  15 +-
>  BaseTools/Source/C/Common/PeCoffLoaderEx.c|  76 +
>  BaseTools/Source/C/GenFv/GenFvInternalLib.c   | 128 ++-
>  BaseTools/Source/C/GenFw/Elf64Convert.c   | 153 +-
>  BaseTools/Source/C/GenFw/elf_common.h |  58 +++
>  .../C/Include/IndustryStandard/PeImage.h  |  57 ---
>  6 files changed, 454 insertions(+), 33 deletions(-)
> 
> diff --git a/BaseTools/Source/C/Common/BasePeCoff.c
> b/BaseTools/Source/C/Common/BasePeCoff.c
> index 62fbb2985c..30400d1341 100644
> --- a/BaseTools/Source/C/Common/BasePeCoff.c
> +++ b/BaseTools/Source/C/Common/BasePeCoff.c
> @@ -5,6 +5,7 @@
>  Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
>  Portions Copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
>  Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All
> rights reserved.
> +Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All
> rights reserved.
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  **/
> @@ -68,6 +69,14 @@ PeCoffLoaderRelocateRiscVImage (
>IN UINT64  Adjust
>);
> 
> +RETURN_STATUS
> +PeCoffLoaderRelocateLoongArch64Image (
> +  IN UINT16  *Reloc,
> +  IN OUT CHAR8   *Fixup,
> +  IN OUT CHAR8   **FixupData,
> +  IN UINT64  Adjust
> +  );
> +
>  STATIC
>  RETURN_STATUS
>  PeCoffLoaderGetPeHeader (
> @@ -184,7 +193,8 @@ Returns:
>ImageContext->Machine != EFI_IMAGE_MACHINE_ARMT && \
>ImageContext->Machine != EFI_IMAGE_MACHINE_EBC  && \
>ImageContext->Machine != EFI_IMAGE_MACHINE_AARCH64 && \
> -  ImageContext->Machine != EFI_IMAGE_MACHINE_RISCV64) {
> +  ImageContext->Machine != EFI_IMAGE_MACHINE_RISCV64 && \
> +  ImageContext->Machine != EFI_IMAGE_MACHINE_LOONGARCH64) {
>  if (ImageContext->Machine == IMAGE_FILE_MACHINE_ARM) {
>//
>// There are two types of ARM images. Pure ARM and ARM/Thumb.
> @@ -815,6 +825,9 @@ Returns:
>  case EFI_IMAGE_MACHINE_RISCV64:
>Status = PeCoffLoaderRelocateRiscVImage (Reloc, Fixup, ,
> Adjust);
>break;
> +case EFI_IMAGE_MACHINE_LOONGARCH64:
> +  Status = PeCoffLoaderRelocateLoongArch64Image (Reloc, Fixup,
> , Adjust);
> +  break;
>  default:
>Status = RETURN_UNSUPPORTED;
>break;
> diff --git a/BaseTools/Source/C/Common/PeCoffLoaderEx.c
> b/BaseTools/Source/C/Common/PeCoffLoaderEx.c
> index 799f282970..b50ce8bdef 100644
> --- a/BaseTools/Source/C/Common/PeCoffLoaderEx.c
> +++ b/BaseTools/Source/C/Common/PeCoffLoaderEx.c
> @@ -4,6 +4,7 @@ IA32 and X64 Specific relocation fixups
>  Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
>  Portions Copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
>  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights
> reserved.
> +Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> reserved.
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  --*/
> @@ -332,3 +333,78 @@ PeCoffLoaderRelocateArmImage (
> 
>return RETURN_SUCCESS;
>  }
> +
> +/**
> +  Performs a LoongArch specific relocation fixup.
> +
> +  @param  Reloc   Pointer to the relocation record.
> +  @param  Fixup   Pointer to the address to fix up.
> +  @param  FixupData   Pointer to a buffer to log the fixups.
> +  @param  Adjust  The offset to adjust the fixup.
> +
> +  @return Status code.
> +**/
> +RETURN_STATUS
> +PeCoffLoaderRelocateLoongArch64Image (
> +  IN UINT16  *Reloc,
> +  IN OUT CHAR8   *Fixup,
> +  IN OUT CHAR8   **FixupData,
> +  IN UINT64  Adjust
> +  )
> +{
> +  UINT8  RelocType;
> +  UINT64 Value = 0;
> +  UINT64 Tmp1 = 0;
> +  UINT64 Tmp2 = 0;
> +
> +  RelocType = ((*Reloc) >> 12);
> +
> +  switch (RelocType) {
> +case EFI_IMAGE_REL_BASED_LOONGARCH64_MARK_LA:
> +  /* The next four instructions are used to load a 64 bit address, we
> change it together*/
> +  Value = (*(UINT32*)Fixup & 0x1e0) << 7 |   /* lu12i.w 20bits 
> from
> bit5 */
Please use double back slash for the comment in the function. So the comment in 
the entire file look consistent. This applied to the changes in this patch.

> +  (*((UINT32*)Fixup + 1) & 0x3ffc00) >> 10;  /* ori  12bits from 
> bit10 */
> +  Tmp1 = *((UINT32*)Fixup + 2) & 0x1e0;  /* lu32i.d 20bits 
> from bit5
> */
> +  Tmp2 = *((UINT32*)Fixup + 

Re: [edk2-devel] [PATCH v3] OvmfPkg/BhyveBhfPkg: add support for QemuFwCfg

2022-04-08 Thread Yao, Jiewen
Acked-by: Jiewen Yao 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Corvin
> Köhne
> Sent: Friday, April 8, 2022 1:53 PM
> Cc: Corvin Köhne ; Köhne, Corvin
> ; Ard Biesheuvel ; Yao,
> Jiewen ; Justen, Jordan L ;
> devel@edk2.groups.io; FreeBSD Virtualization  virtualizat...@freebsd.org>; Gerd Hoffmann ; Rebecca
> Cran ; Peter Grehan 
> Subject: [edk2-devel] [PATCH v3] OvmfPkg/BhyveBhfPkg: add support for
> QemuFwCfg
> 
> From: Corvin Köhne 
> 
> QemuFwCfg is much more powerful than BhyveFwCtl. Sadly, BhyveFwCtl
> decided to use the same IO ports as QemuFwCfg. It's not possible to use
> both interfaces simultaneously. So, prefer QemuFwCfg over BhyveFwCtl.
> 
> Signed-off-by: Corvin Köhne 
> Acked-by: Gerd Hoffmann 
> Acked-by: Rebecca Cran 
> Acked-by: Peter Grehan 
> CC: Ard Biesheuvel 
> CC: Jiewen Yao 
> CC: Jordan Justen 
> CC: devel@edk2.groups.io
> CC: FreeBSD Virtualization 
> ---
>  OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf |  1 +
>  OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c | 41 -
> --
>  OvmfPkg/Bhyve/BhyveX64.dsc|  4 +--
>  3 files changed, 40 insertions(+), 6 deletions(-)
> 
> diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
> b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
> index 595fd055f9..94c65f32dc 100644
> --- a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
> +++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
> @@ -43,6 +43,7 @@
>MemoryAllocationLib
>OrderedCollectionLib
>PcdLib
> +  QemuFwCfgLib
>UefiBootServicesTableLib
>UefiDriverEntryPoint
>UefiLib
> diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c
> b/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c
> index 8e80aa33e1..e216a21bfa 100644
> --- a/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c
> +++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c
> @@ -11,6 +11,41 @@
>  #include 
>  #include 
>  #include 
> +#include  // QemuFwCfgFindFile()
> +
> +STATIC
> +EFI_STATUS
> +EFIAPI
> +BhyveGetCpuCount (
> +  OUT UINT32  *CpuCount
> +  )
> +{
> +  FIRMWARE_CONFIG_ITEM  Item;
> +  UINTN Size;
> +
> +  if (QemuFwCfgIsAvailable ()) {
> +if (EFI_ERROR (QemuFwCfgFindFile ("opt/bhyve/hw.ncpu", , ))) {
> +  return EFI_NOT_FOUND;
> +} else if (Size != sizeof (*CpuCount)) {
> +  return EFI_BAD_BUFFER_SIZE;
> +}
> +
> +QemuFwCfgSelectItem (Item);
> +QemuFwCfgReadBytes (Size, CpuCount);
> +
> +return EFI_SUCCESS;
> +  }
> +
> +  //
> +  // QemuFwCfg not available, try BhyveFwCtl.
> +  //
> +  Size = sizeof (*CpuCount);
> +  if (BhyveFwCtlGet ("hw.ncpu", CpuCount, ) == RETURN_SUCCESS) {
> +return EFI_SUCCESS;
> +  }
> +
> +  return EFI_UNSUPPORTED;
> +}
> 
>  STATIC
>  EFI_STATUS
> @@ -23,7 +58,6 @@ BhyveInstallAcpiMadtTable (
>)
>  {
>UINT32   CpuCount;
> -  UINTNcSize;
>UINTNNewBufferSize;
>EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER  *Madt;
>EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC_STRUCTURE  *LocalApic;
> @@ -36,9 +70,8 @@ BhyveInstallAcpiMadtTable (
>ASSERT (AcpiTableBufferSize >= sizeof (EFI_ACPI_DESCRIPTION_HEADER));
> 
>// Query the host for the number of vCPUs
> -  CpuCount = 0;
> -  cSize= sizeof (CpuCount);
> -  if (BhyveFwCtlGet ("hw.ncpu", , ) == RETURN_SUCCESS) {
> +  Status = BhyveGetCpuCount ();
> +  if (!EFI_ERROR (Status)) {
>  DEBUG ((DEBUG_INFO, "Retrieved CpuCount %d\n", CpuCount));
>  ASSERT (CpuCount >= 1);
>} else {
> diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
> index 5fa08bebd7..14070fd6dd 100644
> --- a/OvmfPkg/Bhyve/BhyveX64.dsc
> +++ b/OvmfPkg/Bhyve/BhyveX64.dsc
> @@ -163,8 +163,7 @@
> 
> SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/D
> xeSecurityManagementLib.inf
>UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
> 
> SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLi
> b.inf
> -  QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibNull.inf
> -
> QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNu
> ll.inf
> +  QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxeLib.inf
>BhyveFwCtlLib|OvmfPkg/Library/BhyveFwCtlLib/BhyveFwCtlLib.inf
>VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
> 
> MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptS
> evLib.inf
> @@ -355,6 +354,7 @@
>  !endif
>PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
>MpInitLib|UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.inf
> +
> QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwC
> fg.inf
> 
>  [LibraryClasses.common.UEFI_APPLICATION]
>PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
> --
> 2.11.0
> 
> Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans
> Beckhoff
> Registered office: Verl, Germany | Register